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 @@ -229,6 +236,32 @@ void __devinit bcma_core_pci_init(struct
1688 bcma_core_pci_clientmode_init(pc);
1691 +void bcma_core_pci_power_save(struct bcma_bus *bus, bool up)
1693 + struct bcma_drv_pci *pc;
1696 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
1699 + pc = &bus->drv_pci[0];
1701 + if (pc->core->id.rev >= 15 && pc->core->id.rev <= 20) {
1702 + data = up ? 0x74 : 0x7C;
1703 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1704 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7F64);
1705 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1706 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
1707 + } else if (pc->core->id.rev >= 21 && pc->core->id.rev <= 22) {
1708 + data = up ? 0x75 : 0x7D;
1709 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1710 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7E65);
1711 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
1712 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
1715 +EXPORT_SYMBOL_GPL(bcma_core_pci_power_save);
1717 int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
1720 @@ -262,7 +295,7 @@ out:
1722 EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
1724 -void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
1725 +static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
1729 @@ -274,4 +307,29 @@ void bcma_core_pci_extend_L1timer(struct
1730 bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
1731 bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
1733 -EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
1735 +void bcma_core_pci_up(struct bcma_bus *bus)
1737 + struct bcma_drv_pci *pc;
1739 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
1742 + pc = &bus->drv_pci[0];
1744 + bcma_core_pci_extend_L1timer(pc, true);
1746 +EXPORT_SYMBOL_GPL(bcma_core_pci_up);
1748 +void bcma_core_pci_down(struct bcma_bus *bus)
1750 + struct bcma_drv_pci *pc;
1752 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
1755 + pc = &bus->drv_pci[0];
1757 + bcma_core_pci_extend_L1timer(pc, false);
1759 +EXPORT_SYMBOL_GPL(bcma_core_pci_down);
1760 --- a/drivers/bcma/driver_pci_host.c
1761 +++ b/drivers/bcma/driver_pci_host.c
1762 @@ -35,11 +35,6 @@ bool __devinit bcma_core_pci_is_in_hostm
1763 chipid_top != 0x5300)
1766 - if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1767 - bcma_info(bus, "This PCI core is disabled and not working\n");
1771 bcma_core_enable(pc->core, 0);
1773 return !mips_busprobe32(tmp, pc->core->io_addr);
1774 @@ -99,19 +94,19 @@ static int bcma_extpci_read_config(struc
1776 /* we support only two functions on device 0 */
1781 /* accesses to config registers with offsets >= 256
1782 * requires indirect access.
1784 if (off >= PCI_CONFIG_SPACE_SIZE) {
1785 addr = (func << 12);
1786 - addr |= (off & 0x0FFF);
1787 + addr |= (off & 0x0FFC);
1788 val = bcma_pcie_read_config(pc, addr);
1790 addr = BCMA_CORE_PCI_PCICFG0;
1791 addr |= (func << 8);
1792 - addr |= (off & 0xfc);
1793 + addr |= (off & 0xFC);
1794 val = pcicore_read32(pc, addr);
1797 @@ -124,11 +119,9 @@ static int bcma_extpci_read_config(struc
1800 if (mips_busprobe32(val, mmio)) {
1806 - val = readl(mmio);
1808 val >>= (8 * (off & 3));
1810 @@ -156,7 +149,7 @@ static int bcma_extpci_write_config(stru
1811 const void *buf, int len)
1814 - u32 addr = 0, val = 0;
1816 void __iomem *mmio = 0;
1817 u16 chipid = pc->core->bus->chipinfo.id;
1819 @@ -164,16 +157,22 @@ static int bcma_extpci_write_config(stru
1820 if (unlikely(len != 1 && len != 2 && len != 4))
1823 + /* we support only two functions on device 0 */
1827 /* accesses to config registers with offsets >= 256
1828 * requires indirect access.
1830 - if (off < PCI_CONFIG_SPACE_SIZE) {
1831 - addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
1832 + if (off >= PCI_CONFIG_SPACE_SIZE) {
1833 + addr = (func << 12);
1834 + addr |= (off & 0x0FFC);
1835 + val = bcma_pcie_read_config(pc, addr);
1837 + addr = BCMA_CORE_PCI_PCICFG0;
1838 addr |= (func << 8);
1839 - addr |= (off & 0xfc);
1840 - mmio = ioremap_nocache(addr, sizeof(val));
1843 + addr |= (off & 0xFC);
1844 + val = pcicore_read32(pc, addr);
1847 addr = bcma_get_cfgspace_addr(pc, dev, func, off);
1848 @@ -185,19 +184,17 @@ static int bcma_extpci_write_config(stru
1851 if (mips_busprobe32(val, mmio)) {
1860 - val = readl(mmio);
1861 val &= ~(0xFF << (8 * (off & 3)));
1862 val |= *((const u8 *)buf) << (8 * (off & 3));
1865 - val = readl(mmio);
1866 val &= ~(0xFFFF << (8 * (off & 3)));
1867 val |= *((const u16 *)buf) << (8 * (off & 3));
1869 @@ -205,13 +202,14 @@ static int bcma_extpci_write_config(stru
1870 val = *((const u32 *)buf);
1873 - if (dev == 0 && !addr) {
1875 /* accesses to config registers with offsets >= 256
1876 * requires indirect access.
1878 - addr = (func << 12);
1879 - addr |= (off & 0x0FFF);
1880 - bcma_pcie_write_config(pc, addr, val);
1881 + if (off >= PCI_CONFIG_SPACE_SIZE)
1882 + bcma_pcie_write_config(pc, addr, val);
1884 + pcicore_write32(pc, addr, val);
1888 @@ -282,7 +280,7 @@ static u8 __devinit bcma_find_pci_capabi
1889 /* check for Header type 0 */
1890 bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
1892 - if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
1893 + if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
1896 /* check if the capability pointer field exists */
1897 @@ -396,12 +394,19 @@ void __devinit bcma_core_pci_hostmode_in
1899 bcma_info(bus, "PCIEcore in host mode found\n");
1901 + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1902 + bcma_info(bus, "This PCIE core is disabled and not working\n");
1906 pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
1908 bcma_err(bus, "can not allocate memory");
1912 + spin_lock_init(&pc_host->cfgspace_lock);
1914 pc->host_controller = pc_host;
1915 pc_host->pci_controller.io_resource = &pc_host->io_resource;
1916 pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
1917 @@ -425,9 +430,9 @@ void __devinit bcma_core_pci_hostmode_in
1918 pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
1922 + usleep_range(3000, 5000);
1923 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
1926 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
1927 BCMA_CORE_PCI_CTL_RST_OE);
1929 @@ -452,6 +457,8 @@ void __devinit bcma_core_pci_hostmode_in
1930 pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
1931 pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
1932 BCMA_SOC_PCI_MEM_SZ - 1;
1933 + pc_host->io_resource.start = 0x100;
1934 + pc_host->io_resource.end = 0x47F;
1935 pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
1936 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1937 tmp | BCMA_SOC_PCI_MEM);
1938 @@ -459,6 +466,8 @@ void __devinit bcma_core_pci_hostmode_in
1939 pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
1940 pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
1941 BCMA_SOC_PCI_MEM_SZ - 1;
1942 + pc_host->io_resource.start = 0x480;
1943 + pc_host->io_resource.end = 0x7FF;
1944 pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
1945 pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
1946 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1947 @@ -481,10 +490,21 @@ void __devinit bcma_core_pci_hostmode_in
1948 * before issuing configuration requests to PCI Express
1954 bcma_core_pci_enable_crs(pc);
1956 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706 ||
1957 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4716) {
1959 + bcma_extpci_read_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
1960 + &val16, sizeof(val16));
1961 + val16 |= (2 << 5); /* Max payload size of 512 */
1962 + val16 |= (2 << 12); /* MRRS 512 */
1963 + bcma_extpci_write_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
1964 + &val16, sizeof(val16));
1967 /* Enable PCI bridge BAR0 memory & master access */
1968 tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
1969 bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
1970 @@ -501,7 +521,7 @@ void __devinit bcma_core_pci_hostmode_in
1971 set_io_port_base(pc_host->pci_controller.io_map_base);
1972 /* Give some time to the PCI controller to configure itself with the new
1973 * values. Not waiting at this point causes crashes of the machine. */
1975 + usleep_range(10000, 15000);
1976 register_pci_controller(&pc_host->pci_controller);
1979 @@ -534,7 +554,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_
1980 static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
1982 struct resource *res;
1986 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
1987 /* This is not a device on the PCI-core bridge. */
1988 @@ -547,8 +567,12 @@ static void bcma_core_pci_fixup_addresse
1990 for (pos = 0; pos < 6; pos++) {
1991 res = &dev->resource[pos];
1992 - if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM))
1993 - pci_assign_resource(dev, pos);
1994 + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) {
1995 + err = pci_assign_resource(dev, pos);
1997 + pr_err("PCI: Problem fixing up the addresses on %s\n",
2002 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
2003 @@ -558,6 +582,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI
2004 int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
2006 struct bcma_drv_pci_host *pc_host;
2009 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
2010 /* This is not a device on the PCI-core bridge. */
2011 @@ -569,9 +594,14 @@ int bcma_core_pci_plat_dev_init(struct p
2012 pr_info("PCI: Fixing up device %s\n", pci_name(dev));
2014 /* Fix up interrupt lines */
2015 - dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2;
2016 + dev->irq = bcma_core_irq(pc_host->pdev->core);
2017 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
2019 + readrq = pcie_get_readrq(dev);
2020 + if (readrq > 128) {
2021 + pr_info("change PCIe max read request size from %i to 128\n", readrq);
2022 + pcie_set_readrq(dev, 128);
2026 EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
2027 @@ -588,6 +618,6 @@ int bcma_core_pci_pcibios_map_irq(const
2029 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
2031 - return bcma_core_mips_irq(pc_host->pdev->core) + 2;
2032 + return bcma_core_irq(pc_host->pdev->core);
2034 EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
2035 --- a/drivers/bcma/host_pci.c
2036 +++ b/drivers/bcma/host_pci.c
2037 @@ -77,8 +77,8 @@ static void bcma_host_pci_write32(struct
2040 #ifdef CONFIG_BCMA_BLOCKIO
2041 -void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
2042 - size_t count, u16 offset, u8 reg_width)
2043 +static void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
2044 + size_t count, u16 offset, u8 reg_width)
2046 void __iomem *addr = core->bus->mmio + offset;
2047 if (core->bus->mapped_core != core)
2048 @@ -100,8 +100,9 @@ void bcma_host_pci_block_read(struct bcm
2052 -void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
2053 - size_t count, u16 offset, u8 reg_width)
2054 +static void bcma_host_pci_block_write(struct bcma_device *core,
2055 + const void *buffer, size_t count,
2056 + u16 offset, u8 reg_width)
2058 void __iomem *addr = core->bus->mmio + offset;
2059 if (core->bus->mapped_core != core)
2060 @@ -139,7 +140,7 @@ static void bcma_host_pci_awrite32(struc
2061 iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
2064 -const struct bcma_host_ops bcma_host_pci_ops = {
2065 +static const struct bcma_host_ops bcma_host_pci_ops = {
2066 .read8 = bcma_host_pci_read8,
2067 .read16 = bcma_host_pci_read16,
2068 .read32 = bcma_host_pci_read32,
2069 @@ -237,7 +238,7 @@ static void __devexit bcma_host_pci_remo
2070 pci_set_drvdata(dev, NULL);
2074 +#ifdef CONFIG_PM_SLEEP
2075 static int bcma_host_pci_suspend(struct device *dev)
2077 struct pci_dev *pdev = to_pci_dev(dev);
2078 @@ -260,11 +261,11 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
2079 bcma_host_pci_resume);
2080 #define BCMA_PM_OPS (&bcma_pm_ops)
2082 -#else /* CONFIG_PM */
2083 +#else /* CONFIG_PM_SLEEP */
2085 #define BCMA_PM_OPS NULL
2087 -#endif /* CONFIG_PM */
2088 +#endif /* CONFIG_PM_SLEEP */
2090 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
2091 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
2092 @@ -272,7 +273,9 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_
2093 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
2094 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
2095 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
2096 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
2097 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
2098 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
2099 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
2102 --- a/drivers/bcma/host_soc.c
2103 +++ b/drivers/bcma/host_soc.c
2104 @@ -143,7 +143,7 @@ static void bcma_host_soc_awrite32(struc
2105 writel(value, core->io_wrap + offset);
2108 -const struct bcma_host_ops bcma_host_soc_ops = {
2109 +static const struct bcma_host_ops bcma_host_soc_ops = {
2110 .read8 = bcma_host_soc_read8,
2111 .read16 = bcma_host_soc_read16,
2112 .read32 = bcma_host_soc_read32,
2113 --- a/drivers/bcma/main.c
2114 +++ b/drivers/bcma/main.c
2117 #include "bcma_private.h"
2118 #include <linux/module.h>
2119 +#include <linux/platform_device.h>
2120 #include <linux/bcma/bcma.h>
2121 #include <linux/slab.h>
2123 @@ -80,6 +81,37 @@ struct bcma_device *bcma_find_core(struc
2125 EXPORT_SYMBOL_GPL(bcma_find_core);
2127 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
2130 + struct bcma_device *core;
2132 + list_for_each_entry(core, &bus->cores, list) {
2133 + if (core->id.id == coreid && core->core_unit == unit)
2139 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
2142 + unsigned long deadline = jiffies + timeout;
2146 + val = bcma_read32(core, reg);
2147 + if ((val & mask) == value)
2151 + } while (!time_after_eq(jiffies, deadline));
2153 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
2158 static void bcma_release_core_dev(struct device *dev)
2160 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
2161 @@ -107,6 +139,11 @@ static int bcma_register_cores(struct bc
2165 + /* Only first GMAC core on BCM4706 is connected and working */
2166 + if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
2167 + core->core_unit > 0)
2170 core->dev.release = bcma_release_core_dev;
2171 core->dev.bus = &bcma_bus_type;
2172 dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
2173 @@ -136,6 +173,41 @@ static int bcma_register_cores(struct bc
2177 +#ifdef CONFIG_BCMA_DRIVER_MIPS
2178 + if (bus->drv_cc.pflash.present) {
2179 + err = platform_device_register(&bcma_pflash_dev);
2181 + bcma_err(bus, "Error registering parallel flash\n");
2185 +#ifdef CONFIG_BCMA_SFLASH
2186 + if (bus->drv_cc.sflash.present) {
2187 + err = platform_device_register(&bcma_sflash_dev);
2189 + bcma_err(bus, "Error registering serial flash\n");
2193 +#ifdef CONFIG_BCMA_NFLASH
2194 + if (bus->drv_cc.nflash.present) {
2195 + err = platform_device_register(&bcma_nflash_dev);
2197 + bcma_err(bus, "Error registering NAND flash\n");
2200 + err = bcma_gpio_init(&bus->drv_cc);
2201 + if (err == -ENOTSUPP)
2202 + bcma_debug(bus, "GPIO driver not activated\n");
2204 + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
2206 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
2207 + err = bcma_chipco_watchdog_register(&bus->drv_cc);
2209 + bcma_err(bus, "Error registering watchdog driver\n");
2215 @@ -148,6 +220,8 @@ static void bcma_unregister_cores(struct
2216 if (core->dev_registered)
2217 device_unregister(&core->dev);
2219 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
2220 + platform_device_unregister(bus->drv_cc.watchdog);
2223 int __devinit bcma_bus_register(struct bcma_bus *bus)
2224 @@ -163,9 +237,23 @@ int __devinit bcma_bus_register(struct b
2225 err = bcma_bus_scan(bus);
2227 bcma_err(bus, "Failed to scan: %d\n", err);
2232 + /* Early init CC core */
2233 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
2235 + bus->drv_cc.core = core;
2236 + bcma_core_chipcommon_early_init(&bus->drv_cc);
2239 + /* Try to get SPROM */
2240 + err = bcma_sprom_get(bus);
2241 + if (err == -ENOENT) {
2242 + bcma_err(bus, "No SPROM available\n");
2244 + bcma_err(bus, "Failed to get SPROM: %d\n", err);
2247 core = bcma_find_core(bus, bcma_cc_core_id(bus));
2249 @@ -181,10 +269,17 @@ int __devinit bcma_bus_register(struct b
2252 /* Init PCIE core */
2253 - core = bcma_find_core(bus, BCMA_CORE_PCIE);
2254 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
2256 - bus->drv_pci.core = core;
2257 - bcma_core_pci_init(&bus->drv_pci);
2258 + bus->drv_pci[0].core = core;
2259 + bcma_core_pci_init(&bus->drv_pci[0]);
2262 + /* Init PCIE core */
2263 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
2265 + bus->drv_pci[1].core = core;
2266 + bcma_core_pci_init(&bus->drv_pci[1]);
2269 /* Init GBIT MAC COMMON core */
2270 @@ -194,13 +289,6 @@ int __devinit bcma_bus_register(struct b
2271 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
2274 - /* Try to get SPROM */
2275 - err = bcma_sprom_get(bus);
2276 - if (err == -ENOENT) {
2277 - bcma_err(bus, "No SPROM available\n");
2279 - bcma_err(bus, "Failed to get SPROM: %d\n", err);
2281 /* Register found cores */
2282 bcma_register_cores(bus);
2284 @@ -211,7 +299,24 @@ int __devinit bcma_bus_register(struct b
2286 void bcma_bus_unregister(struct bcma_bus *bus)
2288 + struct bcma_device *cores[3];
2291 + err = bcma_gpio_unregister(&bus->drv_cc);
2292 + if (err == -EBUSY)
2293 + bcma_err(bus, "Some GPIOs are still in use.\n");
2295 + bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
2297 + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
2298 + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
2299 + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
2301 bcma_unregister_cores(bus);
2308 int __init bcma_bus_early_register(struct bcma_bus *bus,
2309 @@ -248,18 +353,18 @@ int __init bcma_bus_early_register(struc
2313 - /* Init CC core */
2314 + /* Early init CC core */
2315 core = bcma_find_core(bus, bcma_cc_core_id(bus));
2317 bus->drv_cc.core = core;
2318 - bcma_core_chipcommon_init(&bus->drv_cc);
2319 + bcma_core_chipcommon_early_init(&bus->drv_cc);
2322 - /* Init MIPS core */
2323 + /* Early init MIPS core */
2324 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
2326 bus->drv_mips.core = core;
2327 - bcma_core_mips_init(&bus->drv_mips);
2328 + bcma_core_mips_early_init(&bus->drv_mips);
2331 bcma_info(bus, "Early bus registered\n");
2332 --- a/drivers/bcma/scan.c
2333 +++ b/drivers/bcma/scan.c
2334 @@ -32,6 +32,18 @@ static const struct bcma_device_id_name
2335 { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
2336 { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
2337 { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
2338 + { BCMA_CORE_PCIEG2, "PCIe Gen 2" },
2339 + { BCMA_CORE_DMA, "DMA" },
2340 + { BCMA_CORE_SDIO3, "SDIO3" },
2341 + { BCMA_CORE_USB20, "USB 2.0" },
2342 + { BCMA_CORE_USB30, "USB 3.0" },
2343 + { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" },
2344 + { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" },
2345 + { BCMA_CORE_ROM, "ROM" },
2346 + { BCMA_CORE_NAND, "NAND flash controller" },
2347 + { BCMA_CORE_QSPI, "SPI flash controller" },
2348 + { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" },
2349 + { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" },
2350 { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
2351 { BCMA_CORE_ALTA, "ALTA (I2S)" },
2352 { BCMA_CORE_INVALID, "Invalid" },
2353 @@ -84,6 +96,8 @@ static const struct bcma_device_id_name
2354 { BCMA_CORE_I2S, "I2S" },
2355 { BCMA_CORE_SDR_DDR1_MEM_CTL, "SDR/DDR1 Memory Controller" },
2356 { BCMA_CORE_SHIM, "SHIM" },
2357 + { BCMA_CORE_PCIE2, "PCIe Gen2" },
2358 + { BCMA_CORE_ARM_CR4, "ARM CR4" },
2359 { BCMA_CORE_DEFAULT, "Default" },
2362 @@ -137,19 +151,19 @@ static void bcma_scan_switch_core(struct
2366 -static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 **eromptr)
2367 +static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 __iomem **eromptr)
2369 u32 ent = readl(*eromptr);
2374 -static void bcma_erom_push_ent(u32 **eromptr)
2375 +static void bcma_erom_push_ent(u32 __iomem **eromptr)
2380 -static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 **eromptr)
2381 +static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 __iomem **eromptr)
2383 u32 ent = bcma_erom_get_ent(bus, eromptr);
2384 if (!(ent & SCAN_ER_VALID))
2385 @@ -159,14 +173,14 @@ static s32 bcma_erom_get_ci(struct bcma_
2389 -static bool bcma_erom_is_end(struct bcma_bus *bus, u32 **eromptr)
2390 +static bool bcma_erom_is_end(struct bcma_bus *bus, u32 __iomem **eromptr)
2392 u32 ent = bcma_erom_get_ent(bus, eromptr);
2393 bcma_erom_push_ent(eromptr);
2394 return (ent == (SCAN_ER_TAG_END | SCAN_ER_VALID));
2397 -static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 **eromptr)
2398 +static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 __iomem **eromptr)
2400 u32 ent = bcma_erom_get_ent(bus, eromptr);
2401 bcma_erom_push_ent(eromptr);
2402 @@ -175,7 +189,7 @@ static bool bcma_erom_is_bridge(struct b
2403 ((ent & SCAN_ADDR_TYPE) == SCAN_ADDR_TYPE_BRIDGE));
2406 -static void bcma_erom_skip_component(struct bcma_bus *bus, u32 **eromptr)
2407 +static void bcma_erom_skip_component(struct bcma_bus *bus, u32 __iomem **eromptr)
2411 @@ -189,7 +203,7 @@ static void bcma_erom_skip_component(str
2412 bcma_erom_push_ent(eromptr);
2415 -static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr)
2416 +static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 __iomem **eromptr)
2418 u32 ent = bcma_erom_get_ent(bus, eromptr);
2419 if (!(ent & SCAN_ER_VALID))
2420 @@ -199,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct
2424 -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 **eromptr,
2425 +static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
2428 u32 addrl, addrh, sizel, sizeh = 0;
2429 @@ -211,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc
2430 ((ent & SCAN_ADDR_TYPE) != type) ||
2431 (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
2432 bcma_erom_push_ent(eromptr);
2434 + return (u32)-EINVAL;
2437 addrl = ent & SCAN_ADDR_ADDR;
2438 @@ -255,11 +269,13 @@ static struct bcma_device *bcma_find_cor
2442 +#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
2444 static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
2445 struct bcma_device_id *match, int core_num,
2446 struct bcma_device *core)
2452 u8 ports[2], wrappers[2];
2453 @@ -337,11 +353,11 @@ static int bcma_get_next_core(struct bcm
2454 * the main register space for the core
2456 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
2458 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
2459 /* Try again to see if it is a bridge */
2460 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2461 SCAN_ADDR_TYPE_BRIDGE, 0);
2463 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
2466 bcma_info(bus, "Bridge found\n");
2467 @@ -355,7 +371,7 @@ static int bcma_get_next_core(struct bcm
2468 for (j = 0; ; j++) {
2469 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2470 SCAN_ADDR_TYPE_SLAVE, i);
2472 + if (IS_ERR_VALUE_U32(tmp)) {
2473 /* no more entries for port _i_ */
2474 /* pr_debug("erom: slave port %d "
2475 * "has %d descriptors\n", i, j); */
2476 @@ -372,7 +388,7 @@ static int bcma_get_next_core(struct bcm
2477 for (j = 0; ; j++) {
2478 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2479 SCAN_ADDR_TYPE_MWRAP, i);
2481 + if (IS_ERR_VALUE_U32(tmp)) {
2482 /* no more entries for port _i_ */
2483 /* pr_debug("erom: master wrapper %d "
2484 * "has %d descriptors\n", i, j); */
2485 @@ -390,7 +406,7 @@ static int bcma_get_next_core(struct bcm
2486 for (j = 0; ; j++) {
2487 tmp = bcma_erom_get_addr_desc(bus, eromptr,
2488 SCAN_ADDR_TYPE_SWRAP, i + hack);
2490 + if (IS_ERR_VALUE_U32(tmp)) {
2491 /* no more entries for port _i_ */
2492 /* pr_debug("erom: master wrapper %d "
2493 * has %d descriptors\n", i, j); */
2494 --- a/drivers/bcma/sprom.c
2495 +++ b/drivers/bcma/sprom.c
2496 @@ -72,12 +72,12 @@ fail:
2498 **************************************************/
2500 -static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
2501 +static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom,
2505 - for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
2506 - sprom[i] = bcma_read16(bus->drv_cc.core,
2507 - offset + (i * 2));
2508 + for (i = 0; i < words; i++)
2509 + sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2));
2512 /**************************************************
2513 @@ -124,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da
2514 return t[crc ^ data];
2517 -static u8 bcma_sprom_crc(const u16 *sprom)
2518 +static u8 bcma_sprom_crc(const u16 *sprom, size_t words)
2523 - for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
2524 + for (word = 0; word < words - 1; word++) {
2525 crc = bcma_crc8(crc, sprom[word] & 0x00FF);
2526 crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
2528 - crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
2529 + crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF);
2535 -static int bcma_sprom_check_crc(const u16 *sprom)
2536 +static int bcma_sprom_check_crc(const u16 *sprom, size_t words)
2542 - crc = bcma_sprom_crc(sprom);
2543 - tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
2544 + crc = bcma_sprom_crc(sprom, words);
2545 + tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC;
2546 expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
2547 if (crc != expected_crc)
2549 @@ -154,21 +154,25 @@ static int bcma_sprom_check_crc(const u1
2553 -static int bcma_sprom_valid(const u16 *sprom)
2554 +static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom,
2560 - err = bcma_sprom_check_crc(sprom);
2561 + err = bcma_sprom_check_crc(sprom, words);
2565 - revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
2566 - if (revision != 8 && revision != 9) {
2567 + revision = sprom[words - 1] & SSB_SPROM_REVISION_REV;
2568 + if (revision != 8 && revision != 9 && revision != 10) {
2569 pr_err("Unsupported SPROM revision: %d\n", revision);
2573 + bus->sprom.revision = revision;
2574 + bcma_debug(bus, "Found SPROM revision %d\n", revision);
2579 @@ -208,15 +212,13 @@ static void bcma_sprom_extract_r8(struct
2580 BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
2581 ARRAY_SIZE(bus->sprom.core_pwr_info));
2583 - bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
2584 - SSB_SPROM_REVISION_REV;
2586 for (i = 0; i < 3; i++) {
2587 v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
2588 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
2591 SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
2592 + SPEX(board_type, SSB_SPROM1_SPID, ~0, 0);
2594 SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
2595 SSB_SPROM4_TXPID2G0_SHIFT);
2596 @@ -501,13 +503,15 @@ static bool bcma_sprom_onchip_available(
2597 case BCMA_CHIP_ID_BCM4331:
2598 present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
2601 + case BCMA_CHIP_ID_BCM43142:
2602 case BCMA_CHIP_ID_BCM43224:
2603 case BCMA_CHIP_ID_BCM43225:
2604 /* for these chips OTP is always available */
2607 + case BCMA_CHIP_ID_BCM43227:
2608 case BCMA_CHIP_ID_BCM43228:
2609 + case BCMA_CHIP_ID_BCM43428:
2610 present = chip_status & BCMA_CC_CHIPST_43228_OTP_PRESENT;
2613 @@ -547,7 +551,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
2615 u16 offset = BCMA_CC_SPROM;
2618 + size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
2619 + SSB_SPROMSIZE_WORDS_R10, };
2622 if (!bus->drv_cc.core)
2624 @@ -576,29 +582,37 @@ int bcma_sprom_get(struct bcma_bus *bus)
2628 - sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
2633 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
2634 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
2635 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
2637 bcma_debug(bus, "SPROM offset 0x%x\n", offset);
2638 - bcma_sprom_read(bus, offset, sprom);
2639 + for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
2640 + size_t words = sprom_sizes[i];
2642 + sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
2646 + bcma_sprom_read(bus, offset, sprom, words);
2647 + err = bcma_sprom_valid(bus, sprom, words);
2654 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
2655 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
2656 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
2658 - err = bcma_sprom_valid(sprom);
2662 - bcma_sprom_extract_r8(bus, sprom);
2664 + bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n");
2665 + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
2667 + bcma_sprom_extract_r8(bus, sprom);
2675 --- a/include/linux/bcma/bcma.h
2676 +++ b/include/linux/bcma/bcma.h
2678 #include <linux/bcma/bcma_driver_gmac_cmn.h>
2679 #include <linux/ssb/ssb.h> /* SPROM sharing */
2681 -#include "bcma_regs.h"
2682 +#include <linux/bcma/bcma_regs.h>
2686 @@ -72,7 +72,19 @@ struct bcma_host_ops {
2687 /* Core-ID values. */
2688 #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
2689 #define BCMA_CORE_4706_CHIPCOMMON 0x500
2690 +#define BCMA_CORE_PCIEG2 0x501
2691 +#define BCMA_CORE_DMA 0x502
2692 +#define BCMA_CORE_SDIO3 0x503
2693 +#define BCMA_CORE_USB20 0x504
2694 +#define BCMA_CORE_USB30 0x505
2695 +#define BCMA_CORE_A9JTAG 0x506
2696 +#define BCMA_CORE_DDR23 0x507
2697 +#define BCMA_CORE_ROM 0x508
2698 +#define BCMA_CORE_NAND 0x509
2699 +#define BCMA_CORE_QSPI 0x50A
2700 +#define BCMA_CORE_CHIPCOMMON_B 0x50B
2701 #define BCMA_CORE_4706_SOC_RAM 0x50E
2702 +#define BCMA_CORE_ARMCA9 0x510
2703 #define BCMA_CORE_4706_MAC_GBIT 0x52D
2704 #define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */
2705 #define BCMA_CORE_ALTA 0x534 /* I2S core */
2706 @@ -134,12 +146,17 @@ struct bcma_host_ops {
2707 #define BCMA_CORE_I2S 0x834
2708 #define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
2709 #define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
2710 +#define BCMA_CORE_PHY_AC 0x83B
2711 +#define BCMA_CORE_PCIE2 0x83C /* PCI Express Gen2 */
2712 +#define BCMA_CORE_USB30_DEV 0x83D
2713 +#define BCMA_CORE_ARM_CR4 0x83E
2714 #define BCMA_CORE_DEFAULT 0xFFF
2716 #define BCMA_MAX_NR_CORES 16
2718 /* Chip IDs of PCIe devices */
2719 #define BCMA_CHIP_ID_BCM4313 0x4313
2720 +#define BCMA_CHIP_ID_BCM43142 43142
2721 #define BCMA_CHIP_ID_BCM43224 43224
2722 #define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
2723 #define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
2724 @@ -157,6 +174,7 @@ struct bcma_host_ops {
2726 /* Chip IDs of SoCs */
2727 #define BCMA_CHIP_ID_BCM4706 0x5300
2728 +#define BCMA_PKG_ID_BCM4706L 1
2729 #define BCMA_CHIP_ID_BCM4716 0x4716
2730 #define BCMA_PKG_ID_BCM4716 8
2731 #define BCMA_PKG_ID_BCM4717 9
2732 @@ -166,7 +184,70 @@ struct bcma_host_ops {
2733 #define BCMA_CHIP_ID_BCM4749 0x4749
2734 #define BCMA_CHIP_ID_BCM5356 0x5356
2735 #define BCMA_CHIP_ID_BCM5357 0x5357
2736 +#define BCMA_PKG_ID_BCM5358 9
2737 +#define BCMA_PKG_ID_BCM47186 10
2738 +#define BCMA_PKG_ID_BCM5357 11
2739 #define BCMA_CHIP_ID_BCM53572 53572
2740 +#define BCMA_PKG_ID_BCM47188 9
2741 +#define BCMA_CHIP_ID_BCM4707 53010
2742 +#define BCMA_PKG_ID_BCM4707 1
2743 +#define BCMA_PKG_ID_BCM4708 2
2744 +#define BCMA_PKG_ID_BCM4709 0
2745 +#define BCMA_CHIP_ID_BCM53018 53018
2747 +/* Board types (on PCI usually equals to the subsystem dev id) */
2749 +#define BCMA_BOARD_TYPE_BCM94313BU 0X050F
2750 +#define BCMA_BOARD_TYPE_BCM94313HM 0X0510
2751 +#define BCMA_BOARD_TYPE_BCM94313EPA 0X0511
2752 +#define BCMA_BOARD_TYPE_BCM94313HMG 0X051C
2754 +#define BCMA_BOARD_TYPE_BCM94716NR2 0X04CD
2756 +#define BCMA_BOARD_TYPE_BCM943224X21 0X056E
2757 +#define BCMA_BOARD_TYPE_BCM943224X21_FCC 0X00D1
2758 +#define BCMA_BOARD_TYPE_BCM943224X21B 0X00E9
2759 +#define BCMA_BOARD_TYPE_BCM943224M93 0X008B
2760 +#define BCMA_BOARD_TYPE_BCM943224M93A 0X0090
2761 +#define BCMA_BOARD_TYPE_BCM943224X16 0X0093
2762 +#define BCMA_BOARD_TYPE_BCM94322X9 0X008D
2763 +#define BCMA_BOARD_TYPE_BCM94322M35E 0X008E
2765 +#define BCMA_BOARD_TYPE_BCM943228BU8 0X0540
2766 +#define BCMA_BOARD_TYPE_BCM943228BU9 0X0541
2767 +#define BCMA_BOARD_TYPE_BCM943228BU 0X0542
2768 +#define BCMA_BOARD_TYPE_BCM943227HM4L 0X0543
2769 +#define BCMA_BOARD_TYPE_BCM943227HMB 0X0544
2770 +#define BCMA_BOARD_TYPE_BCM943228HM4L 0X0545
2771 +#define BCMA_BOARD_TYPE_BCM943228SD 0X0573
2773 +#define BCMA_BOARD_TYPE_BCM94331X19 0X00D6
2774 +#define BCMA_BOARD_TYPE_BCM94331X28 0X00E4
2775 +#define BCMA_BOARD_TYPE_BCM94331X28B 0X010E
2776 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT3AX 0X00E4
2777 +#define BCMA_BOARD_TYPE_BCM94331X12_2G 0X00EC
2778 +#define BCMA_BOARD_TYPE_BCM94331X12_5G 0X00ED
2779 +#define BCMA_BOARD_TYPE_BCM94331X29B 0X00EF
2780 +#define BCMA_BOARD_TYPE_BCM94331CSAX 0X00EF
2781 +#define BCMA_BOARD_TYPE_BCM94331X19C 0X00F5
2782 +#define BCMA_BOARD_TYPE_BCM94331X33 0X00F4
2783 +#define BCMA_BOARD_TYPE_BCM94331BU 0X0523
2784 +#define BCMA_BOARD_TYPE_BCM94331S9BU 0X0524
2785 +#define BCMA_BOARD_TYPE_BCM94331MC 0X0525
2786 +#define BCMA_BOARD_TYPE_BCM94331MCI 0X0526
2787 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT4 0X0527
2788 +#define BCMA_BOARD_TYPE_BCM94331HM 0X0574
2789 +#define BCMA_BOARD_TYPE_BCM94331PCIEDUAL 0X059B
2790 +#define BCMA_BOARD_TYPE_BCM94331MCH5 0X05A9
2791 +#define BCMA_BOARD_TYPE_BCM94331CS 0X05C6
2792 +#define BCMA_BOARD_TYPE_BCM94331CD 0X05DA
2794 +#define BCMA_BOARD_TYPE_BCM953572BU 0X058D
2795 +#define BCMA_BOARD_TYPE_BCM953572NR2 0X058E
2796 +#define BCMA_BOARD_TYPE_BCM947188NR2 0X058F
2797 +#define BCMA_BOARD_TYPE_BCM953572SDRNR2 0X0590
2799 +#define BCMA_BOARD_TYPE_BCM943142HM 0X05E0
2801 struct bcma_device {
2802 struct bcma_bus *bus;
2803 @@ -251,7 +332,7 @@ struct bcma_bus {
2806 struct bcma_drv_cc drv_cc;
2807 - struct bcma_drv_pci drv_pci;
2808 + struct bcma_drv_pci drv_pci[2];
2809 struct bcma_drv_mips drv_mips;
2810 struct bcma_drv_gmac_cmn drv_gmac_cmn;
2812 @@ -345,6 +426,7 @@ extern void bcma_core_set_clockmode(stru
2813 enum bcma_clkmode clkmode);
2814 extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
2816 +extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
2817 #define BCMA_DMA_TRANSLATION_MASK 0xC0000000
2818 #define BCMA_DMA_TRANSLATION_NONE 0x00000000
2819 #define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
2820 --- a/include/linux/bcma/bcma_driver_chipcommon.h
2821 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
2823 #ifndef LINUX_BCMA_DRIVER_CC_H_
2824 #define LINUX_BCMA_DRIVER_CC_H_
2826 +#include <linux/platform_device.h>
2827 +#include <linux/gpio.h>
2829 /** ChipCommon core registers. **/
2830 #define BCMA_CC_ID 0x0000
2831 #define BCMA_CC_ID_ID 0x0000FFFF
2833 #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
2834 #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
2835 #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
2836 -#define BCMA_CC_FLASHT_NFLASH 0x00000200 /* NAND flash */
2837 +#define BCMA_CC_FLASHT_NAND 0x00000300 /* NAND flash */
2838 #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
2839 #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
2840 #define BCMA_PLLTYPE_NONE 0x00000000
2842 #define BCMA_CC_CHIPST_4706_SFLASH_TYPE BIT(2) /* 0: 8b-p/ST-s flash, 1: 16b-p/Atmal-s flash */
2843 #define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
2844 #define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
2845 +#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
2846 +#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
2847 #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
2848 #define BCMA_CC_JCMD_START 0x80000000
2849 #define BCMA_CC_JCMD_BUSY 0x80000000
2850 @@ -266,6 +271,29 @@
2851 #define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004
2852 #define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1
2853 #define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001
2854 +/* Block 0x140 - 0x190 registers are chipset specific */
2855 +#define BCMA_CC_4706_FLASHSCFG 0x18C /* Flash struct configuration */
2856 +#define BCMA_CC_4706_FLASHSCFG_MASK 0x000000ff
2857 +#define BCMA_CC_4706_FLASHSCFG_SF1 0x00000001 /* 2nd serial flash present */
2858 +#define BCMA_CC_4706_FLASHSCFG_PF1 0x00000002 /* 2nd parallel flash present */
2859 +#define BCMA_CC_4706_FLASHSCFG_SF1_TYPE 0x00000004 /* 2nd serial flash type : 0 : ST, 1 : Atmel */
2860 +#define BCMA_CC_4706_FLASHSCFG_NF1 0x00000008 /* 2nd NAND flash present */
2861 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_MASK 0x000000f0
2862 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_4MB 0x00000010 /* 4MB */
2863 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_8MB 0x00000020 /* 8MB */
2864 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_16MB 0x00000030 /* 16MB */
2865 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_32MB 0x00000040 /* 32MB */
2866 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_64MB 0x00000050 /* 64MB */
2867 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_128MB 0x00000060 /* 128MB */
2868 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_256MB 0x00000070 /* 256MB */
2869 +/* NAND flash registers for BCM4706 (corerev = 31) */
2870 +#define BCMA_CC_NFLASH_CTL 0x01A0
2871 +#define BCMA_CC_NFLASH_CTL_ERR 0x08000000
2872 +#define BCMA_CC_NFLASH_CONF 0x01A4
2873 +#define BCMA_CC_NFLASH_COL_ADDR 0x01A8
2874 +#define BCMA_CC_NFLASH_ROW_ADDR 0x01AC
2875 +#define BCMA_CC_NFLASH_DATA 0x01B0
2876 +#define BCMA_CC_NFLASH_WAITCNT0 0x01B4
2877 /* 0x1E0 is defined as shared BCMA_CLKCTLST */
2878 #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
2879 #define BCMA_CC_UART0_DATA 0x0300
2881 #define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
2882 #define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
2883 #define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
2884 +#define BCMA_CC_PMU_CTL_RES 0x00006000 /* reset control mask */
2885 +#define BCMA_CC_PMU_CTL_RES_SHIFT 13
2886 +#define BCMA_CC_PMU_CTL_RES_RELOAD 0x2 /* reload POR values */
2887 #define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
2888 #define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
2889 #define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
2891 #define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
2892 #define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
2893 #define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
2894 +#define BCMA_CC_PMU_STAT_EXT_LPO_AVAIL 0x00000100
2895 +#define BCMA_CC_PMU_STAT_WDRESET 0x00000080
2896 #define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
2897 #define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
2898 #define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
2899 @@ -324,7 +357,66 @@
2900 #define BCMA_CC_REGCTL_DATA 0x065C
2901 #define BCMA_CC_PLLCTL_ADDR 0x0660
2902 #define BCMA_CC_PLLCTL_DATA 0x0664
2903 +#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */
2904 +#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */
2905 +#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF
2906 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_MASK 0x80000000
2907 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT 31
2908 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
2909 +/* NAND flash MLC controller registers (corerev >= 38) */
2910 +#define BCMA_CC_NAND_REVISION 0x0C00
2911 +#define BCMA_CC_NAND_CMD_START 0x0C04
2912 +#define BCMA_CC_NAND_CMD_ADDR_X 0x0C08
2913 +#define BCMA_CC_NAND_CMD_ADDR 0x0C0C
2914 +#define BCMA_CC_NAND_CMD_END_ADDR 0x0C10
2915 +#define BCMA_CC_NAND_CS_NAND_SELECT 0x0C14
2916 +#define BCMA_CC_NAND_CS_NAND_XOR 0x0C18
2917 +#define BCMA_CC_NAND_SPARE_RD0 0x0C20
2918 +#define BCMA_CC_NAND_SPARE_RD4 0x0C24
2919 +#define BCMA_CC_NAND_SPARE_RD8 0x0C28
2920 +#define BCMA_CC_NAND_SPARE_RD12 0x0C2C
2921 +#define BCMA_CC_NAND_SPARE_WR0 0x0C30
2922 +#define BCMA_CC_NAND_SPARE_WR4 0x0C34
2923 +#define BCMA_CC_NAND_SPARE_WR8 0x0C38
2924 +#define BCMA_CC_NAND_SPARE_WR12 0x0C3C
2925 +#define BCMA_CC_NAND_ACC_CONTROL 0x0C40
2926 +#define BCMA_CC_NAND_CONFIG 0x0C48
2927 +#define BCMA_CC_NAND_TIMING_1 0x0C50
2928 +#define BCMA_CC_NAND_TIMING_2 0x0C54
2929 +#define BCMA_CC_NAND_SEMAPHORE 0x0C58
2930 +#define BCMA_CC_NAND_DEVID 0x0C60
2931 +#define BCMA_CC_NAND_DEVID_X 0x0C64
2932 +#define BCMA_CC_NAND_BLOCK_LOCK_STATUS 0x0C68
2933 +#define BCMA_CC_NAND_INTFC_STATUS 0x0C6C
2934 +#define BCMA_CC_NAND_ECC_CORR_ADDR_X 0x0C70
2935 +#define BCMA_CC_NAND_ECC_CORR_ADDR 0x0C74
2936 +#define BCMA_CC_NAND_ECC_UNC_ADDR_X 0x0C78
2937 +#define BCMA_CC_NAND_ECC_UNC_ADDR 0x0C7C
2938 +#define BCMA_CC_NAND_READ_ERROR_COUNT 0x0C80
2939 +#define BCMA_CC_NAND_CORR_STAT_THRESHOLD 0x0C84
2940 +#define BCMA_CC_NAND_READ_ADDR_X 0x0C90
2941 +#define BCMA_CC_NAND_READ_ADDR 0x0C94
2942 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR_X 0x0C98
2943 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR 0x0C9C
2944 +#define BCMA_CC_NAND_COPY_BACK_ADDR_X 0x0CA0
2945 +#define BCMA_CC_NAND_COPY_BACK_ADDR 0x0CA4
2946 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR_X 0x0CA8
2947 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR 0x0CAC
2948 +#define BCMA_CC_NAND_INV_READ_ADDR_X 0x0CB0
2949 +#define BCMA_CC_NAND_INV_READ_ADDR 0x0CB4
2950 +#define BCMA_CC_NAND_BLK_WR_PROTECT 0x0CC0
2951 +#define BCMA_CC_NAND_ACC_CONTROL_CS1 0x0CD0
2952 +#define BCMA_CC_NAND_CONFIG_CS1 0x0CD4
2953 +#define BCMA_CC_NAND_TIMING_1_CS1 0x0CD8
2954 +#define BCMA_CC_NAND_TIMING_2_CS1 0x0CDC
2955 +#define BCMA_CC_NAND_SPARE_RD16 0x0D30
2956 +#define BCMA_CC_NAND_SPARE_RD20 0x0D34
2957 +#define BCMA_CC_NAND_SPARE_RD24 0x0D38
2958 +#define BCMA_CC_NAND_SPARE_RD28 0x0D3C
2959 +#define BCMA_CC_NAND_CACHE_ADDR 0x0D40
2960 +#define BCMA_CC_NAND_CACHE_DATA 0x0D44
2961 +#define BCMA_CC_NAND_CTRL_CONFIG 0x0D48
2962 +#define BCMA_CC_NAND_CTRL_STATUS 0x0D4C
2964 /* Divider allocation in 4716/47162/5356 */
2965 #define BCMA_CC_PMU5_MAINPLL_CPU 1
2966 @@ -350,6 +442,23 @@
2967 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007
2968 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0
2971 +#define BCMA_CC_PMU15_PLL_PLLCTL0 0
2972 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_MASK 0x00000003
2973 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_SHIFT 0
2974 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK 0x003FFFFC
2975 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT 2
2976 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_MASK 0x00C00000
2977 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_SHIFT 22
2978 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_MASK 0x07000000
2979 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_SHIFT 24
2980 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_MASK 0x38000000
2981 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_SHIFT 27
2982 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_MASK 0x40000000
2983 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_SHIFT 30
2984 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_MASK 0x80000000
2985 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_SHIFT 31
2987 /* ALP clock on pre-PMU chips */
2988 #define BCMA_CC_PMU_ALP_CLOCK 20000000
2989 /* HT clock for systems with PMU-enabled chipcommon */
2990 @@ -415,6 +524,44 @@
2991 /* 4313 Chip specific ChipControl register bits */
2992 #define BCMA_CCTRL_4313_12MA_LED_DRIVE 0x00000007 /* 12 mA drive strengh for later 4313 */
2994 +/* BCM5357 ChipControl register bits */
2995 +#define BCMA_CHIPCTL_5357_EXTPA BIT(14)
2996 +#define BCMA_CHIPCTL_5357_ANT_MUX_2O3 BIT(15)
2997 +#define BCMA_CHIPCTL_5357_NFLASH BIT(16)
2998 +#define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
2999 +#define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
3001 +#define BCMA_RES_4314_LPLDO_PU BIT(0)
3002 +#define BCMA_RES_4314_PMU_SLEEP_DIS BIT(1)
3003 +#define BCMA_RES_4314_PMU_BG_PU BIT(2)
3004 +#define BCMA_RES_4314_CBUCK_LPOM_PU BIT(3)
3005 +#define BCMA_RES_4314_CBUCK_PFM_PU BIT(4)
3006 +#define BCMA_RES_4314_CLDO_PU BIT(5)
3007 +#define BCMA_RES_4314_LPLDO2_LVM BIT(6)
3008 +#define BCMA_RES_4314_WL_PMU_PU BIT(7)
3009 +#define BCMA_RES_4314_LNLDO_PU BIT(8)
3010 +#define BCMA_RES_4314_LDO3P3_PU BIT(9)
3011 +#define BCMA_RES_4314_OTP_PU BIT(10)
3012 +#define BCMA_RES_4314_XTAL_PU BIT(11)
3013 +#define BCMA_RES_4314_WL_PWRSW_PU BIT(12)
3014 +#define BCMA_RES_4314_LQ_AVAIL BIT(13)
3015 +#define BCMA_RES_4314_LOGIC_RET BIT(14)
3016 +#define BCMA_RES_4314_MEM_SLEEP BIT(15)
3017 +#define BCMA_RES_4314_MACPHY_RET BIT(16)
3018 +#define BCMA_RES_4314_WL_CORE_READY BIT(17)
3019 +#define BCMA_RES_4314_ILP_REQ BIT(18)
3020 +#define BCMA_RES_4314_ALP_AVAIL BIT(19)
3021 +#define BCMA_RES_4314_MISC_PWRSW_PU BIT(20)
3022 +#define BCMA_RES_4314_SYNTH_PWRSW_PU BIT(21)
3023 +#define BCMA_RES_4314_RX_PWRSW_PU BIT(22)
3024 +#define BCMA_RES_4314_RADIO_PU BIT(23)
3025 +#define BCMA_RES_4314_VCO_LDO_PU BIT(24)
3026 +#define BCMA_RES_4314_AFE_LDO_PU BIT(25)
3027 +#define BCMA_RES_4314_RX_LDO_PU BIT(26)
3028 +#define BCMA_RES_4314_TX_LDO_PU BIT(27)
3029 +#define BCMA_RES_4314_HT_AVAIL BIT(28)
3030 +#define BCMA_RES_4314_MACPHY_CLK_AVAIL BIT(29)
3032 /* Data for the PMU, if available.
3033 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
3035 @@ -425,11 +572,36 @@ struct bcma_chipcommon_pmu {
3037 #ifdef CONFIG_BCMA_DRIVER_MIPS
3038 struct bcma_pflash {
3045 +#ifdef CONFIG_BCMA_SFLASH
3046 +struct bcma_sflash {
3053 + struct mtd_info *mtd;
3058 +#ifdef CONFIG_BCMA_NFLASH
3061 +struct bcma_nflash {
3063 + bool boot; /* This is the flash the SoC boots from */
3065 + struct mtd_info *mtd;
3069 struct bcma_serial_port {
3071 unsigned long clockspeed;
3072 @@ -445,15 +617,30 @@ struct bcma_drv_cc {
3074 u32 capabilities_ext;
3076 + u8 early_setup_done:1;
3077 /* Fast Powerup Delay constant */
3078 u16 fast_pwrup_delay;
3079 struct bcma_chipcommon_pmu pmu;
3080 #ifdef CONFIG_BCMA_DRIVER_MIPS
3081 struct bcma_pflash pflash;
3082 +#ifdef CONFIG_BCMA_SFLASH
3083 + struct bcma_sflash sflash;
3085 +#ifdef CONFIG_BCMA_NFLASH
3086 + struct bcma_nflash nflash;
3089 int nr_serial_ports;
3090 struct bcma_serial_port serial_ports[4];
3091 #endif /* CONFIG_BCMA_DRIVER_MIPS */
3093 + struct platform_device *watchdog;
3095 + /* Lock for GPIO register access. */
3096 + spinlock_t gpio_lock;
3097 +#ifdef CONFIG_BCMA_DRIVER_GPIO
3098 + struct gpio_chip gpio;
3102 /* Register access */
3103 @@ -470,14 +657,16 @@ struct bcma_drv_cc {
3104 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
3106 extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
3107 +extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
3109 extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
3110 extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
3112 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
3114 -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
3116 +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
3118 +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
3120 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
3122 @@ -490,9 +679,12 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
3123 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
3124 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
3125 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
3126 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
3127 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
3130 extern void bcma_pmu_init(struct bcma_drv_cc *cc);
3131 +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
3133 extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
3135 @@ -504,4 +696,6 @@ extern void bcma_chipco_regctl_maskset(s
3136 u32 offset, u32 mask, u32 set);
3137 extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
3139 +extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
3141 #endif /* LINUX_BCMA_DRIVER_CC_H_ */
3142 --- a/include/linux/bcma/bcma_driver_mips.h
3143 +++ b/include/linux/bcma/bcma_driver_mips.h
3145 #define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
3146 #define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
3148 +#define BCMA_MIPS_OOBSELINA74 0x004
3149 #define BCMA_MIPS_OOBSELOUTA30 0x100
3152 @@ -35,17 +36,24 @@ struct bcma_device;
3153 struct bcma_drv_mips {
3154 struct bcma_device *core;
3156 - unsigned int assigned_irqs;
3157 + u8 early_setup_done:1;
3160 #ifdef CONFIG_BCMA_DRIVER_MIPS
3161 extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
3162 +extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
3164 +extern unsigned int bcma_core_irq(struct bcma_device *core);
3166 static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
3167 +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
3169 +static inline unsigned int bcma_core_irq(struct bcma_device *core)
3175 extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
3177 -extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
3179 #endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
3180 --- a/include/linux/bcma/bcma_driver_pci.h
3181 +++ b/include/linux/bcma/bcma_driver_pci.h
3182 @@ -179,10 +179,33 @@ struct pci_dev;
3183 #define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */
3184 #define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */
3186 +#define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8
3188 +#define BCMA_CORE_PCI_
3190 +/* MDIO devices (SERDES modules) */
3191 +#define BCMA_CORE_PCI_MDIO_IEEE0 0x000
3192 +#define BCMA_CORE_PCI_MDIO_IEEE1 0x001
3193 +#define BCMA_CORE_PCI_MDIO_BLK0 0x800
3194 +#define BCMA_CORE_PCI_MDIO_BLK1 0x801
3195 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT0 0x16
3196 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT1 0x17
3197 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT2 0x18
3198 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT3 0x19
3199 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT4 0x1A
3200 +#define BCMA_CORE_PCI_MDIO_BLK2 0x802
3201 +#define BCMA_CORE_PCI_MDIO_BLK3 0x803
3202 +#define BCMA_CORE_PCI_MDIO_BLK4 0x804
3203 +#define BCMA_CORE_PCI_MDIO_TXPLL 0x808 /* TXPLL register block idx */
3204 +#define BCMA_CORE_PCI_MDIO_TXCTRL0 0x820
3205 +#define BCMA_CORE_PCI_MDIO_SERDESID 0x831
3206 +#define BCMA_CORE_PCI_MDIO_RXCTRL0 0x840
3208 /* PCIE Root Capability Register bits (Host mode only) */
3209 #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
3211 struct bcma_drv_pci;
3214 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
3215 struct bcma_drv_pci_host {
3216 @@ -217,7 +240,9 @@ struct bcma_drv_pci {
3217 extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
3218 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
3219 struct bcma_device *core, bool enable);
3220 -extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend);
3221 +extern void bcma_core_pci_up(struct bcma_bus *bus);
3222 +extern void bcma_core_pci_down(struct bcma_bus *bus);
3223 +extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up);
3225 extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
3226 extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
3227 --- a/include/linux/bcma/bcma_regs.h
3228 +++ b/include/linux/bcma/bcma_regs.h
3230 #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
3231 #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
3232 #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
3233 +#define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
3234 #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
3235 #define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
3236 #define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
3237 #define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
3238 #define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
3239 +#define BCMA_CLKCTLST_EXTRESST_SHIFT 24
3240 /* Is there any BCM4328 on BCMA bus? */
3241 #define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
3242 #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
3244 #define BCMA_IOST_BIST_DONE 0x8000
3245 #define BCMA_RESET_CTL 0x0800
3246 #define BCMA_RESET_CTL_RESET 0x0001
3247 +#define BCMA_RESET_ST 0x0804
3249 /* BCMA PCI config space registers. */
3250 #define BCMA_PCI_PMCSR 0x44
3252 * (2 ZettaBytes), high 32 bits
3255 +#define BCMA_SOC_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */
3256 +#define BCMA_SOC_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */
3257 +#define BCMA_SOC_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
3258 +#define BCMA_SOC_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
3260 #endif /* LINUX_BCMA_REGS_H_ */
3261 --- a/drivers/net/wireless/b43/main.c
3262 +++ b/drivers/net/wireless/b43/main.c
3263 @@ -4622,7 +4622,7 @@ static int b43_wireless_core_init(struct
3264 switch (dev->dev->bus_type) {
3265 #ifdef CONFIG_B43_BCMA
3267 - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
3268 + bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
3269 dev->dev->bdev, true);
3272 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
3273 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
3274 @@ -688,27 +688,6 @@ bool ai_clkctl_cc(struct si_pub *sih, en
3275 return mode == BCMA_CLKMODE_FAST;
3278 -void ai_pci_up(struct si_pub *sih)
3280 - struct si_info *sii;
3282 - sii = container_of(sih, struct si_info, pub);
3284 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
3285 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, true);
3288 -/* Unconfigure and/or apply various WARs when going down */
3289 -void ai_pci_down(struct si_pub *sih)
3291 - struct si_info *sii;
3293 - sii = container_of(sih, struct si_info, pub);
3295 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
3296 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, false);
3299 /* Enable BT-COEX & Ex-PA for 4313 */
3300 void ai_epa_4313war(struct si_pub *sih)
3302 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
3303 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
3304 @@ -4689,7 +4689,7 @@ static int brcms_b_attach(struct brcms_c
3305 brcms_c_coredisable(wlc_hw);
3307 /* Match driver "down" state */
3308 - ai_pci_down(wlc_hw->sih);
3309 + bcma_core_pci_down(wlc_hw->d11core->bus);
3311 /* turn off pll and xtal to match driver "down" state */
3312 brcms_b_xtal(wlc_hw, OFF);
3313 @@ -5077,7 +5077,7 @@ static int brcms_b_up_prep(struct brcms_
3314 * Configure pci/pcmcia here instead of in brcms_c_attach()
3315 * to allow mfg hotswap: down, hotswap (chip power cycle), up.
3317 - bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci, wlc_hw->d11core,
3318 + bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,
3322 @@ -5087,12 +5087,12 @@ static int brcms_b_up_prep(struct brcms_
3324 if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
3325 /* put SB PCI in down state again */
3326 - ai_pci_down(wlc_hw->sih);
3327 + bcma_core_pci_down(wlc_hw->d11core->bus);
3328 brcms_b_xtal(wlc_hw, OFF);
3332 - ai_pci_up(wlc_hw->sih);
3333 + bcma_core_pci_up(wlc_hw->d11core->bus);
3335 /* reset the d11 core */
3336 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
3337 @@ -5295,7 +5295,7 @@ static int brcms_b_down_finish(struct br
3339 /* turn off primary xtal and pll */
3340 if (!wlc_hw->noreset) {
3341 - ai_pci_down(wlc_hw->sih);
3342 + bcma_core_pci_down(wlc_hw->d11core->bus);
3343 brcms_b_xtal(wlc_hw, OFF);
3346 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
3347 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
3348 @@ -183,9 +183,6 @@ extern u16 ai_clkctl_fast_pwrup_delay(st
3349 extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode);
3350 extern bool ai_deviceremoved(struct si_pub *sih);
3352 -extern void ai_pci_down(struct si_pub *sih);
3353 -extern void ai_pci_up(struct si_pub *sih);
3355 /* Enable Ex-PA for 4313 */
3356 extern void ai_epa_4313war(struct si_pub *sih);