staticvoid bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
{ int err;
err = device_add(&core->dev); if (err) {
bcma_err(bus, "Could not register dev for core 0x%03X\n",
core->id.id); return;
}
core->dev_registered = true;
}
staticint bcma_register_devices(struct bcma_bus *bus)
{ struct bcma_device *core; int err;
list_for_each_entry(core, &bus->cores, list) { /* We support that core ourselves */ switch (core->id.id) { case BCMA_CORE_4706_CHIPCOMMON: case BCMA_CORE_CHIPCOMMON: case BCMA_CORE_NS_CHIPCOMMON_B: case BCMA_CORE_PCI: case BCMA_CORE_PCIE: case BCMA_CORE_PCIE2: case BCMA_CORE_MIPS_74K: case BCMA_CORE_4706_MAC_GBIT_COMMON: continue;
}
/* Early cores were already registered */ if (bcma_is_core_needed_early(core->id.id)) continue;
/* Only first GMAC core on BCM4706 is connected and working */ if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
core->core_unit > 0) continue;
bcma_register_core(bus, core);
}
#ifdef CONFIG_BCMA_PFLASH if (bus->drv_cc.pflash.present) {
err = platform_device_register(&bcma_pflash_dev); if (err)
bcma_err(bus, "Error registering parallel flash\n");
} #endif
#ifdef CONFIG_BCMA_SFLASH if (bus->drv_cc.sflash.present) {
err = platform_device_register(&bcma_sflash_dev); if (err)
bcma_err(bus, "Error registering serial flash\n");
} #endif
list_for_each_entry_safe(core, tmp, &bus->cores, list) { if (!core->dev_registered) continue;
list_del(&core->list);
device_unregister(&core->dev);
} if (bus->hosttype == BCMA_HOSTTYPE_SOC)
platform_device_unregister(bus->drv_cc.watchdog);
/* Now no one uses internally-handled cores, we can free them */
list_for_each_entry_safe(core, tmp, &bus->cores, list) {
list_del(&core->list);
put_device(&core->dev);
}
}
int bcma_bus_register(struct bcma_bus *bus)
{ int err; struct bcma_device *core;
/* Scan for devices (cores) */
err = bcma_bus_scan(bus); if (err) {
bcma_err(bus, "Failed to scan: %d\n", err); return err;
}
/* Early init CC core */
core = bcma_find_core(bus, bcma_cc_core_id(bus)); if (core) {
bus->drv_cc.core = core;
bcma_core_chipcommon_early_init(&bus->drv_cc);
}
/* Early init PCIE core */
core = bcma_find_core(bus, BCMA_CORE_PCIE); if (core) {
bus->drv_pci[0].core = core;
bcma_core_pci_early_init(&bus->drv_pci[0]);
}
if (bus->dev)
of_platform_default_populate(bus->dev->of_node, NULL, bus->dev);
/* Cores providing flash access go before SPROM init */
list_for_each_entry(core, &bus->cores, list) { if (bcma_is_core_needed_early(core->id.id))
bcma_register_core(bus, core);
}
/* Try to get SPROM */
err = bcma_sprom_get(bus); if (err == -ENOENT) {
bcma_err(bus, "No SPROM available\n");
} elseif (err)
bcma_err(bus, "Failed to get SPROM: %d\n", err);
/* Init CC core */
core = bcma_find_core(bus, bcma_cc_core_id(bus)); if (core) {
bus->drv_cc.core = core;
bcma_core_chipcommon_init(&bus->drv_cc);
}
/* Init CC core */
core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B); if (core) {
bus->drv_cc_b.core = core;
bcma_core_chipcommon_b_init(&bus->drv_cc_b);
}
/* Init PCIe Gen 2 core */
core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0); if (core) {
bus->drv_pcie2.core = core;
bcma_core_pcie2_init(&bus->drv_pcie2);
}
/* Init GBIT MAC COMMON core */
core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); if (core) {
bus->drv_gmac_cmn.core = core;
bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
}
/* Register found cores */
bcma_register_devices(bus);
bcma_info(bus, "Bus registered\n");
return 0;
}
void bcma_bus_unregister(struct bcma_bus *bus)
{ int err;
err = bcma_gpio_unregister(&bus->drv_cc); if (err == -EBUSY)
bcma_err(bus, "Some GPIOs are still in use.\n"); elseif (err)
bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
bcma_core_chipcommon_b_free(&bus->drv_cc_b);
bcma_unregister_cores(bus);
}
/* * This is a special version of bus registration function designed for SoCs. * It scans bus and performs basic initialization of main cores only. * Please note it requires memory allocation, however it won't try to sleep.
*/ int __init bcma_bus_early_register(struct bcma_bus *bus)
{ int err; struct bcma_device *core;
/* Scan for devices (cores) */
err = bcma_bus_scan(bus); if (err) {
bcma_err(bus, "Failed to scan bus: %d\n", err); return -1;
}
/* Early init CC core */
core = bcma_find_core(bus, bcma_cc_core_id(bus)); if (core) {
bus->drv_cc.core = core;
bcma_core_chipcommon_early_init(&bus->drv_cc);
}
/* Early init MIPS core */
core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); if (core) {
bus->drv_mips.core = core;
bcma_core_mips_early_init(&bus->drv_mips);
}
bcma_info(bus, "Early bus registered\n");
return 0;
}
#ifdef CONFIG_PM int bcma_bus_suspend(struct bcma_bus *bus)
{ struct bcma_device *core;
/* * If built-in, bus has to be registered early, before any driver calls * bcma_driver_register. * Otherwise registering driver would trigger BUG in driver_register.
*/ staticint __init bcma_init_bus_register(void)
{ int err;
if (bcma_bus_registered) return 0;
err = bus_register(&bcma_bus_type); if (!err)
bcma_bus_registered = 1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.