NOTE that this will change the association of /dev/occanN
with OCCAN[N] device to the same order as in hardware. This means
that if you have been useing /dev/occan0 before you have to use
/dev/occan1 on a dual OCCAN device system (this affects GR712RC).
---
 c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c | 28 +++++++++++++++--------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c 
b/c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c
index 922c43b..02aeda0 100644
--- a/c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c
+++ b/c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c
@@ -453,7 +453,11 @@ void ambapp_dev_info(
 }
 #endif
 
-/* Fix device in last stage */
+/* Fix device in last stage and/or register additional devices.
+ * Function returns:
+ *  0  Register device as normal
+ *  1  Fixup function handles registration
+ */
 static int ambapp_dev_fixup(struct drvmgr_dev *dev, struct amba_dev_info *pnp)
 {
        /* OCCAN speciality:
@@ -464,12 +468,14 @@ static int ambapp_dev_fixup(struct drvmgr_dev *dev, 
struct amba_dev_info *pnp)
         *
         *  Now, lets detect sub cores.
         */
-       if ( (pnp->info.device == GAISLER_CANAHB) && (pnp->info.vendor == 
VENDOR_GAISLER) ) {
-               struct drvmgr_dev *newdev;
+       if ( (pnp->info.device == GAISLER_CANAHB) &&
+            (pnp->info.vendor == VENDOR_GAISLER) ) {
+               struct drvmgr_dev *newdev, *devs_to_register[8];
                struct amba_dev_info *pnpinfo;
                int subcores;
                int core;
 
+               devs_to_register[0] = dev;
                subcores = (pnp->info.ahb_slv->ver & 0x7) + 1;
                for(core = 1; core < subcores; core++) {
                        drvmgr_alloc_dev(&newdev, sizeof(*pnpinfo));
@@ -480,10 +486,14 @@ static int ambapp_dev_fixup(struct drvmgr_dev *dev, 
struct amba_dev_info *pnp)
                        pnpinfo->info.irq += core;
                        newdev->businfo = (void *)pnpinfo;
 
-                       /* Register device */
-                       drvmgr_dev_register(newdev);
+                       devs_to_register[core] = newdev;
                }
-       } else if ( (pnp->info.device == GAISLER_GPIO) && (pnp->info.vendor == 
VENDOR_GAISLER) ) {
+               /* Register all CAN devices */
+               for(core = 0; core < subcores; core++)
+                       drvmgr_dev_register(devs_to_register[core]);
+               return 1;
+       } else if ( (pnp->info.device == GAISLER_GPIO) &&
+                   (pnp->info.vendor == VENDOR_GAISLER) ) {
                /* PIO[N] is connected to IRQ[N]. */
                pnp->info.irq = 0;
        }
@@ -583,10 +593,8 @@ static void ambapp_core_register(
        /* Connect device with PnP information */
        newdev->businfo = (void *)pnpinfo;
 
-       ambapp_dev_fixup(newdev, pnpinfo);
-
-       /* Register New Device */
-       drvmgr_dev_register(newdev);
+       if ( ambapp_dev_fixup(newdev, pnpinfo) == 0 )
+               drvmgr_dev_register(newdev); /* Register New Device */
 }
 
 /* Register one AMBA device */
-- 
2.7.4

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to