Re: armv7/omap: attach edma at fdt, re-enable

2017-02-28 Thread Jonathan Gray
On Mon, Feb 27, 2017 at 04:16:30AM -0500, Ian Sutton wrote:
> On Mon, Feb 27, 2017 at 08:08:16PM +1100, Jonathan Gray wrote:
> > There is only one with "ti,edma3-tpcc".
> 
> Geez. It may be time to increase my font size.

This has been committed with some changes:
a nreg test at the start of attach
manual page changes
remains disabled in GENERIC as it isn't used yet
config line changed in RAMDISK as well
remains of table driven way of attaching edma removed

> 
> Index: conf/GENERIC
> ===
> RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
> retrieving revision 1.71
> diff -u -p -r1.71 GENERIC
> --- conf/GENERIC  23 Jan 2017 22:43:17 -  1.71
> +++ conf/GENERIC  27 Feb 2017 09:16:03 -
> @@ -63,7 +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
> +edma*at fdt? # OMAP3 dma controller
>  prcm*at omap?# power/clock controller
>  ompinmux*at fdt? # pin muxing
>  omdog*   at fdt? # watchdog timer
> Index: omap/edma.c
> ===
> RCS file: /cvs/src/sys/arch/armv7/omap/edma.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 edma.c
> --- omap/edma.c   22 Jan 2015 14:33:01 -  1.5
> +++ omap/edma.c   27 Feb 2017 09:16:03 -
> @@ -19,12 +19,15 @@
>  #include 
>  #include 
>  
> -#include 
> +#include 
>  
>  #include 
>  #include 
>  #include 
>  
> +#include 
> +#include 
> +
>  #define DEVNAME(s)   ((s)->sc_dev.dv_xname)
>  
>  struct edma_softc {
> @@ -78,30 +81,39 @@ struct edma_softc {
>  
>  struct edma_softc *edma_sc;
>  
> +int  edma_match(struct device *, void *, void *);
>  void edma_attach(struct device *, struct device *, void *);
>  int  edma_comp_intr(void *);
>  
>  struct cfattach edma_ca = {
> - sizeof(struct edma_softc), NULL, edma_attach
> + sizeof(struct edma_softc), edma_match, edma_attach
>  };
>  
>  struct cfdriver edma_cd = {
>   NULL, "edma", DV_DULL
>  };
>  
> +int
> +edma_match(struct device *parent, void *match, void *aux)
> +{
> + struct fdt_attach_args *faa = aux;
> +
> + return OF_is_compatible(faa->fa_node, "ti,edma3-tpcc");
> +}
> +
>  void
>  edma_attach(struct device *parent, struct device *self, void *aux)
>  {
> - struct armv7_attach_args *aa = aux;
> + struct fdt_attach_args *faa = aux;
>   struct edma_softc *sc = (struct edma_softc *)self;
>   uint32_t rev;
>   int i;
>  
> - sc->sc_iot = aa->aa_iot;
> + sc->sc_iot = faa->fa_iot;
>  
>   /* Map Base address for TPCC and TPCTX */
> - if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
> - aa->aa_dev->mem[0].size, 0, &sc->sc_tpcc)) {
> + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
> + faa->fa_reg[0].size, 0, &sc->sc_tpcc)) {
>   printf("%s: bus_space_map failed for TPCC\n", DEVNAME(sc));
>   return ;
>   }
> @@ -115,12 +127,12 @@ edma_attach(struct device *parent, struc
>  
>   /* XXX IPL_VM ? */
>   /* Enable interrupts line */
> - sc->sc_ih_comp = arm_intr_establish(aa->aa_dev->irq[0], IPL_VM,
> + sc->sc_ih_comp = arm_intr_establish_fdt(faa->fa_node, IPL_VM,
>   edma_comp_intr, sc, DEVNAME(sc));
>   if (sc->sc_ih_comp == NULL) {
>   printf("%s: unable to establish interrupt comp\n", DEVNAME(sc));
>   bus_space_unmap(sc->sc_iot, sc->sc_tpcc,
> - aa->aa_dev->mem[0].size);
> + faa->fa_reg[0].size);
>   return ;
>   }
>  
> Index: omap/files.omap
> ===
> RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
> retrieving revision 1.19
> diff -u -p -r1.19 files.omap
> --- omap/files.omap   3 Oct 2016 01:59:20 -   1.19
> +++ omap/files.omap   27 Feb 2017 09:16:03 -
> @@ -39,7 +39,7 @@ attach tiiic at fdt
>  file arch/armv7/omap/ti_iic.ctiiic
>  
>  device edma
> -attach edma at omap
> +attach edma at fdt
>  file arch/armv7/omap/edma.c  edma
>  
>  device intc
> 



Re: armv7/omap: attach edma at fdt, re-enable

2017-02-27 Thread Ian Sutton
On Mon, Feb 27, 2017 at 08:08:16PM +1100, Jonathan Gray wrote:
> There is only one with "ti,edma3-tpcc".

Geez. It may be time to increase my font size.

Index: conf/GENERIC
===
RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
retrieving revision 1.71
diff -u -p -r1.71 GENERIC
--- conf/GENERIC23 Jan 2017 22:43:17 -  1.71
+++ conf/GENERIC27 Feb 2017 09:16:03 -
@@ -63,7 +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
+edma*  at fdt? # OMAP3 dma controller
 prcm*  at omap?# power/clock controller
 ompinmux*  at fdt? # pin muxing
 omdog* at fdt? # watchdog timer
Index: omap/edma.c
===
RCS file: /cvs/src/sys/arch/armv7/omap/edma.c,v
retrieving revision 1.5
diff -u -p -r1.5 edma.c
--- omap/edma.c 22 Jan 2015 14:33:01 -  1.5
+++ omap/edma.c 27 Feb 2017 09:16:03 -
@@ -19,12 +19,15 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #define DEVNAME(s) ((s)->sc_dev.dv_xname)
 
 struct edma_softc {
@@ -78,30 +81,39 @@ struct edma_softc {
 
 struct edma_softc *edma_sc;
 
+intedma_match(struct device *, void *, void *);
 void   edma_attach(struct device *, struct device *, void *);
 intedma_comp_intr(void *);
 
 struct cfattach edma_ca = {
-   sizeof(struct edma_softc), NULL, edma_attach
+   sizeof(struct edma_softc), edma_match, edma_attach
 };
 
 struct cfdriver edma_cd = {
NULL, "edma", DV_DULL
 };
 
+int
+edma_match(struct device *parent, void *match, void *aux)
+{
+   struct fdt_attach_args *faa = aux;
+
+   return OF_is_compatible(faa->fa_node, "ti,edma3-tpcc");
+}
+
 void
 edma_attach(struct device *parent, struct device *self, void *aux)
 {
-   struct armv7_attach_args *aa = aux;
+   struct fdt_attach_args *faa = aux;
struct edma_softc *sc = (struct edma_softc *)self;
uint32_t rev;
int i;
 
-   sc->sc_iot = aa->aa_iot;
+   sc->sc_iot = faa->fa_iot;
 
/* Map Base address for TPCC and TPCTX */
-   if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
-   aa->aa_dev->mem[0].size, 0, &sc->sc_tpcc)) {
+   if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
+   faa->fa_reg[0].size, 0, &sc->sc_tpcc)) {
printf("%s: bus_space_map failed for TPCC\n", DEVNAME(sc));
return ;
}
@@ -115,12 +127,12 @@ edma_attach(struct device *parent, struc
 
/* XXX IPL_VM ? */
/* Enable interrupts line */
-   sc->sc_ih_comp = arm_intr_establish(aa->aa_dev->irq[0], IPL_VM,
+   sc->sc_ih_comp = arm_intr_establish_fdt(faa->fa_node, IPL_VM,
edma_comp_intr, sc, DEVNAME(sc));
if (sc->sc_ih_comp == NULL) {
printf("%s: unable to establish interrupt comp\n", DEVNAME(sc));
bus_space_unmap(sc->sc_iot, sc->sc_tpcc,
-   aa->aa_dev->mem[0].size);
+   faa->fa_reg[0].size);
return ;
}
 
Index: omap/files.omap
===
RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
retrieving revision 1.19
diff -u -p -r1.19 files.omap
--- omap/files.omap 3 Oct 2016 01:59:20 -   1.19
+++ omap/files.omap 27 Feb 2017 09:16:03 -
@@ -39,7 +39,7 @@ attach tiiic at fdt
 file   arch/armv7/omap/ti_iic.ctiiic
 
 device edma
-attach edma at omap
+attach edma at fdt
 file   arch/armv7/omap/edma.c  edma
 
 device intc



Re: armv7/omap: attach edma at fdt, re-enable

2017-02-27 Thread Jonathan Gray
On Mon, Feb 27, 2017 at 04:05:45AM -0500, Ian Sutton wrote:
> On Mon, Feb 27, 2017 at 07:59:07PM +1100, Jonathan Gray wrote:
> > On Mon, Feb 27, 2017 at 03:34:35AM -0500, Ian Sutton wrote:
> > > This patch changes edma(4) to attach via device tree and re-enables it.
> > 
> > Looks like the line wrapping got mangled.
> 
> Yes, I had just sent a fixed version :) oops
>  
> > I don't see the point in testing ti,hwmods in match.
> 
> There are three fdt nodes with the target 'compatible' property:

There is only one with "ti,edma3-tpcc".

> 
>   edma@4900 {
>   compatible = "ti,edma3-tpcc";
>   ti,hwmods = "tpcc";
>   reg = <0x4900 0x1>;
>   reg-names = "edma3_cc";
>   interrupts = <0xc 0xd 0xe>;
>   interrupt-names = "edma3_ccint", "edma3_mperr", 
> "edma3_ccerrint";
>   dma-requests = <0x40>;
>   #dma-cells = <0x2>;
>   ti,tptcs = <0x2a 0x7 0x2b 0x5 0x2c 0x0>;
>   ti,edma-memcpy-channels = <0x14 0x15>;
>   linux,phandle = <0x29>;
>   phandle = <0x29>;
>   };
> 
>   tptc@4980 {
>   compatible = "ti,edma3-tptc";
>   ti,hwmods = "tptc0";
>   reg = <0x4980 0x10>;
>   interrupts = <0x70>;
>   interrupt-names = "edma3_tcerrint";
>   linux,phandle = <0x2a>;
>   phandle = <0x2a>;
>   };
> 
>   tptc@4990 {
>   compatible = "ti,edma3-tptc";
>   ti,hwmods = "tptc1";
>   reg = <0x4990 0x10>;
>   interrupts = <0x71>;
>   interrupt-names = "edma3_tcerrint";
>   linux,phandle = <0x2b>;
>   phandle = <0x2b>;
>   };
> 



Re: armv7/omap: attach edma at fdt, re-enable

2017-02-27 Thread Ian Sutton
On Mon, Feb 27, 2017 at 07:59:07PM +1100, Jonathan Gray wrote:
> On Mon, Feb 27, 2017 at 03:34:35AM -0500, Ian Sutton wrote:
> > This patch changes edma(4) to attach via device tree and re-enables it.
> 
> Looks like the line wrapping got mangled.

Yes, I had just sent a fixed version :) oops
 
> I don't see the point in testing ti,hwmods in match.

There are three fdt nodes with the target 'compatible' property:

edma@4900 {
compatible = "ti,edma3-tpcc";
ti,hwmods = "tpcc";
reg = <0x4900 0x1>;
reg-names = "edma3_cc";
interrupts = <0xc 0xd 0xe>;
interrupt-names = "edma3_ccint", "edma3_mperr", 
"edma3_ccerrint";
dma-requests = <0x40>;
#dma-cells = <0x2>;
ti,tptcs = <0x2a 0x7 0x2b 0x5 0x2c 0x0>;
ti,edma-memcpy-channels = <0x14 0x15>;
linux,phandle = <0x29>;
phandle = <0x29>;
};

tptc@4980 {
compatible = "ti,edma3-tptc";
ti,hwmods = "tptc0";
reg = <0x4980 0x10>;
interrupts = <0x70>;
interrupt-names = "edma3_tcerrint";
linux,phandle = <0x2a>;
phandle = <0x2a>;
};

tptc@4990 {
compatible = "ti,edma3-tptc";
ti,hwmods = "tptc1";
reg = <0x4990 0x10>;
interrupts = <0x71>;
interrupt-names = "edma3_tcerrint";
linux,phandle = <0x2b>;
phandle = <0x2b>;
};



Re: armv7/omap: attach edma at fdt, re-enable

2017-02-27 Thread Jonathan Gray
On Mon, Feb 27, 2017 at 03:55:12AM -0500, Ian Sutton wrote:
> Previous patch was malformed, d'oh.
> 
> Index: conf/GENERIC
> ===
> RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
> retrieving revision 1.71
> diff -u -p -r1.71 GENERIC
> --- conf/GENERIC  23 Jan 2017 22:43:17 -  1.71
> +++ conf/GENERIC  27 Feb 2017 08:21:08 -
> @@ -63,7 +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
> +edma*at fdt? # OMAP3 dma controller
>  prcm*at omap?# power/clock controller
>  ompinmux*at fdt? # pin muxing
>  omdog*   at fdt? # watchdog timer
> Index: omap/edma.c
> ===
> RCS file: /cvs/src/sys/arch/armv7/omap/edma.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 edma.c
> --- omap/edma.c   22 Jan 2015 14:33:01 -  1.5
> +++ omap/edma.c   27 Feb 2017 08:21:08 -
> @@ -19,12 +19,15 @@
>  #include 
>  #include 
>  
> -#include 
> +#include 
>  
>  #include 
>  #include 
>  #include 
>  
> +#include 
> +#include 
> +
>  #define DEVNAME(s)   ((s)->sc_dev.dv_xname)
>  
>  struct edma_softc {
> @@ -78,30 +81,46 @@ struct edma_softc {
>  
>  struct edma_softc *edma_sc;
>  
> +int  edma_match(struct device *, void *, void *);
>  void edma_attach(struct device *, struct device *, void *);
>  int  edma_comp_intr(void *);
>  
>  struct cfattach edma_ca = {
> - sizeof(struct edma_softc), NULL, edma_attach
> + sizeof(struct edma_softc), edma_match, edma_attach
>  };
>  
>  struct cfdriver edma_cd = {
>   NULL, "edma", DV_DULL
>  };
>  
> +int
> +edma_match(struct device *parent, void *match, void *aux)
> +{
> + struct fdt_attach_args *faa = aux;
> + char hwmods[32];
> +
> + if (OF_is_compatible(faa->fa_node, "ti,edma3-tpcc")) {
> + OF_getprop(faa->fa_node, "ti,hwmods", &hwmods, 32);
> +
> + return !strncmp(hwmods, "tpcc", 32);
> + }
> +
> + return 0;
> +}
> +
>  void
>  edma_attach(struct device *parent, struct device *self, void *aux)
>  {
> - struct armv7_attach_args *aa = aux;
> + struct fdt_attach_args *faa = aux;
>   struct edma_softc *sc = (struct edma_softc *)self;
>   uint32_t rev;
>   int i;
>  
> - sc->sc_iot = aa->aa_iot;
> + sc->sc_iot = faa->fa_iot;
>  
>   /* Map Base address for TPCC and TPCTX */
> - if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
> - aa->aa_dev->mem[0].size, 0, &sc->sc_tpcc)) {
> + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size, 
> 0,

this exceeds 80 chars

> + &sc->sc_tpcc)) {
>   printf("%s: bus_space_map failed for TPCC\n", DEVNAME(sc));
>   return ;
>   }
> @@ -115,12 +134,12 @@ edma_attach(struct device *parent, struc
>  
>   /* XXX IPL_VM ? */
>   /* Enable interrupts line */
> - sc->sc_ih_comp = arm_intr_establish(aa->aa_dev->irq[0], IPL_VM,
> - edma_comp_intr, sc, DEVNAME(sc));
> + sc->sc_ih_comp = arm_intr_establish_fdt(faa->fa_node, IPL_VM, 
> edma_comp_intr,

as does this

> + sc, DEVNAME(sc));
>   if (sc->sc_ih_comp == NULL) {
>   printf("%s: unable to establish interrupt comp\n", DEVNAME(sc));
>   bus_space_unmap(sc->sc_iot, sc->sc_tpcc,
> - aa->aa_dev->mem[0].size);
> + faa->fa_reg[0].size);
>   return ;
>   }
>  
> Index: omap/files.omap
> ===
> RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
> retrieving revision 1.19
> diff -u -p -r1.19 files.omap
> --- omap/files.omap   3 Oct 2016 01:59:20 -   1.19
> +++ omap/files.omap   27 Feb 2017 08:21:08 -
> @@ -39,7 +39,7 @@ attach tiiic at fdt
>  file arch/armv7/omap/ti_iic.ctiiic
>  
>  device edma
> -attach edma at omap
> +attach edma at fdt
>  file arch/armv7/omap/edma.c  edma
>  
>  device intc
> 



Re: armv7/omap: attach edma at fdt, re-enable

2017-02-27 Thread Jonathan Gray
On Mon, Feb 27, 2017 at 03:34:35AM -0500, Ian Sutton wrote:
> This patch changes edma(4) to attach via device tree and re-enables it.

Looks like the line wrapping got mangled.

I don't see the point in testing ti,hwmods in match.

> 
> 
> Index: conf/GENERIC
> ===
> RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
> retrieving revision 1.71
> diff -u -p -r1.71 GENERIC
> --- conf/GENERIC  23 Jan 2017 22:43:17 -  1.71
> +++ conf/GENERIC  27 Feb 2017 08:21:08 -
> @@ -63,7 +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
> +edma*at fdt? # OMAP3 dma controller
>  prcm*at omap?# power/clock controller
>  ompinmux*at fdt? # pin muxing
>  omdog*   at fdt? # watchdog timer
> Index: omap/edma.c
> ===
> RCS file: /cvs/src/sys/arch/armv7/omap/edma.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 edma.c
> --- omap/edma.c   22 Jan 2015 14:33:01 -  1.5
> +++ omap/edma.c   27 Feb 2017 08:21:08 -
> @@ -19,12 +19,15 @@
>  #include 
>  #include 
>  
> -#include 
> +#include 
>  
>  #include 
>  #include 
>  #include 
>  
> +#include 
> +#include 
> +
>  #define DEVNAME(s)   ((s)->sc_dev.dv_xname)
>  
>  struct edma_softc {
> @@ -78,30 +81,46 @@ struct edma_softc {
>  
>  struct edma_softc *edma_sc;
>  
> +int  edma_match(struct device *, void *, void *);
>  void edma_attach(struct device *, struct device *, void *);
>  int  edma_comp_intr(void *);
>  
>  struct cfattach edma_ca = {
> - sizeof(struct edma_softc), NULL, edma_attach
> + sizeof(struct edma_softc), edma_match, edma_attach
>  };
>  
>  struct cfdriver edma_cd = {
>   NULL, "edma", DV_DULL
>  };
>  
> +int
> +edma_match(struct device *parent, void *match, void *aux)
> +{
> + struct fdt_attach_args *faa = aux;
> + char hwmods[32];
> +
> + if (OF_is_compatible(faa->fa_node, "ti,edma3-tpcc")) {
> + OF_getprop(faa->fa_node, "ti,hwmods", &hwmods, 32);
> +
> + return !strncmp(hwmods, "tpcc", 32);
> + }
> +
> + return 0;
> +}
> +
>  void
>  edma_attach(struct device *parent, struct device *self, void *aux)
>  {
> - struct armv7_attach_args *aa = aux;
> + struct fdt_attach_args *faa = aux;
>   struct edma_softc *sc = (struct edma_softc *)self;
>   uint32_t rev;
>   int i;
>  
> - sc->sc_iot = aa->aa_iot;
> + sc->sc_iot = faa->fa_iot;
>  
>   /* Map Base address for TPCC and TPCTX */
> - if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
> - aa->aa_dev->mem[0].size, 0, &sc->sc_tpcc)) {
> + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
> faa->fa_reg[0].size, 0,
> + &sc->sc_tpcc)) {
>   printf("%s: bus_space_map failed for TPCC\n",
> DEVNAME(sc));
>   return ;
>   }
> @@ -115,12 +134,12 @@ edma_attach(struct device *parent, struc
>  
>   /* XXX IPL_VM ? */
>   /* Enable interrupts line */
> - sc->sc_ih_comp = arm_intr_establish(aa->aa_dev->irq[0], IPL_VM,
> - edma_comp_intr, sc, DEVNAME(sc));
> + sc->sc_ih_comp = arm_intr_establish_fdt(faa->fa_node, IPL_VM,
> edma_comp_intr,
> + sc, DEVNAME(sc));
>   if (sc->sc_ih_comp == NULL) {
>   printf("%s: unable to establish interrupt comp\n",
> DEVNAME(sc));
>   bus_space_unmap(sc->sc_iot, sc->sc_tpcc,
> - aa->aa_dev->mem[0].size);
> + faa->fa_reg[0].size);
>   return ;
>   }
>  
> Index: omap/files.omap
> ===
> RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
> retrieving revision 1.19
> diff -u -p -r1.19 files.omap
> --- omap/files.omap   3 Oct 2016 01:59:20 -   1.19
> +++ omap/files.omap   27 Feb 2017 08:21:08 -
> @@ -39,7 +39,7 @@ attach tiiic at fdt
>  file arch/armv7/omap/ti_iic.ctiiic
>  
>  device edma
> -attach edma at omap
> +attach edma at fdt
>  file arch/armv7/omap/edma.c  edma
>  
>  device intc
> 



Re: armv7/omap: attach edma at fdt, re-enable

2017-02-27 Thread Ian Sutton
Previous patch was malformed, d'oh.

Index: conf/GENERIC
===
RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
retrieving revision 1.71
diff -u -p -r1.71 GENERIC
--- conf/GENERIC23 Jan 2017 22:43:17 -  1.71
+++ conf/GENERIC27 Feb 2017 08:21:08 -
@@ -63,7 +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
+edma*  at fdt? # OMAP3 dma controller
 prcm*  at omap?# power/clock controller
 ompinmux*  at fdt? # pin muxing
 omdog* at fdt? # watchdog timer
Index: omap/edma.c
===
RCS file: /cvs/src/sys/arch/armv7/omap/edma.c,v
retrieving revision 1.5
diff -u -p -r1.5 edma.c
--- omap/edma.c 22 Jan 2015 14:33:01 -  1.5
+++ omap/edma.c 27 Feb 2017 08:21:08 -
@@ -19,12 +19,15 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #define DEVNAME(s) ((s)->sc_dev.dv_xname)
 
 struct edma_softc {
@@ -78,30 +81,46 @@ struct edma_softc {
 
 struct edma_softc *edma_sc;
 
+intedma_match(struct device *, void *, void *);
 void   edma_attach(struct device *, struct device *, void *);
 intedma_comp_intr(void *);
 
 struct cfattach edma_ca = {
-   sizeof(struct edma_softc), NULL, edma_attach
+   sizeof(struct edma_softc), edma_match, edma_attach
 };
 
 struct cfdriver edma_cd = {
NULL, "edma", DV_DULL
 };
 
+int
+edma_match(struct device *parent, void *match, void *aux)
+{
+   struct fdt_attach_args *faa = aux;
+   char hwmods[32];
+
+   if (OF_is_compatible(faa->fa_node, "ti,edma3-tpcc")) {
+   OF_getprop(faa->fa_node, "ti,hwmods", &hwmods, 32);
+
+   return !strncmp(hwmods, "tpcc", 32);
+   }
+
+   return 0;
+}
+
 void
 edma_attach(struct device *parent, struct device *self, void *aux)
 {
-   struct armv7_attach_args *aa = aux;
+   struct fdt_attach_args *faa = aux;
struct edma_softc *sc = (struct edma_softc *)self;
uint32_t rev;
int i;
 
-   sc->sc_iot = aa->aa_iot;
+   sc->sc_iot = faa->fa_iot;
 
/* Map Base address for TPCC and TPCTX */
-   if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
-   aa->aa_dev->mem[0].size, 0, &sc->sc_tpcc)) {
+   if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size, 
0,
+   &sc->sc_tpcc)) {
printf("%s: bus_space_map failed for TPCC\n", DEVNAME(sc));
return ;
}
@@ -115,12 +134,12 @@ edma_attach(struct device *parent, struc
 
/* XXX IPL_VM ? */
/* Enable interrupts line */
-   sc->sc_ih_comp = arm_intr_establish(aa->aa_dev->irq[0], IPL_VM,
-   edma_comp_intr, sc, DEVNAME(sc));
+   sc->sc_ih_comp = arm_intr_establish_fdt(faa->fa_node, IPL_VM, 
edma_comp_intr,
+   sc, DEVNAME(sc));
if (sc->sc_ih_comp == NULL) {
printf("%s: unable to establish interrupt comp\n", DEVNAME(sc));
bus_space_unmap(sc->sc_iot, sc->sc_tpcc,
-   aa->aa_dev->mem[0].size);
+   faa->fa_reg[0].size);
return ;
}
 
Index: omap/files.omap
===
RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
retrieving revision 1.19
diff -u -p -r1.19 files.omap
--- omap/files.omap 3 Oct 2016 01:59:20 -   1.19
+++ omap/files.omap 27 Feb 2017 08:21:08 -
@@ -39,7 +39,7 @@ attach tiiic at fdt
 file   arch/armv7/omap/ti_iic.ctiiic
 
 device edma
-attach edma at omap
+attach edma at fdt
 file   arch/armv7/omap/edma.c  edma
 
 device intc



armv7/omap: attach edma at fdt, re-enable

2017-02-27 Thread Ian Sutton
This patch changes edma(4) to attach via device tree and re-enables it.


Index: conf/GENERIC
===
RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v
retrieving revision 1.71
diff -u -p -r1.71 GENERIC
--- conf/GENERIC23 Jan 2017 22:43:17 -  1.71
+++ conf/GENERIC27 Feb 2017 08:21:08 -
@@ -63,7 +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
+edma*  at fdt? # OMAP3 dma controller
 prcm*  at omap?# power/clock controller
 ompinmux*  at fdt? # pin muxing
 omdog* at fdt? # watchdog timer
Index: omap/edma.c
===
RCS file: /cvs/src/sys/arch/armv7/omap/edma.c,v
retrieving revision 1.5
diff -u -p -r1.5 edma.c
--- omap/edma.c 22 Jan 2015 14:33:01 -  1.5
+++ omap/edma.c 27 Feb 2017 08:21:08 -
@@ -19,12 +19,15 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #define DEVNAME(s) ((s)->sc_dev.dv_xname)
 
 struct edma_softc {
@@ -78,30 +81,46 @@ struct edma_softc {
 
 struct edma_softc *edma_sc;
 
+intedma_match(struct device *, void *, void *);
 void   edma_attach(struct device *, struct device *, void *);
 intedma_comp_intr(void *);
 
 struct cfattach edma_ca = {
-   sizeof(struct edma_softc), NULL, edma_attach
+   sizeof(struct edma_softc), edma_match, edma_attach
 };
 
 struct cfdriver edma_cd = {
NULL, "edma", DV_DULL
 };
 
+int
+edma_match(struct device *parent, void *match, void *aux)
+{
+   struct fdt_attach_args *faa = aux;
+   char hwmods[32];
+
+   if (OF_is_compatible(faa->fa_node, "ti,edma3-tpcc")) {
+   OF_getprop(faa->fa_node, "ti,hwmods", &hwmods, 32);
+
+   return !strncmp(hwmods, "tpcc", 32);
+   }
+
+   return 0;
+}
+
 void
 edma_attach(struct device *parent, struct device *self, void *aux)
 {
-   struct armv7_attach_args *aa = aux;
+   struct fdt_attach_args *faa = aux;
struct edma_softc *sc = (struct edma_softc *)self;
uint32_t rev;
int i;
 
-   sc->sc_iot = aa->aa_iot;
+   sc->sc_iot = faa->fa_iot;
 
/* Map Base address for TPCC and TPCTX */
-   if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
-   aa->aa_dev->mem[0].size, 0, &sc->sc_tpcc)) {
+   if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
faa->fa_reg[0].size, 0,
+   &sc->sc_tpcc)) {
printf("%s: bus_space_map failed for TPCC\n",
DEVNAME(sc));
return ;
}
@@ -115,12 +134,12 @@ edma_attach(struct device *parent, struc
 
/* XXX IPL_VM ? */
/* Enable interrupts line */
-   sc->sc_ih_comp = arm_intr_establish(aa->aa_dev->irq[0], IPL_VM,
-   edma_comp_intr, sc, DEVNAME(sc));
+   sc->sc_ih_comp = arm_intr_establish_fdt(faa->fa_node, IPL_VM,
edma_comp_intr,
+   sc, DEVNAME(sc));
if (sc->sc_ih_comp == NULL) {
printf("%s: unable to establish interrupt comp\n",
DEVNAME(sc));
bus_space_unmap(sc->sc_iot, sc->sc_tpcc,
-   aa->aa_dev->mem[0].size);
+   faa->fa_reg[0].size);
return ;
}
 
Index: omap/files.omap
===
RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
retrieving revision 1.19
diff -u -p -r1.19 files.omap
--- omap/files.omap 3 Oct 2016 01:59:20 -   1.19
+++ omap/files.omap 27 Feb 2017 08:21:08 -
@@ -39,7 +39,7 @@ attach tiiic at fdt
 file   arch/armv7/omap/ti_iic.ctiiic
 
 device edma
-attach edma at omap
+attach edma at fdt
 file   arch/armv7/omap/edma.c  edma
 
 device intc