13 #include <linux/pci.h>
16 #include <linux/slab.h>
96 static const char *bcma_device_name(
const struct bcma_device_id *
id)
104 names = bcma_arm_device_names;
108 names = bcma_bcm_device_names;
112 names = bcma_mips_device_names;
119 for (i = 0; i <
size; i++) {
120 if (names[i].
id == id->
id)
121 return names[
i].
name;
147 static void bcma_erom_push_ent(
u32 **eromptr)
154 u32 ent = bcma_erom_get_ent(bus, eromptr);
162 static bool bcma_erom_is_end(
struct bcma_bus *bus,
u32 **eromptr)
164 u32 ent = bcma_erom_get_ent(bus, eromptr);
165 bcma_erom_push_ent(eromptr);
169 static bool bcma_erom_is_bridge(
struct bcma_bus *bus,
u32 **eromptr)
171 u32 ent = bcma_erom_get_ent(bus, eromptr);
172 bcma_erom_push_ent(eromptr);
173 return (((ent & SCAN_ER_VALID)) &&
178 static void bcma_erom_skip_component(
struct bcma_bus *bus,
u32 **eromptr)
182 ent = bcma_erom_get_ent(bus, eromptr);
183 if ((ent & SCAN_ER_VALID) &&
189 bcma_erom_push_ent(eromptr);
192 static s32 bcma_erom_get_mst_port(
struct bcma_bus *bus,
u32 **eromptr)
194 u32 ent = bcma_erom_get_ent(bus, eromptr);
195 if (!(ent & SCAN_ER_VALID))
202 static s32 bcma_erom_get_addr_desc(
struct bcma_bus *bus,
u32 **eromptr,
205 u32 addrl, addrh, sizel, sizeh = 0;
208 u32 ent = bcma_erom_get_ent(bus, eromptr);
209 if ((!(ent & SCAN_ER_VALID)) ||
213 bcma_erom_push_ent(eromptr);
219 addrh = bcma_erom_get_ent(bus, eromptr);
224 size = bcma_erom_get_ent(bus, eromptr);
227 sizeh = bcma_erom_get_ent(bus, eromptr);
252 if (core->
id.id == coreid)
268 cia = bcma_erom_get_ci(bus, eromptr);
270 bcma_erom_push_ent(eromptr);
271 if (bcma_erom_is_end(bus, eromptr))
275 cib = bcma_erom_get_ci(bus, eromptr);
290 (core->
id.id == 0xFFF)) ||
292 bcma_erom_skip_component(bus, eromptr);
297 if (wrappers[0] + wrappers[1] == 0) {
299 switch (core->
id.id) {
304 bcma_erom_skip_component(bus, eromptr);
309 if (bcma_erom_is_bridge(bus, eromptr)) {
310 bcma_erom_skip_component(bus, eromptr);
314 if (bcma_find_core_by_index(bus, core_num)) {
315 bcma_erom_skip_component(bus, eromptr);
320 match->
manuf != core->
id.manuf) ||
325 bcma_erom_skip_component(bus, eromptr);
330 for (i = 0; i < ports[0]; i++) {
331 s32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
342 tmp = bcma_erom_get_addr_desc(bus, eromptr,
354 for (i = 0; i < ports[1]; i++) {
356 tmp = bcma_erom_get_addr_desc(bus, eromptr,
364 if (i == 0 && j == 0)
371 for (i = 0; i < wrappers[0]; i++) {
373 tmp = bcma_erom_get_addr_desc(bus, eromptr,
381 if (i == 0 && j == 0)
388 for (i = 0; i < wrappers[1]; i++) {
389 u8 hack = (ports[1] == 1) ? 0 : 1;
391 tmp = bcma_erom_get_addr_desc(bus, eromptr,
399 if (wrappers[0] == 0 && !i && !j)
425 INIT_LIST_HEAD(&bus->
cores);
434 bcma_info(bus,
"Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
435 chipinfo->
id, chipinfo->
rev, chipinfo->
pkg);
445 int err, core_num = 0;
460 bcma_scan_switch_core(bus, erombase);
462 while (eromptr < eromend) {
469 INIT_LIST_HEAD(&core->
list);
472 err = bcma_get_next_core(bus, &eromptr,
NULL, core_num, core);
478 }
else if (err == -
ENXIO) {
480 }
else if (err == -
ESPIPE) {
488 other_core = bcma_find_core_reverse(bus, core->
id.id);
491 bcma_info(bus,
"Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
493 core->
id.manuf, core->
id.id, core->
id.rev,
528 bcma_scan_switch_core(bus, erombase);
530 while (eromptr < eromend) {
531 memset(core, 0,
sizeof(*core));
532 INIT_LIST_HEAD(&core->
list);
535 err = bcma_get_next_core(bus, &eromptr, match, core_num, core);
539 }
else if (err == -
ENXIO)
548 bcma_info(bus,
"Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
550 core->
id.manuf, core->
id.id, core->
id.rev,