summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2016-03-21 13:50:27 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2017-03-06 07:54:55 +0100
commitb109add5b2d721d2c4a16eed4d221bd1f45c6eca (patch)
tree901a09e310129c8421df3e911a7b1f02a380a46f /c
parentleon, grspw_pkt: Preserve DMA address enable at start. (diff)
downloadrtems-b109add5b2d721d2c4a16eed4d221bd1f45c6eca.tar.bz2
leon: Fix ambapp_bus OCCAN device registeration order
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).
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c28
1 files 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 922c43b5a5..02aeda0dc9 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 */