aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/bcma/bcma_private.h7
-rw-r--r--drivers/bcma/host_soc.c2
-rw-r--r--drivers/bcma/main.c33
-rw-r--r--drivers/bcma/scan.c62
-rw-r--r--include/linux/bcma/bcma_soc.h2
5 files changed, 15 insertions, 91 deletions
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 59422b5fa46c..3f314c98d089 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -28,9 +28,7 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
28void bcma_init_bus(struct bcma_bus *bus); 28void bcma_init_bus(struct bcma_bus *bus);
29int bcma_bus_register(struct bcma_bus *bus); 29int bcma_bus_register(struct bcma_bus *bus);
30void bcma_bus_unregister(struct bcma_bus *bus); 30void bcma_bus_unregister(struct bcma_bus *bus);
31int __init bcma_bus_early_register(struct bcma_bus *bus, 31int __init bcma_bus_early_register(struct bcma_bus *bus);
32 struct bcma_device *core_cc,
33 struct bcma_device *core_mips);
34#ifdef CONFIG_PM 32#ifdef CONFIG_PM
35int bcma_bus_suspend(struct bcma_bus *bus); 33int bcma_bus_suspend(struct bcma_bus *bus);
36int bcma_bus_resume(struct bcma_bus *bus); 34int bcma_bus_resume(struct bcma_bus *bus);
@@ -39,9 +37,6 @@ int bcma_bus_resume(struct bcma_bus *bus);
39/* scan.c */ 37/* scan.c */
40void bcma_detect_chip(struct bcma_bus *bus); 38void bcma_detect_chip(struct bcma_bus *bus);
41int bcma_bus_scan(struct bcma_bus *bus); 39int bcma_bus_scan(struct bcma_bus *bus);
42int __init bcma_bus_scan_early(struct bcma_bus *bus,
43 struct bcma_device_id *match,
44 struct bcma_device *core);
45 40
46/* sprom.c */ 41/* sprom.c */
47int bcma_sprom_get(struct bcma_bus *bus); 42int bcma_sprom_get(struct bcma_bus *bus);
diff --git a/drivers/bcma/host_soc.c b/drivers/bcma/host_soc.c
index 335cbcfd945b..2dce34789329 100644
--- a/drivers/bcma/host_soc.c
+++ b/drivers/bcma/host_soc.c
@@ -193,7 +193,7 @@ int __init bcma_host_soc_init(struct bcma_soc *soc)
193 int err; 193 int err;
194 194
195 /* Scan bus and initialize it */ 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 if (err) 197 if (err)
198 iounmap(bus->mmio); 198 iounmap(bus->mmio);
199 199
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index c166d444fef6..c3c5e0a2d5be 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -489,35 +489,20 @@ void bcma_bus_unregister(struct bcma_bus *bus)
489 kfree(cores[0]); 489 kfree(cores[0]);
490} 490}
491 491
492int __init bcma_bus_early_register(struct bcma_bus *bus, 492/*
493 struct bcma_device *core_cc, 493 * This is a special version of bus registration function designed for SoCs.
494 struct bcma_device *core_mips) 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 */
497int __init bcma_bus_early_register(struct bcma_bus *bus)
495{ 498{
496 int err; 499 int err;
497 struct bcma_device *core; 500 struct bcma_device *core;
498 struct bcma_device_id match;
499
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);
507 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 501
517 /* Scan for mips core */ 502 /* Scan for devices (cores) */
518 err = bcma_bus_scan_early(bus, &match, core_mips); 503 err = bcma_bus_scan(bus);
519 if (err) { 504 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 return -1; 506 return -1;
522 } 507 }
523 508
diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index 5328ee5b4df0..df806b9c5490 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -461,6 +461,10 @@ int bcma_bus_scan(struct bcma_bus *bus)
461 461
462 int err, core_num = 0; 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 erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM); 468 erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
465 if (bus->hosttype == BCMA_HOSTTYPE_SOC) { 469 if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
466 eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE); 470 eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
@@ -519,61 +523,3 @@ out:
519 523
520 return err; 524 return err;
521} 525}
522
523int __init bcma_bus_scan_early(struct bcma_bus *bus,
524 struct bcma_device_id *match,
525 struct bcma_device *core)
526{
527 u32 erombase;
528 u32 __iomem *eromptr, *eromend;
529
530 int err = -ENODEV;
531 int core_num = 0;
532
533 erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
534 if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
535 eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
536 if (!eromptr)
537 return -ENOMEM;
538 } else {
539 eromptr = bus->mmio;
540 }
541
542 eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);
543
544 bcma_scan_switch_core(bus, erombase);
545
546 while (eromptr < eromend) {
547 memset(core, 0, sizeof(*core));
548 INIT_LIST_HEAD(&core->list);
549 core->bus = bus;
550
551 err = bcma_get_next_core(bus, &eromptr, match, core_num, core);
552 if (err == -ENODEV) {
553 core_num++;
554 continue;
555 } else if (err == -ENXIO)
556 continue;
557 else if (err == -ESPIPE)
558 break;
559 else if (err < 0)
560 goto out;
561
562 core->core_index = core_num++;
563 bus->nr_cores++;
564 bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
565 core->core_index, bcma_device_name(&core->id),
566 core->id.manuf, core->id.id, core->id.rev,
567 core->id.class);
568
569 list_add_tail(&core->list, &bus->cores);
570 err = 0;
571 break;
572 }
573
574out:
575 if (bus->hosttype == BCMA_HOSTTYPE_SOC)
576 iounmap(eromptr);
577
578 return err;
579}
diff --git a/include/linux/bcma/bcma_soc.h b/include/linux/bcma/bcma_soc.h
index f24d245f8394..1b5fc0c3b1b5 100644
--- a/include/linux/bcma/bcma_soc.h
+++ b/include/linux/bcma/bcma_soc.h
@@ -5,8 +5,6 @@
5 5
6struct bcma_soc { 6struct bcma_soc {
7 struct bcma_bus bus; 7 struct bcma_bus bus;
8 struct bcma_device core_cc;
9 struct bcma_device core_mips;
10}; 8};
11 9
12int __init bcma_host_soc_register(struct bcma_soc *soc); 10int __init bcma_host_soc_register(struct bcma_soc *soc);