Lines Matching +full:bus +full:- +full:id
3 * Bus subsystem
22 /* contains the number the next bus should get. */
36 return sprintf(buf, "0x%03X\n", core->id.manuf); in manuf_show()
43 return sprintf(buf, "0x%03X\n", core->id.id); in id_show()
45 static DEVICE_ATTR_RO(id);
50 return sprintf(buf, "0x%02X\n", core->id.rev); in rev_show()
57 return sprintf(buf, "0x%X\n", core->id.class); in class_show()
79 static u16 bcma_cc_core_id(struct bcma_bus *bus) in bcma_cc_core_id() argument
81 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) in bcma_cc_core_id()
86 struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid, in bcma_find_core_unit() argument
91 list_for_each_entry(core, &bus->cores, list) { in bcma_find_core_unit()
92 if (core->id.id == coreid && core->core_unit == unit) in bcma_find_core_unit()
113 bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg); in bcma_wait_value()
121 if (core->io_addr) in bcma_release_core_dev()
122 iounmap(core->io_addr); in bcma_release_core_dev()
123 if (core->io_wrap) in bcma_release_core_dev()
124 iounmap(core->io_wrap); in bcma_release_core_dev()
146 if (!parent->of_node) in bcma_of_find_child_device()
149 for_each_child_of_node(parent->of_node, node) { in bcma_of_find_child_device()
153 if (of_translate_address(node, reg) == core->addr) in bcma_of_find_child_device()
166 if (core->dev.of_node) { in bcma_of_irq_parse()
167 rc = of_irq_parse_one(core->dev.of_node, num, out_irq); in bcma_of_irq_parse()
172 out_irq->np = parent->of_node; in bcma_of_irq_parse()
173 out_irq->args_count = 1; in bcma_of_irq_parse()
174 out_irq->args[0] = num; in bcma_of_irq_parse()
176 laddr[0] = cpu_to_be32(core->addr); in bcma_of_irq_parse()
186 if (!IS_ENABLED(CONFIG_OF_IRQ) || !parent->of_node) in bcma_of_get_irq()
191 bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n", in bcma_of_get_irq()
206 core->dev.of_node = node; in bcma_of_fill_device()
208 core->irq = bcma_of_get_irq(parent, core, 0); in bcma_of_fill_device()
210 of_dma_configure(&core->dev, node, false); in bcma_of_fill_device()
215 struct bcma_bus *bus = core->bus; in bcma_core_irq() local
218 switch (bus->hosttype) { in bcma_core_irq()
220 return bus->host_pci->irq; in bcma_core_irq()
222 if (bus->drv_mips.core && num == 0) { in bcma_core_irq()
226 if (bus->dev) in bcma_core_irq()
227 return bcma_of_get_irq(bus->dev, core, num); in bcma_core_irq()
237 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core) in bcma_prepare_core() argument
239 device_initialize(&core->dev); in bcma_prepare_core()
240 core->dev.release = bcma_release_core_dev; in bcma_prepare_core()
241 core->dev.bus = &bcma_bus_type; in bcma_prepare_core()
242 dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index); in bcma_prepare_core()
243 core->dev.parent = bus->dev; in bcma_prepare_core()
244 if (bus->dev) in bcma_prepare_core()
245 bcma_of_fill_device(bus->dev, core); in bcma_prepare_core()
247 switch (bus->hosttype) { in bcma_prepare_core()
249 core->dma_dev = bus->dev; in bcma_prepare_core()
250 core->irq = bus->host_pci->irq; in bcma_prepare_core()
253 if (IS_ENABLED(CONFIG_OF) && bus->dev) { in bcma_prepare_core()
254 core->dma_dev = bus->dev; in bcma_prepare_core()
256 core->dev.dma_mask = &core->dev.coherent_dma_mask; in bcma_prepare_core()
257 core->dma_dev = &core->dev; in bcma_prepare_core()
265 void bcma_init_bus(struct bcma_bus *bus) in bcma_init_bus() argument
268 bus->num = bcma_bus_next_num++; in bcma_init_bus()
271 INIT_LIST_HEAD(&bus->cores); in bcma_init_bus()
272 bus->nr_cores = 0; in bcma_init_bus()
274 bcma_detect_chip(bus); in bcma_init_bus()
277 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core) in bcma_register_core() argument
281 err = device_add(&core->dev); in bcma_register_core()
283 bcma_err(bus, "Could not register dev for core 0x%03X\n", in bcma_register_core()
284 core->id.id); in bcma_register_core()
287 core->dev_registered = true; in bcma_register_core()
290 static int bcma_register_devices(struct bcma_bus *bus) in bcma_register_devices() argument
295 list_for_each_entry(core, &bus->cores, list) { in bcma_register_devices()
297 switch (core->id.id) { in bcma_register_devices()
310 if (bcma_is_core_needed_early(core->id.id)) in bcma_register_devices()
314 if (core->id.id == BCMA_CORE_4706_MAC_GBIT && in bcma_register_devices()
315 core->core_unit > 0) in bcma_register_devices()
318 bcma_register_core(bus, core); in bcma_register_devices()
322 if (bus->drv_cc.pflash.present) { in bcma_register_devices()
325 bcma_err(bus, "Error registering parallel flash\n"); in bcma_register_devices()
330 if (bus->drv_cc.sflash.present) { in bcma_register_devices()
333 bcma_err(bus, "Error registering serial flash\n"); in bcma_register_devices()
338 if (bus->drv_cc.nflash.present) { in bcma_register_devices()
341 bcma_err(bus, "Error registering NAND flash\n"); in bcma_register_devices()
344 err = bcma_gpio_init(&bus->drv_cc); in bcma_register_devices()
345 if (err == -ENOTSUPP) in bcma_register_devices()
346 bcma_debug(bus, "GPIO driver not activated\n"); in bcma_register_devices()
348 bcma_err(bus, "Error registering GPIO driver: %i\n", err); in bcma_register_devices()
350 if (bus->hosttype == BCMA_HOSTTYPE_SOC) { in bcma_register_devices()
351 err = bcma_chipco_watchdog_register(&bus->drv_cc); in bcma_register_devices()
353 bcma_err(bus, "Error registering watchdog driver\n"); in bcma_register_devices()
359 void bcma_unregister_cores(struct bcma_bus *bus) in bcma_unregister_cores() argument
363 list_for_each_entry_safe(core, tmp, &bus->cores, list) { in bcma_unregister_cores()
364 if (!core->dev_registered) in bcma_unregister_cores()
366 list_del(&core->list); in bcma_unregister_cores()
367 device_unregister(&core->dev); in bcma_unregister_cores()
369 if (bus->hosttype == BCMA_HOSTTYPE_SOC) in bcma_unregister_cores()
370 platform_device_unregister(bus->drv_cc.watchdog); in bcma_unregister_cores()
372 /* Now noone uses internally-handled cores, we can free them */ in bcma_unregister_cores()
373 list_for_each_entry_safe(core, tmp, &bus->cores, list) { in bcma_unregister_cores()
374 list_del(&core->list); in bcma_unregister_cores()
375 put_device(&core->dev); in bcma_unregister_cores()
379 int bcma_bus_register(struct bcma_bus *bus) in bcma_bus_register() argument
385 err = bcma_bus_scan(bus); in bcma_bus_register()
387 bcma_err(bus, "Failed to scan: %d\n", err); in bcma_bus_register()
392 core = bcma_find_core(bus, bcma_cc_core_id(bus)); in bcma_bus_register()
394 bus->drv_cc.core = core; in bcma_bus_register()
395 bcma_core_chipcommon_early_init(&bus->drv_cc); in bcma_bus_register()
399 core = bcma_find_core(bus, BCMA_CORE_PCIE); in bcma_bus_register()
401 bus->drv_pci[0].core = core; in bcma_bus_register()
402 bcma_core_pci_early_init(&bus->drv_pci[0]); in bcma_bus_register()
405 if (bus->dev) in bcma_bus_register()
406 of_platform_default_populate(bus->dev->of_node, NULL, bus->dev); in bcma_bus_register()
409 list_for_each_entry(core, &bus->cores, list) { in bcma_bus_register()
410 if (bcma_is_core_needed_early(core->id.id)) in bcma_bus_register()
411 bcma_register_core(bus, core); in bcma_bus_register()
415 err = bcma_sprom_get(bus); in bcma_bus_register()
416 if (err == -ENOENT) { in bcma_bus_register()
417 bcma_err(bus, "No SPROM available\n"); in bcma_bus_register()
419 bcma_err(bus, "Failed to get SPROM: %d\n", err); in bcma_bus_register()
422 core = bcma_find_core(bus, bcma_cc_core_id(bus)); in bcma_bus_register()
424 bus->drv_cc.core = core; in bcma_bus_register()
425 bcma_core_chipcommon_init(&bus->drv_cc); in bcma_bus_register()
429 core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B); in bcma_bus_register()
431 bus->drv_cc_b.core = core; in bcma_bus_register()
432 bcma_core_chipcommon_b_init(&bus->drv_cc_b); in bcma_bus_register()
436 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); in bcma_bus_register()
438 bus->drv_mips.core = core; in bcma_bus_register()
439 bcma_core_mips_init(&bus->drv_mips); in bcma_bus_register()
443 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0); in bcma_bus_register()
445 bus->drv_pci[0].core = core; in bcma_bus_register()
446 bcma_core_pci_init(&bus->drv_pci[0]); in bcma_bus_register()
450 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1); in bcma_bus_register()
452 bus->drv_pci[1].core = core; in bcma_bus_register()
453 bcma_core_pci_init(&bus->drv_pci[1]); in bcma_bus_register()
457 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0); in bcma_bus_register()
459 bus->drv_pcie2.core = core; in bcma_bus_register()
460 bcma_core_pcie2_init(&bus->drv_pcie2); in bcma_bus_register()
464 core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); in bcma_bus_register()
466 bus->drv_gmac_cmn.core = core; in bcma_bus_register()
467 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn); in bcma_bus_register()
471 bcma_register_devices(bus); in bcma_bus_register()
473 bcma_info(bus, "Bus registered\n"); in bcma_bus_register()
478 void bcma_bus_unregister(struct bcma_bus *bus) in bcma_bus_unregister() argument
482 err = bcma_gpio_unregister(&bus->drv_cc); in bcma_bus_unregister()
483 if (err == -EBUSY) in bcma_bus_unregister()
484 bcma_err(bus, "Some GPIOs are still in use.\n"); in bcma_bus_unregister()
486 bcma_err(bus, "Can not unregister GPIO driver: %i\n", err); in bcma_bus_unregister()
488 bcma_core_chipcommon_b_free(&bus->drv_cc_b); in bcma_bus_unregister()
490 bcma_unregister_cores(bus); in bcma_bus_unregister()
494 * This is a special version of bus registration function designed for SoCs.
495 * It scans bus and performs basic initialization of main cores only.
498 int __init bcma_bus_early_register(struct bcma_bus *bus) in bcma_bus_early_register() argument
504 err = bcma_bus_scan(bus); in bcma_bus_early_register()
506 bcma_err(bus, "Failed to scan bus: %d\n", err); in bcma_bus_early_register()
507 return -1; in bcma_bus_early_register()
511 core = bcma_find_core(bus, bcma_cc_core_id(bus)); in bcma_bus_early_register()
513 bus->drv_cc.core = core; in bcma_bus_early_register()
514 bcma_core_chipcommon_early_init(&bus->drv_cc); in bcma_bus_early_register()
518 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); in bcma_bus_early_register()
520 bus->drv_mips.core = core; in bcma_bus_early_register()
521 bcma_core_mips_early_init(&bus->drv_mips); in bcma_bus_early_register()
524 bcma_info(bus, "Early bus registered\n"); in bcma_bus_early_register()
530 int bcma_bus_suspend(struct bcma_bus *bus) in bcma_bus_suspend() argument
534 list_for_each_entry(core, &bus->cores, list) { in bcma_bus_suspend()
535 struct device_driver *drv = core->dev.driver; in bcma_bus_suspend()
538 if (adrv->suspend) in bcma_bus_suspend()
539 adrv->suspend(core); in bcma_bus_suspend()
545 int bcma_bus_resume(struct bcma_bus *bus) in bcma_bus_resume() argument
550 if (bus->drv_cc.core) { in bcma_bus_resume()
551 bus->drv_cc.setup_done = false; in bcma_bus_resume()
552 bcma_core_chipcommon_init(&bus->drv_cc); in bcma_bus_resume()
555 list_for_each_entry(core, &bus->cores, list) { in bcma_bus_resume()
556 struct device_driver *drv = core->dev.driver; in bcma_bus_resume()
559 if (adrv->resume) in bcma_bus_resume()
560 adrv->resume(core); in bcma_bus_resume()
570 drv->drv.name = drv->name; in __bcma_driver_register()
571 drv->drv.bus = &bcma_bus_type; in __bcma_driver_register()
572 drv->drv.owner = owner; in __bcma_driver_register()
574 return driver_register(&drv->drv); in __bcma_driver_register()
580 driver_unregister(&drv->drv); in bcma_driver_unregister()
588 const struct bcma_device_id *cid = &core->id; in bcma_bus_match()
591 for (did = adrv->id_table; did->manuf || did->id || did->rev; did++) { in bcma_bus_match()
592 if ((did->manuf == cid->manuf || did->manuf == BCMA_ANY_MANUF) && in bcma_bus_match()
593 (did->id == cid->id || did->id == BCMA_ANY_ID) && in bcma_bus_match()
594 (did->rev == cid->rev || did->rev == BCMA_ANY_REV) && in bcma_bus_match()
595 (did->class == cid->class || did->class == BCMA_ANY_CLASS)) in bcma_bus_match()
604 struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver, in bcma_device_probe()
609 if (adrv->probe) in bcma_device_probe()
610 err = adrv->probe(core); in bcma_device_probe()
620 struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver, in bcma_device_remove()
623 if (adrv->remove) in bcma_device_remove()
624 adrv->remove(core); in bcma_device_remove()
636 core->id.manuf, core->id.id, in bcma_device_uevent()
637 core->id.rev, core->id.class); in bcma_device_uevent()
643 * If built-in, bus has to be registered early, before any driver calls