summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2016-03-21 13:50:27 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2016-03-21 15:03:58 +0100
commitec0db63b836bba3a07915a3e05399736dddc2a0f (patch)
tree3ab85e1b9a503f06e8d89cf474ea007b37206ee1
parenta8554e36262aa27407c0cf590addefb71b9d54d2 (diff)
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).
-rw-r--r--c/src/lib/libbsp/sparc/shared/drvmgr/ambapp_bus.c36
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 */