summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-01-16 14:59:39 -0500
committerKalle Valo <kvalo@codeaurora.org>2015-01-23 12:44:58 -0500
commit799038ea9bbbfee240b85bcb17e487d44cdf5009 (patch)
tree8ab5ea60a4afa27cd952aa0afc58e2151f65e6bd
parent6b47aacaa4491ab04630ab0aec10d10e6ac9e14f (diff)
bcma: clean bus initialization code
This moves main bus init code to the main.c and renames old function to make its purpose clear. Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
-rw-r--r--drivers/bcma/bcma_private.h3
-rw-r--r--drivers/bcma/main.c16
-rw-r--r--drivers/bcma/scan.c5
3 files changed, 15 insertions, 9 deletions
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 314ae4032f3e..59422b5fa46c 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -25,6 +25,7 @@ struct bcma_bus;
25bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value, 25bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
26 int timeout); 26 int timeout);
27void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core); 27void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
28void bcma_init_bus(struct bcma_bus *bus);
28int bcma_bus_register(struct bcma_bus *bus); 29int bcma_bus_register(struct bcma_bus *bus);
29void bcma_bus_unregister(struct bcma_bus *bus); 30void bcma_bus_unregister(struct bcma_bus *bus);
30int __init bcma_bus_early_register(struct bcma_bus *bus, 31int __init bcma_bus_early_register(struct bcma_bus *bus,
@@ -36,11 +37,11 @@ int bcma_bus_resume(struct bcma_bus *bus);
36#endif 37#endif
37 38
38/* scan.c */ 39/* scan.c */
40void bcma_detect_chip(struct bcma_bus *bus);
39int bcma_bus_scan(struct bcma_bus *bus); 41int bcma_bus_scan(struct bcma_bus *bus);
40int __init bcma_bus_scan_early(struct bcma_bus *bus, 42int __init bcma_bus_scan_early(struct bcma_bus *bus,
41 struct bcma_device_id *match, 43 struct bcma_device_id *match,
42 struct bcma_device *core); 44 struct bcma_device *core);
43void bcma_init_bus(struct bcma_bus *bus);
44 45
45/* sprom.c */ 46/* sprom.c */
46int bcma_sprom_get(struct bcma_bus *bus); 47int bcma_sprom_get(struct bcma_bus *bus);
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 534e1337766d..c166d444fef6 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -268,6 +268,18 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
268 } 268 }
269} 269}
270 270
271void bcma_init_bus(struct bcma_bus *bus)
272{
273 mutex_lock(&bcma_buses_mutex);
274 bus->num = bcma_bus_next_num++;
275 mutex_unlock(&bcma_buses_mutex);
276
277 INIT_LIST_HEAD(&bus->cores);
278 bus->nr_cores = 0;
279
280 bcma_detect_chip(bus);
281}
282
271static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core) 283static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
272{ 284{
273 int err; 285 int err;
@@ -369,10 +381,6 @@ int bcma_bus_register(struct bcma_bus *bus)
369 int err; 381 int err;
370 struct bcma_device *core; 382 struct bcma_device *core;
371 383
372 mutex_lock(&bcma_buses_mutex);
373 bus->num = bcma_bus_next_num++;
374 mutex_unlock(&bcma_buses_mutex);
375
376 /* Scan for devices (cores) */ 384 /* Scan for devices (cores) */
377 err = bcma_bus_scan(bus); 385 err = bcma_bus_scan(bus);
378 if (err) { 386 if (err) {
diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index 917520776879..5328ee5b4df0 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -435,15 +435,12 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
435 return 0; 435 return 0;
436} 436}
437 437
438void bcma_init_bus(struct bcma_bus *bus) 438void bcma_detect_chip(struct bcma_bus *bus)
439{ 439{
440 s32 tmp; 440 s32 tmp;
441 struct bcma_chipinfo *chipinfo = &(bus->chipinfo); 441 struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
442 char chip_id[8]; 442 char chip_id[8];
443 443
444 INIT_LIST_HEAD(&bus->cores);
445 bus->nr_cores = 0;
446
447 bcma_scan_switch_core(bus, BCMA_ADDR_BASE); 444 bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
448 445
449 tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID); 446 tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);