Skip to content

Commit c5ed1df

Browse files
rmileckiKalle Valo
authored andcommitted
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 <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 908414a commit c5ed1df

File tree

5 files changed

+15
-91
lines changed

5 files changed

+15
-91
lines changed

drivers/bcma/bcma_private.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
2828
void bcma_init_bus(struct bcma_bus *bus);
2929
int bcma_bus_register(struct bcma_bus *bus);
3030
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);
3432
#ifdef CONFIG_PM
3533
int bcma_bus_suspend(struct bcma_bus *bus);
3634
int bcma_bus_resume(struct bcma_bus *bus);
@@ -39,9 +37,6 @@ int bcma_bus_resume(struct bcma_bus *bus);
3937
/* scan.c */
4038
void bcma_detect_chip(struct bcma_bus *bus);
4139
int bcma_bus_scan(struct bcma_bus *bus);
42-
int __init bcma_bus_scan_early(struct bcma_bus *bus,
43-
struct bcma_device_id *match,
44-
struct bcma_device *core);
4540

4641
/* sprom.c */
4742
int bcma_sprom_get(struct bcma_bus *bus);

drivers/bcma/host_soc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ int __init bcma_host_soc_init(struct bcma_soc *soc)
193193
int err;
194194

195195
/* 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);
197197
if (err)
198198
iounmap(bus->mmio);
199199

drivers/bcma/main.c

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -489,35 +489,20 @@ void bcma_bus_unregister(struct bcma_bus *bus)
489489
kfree(cores[0]);
490490
}
491491

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)
495498
{
496499
int err;
497500
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;
516501

517-
/* Scan for mips core */
518-
err = bcma_bus_scan_early(bus, &match, core_mips);
502+
/* Scan for devices (cores) */
503+
err = bcma_bus_scan(bus);
519504
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);
521506
return -1;
522507
}
523508

drivers/bcma/scan.c

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ int bcma_bus_scan(struct bcma_bus *bus)
461461

462462
int err, core_num = 0;
463463

464+
/* Skip if bus was already scanned (e.g. during early register) */
465+
if (bus->nr_cores)
466+
return 0;
467+
464468
erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
465469
if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
466470
eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
@@ -519,61 +523,3 @@ int bcma_bus_scan(struct bcma_bus *bus)
519523

520524
return err;
521525
}
522-
523-
int __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-
574-
out:
575-
if (bus->hosttype == BCMA_HOSTTYPE_SOC)
576-
iounmap(eromptr);
577-
578-
return err;
579-
}

include/linux/bcma/bcma_soc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
struct bcma_soc {
77
struct bcma_bus bus;
8-
struct bcma_device core_cc;
9-
struct bcma_device core_mips;
108
};
119

1210
int __init bcma_host_soc_register(struct bcma_soc *soc);

0 commit comments

Comments
 (0)