kirkwood: explicitly set CPU_TYPE to xscale
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.6 / 025-bcma_backport.patch
1 --- a/arch/mips/bcm47xx/serial.c
2 +++ b/arch/mips/bcm47xx/serial.c
3 @@ -62,7 +62,7 @@ static int __init uart8250_init_bcma(voi
4
5 p->mapbase = (unsigned int) bcma_port->regs;
6 p->membase = (void *) bcma_port->regs;
7 - p->irq = bcma_port->irq + 2;
8 + p->irq = bcma_port->irq;
9 p->uartclk = bcma_port->baud_base;
10 p->regshift = bcma_port->reg_shift;
11 p->iotype = UPIO_MEM;
12 --- a/drivers/bcma/Kconfig
13 +++ b/drivers/bcma/Kconfig
14 @@ -26,6 +26,7 @@ config BCMA_HOST_PCI_POSSIBLE
15 config BCMA_HOST_PCI
16 bool "Support for BCMA on PCI-host bus"
17 depends on BCMA_HOST_PCI_POSSIBLE
18 + default y
19
20 config BCMA_DRIVER_PCI_HOSTMODE
21 bool "Driver for PCI core working in hostmode"
22 @@ -34,8 +35,14 @@ config BCMA_DRIVER_PCI_HOSTMODE
23 PCI core hostmode operation (external PCI bus).
24
25 config BCMA_HOST_SOC
26 - bool
27 - depends on BCMA_DRIVER_MIPS
28 + bool "Support for BCMA in a SoC"
29 + depends on BCMA
30 + help
31 + Host interface for a Broadcom AIX bus directly mapped into
32 + the memory. This only works with the Broadcom SoCs from the
33 + BCM47XX line.
34 +
35 + If unsure, say N
36
37 config BCMA_DRIVER_MIPS
38 bool "BCMA Broadcom MIPS core driver"
39 @@ -48,12 +55,12 @@ config BCMA_DRIVER_MIPS
40
41 config BCMA_SFLASH
42 bool
43 - depends on BCMA_DRIVER_MIPS && BROKEN
44 + depends on BCMA_DRIVER_MIPS
45 default y
46
47 config BCMA_NFLASH
48 bool
49 - depends on BCMA_DRIVER_MIPS && BROKEN
50 + depends on BCMA_DRIVER_MIPS
51 default y
52
53 config BCMA_DRIVER_GMAC_CMN
54 @@ -65,6 +72,14 @@ config BCMA_DRIVER_GMAC_CMN
55
56 If unsure, say N
57
58 +config BCMA_DRIVER_GPIO
59 + bool "BCMA GPIO driver"
60 + depends on BCMA && GPIOLIB
61 + help
62 + Driver to provide access to the GPIO pins of the bcma bus.
63 +
64 + If unsure, say N
65 +
66 config BCMA_DEBUG
67 bool "BCMA debugging"
68 depends on BCMA
69 --- a/drivers/bcma/Makefile
70 +++ b/drivers/bcma/Makefile
71 @@ -6,6 +6,7 @@ bcma-y += driver_pci.o
72 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
73 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
74 bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
75 +bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
76 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
77 bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
78 obj-$(CONFIG_BCMA) += bcma.o
79 --- a/drivers/bcma/bcma_private.h
80 +++ b/drivers/bcma/bcma_private.h
81 @@ -22,6 +22,8 @@
82 struct bcma_bus;
83
84 /* main.c */
85 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
86 + int timeout);
87 int __devinit bcma_bus_register(struct bcma_bus *bus);
88 void bcma_bus_unregister(struct bcma_bus *bus);
89 int __init bcma_bus_early_register(struct bcma_bus *bus,
90 @@ -31,6 +33,8 @@ int __init bcma_bus_early_register(struc
91 int bcma_bus_suspend(struct bcma_bus *bus);
92 int bcma_bus_resume(struct bcma_bus *bus);
93 #endif
94 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
95 + u8 unit);
96
97 /* scan.c */
98 int bcma_bus_scan(struct bcma_bus *bus);
99 @@ -45,15 +49,17 @@ int bcma_sprom_get(struct bcma_bus *bus)
100 /* driver_chipcommon.c */
101 #ifdef CONFIG_BCMA_DRIVER_MIPS
102 void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
103 +extern struct platform_device bcma_pflash_dev;
104 #endif /* CONFIG_BCMA_DRIVER_MIPS */
105
106 /* driver_chipcommon_pmu.c */
107 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
108 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
109 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
110 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
111
112 #ifdef CONFIG_BCMA_SFLASH
113 /* driver_chipcommon_sflash.c */
114 int bcma_sflash_init(struct bcma_drv_cc *cc);
115 +extern struct platform_device bcma_sflash_dev;
116 #else
117 static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
118 {
119 @@ -65,6 +71,7 @@ static inline int bcma_sflash_init(struc
120 #ifdef CONFIG_BCMA_NFLASH
121 /* driver_chipcommon_nflash.c */
122 int bcma_nflash_init(struct bcma_drv_cc *cc);
123 +extern struct platform_device bcma_nflash_dev;
124 #else
125 static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
126 {
127 @@ -82,9 +89,26 @@ extern void __exit bcma_host_pci_exit(vo
128 /* driver_pci.c */
129 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
130
131 +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
132 +
133 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
134 bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
135 void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
136 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
137
138 +#ifdef CONFIG_BCMA_DRIVER_GPIO
139 +/* driver_gpio.c */
140 +int bcma_gpio_init(struct bcma_drv_cc *cc);
141 +int bcma_gpio_unregister(struct bcma_drv_cc *cc);
142 +#else
143 +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
144 +{
145 + return -ENOTSUPP;
146 +}
147 +static inline int bcma_gpio_unregister(struct bcma_drv_cc *cc)
148 +{
149 + return 0;
150 +}
151 +#endif /* CONFIG_BCMA_DRIVER_GPIO */
152 +
153 #endif
154 --- a/drivers/bcma/core.c
155 +++ b/drivers/bcma/core.c
156 @@ -9,6 +9,25 @@
157 #include <linux/export.h>
158 #include <linux/bcma/bcma.h>
159
160 +static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask,
161 + u32 value, int timeout)
162 +{
163 + unsigned long deadline = jiffies + timeout;
164 + u32 val;
165 +
166 + do {
167 + val = bcma_aread32(core, reg);
168 + if ((val & mask) == value)
169 + return true;
170 + cpu_relax();
171 + udelay(10);
172 + } while (!time_after_eq(jiffies, deadline));
173 +
174 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
175 +
176 + return false;
177 +}
178 +
179 bool bcma_core_is_enabled(struct bcma_device *core)
180 {
181 if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC))
182 @@ -25,13 +44,15 @@ void bcma_core_disable(struct bcma_devic
183 if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
184 return;
185
186 - bcma_awrite32(core, BCMA_IOCTL, flags);
187 - bcma_aread32(core, BCMA_IOCTL);
188 - udelay(10);
189 + bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300);
190
191 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
192 bcma_aread32(core, BCMA_RESET_CTL);
193 udelay(1);
194 +
195 + bcma_awrite32(core, BCMA_IOCTL, flags);
196 + bcma_aread32(core, BCMA_IOCTL);
197 + udelay(10);
198 }
199 EXPORT_SYMBOL_GPL(bcma_core_disable);
200
201 @@ -43,6 +64,7 @@ int bcma_core_enable(struct bcma_device
202 bcma_aread32(core, BCMA_IOCTL);
203
204 bcma_awrite32(core, BCMA_RESET_CTL, 0);
205 + bcma_aread32(core, BCMA_RESET_CTL);
206 udelay(1);
207
208 bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
209 @@ -65,7 +87,7 @@ void bcma_core_set_clockmode(struct bcma
210 switch (clkmode) {
211 case BCMA_CLKMODE_FAST:
212 bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
213 - udelay(64);
214 + usleep_range(64, 300);
215 for (i = 0; i < 1500; i++) {
216 if (bcma_read32(core, BCMA_CLKCTLST) &
217 BCMA_CLKCTLST_HAVEHT) {
218 @@ -104,7 +126,13 @@ void bcma_core_pll_ctl(struct bcma_devic
219 if (i)
220 bcma_err(core->bus, "PLL enable timeout\n");
221 } else {
222 - bcma_warn(core->bus, "Disabling PLL not supported yet!\n");
223 + /*
224 + * Mask the PLL but don't wait for it to be disabled. PLL may be
225 + * shared between cores and will be still up if there is another
226 + * core using it.
227 + */
228 + bcma_mask32(core, BCMA_CLKCTLST, ~req);
229 + bcma_read32(core, BCMA_CLKCTLST);
230 }
231 }
232 EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
233 --- a/drivers/bcma/driver_chipcommon.c
234 +++ b/drivers/bcma/driver_chipcommon.c
235 @@ -4,12 +4,15 @@
236 *
237 * Copyright 2005, Broadcom Corporation
238 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
239 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
240 *
241 * Licensed under the GNU/GPL. See COPYING for details.
242 */
243
244 #include "bcma_private.h"
245 +#include <linux/bcm47xx_wdt.h>
246 #include <linux/export.h>
247 +#include <linux/platform_device.h>
248 #include <linux/bcma/bcma.h>
249
250 static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
251 @@ -22,23 +25,130 @@ static inline u32 bcma_cc_write32_masked
252 return value;
253 }
254
255 -void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
256 +u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
257 {
258 - u32 leddc_on = 10;
259 - u32 leddc_off = 90;
260 + if (cc->capabilities & BCMA_CC_CAP_PMU)
261 + return bcma_pmu_get_alp_clock(cc);
262
263 - if (cc->setup_done)
264 + return 20000000;
265 +}
266 +EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
267 +
268 +static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
269 +{
270 + struct bcma_bus *bus = cc->core->bus;
271 + u32 nb;
272 +
273 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
274 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
275 + nb = 32;
276 + else if (cc->core->id.rev < 26)
277 + nb = 16;
278 + else
279 + nb = (cc->core->id.rev >= 37) ? 32 : 24;
280 + } else {
281 + nb = 28;
282 + }
283 + if (nb == 32)
284 + return 0xffffffff;
285 + else
286 + return (1 << nb) - 1;
287 +}
288 +
289 +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
290 + u32 ticks)
291 +{
292 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
293 +
294 + return bcma_chipco_watchdog_timer_set(cc, ticks);
295 +}
296 +
297 +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
298 + u32 ms)
299 +{
300 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
301 + u32 ticks;
302 +
303 + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
304 + return ticks / cc->ticks_per_ms;
305 +}
306 +
307 +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
308 +{
309 + struct bcma_bus *bus = cc->core->bus;
310 +
311 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
312 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
313 + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
314 + return bcma_chipco_get_alp_clock(cc) / 4000;
315 + else
316 + /* based on 32KHz ILP clock */
317 + return 32;
318 + } else {
319 + return bcma_chipco_get_alp_clock(cc) / 1000;
320 + }
321 +}
322 +
323 +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
324 +{
325 + struct bcm47xx_wdt wdt = {};
326 + struct platform_device *pdev;
327 +
328 + wdt.driver_data = cc;
329 + wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
330 + wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
331 + wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
332 +
333 + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
334 + cc->core->bus->num, &wdt,
335 + sizeof(wdt));
336 + if (IS_ERR(pdev))
337 + return PTR_ERR(pdev);
338 +
339 + cc->watchdog = pdev;
340 +
341 + return 0;
342 +}
343 +
344 +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
345 +{
346 + if (cc->early_setup_done)
347 return;
348
349 + spin_lock_init(&cc->gpio_lock);
350 +
351 if (cc->core->id.rev >= 11)
352 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
353 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
354 if (cc->core->id.rev >= 35)
355 cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);
356
357 + if (cc->capabilities & BCMA_CC_CAP_PMU)
358 + bcma_pmu_early_init(cc);
359 +
360 + cc->early_setup_done = true;
361 +}
362 +
363 +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
364 +{
365 + u32 leddc_on = 10;
366 + u32 leddc_off = 90;
367 +
368 + if (cc->setup_done)
369 + return;
370 +
371 + bcma_core_chipcommon_early_init(cc);
372 +
373 if (cc->core->id.rev >= 20) {
374 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
375 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
376 + u32 pullup = 0, pulldown = 0;
377 +
378 + if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) {
379 + pullup = 0x402e0;
380 + pulldown = 0x20500;
381 + }
382 +
383 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup);
384 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown);
385 }
386
387 if (cc->capabilities & BCMA_CC_CAP_PMU)
388 @@ -56,15 +166,33 @@ void bcma_core_chipcommon_init(struct bc
389 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
390 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
391 }
392 + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
393
394 cc->setup_done = true;
395 }
396
397 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
398 -void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
399 +u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
400 {
401 - /* instant NMI */
402 - bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
403 + u32 maxt;
404 + enum bcma_clkmode clkmode;
405 +
406 + maxt = bcma_chipco_watchdog_get_max_timer(cc);
407 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
408 + if (ticks == 1)
409 + ticks = 2;
410 + else if (ticks > maxt)
411 + ticks = maxt;
412 + bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
413 + } else {
414 + clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
415 + bcma_core_set_clockmode(cc->core, clkmode);
416 + if (ticks > maxt)
417 + ticks = maxt;
418 + /* instant NMI */
419 + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
420 + }
421 + return ticks;
422 }
423
424 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
425 @@ -84,28 +212,99 @@ u32 bcma_chipco_gpio_in(struct bcma_drv_
426
427 u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
428 {
429 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
430 + unsigned long flags;
431 + u32 res;
432 +
433 + spin_lock_irqsave(&cc->gpio_lock, flags);
434 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
435 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
436 +
437 + return res;
438 }
439 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
440
441 u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
442 {
443 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
444 + unsigned long flags;
445 + u32 res;
446 +
447 + spin_lock_irqsave(&cc->gpio_lock, flags);
448 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
449 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
450 +
451 + return res;
452 }
453 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
454
455 +/*
456 + * If the bit is set to 0, chipcommon controlls this GPIO,
457 + * if the bit is set to 1, it is used by some part of the chip and not our code.
458 + */
459 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
460 {
461 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
462 + unsigned long flags;
463 + u32 res;
464 +
465 + spin_lock_irqsave(&cc->gpio_lock, flags);
466 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
467 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
468 +
469 + return res;
470 }
471 EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
472
473 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
474 {
475 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
476 + unsigned long flags;
477 + u32 res;
478 +
479 + spin_lock_irqsave(&cc->gpio_lock, flags);
480 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
481 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
482 +
483 + return res;
484 }
485
486 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
487 {
488 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
489 + unsigned long flags;
490 + u32 res;
491 +
492 + spin_lock_irqsave(&cc->gpio_lock, flags);
493 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
494 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
495 +
496 + return res;
497 +}
498 +
499 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value)
500 +{
501 + unsigned long flags;
502 + u32 res;
503 +
504 + if (cc->core->id.rev < 20)
505 + return 0;
506 +
507 + spin_lock_irqsave(&cc->gpio_lock, flags);
508 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value);
509 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
510 +
511 + return res;
512 +}
513 +
514 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value)
515 +{
516 + unsigned long flags;
517 + u32 res;
518 +
519 + if (cc->core->id.rev < 20)
520 + return 0;
521 +
522 + spin_lock_irqsave(&cc->gpio_lock, flags);
523 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value);
524 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
525 +
526 + return res;
527 }
528
529 #ifdef CONFIG_BCMA_DRIVER_MIPS
530 @@ -118,8 +317,7 @@ void bcma_chipco_serial_init(struct bcma
531 struct bcma_serial_port *ports = cc->serial_ports;
532
533 if (ccrev >= 11 && ccrev != 15) {
534 - /* Fixed ALP clock */
535 - baud_base = bcma_pmu_alp_clock(cc);
536 + baud_base = bcma_chipco_get_alp_clock(cc);
537 if (ccrev >= 21) {
538 /* Turn off UART clock before switching clocksource. */
539 bcma_cc_write32(cc, BCMA_CC_CORECTL,
540 @@ -141,7 +339,7 @@ void bcma_chipco_serial_init(struct bcma
541 return;
542 }
543
544 - irq = bcma_core_mips_irq(cc->core);
545 + irq = bcma_core_irq(cc->core);
546
547 /* Determine the registers of the UARTs */
548 cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART);
549 --- a/drivers/bcma/driver_chipcommon_nflash.c
550 +++ b/drivers/bcma/driver_chipcommon_nflash.c
551 @@ -5,15 +5,40 @@
552 * Licensed under the GNU/GPL. See COPYING for details.
553 */
554
555 +#include "bcma_private.h"
556 +
557 +#include <linux/platform_device.h>
558 #include <linux/bcma/bcma.h>
559 -#include <linux/bcma/bcma_driver_chipcommon.h>
560 -#include <linux/delay.h>
561
562 -#include "bcma_private.h"
563 +struct platform_device bcma_nflash_dev = {
564 + .name = "bcma_nflash",
565 + .num_resources = 0,
566 +};
567
568 /* Initialize NAND flash access */
569 int bcma_nflash_init(struct bcma_drv_cc *cc)
570 {
571 - bcma_err(cc->core->bus, "NAND flash support is broken\n");
572 + struct bcma_bus *bus = cc->core->bus;
573 +
574 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
575 + cc->core->id.rev != 38) {
576 + bcma_err(bus, "NAND flash on unsupported board!\n");
577 + return -ENOTSUPP;
578 + }
579 +
580 + if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
581 + bcma_err(bus, "NAND flash not present according to ChipCommon\n");
582 + return -ENODEV;
583 + }
584 +
585 + cc->nflash.present = true;
586 + if (cc->core->id.rev == 38 &&
587 + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
588 + cc->nflash.boot = true;
589 +
590 + /* Prepare platform device, but don't register it yet. It's too early,
591 + * malloc (required by device_private_init) is not available yet. */
592 + bcma_nflash_dev.dev.platform_data = &cc->nflash;
593 +
594 return 0;
595 }
596 --- a/drivers/bcma/driver_chipcommon_pmu.c
597 +++ b/drivers/bcma/driver_chipcommon_pmu.c
598 @@ -13,12 +13,13 @@
599 #include <linux/export.h>
600 #include <linux/bcma/bcma.h>
601
602 -static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
603 +u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
604 {
605 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
606 bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
607 return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
608 }
609 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
610
611 void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
612 {
613 @@ -55,6 +56,109 @@ void bcma_chipco_regctl_maskset(struct b
614 }
615 EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
616
617 +static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc)
618 +{
619 + u32 ilp_ctl, alp_hz;
620 +
621 + if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) &
622 + BCMA_CC_PMU_STAT_EXT_LPO_AVAIL))
623 + return 0;
624 +
625 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
626 + BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
627 + usleep_range(1000, 2000);
628 +
629 + ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
630 + ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK;
631 +
632 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
633 +
634 + alp_hz = ilp_ctl * 32768 / 4;
635 + return (alp_hz + 50000) / 100000 * 100;
636 +}
637 +
638 +static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq)
639 +{
640 + struct bcma_bus *bus = cc->core->bus;
641 + u32 freq_tgt_target = 0, freq_tgt_current;
642 + u32 pll0, mask;
643 +
644 + switch (bus->chipinfo.id) {
645 + case BCMA_CHIP_ID_BCM43142:
646 + /* pmu2_xtaltab0_adfll_485 */
647 + switch (xtalfreq) {
648 + case 12000:
649 + freq_tgt_target = 0x50D52;
650 + break;
651 + case 20000:
652 + freq_tgt_target = 0x307FE;
653 + break;
654 + case 26000:
655 + freq_tgt_target = 0x254EA;
656 + break;
657 + case 37400:
658 + freq_tgt_target = 0x19EF8;
659 + break;
660 + case 52000:
661 + freq_tgt_target = 0x12A75;
662 + break;
663 + }
664 + break;
665 + }
666 +
667 + if (!freq_tgt_target) {
668 + bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n",
669 + xtalfreq);
670 + return;
671 + }
672 +
673 + pll0 = bcma_chipco_pll_read(cc, BCMA_CC_PMU15_PLL_PLLCTL0);
674 + freq_tgt_current = (pll0 & BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK) >>
675 + BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
676 +
677 + if (freq_tgt_current == freq_tgt_target) {
678 + bcma_debug(bus, "Target TGT frequency already set\n");
679 + return;
680 + }
681 +
682 + /* Turn off PLL */
683 + switch (bus->chipinfo.id) {
684 + case BCMA_CHIP_ID_BCM43142:
685 + mask = (u32)~(BCMA_RES_4314_HT_AVAIL |
686 + BCMA_RES_4314_MACPHY_CLK_AVAIL);
687 +
688 + bcma_cc_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask);
689 + bcma_cc_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask);
690 + bcma_wait_value(cc->core, BCMA_CLKCTLST,
691 + BCMA_CLKCTLST_HAVEHT, 0, 20000);
692 + break;
693 + }
694 +
695 + pll0 &= ~BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK;
696 + pll0 |= freq_tgt_target << BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
697 + bcma_chipco_pll_write(cc, BCMA_CC_PMU15_PLL_PLLCTL0, pll0);
698 +
699 + /* Flush */
700 + if (cc->pmu.rev >= 2)
701 + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
702 +
703 + /* TODO: Do we need to update OTP? */
704 +}
705 +
706 +static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
707 +{
708 + struct bcma_bus *bus = cc->core->bus;
709 + u32 xtalfreq = bcma_pmu_xtalfreq(cc);
710 +
711 + switch (bus->chipinfo.id) {
712 + case BCMA_CHIP_ID_BCM43142:
713 + if (xtalfreq == 0)
714 + xtalfreq = 20000;
715 + bcma_pmu2_pll_init0(cc, xtalfreq);
716 + break;
717 + }
718 +}
719 +
720 static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
721 {
722 struct bcma_bus *bus = cc->core->bus;
723 @@ -65,6 +169,25 @@ static void bcma_pmu_resources_init(stru
724 min_msk = 0x200D;
725 max_msk = 0xFFFF;
726 break;
727 + case BCMA_CHIP_ID_BCM43142:
728 + min_msk = BCMA_RES_4314_LPLDO_PU |
729 + BCMA_RES_4314_PMU_SLEEP_DIS |
730 + BCMA_RES_4314_PMU_BG_PU |
731 + BCMA_RES_4314_CBUCK_LPOM_PU |
732 + BCMA_RES_4314_CBUCK_PFM_PU |
733 + BCMA_RES_4314_CLDO_PU |
734 + BCMA_RES_4314_LPLDO2_LVM |
735 + BCMA_RES_4314_WL_PMU_PU |
736 + BCMA_RES_4314_LDO3P3_PU |
737 + BCMA_RES_4314_OTP_PU |
738 + BCMA_RES_4314_WL_PWRSW_PU |
739 + BCMA_RES_4314_LQ_AVAIL |
740 + BCMA_RES_4314_LOGIC_RET |
741 + BCMA_RES_4314_MEM_SLEEP |
742 + BCMA_RES_4314_MACPHY_RET |
743 + BCMA_RES_4314_WL_CORE_READY;
744 + max_msk = 0x3FFFFFFF;
745 + break;
746 default:
747 bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
748 bus->chipinfo.id);
749 @@ -76,7 +199,10 @@ static void bcma_pmu_resources_init(stru
750 if (max_msk)
751 bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
752
753 - /* Add some delay; allow resources to come up and settle. */
754 + /*
755 + * Add some delay; allow resources to come up and settle.
756 + * Delay is required for SoC (early init).
757 + */
758 mdelay(2);
759 }
760
761 @@ -101,7 +227,7 @@ void bcma_chipco_bcm4331_ext_pa_lines_ct
762 bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
763 }
764
765 -void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
766 +static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
767 {
768 struct bcma_bus *bus = cc->core->bus;
769
770 @@ -141,7 +267,7 @@ void bcma_pmu_workarounds(struct bcma_dr
771 }
772 }
773
774 -void bcma_pmu_init(struct bcma_drv_cc *cc)
775 +void bcma_pmu_early_init(struct bcma_drv_cc *cc)
776 {
777 u32 pmucap;
778
779 @@ -150,7 +276,10 @@ void bcma_pmu_init(struct bcma_drv_cc *c
780
781 bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
782 cc->pmu.rev, pmucap);
783 +}
784
785 +void bcma_pmu_init(struct bcma_drv_cc *cc)
786 +{
787 if (cc->pmu.rev == 1)
788 bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
789 ~BCMA_CC_PMU_CTL_NOILPONW);
790 @@ -158,28 +287,45 @@ void bcma_pmu_init(struct bcma_drv_cc *c
791 bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
792 BCMA_CC_PMU_CTL_NOILPONW);
793
794 + bcma_pmu_pll_init(cc);
795 bcma_pmu_resources_init(cc);
796 bcma_pmu_workarounds(cc);
797 }
798
799 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
800 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
801 {
802 struct bcma_bus *bus = cc->core->bus;
803
804 switch (bus->chipinfo.id) {
805 + case BCMA_CHIP_ID_BCM4313:
806 + case BCMA_CHIP_ID_BCM43224:
807 + case BCMA_CHIP_ID_BCM43225:
808 + case BCMA_CHIP_ID_BCM43227:
809 + case BCMA_CHIP_ID_BCM43228:
810 + case BCMA_CHIP_ID_BCM4331:
811 + case BCMA_CHIP_ID_BCM43421:
812 + case BCMA_CHIP_ID_BCM43428:
813 + case BCMA_CHIP_ID_BCM43431:
814 case BCMA_CHIP_ID_BCM4716:
815 - case BCMA_CHIP_ID_BCM4748:
816 case BCMA_CHIP_ID_BCM47162:
817 - case BCMA_CHIP_ID_BCM4313:
818 - case BCMA_CHIP_ID_BCM5357:
819 + case BCMA_CHIP_ID_BCM4748:
820 case BCMA_CHIP_ID_BCM4749:
821 + case BCMA_CHIP_ID_BCM5357:
822 case BCMA_CHIP_ID_BCM53572:
823 + case BCMA_CHIP_ID_BCM6362:
824 /* always 20Mhz */
825 return 20000 * 1000;
826 - case BCMA_CHIP_ID_BCM5356:
827 case BCMA_CHIP_ID_BCM4706:
828 + case BCMA_CHIP_ID_BCM5356:
829 /* always 25Mhz */
830 return 25000 * 1000;
831 + case BCMA_CHIP_ID_BCM43460:
832 + case BCMA_CHIP_ID_BCM4352:
833 + case BCMA_CHIP_ID_BCM4360:
834 + if (cc->status & BCMA_CC_CHIPST_4360_XTAL_40MZ)
835 + return 40000 * 1000;
836 + else
837 + return 20000 * 1000;
838 default:
839 bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
840 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
841 @@ -190,7 +336,7 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_c
842 /* Find the output of the "m" pll divider given pll controls that start with
843 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
844 */
845 -static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
846 +static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
847 {
848 u32 tmp, div, ndiv, p1, p2, fc;
849 struct bcma_bus *bus = cc->core->bus;
850 @@ -219,14 +365,14 @@ static u32 bcma_pmu_clock(struct bcma_dr
851 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
852
853 /* Do calculation in Mhz */
854 - fc = bcma_pmu_alp_clock(cc) / 1000000;
855 + fc = bcma_pmu_get_alp_clock(cc) / 1000000;
856 fc = (p1 * ndiv * fc) / p2;
857
858 /* Return clock in Hertz */
859 return (fc / div) * 1000000;
860 }
861
862 -static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
863 +static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
864 {
865 u32 tmp, ndiv, p1div, p2div;
866 u32 clock;
867 @@ -257,7 +403,7 @@ static u32 bcma_pmu_clock_bcm4706(struct
868 }
869
870 /* query bus clock frequency for PMU-enabled chipcommon */
871 -u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
872 +u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
873 {
874 struct bcma_bus *bus = cc->core->bus;
875
876 @@ -265,40 +411,43 @@ u32 bcma_pmu_get_clockcontrol(struct bcm
877 case BCMA_CHIP_ID_BCM4716:
878 case BCMA_CHIP_ID_BCM4748:
879 case BCMA_CHIP_ID_BCM47162:
880 - return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
881 - BCMA_CC_PMU5_MAINPLL_SSB);
882 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
883 + BCMA_CC_PMU5_MAINPLL_SSB);
884 case BCMA_CHIP_ID_BCM5356:
885 - return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
886 - BCMA_CC_PMU5_MAINPLL_SSB);
887 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
888 + BCMA_CC_PMU5_MAINPLL_SSB);
889 case BCMA_CHIP_ID_BCM5357:
890 case BCMA_CHIP_ID_BCM4749:
891 - return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
892 - BCMA_CC_PMU5_MAINPLL_SSB);
893 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
894 + BCMA_CC_PMU5_MAINPLL_SSB);
895 case BCMA_CHIP_ID_BCM4706:
896 - return bcma_pmu_clock_bcm4706(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
897 - BCMA_CC_PMU5_MAINPLL_SSB);
898 + return bcma_pmu_pll_clock_bcm4706(cc,
899 + BCMA_CC_PMU4706_MAINPLL_PLL0,
900 + BCMA_CC_PMU5_MAINPLL_SSB);
901 case BCMA_CHIP_ID_BCM53572:
902 return 75000000;
903 default:
904 - bcma_warn(bus, "No backplane clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
905 + bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
906 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
907 }
908 return BCMA_CC_PMU_HT_CLOCK;
909 }
910 +EXPORT_SYMBOL_GPL(bcma_pmu_get_bus_clock);
911
912 /* query cpu clock frequency for PMU-enabled chipcommon */
913 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
914 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
915 {
916 struct bcma_bus *bus = cc->core->bus;
917
918 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
919 return 300000000;
920
921 + /* New PMUs can have different clock for bus and CPU */
922 if (cc->pmu.rev >= 5) {
923 u32 pll;
924 switch (bus->chipinfo.id) {
925 case BCMA_CHIP_ID_BCM4706:
926 - return bcma_pmu_clock_bcm4706(cc,
927 + return bcma_pmu_pll_clock_bcm4706(cc,
928 BCMA_CC_PMU4706_MAINPLL_PLL0,
929 BCMA_CC_PMU5_MAINPLL_CPU);
930 case BCMA_CHIP_ID_BCM5356:
931 @@ -313,10 +462,11 @@ u32 bcma_pmu_get_clockcpu(struct bcma_dr
932 break;
933 }
934
935 - return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
936 + return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
937 }
938
939 - return bcma_pmu_get_clockcontrol(cc);
940 + /* On old PMUs CPU has the same clock as the bus */
941 + return bcma_pmu_get_bus_clock(cc);
942 }
943
944 static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
945 @@ -362,7 +512,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
946 tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
947 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
948
949 - tmp = 1 << 10;
950 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
951 break;
952
953 case BCMA_CHIP_ID_BCM4331:
954 @@ -383,7 +533,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
955 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
956 0x03000a08);
957 }
958 - tmp = 1 << 10;
959 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
960 break;
961
962 case BCMA_CHIP_ID_BCM43224:
963 @@ -416,7 +566,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
964 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
965 0x88888815);
966 }
967 - tmp = 1 << 10;
968 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
969 break;
970
971 case BCMA_CHIP_ID_BCM4716:
972 @@ -450,7 +600,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
973 0x88888815);
974 }
975
976 - tmp = 3 << 9;
977 + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
978 break;
979
980 case BCMA_CHIP_ID_BCM43227:
981 @@ -486,7 +636,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
982 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
983 0x88888815);
984 }
985 - tmp = 1 << 10;
986 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
987 break;
988 default:
989 bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
990 --- a/drivers/bcma/driver_chipcommon_sflash.c
991 +++ b/drivers/bcma/driver_chipcommon_sflash.c
992 @@ -5,15 +5,161 @@
993 * Licensed under the GNU/GPL. See COPYING for details.
994 */
995
996 +#include "bcma_private.h"
997 +
998 +#include <linux/platform_device.h>
999 #include <linux/bcma/bcma.h>
1000 -#include <linux/bcma/bcma_driver_chipcommon.h>
1001 -#include <linux/delay.h>
1002
1003 -#include "bcma_private.h"
1004 +static struct resource bcma_sflash_resource = {
1005 + .name = "bcma_sflash",
1006 + .start = BCMA_SOC_FLASH2,
1007 + .end = 0,
1008 + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
1009 +};
1010 +
1011 +struct platform_device bcma_sflash_dev = {
1012 + .name = "bcma_sflash",
1013 + .resource = &bcma_sflash_resource,
1014 + .num_resources = 1,
1015 +};
1016 +
1017 +struct bcma_sflash_tbl_e {
1018 + char *name;
1019 + u32 id;
1020 + u32 blocksize;
1021 + u16 numblocks;
1022 +};
1023 +
1024 +static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
1025 + { "M25P20", 0x11, 0x10000, 4, },
1026 + { "M25P40", 0x12, 0x10000, 8, },
1027 +
1028 + { "M25P16", 0x14, 0x10000, 32, },
1029 + { "M25P32", 0x15, 0x10000, 64, },
1030 + { "M25P64", 0x16, 0x10000, 128, },
1031 + { "M25FL128", 0x17, 0x10000, 256, },
1032 + { 0 },
1033 +};
1034 +
1035 +static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
1036 + { "SST25WF512", 1, 0x1000, 16, },
1037 + { "SST25VF512", 0x48, 0x1000, 16, },
1038 + { "SST25WF010", 2, 0x1000, 32, },
1039 + { "SST25VF010", 0x49, 0x1000, 32, },
1040 + { "SST25WF020", 3, 0x1000, 64, },
1041 + { "SST25VF020", 0x43, 0x1000, 64, },
1042 + { "SST25WF040", 4, 0x1000, 128, },
1043 + { "SST25VF040", 0x44, 0x1000, 128, },
1044 + { "SST25VF040B", 0x8d, 0x1000, 128, },
1045 + { "SST25WF080", 5, 0x1000, 256, },
1046 + { "SST25VF080B", 0x8e, 0x1000, 256, },
1047 + { "SST25VF016", 0x41, 0x1000, 512, },
1048 + { "SST25VF032", 0x4a, 0x1000, 1024, },
1049 + { "SST25VF064", 0x4b, 0x1000, 2048, },
1050 + { 0 },
1051 +};
1052 +
1053 +static const struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
1054 + { "AT45DB011", 0xc, 256, 512, },
1055 + { "AT45DB021", 0x14, 256, 1024, },
1056 + { "AT45DB041", 0x1c, 256, 2048, },
1057 + { "AT45DB081", 0x24, 256, 4096, },
1058 + { "AT45DB161", 0x2c, 512, 4096, },
1059 + { "AT45DB321", 0x34, 512, 8192, },
1060 + { "AT45DB642", 0x3c, 1024, 8192, },
1061 + { 0 },
1062 +};
1063 +
1064 +static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
1065 +{
1066 + int i;
1067 + bcma_cc_write32(cc, BCMA_CC_FLASHCTL,
1068 + BCMA_CC_FLASHCTL_START | opcode);
1069 + for (i = 0; i < 1000; i++) {
1070 + if (!(bcma_cc_read32(cc, BCMA_CC_FLASHCTL) &
1071 + BCMA_CC_FLASHCTL_BUSY))
1072 + return;
1073 + cpu_relax();
1074 + }
1075 + bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
1076 +}
1077
1078 /* Initialize serial flash access */
1079 int bcma_sflash_init(struct bcma_drv_cc *cc)
1080 {
1081 - bcma_err(cc->core->bus, "Serial flash support is broken\n");
1082 + struct bcma_bus *bus = cc->core->bus;
1083 + struct bcma_sflash *sflash = &cc->sflash;
1084 + const struct bcma_sflash_tbl_e *e;
1085 + u32 id, id2;
1086 +
1087 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
1088 + case BCMA_CC_FLASHT_STSER:
1089 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_DP);
1090 +
1091 + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 0);
1092 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
1093 + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
1094 +
1095 + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 1);
1096 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
1097 + id2 = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
1098 +
1099 + switch (id) {
1100 + case 0xbf:
1101 + for (e = bcma_sflash_sst_tbl; e->name; e++) {
1102 + if (e->id == id2)
1103 + break;
1104 + }
1105 + break;
1106 + case 0x13:
1107 + return -ENOTSUPP;
1108 + default:
1109 + for (e = bcma_sflash_st_tbl; e->name; e++) {
1110 + if (e->id == id)
1111 + break;
1112 + }
1113 + break;
1114 + }
1115 + if (!e->name) {
1116 + bcma_err(bus, "Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n", id, id2);
1117 + return -ENOTSUPP;
1118 + }
1119 +
1120 + break;
1121 + case BCMA_CC_FLASHT_ATSER:
1122 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_AT_STATUS);
1123 + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA) & 0x3c;
1124 +
1125 + for (e = bcma_sflash_at_tbl; e->name; e++) {
1126 + if (e->id == id)
1127 + break;
1128 + }
1129 + if (!e->name) {
1130 + bcma_err(bus, "Unsupported Atmel serial flash (id: 0x%X)\n", id);
1131 + return -ENOTSUPP;
1132 + }
1133 +
1134 + break;
1135 + default:
1136 + bcma_err(bus, "Unsupported flash type\n");
1137 + return -ENOTSUPP;
1138 + }
1139 +
1140 + sflash->window = BCMA_SOC_FLASH2;
1141 + sflash->blocksize = e->blocksize;
1142 + sflash->numblocks = e->numblocks;
1143 + sflash->size = sflash->blocksize * sflash->numblocks;
1144 + sflash->present = true;
1145 +
1146 + bcma_info(bus, "Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
1147 + e->name, sflash->size / 1024, sflash->blocksize,
1148 + sflash->numblocks);
1149 +
1150 + /* Prepare platform device, but don't register it yet. It's too early,
1151 + * malloc (required by device_private_init) is not available yet. */
1152 + bcma_sflash_dev.resource[0].end = bcma_sflash_dev.resource[0].start +
1153 + sflash->size;
1154 + bcma_sflash_dev.dev.platform_data = sflash;
1155 +
1156 return 0;
1157 }
1158 --- /dev/null
1159 +++ b/drivers/bcma/driver_gpio.c
1160 @@ -0,0 +1,114 @@
1161 +/*
1162 + * Broadcom specific AMBA
1163 + * GPIO driver
1164 + *
1165 + * Copyright 2011, Broadcom Corporation
1166 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
1167 + *
1168 + * Licensed under the GNU/GPL. See COPYING for details.
1169 + */
1170 +
1171 +#include <linux/gpio.h>
1172 +#include <linux/export.h>
1173 +#include <linux/bcma/bcma.h>
1174 +
1175 +#include "bcma_private.h"
1176 +
1177 +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
1178 +{
1179 + return container_of(chip, struct bcma_drv_cc, gpio);
1180 +}
1181 +
1182 +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
1183 +{
1184 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1185 +
1186 + return !!bcma_chipco_gpio_in(cc, 1 << gpio);
1187 +}
1188 +
1189 +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
1190 + int value)
1191 +{
1192 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1193 +
1194 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1195 +}
1196 +
1197 +static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
1198 +{
1199 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1200 +
1201 + bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
1202 + return 0;
1203 +}
1204 +
1205 +static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
1206 + int value)
1207 +{
1208 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1209 +
1210 + bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
1211 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1212 + return 0;
1213 +}
1214 +
1215 +static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
1216 +{
1217 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1218 +
1219 + bcma_chipco_gpio_control(cc, 1 << gpio, 0);
1220 + /* clear pulldown */
1221 + bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
1222 + /* Set pullup */
1223 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
1224 +
1225 + return 0;
1226 +}
1227 +
1228 +static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
1229 +{
1230 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1231 +
1232 + /* clear pullup */
1233 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
1234 +}
1235 +
1236 +static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
1237 +{
1238 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1239 +
1240 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
1241 + return bcma_core_irq(cc->core);
1242 + else
1243 + return -EINVAL;
1244 +}
1245 +
1246 +int bcma_gpio_init(struct bcma_drv_cc *cc)
1247 +{
1248 + struct gpio_chip *chip = &cc->gpio;
1249 +
1250 + chip->label = "bcma_gpio";
1251 + chip->owner = THIS_MODULE;
1252 + chip->request = bcma_gpio_request;
1253 + chip->free = bcma_gpio_free;
1254 + chip->get = bcma_gpio_get_value;
1255 + chip->set = bcma_gpio_set_value;
1256 + chip->direction_input = bcma_gpio_direction_input;
1257 + chip->direction_output = bcma_gpio_direction_output;
1258 + chip->to_irq = bcma_gpio_to_irq;
1259 + chip->ngpio = 16;
1260 + /* There is just one SoC in one device and its GPIO addresses should be
1261 + * deterministic to address them more easily. The other buses could get
1262 + * a random base number. */
1263 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
1264 + chip->base = 0;
1265 + else
1266 + chip->base = -1;
1267 +
1268 + return gpiochip_add(chip);
1269 +}
1270 +
1271 +int bcma_gpio_unregister(struct bcma_drv_cc *cc)
1272 +{
1273 + return gpiochip_remove(&cc->gpio);
1274 +}
1275 --- a/drivers/bcma/driver_mips.c
1276 +++ b/drivers/bcma/driver_mips.c
1277 @@ -14,11 +14,33 @@
1278
1279 #include <linux/bcma/bcma.h>
1280
1281 +#include <linux/mtd/physmap.h>
1282 +#include <linux/platform_device.h>
1283 #include <linux/serial.h>
1284 #include <linux/serial_core.h>
1285 #include <linux/serial_reg.h>
1286 #include <linux/time.h>
1287
1288 +static const char * const part_probes[] = { "bcm47xxpart", NULL };
1289 +
1290 +static struct physmap_flash_data bcma_pflash_data = {
1291 + .part_probe_types = part_probes,
1292 +};
1293 +
1294 +static struct resource bcma_pflash_resource = {
1295 + .name = "bcma_pflash",
1296 + .flags = IORESOURCE_MEM,
1297 +};
1298 +
1299 +struct platform_device bcma_pflash_dev = {
1300 + .name = "physmap-flash",
1301 + .dev = {
1302 + .platform_data = &bcma_pflash_data,
1303 + },
1304 + .resource = &bcma_pflash_resource,
1305 + .num_resources = 1,
1306 +};
1307 +
1308 /* The 47162a0 hangs when reading MIPS DMP registers registers */
1309 static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
1310 {
1311 @@ -74,28 +96,41 @@ static u32 bcma_core_mips_irqflag(struct
1312 return dev->core_index;
1313 flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
1314
1315 - return flag & 0x1F;
1316 + if (flag)
1317 + return flag & 0x1F;
1318 + else
1319 + return 0x3f;
1320 }
1321
1322 /* Get the MIPS IRQ assignment for a specified device.
1323 * If unassigned, 0 is returned.
1324 + * If disabled, 5 is returned.
1325 + * If not supported, 6 is returned.
1326 */
1327 -unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1328 +static unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1329 {
1330 struct bcma_device *mdev = dev->bus->drv_mips.core;
1331 u32 irqflag;
1332 unsigned int irq;
1333
1334 irqflag = bcma_core_mips_irqflag(dev);
1335 + if (irqflag == 0x3f)
1336 + return 6;
1337
1338 - for (irq = 1; irq <= 4; irq++)
1339 + for (irq = 0; irq <= 4; irq++)
1340 if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
1341 (1 << irqflag))
1342 return irq;
1343
1344 - return 0;
1345 + return 5;
1346 +}
1347 +
1348 +unsigned int bcma_core_irq(struct bcma_device *dev)
1349 +{
1350 + unsigned int mips_irq = bcma_core_mips_irq(dev);
1351 + return mips_irq <= 4 ? mips_irq + 2 : 0;
1352 }
1353 -EXPORT_SYMBOL(bcma_core_mips_irq);
1354 +EXPORT_SYMBOL(bcma_core_irq);
1355
1356 static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
1357 {
1358 @@ -114,8 +149,8 @@ static void bcma_core_mips_set_irq(struc
1359 bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
1360 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
1361 ~(1 << irqflag));
1362 - else
1363 - bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
1364 + else if (oldirq != 5)
1365 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
1366
1367 /* assign the new one */
1368 if (irq == 0) {
1369 @@ -123,9 +158,9 @@ static void bcma_core_mips_set_irq(struc
1370 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
1371 (1 << irqflag));
1372 } else {
1373 - u32 oldirqflag = bcma_read32(mdev,
1374 - BCMA_MIPS_MIPS74K_INTMASK(irq));
1375 - if (oldirqflag) {
1376 + u32 irqinitmask = bcma_read32(mdev,
1377 + BCMA_MIPS_MIPS74K_INTMASK(irq));
1378 + if (irqinitmask) {
1379 struct bcma_device *core;
1380
1381 /* backplane irq line is in use, find out who uses
1382 @@ -133,7 +168,7 @@ static void bcma_core_mips_set_irq(struc
1383 */
1384 list_for_each_entry(core, &bus->cores, list) {
1385 if ((1 << bcma_core_mips_irqflag(core)) ==
1386 - oldirqflag) {
1387 + irqinitmask) {
1388 bcma_core_mips_set_irq(core, 0);
1389 break;
1390 }
1391 @@ -143,15 +178,31 @@ static void bcma_core_mips_set_irq(struc
1392 1 << irqflag);
1393 }
1394
1395 - bcma_info(bus, "set_irq: core 0x%04x, irq %d => %d\n",
1396 - dev->id.id, oldirq + 2, irq + 2);
1397 + bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n",
1398 + dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2);
1399 +}
1400 +
1401 +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
1402 + u16 coreid, u8 unit)
1403 +{
1404 + struct bcma_device *core;
1405 +
1406 + core = bcma_find_core_unit(bus, coreid, unit);
1407 + if (!core) {
1408 + bcma_warn(bus,
1409 + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
1410 + coreid, unit);
1411 + return;
1412 + }
1413 +
1414 + bcma_core_mips_set_irq(core, irq);
1415 }
1416
1417 static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
1418 {
1419 int i;
1420 static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
1421 - printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
1422 + printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
1423 for (i = 0; i <= 6; i++)
1424 printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
1425 printk("\n");
1426 @@ -171,7 +222,7 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
1427 struct bcma_bus *bus = mcore->core->bus;
1428
1429 if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
1430 - return bcma_pmu_get_clockcpu(&bus->drv_cc);
1431 + return bcma_pmu_get_cpu_clock(&bus->drv_cc);
1432
1433 bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
1434 return 0;
1435 @@ -181,85 +232,143 @@ EXPORT_SYMBOL(bcma_cpu_clock);
1436 static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
1437 {
1438 struct bcma_bus *bus = mcore->core->bus;
1439 + struct bcma_drv_cc *cc = &bus->drv_cc;
1440 + struct bcma_pflash *pflash = &cc->pflash;
1441
1442 - switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
1443 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
1444 case BCMA_CC_FLASHT_STSER:
1445 case BCMA_CC_FLASHT_ATSER:
1446 bcma_debug(bus, "Found serial flash\n");
1447 - bcma_sflash_init(&bus->drv_cc);
1448 + bcma_sflash_init(cc);
1449 break;
1450 case BCMA_CC_FLASHT_PARA:
1451 bcma_debug(bus, "Found parallel flash\n");
1452 - bus->drv_cc.pflash.window = 0x1c000000;
1453 - bus->drv_cc.pflash.window_size = 0x02000000;
1454 + pflash->present = true;
1455 + pflash->window = BCMA_SOC_FLASH2;
1456 + pflash->window_size = BCMA_SOC_FLASH2_SZ;
1457
1458 - if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
1459 + if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
1460 BCMA_CC_FLASH_CFG_DS) == 0)
1461 - bus->drv_cc.pflash.buswidth = 1;
1462 + pflash->buswidth = 1;
1463 else
1464 - bus->drv_cc.pflash.buswidth = 2;
1465 + pflash->buswidth = 2;
1466 +
1467 + bcma_pflash_data.width = pflash->buswidth;
1468 + bcma_pflash_resource.start = pflash->window;
1469 + bcma_pflash_resource.end = pflash->window + pflash->window_size;
1470 +
1471 break;
1472 default:
1473 bcma_err(bus, "Flash type not supported\n");
1474 }
1475
1476 - if (bus->drv_cc.core->id.rev == 38 ||
1477 + if (cc->core->id.rev == 38 ||
1478 bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
1479 - if (bus->drv_cc.capabilities & BCMA_CC_CAP_NFLASH) {
1480 + if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
1481 bcma_debug(bus, "Found NAND flash\n");
1482 - bcma_nflash_init(&bus->drv_cc);
1483 + bcma_nflash_init(cc);
1484 }
1485 }
1486 }
1487
1488 +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
1489 +{
1490 + struct bcma_bus *bus = mcore->core->bus;
1491 +
1492 + if (mcore->early_setup_done)
1493 + return;
1494 +
1495 + bcma_chipco_serial_init(&bus->drv_cc);
1496 + bcma_core_mips_flash_detect(mcore);
1497 +
1498 + mcore->early_setup_done = true;
1499 +}
1500 +
1501 +static void bcma_fix_i2s_irqflag(struct bcma_bus *bus)
1502 +{
1503 + struct bcma_device *cpu, *pcie, *i2s;
1504 +
1505 + /* Fixup the interrupts in 4716/4748 for i2s core (2010 Broadcom SDK)
1506 + * (IRQ flags > 7 are ignored when setting the interrupt masks)
1507 + */
1508 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4716 &&
1509 + bus->chipinfo.id != BCMA_CHIP_ID_BCM4748)
1510 + return;
1511 +
1512 + cpu = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1513 + pcie = bcma_find_core(bus, BCMA_CORE_PCIE);
1514 + i2s = bcma_find_core(bus, BCMA_CORE_I2S);
1515 + if (cpu && pcie && i2s &&
1516 + bcma_aread32(cpu, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
1517 + bcma_aread32(pcie, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
1518 + bcma_aread32(i2s, BCMA_MIPS_OOBSELOUTA30) == 0x88) {
1519 + bcma_awrite32(cpu, BCMA_MIPS_OOBSELINA74, 0x07060504);
1520 + bcma_awrite32(pcie, BCMA_MIPS_OOBSELINA74, 0x07060504);
1521 + bcma_awrite32(i2s, BCMA_MIPS_OOBSELOUTA30, 0x87);
1522 + bcma_debug(bus,
1523 + "Moved i2s interrupt to oob line 7 instead of 8\n");
1524 + }
1525 +}
1526 +
1527 void bcma_core_mips_init(struct bcma_drv_mips *mcore)
1528 {
1529 struct bcma_bus *bus;
1530 struct bcma_device *core;
1531 bus = mcore->core->bus;
1532
1533 - bcma_info(bus, "Initializing MIPS core...\n");
1534 + if (mcore->setup_done)
1535 + return;
1536
1537 - if (!mcore->setup_done)
1538 - mcore->assigned_irqs = 1;
1539 + bcma_debug(bus, "Initializing MIPS core...\n");
1540
1541 - /* Assign IRQs to all cores on the bus */
1542 - list_for_each_entry(core, &bus->cores, list) {
1543 - int mips_irq;
1544 - if (core->irq)
1545 - continue;
1546 -
1547 - mips_irq = bcma_core_mips_irq(core);
1548 - if (mips_irq > 4)
1549 - core->irq = 0;
1550 - else
1551 - core->irq = mips_irq + 2;
1552 - if (core->irq > 5)
1553 - continue;
1554 - switch (core->id.id) {
1555 - case BCMA_CORE_PCI:
1556 - case BCMA_CORE_PCIE:
1557 - case BCMA_CORE_ETHERNET:
1558 - case BCMA_CORE_ETHERNET_GBIT:
1559 - case BCMA_CORE_MAC_GBIT:
1560 - case BCMA_CORE_80211:
1561 - case BCMA_CORE_USB20_HOST:
1562 - /* These devices get their own IRQ line if available,
1563 - * the rest goes on IRQ0
1564 - */
1565 - if (mcore->assigned_irqs <= 4)
1566 - bcma_core_mips_set_irq(core,
1567 - mcore->assigned_irqs++);
1568 - break;
1569 + bcma_core_mips_early_init(mcore);
1570 +
1571 + bcma_fix_i2s_irqflag(bus);
1572 +
1573 + switch (bus->chipinfo.id) {
1574 + case BCMA_CHIP_ID_BCM4716:
1575 + case BCMA_CHIP_ID_BCM4748:
1576 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1577 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1578 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
1579 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
1580 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1581 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
1582 + break;
1583 + case BCMA_CHIP_ID_BCM5356:
1584 + case BCMA_CHIP_ID_BCM47162:
1585 + case BCMA_CHIP_ID_BCM53572:
1586 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1587 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1588 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1589 + break;
1590 + case BCMA_CHIP_ID_BCM5357:
1591 + case BCMA_CHIP_ID_BCM4749:
1592 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1593 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1594 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
1595 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1596 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
1597 + break;
1598 + case BCMA_CHIP_ID_BCM4706:
1599 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
1600 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
1601 + 0);
1602 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
1603 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
1604 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
1605 + 0);
1606 + break;
1607 + default:
1608 + list_for_each_entry(core, &bus->cores, list) {
1609 + core->irq = bcma_core_irq(core);
1610 }
1611 + bcma_err(bus,
1612 + "Unknown device (0x%x) found, can not configure IRQs\n",
1613 + bus->chipinfo.id);
1614 }
1615 - bcma_info(bus, "IRQ reconfiguration done\n");
1616 + bcma_debug(bus, "IRQ reconfiguration done\n");
1617 bcma_core_mips_dump_irq(bus);
1618
1619 - if (mcore->setup_done)
1620 - return;
1621 -
1622 - bcma_chipco_serial_init(&bus->drv_cc);
1623 - bcma_core_mips_flash_detect(mcore);
1624 mcore->setup_done = true;
1625 }
1626 --- a/drivers/bcma/driver_pci.c
1627 +++ b/drivers/bcma/driver_pci.c
1628 @@ -31,7 +31,7 @@ static void bcma_pcie_write(struct bcma_
1629 pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
1630 }
1631
1632 -static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
1633 +static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u16 phy)
1634 {
1635 u32 v;
1636 int i;
1637 @@ -51,11 +51,11 @@ static void bcma_pcie_mdio_set_phy(struc
1638 v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
1639 if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
1640 break;
1641 - msleep(1);
1642 + usleep_range(1000, 2000);
1643 }
1644 }
1645
1646 -static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
1647 +static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address)
1648 {
1649 int max_retries = 10;
1650 u16 ret = 0;
1651 @@ -92,13 +92,13 @@ static u16 bcma_pcie_mdio_read(struct bc
1652 ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
1653 break;
1654 }
1655 - msleep(1);
1656 + usleep_range(1000, 2000);
1657 }
1658 pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
1659 return ret;
1660 }
1661
1662 -static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
1663 +static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device,
1664 u8 address, u16 data)
1665 {
1666 int max_retries = 10;
1667 @@ -132,11 +132,18 @@ static void bcma_pcie_mdio_write(struct
1668 v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
1669 if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
1670 break;
1671 - msleep(1);
1672 + usleep_range(1000, 2000);
1673 }
1674 pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
1675 }
1676
1677 +static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device,
1678 + u8 address, u16 data)
1679 +{
1680 + bcma_pcie_mdio_write(pc, device, address, data);
1681 + return bcma_pcie_mdio_read(pc, device, address);
1682 +}
1683 +
1684 /**************************************************
1685 * Workarounds.
1686 **************************************************/
1687 @@ -203,6 +210,25 @@ static void bcma_core_pci_config_fixup(s
1688 }
1689 }
1690
1691 +static void bcma_core_pci_power_save(struct bcma_drv_pci *pc, bool up)
1692 +{
1693 + u16 data;
1694 +
1695 + if (pc->core->id.rev >= 15 && pc->core->id.rev <= 20) {
1696 + data = up ? 0x74 : 0x7C;
1697 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1698 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7F64);
1699 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1700 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
1701 + } else if (pc->core->id.rev >= 21 && pc->core->id.rev <= 22) {
1702 + data = up ? 0x75 : 0x7D;
1703 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1704 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7E65);
1705 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1706 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
1707 + }
1708 +}
1709 +
1710 /**************************************************
1711 * Init.
1712 **************************************************/
1713 @@ -262,7 +288,7 @@ out:
1714 }
1715 EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
1716
1717 -void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
1718 +static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
1719 {
1720 u32 w;
1721
1722 @@ -274,4 +300,33 @@ void bcma_core_pci_extend_L1timer(struct
1723 bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
1724 bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
1725 }
1726 -EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
1727 +
1728 +void bcma_core_pci_up(struct bcma_bus *bus)
1729 +{
1730 + struct bcma_drv_pci *pc;
1731 +
1732 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
1733 + return;
1734 +
1735 + pc = &bus->drv_pci[0];
1736 +
1737 + bcma_core_pci_power_save(pc, true);
1738 +
1739 + bcma_core_pci_extend_L1timer(pc, true);
1740 +}
1741 +EXPORT_SYMBOL_GPL(bcma_core_pci_up);
1742 +
1743 +void bcma_core_pci_down(struct bcma_bus *bus)
1744 +{
1745 + struct bcma_drv_pci *pc;
1746 +
1747 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
1748 + return;
1749 +
1750 + pc = &bus->drv_pci[0];
1751 +
1752 + bcma_core_pci_extend_L1timer(pc, false);
1753 +
1754 + bcma_core_pci_power_save(pc, false);
1755 +}
1756 +EXPORT_SYMBOL_GPL(bcma_core_pci_down);
1757 --- a/drivers/bcma/driver_pci_host.c
1758 +++ b/drivers/bcma/driver_pci_host.c
1759 @@ -35,11 +35,6 @@ bool __devinit bcma_core_pci_is_in_hostm
1760 chipid_top != 0x5300)
1761 return false;
1762
1763 - if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1764 - bcma_info(bus, "This PCI core is disabled and not working\n");
1765 - return false;
1766 - }
1767 -
1768 bcma_core_enable(pc->core, 0);
1769
1770 return !mips_busprobe32(tmp, pc->core->io_addr);
1771 @@ -99,19 +94,19 @@ static int bcma_extpci_read_config(struc
1772 if (dev == 0) {
1773 /* we support only two functions on device 0 */
1774 if (func > 1)
1775 - return -EINVAL;
1776 + goto out;
1777
1778 /* accesses to config registers with offsets >= 256
1779 * requires indirect access.
1780 */
1781 if (off >= PCI_CONFIG_SPACE_SIZE) {
1782 addr = (func << 12);
1783 - addr |= (off & 0x0FFF);
1784 + addr |= (off & 0x0FFC);
1785 val = bcma_pcie_read_config(pc, addr);
1786 } else {
1787 addr = BCMA_CORE_PCI_PCICFG0;
1788 addr |= (func << 8);
1789 - addr |= (off & 0xfc);
1790 + addr |= (off & 0xFC);
1791 val = pcicore_read32(pc, addr);
1792 }
1793 } else {
1794 @@ -124,11 +119,9 @@ static int bcma_extpci_read_config(struc
1795 goto out;
1796
1797 if (mips_busprobe32(val, mmio)) {
1798 - val = 0xffffffff;
1799 + val = 0xFFFFFFFF;
1800 goto unmap;
1801 }
1802 -
1803 - val = readl(mmio);
1804 }
1805 val >>= (8 * (off & 3));
1806
1807 @@ -156,7 +149,7 @@ static int bcma_extpci_write_config(stru
1808 const void *buf, int len)
1809 {
1810 int err = -EINVAL;
1811 - u32 addr = 0, val = 0;
1812 + u32 addr, val;
1813 void __iomem *mmio = 0;
1814 u16 chipid = pc->core->bus->chipinfo.id;
1815
1816 @@ -164,16 +157,22 @@ static int bcma_extpci_write_config(stru
1817 if (unlikely(len != 1 && len != 2 && len != 4))
1818 goto out;
1819 if (dev == 0) {
1820 + /* we support only two functions on device 0 */
1821 + if (func > 1)
1822 + goto out;
1823 +
1824 /* accesses to config registers with offsets >= 256
1825 * requires indirect access.
1826 */
1827 - if (off < PCI_CONFIG_SPACE_SIZE) {
1828 - addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
1829 + if (off >= PCI_CONFIG_SPACE_SIZE) {
1830 + addr = (func << 12);
1831 + addr |= (off & 0x0FFC);
1832 + val = bcma_pcie_read_config(pc, addr);
1833 + } else {
1834 + addr = BCMA_CORE_PCI_PCICFG0;
1835 addr |= (func << 8);
1836 - addr |= (off & 0xfc);
1837 - mmio = ioremap_nocache(addr, sizeof(val));
1838 - if (!mmio)
1839 - goto out;
1840 + addr |= (off & 0xFC);
1841 + val = pcicore_read32(pc, addr);
1842 }
1843 } else {
1844 addr = bcma_get_cfgspace_addr(pc, dev, func, off);
1845 @@ -185,19 +184,17 @@ static int bcma_extpci_write_config(stru
1846 goto out;
1847
1848 if (mips_busprobe32(val, mmio)) {
1849 - val = 0xffffffff;
1850 + val = 0xFFFFFFFF;
1851 goto unmap;
1852 }
1853 }
1854
1855 switch (len) {
1856 case 1:
1857 - val = readl(mmio);
1858 val &= ~(0xFF << (8 * (off & 3)));
1859 val |= *((const u8 *)buf) << (8 * (off & 3));
1860 break;
1861 case 2:
1862 - val = readl(mmio);
1863 val &= ~(0xFFFF << (8 * (off & 3)));
1864 val |= *((const u16 *)buf) << (8 * (off & 3));
1865 break;
1866 @@ -205,13 +202,14 @@ static int bcma_extpci_write_config(stru
1867 val = *((const u32 *)buf);
1868 break;
1869 }
1870 - if (dev == 0 && !addr) {
1871 + if (dev == 0) {
1872 /* accesses to config registers with offsets >= 256
1873 * requires indirect access.
1874 */
1875 - addr = (func << 12);
1876 - addr |= (off & 0x0FFF);
1877 - bcma_pcie_write_config(pc, addr, val);
1878 + if (off >= PCI_CONFIG_SPACE_SIZE)
1879 + bcma_pcie_write_config(pc, addr, val);
1880 + else
1881 + pcicore_write32(pc, addr, val);
1882 } else {
1883 writel(val, mmio);
1884
1885 @@ -282,7 +280,7 @@ static u8 __devinit bcma_find_pci_capabi
1886 /* check for Header type 0 */
1887 bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
1888 sizeof(u8));
1889 - if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
1890 + if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
1891 return cap_ptr;
1892
1893 /* check if the capability pointer field exists */
1894 @@ -396,12 +394,19 @@ void __devinit bcma_core_pci_hostmode_in
1895
1896 bcma_info(bus, "PCIEcore in host mode found\n");
1897
1898 + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1899 + bcma_info(bus, "This PCIE core is disabled and not working\n");
1900 + return;
1901 + }
1902 +
1903 pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
1904 if (!pc_host) {
1905 bcma_err(bus, "can not allocate memory");
1906 return;
1907 }
1908
1909 + spin_lock_init(&pc_host->cfgspace_lock);
1910 +
1911 pc->host_controller = pc_host;
1912 pc_host->pci_controller.io_resource = &pc_host->io_resource;
1913 pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
1914 @@ -425,9 +430,9 @@ void __devinit bcma_core_pci_hostmode_in
1915 pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
1916
1917 /* Reset RC */
1918 - udelay(3000);
1919 + usleep_range(3000, 5000);
1920 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
1921 - udelay(1000);
1922 + msleep(50);
1923 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
1924 BCMA_CORE_PCI_CTL_RST_OE);
1925
1926 @@ -452,6 +457,8 @@ void __devinit bcma_core_pci_hostmode_in
1927 pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
1928 pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
1929 BCMA_SOC_PCI_MEM_SZ - 1;
1930 + pc_host->io_resource.start = 0x100;
1931 + pc_host->io_resource.end = 0x47F;
1932 pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
1933 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1934 tmp | BCMA_SOC_PCI_MEM);
1935 @@ -459,6 +466,8 @@ void __devinit bcma_core_pci_hostmode_in
1936 pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
1937 pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
1938 BCMA_SOC_PCI_MEM_SZ - 1;
1939 + pc_host->io_resource.start = 0x480;
1940 + pc_host->io_resource.end = 0x7FF;
1941 pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
1942 pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
1943 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1944 @@ -481,10 +490,21 @@ void __devinit bcma_core_pci_hostmode_in
1945 * before issuing configuration requests to PCI Express
1946 * devices.
1947 */
1948 - udelay(100000);
1949 + msleep(100);
1950
1951 bcma_core_pci_enable_crs(pc);
1952
1953 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706 ||
1954 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4716) {
1955 + u16 val16;
1956 + bcma_extpci_read_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
1957 + &val16, sizeof(val16));
1958 + val16 |= (2 << 5); /* Max payload size of 512 */
1959 + val16 |= (2 << 12); /* MRRS 512 */
1960 + bcma_extpci_write_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
1961 + &val16, sizeof(val16));
1962 + }
1963 +
1964 /* Enable PCI bridge BAR0 memory & master access */
1965 tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
1966 bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
1967 @@ -501,7 +521,7 @@ void __devinit bcma_core_pci_hostmode_in
1968 set_io_port_base(pc_host->pci_controller.io_map_base);
1969 /* Give some time to the PCI controller to configure itself with the new
1970 * values. Not waiting at this point causes crashes of the machine. */
1971 - mdelay(10);
1972 + usleep_range(10000, 15000);
1973 register_pci_controller(&pc_host->pci_controller);
1974 return;
1975 }
1976 @@ -534,7 +554,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_
1977 static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
1978 {
1979 struct resource *res;
1980 - int pos;
1981 + int pos, err;
1982
1983 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
1984 /* This is not a device on the PCI-core bridge. */
1985 @@ -547,8 +567,12 @@ static void bcma_core_pci_fixup_addresse
1986
1987 for (pos = 0; pos < 6; pos++) {
1988 res = &dev->resource[pos];
1989 - if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM))
1990 - pci_assign_resource(dev, pos);
1991 + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) {
1992 + err = pci_assign_resource(dev, pos);
1993 + if (err)
1994 + pr_err("PCI: Problem fixing up the addresses on %s\n",
1995 + pci_name(dev));
1996 + }
1997 }
1998 }
1999 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
2000 @@ -558,6 +582,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI
2001 int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
2002 {
2003 struct bcma_drv_pci_host *pc_host;
2004 + int readrq;
2005
2006 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
2007 /* This is not a device on the PCI-core bridge. */
2008 @@ -569,9 +594,14 @@ int bcma_core_pci_plat_dev_init(struct p
2009 pr_info("PCI: Fixing up device %s\n", pci_name(dev));
2010
2011 /* Fix up interrupt lines */
2012 - dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2;
2013 + dev->irq = bcma_core_irq(pc_host->pdev->core);
2014 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
2015
2016 + readrq = pcie_get_readrq(dev);
2017 + if (readrq > 128) {
2018 + pr_info("change PCIe max read request size from %i to 128\n", readrq);
2019 + pcie_set_readrq(dev, 128);
2020 + }
2021 return 0;
2022 }
2023 EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
2024 @@ -588,6 +618,6 @@ int bcma_core_pci_pcibios_map_irq(const
2025
2026 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
2027 pci_ops);
2028 - return bcma_core_mips_irq(pc_host->pdev->core) + 2;
2029 + return bcma_core_irq(pc_host->pdev->core);
2030 }
2031 EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
2032 --- a/drivers/bcma/host_pci.c
2033 +++ b/drivers/bcma/host_pci.c
2034 @@ -77,8 +77,8 @@ static void bcma_host_pci_write32(struct
2035 }
2036
2037 #ifdef CONFIG_BCMA_BLOCKIO
2038 -void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
2039 - size_t count, u16 offset, u8 reg_width)
2040 +static void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
2041 + size_t count, u16 offset, u8 reg_width)
2042 {
2043 void __iomem *addr = core->bus->mmio + offset;
2044 if (core->bus->mapped_core != core)
2045 @@ -100,8 +100,9 @@ void bcma_host_pci_block_read(struct bcm
2046 }
2047 }
2048
2049 -void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
2050 - size_t count, u16 offset, u8 reg_width)
2051 +static void bcma_host_pci_block_write(struct bcma_device *core,
2052 + const void *buffer, size_t count,
2053 + u16 offset, u8 reg_width)
2054 {
2055 void __iomem *addr = core->bus->mmio + offset;
2056 if (core->bus->mapped_core != core)
2057 @@ -139,7 +140,7 @@ static void bcma_host_pci_awrite32(struc
2058 iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
2059 }
2060
2061 -const struct bcma_host_ops bcma_host_pci_ops = {
2062 +static const struct bcma_host_ops bcma_host_pci_ops = {
2063 .read8 = bcma_host_pci_read8,
2064 .read16 = bcma_host_pci_read16,
2065 .read32 = bcma_host_pci_read32,
2066 @@ -237,7 +238,7 @@ static void __devexit bcma_host_pci_remo
2067 pci_set_drvdata(dev, NULL);
2068 }
2069
2070 -#ifdef CONFIG_PM
2071 +#ifdef CONFIG_PM_SLEEP
2072 static int bcma_host_pci_suspend(struct device *dev)
2073 {
2074 struct pci_dev *pdev = to_pci_dev(dev);
2075 @@ -260,11 +261,11 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
2076 bcma_host_pci_resume);
2077 #define BCMA_PM_OPS (&bcma_pm_ops)
2078
2079 -#else /* CONFIG_PM */
2080 +#else /* CONFIG_PM_SLEEP */
2081
2082 #define BCMA_PM_OPS NULL
2083
2084 -#endif /* CONFIG_PM */
2085 +#endif /* CONFIG_PM_SLEEP */
2086
2087 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
2088 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
2089 @@ -272,7 +273,9 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_
2090 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
2091 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
2092 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
2093 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
2094 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
2095 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
2096 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
2097 { 0, },
2098 };
2099 --- a/drivers/bcma/host_soc.c
2100 +++ b/drivers/bcma/host_soc.c
2101 @@ -143,7 +143,7 @@ static void bcma_host_soc_awrite32(struc
2102 writel(value, core->io_wrap + offset);
2103 }
2104
2105 -const struct bcma_host_ops bcma_host_soc_ops = {
2106 +static const struct bcma_host_ops bcma_host_soc_ops = {
2107 .read8 = bcma_host_soc_read8,
2108 .read16 = bcma_host_soc_read16,
2109 .read32 = bcma_host_soc_read32,
2110 --- a/drivers/bcma/main.c
2111 +++ b/drivers/bcma/main.c
2112 @@ -7,6 +7,7 @@
2113
2114 #include "bcma_private.h"
2115 #include <linux/module.h>
2116 +#include <linux/platform_device.h>
2117 #include <linux/bcma/bcma.h>
2118 #include <linux/slab.h>
2119
2120 @@ -80,6 +81,37 @@ struct bcma_device *bcma_find_core(struc
2121 }
2122 EXPORT_SYMBOL_GPL(bcma_find_core);
2123
2124 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
2125 + u8 unit)
2126 +{
2127 + struct bcma_device *core;
2128 +
2129 + list_for_each_entry(core, &bus->cores, list) {
2130 + if (core->id.id == coreid && core->core_unit == unit)
2131 + return core;
2132 + }
2133 + return NULL;
2134 +}
2135 +
2136 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
2137 + int timeout)
2138 +{
2139 + unsigned long deadline = jiffies + timeout;
2140 + u32 val;
2141 +
2142 + do {
2143 + val = bcma_read32(core, reg);
2144 + if ((val & mask) == value)
2145 + return true;
2146 + cpu_relax();
2147 + udelay(10);
2148 + } while (!time_after_eq(jiffies, deadline));
2149 +
2150 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
2151 +
2152 + return false;
2153 +}
2154 +
2155 static void bcma_release_core_dev(struct device *dev)
2156 {
2157 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
2158 @@ -107,6 +139,11 @@ static int bcma_register_cores(struct bc
2159 continue;
2160 }
2161
2162 + /* Only first GMAC core on BCM4706 is connected and working */
2163 + if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
2164 + core->core_unit > 0)
2165 + continue;
2166 +
2167 core->dev.release = bcma_release_core_dev;
2168 core->dev.bus = &bcma_bus_type;
2169 dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
2170 @@ -136,6 +173,41 @@ static int bcma_register_cores(struct bc
2171 dev_id++;
2172 }
2173
2174 +#ifdef CONFIG_BCMA_DRIVER_MIPS
2175 + if (bus->drv_cc.pflash.present) {
2176 + err = platform_device_register(&bcma_pflash_dev);
2177 + if (err)
2178 + bcma_err(bus, "Error registering parallel flash\n");
2179 + }
2180 +#endif
2181 +
2182 +#ifdef CONFIG_BCMA_SFLASH
2183 + if (bus->drv_cc.sflash.present) {
2184 + err = platform_device_register(&bcma_sflash_dev);
2185 + if (err)
2186 + bcma_err(bus, "Error registering serial flash\n");
2187 + }
2188 +#endif
2189 +
2190 +#ifdef CONFIG_BCMA_NFLASH
2191 + if (bus->drv_cc.nflash.present) {
2192 + err = platform_device_register(&bcma_nflash_dev);
2193 + if (err)
2194 + bcma_err(bus, "Error registering NAND flash\n");
2195 + }
2196 +#endif
2197 + err = bcma_gpio_init(&bus->drv_cc);
2198 + if (err == -ENOTSUPP)
2199 + bcma_debug(bus, "GPIO driver not activated\n");
2200 + else if (err)
2201 + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
2202 +
2203 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
2204 + err = bcma_chipco_watchdog_register(&bus->drv_cc);
2205 + if (err)
2206 + bcma_err(bus, "Error registering watchdog driver\n");
2207 + }
2208 +
2209 return 0;
2210 }
2211
2212 @@ -148,6 +220,8 @@ static void bcma_unregister_cores(struct
2213 if (core->dev_registered)
2214 device_unregister(&core->dev);
2215 }
2216 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
2217 + platform_device_unregister(bus->drv_cc.watchdog);
2218 }
2219
2220 int __devinit bcma_bus_register(struct bcma_bus *bus)
2221 @@ -163,9 +237,23 @@ int __devinit bcma_bus_register(struct b
2222 err = bcma_bus_scan(bus);
2223 if (err) {
2224 bcma_err(bus, "Failed to scan: %d\n", err);
2225 - return -1;
2226 + return err;
2227 }
2228
2229 + /* Early init CC core */
2230 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
2231 + if (core) {
2232 + bus->drv_cc.core = core;
2233 + bcma_core_chipcommon_early_init(&bus->drv_cc);
2234 + }
2235 +
2236 + /* Try to get SPROM */
2237 + err = bcma_sprom_get(bus);
2238 + if (err == -ENOENT) {
2239 + bcma_err(bus, "No SPROM available\n");
2240 + } else if (err)
2241 + bcma_err(bus, "Failed to get SPROM: %d\n", err);
2242 +
2243 /* Init CC core */
2244 core = bcma_find_core(bus, bcma_cc_core_id(bus));
2245 if (core) {
2246 @@ -181,10 +269,17 @@ int __devinit bcma_bus_register(struct b
2247 }
2248
2249 /* Init PCIE core */
2250 - core = bcma_find_core(bus, BCMA_CORE_PCIE);
2251 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
2252 if (core) {
2253 - bus->drv_pci.core = core;
2254 - bcma_core_pci_init(&bus->drv_pci);
2255 + bus->drv_pci[0].core = core;
2256 + bcma_core_pci_init(&bus->drv_pci[0]);
2257 + }
2258 +
2259 + /* Init PCIE core */
2260 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
2261 + if (core) {
2262 + bus->drv_pci[1].core = core;
2263 + bcma_core_pci_init(&bus->drv_pci[1]);
2264 }
2265
2266 /* Init GBIT MAC COMMON core */
2267 @@ -194,13 +289,6 @@ int __devinit bcma_bus_register(struct b
2268 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
2269 }
2270
2271 - /* Try to get SPROM */
2272 - err = bcma_sprom_get(bus);
2273 - if (err == -ENOENT) {
2274 - bcma_err(bus, "No SPROM available\n");
2275 - } else if (err)
2276 - bcma_err(bus, "Failed to get SPROM: %d\n", err);
2277 -
2278 /* Register found cores */
2279 bcma_register_cores(bus);
2280
2281 @@ -211,7 +299,24 @@ int __devinit bcma_bus_register(struct b
2282
2283 void bcma_bus_unregister(struct bcma_bus *bus)
2284 {
2285 + struct bcma_device *cores[3];
2286 + int err;
2287 +
2288 + err = bcma_gpio_unregister(&bus->drv_cc);
2289 + if (err == -EBUSY)
2290 + bcma_err(bus, "Some GPIOs are still in use.\n");
2291 + else if (err)
2292 + bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
2293 +
2294 + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
2295 + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
2296 + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
2297 +
2298 bcma_unregister_cores(bus);
2299 +
2300 + kfree(cores[2]);
2301 + kfree(cores[1]);
2302 + kfree(cores[0]);
2303 }
2304
2305 int __init bcma_bus_early_register(struct bcma_bus *bus,
2306 @@ -248,18 +353,18 @@ int __init bcma_bus_early_register(struc
2307 return -1;
2308 }
2309
2310 - /* Init CC core */
2311 + /* Early init CC core */
2312 core = bcma_find_core(bus, bcma_cc_core_id(bus));
2313 if (core) {
2314 bus->drv_cc.core = core;
2315 - bcma_core_chipcommon_init(&bus->drv_cc);
2316 + bcma_core_chipcommon_early_init(&bus->drv_cc);
2317 }
2318
2319 - /* Init MIPS core */
2320 + /* Early init MIPS core */
2321 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
2322 if (core) {
2323 bus->drv_mips.core = core;
2324 - bcma_core_mips_init(&bus->drv_mips);
2325 + bcma_core_mips_early_init(&bus->drv_mips);
2326 }
2327
2328 bcma_info(bus, "Early bus registered\n");
2329 --- a/drivers/bcma/scan.c
2330 +++ b/drivers/bcma/scan.c
2331 @@ -32,6 +32,18 @@ static const struct bcma_device_id_name
2332 { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
2333 { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
2334 { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
2335 + { BCMA_CORE_PCIEG2, "PCIe Gen 2" },
2336 + { BCMA_CORE_DMA, "DMA" },
2337 + { BCMA_CORE_SDIO3, "SDIO3" },
2338 + { BCMA_CORE_USB20, "USB 2.0" },
2339 + { BCMA_CORE_USB30, "USB 3.0" },
2340 + { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" },
2341 + { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" },
2342 + { BCMA_CORE_ROM, "ROM" },
2343 + { BCMA_CORE_NAND, "NAND flash controller" },
2344 + { BCMA_CORE_QSPI, "SPI flash controller" },
2345 + { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" },
2346 + { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" },
2347 { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
2348 { BCMA_CORE_ALTA, "ALTA (I2S)" },
2349 { BCMA_CORE_INVALID, "Invalid" },
2350 @@ -84,6 +96,8 @@ static const struct bcma_device_id_name
2351 { BCMA_CORE_I2S, "I2S" },
2352 { BCMA_CORE_SDR_DDR1_MEM_CTL, "SDR/DDR1 Memory Controller" },
2353 { BCMA_CORE_SHIM, "SHIM" },
2354 + { BCMA_CORE_PCIE2, "PCIe Gen2" },
2355 + { BCMA_CORE_ARM_CR4, "ARM CR4" },
2356 { BCMA_CORE_DEFAULT, "Default" },
2357 };
2358
2359 @@ -137,19 +151,19 @@ static void bcma_scan_switch_core(struct
2360 addr);
2361 }
2362
2363 -static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 **eromptr)
2364 +static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 __iomem **eromptr)
2365 {
2366 u32 ent = readl(*eromptr);
2367 (*eromptr)++;
2368 return ent;
2369 }
2370
2371 -static void bcma_erom_push_ent(u32 **eromptr)
2372 +static void bcma_erom_push_ent(u32 __iomem **eromptr)
2373 {
2374 (*eromptr)--;
2375 }
2376
2377 -static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 **eromptr)
2378 +static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 __iomem **eromptr)
2379 {
2380 u32 ent = bcma_erom_get_ent(bus, eromptr);
2381 if (!(ent & SCAN_ER_VALID))
2382 @@ -159,14 +173,14 @@ static s32 bcma_erom_get_ci(struct bcma_
2383 return ent;
2384 }
2385
2386 -static bool bcma_erom_is_end(struct bcma_bus *bus, u32 **eromptr)
2387 +static bool bcma_erom_is_end(struct bcma_bus *bus, u32 __iomem **eromptr)
2388 {
2389 u32 ent = bcma_erom_get_ent(bus, eromptr);
2390 bcma_erom_push_ent(eromptr);
2391 return (ent == (SCAN_ER_TAG_END | SCAN_ER_VALID));
2392 }
2393
2394 -static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 **eromptr)
2395 +static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 __iomem **eromptr)
2396 {
2397 u32 ent = bcma_erom_get_ent(bus, eromptr);
2398 bcma_erom_push_ent(eromptr);
2399 @@ -175,7 +189,7 @@ static bool bcma_erom_is_bridge(struct b
2400 ((ent & SCAN_ADDR_TYPE) == SCAN_ADDR_TYPE_BRIDGE));
2401 }
2402
2403 -static void bcma_erom_skip_component(struct bcma_bus *bus, u32 **eromptr)
2404 +static void bcma_erom_skip_component(struct bcma_bus *bus, u32 __iomem **eromptr)
2405 {
2406 u32 ent;
2407 while (1) {
2408 @@ -189,7 +203,7 @@ static void bcma_erom_skip_component(str
2409 bcma_erom_push_ent(eromptr);
2410 }
2411
2412 -static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr)
2413 +static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 __iomem **eromptr)
2414 {
2415 u32 ent = bcma_erom_get_ent(bus, eromptr);
2416 if (!(ent & SCAN_ER_VALID))
2417 @@ -199,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct
2418 return ent;
2419 }
2420
2421 -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 **eromptr,
2422 +static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
2423 u32 type, u8 port)
2424 {
2425 u32 addrl, addrh, sizel, sizeh = 0;
2426 @@ -211,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc
2427 ((ent & SCAN_ADDR_TYPE) != type) ||
2428 (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
2429 bcma_erom_push_ent(eromptr);
2430 - return -EINVAL;
2431 + return (u32)-EINVAL;
2432 }
2433
2434 addrl = ent & SCAN_ADDR_ADDR;
2435 @@ -255,11 +269,13 @@ static struct bcma_device *bcma_find_cor
2436 return NULL;
2437 }
2438
2439 +#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
2440 +
2441 static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
2442 struct bcma_device_id *match, int core_num,
2443 struct bcma_device *core)
2444 {
2445 - s32 tmp;
2446 + u32 tmp;
2447 u8 i, j;
2448 s32 cia, cib;
2449 u8 ports[2], wrappers[2];
2450 @@ -337,11 +353,11 @@ static int bcma_get_next_core(struct bcm
2451 * the main register space for the core
2452 */
2453 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
2454 - if (tmp <= 0) {
2455 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
2456 /* Try again to see if it is a bridge */
2457 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2458 SCAN_ADDR_TYPE_BRIDGE, 0);
2459 - if (tmp <= 0) {
2460 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
2461 return -EILSEQ;
2462 } else {
2463 bcma_info(bus, "Bridge found\n");
2464 @@ -355,7 +371,7 @@ static int bcma_get_next_core(struct bcm
2465 for (j = 0; ; j++) {
2466 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2467 SCAN_ADDR_TYPE_SLAVE, i);
2468 - if (tmp < 0) {
2469 + if (IS_ERR_VALUE_U32(tmp)) {
2470 /* no more entries for port _i_ */
2471 /* pr_debug("erom: slave port %d "
2472 * "has %d descriptors\n", i, j); */
2473 @@ -372,7 +388,7 @@ static int bcma_get_next_core(struct bcm
2474 for (j = 0; ; j++) {
2475 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2476 SCAN_ADDR_TYPE_MWRAP, i);
2477 - if (tmp < 0) {
2478 + if (IS_ERR_VALUE_U32(tmp)) {
2479 /* no more entries for port _i_ */
2480 /* pr_debug("erom: master wrapper %d "
2481 * "has %d descriptors\n", i, j); */
2482 @@ -390,7 +406,7 @@ static int bcma_get_next_core(struct bcm
2483 for (j = 0; ; j++) {
2484 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2485 SCAN_ADDR_TYPE_SWRAP, i + hack);
2486 - if (tmp < 0) {
2487 + if (IS_ERR_VALUE_U32(tmp)) {
2488 /* no more entries for port _i_ */
2489 /* pr_debug("erom: master wrapper %d "
2490 * has %d descriptors\n", i, j); */
2491 --- a/drivers/bcma/sprom.c
2492 +++ b/drivers/bcma/sprom.c
2493 @@ -72,12 +72,12 @@ fail:
2494 * R/W ops.
2495 **************************************************/
2496
2497 -static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
2498 +static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom,
2499 + size_t words)
2500 {
2501 int i;
2502 - for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
2503 - sprom[i] = bcma_read16(bus->drv_cc.core,
2504 - offset + (i * 2));
2505 + for (i = 0; i < words; i++)
2506 + sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2));
2507 }
2508
2509 /**************************************************
2510 @@ -124,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da
2511 return t[crc ^ data];
2512 }
2513
2514 -static u8 bcma_sprom_crc(const u16 *sprom)
2515 +static u8 bcma_sprom_crc(const u16 *sprom, size_t words)
2516 {
2517 int word;
2518 u8 crc = 0xFF;
2519
2520 - for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
2521 + for (word = 0; word < words - 1; word++) {
2522 crc = bcma_crc8(crc, sprom[word] & 0x00FF);
2523 crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
2524 }
2525 - crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
2526 + crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF);
2527 crc ^= 0xFF;
2528
2529 return crc;
2530 }
2531
2532 -static int bcma_sprom_check_crc(const u16 *sprom)
2533 +static int bcma_sprom_check_crc(const u16 *sprom, size_t words)
2534 {
2535 u8 crc;
2536 u8 expected_crc;
2537 u16 tmp;
2538
2539 - crc = bcma_sprom_crc(sprom);
2540 - tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
2541 + crc = bcma_sprom_crc(sprom, words);
2542 + tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC;
2543 expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
2544 if (crc != expected_crc)
2545 return -EPROTO;
2546 @@ -154,21 +154,25 @@ static int bcma_sprom_check_crc(const u1
2547 return 0;
2548 }
2549
2550 -static int bcma_sprom_valid(const u16 *sprom)
2551 +static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom,
2552 + size_t words)
2553 {
2554 u16 revision;
2555 int err;
2556
2557 - err = bcma_sprom_check_crc(sprom);
2558 + err = bcma_sprom_check_crc(sprom, words);
2559 if (err)
2560 return err;
2561
2562 - revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
2563 - if (revision != 8 && revision != 9) {
2564 + revision = sprom[words - 1] & SSB_SPROM_REVISION_REV;
2565 + if (revision != 8 && revision != 9 && revision != 10) {
2566 pr_err("Unsupported SPROM revision: %d\n", revision);
2567 return -ENOENT;
2568 }
2569
2570 + bus->sprom.revision = revision;
2571 + bcma_debug(bus, "Found SPROM revision %d\n", revision);
2572 +
2573 return 0;
2574 }
2575
2576 @@ -208,15 +212,13 @@ static void bcma_sprom_extract_r8(struct
2577 BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
2578 ARRAY_SIZE(bus->sprom.core_pwr_info));
2579
2580 - bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
2581 - SSB_SPROM_REVISION_REV;
2582 -
2583 for (i = 0; i < 3; i++) {
2584 v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
2585 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
2586 }
2587
2588 SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
2589 + SPEX(board_type, SSB_SPROM1_SPID, ~0, 0);
2590
2591 SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
2592 SSB_SPROM4_TXPID2G0_SHIFT);
2593 @@ -501,13 +503,15 @@ static bool bcma_sprom_onchip_available(
2594 case BCMA_CHIP_ID_BCM4331:
2595 present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
2596 break;
2597 -
2598 + case BCMA_CHIP_ID_BCM43142:
2599 case BCMA_CHIP_ID_BCM43224:
2600 case BCMA_CHIP_ID_BCM43225:
2601 /* for these chips OTP is always available */
2602 present = true;
2603 break;
2604 + case BCMA_CHIP_ID_BCM43227:
2605 case BCMA_CHIP_ID_BCM43228:
2606 + case BCMA_CHIP_ID_BCM43428:
2607 present = chip_status & BCMA_CC_CHIPST_43228_OTP_PRESENT;
2608 break;
2609 default:
2610 @@ -547,7 +551,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
2611 {
2612 u16 offset = BCMA_CC_SPROM;
2613 u16 *sprom;
2614 - int err = 0;
2615 + size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
2616 + SSB_SPROMSIZE_WORDS_R10, };
2617 + int i, err = 0;
2618
2619 if (!bus->drv_cc.core)
2620 return -EOPNOTSUPP;
2621 @@ -576,29 +582,37 @@ int bcma_sprom_get(struct bcma_bus *bus)
2622 }
2623 }
2624
2625 - sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
2626 - GFP_KERNEL);
2627 - if (!sprom)
2628 - return -ENOMEM;
2629 -
2630 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
2631 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
2632 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
2633
2634 bcma_debug(bus, "SPROM offset 0x%x\n", offset);
2635 - bcma_sprom_read(bus, offset, sprom);
2636 + for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
2637 + size_t words = sprom_sizes[i];
2638 +
2639 + sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
2640 + if (!sprom)
2641 + return -ENOMEM;
2642 +
2643 + bcma_sprom_read(bus, offset, sprom, words);
2644 + err = bcma_sprom_valid(bus, sprom, words);
2645 + if (!err)
2646 + break;
2647 +
2648 + kfree(sprom);
2649 + }
2650
2651 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
2652 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
2653 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
2654
2655 - err = bcma_sprom_valid(sprom);
2656 - if (err)
2657 - goto out;
2658 -
2659 - bcma_sprom_extract_r8(bus, sprom);
2660 + if (err) {
2661 + bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n");
2662 + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
2663 + } else {
2664 + bcma_sprom_extract_r8(bus, sprom);
2665 + kfree(sprom);
2666 + }
2667
2668 -out:
2669 - kfree(sprom);
2670 return err;
2671 }
2672 --- a/include/linux/bcma/bcma.h
2673 +++ b/include/linux/bcma/bcma.h
2674 @@ -10,7 +10,7 @@
2675 #include <linux/bcma/bcma_driver_gmac_cmn.h>
2676 #include <linux/ssb/ssb.h> /* SPROM sharing */
2677
2678 -#include "bcma_regs.h"
2679 +#include <linux/bcma/bcma_regs.h>
2680
2681 struct bcma_device;
2682 struct bcma_bus;
2683 @@ -72,7 +72,19 @@ struct bcma_host_ops {
2684 /* Core-ID values. */
2685 #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
2686 #define BCMA_CORE_4706_CHIPCOMMON 0x500
2687 +#define BCMA_CORE_PCIEG2 0x501
2688 +#define BCMA_CORE_DMA 0x502
2689 +#define BCMA_CORE_SDIO3 0x503
2690 +#define BCMA_CORE_USB20 0x504
2691 +#define BCMA_CORE_USB30 0x505
2692 +#define BCMA_CORE_A9JTAG 0x506
2693 +#define BCMA_CORE_DDR23 0x507
2694 +#define BCMA_CORE_ROM 0x508
2695 +#define BCMA_CORE_NAND 0x509
2696 +#define BCMA_CORE_QSPI 0x50A
2697 +#define BCMA_CORE_CHIPCOMMON_B 0x50B
2698 #define BCMA_CORE_4706_SOC_RAM 0x50E
2699 +#define BCMA_CORE_ARMCA9 0x510
2700 #define BCMA_CORE_4706_MAC_GBIT 0x52D
2701 #define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */
2702 #define BCMA_CORE_ALTA 0x534 /* I2S core */
2703 @@ -134,12 +146,17 @@ struct bcma_host_ops {
2704 #define BCMA_CORE_I2S 0x834
2705 #define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
2706 #define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
2707 +#define BCMA_CORE_PHY_AC 0x83B
2708 +#define BCMA_CORE_PCIE2 0x83C /* PCI Express Gen2 */
2709 +#define BCMA_CORE_USB30_DEV 0x83D
2710 +#define BCMA_CORE_ARM_CR4 0x83E
2711 #define BCMA_CORE_DEFAULT 0xFFF
2712
2713 #define BCMA_MAX_NR_CORES 16
2714
2715 /* Chip IDs of PCIe devices */
2716 #define BCMA_CHIP_ID_BCM4313 0x4313
2717 +#define BCMA_CHIP_ID_BCM43142 43142
2718 #define BCMA_CHIP_ID_BCM43224 43224
2719 #define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
2720 #define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
2721 @@ -157,6 +174,7 @@ struct bcma_host_ops {
2722
2723 /* Chip IDs of SoCs */
2724 #define BCMA_CHIP_ID_BCM4706 0x5300
2725 +#define BCMA_PKG_ID_BCM4706L 1
2726 #define BCMA_CHIP_ID_BCM4716 0x4716
2727 #define BCMA_PKG_ID_BCM4716 8
2728 #define BCMA_PKG_ID_BCM4717 9
2729 @@ -166,7 +184,70 @@ struct bcma_host_ops {
2730 #define BCMA_CHIP_ID_BCM4749 0x4749
2731 #define BCMA_CHIP_ID_BCM5356 0x5356
2732 #define BCMA_CHIP_ID_BCM5357 0x5357
2733 +#define BCMA_PKG_ID_BCM5358 9
2734 +#define BCMA_PKG_ID_BCM47186 10
2735 +#define BCMA_PKG_ID_BCM5357 11
2736 #define BCMA_CHIP_ID_BCM53572 53572
2737 +#define BCMA_PKG_ID_BCM47188 9
2738 +#define BCMA_CHIP_ID_BCM4707 53010
2739 +#define BCMA_PKG_ID_BCM4707 1
2740 +#define BCMA_PKG_ID_BCM4708 2
2741 +#define BCMA_PKG_ID_BCM4709 0
2742 +#define BCMA_CHIP_ID_BCM53018 53018
2743 +
2744 +/* Board types (on PCI usually equals to the subsystem dev id) */
2745 +/* BCM4313 */
2746 +#define BCMA_BOARD_TYPE_BCM94313BU 0X050F
2747 +#define BCMA_BOARD_TYPE_BCM94313HM 0X0510
2748 +#define BCMA_BOARD_TYPE_BCM94313EPA 0X0511
2749 +#define BCMA_BOARD_TYPE_BCM94313HMG 0X051C
2750 +/* BCM4716 */
2751 +#define BCMA_BOARD_TYPE_BCM94716NR2 0X04CD
2752 +/* BCM43224 */
2753 +#define BCMA_BOARD_TYPE_BCM943224X21 0X056E
2754 +#define BCMA_BOARD_TYPE_BCM943224X21_FCC 0X00D1
2755 +#define BCMA_BOARD_TYPE_BCM943224X21B 0X00E9
2756 +#define BCMA_BOARD_TYPE_BCM943224M93 0X008B
2757 +#define BCMA_BOARD_TYPE_BCM943224M93A 0X0090
2758 +#define BCMA_BOARD_TYPE_BCM943224X16 0X0093
2759 +#define BCMA_BOARD_TYPE_BCM94322X9 0X008D
2760 +#define BCMA_BOARD_TYPE_BCM94322M35E 0X008E
2761 +/* BCM43228 */
2762 +#define BCMA_BOARD_TYPE_BCM943228BU8 0X0540
2763 +#define BCMA_BOARD_TYPE_BCM943228BU9 0X0541
2764 +#define BCMA_BOARD_TYPE_BCM943228BU 0X0542
2765 +#define BCMA_BOARD_TYPE_BCM943227HM4L 0X0543
2766 +#define BCMA_BOARD_TYPE_BCM943227HMB 0X0544
2767 +#define BCMA_BOARD_TYPE_BCM943228HM4L 0X0545
2768 +#define BCMA_BOARD_TYPE_BCM943228SD 0X0573
2769 +/* BCM4331 */
2770 +#define BCMA_BOARD_TYPE_BCM94331X19 0X00D6
2771 +#define BCMA_BOARD_TYPE_BCM94331X28 0X00E4
2772 +#define BCMA_BOARD_TYPE_BCM94331X28B 0X010E
2773 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT3AX 0X00E4
2774 +#define BCMA_BOARD_TYPE_BCM94331X12_2G 0X00EC
2775 +#define BCMA_BOARD_TYPE_BCM94331X12_5G 0X00ED
2776 +#define BCMA_BOARD_TYPE_BCM94331X29B 0X00EF
2777 +#define BCMA_BOARD_TYPE_BCM94331CSAX 0X00EF
2778 +#define BCMA_BOARD_TYPE_BCM94331X19C 0X00F5
2779 +#define BCMA_BOARD_TYPE_BCM94331X33 0X00F4
2780 +#define BCMA_BOARD_TYPE_BCM94331BU 0X0523
2781 +#define BCMA_BOARD_TYPE_BCM94331S9BU 0X0524
2782 +#define BCMA_BOARD_TYPE_BCM94331MC 0X0525
2783 +#define BCMA_BOARD_TYPE_BCM94331MCI 0X0526
2784 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT4 0X0527
2785 +#define BCMA_BOARD_TYPE_BCM94331HM 0X0574
2786 +#define BCMA_BOARD_TYPE_BCM94331PCIEDUAL 0X059B
2787 +#define BCMA_BOARD_TYPE_BCM94331MCH5 0X05A9
2788 +#define BCMA_BOARD_TYPE_BCM94331CS 0X05C6
2789 +#define BCMA_BOARD_TYPE_BCM94331CD 0X05DA
2790 +/* BCM53572 */
2791 +#define BCMA_BOARD_TYPE_BCM953572BU 0X058D
2792 +#define BCMA_BOARD_TYPE_BCM953572NR2 0X058E
2793 +#define BCMA_BOARD_TYPE_BCM947188NR2 0X058F
2794 +#define BCMA_BOARD_TYPE_BCM953572SDRNR2 0X0590
2795 +/* BCM43142 */
2796 +#define BCMA_BOARD_TYPE_BCM943142HM 0X05E0
2797
2798 struct bcma_device {
2799 struct bcma_bus *bus;
2800 @@ -251,7 +332,7 @@ struct bcma_bus {
2801 u8 num;
2802
2803 struct bcma_drv_cc drv_cc;
2804 - struct bcma_drv_pci drv_pci;
2805 + struct bcma_drv_pci drv_pci[2];
2806 struct bcma_drv_mips drv_mips;
2807 struct bcma_drv_gmac_cmn drv_gmac_cmn;
2808
2809 @@ -345,6 +426,7 @@ extern void bcma_core_set_clockmode(stru
2810 enum bcma_clkmode clkmode);
2811 extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
2812 bool on);
2813 +extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
2814 #define BCMA_DMA_TRANSLATION_MASK 0xC0000000
2815 #define BCMA_DMA_TRANSLATION_NONE 0x00000000
2816 #define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
2817 --- a/include/linux/bcma/bcma_driver_chipcommon.h
2818 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
2819 @@ -1,6 +1,9 @@
2820 #ifndef LINUX_BCMA_DRIVER_CC_H_
2821 #define LINUX_BCMA_DRIVER_CC_H_
2822
2823 +#include <linux/platform_device.h>
2824 +#include <linux/gpio.h>
2825 +
2826 /** ChipCommon core registers. **/
2827 #define BCMA_CC_ID 0x0000
2828 #define BCMA_CC_ID_ID 0x0000FFFF
2829 @@ -24,7 +27,7 @@
2830 #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
2831 #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
2832 #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
2833 -#define BCMA_CC_FLASHT_NFLASH 0x00000200 /* NAND flash */
2834 +#define BCMA_CC_FLASHT_NAND 0x00000300 /* NAND flash */
2835 #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
2836 #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
2837 #define BCMA_PLLTYPE_NONE 0x00000000
2838 @@ -100,6 +103,8 @@
2839 #define BCMA_CC_CHIPST_4706_SFLASH_TYPE BIT(2) /* 0: 8b-p/ST-s flash, 1: 16b-p/Atmal-s flash */
2840 #define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
2841 #define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
2842 +#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
2843 +#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
2844 #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
2845 #define BCMA_CC_JCMD_START 0x80000000
2846 #define BCMA_CC_JCMD_BUSY 0x80000000
2847 @@ -266,6 +271,29 @@
2848 #define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004
2849 #define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1
2850 #define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001
2851 +/* Block 0x140 - 0x190 registers are chipset specific */
2852 +#define BCMA_CC_4706_FLASHSCFG 0x18C /* Flash struct configuration */
2853 +#define BCMA_CC_4706_FLASHSCFG_MASK 0x000000ff
2854 +#define BCMA_CC_4706_FLASHSCFG_SF1 0x00000001 /* 2nd serial flash present */
2855 +#define BCMA_CC_4706_FLASHSCFG_PF1 0x00000002 /* 2nd parallel flash present */
2856 +#define BCMA_CC_4706_FLASHSCFG_SF1_TYPE 0x00000004 /* 2nd serial flash type : 0 : ST, 1 : Atmel */
2857 +#define BCMA_CC_4706_FLASHSCFG_NF1 0x00000008 /* 2nd NAND flash present */
2858 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_MASK 0x000000f0
2859 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_4MB 0x00000010 /* 4MB */
2860 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_8MB 0x00000020 /* 8MB */
2861 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_16MB 0x00000030 /* 16MB */
2862 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_32MB 0x00000040 /* 32MB */
2863 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_64MB 0x00000050 /* 64MB */
2864 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_128MB 0x00000060 /* 128MB */
2865 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_256MB 0x00000070 /* 256MB */
2866 +/* NAND flash registers for BCM4706 (corerev = 31) */
2867 +#define BCMA_CC_NFLASH_CTL 0x01A0
2868 +#define BCMA_CC_NFLASH_CTL_ERR 0x08000000
2869 +#define BCMA_CC_NFLASH_CONF 0x01A4
2870 +#define BCMA_CC_NFLASH_COL_ADDR 0x01A8
2871 +#define BCMA_CC_NFLASH_ROW_ADDR 0x01AC
2872 +#define BCMA_CC_NFLASH_DATA 0x01B0
2873 +#define BCMA_CC_NFLASH_WAITCNT0 0x01B4
2874 /* 0x1E0 is defined as shared BCMA_CLKCTLST */
2875 #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
2876 #define BCMA_CC_UART0_DATA 0x0300
2877 @@ -288,6 +316,9 @@
2878 #define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
2879 #define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
2880 #define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
2881 +#define BCMA_CC_PMU_CTL_RES 0x00006000 /* reset control mask */
2882 +#define BCMA_CC_PMU_CTL_RES_SHIFT 13
2883 +#define BCMA_CC_PMU_CTL_RES_RELOAD 0x2 /* reload POR values */
2884 #define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
2885 #define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
2886 #define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
2887 @@ -299,6 +330,8 @@
2888 #define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
2889 #define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
2890 #define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
2891 +#define BCMA_CC_PMU_STAT_EXT_LPO_AVAIL 0x00000100
2892 +#define BCMA_CC_PMU_STAT_WDRESET 0x00000080
2893 #define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
2894 #define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
2895 #define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
2896 @@ -324,7 +357,66 @@
2897 #define BCMA_CC_REGCTL_DATA 0x065C
2898 #define BCMA_CC_PLLCTL_ADDR 0x0660
2899 #define BCMA_CC_PLLCTL_DATA 0x0664
2900 +#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */
2901 +#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */
2902 +#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF
2903 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_MASK 0x80000000
2904 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT 31
2905 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
2906 +/* NAND flash MLC controller registers (corerev >= 38) */
2907 +#define BCMA_CC_NAND_REVISION 0x0C00
2908 +#define BCMA_CC_NAND_CMD_START 0x0C04
2909 +#define BCMA_CC_NAND_CMD_ADDR_X 0x0C08
2910 +#define BCMA_CC_NAND_CMD_ADDR 0x0C0C
2911 +#define BCMA_CC_NAND_CMD_END_ADDR 0x0C10
2912 +#define BCMA_CC_NAND_CS_NAND_SELECT 0x0C14
2913 +#define BCMA_CC_NAND_CS_NAND_XOR 0x0C18
2914 +#define BCMA_CC_NAND_SPARE_RD0 0x0C20
2915 +#define BCMA_CC_NAND_SPARE_RD4 0x0C24
2916 +#define BCMA_CC_NAND_SPARE_RD8 0x0C28
2917 +#define BCMA_CC_NAND_SPARE_RD12 0x0C2C
2918 +#define BCMA_CC_NAND_SPARE_WR0 0x0C30
2919 +#define BCMA_CC_NAND_SPARE_WR4 0x0C34
2920 +#define BCMA_CC_NAND_SPARE_WR8 0x0C38
2921 +#define BCMA_CC_NAND_SPARE_WR12 0x0C3C
2922 +#define BCMA_CC_NAND_ACC_CONTROL 0x0C40
2923 +#define BCMA_CC_NAND_CONFIG 0x0C48
2924 +#define BCMA_CC_NAND_TIMING_1 0x0C50
2925 +#define BCMA_CC_NAND_TIMING_2 0x0C54
2926 +#define BCMA_CC_NAND_SEMAPHORE 0x0C58
2927 +#define BCMA_CC_NAND_DEVID 0x0C60
2928 +#define BCMA_CC_NAND_DEVID_X 0x0C64
2929 +#define BCMA_CC_NAND_BLOCK_LOCK_STATUS 0x0C68
2930 +#define BCMA_CC_NAND_INTFC_STATUS 0x0C6C
2931 +#define BCMA_CC_NAND_ECC_CORR_ADDR_X 0x0C70
2932 +#define BCMA_CC_NAND_ECC_CORR_ADDR 0x0C74
2933 +#define BCMA_CC_NAND_ECC_UNC_ADDR_X 0x0C78
2934 +#define BCMA_CC_NAND_ECC_UNC_ADDR 0x0C7C
2935 +#define BCMA_CC_NAND_READ_ERROR_COUNT 0x0C80
2936 +#define BCMA_CC_NAND_CORR_STAT_THRESHOLD 0x0C84
2937 +#define BCMA_CC_NAND_READ_ADDR_X 0x0C90
2938 +#define BCMA_CC_NAND_READ_ADDR 0x0C94
2939 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR_X 0x0C98
2940 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR 0x0C9C
2941 +#define BCMA_CC_NAND_COPY_BACK_ADDR_X 0x0CA0
2942 +#define BCMA_CC_NAND_COPY_BACK_ADDR 0x0CA4
2943 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR_X 0x0CA8
2944 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR 0x0CAC
2945 +#define BCMA_CC_NAND_INV_READ_ADDR_X 0x0CB0
2946 +#define BCMA_CC_NAND_INV_READ_ADDR 0x0CB4
2947 +#define BCMA_CC_NAND_BLK_WR_PROTECT 0x0CC0
2948 +#define BCMA_CC_NAND_ACC_CONTROL_CS1 0x0CD0
2949 +#define BCMA_CC_NAND_CONFIG_CS1 0x0CD4
2950 +#define BCMA_CC_NAND_TIMING_1_CS1 0x0CD8
2951 +#define BCMA_CC_NAND_TIMING_2_CS1 0x0CDC
2952 +#define BCMA_CC_NAND_SPARE_RD16 0x0D30
2953 +#define BCMA_CC_NAND_SPARE_RD20 0x0D34
2954 +#define BCMA_CC_NAND_SPARE_RD24 0x0D38
2955 +#define BCMA_CC_NAND_SPARE_RD28 0x0D3C
2956 +#define BCMA_CC_NAND_CACHE_ADDR 0x0D40
2957 +#define BCMA_CC_NAND_CACHE_DATA 0x0D44
2958 +#define BCMA_CC_NAND_CTRL_CONFIG 0x0D48
2959 +#define BCMA_CC_NAND_CTRL_STATUS 0x0D4C
2960
2961 /* Divider allocation in 4716/47162/5356 */
2962 #define BCMA_CC_PMU5_MAINPLL_CPU 1
2963 @@ -350,6 +442,23 @@
2964 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007
2965 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0
2966
2967 +/* PMU rev 15 */
2968 +#define BCMA_CC_PMU15_PLL_PLLCTL0 0
2969 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_MASK 0x00000003
2970 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_SHIFT 0
2971 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK 0x003FFFFC
2972 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT 2
2973 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_MASK 0x00C00000
2974 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_SHIFT 22
2975 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_MASK 0x07000000
2976 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_SHIFT 24
2977 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_MASK 0x38000000
2978 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_SHIFT 27
2979 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_MASK 0x40000000
2980 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_SHIFT 30
2981 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_MASK 0x80000000
2982 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_SHIFT 31
2983 +
2984 /* ALP clock on pre-PMU chips */
2985 #define BCMA_CC_PMU_ALP_CLOCK 20000000
2986 /* HT clock for systems with PMU-enabled chipcommon */
2987 @@ -415,6 +524,44 @@
2988 /* 4313 Chip specific ChipControl register bits */
2989 #define BCMA_CCTRL_4313_12MA_LED_DRIVE 0x00000007 /* 12 mA drive strengh for later 4313 */
2990
2991 +/* BCM5357 ChipControl register bits */
2992 +#define BCMA_CHIPCTL_5357_EXTPA BIT(14)
2993 +#define BCMA_CHIPCTL_5357_ANT_MUX_2O3 BIT(15)
2994 +#define BCMA_CHIPCTL_5357_NFLASH BIT(16)
2995 +#define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
2996 +#define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
2997 +
2998 +#define BCMA_RES_4314_LPLDO_PU BIT(0)
2999 +#define BCMA_RES_4314_PMU_SLEEP_DIS BIT(1)
3000 +#define BCMA_RES_4314_PMU_BG_PU BIT(2)
3001 +#define BCMA_RES_4314_CBUCK_LPOM_PU BIT(3)
3002 +#define BCMA_RES_4314_CBUCK_PFM_PU BIT(4)
3003 +#define BCMA_RES_4314_CLDO_PU BIT(5)
3004 +#define BCMA_RES_4314_LPLDO2_LVM BIT(6)
3005 +#define BCMA_RES_4314_WL_PMU_PU BIT(7)
3006 +#define BCMA_RES_4314_LNLDO_PU BIT(8)
3007 +#define BCMA_RES_4314_LDO3P3_PU BIT(9)
3008 +#define BCMA_RES_4314_OTP_PU BIT(10)
3009 +#define BCMA_RES_4314_XTAL_PU BIT(11)
3010 +#define BCMA_RES_4314_WL_PWRSW_PU BIT(12)
3011 +#define BCMA_RES_4314_LQ_AVAIL BIT(13)
3012 +#define BCMA_RES_4314_LOGIC_RET BIT(14)
3013 +#define BCMA_RES_4314_MEM_SLEEP BIT(15)
3014 +#define BCMA_RES_4314_MACPHY_RET BIT(16)
3015 +#define BCMA_RES_4314_WL_CORE_READY BIT(17)
3016 +#define BCMA_RES_4314_ILP_REQ BIT(18)
3017 +#define BCMA_RES_4314_ALP_AVAIL BIT(19)
3018 +#define BCMA_RES_4314_MISC_PWRSW_PU BIT(20)
3019 +#define BCMA_RES_4314_SYNTH_PWRSW_PU BIT(21)
3020 +#define BCMA_RES_4314_RX_PWRSW_PU BIT(22)
3021 +#define BCMA_RES_4314_RADIO_PU BIT(23)
3022 +#define BCMA_RES_4314_VCO_LDO_PU BIT(24)
3023 +#define BCMA_RES_4314_AFE_LDO_PU BIT(25)
3024 +#define BCMA_RES_4314_RX_LDO_PU BIT(26)
3025 +#define BCMA_RES_4314_TX_LDO_PU BIT(27)
3026 +#define BCMA_RES_4314_HT_AVAIL BIT(28)
3027 +#define BCMA_RES_4314_MACPHY_CLK_AVAIL BIT(29)
3028 +
3029 /* Data for the PMU, if available.
3030 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
3031 */
3032 @@ -425,11 +572,36 @@ struct bcma_chipcommon_pmu {
3033
3034 #ifdef CONFIG_BCMA_DRIVER_MIPS
3035 struct bcma_pflash {
3036 + bool present;
3037 u8 buswidth;
3038 u32 window;
3039 u32 window_size;
3040 };
3041
3042 +#ifdef CONFIG_BCMA_SFLASH
3043 +struct bcma_sflash {
3044 + bool present;
3045 + u32 window;
3046 + u32 blocksize;
3047 + u16 numblocks;
3048 + u32 size;
3049 +
3050 + struct mtd_info *mtd;
3051 + void *priv;
3052 +};
3053 +#endif
3054 +
3055 +#ifdef CONFIG_BCMA_NFLASH
3056 +struct mtd_info;
3057 +
3058 +struct bcma_nflash {
3059 + bool present;
3060 + bool boot; /* This is the flash the SoC boots from */
3061 +
3062 + struct mtd_info *mtd;
3063 +};
3064 +#endif
3065 +
3066 struct bcma_serial_port {
3067 void *regs;
3068 unsigned long clockspeed;
3069 @@ -445,15 +617,30 @@ struct bcma_drv_cc {
3070 u32 capabilities;
3071 u32 capabilities_ext;
3072 u8 setup_done:1;
3073 + u8 early_setup_done:1;
3074 /* Fast Powerup Delay constant */
3075 u16 fast_pwrup_delay;
3076 struct bcma_chipcommon_pmu pmu;
3077 #ifdef CONFIG_BCMA_DRIVER_MIPS
3078 struct bcma_pflash pflash;
3079 +#ifdef CONFIG_BCMA_SFLASH
3080 + struct bcma_sflash sflash;
3081 +#endif
3082 +#ifdef CONFIG_BCMA_NFLASH
3083 + struct bcma_nflash nflash;
3084 +#endif
3085
3086 int nr_serial_ports;
3087 struct bcma_serial_port serial_ports[4];
3088 #endif /* CONFIG_BCMA_DRIVER_MIPS */
3089 + u32 ticks_per_ms;
3090 + struct platform_device *watchdog;
3091 +
3092 + /* Lock for GPIO register access. */
3093 + spinlock_t gpio_lock;
3094 +#ifdef CONFIG_BCMA_DRIVER_GPIO
3095 + struct gpio_chip gpio;
3096 +#endif
3097 };
3098
3099 /* Register access */
3100 @@ -470,14 +657,16 @@ struct bcma_drv_cc {
3101 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
3102
3103 extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
3104 +extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
3105
3106 extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
3107 extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
3108
3109 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
3110
3111 -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
3112 - u32 ticks);
3113 +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
3114 +
3115 +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
3116
3117 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
3118
3119 @@ -490,9 +679,12 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
3120 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
3121 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
3122 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
3123 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
3124 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
3125
3126 /* PMU support */
3127 extern void bcma_pmu_init(struct bcma_drv_cc *cc);
3128 +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
3129
3130 extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
3131 u32 value);
3132 @@ -504,4 +696,6 @@ extern void bcma_chipco_regctl_maskset(s
3133 u32 offset, u32 mask, u32 set);
3134 extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
3135
3136 +extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
3137 +
3138 #endif /* LINUX_BCMA_DRIVER_CC_H_ */
3139 --- a/include/linux/bcma/bcma_driver_mips.h
3140 +++ b/include/linux/bcma/bcma_driver_mips.h
3141 @@ -28,6 +28,7 @@
3142 #define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
3143 #define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
3144
3145 +#define BCMA_MIPS_OOBSELINA74 0x004
3146 #define BCMA_MIPS_OOBSELOUTA30 0x100
3147
3148 struct bcma_device;
3149 @@ -35,17 +36,24 @@ struct bcma_device;
3150 struct bcma_drv_mips {
3151 struct bcma_device *core;
3152 u8 setup_done:1;
3153 - unsigned int assigned_irqs;
3154 + u8 early_setup_done:1;
3155 };
3156
3157 #ifdef CONFIG_BCMA_DRIVER_MIPS
3158 extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
3159 +extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
3160 +
3161 +extern unsigned int bcma_core_irq(struct bcma_device *core);
3162 #else
3163 static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
3164 +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
3165 +
3166 +static inline unsigned int bcma_core_irq(struct bcma_device *core)
3167 +{
3168 + return 0;
3169 +}
3170 #endif
3171
3172 extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
3173
3174 -extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
3175 -
3176 #endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
3177 --- a/include/linux/bcma/bcma_driver_pci.h
3178 +++ b/include/linux/bcma/bcma_driver_pci.h
3179 @@ -179,10 +179,33 @@ struct pci_dev;
3180 #define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */
3181 #define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */
3182
3183 +#define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8
3184 +
3185 +#define BCMA_CORE_PCI_
3186 +
3187 +/* MDIO devices (SERDES modules) */
3188 +#define BCMA_CORE_PCI_MDIO_IEEE0 0x000
3189 +#define BCMA_CORE_PCI_MDIO_IEEE1 0x001
3190 +#define BCMA_CORE_PCI_MDIO_BLK0 0x800
3191 +#define BCMA_CORE_PCI_MDIO_BLK1 0x801
3192 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT0 0x16
3193 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT1 0x17
3194 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT2 0x18
3195 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT3 0x19
3196 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT4 0x1A
3197 +#define BCMA_CORE_PCI_MDIO_BLK2 0x802
3198 +#define BCMA_CORE_PCI_MDIO_BLK3 0x803
3199 +#define BCMA_CORE_PCI_MDIO_BLK4 0x804
3200 +#define BCMA_CORE_PCI_MDIO_TXPLL 0x808 /* TXPLL register block idx */
3201 +#define BCMA_CORE_PCI_MDIO_TXCTRL0 0x820
3202 +#define BCMA_CORE_PCI_MDIO_SERDESID 0x831
3203 +#define BCMA_CORE_PCI_MDIO_RXCTRL0 0x840
3204 +
3205 /* PCIE Root Capability Register bits (Host mode only) */
3206 #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
3207
3208 struct bcma_drv_pci;
3209 +struct bcma_bus;
3210
3211 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
3212 struct bcma_drv_pci_host {
3213 @@ -217,7 +240,8 @@ struct bcma_drv_pci {
3214 extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
3215 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
3216 struct bcma_device *core, bool enable);
3217 -extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend);
3218 +extern void bcma_core_pci_up(struct bcma_bus *bus);
3219 +extern void bcma_core_pci_down(struct bcma_bus *bus);
3220
3221 extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
3222 extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
3223 --- a/include/linux/bcma/bcma_regs.h
3224 +++ b/include/linux/bcma/bcma_regs.h
3225 @@ -11,11 +11,13 @@
3226 #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
3227 #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
3228 #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
3229 +#define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
3230 #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
3231 #define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
3232 #define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
3233 #define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
3234 #define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
3235 +#define BCMA_CLKCTLST_EXTRESST_SHIFT 24
3236 /* Is there any BCM4328 on BCMA bus? */
3237 #define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
3238 #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
3239 @@ -35,6 +37,7 @@
3240 #define BCMA_IOST_BIST_DONE 0x8000
3241 #define BCMA_RESET_CTL 0x0800
3242 #define BCMA_RESET_CTL_RESET 0x0001
3243 +#define BCMA_RESET_ST 0x0804
3244
3245 /* BCMA PCI config space registers. */
3246 #define BCMA_PCI_PMCSR 0x44
3247 @@ -83,4 +86,9 @@
3248 * (2 ZettaBytes), high 32 bits
3249 */
3250
3251 +#define BCMA_SOC_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */
3252 +#define BCMA_SOC_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */
3253 +#define BCMA_SOC_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
3254 +#define BCMA_SOC_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
3255 +
3256 #endif /* LINUX_BCMA_REGS_H_ */
3257 --- a/drivers/net/wireless/b43/main.c
3258 +++ b/drivers/net/wireless/b43/main.c
3259 @@ -4622,7 +4622,7 @@ static int b43_wireless_core_init(struct
3260 switch (dev->dev->bus_type) {
3261 #ifdef CONFIG_B43_BCMA
3262 case B43_BUS_BCMA:
3263 - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
3264 + bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
3265 dev->dev->bdev, true);
3266 break;
3267 #endif
3268 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
3269 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
3270 @@ -688,27 +688,6 @@ bool ai_clkctl_cc(struct si_pub *sih, en
3271 return mode == BCMA_CLKMODE_FAST;
3272 }
3273
3274 -void ai_pci_up(struct si_pub *sih)
3275 -{
3276 - struct si_info *sii;
3277 -
3278 - sii = container_of(sih, struct si_info, pub);
3279 -
3280 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
3281 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, true);
3282 -}
3283 -
3284 -/* Unconfigure and/or apply various WARs when going down */
3285 -void ai_pci_down(struct si_pub *sih)
3286 -{
3287 - struct si_info *sii;
3288 -
3289 - sii = container_of(sih, struct si_info, pub);
3290 -
3291 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
3292 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, false);
3293 -}
3294 -
3295 /* Enable BT-COEX & Ex-PA for 4313 */
3296 void ai_epa_4313war(struct si_pub *sih)
3297 {
3298 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
3299 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
3300 @@ -4689,7 +4689,7 @@ static int brcms_b_attach(struct brcms_c
3301 brcms_c_coredisable(wlc_hw);
3302
3303 /* Match driver "down" state */
3304 - ai_pci_down(wlc_hw->sih);
3305 + bcma_core_pci_down(wlc_hw->d11core->bus);
3306
3307 /* turn off pll and xtal to match driver "down" state */
3308 brcms_b_xtal(wlc_hw, OFF);
3309 @@ -5077,7 +5077,7 @@ static int brcms_b_up_prep(struct brcms_
3310 * Configure pci/pcmcia here instead of in brcms_c_attach()
3311 * to allow mfg hotswap: down, hotswap (chip power cycle), up.
3312 */
3313 - bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci, wlc_hw->d11core,
3314 + bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,
3315 true);
3316
3317 /*
3318 @@ -5087,12 +5087,12 @@ static int brcms_b_up_prep(struct brcms_
3319 */
3320 if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
3321 /* put SB PCI in down state again */
3322 - ai_pci_down(wlc_hw->sih);
3323 + bcma_core_pci_down(wlc_hw->d11core->bus);
3324 brcms_b_xtal(wlc_hw, OFF);
3325 return -ENOMEDIUM;
3326 }
3327
3328 - ai_pci_up(wlc_hw->sih);
3329 + bcma_core_pci_up(wlc_hw->d11core->bus);
3330
3331 /* reset the d11 core */
3332 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
3333 @@ -5295,7 +5295,7 @@ static int brcms_b_down_finish(struct br
3334
3335 /* turn off primary xtal and pll */
3336 if (!wlc_hw->noreset) {
3337 - ai_pci_down(wlc_hw->sih);
3338 + bcma_core_pci_down(wlc_hw->d11core->bus);
3339 brcms_b_xtal(wlc_hw, OFF);
3340 }
3341 }
3342 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
3343 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
3344 @@ -183,9 +183,6 @@ extern u16 ai_clkctl_fast_pwrup_delay(st
3345 extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode);
3346 extern bool ai_deviceremoved(struct si_pub *sih);
3347
3348 -extern void ai_pci_down(struct si_pub *sih);
3349 -extern void ai_pci_up(struct si_pub *sih);
3350 -
3351 /* Enable Ex-PA for 4313 */
3352 extern void ai_epa_4313war(struct si_pub *sih);
3353