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
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;
12 --- a/drivers/bcma/Kconfig
13 +++ b/drivers/bcma/Kconfig
14 @@ -26,6 +26,7 @@ config BCMA_HOST_PCI_POSSIBLE
16 bool "Support for BCMA on PCI-host bus"
17 depends on BCMA_HOST_PCI_POSSIBLE
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).
27 - depends on BCMA_DRIVER_MIPS
28 + bool "Support for BCMA in a SoC"
31 + Host interface for a Broadcom AIX bus directly mapped into
32 + the memory. This only works with the Broadcom SoCs from the
37 config BCMA_DRIVER_MIPS
38 bool "BCMA Broadcom MIPS core driver"
39 @@ -48,12 +55,12 @@ config BCMA_DRIVER_MIPS
43 - depends on BCMA_DRIVER_MIPS && BROKEN
44 + depends on BCMA_DRIVER_MIPS
49 - depends on BCMA_DRIVER_MIPS && BROKEN
50 + depends on BCMA_DRIVER_MIPS
53 config BCMA_DRIVER_GMAC_CMN
54 @@ -65,6 +72,14 @@ config BCMA_DRIVER_GMAC_CMN
58 +config BCMA_DRIVER_GPIO
59 + bool "BCMA GPIO driver"
60 + depends on BCMA && GPIOLIB
62 + Driver to provide access to the GPIO pins of the bcma bus.
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
85 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
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);
94 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
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 */
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);
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;
117 static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
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;
125 static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
127 @@ -82,9 +89,26 @@ extern void __exit bcma_host_pci_exit(vo
129 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
131 +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
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 */
138 +#ifdef CONFIG_BCMA_DRIVER_GPIO
140 +int bcma_gpio_init(struct bcma_drv_cc *cc);
141 +int bcma_gpio_unregister(struct bcma_drv_cc *cc);
143 +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
147 +static inline int bcma_gpio_unregister(struct bcma_drv_cc *cc)
151 +#endif /* CONFIG_BCMA_DRIVER_GPIO */
154 --- a/drivers/bcma/core.c
155 +++ b/drivers/bcma/core.c
157 #include <linux/export.h>
158 #include <linux/bcma/bcma.h>
160 +static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask,
161 + u32 value, int timeout)
163 + unsigned long deadline = jiffies + timeout;
167 + val = bcma_aread32(core, reg);
168 + if ((val & mask) == value)
172 + } while (!time_after_eq(jiffies, deadline));
174 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
179 bool bcma_core_is_enabled(struct bcma_device *core)
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)
186 - bcma_awrite32(core, BCMA_IOCTL, flags);
187 - bcma_aread32(core, BCMA_IOCTL);
189 + bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300);
191 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
192 bcma_aread32(core, BCMA_RESET_CTL);
195 + bcma_awrite32(core, BCMA_IOCTL, flags);
196 + bcma_aread32(core, BCMA_IOCTL);
199 EXPORT_SYMBOL_GPL(bcma_core_disable);
201 @@ -43,6 +64,7 @@ int bcma_core_enable(struct bcma_device
202 bcma_aread32(core, BCMA_IOCTL);
204 bcma_awrite32(core, BCMA_RESET_CTL, 0);
205 + bcma_aread32(core, BCMA_RESET_CTL);
208 bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
209 @@ -65,7 +87,7 @@ void bcma_core_set_clockmode(struct bcma
211 case BCMA_CLKMODE_FAST:
212 bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
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
220 bcma_err(core->bus, "PLL enable timeout\n");
222 - bcma_warn(core->bus, "Disabling PLL not supported yet!\n");
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
228 + bcma_mask32(core, BCMA_CLKCTLST, ~req);
229 + bcma_read32(core, BCMA_CLKCTLST);
232 EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
233 --- a/drivers/bcma/driver_chipcommon.c
234 +++ b/drivers/bcma/driver_chipcommon.c
237 * Copyright 2005, Broadcom Corporation
238 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
239 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
241 * Licensed under the GNU/GPL. See COPYING for details.
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>
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
255 -void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
256 +u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
259 - u32 leddc_off = 90;
260 + if (cc->capabilities & BCMA_CC_CAP_PMU)
261 + return bcma_pmu_get_alp_clock(cc);
263 - if (cc->setup_done)
266 +EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
268 +static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
270 + struct bcma_bus *bus = cc->core->bus;
273 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
274 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
276 + else if (cc->core->id.rev < 26)
279 + nb = (cc->core->id.rev >= 37) ? 32 : 24;
286 + return (1 << nb) - 1;
289 +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
292 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
294 + return bcma_chipco_watchdog_timer_set(cc, ticks);
297 +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
300 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
303 + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
304 + return ticks / cc->ticks_per_ms;
307 +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
309 + struct bcma_bus *bus = cc->core->bus;
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;
316 + /* based on 32KHz ILP clock */
319 + return bcma_chipco_get_alp_clock(cc) / 1000;
323 +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
325 + struct bcm47xx_wdt wdt = {};
326 + struct platform_device *pdev;
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;
333 + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
334 + cc->core->bus->num, &wdt,
337 + return PTR_ERR(pdev);
339 + cc->watchdog = pdev;
344 +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
346 + if (cc->early_setup_done)
349 + spin_lock_init(&cc->gpio_lock);
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);
357 + if (cc->capabilities & BCMA_CC_CAP_PMU)
358 + bcma_pmu_early_init(cc);
360 + cc->early_setup_done = true;
363 +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
366 + u32 leddc_off = 90;
368 + if (cc->setup_done)
371 + bcma_core_chipcommon_early_init(cc);
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;
378 + if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) {
380 + pulldown = 0x20500;
383 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup);
384 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown);
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)));
392 + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
394 cc->setup_done = true;
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)
402 - bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
404 + enum bcma_clkmode clkmode;
406 + maxt = bcma_chipco_watchdog_get_max_timer(cc);
407 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
410 + else if (ticks > maxt)
412 + bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
414 + clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
415 + bcma_core_set_clockmode(cc->core, clkmode);
419 + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
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_
427 u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
429 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
430 + unsigned long flags;
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);
439 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
441 u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
443 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
444 + unsigned long flags;
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);
453 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
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.
459 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
461 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
462 + unsigned long flags;
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);
471 EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
473 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
475 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
476 + unsigned long flags;
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);
486 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
488 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
489 + unsigned long flags;
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);
499 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value)
501 + unsigned long flags;
504 + if (cc->core->id.rev < 20)
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);
514 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value)
516 + unsigned long flags;
519 + if (cc->core->id.rev < 20)
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);
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;
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);
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
544 - irq = bcma_core_mips_irq(cc->core);
545 + irq = bcma_core_irq(cc->core);
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
552 * Licensed under the GNU/GPL. See COPYING for details.
555 +#include "bcma_private.h"
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>
562 -#include "bcma_private.h"
563 +struct platform_device bcma_nflash_dev = {
564 + .name = "bcma_nflash",
565 + .num_resources = 0,
568 /* Initialize NAND flash access */
569 int bcma_nflash_init(struct bcma_drv_cc *cc)
571 - bcma_err(cc->core->bus, "NAND flash support is broken\n");
572 + struct bcma_bus *bus = cc->core->bus;
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");
580 + if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
581 + bcma_err(bus, "NAND flash not present according to ChipCommon\n");
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;
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;
596 --- a/drivers/bcma/driver_chipcommon_pmu.c
597 +++ b/drivers/bcma/driver_chipcommon_pmu.c
599 #include <linux/export.h>
600 #include <linux/bcma/bcma.h>
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)
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);
609 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
611 void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
613 @@ -55,6 +56,109 @@ void bcma_chipco_regctl_maskset(struct b
615 EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
617 +static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc)
619 + u32 ilp_ctl, alp_hz;
621 + if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) &
622 + BCMA_CC_PMU_STAT_EXT_LPO_AVAIL))
625 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
626 + BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
627 + usleep_range(1000, 2000);
629 + ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
630 + ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK;
632 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
634 + alp_hz = ilp_ctl * 32768 / 4;
635 + return (alp_hz + 50000) / 100000 * 100;
638 +static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq)
640 + struct bcma_bus *bus = cc->core->bus;
641 + u32 freq_tgt_target = 0, freq_tgt_current;
644 + switch (bus->chipinfo.id) {
645 + case BCMA_CHIP_ID_BCM43142:
646 + /* pmu2_xtaltab0_adfll_485 */
647 + switch (xtalfreq) {
649 + freq_tgt_target = 0x50D52;
652 + freq_tgt_target = 0x307FE;
655 + freq_tgt_target = 0x254EA;
658 + freq_tgt_target = 0x19EF8;
661 + freq_tgt_target = 0x12A75;
667 + if (!freq_tgt_target) {
668 + bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n",
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;
677 + if (freq_tgt_current == freq_tgt_target) {
678 + bcma_debug(bus, "Target TGT frequency already set\n");
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);
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);
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);
700 + if (cc->pmu.rev >= 2)
701 + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
703 + /* TODO: Do we need to update OTP? */
706 +static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
708 + struct bcma_bus *bus = cc->core->bus;
709 + u32 xtalfreq = bcma_pmu_xtalfreq(cc);
711 + switch (bus->chipinfo.id) {
712 + case BCMA_CHIP_ID_BCM43142:
715 + bcma_pmu2_pll_init0(cc, xtalfreq);
720 static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
722 struct bcma_bus *bus = cc->core->bus;
723 @@ -65,6 +169,25 @@ static void bcma_pmu_resources_init(stru
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;
747 bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
749 @@ -76,7 +199,10 @@ static void bcma_pmu_resources_init(stru
751 bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
753 - /* Add some delay; allow resources to come up and settle. */
755 + * Add some delay; allow resources to come up and settle.
756 + * Delay is required for SoC (early init).
761 @@ -101,7 +227,7 @@ void bcma_chipco_bcm4331_ext_pa_lines_ct
762 bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
765 -void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
766 +static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
768 struct bcma_bus *bus = cc->core->bus;
770 @@ -141,7 +267,7 @@ void bcma_pmu_workarounds(struct bcma_dr
774 -void bcma_pmu_init(struct bcma_drv_cc *cc)
775 +void bcma_pmu_early_init(struct bcma_drv_cc *cc)
779 @@ -150,7 +276,10 @@ void bcma_pmu_init(struct bcma_drv_cc *c
781 bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
782 cc->pmu.rev, pmucap);
785 +void bcma_pmu_init(struct bcma_drv_cc *cc)
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);
794 + bcma_pmu_pll_init(cc);
795 bcma_pmu_resources_init(cc);
796 bcma_pmu_workarounds(cc);
799 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
800 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
802 struct bcma_bus *bus = cc->core->bus;
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:
826 - case BCMA_CHIP_ID_BCM5356:
827 case BCMA_CHIP_ID_BCM4706:
828 + case BCMA_CHIP_ID_BCM5356:
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;
837 + return 20000 * 1000;
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.
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)
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;
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;
858 /* Return clock in Hertz */
859 return (fc / div) * 1000000;
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)
865 u32 tmp, ndiv, p1div, p2div;
867 @@ -257,7 +403,7 @@ static u32 bcma_pmu_clock_bcm4706(struct
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)
874 struct bcma_bus *bus = cc->core->bus;
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:
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);
908 return BCMA_CC_PMU_HT_CLOCK;
910 +EXPORT_SYMBOL_GPL(bcma_pmu_get_bus_clock);
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)
916 struct bcma_bus *bus = cc->core->bus;
918 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
921 + /* New PMUs can have different clock for bus and CPU */
922 if (cc->pmu.rev >= 5) {
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
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);
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);
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);
950 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
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,
959 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
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,
968 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
971 case BCMA_CHIP_ID_BCM4716:
972 @@ -450,7 +600,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
977 + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
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,
986 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
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
993 * Licensed under the GNU/GPL. See COPYING for details.
996 +#include "bcma_private.h"
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>
1003 -#include "bcma_private.h"
1004 +static struct resource bcma_sflash_resource = {
1005 + .name = "bcma_sflash",
1006 + .start = BCMA_SOC_FLASH2,
1008 + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
1011 +struct platform_device bcma_sflash_dev = {
1012 + .name = "bcma_sflash",
1013 + .resource = &bcma_sflash_resource,
1014 + .num_resources = 1,
1017 +struct bcma_sflash_tbl_e {
1024 +static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
1025 + { "M25P20", 0x11, 0x10000, 4, },
1026 + { "M25P40", 0x12, 0x10000, 8, },
1028 + { "M25P16", 0x14, 0x10000, 32, },
1029 + { "M25P32", 0x15, 0x10000, 64, },
1030 + { "M25P64", 0x16, 0x10000, 128, },
1031 + { "M25FL128", 0x17, 0x10000, 256, },
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, },
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, },
1064 +static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
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))
1075 + bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
1078 /* Initialize serial flash access */
1079 int bcma_sflash_init(struct bcma_drv_cc *cc)
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;
1087 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
1088 + case BCMA_CC_FLASHT_STSER:
1089 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_DP);
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);
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);
1101 + for (e = bcma_sflash_sst_tbl; e->name; e++) {
1109 + for (e = bcma_sflash_st_tbl; e->name; e++) {
1116 + bcma_err(bus, "Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n", id, id2);
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;
1125 + for (e = bcma_sflash_at_tbl; e->name; e++) {
1130 + bcma_err(bus, "Unsupported Atmel serial flash (id: 0x%X)\n", id);
1136 + bcma_err(bus, "Unsupported flash type\n");
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;
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);
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 +
1154 + bcma_sflash_dev.dev.platform_data = sflash;
1159 +++ b/drivers/bcma/driver_gpio.c
1162 + * Broadcom specific AMBA
1165 + * Copyright 2011, Broadcom Corporation
1166 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
1168 + * Licensed under the GNU/GPL. See COPYING for details.
1171 +#include <linux/gpio.h>
1172 +#include <linux/export.h>
1173 +#include <linux/bcma/bcma.h>
1175 +#include "bcma_private.h"
1177 +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
1179 + return container_of(chip, struct bcma_drv_cc, gpio);
1182 +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
1184 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1186 + return !!bcma_chipco_gpio_in(cc, 1 << gpio);
1189 +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
1192 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1194 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1197 +static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
1199 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1201 + bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
1205 +static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
1208 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1210 + bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
1211 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1215 +static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
1217 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1219 + bcma_chipco_gpio_control(cc, 1 << gpio, 0);
1220 + /* clear pulldown */
1221 + bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
1223 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
1228 +static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
1230 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1232 + /* clear pullup */
1233 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
1236 +static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
1238 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1240 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
1241 + return bcma_core_irq(cc->core);
1246 +int bcma_gpio_init(struct bcma_drv_cc *cc)
1248 + struct gpio_chip *chip = &cc->gpio;
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;
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)
1268 + return gpiochip_add(chip);
1271 +int bcma_gpio_unregister(struct bcma_drv_cc *cc)
1273 + return gpiochip_remove(&cc->gpio);
1275 --- a/drivers/bcma/driver_mips.c
1276 +++ b/drivers/bcma/driver_mips.c
1279 #include <linux/bcma/bcma.h>
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>
1288 +static const char * const part_probes[] = { "bcm47xxpart", NULL };
1290 +static struct physmap_flash_data bcma_pflash_data = {
1291 + .part_probe_types = part_probes,
1294 +static struct resource bcma_pflash_resource = {
1295 + .name = "bcma_pflash",
1296 + .flags = IORESOURCE_MEM,
1299 +struct platform_device bcma_pflash_dev = {
1300 + .name = "physmap-flash",
1302 + .platform_data = &bcma_pflash_data,
1304 + .resource = &bcma_pflash_resource,
1305 + .num_resources = 1,
1308 /* The 47162a0 hangs when reading MIPS DMP registers registers */
1309 static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
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);
1315 - return flag & 0x1F;
1317 + return flag & 0x1F;
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.
1327 -unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1328 +static unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1330 struct bcma_device *mdev = dev->bus->drv_mips.core;
1334 irqflag = bcma_core_mips_irqflag(dev);
1335 + if (irqflag == 0x3f)
1338 - for (irq = 1; irq <= 4; irq++)
1339 + for (irq = 0; irq <= 4; irq++)
1340 if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
1348 +unsigned int bcma_core_irq(struct bcma_device *dev)
1350 + unsigned int mips_irq = bcma_core_mips_irq(dev);
1351 + return mips_irq <= 4 ? mips_irq + 2 : 0;
1353 -EXPORT_SYMBOL(bcma_core_mips_irq);
1354 +EXPORT_SYMBOL(bcma_core_irq);
1356 static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
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)) &
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);
1367 /* assign the new one */
1369 @@ -123,9 +158,9 @@ static void bcma_core_mips_set_irq(struc
1370 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
1373 - u32 oldirqflag = bcma_read32(mdev,
1374 - BCMA_MIPS_MIPS74K_INTMASK(irq));
1376 + u32 irqinitmask = bcma_read32(mdev,
1377 + BCMA_MIPS_MIPS74K_INTMASK(irq));
1378 + if (irqinitmask) {
1379 struct bcma_device *core;
1381 /* backplane irq line is in use, find out who uses
1382 @@ -133,7 +168,7 @@ static void bcma_core_mips_set_irq(struc
1384 list_for_each_entry(core, &bus->cores, list) {
1385 if ((1 << bcma_core_mips_irqflag(core)) ==
1388 bcma_core_mips_set_irq(core, 0);
1391 @@ -143,15 +178,31 @@ static void bcma_core_mips_set_irq(struc
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);
1401 +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
1402 + u16 coreid, u8 unit)
1404 + struct bcma_device *core;
1406 + core = bcma_find_core_unit(bus, coreid, unit);
1409 + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
1414 + bcma_core_mips_set_irq(core, irq);
1417 static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
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 ? "*" : " ");
1426 @@ -171,7 +222,7 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
1427 struct bcma_bus *bus = mcore->core->bus;
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);
1433 bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
1435 @@ -181,85 +232,143 @@ EXPORT_SYMBOL(bcma_cpu_clock);
1436 static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
1438 struct bcma_bus *bus = mcore->core->bus;
1439 + struct bcma_drv_cc *cc = &bus->drv_cc;
1440 + struct bcma_pflash *pflash = &cc->pflash;
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);
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;
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;
1464 - bus->drv_cc.pflash.buswidth = 2;
1465 + pflash->buswidth = 2;
1467 + bcma_pflash_data.width = pflash->buswidth;
1468 + bcma_pflash_resource.start = pflash->window;
1469 + bcma_pflash_resource.end = pflash->window + pflash->window_size;
1473 bcma_err(bus, "Flash type not supported\n");
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);
1488 +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
1490 + struct bcma_bus *bus = mcore->core->bus;
1492 + if (mcore->early_setup_done)
1495 + bcma_chipco_serial_init(&bus->drv_cc);
1496 + bcma_core_mips_flash_detect(mcore);
1498 + mcore->early_setup_done = true;
1501 +static void bcma_fix_i2s_irqflag(struct bcma_bus *bus)
1503 + struct bcma_device *cpu, *pcie, *i2s;
1505 + /* Fixup the interrupts in 4716/4748 for i2s core (2010 Broadcom SDK)
1506 + * (IRQ flags > 7 are ignored when setting the interrupt masks)
1508 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4716 &&
1509 + bus->chipinfo.id != BCMA_CHIP_ID_BCM4748)
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);
1523 + "Moved i2s interrupt to oob line 7 instead of 8\n");
1527 void bcma_core_mips_init(struct bcma_drv_mips *mcore)
1529 struct bcma_bus *bus;
1530 struct bcma_device *core;
1531 bus = mcore->core->bus;
1533 - bcma_info(bus, "Initializing MIPS core...\n");
1534 + if (mcore->setup_done)
1537 - if (!mcore->setup_done)
1538 - mcore->assigned_irqs = 1;
1539 + bcma_debug(bus, "Initializing MIPS core...\n");
1541 - /* Assign IRQs to all cores on the bus */
1542 - list_for_each_entry(core, &bus->cores, list) {
1547 - mips_irq = bcma_core_mips_irq(core);
1551 - core->irq = mips_irq + 2;
1552 - if (core->irq > 5)
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
1565 - if (mcore->assigned_irqs <= 4)
1566 - bcma_core_mips_set_irq(core,
1567 - mcore->assigned_irqs++);
1569 + bcma_core_mips_early_init(mcore);
1571 + bcma_fix_i2s_irqflag(bus);
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);
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);
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);
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,
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,
1608 + list_for_each_entry(core, &bus->cores, list) {
1609 + core->irq = bcma_core_irq(core);
1612 + "Unknown device (0x%x) found, can not configure IRQs\n",
1613 + bus->chipinfo.id);
1615 - bcma_info(bus, "IRQ reconfiguration done\n");
1616 + bcma_debug(bus, "IRQ reconfiguration done\n");
1617 bcma_core_mips_dump_irq(bus);
1619 - if (mcore->setup_done)
1622 - bcma_chipco_serial_init(&bus->drv_cc);
1623 - bcma_core_mips_flash_detect(mcore);
1624 mcore->setup_done = true;
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);
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)
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)
1642 + usleep_range(1000, 2000);
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)
1649 int max_retries = 10;
1651 @@ -92,13 +92,13 @@ static u16 bcma_pcie_mdio_read(struct bc
1652 ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
1656 + usleep_range(1000, 2000);
1658 pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
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)
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)
1672 + usleep_range(1000, 2000);
1674 pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
1677 +static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device,
1678 + u8 address, u16 data)
1680 + bcma_pcie_mdio_write(pc, device, address, data);
1681 + return bcma_pcie_mdio_read(pc, device, address);
1684 /**************************************************
1686 **************************************************/
1687 @@ -203,6 +210,25 @@ static void bcma_core_pci_config_fixup(s
1691 +static void bcma_core_pci_power_save(struct bcma_drv_pci *pc, bool up)
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);
1710 /**************************************************
1712 **************************************************/
1713 @@ -262,7 +288,7 @@ out:
1715 EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
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)
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);
1726 -EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
1728 +void bcma_core_pci_up(struct bcma_bus *bus)
1730 + struct bcma_drv_pci *pc;
1732 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
1735 + pc = &bus->drv_pci[0];
1737 + bcma_core_pci_power_save(pc, true);
1739 + bcma_core_pci_extend_L1timer(pc, true);
1741 +EXPORT_SYMBOL_GPL(bcma_core_pci_up);
1743 +void bcma_core_pci_down(struct bcma_bus *bus)
1745 + struct bcma_drv_pci *pc;
1747 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
1750 + pc = &bus->drv_pci[0];
1752 + bcma_core_pci_extend_L1timer(pc, false);
1754 + bcma_core_pci_power_save(pc, false);
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)
1763 - if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1764 - bcma_info(bus, "This PCI core is disabled and not working\n");
1768 bcma_core_enable(pc->core, 0);
1770 return !mips_busprobe32(tmp, pc->core->io_addr);
1771 @@ -99,19 +94,19 @@ static int bcma_extpci_read_config(struc
1773 /* we support only two functions on device 0 */
1778 /* accesses to config registers with offsets >= 256
1779 * requires indirect access.
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);
1787 addr = BCMA_CORE_PCI_PCICFG0;
1788 addr |= (func << 8);
1789 - addr |= (off & 0xfc);
1790 + addr |= (off & 0xFC);
1791 val = pcicore_read32(pc, addr);
1794 @@ -124,11 +119,9 @@ static int bcma_extpci_read_config(struc
1797 if (mips_busprobe32(val, mmio)) {
1803 - val = readl(mmio);
1805 val >>= (8 * (off & 3));
1807 @@ -156,7 +149,7 @@ static int bcma_extpci_write_config(stru
1808 const void *buf, int len)
1811 - u32 addr = 0, val = 0;
1813 void __iomem *mmio = 0;
1814 u16 chipid = pc->core->bus->chipinfo.id;
1816 @@ -164,16 +157,22 @@ static int bcma_extpci_write_config(stru
1817 if (unlikely(len != 1 && len != 2 && len != 4))
1820 + /* we support only two functions on device 0 */
1824 /* accesses to config registers with offsets >= 256
1825 * requires indirect access.
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);
1834 + addr = BCMA_CORE_PCI_PCICFG0;
1835 addr |= (func << 8);
1836 - addr |= (off & 0xfc);
1837 - mmio = ioremap_nocache(addr, sizeof(val));
1840 + addr |= (off & 0xFC);
1841 + val = pcicore_read32(pc, addr);
1844 addr = bcma_get_cfgspace_addr(pc, dev, func, off);
1845 @@ -185,19 +184,17 @@ static int bcma_extpci_write_config(stru
1848 if (mips_busprobe32(val, mmio)) {
1857 - val = readl(mmio);
1858 val &= ~(0xFF << (8 * (off & 3)));
1859 val |= *((const u8 *)buf) << (8 * (off & 3));
1862 - val = readl(mmio);
1863 val &= ~(0xFFFF << (8 * (off & 3)));
1864 val |= *((const u16 *)buf) << (8 * (off & 3));
1866 @@ -205,13 +202,14 @@ static int bcma_extpci_write_config(stru
1867 val = *((const u32 *)buf);
1870 - if (dev == 0 && !addr) {
1872 /* accesses to config registers with offsets >= 256
1873 * requires indirect access.
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);
1881 + pcicore_write32(pc, addr, val);
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,
1889 - if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
1890 + if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
1893 /* check if the capability pointer field exists */
1894 @@ -396,12 +394,19 @@ void __devinit bcma_core_pci_hostmode_in
1896 bcma_info(bus, "PCIEcore in host mode found\n");
1898 + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1899 + bcma_info(bus, "This PCIE core is disabled and not working\n");
1903 pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
1905 bcma_err(bus, "can not allocate memory");
1909 + spin_lock_init(&pc_host->cfgspace_lock);
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;
1919 + usleep_range(3000, 5000);
1920 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
1923 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
1924 BCMA_CORE_PCI_CTL_RST_OE);
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
1951 bcma_core_pci_enable_crs(pc);
1953 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706 ||
1954 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4716) {
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));
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. */
1972 + usleep_range(10000, 15000);
1973 register_pci_controller(&pc_host->pci_controller);
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)
1979 struct resource *res;
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
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);
1994 + pr_err("PCI: Problem fixing up the addresses on %s\n",
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)
2003 struct bcma_drv_pci_host *pc_host;
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));
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);
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);
2023 EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
2024 @@ -588,6 +618,6 @@ int bcma_core_pci_pcibios_map_irq(const
2026 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
2028 - return bcma_core_mips_irq(pc_host->pdev->core) + 2;
2029 + return bcma_core_irq(pc_host->pdev->core);
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
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)
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
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)
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);
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);
2071 +#ifdef CONFIG_PM_SLEEP
2072 static int bcma_host_pci_suspend(struct device *dev)
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)
2079 -#else /* CONFIG_PM */
2080 +#else /* CONFIG_PM_SLEEP */
2082 #define BCMA_PM_OPS NULL
2084 -#endif /* CONFIG_PM */
2085 +#endif /* CONFIG_PM_SLEEP */
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) },
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);
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
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>
2120 @@ -80,6 +81,37 @@ struct bcma_device *bcma_find_core(struc
2122 EXPORT_SYMBOL_GPL(bcma_find_core);
2124 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
2127 + struct bcma_device *core;
2129 + list_for_each_entry(core, &bus->cores, list) {
2130 + if (core->id.id == coreid && core->core_unit == unit)
2136 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
2139 + unsigned long deadline = jiffies + timeout;
2143 + val = bcma_read32(core, reg);
2144 + if ((val & mask) == value)
2148 + } while (!time_after_eq(jiffies, deadline));
2150 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
2155 static void bcma_release_core_dev(struct device *dev)
2157 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
2158 @@ -107,6 +139,11 @@ static int bcma_register_cores(struct bc
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)
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
2174 +#ifdef CONFIG_BCMA_DRIVER_MIPS
2175 + if (bus->drv_cc.pflash.present) {
2176 + err = platform_device_register(&bcma_pflash_dev);
2178 + bcma_err(bus, "Error registering parallel flash\n");
2182 +#ifdef CONFIG_BCMA_SFLASH
2183 + if (bus->drv_cc.sflash.present) {
2184 + err = platform_device_register(&bcma_sflash_dev);
2186 + bcma_err(bus, "Error registering serial flash\n");
2190 +#ifdef CONFIG_BCMA_NFLASH
2191 + if (bus->drv_cc.nflash.present) {
2192 + err = platform_device_register(&bcma_nflash_dev);
2194 + bcma_err(bus, "Error registering NAND flash\n");
2197 + err = bcma_gpio_init(&bus->drv_cc);
2198 + if (err == -ENOTSUPP)
2199 + bcma_debug(bus, "GPIO driver not activated\n");
2201 + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
2203 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
2204 + err = bcma_chipco_watchdog_register(&bus->drv_cc);
2206 + bcma_err(bus, "Error registering watchdog driver\n");
2212 @@ -148,6 +220,8 @@ static void bcma_unregister_cores(struct
2213 if (core->dev_registered)
2214 device_unregister(&core->dev);
2216 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
2217 + platform_device_unregister(bus->drv_cc.watchdog);
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);
2224 bcma_err(bus, "Failed to scan: %d\n", err);
2229 + /* Early init CC core */
2230 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
2232 + bus->drv_cc.core = core;
2233 + bcma_core_chipcommon_early_init(&bus->drv_cc);
2236 + /* Try to get SPROM */
2237 + err = bcma_sprom_get(bus);
2238 + if (err == -ENOENT) {
2239 + bcma_err(bus, "No SPROM available\n");
2241 + bcma_err(bus, "Failed to get SPROM: %d\n", err);
2244 core = bcma_find_core(bus, bcma_cc_core_id(bus));
2246 @@ -181,10 +269,17 @@ int __devinit bcma_bus_register(struct b
2249 /* Init PCIE core */
2250 - core = bcma_find_core(bus, BCMA_CORE_PCIE);
2251 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
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]);
2259 + /* Init PCIE core */
2260 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
2262 + bus->drv_pci[1].core = core;
2263 + bcma_core_pci_init(&bus->drv_pci[1]);
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);
2271 - /* Try to get SPROM */
2272 - err = bcma_sprom_get(bus);
2273 - if (err == -ENOENT) {
2274 - bcma_err(bus, "No SPROM available\n");
2276 - bcma_err(bus, "Failed to get SPROM: %d\n", err);
2278 /* Register found cores */
2279 bcma_register_cores(bus);
2281 @@ -211,7 +299,24 @@ int __devinit bcma_bus_register(struct b
2283 void bcma_bus_unregister(struct bcma_bus *bus)
2285 + struct bcma_device *cores[3];
2288 + err = bcma_gpio_unregister(&bus->drv_cc);
2289 + if (err == -EBUSY)
2290 + bcma_err(bus, "Some GPIOs are still in use.\n");
2292 + bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
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);
2298 bcma_unregister_cores(bus);
2305 int __init bcma_bus_early_register(struct bcma_bus *bus,
2306 @@ -248,18 +353,18 @@ int __init bcma_bus_early_register(struc
2310 - /* Init CC core */
2311 + /* Early init CC core */
2312 core = bcma_find_core(bus, bcma_cc_core_id(bus));
2314 bus->drv_cc.core = core;
2315 - bcma_core_chipcommon_init(&bus->drv_cc);
2316 + bcma_core_chipcommon_early_init(&bus->drv_cc);
2319 - /* Init MIPS core */
2320 + /* Early init MIPS core */
2321 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
2323 bus->drv_mips.core = core;
2324 - bcma_core_mips_init(&bus->drv_mips);
2325 + bcma_core_mips_early_init(&bus->drv_mips);
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" },
2359 @@ -137,19 +151,19 @@ static void bcma_scan_switch_core(struct
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)
2366 u32 ent = readl(*eromptr);
2371 -static void bcma_erom_push_ent(u32 **eromptr)
2372 +static void bcma_erom_push_ent(u32 __iomem **eromptr)
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)
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_
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)
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));
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)
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));
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)
2408 @@ -189,7 +203,7 @@ static void bcma_erom_skip_component(str
2409 bcma_erom_push_ent(eromptr);
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)
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
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,
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);
2431 + return (u32)-EINVAL;
2434 addrl = ent & SCAN_ADDR_ADDR;
2435 @@ -255,11 +269,13 @@ static struct bcma_device *bcma_find_cor
2439 +#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
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)
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
2453 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 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);
2460 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
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);
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);
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);
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:
2495 **************************************************/
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,
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));
2509 /**************************************************
2510 @@ -124,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da
2511 return t[crc ^ data];
2514 -static u8 bcma_sprom_crc(const u16 *sprom)
2515 +static u8 bcma_sprom_crc(const u16 *sprom, size_t words)
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);
2525 - crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
2526 + crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF);
2532 -static int bcma_sprom_check_crc(const u16 *sprom)
2533 +static int bcma_sprom_check_crc(const u16 *sprom, size_t words)
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)
2546 @@ -154,21 +154,25 @@ static int bcma_sprom_check_crc(const u1
2550 -static int bcma_sprom_valid(const u16 *sprom)
2551 +static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom,
2557 - err = bcma_sprom_check_crc(sprom);
2558 + err = bcma_sprom_check_crc(sprom, words);
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);
2570 + bus->sprom.revision = revision;
2571 + bcma_debug(bus, "Found SPROM revision %d\n", revision);
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));
2580 - bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
2581 - SSB_SPROM_REVISION_REV;
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);
2588 SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
2589 + SPEX(board_type, SSB_SPROM1_SPID, ~0, 0);
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;
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 */
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;
2610 @@ -547,7 +551,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
2612 u16 offset = BCMA_CC_SPROM;
2615 + size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
2616 + SSB_SPROMSIZE_WORDS_R10, };
2619 if (!bus->drv_cc.core)
2621 @@ -576,29 +582,37 @@ int bcma_sprom_get(struct bcma_bus *bus)
2625 - sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
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);
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];
2639 + sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
2643 + bcma_sprom_read(bus, offset, sprom, words);
2644 + err = bcma_sprom_valid(bus, sprom, words);
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);
2655 - err = bcma_sprom_valid(sprom);
2659 - bcma_sprom_extract_r8(bus, sprom);
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);
2664 + bcma_sprom_extract_r8(bus, sprom);
2672 --- a/include/linux/bcma/bcma.h
2673 +++ b/include/linux/bcma/bcma.h
2675 #include <linux/bcma/bcma_driver_gmac_cmn.h>
2676 #include <linux/ssb/ssb.h> /* SPROM sharing */
2678 -#include "bcma_regs.h"
2679 +#include <linux/bcma/bcma_regs.h>
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
2713 #define BCMA_MAX_NR_CORES 16
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 {
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
2744 +/* Board types (on PCI usually equals to the subsystem dev id) */
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
2751 +#define BCMA_BOARD_TYPE_BCM94716NR2 0X04CD
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
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
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
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
2796 +#define BCMA_BOARD_TYPE_BCM943142HM 0X05E0
2798 struct bcma_device {
2799 struct bcma_bus *bus;
2800 @@ -251,7 +332,7 @@ struct bcma_bus {
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;
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,
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
2820 #ifndef LINUX_BCMA_DRIVER_CC_H_
2821 #define LINUX_BCMA_DRIVER_CC_H_
2823 +#include <linux/platform_device.h>
2824 +#include <linux/gpio.h>
2826 /** ChipCommon core registers. **/
2827 #define BCMA_CC_ID 0x0000
2828 #define BCMA_CC_ID_ID 0x0000FFFF
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
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
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 */
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
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
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
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 */
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)
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)
3029 /* Data for the PMU, if available.
3030 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
3032 @@ -425,11 +572,36 @@ struct bcma_chipcommon_pmu {
3034 #ifdef CONFIG_BCMA_DRIVER_MIPS
3035 struct bcma_pflash {
3042 +#ifdef CONFIG_BCMA_SFLASH
3043 +struct bcma_sflash {
3050 + struct mtd_info *mtd;
3055 +#ifdef CONFIG_BCMA_NFLASH
3058 +struct bcma_nflash {
3060 + bool boot; /* This is the flash the SoC boots from */
3062 + struct mtd_info *mtd;
3066 struct bcma_serial_port {
3068 unsigned long clockspeed;
3069 @@ -445,15 +617,30 @@ struct bcma_drv_cc {
3071 u32 capabilities_ext;
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;
3082 +#ifdef CONFIG_BCMA_NFLASH
3083 + struct bcma_nflash nflash;
3086 int nr_serial_ports;
3087 struct bcma_serial_port serial_ports[4];
3088 #endif /* CONFIG_BCMA_DRIVER_MIPS */
3090 + struct platform_device *watchdog;
3092 + /* Lock for GPIO register access. */
3093 + spinlock_t gpio_lock;
3094 +#ifdef CONFIG_BCMA_DRIVER_GPIO
3095 + struct gpio_chip gpio;
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))
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);
3106 extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
3107 extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
3109 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
3111 -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
3113 +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
3115 +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
3117 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
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);
3127 extern void bcma_pmu_init(struct bcma_drv_cc *cc);
3128 +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
3130 extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
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);
3136 +extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
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
3142 #define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
3143 #define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
3145 +#define BCMA_MIPS_OOBSELINA74 0x004
3146 #define BCMA_MIPS_OOBSELOUTA30 0x100
3149 @@ -35,17 +36,24 @@ struct bcma_device;
3150 struct bcma_drv_mips {
3151 struct bcma_device *core;
3153 - unsigned int assigned_irqs;
3154 + u8 early_setup_done:1;
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);
3161 +extern unsigned int bcma_core_irq(struct bcma_device *core);
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) { }
3166 +static inline unsigned int bcma_core_irq(struct bcma_device *core)
3172 extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
3174 -extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
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 */
3183 +#define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8
3185 +#define BCMA_CORE_PCI_
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
3205 /* PCIE Root Capability Register bits (Host mode only) */
3206 #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
3208 struct bcma_drv_pci;
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);
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
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 */
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
3245 /* BCMA PCI config space registers. */
3246 #define BCMA_PCI_PMCSR 0x44
3248 * (2 ZettaBytes), high 32 bits
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 */
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
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);
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;
3274 -void ai_pci_up(struct si_pub *sih)
3276 - struct si_info *sii;
3278 - sii = container_of(sih, struct si_info, pub);
3280 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
3281 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, true);
3284 -/* Unconfigure and/or apply various WARs when going down */
3285 -void ai_pci_down(struct si_pub *sih)
3287 - struct si_info *sii;
3289 - sii = container_of(sih, struct si_info, pub);
3291 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
3292 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, false);
3295 /* Enable BT-COEX & Ex-PA for 4313 */
3296 void ai_epa_4313war(struct si_pub *sih)
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);
3303 /* Match driver "down" state */
3304 - ai_pci_down(wlc_hw->sih);
3305 + bcma_core_pci_down(wlc_hw->d11core->bus);
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.
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,
3318 @@ -5087,12 +5087,12 @@ static int brcms_b_up_prep(struct brcms_
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);
3328 - ai_pci_up(wlc_hw->sih);
3329 + bcma_core_pci_up(wlc_hw->d11core->bus);
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
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);
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);
3348 -extern void ai_pci_down(struct si_pub *sih);
3349 -extern void ai_pci_up(struct si_pub *sih);
3351 /* Enable Ex-PA for 4313 */
3352 extern void ai_epa_4313war(struct si_pub *sih);