1 --- a/drivers/bcma/bcma_private.h
2 +++ b/drivers/bcma/bcma_private.h
3 @@ -25,22 +25,18 @@ struct bcma_bus;
4 bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
6 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
7 +void bcma_init_bus(struct bcma_bus *bus);
8 int bcma_bus_register(struct bcma_bus *bus);
9 void bcma_bus_unregister(struct bcma_bus *bus);
10 -int __init bcma_bus_early_register(struct bcma_bus *bus,
11 - struct bcma_device *core_cc,
12 - struct bcma_device *core_mips);
13 +int __init bcma_bus_early_register(struct bcma_bus *bus);
15 int bcma_bus_suspend(struct bcma_bus *bus);
16 int bcma_bus_resume(struct bcma_bus *bus);
20 +void bcma_detect_chip(struct bcma_bus *bus);
21 int bcma_bus_scan(struct bcma_bus *bus);
22 -int __init bcma_bus_scan_early(struct bcma_bus *bus,
23 - struct bcma_device_id *match,
24 - struct bcma_device *core);
25 -void bcma_init_bus(struct bcma_bus *bus);
28 int bcma_sprom_get(struct bcma_bus *bus);
29 @@ -111,6 +107,14 @@ extern int bcma_chipco_watchdog_register
30 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
31 bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
32 void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
34 +static inline bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
38 +static inline void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
41 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
43 #ifdef CONFIG_BCMA_DRIVER_GPIO
44 --- a/drivers/bcma/driver_chipcommon.c
45 +++ b/drivers/bcma/driver_chipcommon.c
46 @@ -79,7 +79,9 @@ static int bcma_chipco_watchdog_ticks_pe
48 if (cc->capabilities & BCMA_CC_CAP_PMU) {
49 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
50 - /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
51 + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP
54 return bcma_chipco_get_alp_clock(cc) / 4000;
56 /* based on 32KHz ILP clock */
57 @@ -97,7 +99,8 @@ int bcma_chipco_watchdog_register(struct
59 wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
60 wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
61 - wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
63 + bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
65 pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
66 cc->core->bus->num, &wdt,
67 @@ -175,7 +178,6 @@ void bcma_core_chipcommon_init(struct bc
68 u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
71 - enum bcma_clkmode clkmode;
73 maxt = bcma_chipco_watchdog_get_max_timer(cc);
74 if (cc->capabilities & BCMA_CC_CAP_PMU) {
75 @@ -185,8 +187,13 @@ u32 bcma_chipco_watchdog_timer_set(struc
77 bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
79 - clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
80 - bcma_core_set_clockmode(cc->core, clkmode);
81 + struct bcma_bus *bus = cc->core->bus;
83 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4707 &&
84 + bus->chipinfo.id != BCMA_CHIP_ID_BCM53018)
85 + bcma_core_set_clockmode(cc->core,
86 + ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC);
91 @@ -335,7 +342,8 @@ void bcma_chipco_serial_init(struct bcma
92 | BCMA_CC_CORECTL_UARTCLKEN);
95 - bcma_err(cc->core->bus, "serial not supported on this device ccrev: 0x%x\n", ccrev);
96 + bcma_err(cc->core->bus, "serial not supported on this device ccrev: 0x%x\n",
101 --- a/drivers/bcma/driver_pci.c
102 +++ b/drivers/bcma/driver_pci.c
103 @@ -145,6 +145,47 @@ static u16 bcma_pcie_mdio_writeread(stru
106 /**************************************************
108 + **************************************************/
110 +static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
112 + struct bcma_device *core = pc->core;
113 + u16 val16, core_index;
116 + regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
117 + core_index = (u16)core->core_index;
119 + val16 = pcicore_read16(pc, regoff);
120 + if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
122 + val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
123 + (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
124 + pcicore_write16(pc, regoff, val16);
129 + * Apply some early fixes required before accessing SPROM.
130 + * See also si_pci_fixcfg.
132 +void bcma_core_pci_early_init(struct bcma_drv_pci *pc)
134 + if (pc->early_setup_done)
137 + pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
141 + bcma_core_pci_fixcfg(pc);
144 + pc->early_setup_done = true;
147 +/**************************************************
149 **************************************************/
151 @@ -175,24 +216,6 @@ static void bcma_pcicore_serdes_workarou
152 tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
155 -static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
157 - struct bcma_device *core = pc->core;
158 - u16 val16, core_index;
161 - regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
162 - core_index = (u16)core->core_index;
164 - val16 = pcicore_read16(pc, regoff);
165 - if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
167 - val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
168 - (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
169 - pcicore_write16(pc, regoff, val16);
173 /* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */
174 /* Needs to happen when coming out of 'standby'/'hibernate' */
175 static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc)
176 @@ -216,7 +239,6 @@ static void bcma_core_pci_config_fixup(s
178 static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
180 - bcma_core_pci_fixcfg(pc);
181 bcma_pcicore_serdes_workaround(pc);
182 bcma_core_pci_config_fixup(pc);
184 @@ -226,13 +248,11 @@ void bcma_core_pci_init(struct bcma_drv_
188 -#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
189 - pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
190 + bcma_core_pci_early_init(pc);
193 bcma_core_pci_hostmode_init(pc);
194 -#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
198 bcma_core_pci_clientmode_init(pc);
201 --- a/drivers/bcma/host_pci.c
202 +++ b/drivers/bcma/host_pci.c
205 static void bcma_host_pci_switch_core(struct bcma_device *core)
207 + int win2 = core->bus->host_is_pcie2 ?
208 + BCMA_PCIE2_BAR0_WIN2 : BCMA_PCI_BAR0_WIN2;
210 pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN,
212 - pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN2,
214 + pci_write_config_dword(core->bus->host_pci, win2, core->wrap);
215 core->bus->mapped_core = core;
216 bcma_debug(core->bus, "Switched to core: 0x%X\n", core->id.id);
218 --- a/drivers/bcma/host_soc.c
219 +++ b/drivers/bcma/host_soc.c
220 @@ -193,7 +193,7 @@ int __init bcma_host_soc_init(struct bcm
223 /* Scan bus and initialize it */
224 - err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
225 + err = bcma_bus_early_register(bus);
229 --- a/drivers/bcma/main.c
230 +++ b/drivers/bcma/main.c
231 @@ -268,6 +268,18 @@ void bcma_prepare_core(struct bcma_bus *
235 +void bcma_init_bus(struct bcma_bus *bus)
237 + mutex_lock(&bcma_buses_mutex);
238 + bus->num = bcma_bus_next_num++;
239 + mutex_unlock(&bcma_buses_mutex);
241 + INIT_LIST_HEAD(&bus->cores);
244 + bcma_detect_chip(bus);
247 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
250 @@ -356,12 +368,19 @@ static void bcma_unregister_cores(struct
251 struct bcma_device *core, *tmp;
253 list_for_each_entry_safe(core, tmp, &bus->cores, list) {
254 + if (!core->dev_registered)
256 list_del(&core->list);
257 - if (core->dev_registered)
258 - device_unregister(&core->dev);
259 + device_unregister(&core->dev);
261 if (bus->hosttype == BCMA_HOSTTYPE_SOC)
262 platform_device_unregister(bus->drv_cc.watchdog);
264 + /* Now noone uses internally-handled cores, we can free them */
265 + list_for_each_entry_safe(core, tmp, &bus->cores, list) {
266 + list_del(&core->list);
271 int bcma_bus_register(struct bcma_bus *bus)
272 @@ -369,10 +388,6 @@ int bcma_bus_register(struct bcma_bus *b
274 struct bcma_device *core;
276 - mutex_lock(&bcma_buses_mutex);
277 - bus->num = bcma_bus_next_num++;
278 - mutex_unlock(&bcma_buses_mutex);
280 /* Scan for devices (cores) */
281 err = bcma_bus_scan(bus);
283 @@ -387,6 +402,13 @@ int bcma_bus_register(struct bcma_bus *b
284 bcma_core_chipcommon_early_init(&bus->drv_cc);
287 + /* Early init PCIE core */
288 + core = bcma_find_core(bus, BCMA_CORE_PCIE);
290 + bus->drv_pci[0].core = core;
291 + bcma_core_pci_early_init(&bus->drv_pci[0]);
294 /* Cores providing flash access go before SPROM init */
295 list_for_each_entry(core, &bus->cores, list) {
296 if (bcma_is_core_needed_early(core->id.id))
297 @@ -459,7 +481,6 @@ int bcma_bus_register(struct bcma_bus *b
299 void bcma_bus_unregister(struct bcma_bus *bus)
301 - struct bcma_device *cores[3];
304 err = bcma_gpio_unregister(&bus->drv_cc);
305 @@ -470,46 +491,23 @@ void bcma_bus_unregister(struct bcma_bus
307 bcma_core_chipcommon_b_free(&bus->drv_cc_b);
309 - cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
310 - cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
311 - cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
313 bcma_unregister_cores(bus);
320 -int __init bcma_bus_early_register(struct bcma_bus *bus,
321 - struct bcma_device *core_cc,
322 - struct bcma_device *core_mips)
324 + * This is a special version of bus registration function designed for SoCs.
325 + * It scans bus and performs basic initialization of main cores only.
326 + * Please note it requires memory allocation, however it won't try to sleep.
328 +int __init bcma_bus_early_register(struct bcma_bus *bus)
331 struct bcma_device *core;
332 - struct bcma_device_id match;
334 - match.manuf = BCMA_MANUF_BCM;
335 - match.id = bcma_cc_core_id(bus);
336 - match.class = BCMA_CL_SIM;
337 - match.rev = BCMA_ANY_REV;
339 - /* Scan for chip common core */
340 - err = bcma_bus_scan_early(bus, &match, core_cc);
342 - bcma_err(bus, "Failed to scan for common core: %d\n", err);
346 - match.manuf = BCMA_MANUF_MIPS;
347 - match.id = BCMA_CORE_MIPS_74K;
348 - match.class = BCMA_CL_SIM;
349 - match.rev = BCMA_ANY_REV;
351 - /* Scan for mips core */
352 - err = bcma_bus_scan_early(bus, &match, core_mips);
353 + /* Scan for devices (cores) */
354 + err = bcma_bus_scan(bus);
356 - bcma_err(bus, "Failed to scan for mips core: %d\n", err);
357 + bcma_err(bus, "Failed to scan bus: %d\n", err);
361 --- a/drivers/bcma/scan.c
362 +++ b/drivers/bcma/scan.c
363 @@ -435,15 +435,12 @@ static int bcma_get_next_core(struct bcm
367 -void bcma_init_bus(struct bcma_bus *bus)
368 +void bcma_detect_chip(struct bcma_bus *bus)
371 struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
374 - INIT_LIST_HEAD(&bus->cores);
377 bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
379 tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
380 @@ -464,6 +461,10 @@ int bcma_bus_scan(struct bcma_bus *bus)
382 int err, core_num = 0;
384 + /* Skip if bus was already scanned (e.g. during early register) */
388 erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
389 if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
390 eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
391 @@ -519,64 +520,6 @@ int bcma_bus_scan(struct bcma_bus *bus)
393 if (bus->hosttype == BCMA_HOSTTYPE_SOC)
399 -int __init bcma_bus_scan_early(struct bcma_bus *bus,
400 - struct bcma_device_id *match,
401 - struct bcma_device *core)
404 - u32 __iomem *eromptr, *eromend;
409 - erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
410 - if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
411 - eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
415 - eromptr = bus->mmio;
418 - eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);
420 - bcma_scan_switch_core(bus, erombase);
422 - while (eromptr < eromend) {
423 - memset(core, 0, sizeof(*core));
424 - INIT_LIST_HEAD(&core->list);
427 - err = bcma_get_next_core(bus, &eromptr, match, core_num, core);
428 - if (err == -ENODEV) {
431 - } else if (err == -ENXIO)
433 - else if (err == -ESPIPE)
438 - core->core_index = core_num++;
440 - bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
441 - core->core_index, bcma_device_name(&core->id),
442 - core->id.manuf, core->id.id, core->id.rev,
445 - list_add_tail(&core->list, &bus->cores);
451 - if (bus->hosttype == BCMA_HOSTTYPE_SOC)
456 --- a/drivers/bcma/sprom.c
457 +++ b/drivers/bcma/sprom.c
458 @@ -579,7 +579,8 @@ int bcma_sprom_get(struct bcma_bus *bus)
459 u16 offset = BCMA_CC_SPROM;
461 size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
462 - SSB_SPROMSIZE_WORDS_R10, };
463 + SSB_SPROMSIZE_WORDS_R10,
464 + SSB_SPROMSIZE_WORDS_R11, };
467 if (!bus->drv_cc.core)
468 --- a/include/linux/bcma/bcma.h
469 +++ b/include/linux/bcma/bcma.h
470 @@ -318,6 +318,7 @@ struct bcma_bus {
471 const struct bcma_host_ops *ops;
473 enum bcma_hosttype hosttype;
474 + bool host_is_pcie2; /* Used for BCMA_HOSTTYPE_PCI only */
476 /* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
477 struct pci_dev *host_pci;
478 --- a/include/linux/bcma/bcma_driver_pci.h
479 +++ b/include/linux/bcma/bcma_driver_pci.h
480 @@ -223,6 +223,7 @@ struct bcma_drv_pci_host {
482 struct bcma_drv_pci {
483 struct bcma_device *core;
484 + u8 early_setup_done:1;
488 @@ -237,6 +238,7 @@ struct bcma_drv_pci {
489 #define pcicore_write16(pc, offset, val) bcma_write16((pc)->core, offset, val)
490 #define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
492 +extern void bcma_core_pci_early_init(struct bcma_drv_pci *pc);
493 extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
494 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
495 struct bcma_device *core, bool enable);
496 --- a/include/linux/bcma/bcma_regs.h
497 +++ b/include/linux/bcma/bcma_regs.h
499 #define BCMA_PCI_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
500 #define BCMA_PCI_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
502 +#define BCMA_PCIE2_BAR0_WIN2 0x70
504 /* SiliconBackplane Address Map.
505 * All regions may not exist on all chips.
507 --- a/include/linux/bcma/bcma_soc.h
508 +++ b/include/linux/bcma/bcma_soc.h
513 - struct bcma_device core_cc;
514 - struct bcma_device core_mips;
517 int __init bcma_host_soc_register(struct bcma_soc *soc);
518 --- a/include/linux/ssb/ssb_regs.h
519 +++ b/include/linux/ssb/ssb_regs.h
521 #define SSB_SPROMSIZE_BYTES_R123 (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
522 #define SSB_SPROMSIZE_BYTES_R4 (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
523 #define SSB_SPROMSIZE_WORDS_R10 230
524 +#define SSB_SPROMSIZE_WORDS_R11 234
525 #define SSB_SPROM_BASE1 0x1000
526 #define SSB_SPROM_BASE31 0x0800
527 #define SSB_SPROM_REVISION 0x007E