> Date: Thu, 15 Sep 2016 14:53:14 +1000
> From: Jonathan Gray <j...@jsg.id.au>
> 
> It turns out on OMAP4/OMAP5 there is a "Wake-up generator"
> interrupt controller that routes interrupts to the GIC and does power
> management comparable to imx with the i.MX6 General Power Controller
> (GPC).
> 
> / {
>     #address-cells = <0x00000001>;
>     #size-cells = <0x00000001>;
>     compatible = "ti,omap4-panda-es", "ti,omap4-panda", "ti,omap4460", 
> "ti,omap4430", "ti,omap4";
>     interrupt-parent = <0x00000001>;
>     model = "TI OMAP4 PandaBoard-ES";
> ...
> 
>     interrupt-controller@48241000 {
>         compatible = "arm,cortex-a9-gic";
>         interrupt-controller;
>         #interrupt-cells = <0x00000003>;
>         reg = <0x48241000 0x00001000 0x48240100 0x00000100>;
>         interrupt-parent = <0x00000004>;
>         linux,phandle = <0x00000004>;
>         phandle = <0x00000004>;
>     };
> 
>     interrupt-controller@48281000 {
>         compatible = "ti,omap4-wugen-mpu";
>         interrupt-controller;
>         #interrupt-cells = <0x00000003>;
>         reg = <0x48281000 0x00001000>;
>         interrupt-parent = <0x00000004>;
>         linux,phandle = <0x00000001>;
>         phandle = <0x00000001>;
>     };
> 
> Reusing the imxgpc code to handle this allows interrupts on ommc(4) with
> the pandaboard to work again and the board can now find it's root disk
> once again.

Go for it.

The wakeup issue is cited in the "Linus ARM rant" thread as a flaw of
the GIC, so we can expect this sort of wakeup interrupt controller to
appear om other "platforms" as well.  This is why we implement the
"parent" establish and disestablish functions.

> Index: omap/files.omap
> ===================================================================
> RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
> retrieving revision 1.17
> diff -u -p -r1.17 files.omap
> --- omap/files.omap   15 Aug 2016 13:42:49 -0000      1.17
> +++ omap/files.omap   15 Sep 2016 04:33:56 -0000
> @@ -42,6 +42,10 @@ device intc
>  attach intc at fdt
>  file arch/armv7/omap/intc.c                  intc
>  
> +device omwugen
> +attach omwugen at fdt
> +file arch/armv7/omap/omwugen.c               omwugen
> +
>  device gptimer
>  attach gptimer at omap
>  file arch/armv7/omap/gptimer.c               gptimer
> Index: conf/GENERIC
> ===================================================================
> RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
> retrieving revision 1.53
> diff -u -p -r1.53 GENERIC
> --- conf/GENERIC      12 Sep 2016 08:28:44 -0000      1.53
> +++ conf/GENERIC      15 Sep 2016 04:33:56 -0000
> @@ -63,6 +63,7 @@ omapid*             at omap?
>  
>  # OMAP on-chip devices
>  intc*                at fdt?                 # OMAP3 interrupt controller
> +omwugen*     at fdt?                 # Wake-up generator
>  #edma*               at omap?                # OMAP3 dma controller
>  prcm*                at omap?                # power/clock controller
>  sitaracm*    at omap?                # sitara control module
> Index: conf/RAMDISK
> ===================================================================
> RCS file: /cvs/src/sys/arch/armv7/conf/RAMDISK,v
> retrieving revision 1.48
> diff -u -p -r1.48 RAMDISK
> --- conf/RAMDISK      21 Aug 2016 06:36:23 -0000      1.48
> +++ conf/RAMDISK      15 Sep 2016 04:33:56 -0000
> @@ -61,6 +61,7 @@ omapid*             at omap?
>  
>  # OMAP on-chip devices
>  intc*                at fdt?                 # OMAP3 interrupt controller
> +omwugen*     at fdt?                 # Wake-up generator
>  #edma*               at omap?                # OMAP3 dma controller
>  prcm*                at omap?                # power/clock controller
>  sitaracm*    at omap?                # sitara control module
> --- /dev/null Thu Sep 15 14:35:46 2016
> +++ omap/omwugen.c    Thu Sep 15 14:22:00 2016
> @@ -0,0 +1,63 @@
> +/*   $OpenBSD$       */
> +/*
> + * Copyright (c) 2016 Mark Kettenis
> + *
> + * Permission to use, copy, modify, and distribute this software for any
> + * purpose with or without fee is hereby granted, provided that the above
> + * copyright notice and this permission notice appear in all copies.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> + */
> +
> +#include <sys/param.h>
> +#include <sys/systm.h>
> +#include <sys/device.h>
> +
> +#include <machine/fdt.h>
> +
> +#include <dev/ofw/openfirm.h>
> +
> +struct omwugen_softc {
> +     struct device   sc_dev;
> +     struct interrupt_controller sc_ic;
> +};
> +
> +int  omwugen_match(struct device *, void *, void *);
> +void omwugen_attach(struct device *, struct device *, void *);
> +
> +struct cfattach omwugen_ca = {
> +     sizeof(struct omwugen_softc), omwugen_match, omwugen_attach
> +};
> +
> +struct cfdriver omwugen_cd = {
> +     NULL, "omwugen", DV_DULL
> +};
> +
> +int
> +omwugen_match(struct device *parent, void *match, void *aux)
> +{
> +     struct fdt_attach_args *faa = aux;
> +
> +     return OF_is_compatible(faa->fa_node, "ti,omap4-wugen-mpu");
> +}
> +
> +void
> +omwugen_attach(struct device *parent, struct device *self, void *aux)
> +{
> +     struct fdt_attach_args *faa = aux;
> +     struct omwugen_softc *sc = (struct omwugen_softc *)self;
> +
> +     sc->sc_ic.ic_node = faa->fa_node;
> +     sc->sc_ic.ic_cookie = &sc->sc_ic;
> +     sc->sc_ic.ic_establish = arm_intr_parent_establish_fdt;
> +     sc->sc_ic.ic_disestablish = arm_intr_parent_disestablish_fdt;
> +     arm_intr_register_fdt(&sc->sc_ic);
> +
> +     printf("\n");
> +}
> 
> 

Reply via email to