Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcma: use standard bus scanning during early register

Starting with kernel 3.19-rc1 early registration of bcma on MIPS is done
a bit later, with memory allocator available. This allows us to simplify
code by using standard bus scanning method.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

authored by

Rafał Miłecki and committed by
Kalle Valo
c5ed1df7 908414af

+15 -91
+1 -6
drivers/bcma/bcma_private.h
··· 28 28 void bcma_init_bus(struct bcma_bus *bus); 29 29 int bcma_bus_register(struct bcma_bus *bus); 30 30 void bcma_bus_unregister(struct bcma_bus *bus); 31 - int __init bcma_bus_early_register(struct bcma_bus *bus, 32 - struct bcma_device *core_cc, 33 - struct bcma_device *core_mips); 31 + int __init bcma_bus_early_register(struct bcma_bus *bus); 34 32 #ifdef CONFIG_PM 35 33 int bcma_bus_suspend(struct bcma_bus *bus); 36 34 int bcma_bus_resume(struct bcma_bus *bus); ··· 37 39 /* scan.c */ 38 40 void bcma_detect_chip(struct bcma_bus *bus); 39 41 int bcma_bus_scan(struct bcma_bus *bus); 40 - int __init bcma_bus_scan_early(struct bcma_bus *bus, 41 - struct bcma_device_id *match, 42 - struct bcma_device *core); 43 42 44 43 /* sprom.c */ 45 44 int bcma_sprom_get(struct bcma_bus *bus);
+1 -1
drivers/bcma/host_soc.c
··· 193 193 int err; 194 194 195 195 /* Scan bus and initialize it */ 196 - err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips); 196 + err = bcma_bus_early_register(bus); 197 197 if (err) 198 198 iounmap(bus->mmio); 199 199
+9 -24
drivers/bcma/main.c
··· 489 489 kfree(cores[0]); 490 490 } 491 491 492 - int __init bcma_bus_early_register(struct bcma_bus *bus, 493 - struct bcma_device *core_cc, 494 - struct bcma_device *core_mips) 492 + /* 493 + * This is a special version of bus registration function designed for SoCs. 494 + * It scans bus and performs basic initialization of main cores only. 495 + * Please note it requires memory allocation, however it won't try to sleep. 496 + */ 497 + int __init bcma_bus_early_register(struct bcma_bus *bus) 495 498 { 496 499 int err; 497 500 struct bcma_device *core; 498 - struct bcma_device_id match; 499 501 500 - match.manuf = BCMA_MANUF_BCM; 501 - match.id = bcma_cc_core_id(bus); 502 - match.class = BCMA_CL_SIM; 503 - match.rev = BCMA_ANY_REV; 504 - 505 - /* Scan for chip common core */ 506 - err = bcma_bus_scan_early(bus, &match, core_cc); 502 + /* Scan for devices (cores) */ 503 + err = bcma_bus_scan(bus); 507 504 if (err) { 508 - bcma_err(bus, "Failed to scan for common core: %d\n", err); 509 - return -1; 510 - } 511 - 512 - match.manuf = BCMA_MANUF_MIPS; 513 - match.id = BCMA_CORE_MIPS_74K; 514 - match.class = BCMA_CL_SIM; 515 - match.rev = BCMA_ANY_REV; 516 - 517 - /* Scan for mips core */ 518 - err = bcma_bus_scan_early(bus, &match, core_mips); 519 - if (err) { 520 - bcma_err(bus, "Failed to scan for mips core: %d\n", err); 505 + bcma_err(bus, "Failed to scan bus: %d\n", err); 521 506 return -1; 522 507 } 523 508
+4 -58
drivers/bcma/scan.c
··· 461 461 462 462 int err, core_num = 0; 463 463 464 + /* Skip if bus was already scanned (e.g. during early register) */ 465 + if (bus->nr_cores) 466 + return 0; 467 + 464 468 erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM); 465 469 if (bus->hosttype == BCMA_HOSTTYPE_SOC) { 466 470 eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE); ··· 517 513 } 518 514 519 515 err = 0; 520 - out: 521 - if (bus->hosttype == BCMA_HOSTTYPE_SOC) 522 - iounmap(eromptr); 523 - 524 - return err; 525 - } 526 - 527 - int __init bcma_bus_scan_early(struct bcma_bus *bus, 528 - struct bcma_device_id *match, 529 - struct bcma_device *core) 530 - { 531 - u32 erombase; 532 - u32 __iomem *eromptr, *eromend; 533 - 534 - int err = -ENODEV; 535 - int core_num = 0; 536 - 537 - erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM); 538 - if (bus->hosttype == BCMA_HOSTTYPE_SOC) { 539 - eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE); 540 - if (!eromptr) 541 - return -ENOMEM; 542 - } else { 543 - eromptr = bus->mmio; 544 - } 545 - 546 - eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32); 547 - 548 - bcma_scan_switch_core(bus, erombase); 549 - 550 - while (eromptr < eromend) { 551 - memset(core, 0, sizeof(*core)); 552 - INIT_LIST_HEAD(&core->list); 553 - core->bus = bus; 554 - 555 - err = bcma_get_next_core(bus, &eromptr, match, core_num, core); 556 - if (err == -ENODEV) { 557 - core_num++; 558 - continue; 559 - } else if (err == -ENXIO) 560 - continue; 561 - else if (err == -ESPIPE) 562 - break; 563 - else if (err < 0) 564 - goto out; 565 - 566 - core->core_index = core_num++; 567 - bus->nr_cores++; 568 - bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n", 569 - core->core_index, bcma_device_name(&core->id), 570 - core->id.manuf, core->id.id, core->id.rev, 571 - core->id.class); 572 - 573 - list_add_tail(&core->list, &bus->cores); 574 - err = 0; 575 - break; 576 - } 577 - 578 516 out: 579 517 if (bus->hosttype == BCMA_HOSTTYPE_SOC) 580 518 iounmap(eromptr);
-2
include/linux/bcma/bcma_soc.h
··· 5 5 6 6 struct bcma_soc { 7 7 struct bcma_bus bus; 8 - struct bcma_device core_cc; 9 - struct bcma_device core_mips; 10 8 }; 11 9 12 10 int __init bcma_host_soc_register(struct bcma_soc *soc);