diff options
-rw-r--r-- | c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c | 36 |
1 files changed, 22 insertions, 14 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 007cefb9e2..7c7103112a 100644 --- a/c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c +++ b/c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c @@ -466,7 +466,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 + */ int ambapp_dev_fixup(struct drvmgr_dev *dev, struct amba_dev_info *pnp) { /* OCCAN speciality: @@ -477,12 +481,14 @@ 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)); @@ -493,10 +499,14 @@ 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; } @@ -504,11 +514,11 @@ int ambapp_dev_fixup(struct drvmgr_dev *dev, struct amba_dev_info *pnp) } struct ambapp_dev_reg_struct { - struct ambapp_bus *abus; + struct ambapp_bus *abus; struct drvmgr_bus *bus; - struct ambapp_dev *ahb_mst; - struct ambapp_dev *ahb_slv; - struct ambapp_dev *apb_slv; + struct ambapp_dev *ahb_mst; + struct ambapp_dev *ahb_slv; + struct ambapp_dev *apb_slv; }; void ambapp_core_register( @@ -596,10 +606,8 @@ 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 */ |