Skip to content

Commit

Permalink
bcma: use standard bus scanning during early register
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafał Miłecki authored and Kalle Valo committed Jan 23, 2015
1 parent 908414a commit c5ed1df
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 91 deletions.
7 changes: 1 addition & 6 deletions drivers/bcma/bcma_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
void bcma_init_bus(struct bcma_bus *bus);
int bcma_bus_register(struct bcma_bus *bus);
void bcma_bus_unregister(struct bcma_bus *bus);
int __init bcma_bus_early_register(struct bcma_bus *bus,
struct bcma_device *core_cc,
struct bcma_device *core_mips);
int __init bcma_bus_early_register(struct bcma_bus *bus);
#ifdef CONFIG_PM
int bcma_bus_suspend(struct bcma_bus *bus);
int bcma_bus_resume(struct bcma_bus *bus);
Expand All @@ -39,9 +37,6 @@ int bcma_bus_resume(struct bcma_bus *bus);
/* scan.c */
void bcma_detect_chip(struct bcma_bus *bus);
int bcma_bus_scan(struct bcma_bus *bus);
int __init bcma_bus_scan_early(struct bcma_bus *bus,
struct bcma_device_id *match,
struct bcma_device *core);

/* sprom.c */
int bcma_sprom_get(struct bcma_bus *bus);
Expand Down
2 changes: 1 addition & 1 deletion drivers/bcma/host_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int __init bcma_host_soc_init(struct bcma_soc *soc)
int err;

/* Scan bus and initialize it */
err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
err = bcma_bus_early_register(bus);
if (err)
iounmap(bus->mmio);

Expand Down
33 changes: 9 additions & 24 deletions drivers/bcma/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,35 +489,20 @@ void bcma_bus_unregister(struct bcma_bus *bus)
kfree(cores[0]);
}

int __init bcma_bus_early_register(struct bcma_bus *bus,
struct bcma_device *core_cc,
struct bcma_device *core_mips)
/*
* This is a special version of bus registration function designed for SoCs.
* It scans bus and performs basic initialization of main cores only.
* Please note it requires memory allocation, however it won't try to sleep.
*/
int __init bcma_bus_early_register(struct bcma_bus *bus)
{
int err;
struct bcma_device *core;
struct bcma_device_id match;

match.manuf = BCMA_MANUF_BCM;
match.id = bcma_cc_core_id(bus);
match.class = BCMA_CL_SIM;
match.rev = BCMA_ANY_REV;

/* Scan for chip common core */
err = bcma_bus_scan_early(bus, &match, core_cc);
if (err) {
bcma_err(bus, "Failed to scan for common core: %d\n", err);
return -1;
}

match.manuf = BCMA_MANUF_MIPS;
match.id = BCMA_CORE_MIPS_74K;
match.class = BCMA_CL_SIM;
match.rev = BCMA_ANY_REV;

/* Scan for mips core */
err = bcma_bus_scan_early(bus, &match, core_mips);
/* Scan for devices (cores) */
err = bcma_bus_scan(bus);
if (err) {
bcma_err(bus, "Failed to scan for mips core: %d\n", err);
bcma_err(bus, "Failed to scan bus: %d\n", err);
return -1;
}

Expand Down
62 changes: 4 additions & 58 deletions drivers/bcma/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ int bcma_bus_scan(struct bcma_bus *bus)

int err, core_num = 0;

/* Skip if bus was already scanned (e.g. during early register) */
if (bus->nr_cores)
return 0;

erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
Expand Down Expand Up @@ -519,61 +523,3 @@ int bcma_bus_scan(struct bcma_bus *bus)

return err;
}

int __init bcma_bus_scan_early(struct bcma_bus *bus,
struct bcma_device_id *match,
struct bcma_device *core)
{
u32 erombase;
u32 __iomem *eromptr, *eromend;

int err = -ENODEV;
int core_num = 0;

erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
if (!eromptr)
return -ENOMEM;
} else {
eromptr = bus->mmio;
}

eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);

bcma_scan_switch_core(bus, erombase);

while (eromptr < eromend) {
memset(core, 0, sizeof(*core));
INIT_LIST_HEAD(&core->list);
core->bus = bus;

err = bcma_get_next_core(bus, &eromptr, match, core_num, core);
if (err == -ENODEV) {
core_num++;
continue;
} else if (err == -ENXIO)
continue;
else if (err == -ESPIPE)
break;
else if (err < 0)
goto out;

core->core_index = core_num++;
bus->nr_cores++;
bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
core->core_index, bcma_device_name(&core->id),
core->id.manuf, core->id.id, core->id.rev,
core->id.class);

list_add_tail(&core->list, &bus->cores);
err = 0;
break;
}

out:
if (bus->hosttype == BCMA_HOSTTYPE_SOC)
iounmap(eromptr);

return err;
}
2 changes: 0 additions & 2 deletions include/linux/bcma/bcma_soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

struct bcma_soc {
struct bcma_bus bus;
struct bcma_device core_cc;
struct bcma_device core_mips;
};

int __init bcma_host_soc_register(struct bcma_soc *soc);
Expand Down

0 comments on commit c5ed1df

Please sign in to comment.