Lines Matching refs:bus
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()
113 bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg); in bcma_wait_value()
192 bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n", in bcma_of_get_irq()
225 struct bcma_bus *bus = core->bus; in bcma_core_irq() local
228 switch (bus->hosttype) { in bcma_core_irq()
230 return bus->host_pci->irq; in bcma_core_irq()
232 if (bus->drv_mips.core && num == 0) { in bcma_core_irq()
236 if (bus->host_pdev) in bcma_core_irq()
237 return bcma_of_get_irq(bus->host_pdev, core, num); in bcma_core_irq()
247 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core) in bcma_prepare_core() argument
250 core->dev.bus = &bcma_bus_type; in bcma_prepare_core()
251 dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index); in bcma_prepare_core()
253 switch (bus->hosttype) { in bcma_prepare_core()
255 core->dev.parent = &bus->host_pci->dev; in bcma_prepare_core()
256 core->dma_dev = &bus->host_pci->dev; in bcma_prepare_core()
257 core->irq = bus->host_pci->irq; in bcma_prepare_core()
261 if (bus->host_pdev) { in bcma_prepare_core()
262 core->dma_dev = &bus->host_pdev->dev; in bcma_prepare_core()
263 core->dev.parent = &bus->host_pdev->dev; in bcma_prepare_core()
264 bcma_of_fill_device(bus->host_pdev, core); in bcma_prepare_core()
274 struct device *bcma_bus_get_host_dev(struct bcma_bus *bus) in bcma_bus_get_host_dev() argument
276 switch (bus->hosttype) { in bcma_bus_get_host_dev()
278 if (bus->host_pci) in bcma_bus_get_host_dev()
279 return &bus->host_pci->dev; in bcma_bus_get_host_dev()
283 if (bus->host_pdev) in bcma_bus_get_host_dev()
284 return &bus->host_pdev->dev; in bcma_bus_get_host_dev()
288 if (bus->host_sdio) in bcma_bus_get_host_dev()
289 return &bus->host_sdio->dev; in bcma_bus_get_host_dev()
296 void bcma_init_bus(struct bcma_bus *bus) in bcma_init_bus() argument
299 bus->num = bcma_bus_next_num++; in bcma_init_bus()
302 INIT_LIST_HEAD(&bus->cores); in bcma_init_bus()
303 bus->nr_cores = 0; in bcma_init_bus()
305 bcma_detect_chip(bus); in bcma_init_bus()
308 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core) in bcma_register_core() argument
314 bcma_err(bus, "Could not register dev for core 0x%03X\n", in bcma_register_core()
322 static int bcma_register_devices(struct bcma_bus *bus) in bcma_register_devices() argument
327 list_for_each_entry(core, &bus->cores, list) { in bcma_register_devices()
350 bcma_register_core(bus, core); in bcma_register_devices()
354 if (bus->drv_cc.pflash.present) { in bcma_register_devices()
357 bcma_err(bus, "Error registering parallel flash\n"); in bcma_register_devices()
362 if (bus->drv_cc.sflash.present) { in bcma_register_devices()
365 bcma_err(bus, "Error registering serial flash\n"); in bcma_register_devices()
370 if (bus->drv_cc.nflash.present) { in bcma_register_devices()
373 bcma_err(bus, "Error registering NAND flash\n"); in bcma_register_devices()
376 err = bcma_gpio_init(&bus->drv_cc); in bcma_register_devices()
378 bcma_debug(bus, "GPIO driver not activated\n"); in bcma_register_devices()
380 bcma_err(bus, "Error registering GPIO driver: %i\n", err); in bcma_register_devices()
382 if (bus->hosttype == BCMA_HOSTTYPE_SOC) { in bcma_register_devices()
383 err = bcma_chipco_watchdog_register(&bus->drv_cc); in bcma_register_devices()
385 bcma_err(bus, "Error registering watchdog driver\n"); in bcma_register_devices()
391 void bcma_unregister_cores(struct bcma_bus *bus) in bcma_unregister_cores() argument
395 list_for_each_entry_safe(core, tmp, &bus->cores, list) { in bcma_unregister_cores()
401 if (bus->hosttype == BCMA_HOSTTYPE_SOC) in bcma_unregister_cores()
402 platform_device_unregister(bus->drv_cc.watchdog); in bcma_unregister_cores()
405 list_for_each_entry_safe(core, tmp, &bus->cores, list) { in bcma_unregister_cores()
411 int bcma_bus_register(struct bcma_bus *bus) in bcma_bus_register() argument
418 err = bcma_bus_scan(bus); in bcma_bus_register()
420 bcma_err(bus, "Failed to scan: %d\n", err); in bcma_bus_register()
425 core = bcma_find_core(bus, bcma_cc_core_id(bus)); in bcma_bus_register()
427 bus->drv_cc.core = core; in bcma_bus_register()
428 bcma_core_chipcommon_early_init(&bus->drv_cc); in bcma_bus_register()
432 core = bcma_find_core(bus, BCMA_CORE_PCIE); in bcma_bus_register()
434 bus->drv_pci[0].core = core; in bcma_bus_register()
435 bcma_core_pci_early_init(&bus->drv_pci[0]); in bcma_bus_register()
438 dev = bcma_bus_get_host_dev(bus); in bcma_bus_register()
444 list_for_each_entry(core, &bus->cores, list) { in bcma_bus_register()
446 bcma_register_core(bus, core); in bcma_bus_register()
450 err = bcma_sprom_get(bus); in bcma_bus_register()
452 bcma_err(bus, "No SPROM available\n"); in bcma_bus_register()
454 bcma_err(bus, "Failed to get SPROM: %d\n", err); in bcma_bus_register()
457 core = bcma_find_core(bus, bcma_cc_core_id(bus)); in bcma_bus_register()
459 bus->drv_cc.core = core; in bcma_bus_register()
460 bcma_core_chipcommon_init(&bus->drv_cc); in bcma_bus_register()
464 core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B); in bcma_bus_register()
466 bus->drv_cc_b.core = core; in bcma_bus_register()
467 bcma_core_chipcommon_b_init(&bus->drv_cc_b); in bcma_bus_register()
471 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); in bcma_bus_register()
473 bus->drv_mips.core = core; in bcma_bus_register()
474 bcma_core_mips_init(&bus->drv_mips); in bcma_bus_register()
478 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0); in bcma_bus_register()
480 bus->drv_pci[0].core = core; in bcma_bus_register()
481 bcma_core_pci_init(&bus->drv_pci[0]); in bcma_bus_register()
485 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1); in bcma_bus_register()
487 bus->drv_pci[1].core = core; in bcma_bus_register()
488 bcma_core_pci_init(&bus->drv_pci[1]); in bcma_bus_register()
492 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0); in bcma_bus_register()
494 bus->drv_pcie2.core = core; in bcma_bus_register()
495 bcma_core_pcie2_init(&bus->drv_pcie2); in bcma_bus_register()
499 core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); in bcma_bus_register()
501 bus->drv_gmac_cmn.core = core; in bcma_bus_register()
502 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn); in bcma_bus_register()
506 bcma_register_devices(bus); in bcma_bus_register()
508 bcma_info(bus, "Bus registered\n"); in bcma_bus_register()
513 void bcma_bus_unregister(struct bcma_bus *bus) in bcma_bus_unregister() argument
517 err = bcma_gpio_unregister(&bus->drv_cc); in bcma_bus_unregister()
519 bcma_err(bus, "Some GPIOs are still in use.\n"); in bcma_bus_unregister()
521 bcma_err(bus, "Can not unregister GPIO driver: %i\n", err); in bcma_bus_unregister()
523 bcma_core_chipcommon_b_free(&bus->drv_cc_b); in bcma_bus_unregister()
525 bcma_unregister_cores(bus); in bcma_bus_unregister()
533 int __init bcma_bus_early_register(struct bcma_bus *bus) in bcma_bus_early_register() argument
539 err = bcma_bus_scan(bus); in bcma_bus_early_register()
541 bcma_err(bus, "Failed to scan bus: %d\n", err); in bcma_bus_early_register()
546 core = bcma_find_core(bus, bcma_cc_core_id(bus)); in bcma_bus_early_register()
548 bus->drv_cc.core = core; in bcma_bus_early_register()
549 bcma_core_chipcommon_early_init(&bus->drv_cc); in bcma_bus_early_register()
553 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); in bcma_bus_early_register()
555 bus->drv_mips.core = core; in bcma_bus_early_register()
556 bcma_core_mips_early_init(&bus->drv_mips); in bcma_bus_early_register()
559 bcma_info(bus, "Early bus registered\n"); in bcma_bus_early_register()
565 int bcma_bus_suspend(struct bcma_bus *bus) in bcma_bus_suspend() argument
569 list_for_each_entry(core, &bus->cores, list) { in bcma_bus_suspend()
580 int bcma_bus_resume(struct bcma_bus *bus) in bcma_bus_resume() argument
585 if (bus->drv_cc.core) { in bcma_bus_resume()
586 bus->drv_cc.setup_done = false; in bcma_bus_resume()
587 bcma_core_chipcommon_init(&bus->drv_cc); in bcma_bus_resume()
590 list_for_each_entry(core, &bus->cores, list) { in bcma_bus_resume()
606 drv->drv.bus = &bcma_bus_type; in __bcma_driver_register()