1 --- a/drivers/bcma/Kconfig
2 +++ b/drivers/bcma/Kconfig
3 @@ -48,12 +48,12 @@ config BCMA_DRIVER_MIPS
7 - depends on BCMA_DRIVER_MIPS && BROKEN
8 + depends on BCMA_DRIVER_MIPS
13 - depends on BCMA_DRIVER_MIPS && BROKEN
14 + depends on BCMA_DRIVER_MIPS
17 config BCMA_DRIVER_GMAC_CMN
18 @@ -65,6 +65,14 @@ config BCMA_DRIVER_GMAC_CMN
22 +config BCMA_DRIVER_GPIO
23 + bool "BCMA GPIO driver"
24 + depends on BCMA && GPIOLIB
26 + Driver to provide access to the GPIO pins of the bcma bus.
33 --- a/drivers/bcma/Makefile
34 +++ b/drivers/bcma/Makefile
35 @@ -6,6 +6,7 @@ bcma-y += driver_pci.o
36 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
37 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
38 bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
39 +bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
40 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
41 bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
42 obj-$(CONFIG_BCMA) += bcma.o
43 --- a/drivers/bcma/bcma_private.h
44 +++ b/drivers/bcma/bcma_private.h
45 @@ -31,6 +31,8 @@ int __init bcma_bus_early_register(struc
46 int bcma_bus_suspend(struct bcma_bus *bus);
47 int bcma_bus_resume(struct bcma_bus *bus);
49 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
53 int bcma_bus_scan(struct bcma_bus *bus);
54 @@ -48,12 +50,13 @@ void bcma_chipco_serial_init(struct bcma
55 #endif /* CONFIG_BCMA_DRIVER_MIPS */
57 /* driver_chipcommon_pmu.c */
58 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
59 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
60 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
61 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
63 #ifdef CONFIG_BCMA_SFLASH
64 /* driver_chipcommon_sflash.c */
65 int bcma_sflash_init(struct bcma_drv_cc *cc);
66 +extern struct platform_device bcma_sflash_dev;
68 static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
70 @@ -65,6 +68,7 @@ static inline int bcma_sflash_init(struc
71 #ifdef CONFIG_BCMA_NFLASH
72 /* driver_chipcommon_nflash.c */
73 int bcma_nflash_init(struct bcma_drv_cc *cc);
74 +extern struct platform_device bcma_nflash_dev;
76 static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
78 @@ -82,9 +86,21 @@ extern void __exit bcma_host_pci_exit(vo
80 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
82 +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
84 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
85 bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
86 void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
87 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
89 +#ifdef CONFIG_BCMA_DRIVER_GPIO
91 +int bcma_gpio_init(struct bcma_drv_cc *cc);
93 +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
97 +#endif /* CONFIG_BCMA_DRIVER_GPIO */
100 --- a/drivers/bcma/core.c
101 +++ b/drivers/bcma/core.c
102 @@ -65,7 +65,7 @@ void bcma_core_set_clockmode(struct bcma
104 case BCMA_CLKMODE_FAST:
105 bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
107 + usleep_range(64, 300);
108 for (i = 0; i < 1500; i++) {
109 if (bcma_read32(core, BCMA_CLKCTLST) &
110 BCMA_CLKCTLST_HAVEHT) {
111 --- a/drivers/bcma/driver_chipcommon.c
112 +++ b/drivers/bcma/driver_chipcommon.c
115 * Copyright 2005, Broadcom Corporation
116 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
117 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
119 * Licensed under the GNU/GPL. See COPYING for details.
122 #include "bcma_private.h"
123 +#include <linux/bcm47xx_wdt.h>
124 #include <linux/export.h>
125 +#include <linux/platform_device.h>
126 #include <linux/bcma/bcma.h>
128 static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
129 @@ -22,20 +25,119 @@ static inline u32 bcma_cc_write32_masked
133 -void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
134 +static u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
137 - u32 leddc_off = 90;
138 + if (cc->capabilities & BCMA_CC_CAP_PMU)
139 + return bcma_pmu_get_alp_clock(cc);
141 - if (cc->setup_done)
145 +static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
147 + struct bcma_bus *bus = cc->core->bus;
150 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
151 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
153 + else if (cc->core->id.rev < 26)
156 + nb = (cc->core->id.rev >= 37) ? 32 : 24;
163 + return (1 << nb) - 1;
166 +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
169 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
171 + return bcma_chipco_watchdog_timer_set(cc, ticks);
174 +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
177 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
180 + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
181 + return ticks / cc->ticks_per_ms;
184 +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
186 + struct bcma_bus *bus = cc->core->bus;
188 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
189 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
190 + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
191 + return bcma_chipco_get_alp_clock(cc) / 4000;
193 + /* based on 32KHz ILP clock */
196 + return bcma_chipco_get_alp_clock(cc) / 1000;
200 +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
202 + struct bcm47xx_wdt wdt = {};
203 + struct platform_device *pdev;
205 + wdt.driver_data = cc;
206 + wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
207 + wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
208 + wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
210 + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
211 + cc->core->bus->num, &wdt,
214 + return PTR_ERR(pdev);
216 + cc->watchdog = pdev;
221 +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
223 + if (cc->early_setup_done)
226 + spin_lock_init(&cc->gpio_lock);
228 if (cc->core->id.rev >= 11)
229 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
230 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
231 if (cc->core->id.rev >= 35)
232 cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);
234 + if (cc->capabilities & BCMA_CC_CAP_PMU)
235 + bcma_pmu_early_init(cc);
237 + cc->early_setup_done = true;
240 +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
243 + u32 leddc_off = 90;
245 + if (cc->setup_done)
248 + bcma_core_chipcommon_early_init(cc);
250 if (cc->core->id.rev >= 20) {
251 bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
252 bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
253 @@ -56,15 +158,33 @@ void bcma_core_chipcommon_init(struct bc
254 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
255 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
257 + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
259 cc->setup_done = true;
262 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
263 -void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
264 +u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
267 - bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
269 + enum bcma_clkmode clkmode;
271 + maxt = bcma_chipco_watchdog_get_max_timer(cc);
272 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
275 + else if (ticks > maxt)
277 + bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
279 + clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
280 + bcma_core_set_clockmode(cc->core, clkmode);
284 + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
289 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
290 @@ -84,28 +204,97 @@ u32 bcma_chipco_gpio_in(struct bcma_drv_
292 u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
294 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
295 + unsigned long flags;
298 + spin_lock_irqsave(&cc->gpio_lock, flags);
299 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
300 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
305 u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
307 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
308 + unsigned long flags;
311 + spin_lock_irqsave(&cc->gpio_lock, flags);
312 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
313 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
319 + * If the bit is set to 0, chipcommon controlls this GPIO,
320 + * if the bit is set to 1, it is used by some part of the chip and not our code.
322 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
324 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
325 + unsigned long flags;
328 + spin_lock_irqsave(&cc->gpio_lock, flags);
329 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
330 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
334 EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
336 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
338 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
339 + unsigned long flags;
342 + spin_lock_irqsave(&cc->gpio_lock, flags);
343 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
344 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
349 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
351 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
352 + unsigned long flags;
355 + spin_lock_irqsave(&cc->gpio_lock, flags);
356 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
357 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
362 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value)
364 + unsigned long flags;
367 + if (cc->core->id.rev < 20)
370 + spin_lock_irqsave(&cc->gpio_lock, flags);
371 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value);
372 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
377 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value)
379 + unsigned long flags;
382 + if (cc->core->id.rev < 20)
385 + spin_lock_irqsave(&cc->gpio_lock, flags);
386 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value);
387 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
392 #ifdef CONFIG_BCMA_DRIVER_MIPS
393 @@ -118,8 +307,7 @@ void bcma_chipco_serial_init(struct bcma
394 struct bcma_serial_port *ports = cc->serial_ports;
396 if (ccrev >= 11 && ccrev != 15) {
397 - /* Fixed ALP clock */
398 - baud_base = bcma_pmu_alp_clock(cc);
399 + baud_base = bcma_chipco_get_alp_clock(cc);
401 /* Turn off UART clock before switching clocksource. */
402 bcma_cc_write32(cc, BCMA_CC_CORECTL,
403 --- a/drivers/bcma/driver_chipcommon_nflash.c
404 +++ b/drivers/bcma/driver_chipcommon_nflash.c
406 * Licensed under the GNU/GPL. See COPYING for details.
409 +#include <linux/platform_device.h>
410 #include <linux/bcma/bcma.h>
411 -#include <linux/bcma/bcma_driver_chipcommon.h>
412 -#include <linux/delay.h>
414 #include "bcma_private.h"
416 +struct platform_device bcma_nflash_dev = {
417 + .name = "bcma_nflash",
418 + .num_resources = 0,
421 /* Initialize NAND flash access */
422 int bcma_nflash_init(struct bcma_drv_cc *cc)
424 - bcma_err(cc->core->bus, "NAND flash support is broken\n");
425 + struct bcma_bus *bus = cc->core->bus;
427 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
428 + cc->core->id.rev != 0x38) {
429 + bcma_err(bus, "NAND flash on unsupported board!\n");
433 + if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
434 + bcma_err(bus, "NAND flash not present according to ChipCommon\n");
438 + cc->nflash.present = true;
439 + if (cc->core->id.rev == 38 &&
440 + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
441 + cc->nflash.boot = true;
443 + /* Prepare platform device, but don't register it yet. It's too early,
444 + * malloc (required by device_private_init) is not available yet. */
445 + bcma_nflash_dev.dev.platform_data = &cc->nflash;
449 --- a/drivers/bcma/driver_chipcommon_pmu.c
450 +++ b/drivers/bcma/driver_chipcommon_pmu.c
452 #include <linux/export.h>
453 #include <linux/bcma/bcma.h>
455 -static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
456 +u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
458 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
459 bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
460 return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
462 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
464 void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
466 @@ -76,7 +77,10 @@ static void bcma_pmu_resources_init(stru
468 bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
470 - /* Add some delay; allow resources to come up and settle. */
472 + * Add some delay; allow resources to come up and settle.
473 + * Delay is required for SoC (early init).
478 @@ -101,7 +105,7 @@ void bcma_chipco_bcm4331_ext_pa_lines_ct
479 bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
482 -void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
483 +static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
485 struct bcma_bus *bus = cc->core->bus;
487 @@ -141,7 +145,7 @@ void bcma_pmu_workarounds(struct bcma_dr
491 -void bcma_pmu_init(struct bcma_drv_cc *cc)
492 +void bcma_pmu_early_init(struct bcma_drv_cc *cc)
496 @@ -150,7 +154,10 @@ void bcma_pmu_init(struct bcma_drv_cc *c
498 bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
499 cc->pmu.rev, pmucap);
502 +void bcma_pmu_init(struct bcma_drv_cc *cc)
504 if (cc->pmu.rev == 1)
505 bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
506 ~BCMA_CC_PMU_CTL_NOILPONW);
507 @@ -162,7 +169,7 @@ void bcma_pmu_init(struct bcma_drv_cc *c
508 bcma_pmu_workarounds(cc);
511 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
512 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
514 struct bcma_bus *bus = cc->core->bus;
516 @@ -190,7 +197,7 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_c
517 /* Find the output of the "m" pll divider given pll controls that start with
518 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
520 -static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
521 +static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
523 u32 tmp, div, ndiv, p1, p2, fc;
524 struct bcma_bus *bus = cc->core->bus;
525 @@ -219,14 +226,14 @@ static u32 bcma_pmu_clock(struct bcma_dr
526 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
528 /* Do calculation in Mhz */
529 - fc = bcma_pmu_alp_clock(cc) / 1000000;
530 + fc = bcma_pmu_get_alp_clock(cc) / 1000000;
531 fc = (p1 * ndiv * fc) / p2;
533 /* Return clock in Hertz */
534 return (fc / div) * 1000000;
537 -static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
538 +static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
540 u32 tmp, ndiv, p1div, p2div;
542 @@ -257,7 +264,7 @@ static u32 bcma_pmu_clock_bcm4706(struct
545 /* query bus clock frequency for PMU-enabled chipcommon */
546 -u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
547 +static u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
549 struct bcma_bus *bus = cc->core->bus;
551 @@ -265,40 +272,42 @@ u32 bcma_pmu_get_clockcontrol(struct bcm
552 case BCMA_CHIP_ID_BCM4716:
553 case BCMA_CHIP_ID_BCM4748:
554 case BCMA_CHIP_ID_BCM47162:
555 - return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
556 - BCMA_CC_PMU5_MAINPLL_SSB);
557 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
558 + BCMA_CC_PMU5_MAINPLL_SSB);
559 case BCMA_CHIP_ID_BCM5356:
560 - return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
561 - BCMA_CC_PMU5_MAINPLL_SSB);
562 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
563 + BCMA_CC_PMU5_MAINPLL_SSB);
564 case BCMA_CHIP_ID_BCM5357:
565 case BCMA_CHIP_ID_BCM4749:
566 - return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
567 - BCMA_CC_PMU5_MAINPLL_SSB);
568 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
569 + BCMA_CC_PMU5_MAINPLL_SSB);
570 case BCMA_CHIP_ID_BCM4706:
571 - return bcma_pmu_clock_bcm4706(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
572 - BCMA_CC_PMU5_MAINPLL_SSB);
573 + return bcma_pmu_pll_clock_bcm4706(cc,
574 + BCMA_CC_PMU4706_MAINPLL_PLL0,
575 + BCMA_CC_PMU5_MAINPLL_SSB);
576 case BCMA_CHIP_ID_BCM53572:
579 - bcma_warn(bus, "No backplane clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
580 + bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
581 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
583 return BCMA_CC_PMU_HT_CLOCK;
586 /* query cpu clock frequency for PMU-enabled chipcommon */
587 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
588 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
590 struct bcma_bus *bus = cc->core->bus;
592 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
595 + /* New PMUs can have different clock for bus and CPU */
596 if (cc->pmu.rev >= 5) {
598 switch (bus->chipinfo.id) {
599 case BCMA_CHIP_ID_BCM4706:
600 - return bcma_pmu_clock_bcm4706(cc,
601 + return bcma_pmu_pll_clock_bcm4706(cc,
602 BCMA_CC_PMU4706_MAINPLL_PLL0,
603 BCMA_CC_PMU5_MAINPLL_CPU);
604 case BCMA_CHIP_ID_BCM5356:
605 @@ -313,10 +322,11 @@ u32 bcma_pmu_get_clockcpu(struct bcma_dr
609 - return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
610 + return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
613 - return bcma_pmu_get_clockcontrol(cc);
614 + /* On old PMUs CPU has the same clock as the bus */
615 + return bcma_pmu_get_bus_clock(cc);
618 static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
619 --- a/drivers/bcma/driver_chipcommon_sflash.c
620 +++ b/drivers/bcma/driver_chipcommon_sflash.c
622 * Licensed under the GNU/GPL. See COPYING for details.
625 +#include <linux/platform_device.h>
626 #include <linux/bcma/bcma.h>
627 -#include <linux/bcma/bcma_driver_chipcommon.h>
628 -#include <linux/delay.h>
630 #include "bcma_private.h"
632 +static struct resource bcma_sflash_resource = {
633 + .name = "bcma_sflash",
634 + .start = BCMA_SOC_FLASH2,
636 + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
639 +struct platform_device bcma_sflash_dev = {
640 + .name = "bcma_sflash",
641 + .resource = &bcma_sflash_resource,
642 + .num_resources = 1,
645 +struct bcma_sflash_tbl_e {
652 +static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
653 + { "M25P20", 0x11, 0x10000, 4, },
654 + { "M25P40", 0x12, 0x10000, 8, },
656 + { "M25P16", 0x14, 0x10000, 32, },
657 + { "M25P32", 0x15, 0x10000, 64, },
658 + { "M25P64", 0x16, 0x10000, 128, },
659 + { "M25FL128", 0x17, 0x10000, 256, },
663 +static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
664 + { "SST25WF512", 1, 0x1000, 16, },
665 + { "SST25VF512", 0x48, 0x1000, 16, },
666 + { "SST25WF010", 2, 0x1000, 32, },
667 + { "SST25VF010", 0x49, 0x1000, 32, },
668 + { "SST25WF020", 3, 0x1000, 64, },
669 + { "SST25VF020", 0x43, 0x1000, 64, },
670 + { "SST25WF040", 4, 0x1000, 128, },
671 + { "SST25VF040", 0x44, 0x1000, 128, },
672 + { "SST25VF040B", 0x8d, 0x1000, 128, },
673 + { "SST25WF080", 5, 0x1000, 256, },
674 + { "SST25VF080B", 0x8e, 0x1000, 256, },
675 + { "SST25VF016", 0x41, 0x1000, 512, },
676 + { "SST25VF032", 0x4a, 0x1000, 1024, },
677 + { "SST25VF064", 0x4b, 0x1000, 2048, },
681 +static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
682 + { "AT45DB011", 0xc, 256, 512, },
683 + { "AT45DB021", 0x14, 256, 1024, },
684 + { "AT45DB041", 0x1c, 256, 2048, },
685 + { "AT45DB081", 0x24, 256, 4096, },
686 + { "AT45DB161", 0x2c, 512, 4096, },
687 + { "AT45DB321", 0x34, 512, 8192, },
688 + { "AT45DB642", 0x3c, 1024, 8192, },
692 +static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
695 + bcma_cc_write32(cc, BCMA_CC_FLASHCTL,
696 + BCMA_CC_FLASHCTL_START | opcode);
697 + for (i = 0; i < 1000; i++) {
698 + if (!(bcma_cc_read32(cc, BCMA_CC_FLASHCTL) &
699 + BCMA_CC_FLASHCTL_BUSY))
703 + bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
706 /* Initialize serial flash access */
707 int bcma_sflash_init(struct bcma_drv_cc *cc)
709 - bcma_err(cc->core->bus, "Serial flash support is broken\n");
710 + struct bcma_bus *bus = cc->core->bus;
711 + struct bcma_sflash *sflash = &cc->sflash;
712 + struct bcma_sflash_tbl_e *e;
715 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
716 + case BCMA_CC_FLASHT_STSER:
717 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_DP);
719 + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 0);
720 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
721 + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
723 + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 1);
724 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
725 + id2 = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
729 + for (e = bcma_sflash_sst_tbl; e->name; e++) {
737 + for (e = bcma_sflash_st_tbl; e->name; e++) {
744 + bcma_err(bus, "Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n", id, id2);
749 + case BCMA_CC_FLASHT_ATSER:
750 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_AT_STATUS);
751 + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA) & 0x3c;
753 + for (e = bcma_sflash_at_tbl; e->name; e++) {
758 + bcma_err(bus, "Unsupported Atmel serial flash (id: 0x%X)\n", id);
764 + bcma_err(bus, "Unsupported flash type\n");
768 + sflash->window = BCMA_SOC_FLASH2;
769 + sflash->blocksize = e->blocksize;
770 + sflash->numblocks = e->numblocks;
771 + sflash->size = sflash->blocksize * sflash->numblocks;
772 + sflash->present = true;
774 + bcma_info(bus, "Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
775 + e->name, sflash->size / 1024, sflash->blocksize,
776 + sflash->numblocks);
778 + /* Prepare platform device, but don't register it yet. It's too early,
779 + * malloc (required by device_private_init) is not available yet. */
780 + bcma_sflash_dev.resource[0].end = bcma_sflash_dev.resource[0].start +
782 + bcma_sflash_dev.dev.platform_data = sflash;
787 +++ b/drivers/bcma/driver_gpio.c
790 + * Broadcom specific AMBA
793 + * Copyright 2011, Broadcom Corporation
794 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
796 + * Licensed under the GNU/GPL. See COPYING for details.
799 +#include <linux/gpio.h>
800 +#include <linux/export.h>
801 +#include <linux/bcma/bcma.h>
803 +#include "bcma_private.h"
805 +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
807 + return container_of(chip, struct bcma_drv_cc, gpio);
810 +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
812 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
814 + return !!bcma_chipco_gpio_in(cc, 1 << gpio);
817 +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
820 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
822 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
825 +static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
827 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
829 + bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
833 +static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
836 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
838 + bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
839 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
843 +static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
845 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
847 + bcma_chipco_gpio_control(cc, 1 << gpio, 0);
848 + /* clear pulldown */
849 + bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
851 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
856 +static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
858 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
861 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
864 +int bcma_gpio_init(struct bcma_drv_cc *cc)
866 + struct gpio_chip *chip = &cc->gpio;
868 + chip->label = "bcma_gpio";
869 + chip->owner = THIS_MODULE;
870 + chip->request = bcma_gpio_request;
871 + chip->free = bcma_gpio_free;
872 + chip->get = bcma_gpio_get_value;
873 + chip->set = bcma_gpio_set_value;
874 + chip->direction_input = bcma_gpio_direction_input;
875 + chip->direction_output = bcma_gpio_direction_output;
877 + /* There is just one SoC in one device and its GPIO addresses should be
878 + * deterministic to address them more easily. The other buses could get
879 + * a random base number. */
880 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
885 + return gpiochip_add(chip);
887 --- a/drivers/bcma/driver_mips.c
888 +++ b/drivers/bcma/driver_mips.c
889 @@ -74,11 +74,16 @@ static u32 bcma_core_mips_irqflag(struct
890 return dev->core_index;
891 flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
893 - return flag & 0x1F;
895 + return flag & 0x1F;
900 /* Get the MIPS IRQ assignment for a specified device.
901 * If unassigned, 0 is returned.
902 + * If disabled, 5 is returned.
903 + * If not supported, 6 is returned.
905 unsigned int bcma_core_mips_irq(struct bcma_device *dev)
907 @@ -87,13 +92,15 @@ unsigned int bcma_core_mips_irq(struct b
910 irqflag = bcma_core_mips_irqflag(dev);
911 + if (irqflag == 0x3f)
914 - for (irq = 1; irq <= 4; irq++)
915 + for (irq = 0; irq <= 4; irq++)
916 if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
923 EXPORT_SYMBOL(bcma_core_mips_irq);
925 @@ -114,8 +121,8 @@ static void bcma_core_mips_set_irq(struc
926 bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
927 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
930 - bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
931 + else if (oldirq != 5)
932 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
934 /* assign the new one */
936 @@ -123,9 +130,9 @@ static void bcma_core_mips_set_irq(struc
937 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
940 - u32 oldirqflag = bcma_read32(mdev,
941 - BCMA_MIPS_MIPS74K_INTMASK(irq));
943 + u32 irqinitmask = bcma_read32(mdev,
944 + BCMA_MIPS_MIPS74K_INTMASK(irq));
946 struct bcma_device *core;
948 /* backplane irq line is in use, find out who uses
949 @@ -133,7 +140,7 @@ static void bcma_core_mips_set_irq(struc
951 list_for_each_entry(core, &bus->cores, list) {
952 if ((1 << bcma_core_mips_irqflag(core)) ==
955 bcma_core_mips_set_irq(core, 0);
958 @@ -143,15 +150,31 @@ static void bcma_core_mips_set_irq(struc
962 - bcma_info(bus, "set_irq: core 0x%04x, irq %d => %d\n",
963 - dev->id.id, oldirq + 2, irq + 2);
964 + bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n",
965 + dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2);
968 +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
969 + u16 coreid, u8 unit)
971 + struct bcma_device *core;
973 + core = bcma_find_core_unit(bus, coreid, unit);
976 + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
981 + bcma_core_mips_set_irq(core, irq);
984 static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
987 static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
988 - printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
989 + printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
990 for (i = 0; i <= 6; i++)
991 printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
993 @@ -171,7 +194,7 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
994 struct bcma_bus *bus = mcore->core->bus;
996 if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
997 - return bcma_pmu_get_clockcpu(&bus->drv_cc);
998 + return bcma_pmu_get_cpu_clock(&bus->drv_cc);
1000 bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
1002 @@ -181,85 +204,109 @@ EXPORT_SYMBOL(bcma_cpu_clock);
1003 static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
1005 struct bcma_bus *bus = mcore->core->bus;
1006 + struct bcma_drv_cc *cc = &bus->drv_cc;
1008 - switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
1009 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
1010 case BCMA_CC_FLASHT_STSER:
1011 case BCMA_CC_FLASHT_ATSER:
1012 bcma_debug(bus, "Found serial flash\n");
1013 - bcma_sflash_init(&bus->drv_cc);
1014 + bcma_sflash_init(cc);
1016 case BCMA_CC_FLASHT_PARA:
1017 bcma_debug(bus, "Found parallel flash\n");
1018 - bus->drv_cc.pflash.window = 0x1c000000;
1019 - bus->drv_cc.pflash.window_size = 0x02000000;
1020 + cc->pflash.present = true;
1021 + cc->pflash.window = BCMA_SOC_FLASH2;
1022 + cc->pflash.window_size = BCMA_SOC_FLASH2_SZ;
1024 - if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
1025 + if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
1026 BCMA_CC_FLASH_CFG_DS) == 0)
1027 - bus->drv_cc.pflash.buswidth = 1;
1028 + cc->pflash.buswidth = 1;
1030 - bus->drv_cc.pflash.buswidth = 2;
1031 + cc->pflash.buswidth = 2;
1034 bcma_err(bus, "Flash type not supported\n");
1037 - if (bus->drv_cc.core->id.rev == 38 ||
1038 + if (cc->core->id.rev == 38 ||
1039 bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
1040 - if (bus->drv_cc.capabilities & BCMA_CC_CAP_NFLASH) {
1041 + if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
1042 bcma_debug(bus, "Found NAND flash\n");
1043 - bcma_nflash_init(&bus->drv_cc);
1044 + bcma_nflash_init(cc);
1049 +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
1051 + struct bcma_bus *bus = mcore->core->bus;
1053 + if (mcore->early_setup_done)
1056 + bcma_chipco_serial_init(&bus->drv_cc);
1057 + bcma_core_mips_flash_detect(mcore);
1059 + mcore->early_setup_done = true;
1062 void bcma_core_mips_init(struct bcma_drv_mips *mcore)
1064 struct bcma_bus *bus;
1065 struct bcma_device *core;
1066 bus = mcore->core->bus;
1068 - bcma_info(bus, "Initializing MIPS core...\n");
1069 + if (mcore->setup_done)
1072 - if (!mcore->setup_done)
1073 - mcore->assigned_irqs = 1;
1074 + bcma_debug(bus, "Initializing MIPS core...\n");
1076 - /* Assign IRQs to all cores on the bus */
1077 - list_for_each_entry(core, &bus->cores, list) {
1082 - mips_irq = bcma_core_mips_irq(core);
1086 - core->irq = mips_irq + 2;
1087 - if (core->irq > 5)
1089 - switch (core->id.id) {
1090 - case BCMA_CORE_PCI:
1091 - case BCMA_CORE_PCIE:
1092 - case BCMA_CORE_ETHERNET:
1093 - case BCMA_CORE_ETHERNET_GBIT:
1094 - case BCMA_CORE_MAC_GBIT:
1095 - case BCMA_CORE_80211:
1096 - case BCMA_CORE_USB20_HOST:
1097 - /* These devices get their own IRQ line if available,
1098 - * the rest goes on IRQ0
1100 - if (mcore->assigned_irqs <= 4)
1101 - bcma_core_mips_set_irq(core,
1102 - mcore->assigned_irqs++);
1104 + bcma_core_mips_early_init(mcore);
1106 + switch (bus->chipinfo.id) {
1107 + case BCMA_CHIP_ID_BCM4716:
1108 + case BCMA_CHIP_ID_BCM4748:
1109 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1110 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1111 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
1112 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
1113 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1114 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
1116 + case BCMA_CHIP_ID_BCM5356:
1117 + case BCMA_CHIP_ID_BCM47162:
1118 + case BCMA_CHIP_ID_BCM53572:
1119 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1120 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1121 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1123 + case BCMA_CHIP_ID_BCM5357:
1124 + case BCMA_CHIP_ID_BCM4749:
1125 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1126 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1127 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
1128 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1129 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
1131 + case BCMA_CHIP_ID_BCM4706:
1132 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
1133 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
1135 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
1136 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
1137 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
1141 + list_for_each_entry(core, &bus->cores, list) {
1142 + core->irq = bcma_core_mips_irq(core) + 2;
1145 + "Unknown device (0x%x) found, can not configure IRQs\n",
1146 + bus->chipinfo.id);
1148 - bcma_info(bus, "IRQ reconfiguration done\n");
1149 + bcma_debug(bus, "IRQ reconfiguration done\n");
1150 bcma_core_mips_dump_irq(bus);
1152 - if (mcore->setup_done)
1155 - bcma_chipco_serial_init(&bus->drv_cc);
1156 - bcma_core_mips_flash_detect(mcore);
1157 mcore->setup_done = true;
1159 --- a/drivers/bcma/driver_pci.c
1160 +++ b/drivers/bcma/driver_pci.c
1161 @@ -51,7 +51,7 @@ static void bcma_pcie_mdio_set_phy(struc
1162 v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
1163 if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
1166 + usleep_range(1000, 2000);
1170 @@ -92,7 +92,7 @@ static u16 bcma_pcie_mdio_read(struct bc
1171 ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
1175 + usleep_range(1000, 2000);
1177 pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
1179 @@ -132,7 +132,7 @@ static void bcma_pcie_mdio_write(struct
1180 v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
1181 if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
1184 + usleep_range(1000, 2000);
1186 pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
1188 --- a/drivers/bcma/driver_pci_host.c
1189 +++ b/drivers/bcma/driver_pci_host.c
1190 @@ -35,11 +35,6 @@ bool __devinit bcma_core_pci_is_in_hostm
1191 chipid_top != 0x5300)
1194 - if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1195 - bcma_info(bus, "This PCI core is disabled and not working\n");
1199 bcma_core_enable(pc->core, 0);
1201 return !mips_busprobe32(tmp, pc->core->io_addr);
1202 @@ -396,6 +391,11 @@ void __devinit bcma_core_pci_hostmode_in
1204 bcma_info(bus, "PCIEcore in host mode found\n");
1206 + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1207 + bcma_info(bus, "This PCIE core is disabled and not working\n");
1211 pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
1213 bcma_err(bus, "can not allocate memory");
1214 @@ -425,9 +425,9 @@ void __devinit bcma_core_pci_hostmode_in
1215 pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
1219 + usleep_range(3000, 5000);
1220 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
1222 + usleep_range(1000, 2000);
1223 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
1224 BCMA_CORE_PCI_CTL_RST_OE);
1226 @@ -452,6 +452,8 @@ void __devinit bcma_core_pci_hostmode_in
1227 pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
1228 pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
1229 BCMA_SOC_PCI_MEM_SZ - 1;
1230 + pc_host->io_resource.start = 0x100;
1231 + pc_host->io_resource.end = 0x47F;
1232 pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
1233 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1234 tmp | BCMA_SOC_PCI_MEM);
1235 @@ -459,6 +461,8 @@ void __devinit bcma_core_pci_hostmode_in
1236 pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
1237 pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
1238 BCMA_SOC_PCI_MEM_SZ - 1;
1239 + pc_host->io_resource.start = 0x480;
1240 + pc_host->io_resource.end = 0x7FF;
1241 pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
1242 pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
1243 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1244 @@ -481,7 +485,7 @@ void __devinit bcma_core_pci_hostmode_in
1245 * before issuing configuration requests to PCI Express
1251 bcma_core_pci_enable_crs(pc);
1253 @@ -501,7 +505,7 @@ void __devinit bcma_core_pci_hostmode_in
1254 set_io_port_base(pc_host->pci_controller.io_map_base);
1255 /* Give some time to the PCI controller to configure itself with the new
1256 * values. Not waiting at this point causes crashes of the machine. */
1258 + usleep_range(10000, 15000);
1259 register_pci_controller(&pc_host->pci_controller);
1262 @@ -534,7 +538,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_
1263 static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
1265 struct resource *res;
1269 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
1270 /* This is not a device on the PCI-core bridge. */
1271 @@ -547,8 +551,12 @@ static void bcma_core_pci_fixup_addresse
1273 for (pos = 0; pos < 6; pos++) {
1274 res = &dev->resource[pos];
1275 - if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM))
1276 - pci_assign_resource(dev, pos);
1277 + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) {
1278 + err = pci_assign_resource(dev, pos);
1280 + pr_err("PCI: Problem fixing up the addresses on %s\n",
1285 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
1286 --- a/drivers/bcma/host_pci.c
1287 +++ b/drivers/bcma/host_pci.c
1288 @@ -77,8 +77,8 @@ static void bcma_host_pci_write32(struct
1291 #ifdef CONFIG_BCMA_BLOCKIO
1292 -void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
1293 - size_t count, u16 offset, u8 reg_width)
1294 +static void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
1295 + size_t count, u16 offset, u8 reg_width)
1297 void __iomem *addr = core->bus->mmio + offset;
1298 if (core->bus->mapped_core != core)
1299 @@ -100,8 +100,9 @@ void bcma_host_pci_block_read(struct bcm
1303 -void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
1304 - size_t count, u16 offset, u8 reg_width)
1305 +static void bcma_host_pci_block_write(struct bcma_device *core,
1306 + const void *buffer, size_t count,
1307 + u16 offset, u8 reg_width)
1309 void __iomem *addr = core->bus->mmio + offset;
1310 if (core->bus->mapped_core != core)
1311 @@ -139,7 +140,7 @@ static void bcma_host_pci_awrite32(struc
1312 iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
1315 -const struct bcma_host_ops bcma_host_pci_ops = {
1316 +static const struct bcma_host_ops bcma_host_pci_ops = {
1317 .read8 = bcma_host_pci_read8,
1318 .read16 = bcma_host_pci_read16,
1319 .read32 = bcma_host_pci_read32,
1320 @@ -237,7 +238,7 @@ static void __devexit bcma_host_pci_remo
1321 pci_set_drvdata(dev, NULL);
1325 +#ifdef CONFIG_PM_SLEEP
1326 static int bcma_host_pci_suspend(struct device *dev)
1328 struct pci_dev *pdev = to_pci_dev(dev);
1329 @@ -260,11 +261,11 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
1330 bcma_host_pci_resume);
1331 #define BCMA_PM_OPS (&bcma_pm_ops)
1333 -#else /* CONFIG_PM */
1334 +#else /* CONFIG_PM_SLEEP */
1336 #define BCMA_PM_OPS NULL
1338 -#endif /* CONFIG_PM */
1339 +#endif /* CONFIG_PM_SLEEP */
1341 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
1342 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
1343 @@ -272,6 +273,7 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_
1344 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
1345 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
1346 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
1347 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
1348 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
1349 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
1351 --- a/drivers/bcma/host_soc.c
1352 +++ b/drivers/bcma/host_soc.c
1353 @@ -143,7 +143,7 @@ static void bcma_host_soc_awrite32(struc
1354 writel(value, core->io_wrap + offset);
1357 -const struct bcma_host_ops bcma_host_soc_ops = {
1358 +static const struct bcma_host_ops bcma_host_soc_ops = {
1359 .read8 = bcma_host_soc_read8,
1360 .read16 = bcma_host_soc_read16,
1361 .read32 = bcma_host_soc_read32,
1362 --- a/drivers/bcma/main.c
1363 +++ b/drivers/bcma/main.c
1366 #include "bcma_private.h"
1367 #include <linux/module.h>
1368 +#include <linux/platform_device.h>
1369 #include <linux/bcma/bcma.h>
1370 #include <linux/slab.h>
1372 @@ -80,6 +81,18 @@ struct bcma_device *bcma_find_core(struc
1374 EXPORT_SYMBOL_GPL(bcma_find_core);
1376 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
1379 + struct bcma_device *core;
1381 + list_for_each_entry(core, &bus->cores, list) {
1382 + if (core->id.id == coreid && core->core_unit == unit)
1388 static void bcma_release_core_dev(struct device *dev)
1390 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1391 @@ -136,6 +149,33 @@ static int bcma_register_cores(struct bc
1395 +#ifdef CONFIG_BCMA_SFLASH
1396 + if (bus->drv_cc.sflash.present) {
1397 + err = platform_device_register(&bcma_sflash_dev);
1399 + bcma_err(bus, "Error registering serial flash\n");
1403 +#ifdef CONFIG_BCMA_NFLASH
1404 + if (bus->drv_cc.nflash.present) {
1405 + err = platform_device_register(&bcma_nflash_dev);
1407 + bcma_err(bus, "Error registering NAND flash\n");
1410 + err = bcma_gpio_init(&bus->drv_cc);
1411 + if (err == -ENOTSUPP)
1412 + bcma_debug(bus, "GPIO driver not activated\n");
1414 + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
1416 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
1417 + err = bcma_chipco_watchdog_register(&bus->drv_cc);
1419 + bcma_err(bus, "Error registering watchdog driver\n");
1425 @@ -148,6 +188,8 @@ static void bcma_unregister_cores(struct
1426 if (core->dev_registered)
1427 device_unregister(&core->dev);
1429 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
1430 + platform_device_unregister(bus->drv_cc.watchdog);
1433 int __devinit bcma_bus_register(struct bcma_bus *bus)
1434 @@ -166,6 +208,20 @@ int __devinit bcma_bus_register(struct b
1438 + /* Early init CC core */
1439 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
1441 + bus->drv_cc.core = core;
1442 + bcma_core_chipcommon_early_init(&bus->drv_cc);
1445 + /* Try to get SPROM */
1446 + err = bcma_sprom_get(bus);
1447 + if (err == -ENOENT) {
1448 + bcma_err(bus, "No SPROM available\n");
1450 + bcma_err(bus, "Failed to get SPROM: %d\n", err);
1453 core = bcma_find_core(bus, bcma_cc_core_id(bus));
1455 @@ -181,10 +237,17 @@ int __devinit bcma_bus_register(struct b
1458 /* Init PCIE core */
1459 - core = bcma_find_core(bus, BCMA_CORE_PCIE);
1460 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
1462 + bus->drv_pci[0].core = core;
1463 + bcma_core_pci_init(&bus->drv_pci[0]);
1466 + /* Init PCIE core */
1467 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
1469 - bus->drv_pci.core = core;
1470 - bcma_core_pci_init(&bus->drv_pci);
1471 + bus->drv_pci[1].core = core;
1472 + bcma_core_pci_init(&bus->drv_pci[1]);
1475 /* Init GBIT MAC COMMON core */
1476 @@ -194,13 +257,6 @@ int __devinit bcma_bus_register(struct b
1477 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
1480 - /* Try to get SPROM */
1481 - err = bcma_sprom_get(bus);
1482 - if (err == -ENOENT) {
1483 - bcma_err(bus, "No SPROM available\n");
1485 - bcma_err(bus, "Failed to get SPROM: %d\n", err);
1487 /* Register found cores */
1488 bcma_register_cores(bus);
1490 @@ -211,7 +267,17 @@ int __devinit bcma_bus_register(struct b
1492 void bcma_bus_unregister(struct bcma_bus *bus)
1494 + struct bcma_device *cores[3];
1496 + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1497 + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
1498 + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
1500 bcma_unregister_cores(bus);
1507 int __init bcma_bus_early_register(struct bcma_bus *bus,
1508 @@ -248,18 +314,18 @@ int __init bcma_bus_early_register(struc
1512 - /* Init CC core */
1513 + /* Early init CC core */
1514 core = bcma_find_core(bus, bcma_cc_core_id(bus));
1516 bus->drv_cc.core = core;
1517 - bcma_core_chipcommon_init(&bus->drv_cc);
1518 + bcma_core_chipcommon_early_init(&bus->drv_cc);
1521 - /* Init MIPS core */
1522 + /* Early init MIPS core */
1523 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1525 bus->drv_mips.core = core;
1526 - bcma_core_mips_init(&bus->drv_mips);
1527 + bcma_core_mips_early_init(&bus->drv_mips);
1530 bcma_info(bus, "Early bus registered\n");
1531 --- a/drivers/bcma/sprom.c
1532 +++ b/drivers/bcma/sprom.c
1533 @@ -507,7 +507,9 @@ static bool bcma_sprom_onchip_available(
1534 /* for these chips OTP is always available */
1537 + case BCMA_CHIP_ID_BCM43227:
1538 case BCMA_CHIP_ID_BCM43228:
1539 + case BCMA_CHIP_ID_BCM43428:
1540 present = chip_status & BCMA_CC_CHIPST_43228_OTP_PRESENT;
1543 @@ -593,8 +595,11 @@ int bcma_sprom_get(struct bcma_bus *bus)
1544 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
1546 err = bcma_sprom_valid(sprom);
1549 + bcma_warn(bus, "invalid sprom read from the PCIe card, try to use fallback sprom\n");
1550 + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
1554 bcma_sprom_extract_r8(bus, sprom);
1556 --- a/include/linux/bcma/bcma.h
1557 +++ b/include/linux/bcma/bcma.h
1559 #include <linux/bcma/bcma_driver_gmac_cmn.h>
1560 #include <linux/ssb/ssb.h> /* SPROM sharing */
1562 -#include "bcma_regs.h"
1563 +#include <linux/bcma/bcma_regs.h>
1567 @@ -157,6 +157,7 @@ struct bcma_host_ops {
1569 /* Chip IDs of SoCs */
1570 #define BCMA_CHIP_ID_BCM4706 0x5300
1571 +#define BCMA_PKG_ID_BCM4706L 1
1572 #define BCMA_CHIP_ID_BCM4716 0x4716
1573 #define BCMA_PKG_ID_BCM4716 8
1574 #define BCMA_PKG_ID_BCM4717 9
1575 @@ -166,7 +167,11 @@ struct bcma_host_ops {
1576 #define BCMA_CHIP_ID_BCM4749 0x4749
1577 #define BCMA_CHIP_ID_BCM5356 0x5356
1578 #define BCMA_CHIP_ID_BCM5357 0x5357
1579 +#define BCMA_PKG_ID_BCM5358 9
1580 +#define BCMA_PKG_ID_BCM47186 10
1581 +#define BCMA_PKG_ID_BCM5357 11
1582 #define BCMA_CHIP_ID_BCM53572 53572
1583 +#define BCMA_PKG_ID_BCM47188 9
1585 struct bcma_device {
1586 struct bcma_bus *bus;
1587 @@ -251,7 +256,7 @@ struct bcma_bus {
1590 struct bcma_drv_cc drv_cc;
1591 - struct bcma_drv_pci drv_pci;
1592 + struct bcma_drv_pci drv_pci[2];
1593 struct bcma_drv_mips drv_mips;
1594 struct bcma_drv_gmac_cmn drv_gmac_cmn;
1596 @@ -345,6 +350,7 @@ extern void bcma_core_set_clockmode(stru
1597 enum bcma_clkmode clkmode);
1598 extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
1600 +extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
1601 #define BCMA_DMA_TRANSLATION_MASK 0xC0000000
1602 #define BCMA_DMA_TRANSLATION_NONE 0x00000000
1603 #define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
1604 --- a/include/linux/bcma/bcma_driver_chipcommon.h
1605 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
1607 #ifndef LINUX_BCMA_DRIVER_CC_H_
1608 #define LINUX_BCMA_DRIVER_CC_H_
1610 +#include <linux/platform_device.h>
1611 +#include <linux/gpio.h>
1613 /** ChipCommon core registers. **/
1614 #define BCMA_CC_ID 0x0000
1615 #define BCMA_CC_ID_ID 0x0000FFFF
1617 #define BCMA_CC_CHIPST_4706_SFLASH_TYPE BIT(2) /* 0: 8b-p/ST-s flash, 1: 16b-p/Atmal-s flash */
1618 #define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
1619 #define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
1620 +#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
1621 #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
1622 #define BCMA_CC_JCMD_START 0x80000000
1623 #define BCMA_CC_JCMD_BUSY 0x80000000
1624 @@ -266,6 +270,29 @@
1625 #define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004
1626 #define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1
1627 #define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001
1628 +/* Block 0x140 - 0x190 registers are chipset specific */
1629 +#define BCMA_CC_4706_FLASHSCFG 0x18C /* Flash struct configuration */
1630 +#define BCMA_CC_4706_FLASHSCFG_MASK 0x000000ff
1631 +#define BCMA_CC_4706_FLASHSCFG_SF1 0x00000001 /* 2nd serial flash present */
1632 +#define BCMA_CC_4706_FLASHSCFG_PF1 0x00000002 /* 2nd parallel flash present */
1633 +#define BCMA_CC_4706_FLASHSCFG_SF1_TYPE 0x00000004 /* 2nd serial flash type : 0 : ST, 1 : Atmel */
1634 +#define BCMA_CC_4706_FLASHSCFG_NF1 0x00000008 /* 2nd NAND flash present */
1635 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_MASK 0x000000f0
1636 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_4MB 0x00000010 /* 4MB */
1637 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_8MB 0x00000020 /* 8MB */
1638 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_16MB 0x00000030 /* 16MB */
1639 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_32MB 0x00000040 /* 32MB */
1640 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_64MB 0x00000050 /* 64MB */
1641 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_128MB 0x00000060 /* 128MB */
1642 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_256MB 0x00000070 /* 256MB */
1643 +/* NAND flash registers for BCM4706 (corerev = 31) */
1644 +#define BCMA_CC_NFLASH_CTL 0x01A0
1645 +#define BCMA_CC_NFLASH_CTL_ERR 0x08000000
1646 +#define BCMA_CC_NFLASH_CONF 0x01A4
1647 +#define BCMA_CC_NFLASH_COL_ADDR 0x01A8
1648 +#define BCMA_CC_NFLASH_ROW_ADDR 0x01AC
1649 +#define BCMA_CC_NFLASH_DATA 0x01B0
1650 +#define BCMA_CC_NFLASH_WAITCNT0 0x01B4
1651 /* 0x1E0 is defined as shared BCMA_CLKCTLST */
1652 #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
1653 #define BCMA_CC_UART0_DATA 0x0300
1654 @@ -325,6 +352,60 @@
1655 #define BCMA_CC_PLLCTL_ADDR 0x0660
1656 #define BCMA_CC_PLLCTL_DATA 0x0664
1657 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
1658 +/* NAND flash MLC controller registers (corerev >= 38) */
1659 +#define BCMA_CC_NAND_REVISION 0x0C00
1660 +#define BCMA_CC_NAND_CMD_START 0x0C04
1661 +#define BCMA_CC_NAND_CMD_ADDR_X 0x0C08
1662 +#define BCMA_CC_NAND_CMD_ADDR 0x0C0C
1663 +#define BCMA_CC_NAND_CMD_END_ADDR 0x0C10
1664 +#define BCMA_CC_NAND_CS_NAND_SELECT 0x0C14
1665 +#define BCMA_CC_NAND_CS_NAND_XOR 0x0C18
1666 +#define BCMA_CC_NAND_SPARE_RD0 0x0C20
1667 +#define BCMA_CC_NAND_SPARE_RD4 0x0C24
1668 +#define BCMA_CC_NAND_SPARE_RD8 0x0C28
1669 +#define BCMA_CC_NAND_SPARE_RD12 0x0C2C
1670 +#define BCMA_CC_NAND_SPARE_WR0 0x0C30
1671 +#define BCMA_CC_NAND_SPARE_WR4 0x0C34
1672 +#define BCMA_CC_NAND_SPARE_WR8 0x0C38
1673 +#define BCMA_CC_NAND_SPARE_WR12 0x0C3C
1674 +#define BCMA_CC_NAND_ACC_CONTROL 0x0C40
1675 +#define BCMA_CC_NAND_CONFIG 0x0C48
1676 +#define BCMA_CC_NAND_TIMING_1 0x0C50
1677 +#define BCMA_CC_NAND_TIMING_2 0x0C54
1678 +#define BCMA_CC_NAND_SEMAPHORE 0x0C58
1679 +#define BCMA_CC_NAND_DEVID 0x0C60
1680 +#define BCMA_CC_NAND_DEVID_X 0x0C64
1681 +#define BCMA_CC_NAND_BLOCK_LOCK_STATUS 0x0C68
1682 +#define BCMA_CC_NAND_INTFC_STATUS 0x0C6C
1683 +#define BCMA_CC_NAND_ECC_CORR_ADDR_X 0x0C70
1684 +#define BCMA_CC_NAND_ECC_CORR_ADDR 0x0C74
1685 +#define BCMA_CC_NAND_ECC_UNC_ADDR_X 0x0C78
1686 +#define BCMA_CC_NAND_ECC_UNC_ADDR 0x0C7C
1687 +#define BCMA_CC_NAND_READ_ERROR_COUNT 0x0C80
1688 +#define BCMA_CC_NAND_CORR_STAT_THRESHOLD 0x0C84
1689 +#define BCMA_CC_NAND_READ_ADDR_X 0x0C90
1690 +#define BCMA_CC_NAND_READ_ADDR 0x0C94
1691 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR_X 0x0C98
1692 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR 0x0C9C
1693 +#define BCMA_CC_NAND_COPY_BACK_ADDR_X 0x0CA0
1694 +#define BCMA_CC_NAND_COPY_BACK_ADDR 0x0CA4
1695 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR_X 0x0CA8
1696 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR 0x0CAC
1697 +#define BCMA_CC_NAND_INV_READ_ADDR_X 0x0CB0
1698 +#define BCMA_CC_NAND_INV_READ_ADDR 0x0CB4
1699 +#define BCMA_CC_NAND_BLK_WR_PROTECT 0x0CC0
1700 +#define BCMA_CC_NAND_ACC_CONTROL_CS1 0x0CD0
1701 +#define BCMA_CC_NAND_CONFIG_CS1 0x0CD4
1702 +#define BCMA_CC_NAND_TIMING_1_CS1 0x0CD8
1703 +#define BCMA_CC_NAND_TIMING_2_CS1 0x0CDC
1704 +#define BCMA_CC_NAND_SPARE_RD16 0x0D30
1705 +#define BCMA_CC_NAND_SPARE_RD20 0x0D34
1706 +#define BCMA_CC_NAND_SPARE_RD24 0x0D38
1707 +#define BCMA_CC_NAND_SPARE_RD28 0x0D3C
1708 +#define BCMA_CC_NAND_CACHE_ADDR 0x0D40
1709 +#define BCMA_CC_NAND_CACHE_DATA 0x0D44
1710 +#define BCMA_CC_NAND_CTRL_CONFIG 0x0D48
1711 +#define BCMA_CC_NAND_CTRL_STATUS 0x0D4C
1713 /* Divider allocation in 4716/47162/5356 */
1714 #define BCMA_CC_PMU5_MAINPLL_CPU 1
1715 @@ -415,6 +496,13 @@
1716 /* 4313 Chip specific ChipControl register bits */
1717 #define BCMA_CCTRL_4313_12MA_LED_DRIVE 0x00000007 /* 12 mA drive strengh for later 4313 */
1719 +/* BCM5357 ChipControl register bits */
1720 +#define BCMA_CHIPCTL_5357_EXTPA BIT(14)
1721 +#define BCMA_CHIPCTL_5357_ANT_MUX_2O3 BIT(15)
1722 +#define BCMA_CHIPCTL_5357_NFLASH BIT(16)
1723 +#define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
1724 +#define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
1726 /* Data for the PMU, if available.
1727 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
1729 @@ -425,11 +513,35 @@ struct bcma_chipcommon_pmu {
1731 #ifdef CONFIG_BCMA_DRIVER_MIPS
1732 struct bcma_pflash {
1739 +#ifdef CONFIG_BCMA_SFLASH
1740 +struct bcma_sflash {
1747 + struct mtd_info *mtd;
1751 +#ifdef CONFIG_BCMA_NFLASH
1754 +struct bcma_nflash {
1756 + bool boot; /* This is the flash the SoC boots from */
1758 + struct mtd_info *mtd;
1762 struct bcma_serial_port {
1764 unsigned long clockspeed;
1765 @@ -445,15 +557,30 @@ struct bcma_drv_cc {
1767 u32 capabilities_ext;
1769 + u8 early_setup_done:1;
1770 /* Fast Powerup Delay constant */
1771 u16 fast_pwrup_delay;
1772 struct bcma_chipcommon_pmu pmu;
1773 #ifdef CONFIG_BCMA_DRIVER_MIPS
1774 struct bcma_pflash pflash;
1775 +#ifdef CONFIG_BCMA_SFLASH
1776 + struct bcma_sflash sflash;
1778 +#ifdef CONFIG_BCMA_NFLASH
1779 + struct bcma_nflash nflash;
1782 int nr_serial_ports;
1783 struct bcma_serial_port serial_ports[4];
1784 #endif /* CONFIG_BCMA_DRIVER_MIPS */
1786 + struct platform_device *watchdog;
1788 + /* Lock for GPIO register access. */
1789 + spinlock_t gpio_lock;
1790 +#ifdef CONFIG_BCMA_DRIVER_GPIO
1791 + struct gpio_chip gpio;
1795 /* Register access */
1796 @@ -470,14 +597,14 @@ struct bcma_drv_cc {
1797 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
1799 extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
1800 +extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
1802 extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
1803 extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
1805 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
1807 -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
1809 +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
1811 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
1813 @@ -490,9 +617,12 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
1814 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
1815 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
1816 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
1817 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
1818 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
1821 extern void bcma_pmu_init(struct bcma_drv_cc *cc);
1822 +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
1824 extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
1826 --- a/include/linux/bcma/bcma_driver_mips.h
1827 +++ b/include/linux/bcma/bcma_driver_mips.h
1828 @@ -35,13 +35,15 @@ struct bcma_device;
1829 struct bcma_drv_mips {
1830 struct bcma_device *core;
1832 - unsigned int assigned_irqs;
1833 + u8 early_setup_done:1;
1836 #ifdef CONFIG_BCMA_DRIVER_MIPS
1837 extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
1838 +extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
1840 static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
1841 +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
1844 extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
1845 --- a/include/linux/bcma/bcma_regs.h
1846 +++ b/include/linux/bcma/bcma_regs.h
1848 #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
1849 #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
1850 #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
1851 +#define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
1852 #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
1853 #define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
1854 #define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
1855 #define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
1856 #define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
1857 +#define BCMA_CLKCTLST_EXTRESST_SHIFT 24
1858 /* Is there any BCM4328 on BCMA bus? */
1859 #define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
1860 #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
1862 * (2 ZettaBytes), high 32 bits
1865 +#define BCMA_SOC_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */
1866 +#define BCMA_SOC_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */
1867 +#define BCMA_SOC_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
1868 +#define BCMA_SOC_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
1870 #endif /* LINUX_BCMA_REGS_H_ */
1871 --- a/drivers/net/wireless/b43/main.c
1872 +++ b/drivers/net/wireless/b43/main.c
1873 @@ -4622,7 +4622,7 @@ static int b43_wireless_core_init(struct
1874 switch (dev->dev->bus_type) {
1875 #ifdef CONFIG_B43_BCMA
1877 - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
1878 + bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
1879 dev->dev->bdev, true);
1882 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
1883 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
1884 @@ -695,7 +695,7 @@ void ai_pci_up(struct si_pub *sih)
1885 sii = container_of(sih, struct si_info, pub);
1887 if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
1888 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, true);
1889 + bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], true);
1892 /* Unconfigure and/or apply various WARs when going down */
1893 @@ -706,7 +706,7 @@ void ai_pci_down(struct si_pub *sih)
1894 sii = container_of(sih, struct si_info, pub);
1896 if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
1897 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, false);
1898 + bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], false);
1901 /* Enable BT-COEX & Ex-PA for 4313 */
1902 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
1903 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
1904 @@ -5077,7 +5077,7 @@ static int brcms_b_up_prep(struct brcms_
1905 * Configure pci/pcmcia here instead of in brcms_c_attach()
1906 * to allow mfg hotswap: down, hotswap (chip power cycle), up.
1908 - bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci, wlc_hw->d11core,
1909 + bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,