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,16 +26,23 @@ 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 - depends on BCMA && MIPS
23 + depends on BCMA && MIPS && BCMA_HOST_PCI
25 PCI core hostmode operation (external PCI bus).
29 - depends on BCMA_DRIVER_MIPS
30 + bool "Support for BCMA in a SoC"
33 + Host interface for a Broadcom AIX bus directly mapped into
34 + the memory. This only works with the Broadcom SoCs from the
39 config BCMA_DRIVER_MIPS
40 bool "BCMA Broadcom MIPS core driver"
41 @@ -46,6 +53,33 @@ config BCMA_DRIVER_MIPS
47 + depends on BCMA_DRIVER_MIPS
52 + depends on BCMA_DRIVER_MIPS
55 +config BCMA_DRIVER_GMAC_CMN
56 + bool "BCMA Broadcom GBIT MAC COMMON core driver"
59 + Driver for the Broadcom GBIT MAC COMMON core attached to Broadcom
60 + specific Advanced Microcontroller Bus.
64 +config BCMA_DRIVER_GPIO
65 + bool "BCMA GPIO driver"
66 + depends on BCMA && GPIOLIB
68 + Driver to provide access to the GPIO pins of the bcma bus.
75 --- a/drivers/bcma/Makefile
76 +++ b/drivers/bcma/Makefile
78 bcma-y += main.o scan.o core.o sprom.o
79 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
80 +bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o
81 +bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o
82 bcma-y += driver_pci.o
83 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
84 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
85 +bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
86 +bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
87 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
88 bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
89 obj-$(CONFIG_BCMA) += bcma.o
90 --- a/drivers/bcma/bcma_private.h
91 +++ b/drivers/bcma/bcma_private.h
94 #define BCMA_CORE_SIZE 0x1000
96 +#define bcma_err(bus, fmt, ...) \
97 + pr_err("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
98 +#define bcma_warn(bus, fmt, ...) \
99 + pr_warn("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
100 +#define bcma_info(bus, fmt, ...) \
101 + pr_info("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
102 +#define bcma_debug(bus, fmt, ...) \
103 + pr_debug("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
108 -int bcma_bus_register(struct bcma_bus *bus);
109 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
111 +int __devinit bcma_bus_register(struct bcma_bus *bus);
112 void bcma_bus_unregister(struct bcma_bus *bus);
113 int __init bcma_bus_early_register(struct bcma_bus *bus,
114 struct bcma_device *core_cc,
115 @@ -22,6 +33,8 @@ int __init bcma_bus_early_register(struc
116 int bcma_bus_suspend(struct bcma_bus *bus);
117 int bcma_bus_resume(struct bcma_bus *bus);
119 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
123 int bcma_bus_scan(struct bcma_bus *bus);
124 @@ -36,11 +49,36 @@ int bcma_sprom_get(struct bcma_bus *bus)
125 /* driver_chipcommon.c */
126 #ifdef CONFIG_BCMA_DRIVER_MIPS
127 void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
128 +extern struct platform_device bcma_pflash_dev;
129 #endif /* CONFIG_BCMA_DRIVER_MIPS */
131 /* driver_chipcommon_pmu.c */
132 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
133 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
134 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
135 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
137 +#ifdef CONFIG_BCMA_SFLASH
138 +/* driver_chipcommon_sflash.c */
139 +int bcma_sflash_init(struct bcma_drv_cc *cc);
140 +extern struct platform_device bcma_sflash_dev;
142 +static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
144 + bcma_err(cc->core->bus, "Serial flash not supported\n");
147 +#endif /* CONFIG_BCMA_SFLASH */
149 +#ifdef CONFIG_BCMA_NFLASH
150 +/* driver_chipcommon_nflash.c */
151 +int bcma_nflash_init(struct bcma_drv_cc *cc);
152 +extern struct platform_device bcma_nflash_dev;
154 +static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
156 + bcma_err(cc->core->bus, "NAND flash not supported\n");
159 +#endif /* CONFIG_BCMA_NFLASH */
161 #ifdef CONFIG_BCMA_HOST_PCI
163 @@ -48,8 +86,29 @@ extern int __init bcma_host_pci_init(voi
164 extern void __exit bcma_host_pci_exit(void);
165 #endif /* CONFIG_BCMA_HOST_PCI */
168 +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
170 +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
172 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
173 -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
174 +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
175 +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
176 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
178 +#ifdef CONFIG_BCMA_DRIVER_GPIO
180 +int bcma_gpio_init(struct bcma_drv_cc *cc);
181 +int bcma_gpio_unregister(struct bcma_drv_cc *cc);
183 +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
187 +static inline int bcma_gpio_unregister(struct bcma_drv_cc *cc)
191 +#endif /* CONFIG_BCMA_DRIVER_GPIO */
194 --- a/drivers/bcma/core.c
195 +++ b/drivers/bcma/core.c
197 #include <linux/export.h>
198 #include <linux/bcma/bcma.h>
200 +static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask,
201 + u32 value, int timeout)
203 + unsigned long deadline = jiffies + timeout;
207 + val = bcma_aread32(core, reg);
208 + if ((val & mask) == value)
212 + } while (!time_after_eq(jiffies, deadline));
214 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
219 bool bcma_core_is_enabled(struct bcma_device *core)
221 if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC))
222 @@ -25,12 +44,15 @@ void bcma_core_disable(struct bcma_devic
223 if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
226 - bcma_awrite32(core, BCMA_IOCTL, flags);
227 - bcma_aread32(core, BCMA_IOCTL);
229 + bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300);
231 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
232 + bcma_aread32(core, BCMA_RESET_CTL);
235 + bcma_awrite32(core, BCMA_IOCTL, flags);
236 + bcma_aread32(core, BCMA_IOCTL);
239 EXPORT_SYMBOL_GPL(bcma_core_disable);
241 @@ -42,6 +64,7 @@ int bcma_core_enable(struct bcma_device
242 bcma_aread32(core, BCMA_IOCTL);
244 bcma_awrite32(core, BCMA_RESET_CTL, 0);
245 + bcma_aread32(core, BCMA_RESET_CTL);
248 bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
249 @@ -64,7 +87,7 @@ void bcma_core_set_clockmode(struct bcma
251 case BCMA_CLKMODE_FAST:
252 bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
254 + usleep_range(64, 300);
255 for (i = 0; i < 1500; i++) {
256 if (bcma_read32(core, BCMA_CLKCTLST) &
257 BCMA_CLKCTLST_HAVEHT) {
258 @@ -74,10 +97,10 @@ void bcma_core_set_clockmode(struct bcma
262 - pr_err("HT force timeout\n");
263 + bcma_err(core->bus, "HT force timeout\n");
265 case BCMA_CLKMODE_DYNAMIC:
266 - pr_warn("Dynamic clockmode not supported yet!\n");
267 + bcma_set32(core, BCMA_CLKCTLST, ~BCMA_CLKCTLST_FORCEHT);
271 @@ -101,9 +124,15 @@ void bcma_core_pll_ctl(struct bcma_devic
275 - pr_err("PLL enable timeout\n");
276 + bcma_err(core->bus, "PLL enable timeout\n");
278 - pr_warn("Disabling PLL not supported yet!\n");
280 + * Mask the PLL but don't wait for it to be disabled. PLL may be
281 + * shared between cores and will be still up if there is another
284 + bcma_mask32(core, BCMA_CLKCTLST, ~req);
285 + bcma_read32(core, BCMA_CLKCTLST);
288 EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
289 @@ -119,8 +148,8 @@ u32 bcma_core_dma_translation(struct bcm
291 return BCMA_DMA_TRANSLATION_DMA32_CMT;
293 - pr_err("DMA translation unknown for host %d\n",
294 - core->bus->hosttype);
295 + bcma_err(core->bus, "DMA translation unknown for host %d\n",
296 + core->bus->hosttype);
298 return BCMA_DMA_TRANSLATION_NONE;
300 --- a/drivers/bcma/driver_chipcommon.c
301 +++ b/drivers/bcma/driver_chipcommon.c
304 * Copyright 2005, Broadcom Corporation
305 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
306 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
308 * Licensed under the GNU/GPL. See COPYING for details.
311 #include "bcma_private.h"
312 +#include <linux/bcm47xx_wdt.h>
313 #include <linux/export.h>
314 +#include <linux/platform_device.h>
315 #include <linux/bcma/bcma.h>
317 static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
318 @@ -22,29 +25,136 @@ static inline u32 bcma_cc_write32_masked
322 -void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
323 +u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
326 - u32 leddc_off = 90;
327 + if (cc->capabilities & BCMA_CC_CAP_PMU)
328 + return bcma_pmu_get_alp_clock(cc);
330 - if (cc->setup_done)
333 +EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
335 +static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
337 + struct bcma_bus *bus = cc->core->bus;
340 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
341 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
343 + else if (cc->core->id.rev < 26)
346 + nb = (cc->core->id.rev >= 37) ? 32 : 24;
353 + return (1 << nb) - 1;
356 +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
359 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
361 + return bcma_chipco_watchdog_timer_set(cc, ticks);
364 +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
367 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
370 + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
371 + return ticks / cc->ticks_per_ms;
374 +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
376 + struct bcma_bus *bus = cc->core->bus;
378 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
379 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
380 + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
381 + return bcma_chipco_get_alp_clock(cc) / 4000;
383 + /* based on 32KHz ILP clock */
386 + return bcma_chipco_get_alp_clock(cc) / 1000;
390 +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
392 + struct bcm47xx_wdt wdt = {};
393 + struct platform_device *pdev;
395 + wdt.driver_data = cc;
396 + wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
397 + wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
398 + wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
400 + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
401 + cc->core->bus->num, &wdt,
404 + return PTR_ERR(pdev);
406 + cc->watchdog = pdev;
411 +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
413 + if (cc->early_setup_done)
416 + spin_lock_init(&cc->gpio_lock);
418 if (cc->core->id.rev >= 11)
419 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
420 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
421 if (cc->core->id.rev >= 35)
422 cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);
424 + if (cc->capabilities & BCMA_CC_CAP_PMU)
425 + bcma_pmu_early_init(cc);
427 + cc->early_setup_done = true;
430 +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
433 + u32 leddc_off = 90;
435 + if (cc->setup_done)
438 + bcma_core_chipcommon_early_init(cc);
440 if (cc->core->id.rev >= 20) {
441 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
442 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
443 + u32 pullup = 0, pulldown = 0;
445 + if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) {
447 + pulldown = 0x20500;
450 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup);
451 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown);
454 if (cc->capabilities & BCMA_CC_CAP_PMU)
456 if (cc->capabilities & BCMA_CC_CAP_PCTL)
457 - pr_err("Power control not implemented!\n");
458 + bcma_err(cc->core->bus, "Power control not implemented!\n");
460 if (cc->core->id.rev >= 16) {
461 if (cc->core->bus->sprom.leddc_on_time &&
462 @@ -56,15 +166,33 @@ void bcma_core_chipcommon_init(struct bc
463 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
464 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
466 + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
468 cc->setup_done = true;
471 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
472 -void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
473 +u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
476 - bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
478 + enum bcma_clkmode clkmode;
480 + maxt = bcma_chipco_watchdog_get_max_timer(cc);
481 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
484 + else if (ticks > maxt)
486 + bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
488 + clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
489 + bcma_core_set_clockmode(cc->core, clkmode);
493 + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
498 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
499 @@ -84,28 +212,99 @@ u32 bcma_chipco_gpio_in(struct bcma_drv_
501 u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
503 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
504 + unsigned long flags;
507 + spin_lock_irqsave(&cc->gpio_lock, flags);
508 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
509 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
513 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
515 u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
517 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
518 + unsigned long flags;
521 + spin_lock_irqsave(&cc->gpio_lock, flags);
522 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
523 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
527 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
530 + * If the bit is set to 0, chipcommon controlls this GPIO,
531 + * if the bit is set to 1, it is used by some part of the chip and not our code.
533 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
535 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
536 + unsigned long flags;
539 + spin_lock_irqsave(&cc->gpio_lock, flags);
540 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
541 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
545 EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
547 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
549 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
550 + unsigned long flags;
553 + spin_lock_irqsave(&cc->gpio_lock, flags);
554 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
555 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
560 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
562 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
563 + unsigned long flags;
566 + spin_lock_irqsave(&cc->gpio_lock, flags);
567 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
568 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
573 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value)
575 + unsigned long flags;
578 + if (cc->core->id.rev < 20)
581 + spin_lock_irqsave(&cc->gpio_lock, flags);
582 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value);
583 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
588 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value)
590 + unsigned long flags;
593 + if (cc->core->id.rev < 20)
596 + spin_lock_irqsave(&cc->gpio_lock, flags);
597 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value);
598 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
603 #ifdef CONFIG_BCMA_DRIVER_MIPS
604 @@ -118,8 +317,7 @@ void bcma_chipco_serial_init(struct bcma
605 struct bcma_serial_port *ports = cc->serial_ports;
607 if (ccrev >= 11 && ccrev != 15) {
608 - /* Fixed ALP clock */
609 - baud_base = bcma_pmu_alp_clock(cc);
610 + baud_base = bcma_chipco_get_alp_clock(cc);
612 /* Turn off UART clock before switching clocksource. */
613 bcma_cc_write32(cc, BCMA_CC_CORECTL,
614 @@ -137,12 +335,11 @@ void bcma_chipco_serial_init(struct bcma
615 | BCMA_CC_CORECTL_UARTCLKEN);
618 - pr_err("serial not supported on this device ccrev: 0x%x\n",
620 + bcma_err(cc->core->bus, "serial not supported on this device ccrev: 0x%x\n", ccrev);
624 - irq = bcma_core_mips_irq(cc->core);
625 + irq = bcma_core_irq(cc->core);
627 /* Determine the registers of the UARTs */
628 cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART);
630 +++ b/drivers/bcma/driver_chipcommon_nflash.c
633 + * Broadcom specific AMBA
634 + * ChipCommon NAND flash interface
636 + * Licensed under the GNU/GPL. See COPYING for details.
639 +#include "bcma_private.h"
641 +#include <linux/platform_device.h>
642 +#include <linux/bcma/bcma.h>
644 +struct platform_device bcma_nflash_dev = {
645 + .name = "bcma_nflash",
646 + .num_resources = 0,
649 +/* Initialize NAND flash access */
650 +int bcma_nflash_init(struct bcma_drv_cc *cc)
652 + struct bcma_bus *bus = cc->core->bus;
654 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
655 + cc->core->id.rev != 38) {
656 + bcma_err(bus, "NAND flash on unsupported board!\n");
660 + if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
661 + bcma_err(bus, "NAND flash not present according to ChipCommon\n");
665 + cc->nflash.present = true;
666 + if (cc->core->id.rev == 38 &&
667 + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
668 + cc->nflash.boot = true;
670 + /* Prepare platform device, but don't register it yet. It's too early,
671 + * malloc (required by device_private_init) is not available yet. */
672 + bcma_nflash_dev.dev.platform_data = &cc->nflash;
676 --- a/drivers/bcma/driver_chipcommon_pmu.c
677 +++ b/drivers/bcma/driver_chipcommon_pmu.c
679 * ChipCommon Power Management Unit driver
681 * Copyright 2009, Michael Buesch <m@bues.ch>
682 - * Copyright 2007, Broadcom Corporation
683 + * Copyright 2007, 2011, Broadcom Corporation
684 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
686 * Licensed under the GNU/GPL. See COPYING for details.
689 #include <linux/export.h>
690 #include <linux/bcma/bcma.h>
692 -static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
693 +u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
695 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
696 bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
697 return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
699 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
701 void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
703 @@ -54,19 +56,106 @@ void bcma_chipco_regctl_maskset(struct b
705 EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
707 +static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc)
709 + u32 ilp_ctl, alp_hz;
711 + if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) &
712 + BCMA_CC_PMU_STAT_EXT_LPO_AVAIL))
715 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
716 + BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
717 + usleep_range(1000, 2000);
719 + ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
720 + ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK;
722 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
724 + alp_hz = ilp_ctl * 32768 / 4;
725 + return (alp_hz + 50000) / 100000 * 100;
728 +static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq)
730 + struct bcma_bus *bus = cc->core->bus;
731 + u32 freq_tgt_target = 0, freq_tgt_current;
734 + switch (bus->chipinfo.id) {
735 + case BCMA_CHIP_ID_BCM43142:
736 + /* pmu2_xtaltab0_adfll_485 */
737 + switch (xtalfreq) {
739 + freq_tgt_target = 0x50D52;
742 + freq_tgt_target = 0x307FE;
745 + freq_tgt_target = 0x254EA;
748 + freq_tgt_target = 0x19EF8;
751 + freq_tgt_target = 0x12A75;
757 + if (!freq_tgt_target) {
758 + bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n",
763 + pll0 = bcma_chipco_pll_read(cc, BCMA_CC_PMU15_PLL_PLLCTL0);
764 + freq_tgt_current = (pll0 & BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK) >>
765 + BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
767 + if (freq_tgt_current == freq_tgt_target) {
768 + bcma_debug(bus, "Target TGT frequency already set\n");
773 + switch (bus->chipinfo.id) {
774 + case BCMA_CHIP_ID_BCM43142:
775 + mask = (u32)~(BCMA_RES_4314_HT_AVAIL |
776 + BCMA_RES_4314_MACPHY_CLK_AVAIL);
778 + bcma_cc_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask);
779 + bcma_cc_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask);
780 + bcma_wait_value(cc->core, BCMA_CLKCTLST,
781 + BCMA_CLKCTLST_HAVEHT, 0, 20000);
785 + pll0 &= ~BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK;
786 + pll0 |= freq_tgt_target << BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
787 + bcma_chipco_pll_write(cc, BCMA_CC_PMU15_PLL_PLLCTL0, pll0);
790 + if (cc->pmu.rev >= 2)
791 + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
793 + /* TODO: Do we need to update OTP? */
796 static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
798 struct bcma_bus *bus = cc->core->bus;
799 + u32 xtalfreq = bcma_pmu_xtalfreq(cc);
801 switch (bus->chipinfo.id) {
806 + case BCMA_CHIP_ID_BCM43142:
809 + bcma_pmu2_pll_init0(cc, xtalfreq);
812 - pr_err("PLL init unknown for device 0x%04X\n",
817 @@ -76,16 +165,32 @@ static void bcma_pmu_resources_init(stru
818 u32 min_msk = 0, max_msk = 0;
820 switch (bus->chipinfo.id) {
822 + case BCMA_CHIP_ID_BCM4313:
828 + case BCMA_CHIP_ID_BCM43142:
829 + min_msk = BCMA_RES_4314_LPLDO_PU |
830 + BCMA_RES_4314_PMU_SLEEP_DIS |
831 + BCMA_RES_4314_PMU_BG_PU |
832 + BCMA_RES_4314_CBUCK_LPOM_PU |
833 + BCMA_RES_4314_CBUCK_PFM_PU |
834 + BCMA_RES_4314_CLDO_PU |
835 + BCMA_RES_4314_LPLDO2_LVM |
836 + BCMA_RES_4314_WL_PMU_PU |
837 + BCMA_RES_4314_LDO3P3_PU |
838 + BCMA_RES_4314_OTP_PU |
839 + BCMA_RES_4314_WL_PWRSW_PU |
840 + BCMA_RES_4314_LQ_AVAIL |
841 + BCMA_RES_4314_LOGIC_RET |
842 + BCMA_RES_4314_MEM_SLEEP |
843 + BCMA_RES_4314_MACPHY_RET |
844 + BCMA_RES_4314_WL_CORE_READY;
845 + max_msk = 0x3FFFFFFF;
848 - pr_err("PMU resource config unknown for device 0x%04X\n",
850 + bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
854 /* Set the resource masks. */
855 @@ -93,22 +198,12 @@ static void bcma_pmu_resources_init(stru
856 bcma_cc_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
858 bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
861 -void bcma_pmu_swreg_init(struct bcma_drv_cc *cc)
863 - struct bcma_bus *bus = cc->core->bus;
865 - switch (bus->chipinfo.id) {
872 - pr_err("PMU switch/regulators init unknown for device "
873 - "0x%04X\n", bus->chipinfo.id);
876 + * Add some delay; allow resources to come up and settle.
877 + * Delay is required for SoC (early init).
882 /* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
883 @@ -122,51 +217,69 @@ void bcma_chipco_bcm4331_ext_pa_lines_ct
884 val |= BCMA_CHIPCTL_4331_EXTPA_EN;
885 if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11)
886 val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
887 + else if (bus->chipinfo.rev > 0)
888 + val |= BCMA_CHIPCTL_4331_EXTPA_EN2;
890 val &= ~BCMA_CHIPCTL_4331_EXTPA_EN;
891 + val &= ~BCMA_CHIPCTL_4331_EXTPA_EN2;
892 val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
894 bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
897 -void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
898 +static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
900 struct bcma_bus *bus = cc->core->bus;
902 switch (bus->chipinfo.id) {
904 - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7);
905 + case BCMA_CHIP_ID_BCM4313:
906 + /* enable 12 mA drive strenth for 4313 and set chipControl
908 + bcma_chipco_chipctl_maskset(cc, 0,
909 + ~BCMA_CCTRL_4313_12MA_LED_DRIVE,
910 + BCMA_CCTRL_4313_12MA_LED_DRIVE);
913 - /* BCM4331 workaround is SPROM-related, we put it in sprom.c */
914 + case BCMA_CHIP_ID_BCM4331:
915 + case BCMA_CHIP_ID_BCM43431:
916 + /* Ext PA lines must be enabled for tx on BCM4331 */
917 + bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true);
920 + case BCMA_CHIP_ID_BCM43224:
921 + case BCMA_CHIP_ID_BCM43421:
922 + /* enable 12 mA drive strenth for 43224 and set chipControl
924 if (bus->chipinfo.rev == 0) {
925 - pr_err("Workarounds for 43224 rev 0 not fully "
927 - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x00F000F0);
928 + bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL,
929 + ~BCMA_CCTRL_43224_GPIO_TOGGLE,
930 + BCMA_CCTRL_43224_GPIO_TOGGLE);
931 + bcma_chipco_chipctl_maskset(cc, 0,
932 + ~BCMA_CCTRL_43224A0_12MA_LED_DRIVE,
933 + BCMA_CCTRL_43224A0_12MA_LED_DRIVE);
935 - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
936 + bcma_chipco_chipctl_maskset(cc, 0,
937 + ~BCMA_CCTRL_43224B0_12MA_LED_DRIVE,
938 + BCMA_CCTRL_43224B0_12MA_LED_DRIVE);
944 - pr_err("Workarounds unknown for device 0x%04X\n",
946 + bcma_debug(bus, "Workarounds unknown or not needed for device 0x%04X\n",
951 -void bcma_pmu_init(struct bcma_drv_cc *cc)
952 +void bcma_pmu_early_init(struct bcma_drv_cc *cc)
956 pmucap = bcma_cc_read32(cc, BCMA_CC_PMU_CAP);
957 cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION);
959 - pr_debug("Found rev %u PMU (capabilities 0x%08X)\n", cc->pmu.rev,
961 + bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
962 + cc->pmu.rev, pmucap);
965 +void bcma_pmu_init(struct bcma_drv_cc *cc)
967 if (cc->pmu.rev == 1)
968 bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
969 ~BCMA_CC_PMU_CTL_NOILPONW);
970 @@ -174,37 +287,48 @@ void bcma_pmu_init(struct bcma_drv_cc *c
971 bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
972 BCMA_CC_PMU_CTL_NOILPONW);
974 - if (cc->core->id.id == 0x4329 && cc->core->id.rev == 2)
975 - pr_err("Fix for 4329b0 bad LPOM state not implemented!\n");
977 bcma_pmu_pll_init(cc);
978 bcma_pmu_resources_init(cc);
979 - bcma_pmu_swreg_init(cc);
980 bcma_pmu_workarounds(cc);
983 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
984 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
986 struct bcma_bus *bus = cc->core->bus;
988 switch (bus->chipinfo.id) {
996 + case BCMA_CHIP_ID_BCM4313:
997 + case BCMA_CHIP_ID_BCM43224:
998 + case BCMA_CHIP_ID_BCM43225:
999 + case BCMA_CHIP_ID_BCM43227:
1000 + case BCMA_CHIP_ID_BCM43228:
1001 + case BCMA_CHIP_ID_BCM4331:
1002 + case BCMA_CHIP_ID_BCM43421:
1003 + case BCMA_CHIP_ID_BCM43428:
1004 + case BCMA_CHIP_ID_BCM43431:
1005 + case BCMA_CHIP_ID_BCM4716:
1006 + case BCMA_CHIP_ID_BCM47162:
1007 + case BCMA_CHIP_ID_BCM4748:
1008 + case BCMA_CHIP_ID_BCM4749:
1009 + case BCMA_CHIP_ID_BCM5357:
1010 + case BCMA_CHIP_ID_BCM53572:
1011 + case BCMA_CHIP_ID_BCM6362:
1013 return 20000 * 1000;
1016 + case BCMA_CHIP_ID_BCM4706:
1017 + case BCMA_CHIP_ID_BCM5356:
1019 return 25000 * 1000;
1020 + case BCMA_CHIP_ID_BCM43460:
1021 + case BCMA_CHIP_ID_BCM4352:
1022 + case BCMA_CHIP_ID_BCM4360:
1023 + if (cc->status & BCMA_CC_CHIPST_4360_XTAL_40MZ)
1024 + return 40000 * 1000;
1026 + return 20000 * 1000;
1028 - pr_warn("No ALP clock specified for %04X device, "
1029 - "pmu rev. %d, using default %d Hz\n",
1030 - bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
1031 + bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
1032 + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
1034 return BCMA_CC_PMU_ALP_CLOCK;
1036 @@ -212,7 +336,7 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_c
1037 /* Find the output of the "m" pll divider given pll controls that start with
1038 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
1040 -static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
1041 +static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
1043 u32 tmp, div, ndiv, p1, p2, fc;
1044 struct bcma_bus *bus = cc->core->bus;
1045 @@ -221,7 +345,8 @@ static u32 bcma_pmu_clock(struct bcma_dr
1047 BUG_ON(!m || m > 4);
1049 - if (bus->chipinfo.id == 0x5357 || bus->chipinfo.id == 0x4749) {
1050 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
1051 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) {
1052 /* Detect failure in clock setting */
1053 tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
1055 @@ -240,60 +365,96 @@ static u32 bcma_pmu_clock(struct bcma_dr
1056 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
1058 /* Do calculation in Mhz */
1059 - fc = bcma_pmu_alp_clock(cc) / 1000000;
1060 + fc = bcma_pmu_get_alp_clock(cc) / 1000000;
1061 fc = (p1 * ndiv * fc) / p2;
1063 /* Return clock in Hertz */
1064 return (fc / div) * 1000000;
1067 +static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
1069 + u32 tmp, ndiv, p1div, p2div;
1072 + BUG_ON(!m || m > 4);
1074 + /* Get N, P1 and P2 dividers to determine CPU clock */
1075 + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PMU6_4706_PROCPLL_OFF);
1076 + ndiv = (tmp & BCMA_CC_PMU6_4706_PROC_NDIV_INT_MASK)
1077 + >> BCMA_CC_PMU6_4706_PROC_NDIV_INT_SHIFT;
1078 + p1div = (tmp & BCMA_CC_PMU6_4706_PROC_P1DIV_MASK)
1079 + >> BCMA_CC_PMU6_4706_PROC_P1DIV_SHIFT;
1080 + p2div = (tmp & BCMA_CC_PMU6_4706_PROC_P2DIV_MASK)
1081 + >> BCMA_CC_PMU6_4706_PROC_P2DIV_SHIFT;
1083 + tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
1084 + if (tmp & BCMA_CC_CHIPST_4706_PKG_OPTION)
1085 + /* Low cost bonding: Fixed reference clock 25MHz and m = 4 */
1086 + clock = (25000000 / 4) * ndiv * p2div / p1div;
1088 + /* Fixed reference clock 25MHz and m = 2 */
1089 + clock = (25000000 / 2) * ndiv * p2div / p1div;
1091 + if (m == BCMA_CC_PMU5_MAINPLL_SSB)
1092 + clock = clock / 4;
1097 /* query bus clock frequency for PMU-enabled chipcommon */
1098 -u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
1099 +u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
1101 struct bcma_bus *bus = cc->core->bus;
1103 switch (bus->chipinfo.id) {
1107 - return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
1108 - BCMA_CC_PMU5_MAINPLL_SSB);
1110 - return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
1111 - BCMA_CC_PMU5_MAINPLL_SSB);
1114 - return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
1115 - BCMA_CC_PMU5_MAINPLL_SSB);
1117 - return bcma_pmu_clock(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
1118 - BCMA_CC_PMU5_MAINPLL_SSB);
1120 + case BCMA_CHIP_ID_BCM4716:
1121 + case BCMA_CHIP_ID_BCM4748:
1122 + case BCMA_CHIP_ID_BCM47162:
1123 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
1124 + BCMA_CC_PMU5_MAINPLL_SSB);
1125 + case BCMA_CHIP_ID_BCM5356:
1126 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
1127 + BCMA_CC_PMU5_MAINPLL_SSB);
1128 + case BCMA_CHIP_ID_BCM5357:
1129 + case BCMA_CHIP_ID_BCM4749:
1130 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
1131 + BCMA_CC_PMU5_MAINPLL_SSB);
1132 + case BCMA_CHIP_ID_BCM4706:
1133 + return bcma_pmu_pll_clock_bcm4706(cc,
1134 + BCMA_CC_PMU4706_MAINPLL_PLL0,
1135 + BCMA_CC_PMU5_MAINPLL_SSB);
1136 + case BCMA_CHIP_ID_BCM53572:
1139 - pr_warn("No backplane clock specified for %04X device, "
1140 - "pmu rev. %d, using default %d Hz\n",
1141 - bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
1142 + bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
1143 + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
1145 return BCMA_CC_PMU_HT_CLOCK;
1147 +EXPORT_SYMBOL_GPL(bcma_pmu_get_bus_clock);
1149 /* query cpu clock frequency for PMU-enabled chipcommon */
1150 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
1151 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
1153 struct bcma_bus *bus = cc->core->bus;
1155 - if (bus->chipinfo.id == 53572)
1156 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
1159 + /* New PMUs can have different clock for bus and CPU */
1160 if (cc->pmu.rev >= 5) {
1162 switch (bus->chipinfo.id) {
1164 + case BCMA_CHIP_ID_BCM4706:
1165 + return bcma_pmu_pll_clock_bcm4706(cc,
1166 + BCMA_CC_PMU4706_MAINPLL_PLL0,
1167 + BCMA_CC_PMU5_MAINPLL_CPU);
1168 + case BCMA_CHIP_ID_BCM5356:
1169 pll = BCMA_CC_PMU5356_MAINPLL_PLL0;
1173 + case BCMA_CHIP_ID_BCM5357:
1174 + case BCMA_CHIP_ID_BCM4749:
1175 pll = BCMA_CC_PMU5357_MAINPLL_PLL0;
1178 @@ -301,10 +462,189 @@ u32 bcma_pmu_get_clockcpu(struct bcma_dr
1182 - /* TODO: if (bus->chipinfo.id == 0x5300)
1183 - return si_4706_pmu_clock(sih, osh, cc, PMU4706_MAINPLL_PLL0, PMU5_MAINPLL_CPU); */
1184 - return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
1185 + return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
1188 + /* On old PMUs CPU has the same clock as the bus */
1189 + return bcma_pmu_get_bus_clock(cc);
1192 +static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
1195 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
1196 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
1199 +void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid)
1202 + u8 phypll_offset = 0;
1203 + u8 bcm5357_bcm43236_p1div[] = {0x1, 0x5, 0x5};
1204 + u8 bcm5357_bcm43236_ndiv[] = {0x30, 0xf6, 0xfc};
1205 + struct bcma_bus *bus = cc->core->bus;
1207 + switch (bus->chipinfo.id) {
1208 + case BCMA_CHIP_ID_BCM5357:
1209 + case BCMA_CHIP_ID_BCM4749:
1210 + case BCMA_CHIP_ID_BCM53572:
1211 + /* 5357[ab]0, 43236[ab]0, and 6362b0 */
1213 + /* BCM5357 needs to touch PLL1_PLLCTL[02],
1214 + so offset PLL0_PLLCTL[02] by 6 */
1215 + phypll_offset = (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
1216 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4749 ||
1217 + bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) ? 6 : 0;
1219 + /* RMW only the P1 divider */
1220 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
1221 + BCMA_CC_PMU_PLL_CTL0 + phypll_offset);
1222 + tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
1223 + tmp &= (~(BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK));
1224 + tmp |= (bcm5357_bcm43236_p1div[spuravoid] << BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT);
1225 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
1227 + /* RMW only the int feedback divider */
1228 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
1229 + BCMA_CC_PMU_PLL_CTL2 + phypll_offset);
1230 + tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
1231 + tmp &= ~(BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK);
1232 + tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
1233 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
1235 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
1238 + case BCMA_CHIP_ID_BCM4331:
1239 + case BCMA_CHIP_ID_BCM43431:
1240 + if (spuravoid == 2) {
1241 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1243 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1245 + } else if (spuravoid == 1) {
1246 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1248 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1251 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1253 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1256 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
1259 + case BCMA_CHIP_ID_BCM43224:
1260 + case BCMA_CHIP_ID_BCM43225:
1261 + case BCMA_CHIP_ID_BCM43421:
1262 + if (spuravoid == 1) {
1263 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1265 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
1267 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1269 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
1271 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
1273 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
1276 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1278 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
1280 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1282 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
1284 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
1286 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
1289 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
1292 + case BCMA_CHIP_ID_BCM4716:
1293 + case BCMA_CHIP_ID_BCM4748:
1294 + case BCMA_CHIP_ID_BCM47162:
1295 + if (spuravoid == 1) {
1296 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1298 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
1300 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1302 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
1304 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
1306 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
1309 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1311 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
1313 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1315 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
1317 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
1319 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
1323 + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
1326 + case BCMA_CHIP_ID_BCM43227:
1327 + case BCMA_CHIP_ID_BCM43228:
1328 + case BCMA_CHIP_ID_BCM43428:
1330 + /* PLL Settings for spur avoidance on/off mode,
1331 + no on2 support for 43228A0 */
1332 + if (spuravoid == 1) {
1333 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1335 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
1337 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1339 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
1341 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
1343 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
1346 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
1348 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
1350 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
1352 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
1354 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
1356 + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
1359 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
1362 + bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
1363 + bus->chipinfo.id);
1367 - return bcma_pmu_get_clockcontrol(cc);
1368 + tmp |= bcma_cc_read32(cc, BCMA_CC_PMU_CTL);
1369 + bcma_cc_write32(cc, BCMA_CC_PMU_CTL, tmp);
1371 +EXPORT_SYMBOL_GPL(bcma_pmu_spuravoid_pllupdate);
1373 +++ b/drivers/bcma/driver_chipcommon_sflash.c
1376 + * Broadcom specific AMBA
1377 + * ChipCommon serial flash interface
1379 + * Licensed under the GNU/GPL. See COPYING for details.
1382 +#include "bcma_private.h"
1384 +#include <linux/platform_device.h>
1385 +#include <linux/bcma/bcma.h>
1387 +static struct resource bcma_sflash_resource = {
1388 + .name = "bcma_sflash",
1389 + .start = BCMA_SOC_FLASH2,
1391 + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
1394 +struct platform_device bcma_sflash_dev = {
1395 + .name = "bcma_sflash",
1396 + .resource = &bcma_sflash_resource,
1397 + .num_resources = 1,
1400 +struct bcma_sflash_tbl_e {
1407 +static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
1408 + { "M25P20", 0x11, 0x10000, 4, },
1409 + { "M25P40", 0x12, 0x10000, 8, },
1411 + { "M25P16", 0x14, 0x10000, 32, },
1412 + { "M25P32", 0x15, 0x10000, 64, },
1413 + { "M25P64", 0x16, 0x10000, 128, },
1414 + { "M25FL128", 0x17, 0x10000, 256, },
1418 +static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
1419 + { "SST25WF512", 1, 0x1000, 16, },
1420 + { "SST25VF512", 0x48, 0x1000, 16, },
1421 + { "SST25WF010", 2, 0x1000, 32, },
1422 + { "SST25VF010", 0x49, 0x1000, 32, },
1423 + { "SST25WF020", 3, 0x1000, 64, },
1424 + { "SST25VF020", 0x43, 0x1000, 64, },
1425 + { "SST25WF040", 4, 0x1000, 128, },
1426 + { "SST25VF040", 0x44, 0x1000, 128, },
1427 + { "SST25VF040B", 0x8d, 0x1000, 128, },
1428 + { "SST25WF080", 5, 0x1000, 256, },
1429 + { "SST25VF080B", 0x8e, 0x1000, 256, },
1430 + { "SST25VF016", 0x41, 0x1000, 512, },
1431 + { "SST25VF032", 0x4a, 0x1000, 1024, },
1432 + { "SST25VF064", 0x4b, 0x1000, 2048, },
1436 +static const struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
1437 + { "AT45DB011", 0xc, 256, 512, },
1438 + { "AT45DB021", 0x14, 256, 1024, },
1439 + { "AT45DB041", 0x1c, 256, 2048, },
1440 + { "AT45DB081", 0x24, 256, 4096, },
1441 + { "AT45DB161", 0x2c, 512, 4096, },
1442 + { "AT45DB321", 0x34, 512, 8192, },
1443 + { "AT45DB642", 0x3c, 1024, 8192, },
1447 +static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
1450 + bcma_cc_write32(cc, BCMA_CC_FLASHCTL,
1451 + BCMA_CC_FLASHCTL_START | opcode);
1452 + for (i = 0; i < 1000; i++) {
1453 + if (!(bcma_cc_read32(cc, BCMA_CC_FLASHCTL) &
1454 + BCMA_CC_FLASHCTL_BUSY))
1458 + bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
1461 +/* Initialize serial flash access */
1462 +int bcma_sflash_init(struct bcma_drv_cc *cc)
1464 + struct bcma_bus *bus = cc->core->bus;
1465 + struct bcma_sflash *sflash = &cc->sflash;
1466 + const struct bcma_sflash_tbl_e *e;
1469 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
1470 + case BCMA_CC_FLASHT_STSER:
1471 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_DP);
1473 + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 0);
1474 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
1475 + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
1477 + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 1);
1478 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
1479 + id2 = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
1483 + for (e = bcma_sflash_sst_tbl; e->name; e++) {
1491 + for (e = bcma_sflash_st_tbl; e->name; e++) {
1498 + bcma_err(bus, "Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n", id, id2);
1503 + case BCMA_CC_FLASHT_ATSER:
1504 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_AT_STATUS);
1505 + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA) & 0x3c;
1507 + for (e = bcma_sflash_at_tbl; e->name; e++) {
1512 + bcma_err(bus, "Unsupported Atmel serial flash (id: 0x%X)\n", id);
1518 + bcma_err(bus, "Unsupported flash type\n");
1522 + sflash->window = BCMA_SOC_FLASH2;
1523 + sflash->blocksize = e->blocksize;
1524 + sflash->numblocks = e->numblocks;
1525 + sflash->size = sflash->blocksize * sflash->numblocks;
1526 + sflash->present = true;
1528 + bcma_info(bus, "Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
1529 + e->name, sflash->size / 1024, sflash->blocksize,
1530 + sflash->numblocks);
1532 + /* Prepare platform device, but don't register it yet. It's too early,
1533 + * malloc (required by device_private_init) is not available yet. */
1534 + bcma_sflash_dev.resource[0].end = bcma_sflash_dev.resource[0].start +
1536 + bcma_sflash_dev.dev.platform_data = sflash;
1541 +++ b/drivers/bcma/driver_gmac_cmn.c
1544 + * Broadcom specific AMBA
1545 + * GBIT MAC COMMON Core
1547 + * Licensed under the GNU/GPL. See COPYING for details.
1550 +#include "bcma_private.h"
1551 +#include <linux/bcma/bcma.h>
1553 +void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc)
1555 + mutex_init(&gc->phy_mutex);
1558 +++ b/drivers/bcma/driver_gpio.c
1561 + * Broadcom specific AMBA
1564 + * Copyright 2011, Broadcom Corporation
1565 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
1567 + * Licensed under the GNU/GPL. See COPYING for details.
1570 +#include <linux/gpio.h>
1571 +#include <linux/export.h>
1572 +#include <linux/bcma/bcma.h>
1574 +#include "bcma_private.h"
1576 +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
1578 + return container_of(chip, struct bcma_drv_cc, gpio);
1581 +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
1583 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1585 + return !!bcma_chipco_gpio_in(cc, 1 << gpio);
1588 +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
1591 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1593 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1596 +static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
1598 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1600 + bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
1604 +static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
1607 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1609 + bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
1610 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1614 +static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
1616 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1618 + bcma_chipco_gpio_control(cc, 1 << gpio, 0);
1619 + /* clear pulldown */
1620 + bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
1622 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
1627 +static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
1629 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1631 + /* clear pullup */
1632 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
1635 +static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
1637 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1639 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
1640 + return bcma_core_irq(cc->core);
1645 +int bcma_gpio_init(struct bcma_drv_cc *cc)
1647 + struct gpio_chip *chip = &cc->gpio;
1649 + chip->label = "bcma_gpio";
1650 + chip->owner = THIS_MODULE;
1651 + chip->request = bcma_gpio_request;
1652 + chip->free = bcma_gpio_free;
1653 + chip->get = bcma_gpio_get_value;
1654 + chip->set = bcma_gpio_set_value;
1655 + chip->direction_input = bcma_gpio_direction_input;
1656 + chip->direction_output = bcma_gpio_direction_output;
1657 + chip->to_irq = bcma_gpio_to_irq;
1659 + /* There is just one SoC in one device and its GPIO addresses should be
1660 + * deterministic to address them more easily. The other buses could get
1661 + * a random base number. */
1662 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
1667 + return gpiochip_add(chip);
1670 +int bcma_gpio_unregister(struct bcma_drv_cc *cc)
1672 + return gpiochip_remove(&cc->gpio);
1674 --- a/drivers/bcma/driver_mips.c
1675 +++ b/drivers/bcma/driver_mips.c
1678 #include <linux/bcma/bcma.h>
1680 +#include <linux/mtd/physmap.h>
1681 +#include <linux/platform_device.h>
1682 #include <linux/serial.h>
1683 #include <linux/serial_core.h>
1684 #include <linux/serial_reg.h>
1685 #include <linux/time.h>
1687 +static const char * const part_probes[] = { "bcm47xxpart", NULL };
1689 +static struct physmap_flash_data bcma_pflash_data = {
1690 + .part_probe_types = part_probes,
1693 +static struct resource bcma_pflash_resource = {
1694 + .name = "bcma_pflash",
1695 + .flags = IORESOURCE_MEM,
1698 +struct platform_device bcma_pflash_dev = {
1699 + .name = "physmap-flash",
1701 + .platform_data = &bcma_pflash_data,
1703 + .resource = &bcma_pflash_resource,
1704 + .num_resources = 1,
1707 /* The 47162a0 hangs when reading MIPS DMP registers registers */
1708 static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
1710 - return dev->bus->chipinfo.id == 47162 && dev->bus->chipinfo.rev == 0 &&
1711 - dev->id.id == BCMA_CORE_MIPS_74K;
1712 + return dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM47162 &&
1713 + dev->bus->chipinfo.rev == 0 && dev->id.id == BCMA_CORE_MIPS_74K;
1716 /* The 5357b0 hangs when reading USB20H DMP registers */
1717 static inline bool bcma_core_mips_bcm5357b0_quirk(struct bcma_device *dev)
1719 - return (dev->bus->chipinfo.id == 0x5357 ||
1720 - dev->bus->chipinfo.id == 0x4749) &&
1721 + return (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
1722 + dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) &&
1723 dev->bus->chipinfo.pkg == 11 &&
1724 dev->id.id == BCMA_CORE_USB20_HOST;
1726 @@ -74,28 +96,41 @@ static u32 bcma_core_mips_irqflag(struct
1727 return dev->core_index;
1728 flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
1730 - return flag & 0x1F;
1732 + return flag & 0x1F;
1737 /* Get the MIPS IRQ assignment for a specified device.
1738 * If unassigned, 0 is returned.
1739 + * If disabled, 5 is returned.
1740 + * If not supported, 6 is returned.
1742 -unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1743 +static unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1745 struct bcma_device *mdev = dev->bus->drv_mips.core;
1749 irqflag = bcma_core_mips_irqflag(dev);
1750 + if (irqflag == 0x3f)
1753 - for (irq = 1; irq <= 4; irq++)
1754 + for (irq = 0; irq <= 4; irq++)
1755 if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
1763 +unsigned int bcma_core_irq(struct bcma_device *dev)
1765 + unsigned int mips_irq = bcma_core_mips_irq(dev);
1766 + return mips_irq <= 4 ? mips_irq + 2 : 0;
1768 -EXPORT_SYMBOL(bcma_core_mips_irq);
1769 +EXPORT_SYMBOL(bcma_core_irq);
1771 static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
1773 @@ -114,8 +149,8 @@ static void bcma_core_mips_set_irq(struc
1774 bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
1775 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
1778 - bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
1779 + else if (oldirq != 5)
1780 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
1782 /* assign the new one */
1784 @@ -123,17 +158,17 @@ static void bcma_core_mips_set_irq(struc
1785 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
1788 - u32 oldirqflag = bcma_read32(mdev,
1789 - BCMA_MIPS_MIPS74K_INTMASK(irq));
1791 + u32 irqinitmask = bcma_read32(mdev,
1792 + BCMA_MIPS_MIPS74K_INTMASK(irq));
1793 + if (irqinitmask) {
1794 struct bcma_device *core;
1796 /* backplane irq line is in use, find out who uses
1797 * it and set user to irq 0
1799 - list_for_each_entry_reverse(core, &bus->cores, list) {
1800 + list_for_each_entry(core, &bus->cores, list) {
1801 if ((1 << bcma_core_mips_irqflag(core)) ==
1804 bcma_core_mips_set_irq(core, 0);
1807 @@ -143,15 +178,31 @@ static void bcma_core_mips_set_irq(struc
1811 - pr_info("set_irq: core 0x%04x, irq %d => %d\n",
1812 - dev->id.id, oldirq + 2, irq + 2);
1813 + bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n",
1814 + dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2);
1817 +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
1818 + u16 coreid, u8 unit)
1820 + struct bcma_device *core;
1822 + core = bcma_find_core_unit(bus, coreid, unit);
1825 + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
1830 + bcma_core_mips_set_irq(core, irq);
1833 static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
1836 static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
1837 - printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
1838 + printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
1839 for (i = 0; i <= 6; i++)
1840 printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
1842 @@ -161,7 +212,7 @@ static void bcma_core_mips_dump_irq(stru
1844 struct bcma_device *core;
1846 - list_for_each_entry_reverse(core, &bus->cores, list) {
1847 + list_for_each_entry(core, &bus->cores, list) {
1848 bcma_core_mips_print_irq(core, bcma_core_mips_irq(core));
1851 @@ -171,9 +222,9 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
1852 struct bcma_bus *bus = mcore->core->bus;
1854 if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
1855 - return bcma_pmu_get_clockcpu(&bus->drv_cc);
1856 + return bcma_pmu_get_cpu_clock(&bus->drv_cc);
1858 - pr_err("No PMU available, need this to get the cpu clock\n");
1859 + bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
1862 EXPORT_SYMBOL(bcma_cpu_clock);
1863 @@ -181,25 +232,81 @@ EXPORT_SYMBOL(bcma_cpu_clock);
1864 static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
1866 struct bcma_bus *bus = mcore->core->bus;
1867 + struct bcma_drv_cc *cc = &bus->drv_cc;
1868 + struct bcma_pflash *pflash = &cc->pflash;
1870 - switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
1871 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
1872 case BCMA_CC_FLASHT_STSER:
1873 case BCMA_CC_FLASHT_ATSER:
1874 - pr_err("Serial flash not supported.\n");
1875 + bcma_debug(bus, "Found serial flash\n");
1876 + bcma_sflash_init(cc);
1878 case BCMA_CC_FLASHT_PARA:
1879 - pr_info("found parallel flash.\n");
1880 - bus->drv_cc.pflash.window = 0x1c000000;
1881 - bus->drv_cc.pflash.window_size = 0x02000000;
1882 + bcma_debug(bus, "Found parallel flash\n");
1883 + pflash->present = true;
1884 + pflash->window = BCMA_SOC_FLASH2;
1885 + pflash->window_size = BCMA_SOC_FLASH2_SZ;
1887 - if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
1888 + if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
1889 BCMA_CC_FLASH_CFG_DS) == 0)
1890 - bus->drv_cc.pflash.buswidth = 1;
1891 + pflash->buswidth = 1;
1893 - bus->drv_cc.pflash.buswidth = 2;
1894 + pflash->buswidth = 2;
1896 + bcma_pflash_data.width = pflash->buswidth;
1897 + bcma_pflash_resource.start = pflash->window;
1898 + bcma_pflash_resource.end = pflash->window + pflash->window_size;
1902 - pr_err("flash not supported.\n");
1903 + bcma_err(bus, "Flash type not supported\n");
1906 + if (cc->core->id.rev == 38 ||
1907 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
1908 + if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
1909 + bcma_debug(bus, "Found NAND flash\n");
1910 + bcma_nflash_init(cc);
1915 +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
1917 + struct bcma_bus *bus = mcore->core->bus;
1919 + if (mcore->early_setup_done)
1922 + bcma_chipco_serial_init(&bus->drv_cc);
1923 + bcma_core_mips_flash_detect(mcore);
1925 + mcore->early_setup_done = true;
1928 +static void bcma_fix_i2s_irqflag(struct bcma_bus *bus)
1930 + struct bcma_device *cpu, *pcie, *i2s;
1932 + /* Fixup the interrupts in 4716/4748 for i2s core (2010 Broadcom SDK)
1933 + * (IRQ flags > 7 are ignored when setting the interrupt masks)
1935 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4716 &&
1936 + bus->chipinfo.id != BCMA_CHIP_ID_BCM4748)
1939 + cpu = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1940 + pcie = bcma_find_core(bus, BCMA_CORE_PCIE);
1941 + i2s = bcma_find_core(bus, BCMA_CORE_I2S);
1942 + if (cpu && pcie && i2s &&
1943 + bcma_aread32(cpu, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
1944 + bcma_aread32(pcie, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
1945 + bcma_aread32(i2s, BCMA_MIPS_OOBSELOUTA30) == 0x88) {
1946 + bcma_awrite32(cpu, BCMA_MIPS_OOBSELINA74, 0x07060504);
1947 + bcma_awrite32(pcie, BCMA_MIPS_OOBSELINA74, 0x07060504);
1948 + bcma_awrite32(i2s, BCMA_MIPS_OOBSELOUTA30, 0x87);
1950 + "Moved i2s interrupt to oob line 7 instead of 8\n");
1954 @@ -209,48 +316,59 @@ void bcma_core_mips_init(struct bcma_drv
1955 struct bcma_device *core;
1956 bus = mcore->core->bus;
1958 - pr_info("Initializing MIPS core...\n");
1959 + if (mcore->setup_done)
1962 - if (!mcore->setup_done)
1963 - mcore->assigned_irqs = 1;
1964 + bcma_debug(bus, "Initializing MIPS core...\n");
1966 - /* Assign IRQs to all cores on the bus */
1967 - list_for_each_entry_reverse(core, &bus->cores, list) {
1972 - mips_irq = bcma_core_mips_irq(core);
1976 - core->irq = mips_irq + 2;
1977 - if (core->irq > 5)
1979 - switch (core->id.id) {
1980 - case BCMA_CORE_PCI:
1981 - case BCMA_CORE_PCIE:
1982 - case BCMA_CORE_ETHERNET:
1983 - case BCMA_CORE_ETHERNET_GBIT:
1984 - case BCMA_CORE_MAC_GBIT:
1985 - case BCMA_CORE_80211:
1986 - case BCMA_CORE_USB20_HOST:
1987 - /* These devices get their own IRQ line if available,
1988 - * the rest goes on IRQ0
1990 - if (mcore->assigned_irqs <= 4)
1991 - bcma_core_mips_set_irq(core,
1992 - mcore->assigned_irqs++);
1994 + bcma_core_mips_early_init(mcore);
1996 + bcma_fix_i2s_irqflag(bus);
1998 + switch (bus->chipinfo.id) {
1999 + case BCMA_CHIP_ID_BCM4716:
2000 + case BCMA_CHIP_ID_BCM4748:
2001 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
2002 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
2003 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
2004 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
2005 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
2006 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
2008 + case BCMA_CHIP_ID_BCM5356:
2009 + case BCMA_CHIP_ID_BCM47162:
2010 + case BCMA_CHIP_ID_BCM53572:
2011 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
2012 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
2013 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
2015 + case BCMA_CHIP_ID_BCM5357:
2016 + case BCMA_CHIP_ID_BCM4749:
2017 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
2018 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
2019 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
2020 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
2021 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
2023 + case BCMA_CHIP_ID_BCM4706:
2024 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
2025 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
2027 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
2028 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
2029 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
2033 + list_for_each_entry(core, &bus->cores, list) {
2034 + core->irq = bcma_core_irq(core);
2037 + "Unknown device (0x%x) found, can not configure IRQs\n",
2038 + bus->chipinfo.id);
2040 - pr_info("IRQ reconfiguration done\n");
2041 + bcma_debug(bus, "IRQ reconfiguration done\n");
2042 bcma_core_mips_dump_irq(bus);
2044 - if (mcore->setup_done)
2047 - bcma_chipco_serial_init(&bus->drv_cc);
2048 - bcma_core_mips_flash_detect(mcore);
2049 mcore->setup_done = true;
2051 --- a/drivers/bcma/driver_pci.c
2052 +++ b/drivers/bcma/driver_pci.c
2054 * Broadcom specific AMBA
2057 - * Copyright 2005, Broadcom Corporation
2058 + * Copyright 2005, 2011, Broadcom Corporation
2059 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
2060 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
2062 * Licensed under the GNU/GPL. See COPYING for details.
2064 @@ -16,120 +17,131 @@
2066 **************************************************/
2068 -static u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
2069 +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
2071 - pcicore_write32(pc, 0x130, address);
2072 - pcicore_read32(pc, 0x130);
2073 - return pcicore_read32(pc, 0x134);
2074 + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
2075 + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
2076 + return pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_DATA);
2080 static void bcma_pcie_write(struct bcma_drv_pci *pc, u32 address, u32 data)
2082 - pcicore_write32(pc, 0x130, address);
2083 - pcicore_read32(pc, 0x130);
2084 - pcicore_write32(pc, 0x134, data);
2085 + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
2086 + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
2087 + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
2091 -static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
2092 +static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u16 phy)
2094 - const u16 mdio_control = 0x128;
2095 - const u16 mdio_data = 0x12C;
2099 - v = (1 << 30); /* Start of Transaction */
2100 - v |= (1 << 28); /* Write Transaction */
2101 - v |= (1 << 17); /* Turnaround */
2102 - v |= (0x1F << 18);
2103 + v = BCMA_CORE_PCI_MDIODATA_START;
2104 + v |= BCMA_CORE_PCI_MDIODATA_WRITE;
2105 + v |= (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
2106 + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
2107 + v |= (BCMA_CORE_PCI_MDIODATA_BLK_ADDR <<
2108 + BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
2109 + v |= BCMA_CORE_PCI_MDIODATA_TA;
2111 - pcicore_write32(pc, mdio_data, v);
2112 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
2115 for (i = 0; i < 200; i++) {
2116 - v = pcicore_read32(pc, mdio_control);
2117 - if (v & 0x100 /* Trans complete */)
2118 + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
2119 + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
2122 + usleep_range(1000, 2000);
2126 -static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
2127 +static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address)
2129 - const u16 mdio_control = 0x128;
2130 - const u16 mdio_data = 0x12C;
2131 int max_retries = 10;
2136 - v = 0x80; /* Enable Preamble Sequence */
2137 - v |= 0x2; /* MDIO Clock Divisor */
2138 - pcicore_write32(pc, mdio_control, v);
2139 + /* enable mdio access to SERDES */
2140 + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
2141 + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
2142 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
2144 if (pc->core->id.rev >= 10) {
2146 bcma_pcie_mdio_set_phy(pc, device);
2147 + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
2148 + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
2149 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
2151 + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
2152 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
2155 - v = (1 << 30); /* Start of Transaction */
2156 - v |= (1 << 29); /* Read Transaction */
2157 - v |= (1 << 17); /* Turnaround */
2158 - if (pc->core->id.rev < 10)
2159 - v |= (u32)device << 22;
2160 - v |= (u32)address << 18;
2161 - pcicore_write32(pc, mdio_data, v);
2162 + v = BCMA_CORE_PCI_MDIODATA_START;
2163 + v |= BCMA_CORE_PCI_MDIODATA_READ;
2164 + v |= BCMA_CORE_PCI_MDIODATA_TA;
2166 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
2167 /* Wait for the device to complete the transaction */
2169 for (i = 0; i < max_retries; i++) {
2170 - v = pcicore_read32(pc, mdio_control);
2171 - if (v & 0x100 /* Trans complete */) {
2172 + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
2173 + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE) {
2175 - ret = pcicore_read32(pc, mdio_data);
2176 + ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
2180 + usleep_range(1000, 2000);
2182 - pcicore_write32(pc, mdio_control, 0);
2183 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
2187 -static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
2188 +static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device,
2189 u8 address, u16 data)
2191 - const u16 mdio_control = 0x128;
2192 - const u16 mdio_data = 0x12C;
2193 int max_retries = 10;
2197 - v = 0x80; /* Enable Preamble Sequence */
2198 - v |= 0x2; /* MDIO Clock Divisor */
2199 - pcicore_write32(pc, mdio_control, v);
2200 + /* enable mdio access to SERDES */
2201 + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
2202 + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
2203 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
2205 if (pc->core->id.rev >= 10) {
2207 bcma_pcie_mdio_set_phy(pc, device);
2208 + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
2209 + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
2210 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
2212 + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
2213 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
2216 - v = (1 << 30); /* Start of Transaction */
2217 - v |= (1 << 28); /* Write Transaction */
2218 - v |= (1 << 17); /* Turnaround */
2219 - if (pc->core->id.rev < 10)
2220 - v |= (u32)device << 22;
2221 - v |= (u32)address << 18;
2222 + v = BCMA_CORE_PCI_MDIODATA_START;
2223 + v |= BCMA_CORE_PCI_MDIODATA_WRITE;
2224 + v |= BCMA_CORE_PCI_MDIODATA_TA;
2226 - pcicore_write32(pc, mdio_data, v);
2227 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
2228 /* Wait for the device to complete the transaction */
2230 for (i = 0; i < max_retries; i++) {
2231 - v = pcicore_read32(pc, mdio_control);
2232 - if (v & 0x100 /* Trans complete */)
2233 + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
2234 + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
2237 + usleep_range(1000, 2000);
2239 - pcicore_write32(pc, mdio_control, 0);
2240 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
2243 +static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device,
2244 + u8 address, u16 data)
2246 + bcma_pcie_mdio_write(pc, device, address, data);
2247 + return bcma_pcie_mdio_read(pc, device, address);
2250 /**************************************************
2251 @@ -138,88 +150,134 @@ static void bcma_pcie_mdio_write(struct
2253 static u8 bcma_pcicore_polarity_workaround(struct bcma_drv_pci *pc)
2255 - return (bcma_pcie_read(pc, 0x204) & 0x10) ? 0xC0 : 0x80;
2258 + tmp = bcma_pcie_read(pc, BCMA_CORE_PCI_PLP_STATUSREG);
2259 + if (tmp & BCMA_CORE_PCI_PLP_POLARITYINV_STAT)
2260 + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE |
2261 + BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY;
2263 + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE;
2266 static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
2268 - const u8 serdes_pll_device = 0x1D;
2269 - const u8 serdes_rx_device = 0x1F;
2272 - bcma_pcie_mdio_write(pc, serdes_rx_device, 1 /* Control */,
2273 - bcma_pcicore_polarity_workaround(pc));
2274 - tmp = bcma_pcie_mdio_read(pc, serdes_pll_device, 1 /* Control */);
2276 - bcma_pcie_mdio_write(pc, serdes_pll_device, 1, tmp & ~0x4000);
2277 + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_RX,
2278 + BCMA_CORE_PCI_SERDES_RX_CTRL,
2279 + bcma_pcicore_polarity_workaround(pc));
2280 + tmp = bcma_pcie_mdio_read(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
2281 + BCMA_CORE_PCI_SERDES_PLL_CTRL);
2282 + if (tmp & BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN)
2283 + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
2284 + BCMA_CORE_PCI_SERDES_PLL_CTRL,
2285 + tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
2288 +static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
2290 + struct bcma_device *core = pc->core;
2291 + u16 val16, core_index;
2294 + regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
2295 + core_index = (u16)core->core_index;
2297 + val16 = pcicore_read16(pc, regoff);
2298 + if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
2300 + val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
2301 + (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
2302 + pcicore_write16(pc, regoff, val16);
2306 +/* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */
2307 +/* Needs to happen when coming out of 'standby'/'hibernate' */
2308 +static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc)
2313 + regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_MISC_CONFIG);
2315 + val16 = pcicore_read16(pc, regoff);
2317 + if (!(val16 & BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST)) {
2318 + val16 |= BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST;
2319 + pcicore_write16(pc, regoff, val16);
2323 /**************************************************
2325 **************************************************/
2327 -static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
2328 +static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
2330 + bcma_core_pci_fixcfg(pc);
2331 bcma_pcicore_serdes_workaround(pc);
2332 + bcma_core_pci_config_fixup(pc);
2335 -static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
2337 - struct bcma_bus *bus = pc->core->bus;
2340 - chipid_top = (bus->chipinfo.id & 0xFF00);
2341 - if (chipid_top != 0x4700 &&
2342 - chipid_top != 0x5300)
2345 -#ifdef CONFIG_SSB_DRIVER_PCICORE
2346 - if (bus->sprom.boardflags_lo & SSB_BFL_NOPCI)
2348 -#endif /* CONFIG_SSB_DRIVER_PCICORE */
2351 - /* TODO: on BCMA we use address from EROM instead of magic formula */
2353 - return !mips_busprobe32(tmp, (bus->mmio +
2354 - (pc->core->core_index * BCMA_CORE_SIZE)));
2360 -void bcma_core_pci_init(struct bcma_drv_pci *pc)
2361 +void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
2366 - if (bcma_core_pci_is_in_hostmode(pc)) {
2367 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
2368 + pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
2370 bcma_core_pci_hostmode_init(pc);
2372 - pr_err("Driver compiled without support for hostmode PCI\n");
2373 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
2376 + if (!pc->hostmode)
2377 bcma_core_pci_clientmode_init(pc);
2381 +void bcma_core_pci_power_save(struct bcma_bus *bus, bool up)
2383 + struct bcma_drv_pci *pc;
2386 - pc->setup_done = true;
2387 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
2390 + pc = &bus->drv_pci[0];
2392 + if (pc->core->id.rev >= 15 && pc->core->id.rev <= 20) {
2393 + data = up ? 0x74 : 0x7C;
2394 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
2395 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7F64);
2396 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
2397 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
2398 + } else if (pc->core->id.rev >= 21 && pc->core->id.rev <= 22) {
2399 + data = up ? 0x75 : 0x7D;
2400 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
2401 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7E65);
2402 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
2403 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
2406 +EXPORT_SYMBOL_GPL(bcma_core_pci_power_save);
2408 int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
2411 - struct pci_dev *pdev = pc->core->bus->host_pci;
2412 + struct pci_dev *pdev;
2416 - if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
2417 + if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
2418 /* This bcma device is not on a PCI host-bus. So the IRQs are
2419 * not routed through the PCI core.
2420 * So we must not enable routing through the PCI core. */
2424 + pdev = pc->core->bus->host_pci;
2426 err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
2429 @@ -236,3 +294,42 @@ out:
2432 EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
2434 +static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
2438 + w = bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
2440 + w |= BCMA_CORE_PCI_ASPMTIMER_EXTEND;
2442 + w &= ~BCMA_CORE_PCI_ASPMTIMER_EXTEND;
2443 + bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
2444 + bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
2447 +void bcma_core_pci_up(struct bcma_bus *bus)
2449 + struct bcma_drv_pci *pc;
2451 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
2454 + pc = &bus->drv_pci[0];
2456 + bcma_core_pci_extend_L1timer(pc, true);
2458 +EXPORT_SYMBOL_GPL(bcma_core_pci_up);
2460 +void bcma_core_pci_down(struct bcma_bus *bus)
2462 + struct bcma_drv_pci *pc;
2464 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
2467 + pc = &bus->drv_pci[0];
2469 + bcma_core_pci_extend_L1timer(pc, false);
2471 +EXPORT_SYMBOL_GPL(bcma_core_pci_down);
2472 --- a/drivers/bcma/driver_pci_host.c
2473 +++ b/drivers/bcma/driver_pci_host.c
2475 * Broadcom specific AMBA
2476 * PCI Core in hostmode
2478 + * Copyright 2005 - 2011, Broadcom Corporation
2479 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
2480 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
2482 * Licensed under the GNU/GPL. See COPYING for details.
2485 #include "bcma_private.h"
2486 +#include <linux/pci.h>
2487 +#include <linux/export.h>
2488 #include <linux/bcma/bcma.h>
2489 +#include <asm/paccess.h>
2491 +/* Probe a 32bit value on the bus and catch bus exceptions.
2492 + * Returns nonzero on a bus exception.
2493 + * This is MIPS specific */
2494 +#define mips_busprobe32(val, addr) get_dbe((val), ((u32 *)(addr)))
2496 +/* Assume one-hot slot wiring */
2497 +#define BCMA_PCI_SLOT_MAX 16
2498 +#define PCI_CONFIG_SPACE_SIZE 256
2500 +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
2502 + struct bcma_bus *bus = pc->core->bus;
2506 + chipid_top = (bus->chipinfo.id & 0xFF00);
2507 + if (chipid_top != 0x4700 &&
2508 + chipid_top != 0x5300)
2511 + bcma_core_enable(pc->core, 0);
2513 + return !mips_busprobe32(tmp, pc->core->io_addr);
2516 +static u32 bcma_pcie_read_config(struct bcma_drv_pci *pc, u32 address)
2518 + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
2519 + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
2520 + return pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_DATA);
2523 +static void bcma_pcie_write_config(struct bcma_drv_pci *pc, u32 address,
2526 + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
2527 + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
2528 + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_DATA, data);
2531 +static u32 bcma_get_cfgspace_addr(struct bcma_drv_pci *pc, unsigned int dev,
2532 + unsigned int func, unsigned int off)
2536 + /* Issue config commands only when the data link is up (atleast
2537 + * one external pcie device is present).
2539 + if (dev >= 2 || !(bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_LSREG)
2540 + & BCMA_CORE_PCI_DLLP_LSREG_LINKUP))
2543 + /* Type 0 transaction */
2544 + /* Slide the PCI window to the appropriate slot */
2545 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
2546 + /* Calculate the address */
2547 + addr = pc->host_controller->host_cfg_addr;
2548 + addr |= (dev << BCMA_CORE_PCI_CFG_SLOT_SHIFT);
2549 + addr |= (func << BCMA_CORE_PCI_CFG_FUN_SHIFT);
2550 + addr |= (off & ~3);
2556 +static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
2557 + unsigned int func, unsigned int off,
2558 + void *buf, int len)
2560 + int err = -EINVAL;
2562 + void __iomem *mmio = 0;
2564 + WARN_ON(!pc->hostmode);
2565 + if (unlikely(len != 1 && len != 2 && len != 4))
2568 + /* we support only two functions on device 0 */
2572 + /* accesses to config registers with offsets >= 256
2573 + * requires indirect access.
2575 + if (off >= PCI_CONFIG_SPACE_SIZE) {
2576 + addr = (func << 12);
2577 + addr |= (off & 0x0FFC);
2578 + val = bcma_pcie_read_config(pc, addr);
2580 + addr = BCMA_CORE_PCI_PCICFG0;
2581 + addr |= (func << 8);
2582 + addr |= (off & 0xFC);
2583 + val = pcicore_read32(pc, addr);
2586 + addr = bcma_get_cfgspace_addr(pc, dev, func, off);
2587 + if (unlikely(!addr))
2590 + mmio = ioremap_nocache(addr, sizeof(val));
2594 + if (mips_busprobe32(val, mmio)) {
2599 + val >>= (8 * (off & 3));
2603 + *((u8 *)buf) = (u8)val;
2606 + *((u16 *)buf) = (u16)val;
2609 + *((u32 *)buf) = (u32)val;
2620 -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
2621 +static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
2622 + unsigned int func, unsigned int off,
2623 + const void *buf, int len)
2625 - pr_err("No support for PCI core in hostmode yet\n");
2626 + int err = -EINVAL;
2628 + void __iomem *mmio = 0;
2629 + u16 chipid = pc->core->bus->chipinfo.id;
2631 + WARN_ON(!pc->hostmode);
2632 + if (unlikely(len != 1 && len != 2 && len != 4))
2635 + /* we support only two functions on device 0 */
2639 + /* accesses to config registers with offsets >= 256
2640 + * requires indirect access.
2642 + if (off >= PCI_CONFIG_SPACE_SIZE) {
2643 + addr = (func << 12);
2644 + addr |= (off & 0x0FFC);
2645 + val = bcma_pcie_read_config(pc, addr);
2647 + addr = BCMA_CORE_PCI_PCICFG0;
2648 + addr |= (func << 8);
2649 + addr |= (off & 0xFC);
2650 + val = pcicore_read32(pc, addr);
2653 + addr = bcma_get_cfgspace_addr(pc, dev, func, off);
2654 + if (unlikely(!addr))
2657 + mmio = ioremap_nocache(addr, sizeof(val));
2661 + if (mips_busprobe32(val, mmio)) {
2669 + val &= ~(0xFF << (8 * (off & 3)));
2670 + val |= *((const u8 *)buf) << (8 * (off & 3));
2673 + val &= ~(0xFFFF << (8 * (off & 3)));
2674 + val |= *((const u16 *)buf) << (8 * (off & 3));
2677 + val = *((const u32 *)buf);
2681 + /* accesses to config registers with offsets >= 256
2682 + * requires indirect access.
2684 + if (off >= PCI_CONFIG_SPACE_SIZE)
2685 + bcma_pcie_write_config(pc, addr, val);
2687 + pcicore_write32(pc, addr, val);
2689 + writel(val, mmio);
2691 + if (chipid == BCMA_CHIP_ID_BCM4716 ||
2692 + chipid == BCMA_CHIP_ID_BCM4748)
2704 +static int bcma_core_pci_hostmode_read_config(struct pci_bus *bus,
2705 + unsigned int devfn,
2706 + int reg, int size, u32 *val)
2708 + unsigned long flags;
2710 + struct bcma_drv_pci *pc;
2711 + struct bcma_drv_pci_host *pc_host;
2713 + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
2714 + pc = pc_host->pdev;
2716 + spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
2717 + err = bcma_extpci_read_config(pc, PCI_SLOT(devfn),
2718 + PCI_FUNC(devfn), reg, val, size);
2719 + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
2721 + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
2724 +static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus,
2725 + unsigned int devfn,
2726 + int reg, int size, u32 val)
2728 + unsigned long flags;
2730 + struct bcma_drv_pci *pc;
2731 + struct bcma_drv_pci_host *pc_host;
2733 + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
2734 + pc = pc_host->pdev;
2736 + spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
2737 + err = bcma_extpci_write_config(pc, PCI_SLOT(devfn),
2738 + PCI_FUNC(devfn), reg, &val, size);
2739 + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
2741 + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
2744 +/* return cap_offset if requested capability exists in the PCI config space */
2745 +static u8 __devinit bcma_find_pci_capability(struct bcma_drv_pci *pc,
2747 + unsigned int func, u8 req_cap_id,
2748 + unsigned char *buf, u32 *buflen)
2755 + /* check for Header type 0 */
2756 + bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
2758 + if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
2761 + /* check if the capability pointer field exists */
2762 + bcma_extpci_read_config(pc, dev, func, PCI_STATUS, &byte_val,
2764 + if (!(byte_val & PCI_STATUS_CAP_LIST))
2767 + /* check if the capability pointer is 0x00 */
2768 + bcma_extpci_read_config(pc, dev, func, PCI_CAPABILITY_LIST, &cap_ptr,
2770 + if (cap_ptr == 0x00)
2773 + /* loop thr'u the capability list and see if the requested capabilty
2775 + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id, sizeof(u8));
2776 + while (cap_id != req_cap_id) {
2777 + bcma_extpci_read_config(pc, dev, func, cap_ptr + 1, &cap_ptr,
2779 + if (cap_ptr == 0x00)
2781 + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id,
2785 + /* found the caller requested capability */
2786 + if ((buf != NULL) && (buflen != NULL)) {
2789 + bufsize = *buflen;
2795 + /* copy the cpability data excluding cap ID and next ptr */
2796 + cap_data = cap_ptr + 2;
2797 + if ((bufsize + cap_data) > PCI_CONFIG_SPACE_SIZE)
2798 + bufsize = PCI_CONFIG_SPACE_SIZE - cap_data;
2799 + *buflen = bufsize;
2800 + while (bufsize--) {
2801 + bcma_extpci_read_config(pc, dev, func, cap_data, buf,
2811 +/* If the root port is capable of returning Config Request
2812 + * Retry Status (CRS) Completion Status to software then
2813 + * enable the feature.
2815 +static void __devinit bcma_core_pci_enable_crs(struct bcma_drv_pci *pc)
2817 + struct bcma_bus *bus = pc->core->bus;
2818 + u8 cap_ptr, root_ctrl, root_cap, dev;
2822 + cap_ptr = bcma_find_pci_capability(pc, 0, 0, PCI_CAP_ID_EXP, NULL,
2824 + root_cap = cap_ptr + PCI_EXP_RTCAP;
2825 + bcma_extpci_read_config(pc, 0, 0, root_cap, &val16, sizeof(u16));
2826 + if (val16 & BCMA_CORE_PCI_RC_CRS_VISIBILITY) {
2827 + /* Enable CRS software visibility */
2828 + root_ctrl = cap_ptr + PCI_EXP_RTCTL;
2829 + val16 = PCI_EXP_RTCTL_CRSSVE;
2830 + bcma_extpci_read_config(pc, 0, 0, root_ctrl, &val16,
2833 + /* Initiate a configuration request to read the vendor id
2834 + * field of the device function's config space header after
2835 + * 100 ms wait time from the end of Reset. If the device is
2836 + * not done with its internal initialization, it must at
2837 + * least return a completion TLP, with a completion status
2838 + * of "Configuration Request Retry Status (CRS)". The root
2839 + * complex must complete the request to the host by returning
2840 + * a read-data value of 0001h for the Vendor ID field and
2841 + * all 1s for any additional bytes included in the request.
2842 + * Poll using the config reads for max wait time of 1 sec or
2843 + * until we receive the successful completion status. Repeat
2844 + * the procedure for all the devices.
2846 + for (dev = 1; dev < BCMA_PCI_SLOT_MAX; dev++) {
2847 + for (i = 0; i < 100000; i++) {
2848 + bcma_extpci_read_config(pc, dev, 0,
2849 + PCI_VENDOR_ID, &val16,
2856 + bcma_err(bus, "PCI: Broken device in slot %d\n",
2862 +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
2864 + struct bcma_bus *bus = pc->core->bus;
2865 + struct bcma_drv_pci_host *pc_host;
2867 + u32 pci_membase_1G;
2868 + unsigned long io_map_base;
2870 + bcma_info(bus, "PCIEcore in host mode found\n");
2872 + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
2873 + bcma_info(bus, "This PCIE core is disabled and not working\n");
2877 + pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
2879 + bcma_err(bus, "can not allocate memory");
2883 + spin_lock_init(&pc_host->cfgspace_lock);
2885 + pc->host_controller = pc_host;
2886 + pc_host->pci_controller.io_resource = &pc_host->io_resource;
2887 + pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
2888 + pc_host->pci_controller.pci_ops = &pc_host->pci_ops;
2889 + pc_host->pdev = pc;
2891 + pci_membase_1G = BCMA_SOC_PCI_DMA;
2892 + pc_host->host_cfg_addr = BCMA_SOC_PCI_CFG;
2894 + pc_host->pci_ops.read = bcma_core_pci_hostmode_read_config;
2895 + pc_host->pci_ops.write = bcma_core_pci_hostmode_write_config;
2897 + pc_host->mem_resource.name = "BCMA PCIcore external memory",
2898 + pc_host->mem_resource.start = BCMA_SOC_PCI_DMA;
2899 + pc_host->mem_resource.end = BCMA_SOC_PCI_DMA + BCMA_SOC_PCI_DMA_SZ - 1;
2900 + pc_host->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
2902 + pc_host->io_resource.name = "BCMA PCIcore external I/O",
2903 + pc_host->io_resource.start = 0x100;
2904 + pc_host->io_resource.end = 0x7FF;
2905 + pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
2908 + usleep_range(3000, 5000);
2909 + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
2911 + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
2912 + BCMA_CORE_PCI_CTL_RST_OE);
2914 + /* 64 MB I/O access window. On 4716, use
2915 + * sbtopcie0 to access the device registers. We
2916 + * can't use address match 2 (1 GB window) region
2917 + * as mips can't generate 64-bit address on the
2920 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4716 ||
2921 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4748) {
2922 + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
2923 + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
2924 + BCMA_SOC_PCI_MEM_SZ - 1;
2925 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
2926 + BCMA_CORE_PCI_SBTOPCI_MEM | BCMA_SOC_PCI_MEM);
2927 + } else if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
2928 + tmp = BCMA_CORE_PCI_SBTOPCI_MEM;
2929 + tmp |= BCMA_CORE_PCI_SBTOPCI_PREF;
2930 + tmp |= BCMA_CORE_PCI_SBTOPCI_BURST;
2931 + if (pc->core->core_unit == 0) {
2932 + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
2933 + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
2934 + BCMA_SOC_PCI_MEM_SZ - 1;
2935 + pc_host->io_resource.start = 0x100;
2936 + pc_host->io_resource.end = 0x47F;
2937 + pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
2938 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
2939 + tmp | BCMA_SOC_PCI_MEM);
2940 + } else if (pc->core->core_unit == 1) {
2941 + pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
2942 + pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
2943 + BCMA_SOC_PCI_MEM_SZ - 1;
2944 + pc_host->io_resource.start = 0x480;
2945 + pc_host->io_resource.end = 0x7FF;
2946 + pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
2947 + pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
2948 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
2949 + tmp | BCMA_SOC_PCI1_MEM);
2952 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
2953 + BCMA_CORE_PCI_SBTOPCI_IO);
2955 + /* 64 MB configuration access window */
2956 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
2958 + /* 1 GB memory access window */
2959 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI2,
2960 + BCMA_CORE_PCI_SBTOPCI_MEM | pci_membase_1G);
2963 + /* As per PCI Express Base Spec 1.1 we need to wait for
2964 + * at least 100 ms from the end of a reset (cold/warm/hot)
2965 + * before issuing configuration requests to PCI Express
2970 + bcma_core_pci_enable_crs(pc);
2972 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706 ||
2973 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4716) {
2975 + bcma_extpci_read_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
2976 + &val16, sizeof(val16));
2977 + val16 |= (2 << 5); /* Max payload size of 512 */
2978 + val16 |= (2 << 12); /* MRRS 512 */
2979 + bcma_extpci_write_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
2980 + &val16, sizeof(val16));
2983 + /* Enable PCI bridge BAR0 memory & master access */
2984 + tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
2985 + bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
2987 + /* Enable PCI interrupts */
2988 + pcicore_write32(pc, BCMA_CORE_PCI_IMASK, BCMA_CORE_PCI_IMASK_INTA);
2990 + /* Ok, ready to run, register it to the system.
2991 + * The following needs change, if we want to port hostmode
2992 + * to non-MIPS platform. */
2993 + io_map_base = (unsigned long)ioremap_nocache(pc_host->mem_resource.start,
2994 + resource_size(&pc_host->mem_resource));
2995 + pc_host->pci_controller.io_map_base = io_map_base;
2996 + set_io_port_base(pc_host->pci_controller.io_map_base);
2997 + /* Give some time to the PCI controller to configure itself with the new
2998 + * values. Not waiting at this point causes crashes of the machine. */
2999 + usleep_range(10000, 15000);
3000 + register_pci_controller(&pc_host->pci_controller);
3004 +/* Early PCI fixup for a device on the PCI-core bridge. */
3005 +static void bcma_core_pci_fixup_pcibridge(struct pci_dev *dev)
3007 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
3008 + /* This is not a device on the PCI-core bridge. */
3011 + if (PCI_SLOT(dev->devfn) != 0)
3014 + pr_info("PCI: Fixing up bridge %s\n", pci_name(dev));
3016 + /* Enable PCI bridge bus mastering and memory space */
3017 + pci_set_master(dev);
3018 + if (pcibios_enable_device(dev, ~0) < 0) {
3019 + pr_err("PCI: BCMA bridge enable failed\n");
3023 + /* Enable PCI bridge BAR1 prefetch and burst */
3024 + pci_write_config_dword(dev, BCMA_PCI_BAR1_CONTROL, 3);
3026 +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_pcibridge);
3028 +/* Early PCI fixup for all PCI-cores to set the correct memory address. */
3029 +static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
3031 + struct resource *res;
3034 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
3035 + /* This is not a device on the PCI-core bridge. */
3038 + if (PCI_SLOT(dev->devfn) == 0)
3041 + pr_info("PCI: Fixing up addresses %s\n", pci_name(dev));
3043 + for (pos = 0; pos < 6; pos++) {
3044 + res = &dev->resource[pos];
3045 + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) {
3046 + err = pci_assign_resource(dev, pos);
3048 + pr_err("PCI: Problem fixing up the addresses on %s\n",
3053 +DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
3055 +/* This function is called when doing a pci_enable_device().
3056 + * We must first check if the device is a device on the PCI-core bridge. */
3057 +int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
3059 + struct bcma_drv_pci_host *pc_host;
3062 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
3063 + /* This is not a device on the PCI-core bridge. */
3066 + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
3069 + pr_info("PCI: Fixing up device %s\n", pci_name(dev));
3071 + /* Fix up interrupt lines */
3072 + dev->irq = bcma_core_irq(pc_host->pdev->core);
3073 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
3075 + readrq = pcie_get_readrq(dev);
3076 + if (readrq > 128) {
3077 + pr_info("change PCIe max read request size from %i to 128\n", readrq);
3078 + pcie_set_readrq(dev, 128);
3082 +EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
3084 +/* PCI device IRQ mapping. */
3085 +int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev)
3087 + struct bcma_drv_pci_host *pc_host;
3089 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
3090 + /* This is not a device on the PCI-core bridge. */
3094 + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
3096 + return bcma_core_irq(pc_host->pdev->core);
3098 +EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
3099 --- a/drivers/bcma/host_pci.c
3100 +++ b/drivers/bcma/host_pci.c
3101 @@ -18,7 +18,7 @@ static void bcma_host_pci_switch_core(st
3102 pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN2,
3104 core->bus->mapped_core = core;
3105 - pr_debug("Switched to core: 0x%X\n", core->id.id);
3106 + bcma_debug(core->bus, "Switched to core: 0x%X\n", core->id.id);
3109 /* Provides access to the requested core. Returns base offset that has to be
3110 @@ -77,8 +77,8 @@ static void bcma_host_pci_write32(struct
3113 #ifdef CONFIG_BCMA_BLOCKIO
3114 -void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
3115 - size_t count, u16 offset, u8 reg_width)
3116 +static void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
3117 + size_t count, u16 offset, u8 reg_width)
3119 void __iomem *addr = core->bus->mmio + offset;
3120 if (core->bus->mapped_core != core)
3121 @@ -100,8 +100,9 @@ void bcma_host_pci_block_read(struct bcm
3125 -void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
3126 - size_t count, u16 offset, u8 reg_width)
3127 +static void bcma_host_pci_block_write(struct bcma_device *core,
3128 + const void *buffer, size_t count,
3129 + u16 offset, u8 reg_width)
3131 void __iomem *addr = core->bus->mmio + offset;
3132 if (core->bus->mapped_core != core)
3133 @@ -139,7 +140,7 @@ static void bcma_host_pci_awrite32(struc
3134 iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
3137 -const struct bcma_host_ops bcma_host_pci_ops = {
3138 +static const struct bcma_host_ops bcma_host_pci_ops = {
3139 .read8 = bcma_host_pci_read8,
3140 .read16 = bcma_host_pci_read16,
3141 .read32 = bcma_host_pci_read32,
3142 @@ -154,8 +155,8 @@ const struct bcma_host_ops bcma_host_pci
3143 .awrite32 = bcma_host_pci_awrite32,
3146 -static int bcma_host_pci_probe(struct pci_dev *dev,
3147 - const struct pci_device_id *id)
3148 +static int __devinit bcma_host_pci_probe(struct pci_dev *dev,
3149 + const struct pci_device_id *id)
3151 struct bcma_bus *bus;
3153 @@ -188,7 +189,7 @@ static int bcma_host_pci_probe(struct pc
3155 /* SSB needed additional powering up, do we have any AMBA PCI cards? */
3156 if (!pci_is_pcie(dev))
3157 - pr_err("PCI card detected, report problems.\n");
3158 + bcma_err(bus, "PCI card detected, report problems.\n");
3162 @@ -201,6 +202,9 @@ static int bcma_host_pci_probe(struct pc
3163 bus->hosttype = BCMA_HOSTTYPE_PCI;
3164 bus->ops = &bcma_host_pci_ops;
3166 + bus->boardinfo.vendor = bus->host_pci->subsystem_vendor;
3167 + bus->boardinfo.type = bus->host_pci->subsystem_device;
3170 err = bcma_bus_register(bus);
3172 @@ -222,7 +226,7 @@ err_kfree_bus:
3176 -static void bcma_host_pci_remove(struct pci_dev *dev)
3177 +static void __devexit bcma_host_pci_remove(struct pci_dev *dev)
3179 struct bcma_bus *bus = pci_get_drvdata(dev);
3181 @@ -234,7 +238,7 @@ static void bcma_host_pci_remove(struct
3182 pci_set_drvdata(dev, NULL);
3186 +#ifdef CONFIG_PM_SLEEP
3187 static int bcma_host_pci_suspend(struct device *dev)
3189 struct pci_dev *pdev = to_pci_dev(dev);
3190 @@ -257,17 +261,21 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
3191 bcma_host_pci_resume);
3192 #define BCMA_PM_OPS (&bcma_pm_ops)
3194 -#else /* CONFIG_PM */
3195 +#else /* CONFIG_PM_SLEEP */
3197 #define BCMA_PM_OPS NULL
3199 -#endif /* CONFIG_PM */
3200 +#endif /* CONFIG_PM_SLEEP */
3202 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
3203 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
3204 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) },
3205 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
3206 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
3207 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
3208 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
3209 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
3210 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
3211 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
3214 @@ -277,7 +285,7 @@ static struct pci_driver bcma_pci_bridge
3215 .name = "bcma-pci-bridge",
3216 .id_table = bcma_pci_bridge_tbl,
3217 .probe = bcma_host_pci_probe,
3218 - .remove = bcma_host_pci_remove,
3219 + .remove = __devexit_p(bcma_host_pci_remove),
3220 .driver.pm = BCMA_PM_OPS,
3223 --- a/drivers/bcma/host_soc.c
3224 +++ b/drivers/bcma/host_soc.c
3225 @@ -143,7 +143,7 @@ static void bcma_host_soc_awrite32(struc
3226 writel(value, core->io_wrap + offset);
3229 -const struct bcma_host_ops bcma_host_soc_ops = {
3230 +static const struct bcma_host_ops bcma_host_soc_ops = {
3231 .read8 = bcma_host_soc_read8,
3232 .read16 = bcma_host_soc_read16,
3233 .read32 = bcma_host_soc_read32,
3234 --- a/drivers/bcma/main.c
3235 +++ b/drivers/bcma/main.c
3238 #include "bcma_private.h"
3239 #include <linux/module.h>
3240 +#include <linux/platform_device.h>
3241 #include <linux/bcma/bcma.h>
3242 #include <linux/slab.h>
3244 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
3245 MODULE_LICENSE("GPL");
3247 +/* contains the number the next bus should get. */
3248 +static unsigned int bcma_bus_next_num = 0;
3250 +/* bcma_buses_mutex locks the bcma_bus_next_num */
3251 +static DEFINE_MUTEX(bcma_buses_mutex);
3253 static int bcma_bus_match(struct device *dev, struct device_driver *drv);
3254 static int bcma_device_probe(struct device *dev);
3255 static int bcma_device_remove(struct device *dev);
3256 @@ -55,7 +62,14 @@ static struct bus_type bcma_bus_type = {
3257 .dev_attrs = bcma_device_attrs,
3260 -static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
3261 +static u16 bcma_cc_core_id(struct bcma_bus *bus)
3263 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
3264 + return BCMA_CORE_4706_CHIPCOMMON;
3265 + return BCMA_CORE_CHIPCOMMON;
3268 +struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
3270 struct bcma_device *core;
3272 @@ -65,6 +79,38 @@ static struct bcma_device *bcma_find_cor
3276 +EXPORT_SYMBOL_GPL(bcma_find_core);
3278 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
3281 + struct bcma_device *core;
3283 + list_for_each_entry(core, &bus->cores, list) {
3284 + if (core->id.id == coreid && core->core_unit == unit)
3290 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
3293 + unsigned long deadline = jiffies + timeout;
3297 + val = bcma_read32(core, reg);
3298 + if ((val & mask) == value)
3302 + } while (!time_after_eq(jiffies, deadline));
3304 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
3309 static void bcma_release_core_dev(struct device *dev)
3311 @@ -84,16 +130,23 @@ static int bcma_register_cores(struct bc
3312 list_for_each_entry(core, &bus->cores, list) {
3313 /* We support that cores ourself */
3314 switch (core->id.id) {
3315 + case BCMA_CORE_4706_CHIPCOMMON:
3316 case BCMA_CORE_CHIPCOMMON:
3318 case BCMA_CORE_PCIE:
3319 case BCMA_CORE_MIPS_74K:
3320 + case BCMA_CORE_4706_MAC_GBIT_COMMON:
3324 + /* Only first GMAC core on BCM4706 is connected and working */
3325 + if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
3326 + core->core_unit > 0)
3329 core->dev.release = bcma_release_core_dev;
3330 core->dev.bus = &bcma_bus_type;
3331 - dev_set_name(&core->dev, "bcma%d:%d", 0/*bus->num*/, dev_id);
3332 + dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
3334 switch (bus->hosttype) {
3335 case BCMA_HOSTTYPE_PCI:
3336 @@ -111,41 +164,98 @@ static int bcma_register_cores(struct bc
3338 err = device_register(&core->dev);
3340 - pr_err("Could not register dev for core 0x%03X\n",
3343 + "Could not register dev for core 0x%03X\n",
3347 core->dev_registered = true;
3351 +#ifdef CONFIG_BCMA_DRIVER_MIPS
3352 + if (bus->drv_cc.pflash.present) {
3353 + err = platform_device_register(&bcma_pflash_dev);
3355 + bcma_err(bus, "Error registering parallel flash\n");
3359 +#ifdef CONFIG_BCMA_SFLASH
3360 + if (bus->drv_cc.sflash.present) {
3361 + err = platform_device_register(&bcma_sflash_dev);
3363 + bcma_err(bus, "Error registering serial flash\n");
3367 +#ifdef CONFIG_BCMA_NFLASH
3368 + if (bus->drv_cc.nflash.present) {
3369 + err = platform_device_register(&bcma_nflash_dev);
3371 + bcma_err(bus, "Error registering NAND flash\n");
3374 + err = bcma_gpio_init(&bus->drv_cc);
3375 + if (err == -ENOTSUPP)
3376 + bcma_debug(bus, "GPIO driver not activated\n");
3378 + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
3380 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
3381 + err = bcma_chipco_watchdog_register(&bus->drv_cc);
3383 + bcma_err(bus, "Error registering watchdog driver\n");
3389 static void bcma_unregister_cores(struct bcma_bus *bus)
3391 - struct bcma_device *core;
3392 + struct bcma_device *core, *tmp;
3394 - list_for_each_entry(core, &bus->cores, list) {
3395 + list_for_each_entry_safe(core, tmp, &bus->cores, list) {
3396 + list_del(&core->list);
3397 if (core->dev_registered)
3398 device_unregister(&core->dev);
3400 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
3401 + platform_device_unregister(bus->drv_cc.watchdog);
3404 -int bcma_bus_register(struct bcma_bus *bus)
3405 +int __devinit bcma_bus_register(struct bcma_bus *bus)
3408 struct bcma_device *core;
3410 + mutex_lock(&bcma_buses_mutex);
3411 + bus->num = bcma_bus_next_num++;
3412 + mutex_unlock(&bcma_buses_mutex);
3414 /* Scan for devices (cores) */
3415 err = bcma_bus_scan(bus);
3417 - pr_err("Failed to scan: %d\n", err);
3419 + bcma_err(bus, "Failed to scan: %d\n", err);
3423 + /* Early init CC core */
3424 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
3426 + bus->drv_cc.core = core;
3427 + bcma_core_chipcommon_early_init(&bus->drv_cc);
3430 + /* Try to get SPROM */
3431 + err = bcma_sprom_get(bus);
3432 + if (err == -ENOENT) {
3433 + bcma_err(bus, "No SPROM available\n");
3435 + bcma_err(bus, "Failed to get SPROM: %d\n", err);
3438 - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
3439 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
3441 bus->drv_cc.core = core;
3442 bcma_core_chipcommon_init(&bus->drv_cc);
3443 @@ -159,30 +269,54 @@ int bcma_bus_register(struct bcma_bus *b
3446 /* Init PCIE core */
3447 - core = bcma_find_core(bus, BCMA_CORE_PCIE);
3448 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
3450 - bus->drv_pci.core = core;
3451 - bcma_core_pci_init(&bus->drv_pci);
3452 + bus->drv_pci[0].core = core;
3453 + bcma_core_pci_init(&bus->drv_pci[0]);
3456 - /* Try to get SPROM */
3457 - err = bcma_sprom_get(bus);
3458 - if (err == -ENOENT) {
3459 - pr_err("No SPROM available\n");
3461 - pr_err("Failed to get SPROM: %d\n", err);
3462 + /* Init PCIE core */
3463 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
3465 + bus->drv_pci[1].core = core;
3466 + bcma_core_pci_init(&bus->drv_pci[1]);
3469 + /* Init GBIT MAC COMMON core */
3470 + core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
3472 + bus->drv_gmac_cmn.core = core;
3473 + bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
3476 /* Register found cores */
3477 bcma_register_cores(bus);
3479 - pr_info("Bus registered\n");
3480 + bcma_info(bus, "Bus registered\n");
3485 void bcma_bus_unregister(struct bcma_bus *bus)
3487 + struct bcma_device *cores[3];
3490 + err = bcma_gpio_unregister(&bus->drv_cc);
3491 + if (err == -EBUSY)
3492 + bcma_err(bus, "Some GPIOs are still in use.\n");
3494 + bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
3496 + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
3497 + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
3498 + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
3500 bcma_unregister_cores(bus);
3507 int __init bcma_bus_early_register(struct bcma_bus *bus,
3508 @@ -196,14 +330,14 @@ int __init bcma_bus_early_register(struc
3511 match.manuf = BCMA_MANUF_BCM;
3512 - match.id = BCMA_CORE_CHIPCOMMON;
3513 + match.id = bcma_cc_core_id(bus);
3514 match.class = BCMA_CL_SIM;
3515 match.rev = BCMA_ANY_REV;
3517 /* Scan for chip common core */
3518 err = bcma_bus_scan_early(bus, &match, core_cc);
3520 - pr_err("Failed to scan for common core: %d\n", err);
3521 + bcma_err(bus, "Failed to scan for common core: %d\n", err);
3525 @@ -215,25 +349,25 @@ int __init bcma_bus_early_register(struc
3526 /* Scan for mips core */
3527 err = bcma_bus_scan_early(bus, &match, core_mips);
3529 - pr_err("Failed to scan for mips core: %d\n", err);
3530 + bcma_err(bus, "Failed to scan for mips core: %d\n", err);
3534 - /* Init CC core */
3535 - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
3536 + /* Early init CC core */
3537 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
3539 bus->drv_cc.core = core;
3540 - bcma_core_chipcommon_init(&bus->drv_cc);
3541 + bcma_core_chipcommon_early_init(&bus->drv_cc);
3544 - /* Init MIPS core */
3545 + /* Early init MIPS core */
3546 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
3548 bus->drv_mips.core = core;
3549 - bcma_core_mips_init(&bus->drv_mips);
3550 + bcma_core_mips_early_init(&bus->drv_mips);
3553 - pr_info("Early bus registered\n");
3554 + bcma_info(bus, "Early bus registered\n");
3558 @@ -259,8 +393,7 @@ int bcma_bus_resume(struct bcma_bus *bus
3559 struct bcma_device *core;
3562 - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
3564 + if (bus->drv_cc.core) {
3565 bus->drv_cc.setup_done = false;
3566 bcma_core_chipcommon_init(&bus->drv_cc);
3568 --- a/drivers/bcma/scan.c
3569 +++ b/drivers/bcma/scan.c
3570 @@ -19,15 +19,39 @@ struct bcma_device_id_name {
3574 -struct bcma_device_id_name bcma_device_names[] = {
3576 +static const struct bcma_device_id_name bcma_arm_device_names[] = {
3577 + { BCMA_CORE_4706_MAC_GBIT_COMMON, "BCM4706 GBit MAC Common" },
3578 + { BCMA_CORE_ARM_1176, "ARM 1176" },
3579 + { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
3580 + { BCMA_CORE_ARM_CM3, "ARM CM3" },
3583 +static const struct bcma_device_id_name bcma_bcm_device_names[] = {
3584 { BCMA_CORE_OOB_ROUTER, "OOB Router" },
3585 + { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
3586 + { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
3587 + { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
3588 + { BCMA_CORE_PCIEG2, "PCIe Gen 2" },
3589 + { BCMA_CORE_DMA, "DMA" },
3590 + { BCMA_CORE_SDIO3, "SDIO3" },
3591 + { BCMA_CORE_USB20, "USB 2.0" },
3592 + { BCMA_CORE_USB30, "USB 3.0" },
3593 + { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" },
3594 + { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" },
3595 + { BCMA_CORE_ROM, "ROM" },
3596 + { BCMA_CORE_NAND, "NAND flash controller" },
3597 + { BCMA_CORE_QSPI, "SPI flash controller" },
3598 + { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" },
3599 + { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" },
3600 + { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
3601 + { BCMA_CORE_ALTA, "ALTA (I2S)" },
3602 { BCMA_CORE_INVALID, "Invalid" },
3603 { BCMA_CORE_CHIPCOMMON, "ChipCommon" },
3604 { BCMA_CORE_ILINE20, "ILine 20" },
3605 { BCMA_CORE_SRAM, "SRAM" },
3606 { BCMA_CORE_SDRAM, "SDRAM" },
3607 { BCMA_CORE_PCI, "PCI" },
3608 - { BCMA_CORE_MIPS, "MIPS" },
3609 { BCMA_CORE_ETHERNET, "Fast Ethernet" },
3610 { BCMA_CORE_V90, "V90" },
3611 { BCMA_CORE_USB11_HOSTDEV, "USB 1.1 Hostdev" },
3612 @@ -44,7 +68,6 @@ struct bcma_device_id_name bcma_device_n
3613 { BCMA_CORE_PHY_A, "PHY A" },
3614 { BCMA_CORE_PHY_B, "PHY B" },
3615 { BCMA_CORE_PHY_G, "PHY G" },
3616 - { BCMA_CORE_MIPS_3302, "MIPS 3302" },
3617 { BCMA_CORE_USB11_HOST, "USB 1.1 Host" },
3618 { BCMA_CORE_USB11_DEV, "USB 1.1 Device" },
3619 { BCMA_CORE_USB20_HOST, "USB 2.0 Host" },
3620 @@ -58,15 +81,11 @@ struct bcma_device_id_name bcma_device_n
3621 { BCMA_CORE_PHY_N, "PHY N" },
3622 { BCMA_CORE_SRAM_CTL, "SRAM Controller" },
3623 { BCMA_CORE_MINI_MACPHY, "Mini MACPHY" },
3624 - { BCMA_CORE_ARM_1176, "ARM 1176" },
3625 - { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
3626 { BCMA_CORE_PHY_LP, "PHY LP" },
3627 { BCMA_CORE_PMU, "PMU" },
3628 { BCMA_CORE_PHY_SSN, "PHY SSN" },
3629 { BCMA_CORE_SDIO_DEV, "SDIO Device" },
3630 - { BCMA_CORE_ARM_CM3, "ARM CM3" },
3631 { BCMA_CORE_PHY_HT, "PHY HT" },
3632 - { BCMA_CORE_MIPS_74K, "MIPS 74K" },
3633 { BCMA_CORE_MAC_GBIT, "GBit MAC" },
3634 { BCMA_CORE_DDR12_MEM_CTL, "DDR1/DDR2 Memory Controller" },
3635 { BCMA_CORE_PCIE_RC, "PCIe Root Complex" },
3636 @@ -77,18 +96,45 @@ struct bcma_device_id_name bcma_device_n
3637 { BCMA_CORE_I2S, "I2S" },
3638 { BCMA_CORE_SDR_DDR1_MEM_CTL, "SDR/DDR1 Memory Controller" },
3639 { BCMA_CORE_SHIM, "SHIM" },
3640 + { BCMA_CORE_PCIE2, "PCIe Gen2" },
3641 + { BCMA_CORE_ARM_CR4, "ARM CR4" },
3642 { BCMA_CORE_DEFAULT, "Default" },
3644 -const char *bcma_device_name(struct bcma_device_id *id)
3646 +static const struct bcma_device_id_name bcma_mips_device_names[] = {
3647 + { BCMA_CORE_MIPS, "MIPS" },
3648 + { BCMA_CORE_MIPS_3302, "MIPS 3302" },
3649 + { BCMA_CORE_MIPS_74K, "MIPS 74K" },
3652 +static const char *bcma_device_name(const struct bcma_device_id *id)
3655 + const struct bcma_device_id_name *names;
3658 - if (id->manuf == BCMA_MANUF_BCM) {
3659 - for (i = 0; i < ARRAY_SIZE(bcma_device_names); i++) {
3660 - if (bcma_device_names[i].id == id->id)
3661 - return bcma_device_names[i].name;
3663 + /* search manufacturer specific names */
3664 + switch (id->manuf) {
3665 + case BCMA_MANUF_ARM:
3666 + names = bcma_arm_device_names;
3667 + size = ARRAY_SIZE(bcma_arm_device_names);
3669 + case BCMA_MANUF_BCM:
3670 + names = bcma_bcm_device_names;
3671 + size = ARRAY_SIZE(bcma_bcm_device_names);
3673 + case BCMA_MANUF_MIPS:
3674 + names = bcma_mips_device_names;
3675 + size = ARRAY_SIZE(bcma_mips_device_names);
3681 + for (i = 0; i < size; i++) {
3682 + if (names[i].id == id->id)
3683 + return names[i].name;
3689 @@ -105,19 +151,19 @@ static void bcma_scan_switch_core(struct
3693 -static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 **eromptr)
3694 +static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 __iomem **eromptr)
3696 u32 ent = readl(*eromptr);
3701 -static void bcma_erom_push_ent(u32 **eromptr)
3702 +static void bcma_erom_push_ent(u32 __iomem **eromptr)
3707 -static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 **eromptr)
3708 +static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 __iomem **eromptr)
3710 u32 ent = bcma_erom_get_ent(bus, eromptr);
3711 if (!(ent & SCAN_ER_VALID))
3712 @@ -127,14 +173,14 @@ static s32 bcma_erom_get_ci(struct bcma_
3716 -static bool bcma_erom_is_end(struct bcma_bus *bus, u32 **eromptr)
3717 +static bool bcma_erom_is_end(struct bcma_bus *bus, u32 __iomem **eromptr)
3719 u32 ent = bcma_erom_get_ent(bus, eromptr);
3720 bcma_erom_push_ent(eromptr);
3721 return (ent == (SCAN_ER_TAG_END | SCAN_ER_VALID));
3724 -static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 **eromptr)
3725 +static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 __iomem **eromptr)
3727 u32 ent = bcma_erom_get_ent(bus, eromptr);
3728 bcma_erom_push_ent(eromptr);
3729 @@ -143,7 +189,7 @@ static bool bcma_erom_is_bridge(struct b
3730 ((ent & SCAN_ADDR_TYPE) == SCAN_ADDR_TYPE_BRIDGE));
3733 -static void bcma_erom_skip_component(struct bcma_bus *bus, u32 **eromptr)
3734 +static void bcma_erom_skip_component(struct bcma_bus *bus, u32 __iomem **eromptr)
3738 @@ -157,7 +203,7 @@ static void bcma_erom_skip_component(str
3739 bcma_erom_push_ent(eromptr);
3742 -static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr)
3743 +static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 __iomem **eromptr)
3745 u32 ent = bcma_erom_get_ent(bus, eromptr);
3746 if (!(ent & SCAN_ER_VALID))
3747 @@ -167,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct
3751 -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 **eromptr,
3752 +static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
3755 u32 addrl, addrh, sizel, sizeh = 0;
3756 @@ -179,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc
3757 ((ent & SCAN_ADDR_TYPE) != type) ||
3758 (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
3759 bcma_erom_push_ent(eromptr);
3761 + return (u32)-EINVAL;
3764 addrl = ent & SCAN_ADDR_ADDR;
3765 @@ -212,11 +258,24 @@ static struct bcma_device *bcma_find_cor
3769 +static struct bcma_device *bcma_find_core_reverse(struct bcma_bus *bus, u16 coreid)
3771 + struct bcma_device *core;
3773 + list_for_each_entry_reverse(core, &bus->cores, list) {
3774 + if (core->id.id == coreid)
3780 +#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
3782 static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
3783 struct bcma_device_id *match, int core_num,
3784 struct bcma_device *core)
3790 u8 ports[2], wrappers[2];
3791 @@ -252,11 +311,15 @@ static int bcma_get_next_core(struct bcm
3793 /* check if component is a core at all */
3794 if (wrappers[0] + wrappers[1] == 0) {
3795 - /* we could save addrl of the router
3796 - if (cid == BCMA_CORE_OOB_ROUTER)
3798 - bcma_erom_skip_component(bus, eromptr);
3800 + /* Some specific cores don't need wrappers */
3801 + switch (core->id.id) {
3802 + case BCMA_CORE_4706_MAC_GBIT_COMMON:
3803 + /* Not used yet: case BCMA_CORE_OOB_ROUTER: */
3806 + bcma_erom_skip_component(bus, eromptr);
3811 if (bcma_erom_is_bridge(bus, eromptr)) {
3812 @@ -286,19 +349,36 @@ static int bcma_get_next_core(struct bcm
3816 + /* First Slave Address Descriptor should be port 0:
3817 + * the main register space for the core
3819 + tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
3820 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
3821 + /* Try again to see if it is a bridge */
3822 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
3823 + SCAN_ADDR_TYPE_BRIDGE, 0);
3824 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
3827 + bcma_info(bus, "Bridge found\n");
3833 /* get & parse slave ports */
3834 for (i = 0; i < ports[1]; i++) {
3835 for (j = 0; ; j++) {
3836 tmp = bcma_erom_get_addr_desc(bus, eromptr,
3837 SCAN_ADDR_TYPE_SLAVE, i);
3839 + if (IS_ERR_VALUE_U32(tmp)) {
3840 /* no more entries for port _i_ */
3841 /* pr_debug("erom: slave port %d "
3842 * "has %d descriptors\n", i, j); */
3845 if (i == 0 && j == 0)
3847 + core->addr1 = tmp;
3851 @@ -308,7 +388,7 @@ static int bcma_get_next_core(struct bcm
3852 for (j = 0; ; j++) {
3853 tmp = bcma_erom_get_addr_desc(bus, eromptr,
3854 SCAN_ADDR_TYPE_MWRAP, i);
3856 + if (IS_ERR_VALUE_U32(tmp)) {
3857 /* no more entries for port _i_ */
3858 /* pr_debug("erom: master wrapper %d "
3859 * "has %d descriptors\n", i, j); */
3860 @@ -326,7 +406,7 @@ static int bcma_get_next_core(struct bcm
3861 for (j = 0; ; j++) {
3862 tmp = bcma_erom_get_addr_desc(bus, eromptr,
3863 SCAN_ADDR_TYPE_SWRAP, i + hack);
3865 + if (IS_ERR_VALUE_U32(tmp)) {
3866 /* no more entries for port _i_ */
3867 /* pr_debug("erom: master wrapper %d "
3868 * has %d descriptors\n", i, j); */
3869 @@ -353,6 +433,7 @@ static int bcma_get_next_core(struct bcm
3870 void bcma_init_bus(struct bcma_bus *bus)
3873 + struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
3877 @@ -363,9 +444,12 @@ void bcma_init_bus(struct bcma_bus *bus)
3878 bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
3880 tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
3881 - bus->chipinfo.id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
3882 - bus->chipinfo.rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
3883 - bus->chipinfo.pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
3884 + chipinfo->id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
3885 + chipinfo->rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
3886 + chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
3887 + bcma_info(bus, "Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
3888 + chipinfo->id, chipinfo->rev, chipinfo->pkg);
3890 bus->init_done = true;
3893 @@ -392,9 +476,12 @@ int bcma_bus_scan(struct bcma_bus *bus)
3894 bcma_scan_switch_core(bus, erombase);
3896 while (eromptr < eromend) {
3897 + struct bcma_device *other_core;
3898 struct bcma_device *core = kzalloc(sizeof(*core), GFP_KERNEL);
3905 INIT_LIST_HEAD(&core->list);
3908 @@ -409,25 +496,28 @@ int bcma_bus_scan(struct bcma_bus *bus)
3909 } else if (err == -ESPIPE) {
3916 core->core_index = core_num++;
3918 + other_core = bcma_find_core_reverse(bus, core->id.id);
3919 + core->core_unit = (other_core == NULL) ? 0 : other_core->core_unit + 1;
3921 - pr_info("Core %d found: %s "
3922 - "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
3923 - core->core_index, bcma_device_name(&core->id),
3924 - core->id.manuf, core->id.id, core->id.rev,
3926 + bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
3927 + core->core_index, bcma_device_name(&core->id),
3928 + core->id.manuf, core->id.id, core->id.rev,
3931 - list_add(&core->list, &bus->cores);
3932 + list_add_tail(&core->list, &bus->cores);
3937 if (bus->hosttype == BCMA_HOSTTYPE_SOC)
3944 int __init bcma_bus_scan_early(struct bcma_bus *bus,
3945 @@ -467,21 +557,21 @@ int __init bcma_bus_scan_early(struct bc
3946 else if (err == -ESPIPE)
3952 core->core_index = core_num++;
3954 - pr_info("Core %d found: %s "
3955 - "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
3956 - core->core_index, bcma_device_name(&core->id),
3957 - core->id.manuf, core->id.id, core->id.rev,
3959 + bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
3960 + core->core_index, bcma_device_name(&core->id),
3961 + core->id.manuf, core->id.id, core->id.rev,
3964 - list_add(&core->list, &bus->cores);
3965 + list_add_tail(&core->list, &bus->cores);
3971 if (bus->hosttype == BCMA_HOSTTYPE_SOC)
3974 --- a/drivers/bcma/scan.h
3975 +++ b/drivers/bcma/scan.h
3977 #define SCAN_CIB_NMW 0x0007C000
3978 #define SCAN_CIB_NMW_SHIFT 14
3979 #define SCAN_CIB_NSW 0x00F80000
3980 -#define SCAN_CIB_NSW_SHIFT 17
3981 +#define SCAN_CIB_NSW_SHIFT 19
3982 #define SCAN_CIB_REV 0xFF000000
3983 #define SCAN_CIB_REV_SHIFT 24
3985 --- a/drivers/bcma/sprom.c
3986 +++ b/drivers/bcma/sprom.c
3988 * Broadcom specific AMBA
3991 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
3993 * Licensed under the GNU/GPL. See COPYING for details.
3997 #include <linux/dma-mapping.h>
3998 #include <linux/slab.h>
4000 -#define SPOFF(offset) ((offset) / sizeof(u16))
4001 +static int(*get_fallback_sprom)(struct bcma_bus *dev, struct ssb_sprom *out);
4004 + * bcma_arch_register_fallback_sprom - Registers a method providing a
4005 + * fallback SPROM if no SPROM is found.
4007 + * @sprom_callback: The callback function.
4009 + * With this function the architecture implementation may register a
4010 + * callback handler which fills the SPROM data structure. The fallback is
4011 + * used for PCI based BCMA devices, where no valid SPROM can be found
4012 + * in the shadow registers and to provide the SPROM for SoCs where BCMA is
4013 + * to controll the system bus.
4015 + * This function is useful for weird architectures that have a half-assed
4016 + * BCMA device hardwired to their PCI bus.
4018 + * This function is available for architecture code, only. So it is not
4021 +int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus,
4022 + struct ssb_sprom *out))
4024 + if (get_fallback_sprom)
4026 + get_fallback_sprom = sprom_callback;
4031 +static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus,
4032 + struct ssb_sprom *out)
4036 + if (!get_fallback_sprom) {
4041 + err = get_fallback_sprom(bus, out);
4045 + bcma_debug(bus, "Using SPROM revision %d provided by platform.\n",
4046 + bus->sprom.revision);
4049 + bcma_warn(bus, "Using fallback SPROM failed (err %d)\n", err);
4053 /**************************************************
4055 **************************************************/
4057 -static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
4058 +static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom,
4062 - for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
4063 - sprom[i] = bcma_read16(bus->drv_cc.core,
4064 - offset + (i * 2));
4065 + for (i = 0; i < words; i++)
4066 + sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2));
4069 /**************************************************
4070 @@ -72,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da
4071 return t[crc ^ data];
4074 -static u8 bcma_sprom_crc(const u16 *sprom)
4075 +static u8 bcma_sprom_crc(const u16 *sprom, size_t words)
4080 - for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
4081 + for (word = 0; word < words - 1; word++) {
4082 crc = bcma_crc8(crc, sprom[word] & 0x00FF);
4083 crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
4085 - crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
4086 + crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF);
4092 -static int bcma_sprom_check_crc(const u16 *sprom)
4093 +static int bcma_sprom_check_crc(const u16 *sprom, size_t words)
4099 - crc = bcma_sprom_crc(sprom);
4100 - tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
4101 + crc = bcma_sprom_crc(sprom, words);
4102 + tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC;
4103 expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
4104 if (crc != expected_crc)
4106 @@ -102,21 +154,25 @@ static int bcma_sprom_check_crc(const u1
4110 -static int bcma_sprom_valid(const u16 *sprom)
4111 +static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom,
4117 - err = bcma_sprom_check_crc(sprom);
4118 + err = bcma_sprom_check_crc(sprom, words);
4122 - revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
4123 - if (revision != 8 && revision != 9) {
4124 + revision = sprom[words - 1] & SSB_SPROM_REVISION_REV;
4125 + if (revision != 8 && revision != 9 && revision != 10) {
4126 pr_err("Unsupported SPROM revision: %d\n", revision);
4130 + bus->sprom.revision = revision;
4131 + bcma_debug(bus, "Found SPROM revision %d\n", revision);
4136 @@ -124,124 +180,439 @@ static int bcma_sprom_valid(const u16 *s
4138 **************************************************/
4140 +#define SPOFF(offset) ((offset) / sizeof(u16))
4142 +#define SPEX(_field, _offset, _mask, _shift) \
4143 + bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
4145 +#define SPEX32(_field, _offset, _mask, _shift) \
4146 + bus->sprom._field = ((((u32)sprom[SPOFF((_offset)+2)] << 16 | \
4147 + sprom[SPOFF(_offset)]) & (_mask)) >> (_shift))
4149 +#define SPEX_ARRAY8(_field, _offset, _mask, _shift) \
4151 + SPEX(_field[0], _offset + 0, _mask, _shift); \
4152 + SPEX(_field[1], _offset + 2, _mask, _shift); \
4153 + SPEX(_field[2], _offset + 4, _mask, _shift); \
4154 + SPEX(_field[3], _offset + 6, _mask, _shift); \
4155 + SPEX(_field[4], _offset + 8, _mask, _shift); \
4156 + SPEX(_field[5], _offset + 10, _mask, _shift); \
4157 + SPEX(_field[6], _offset + 12, _mask, _shift); \
4158 + SPEX(_field[7], _offset + 14, _mask, _shift); \
4161 static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
4167 - bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
4168 - SSB_SPROM_REVISION_REV;
4169 + u16 pwr_info_offset[] = {
4170 + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
4171 + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
4173 + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
4174 + ARRAY_SIZE(bus->sprom.core_pwr_info));
4176 for (i = 0; i < 3; i++) {
4177 v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
4178 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
4181 - bus->sprom.board_rev = sprom[SPOFF(SSB_SPROM8_BOARDREV)];
4182 + SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
4183 + SPEX(board_type, SSB_SPROM1_SPID, ~0, 0);
4185 + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
4186 + SSB_SPROM4_TXPID2G0_SHIFT);
4187 + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1,
4188 + SSB_SPROM4_TXPID2G1_SHIFT);
4189 + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2,
4190 + SSB_SPROM4_TXPID2G2_SHIFT);
4191 + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3,
4192 + SSB_SPROM4_TXPID2G3_SHIFT);
4194 + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0,
4195 + SSB_SPROM4_TXPID5GL0_SHIFT);
4196 + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1,
4197 + SSB_SPROM4_TXPID5GL1_SHIFT);
4198 + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2,
4199 + SSB_SPROM4_TXPID5GL2_SHIFT);
4200 + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3,
4201 + SSB_SPROM4_TXPID5GL3_SHIFT);
4203 + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0,
4204 + SSB_SPROM4_TXPID5G0_SHIFT);
4205 + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1,
4206 + SSB_SPROM4_TXPID5G1_SHIFT);
4207 + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2,
4208 + SSB_SPROM4_TXPID5G2_SHIFT);
4209 + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3,
4210 + SSB_SPROM4_TXPID5G3_SHIFT);
4212 + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0,
4213 + SSB_SPROM4_TXPID5GH0_SHIFT);
4214 + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1,
4215 + SSB_SPROM4_TXPID5GH1_SHIFT);
4216 + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2,
4217 + SSB_SPROM4_TXPID5GH2_SHIFT);
4218 + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3,
4219 + SSB_SPROM4_TXPID5GH3_SHIFT);
4221 + SPEX(boardflags_lo, SSB_SPROM8_BFLLO, ~0, 0);
4222 + SPEX(boardflags_hi, SSB_SPROM8_BFLHI, ~0, 0);
4223 + SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0);
4224 + SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0);
4226 + SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
4227 + SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);
4229 + /* Extract cores power info info */
4230 + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
4231 + o = pwr_info_offset[i];
4232 + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
4233 + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
4234 + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
4235 + SSB_SPROM8_2G_MAXP, 0);
4237 + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
4238 + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
4239 + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
4241 + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
4242 + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
4243 + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
4244 + SSB_SPROM8_5G_MAXP, 0);
4245 + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
4246 + SSB_SPROM8_5GH_MAXP, 0);
4247 + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
4248 + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
4250 + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
4251 + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
4252 + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
4253 + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
4254 + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
4255 + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
4256 + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
4257 + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
4258 + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
4261 + SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS,
4262 + SSB_SROM8_FEM_TSSIPOS_SHIFT);
4263 + SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN,
4264 + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
4265 + SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE,
4266 + SSB_SROM8_FEM_PDET_RANGE_SHIFT);
4267 + SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO,
4268 + SSB_SROM8_FEM_TR_ISO_SHIFT);
4269 + SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT,
4270 + SSB_SROM8_FEM_ANTSWLUT_SHIFT);
4272 + SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS,
4273 + SSB_SROM8_FEM_TSSIPOS_SHIFT);
4274 + SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN,
4275 + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
4276 + SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE,
4277 + SSB_SROM8_FEM_PDET_RANGE_SHIFT);
4278 + SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO,
4279 + SSB_SROM8_FEM_TR_ISO_SHIFT);
4280 + SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT,
4281 + SSB_SROM8_FEM_ANTSWLUT_SHIFT);
4283 + SPEX(ant_available_a, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_A,
4284 + SSB_SPROM8_ANTAVAIL_A_SHIFT);
4285 + SPEX(ant_available_bg, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_BG,
4286 + SSB_SPROM8_ANTAVAIL_BG_SHIFT);
4287 + SPEX(maxpwr_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_MAXP_BG_MASK, 0);
4288 + SPEX(itssi_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_ITSSI_BG,
4289 + SSB_SPROM8_ITSSI_BG_SHIFT);
4290 + SPEX(maxpwr_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_MAXP_A_MASK, 0);
4291 + SPEX(itssi_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_ITSSI_A,
4292 + SSB_SPROM8_ITSSI_A_SHIFT);
4293 + SPEX(maxpwr_ah, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AH_MASK, 0);
4294 + SPEX(maxpwr_al, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AL_MASK,
4295 + SSB_SPROM8_MAXP_AL_SHIFT);
4296 + SPEX(gpio0, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P0, 0);
4297 + SPEX(gpio1, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P1,
4298 + SSB_SPROM8_GPIOA_P1_SHIFT);
4299 + SPEX(gpio2, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P2, 0);
4300 + SPEX(gpio3, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P3,
4301 + SSB_SPROM8_GPIOB_P3_SHIFT);
4302 + SPEX(tri2g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI2G, 0);
4303 + SPEX(tri5g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI5G,
4304 + SSB_SPROM8_TRI5G_SHIFT);
4305 + SPEX(tri5gl, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GL, 0);
4306 + SPEX(tri5gh, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GH,
4307 + SSB_SPROM8_TRI5GH_SHIFT);
4308 + SPEX(rxpo2g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO2G,
4309 + SSB_SPROM8_RXPO2G_SHIFT);
4310 + SPEX(rxpo5g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO5G,
4311 + SSB_SPROM8_RXPO5G_SHIFT);
4312 + SPEX(rssismf2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMF2G, 0);
4313 + SPEX(rssismc2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMC2G,
4314 + SSB_SPROM8_RSSISMC2G_SHIFT);
4315 + SPEX(rssisav2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISAV2G,
4316 + SSB_SPROM8_RSSISAV2G_SHIFT);
4317 + SPEX(bxa2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_BXA2G,
4318 + SSB_SPROM8_BXA2G_SHIFT);
4319 + SPEX(rssismf5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMF5G, 0);
4320 + SPEX(rssismc5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMC5G,
4321 + SSB_SPROM8_RSSISMC5G_SHIFT);
4322 + SPEX(rssisav5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISAV5G,
4323 + SSB_SPROM8_RSSISAV5G_SHIFT);
4324 + SPEX(bxa5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_BXA5G,
4325 + SSB_SPROM8_BXA5G_SHIFT);
4327 + SPEX(pa0b0, SSB_SPROM8_PA0B0, ~0, 0);
4328 + SPEX(pa0b1, SSB_SPROM8_PA0B1, ~0, 0);
4329 + SPEX(pa0b2, SSB_SPROM8_PA0B2, ~0, 0);
4330 + SPEX(pa1b0, SSB_SPROM8_PA1B0, ~0, 0);
4331 + SPEX(pa1b1, SSB_SPROM8_PA1B1, ~0, 0);
4332 + SPEX(pa1b2, SSB_SPROM8_PA1B2, ~0, 0);
4333 + SPEX(pa1lob0, SSB_SPROM8_PA1LOB0, ~0, 0);
4334 + SPEX(pa1lob1, SSB_SPROM8_PA1LOB1, ~0, 0);
4335 + SPEX(pa1lob2, SSB_SPROM8_PA1LOB2, ~0, 0);
4336 + SPEX(pa1hib0, SSB_SPROM8_PA1HIB0, ~0, 0);
4337 + SPEX(pa1hib1, SSB_SPROM8_PA1HIB1, ~0, 0);
4338 + SPEX(pa1hib2, SSB_SPROM8_PA1HIB2, ~0, 0);
4339 + SPEX(cck2gpo, SSB_SPROM8_CCK2GPO, ~0, 0);
4340 + SPEX32(ofdm2gpo, SSB_SPROM8_OFDM2GPO, ~0, 0);
4341 + SPEX32(ofdm5glpo, SSB_SPROM8_OFDM5GLPO, ~0, 0);
4342 + SPEX32(ofdm5gpo, SSB_SPROM8_OFDM5GPO, ~0, 0);
4343 + SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, ~0, 0);
4345 + /* Extract the antenna gain values. */
4346 + SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
4347 + SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
4348 + SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
4349 + SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
4350 + SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
4351 + SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
4352 + SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
4353 + SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
4355 + SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
4356 + SSB_SPROM8_LEDDC_ON_SHIFT);
4357 + SPEX(leddc_off_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_OFF,
4358 + SSB_SPROM8_LEDDC_OFF_SHIFT);
4360 + SPEX(txchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_TXCHAIN,
4361 + SSB_SPROM8_TXRXC_TXCHAIN_SHIFT);
4362 + SPEX(rxchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_RXCHAIN,
4363 + SSB_SPROM8_TXRXC_RXCHAIN_SHIFT);
4364 + SPEX(antswitch, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_SWITCH,
4365 + SSB_SPROM8_TXRXC_SWITCH_SHIFT);
4367 + SPEX(opo, SSB_SPROM8_OFDM2GPO, 0x00ff, 0);
4369 + SPEX_ARRAY8(mcs2gpo, SSB_SPROM8_2G_MCSPO, ~0, 0);
4370 + SPEX_ARRAY8(mcs5gpo, SSB_SPROM8_5G_MCSPO, ~0, 0);
4371 + SPEX_ARRAY8(mcs5glpo, SSB_SPROM8_5GL_MCSPO, ~0, 0);
4372 + SPEX_ARRAY8(mcs5ghpo, SSB_SPROM8_5GH_MCSPO, ~0, 0);
4374 + SPEX(rawtempsense, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_RAWTEMP,
4375 + SSB_SPROM8_RAWTS_RAWTEMP_SHIFT);
4376 + SPEX(measpower, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_MEASPOWER,
4377 + SSB_SPROM8_RAWTS_MEASPOWER_SHIFT);
4378 + SPEX(tempsense_slope, SSB_SPROM8_OPT_CORRX,
4379 + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE,
4380 + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT);
4381 + SPEX(tempcorrx, SSB_SPROM8_OPT_CORRX, SSB_SPROM8_OPT_CORRX_TEMPCORRX,
4382 + SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT);
4383 + SPEX(tempsense_option, SSB_SPROM8_OPT_CORRX,
4384 + SSB_SPROM8_OPT_CORRX_TEMP_OPTION,
4385 + SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT);
4386 + SPEX(freqoffset_corr, SSB_SPROM8_HWIQ_IQSWP,
4387 + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR,
4388 + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT);
4389 + SPEX(iqcal_swp_dis, SSB_SPROM8_HWIQ_IQSWP,
4390 + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP,
4391 + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT);
4392 + SPEX(hw_iqcal_en, SSB_SPROM8_HWIQ_IQSWP, SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL,
4393 + SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT);
4395 + SPEX(bw40po, SSB_SPROM8_BW40PO, ~0, 0);
4396 + SPEX(cddpo, SSB_SPROM8_CDDPO, ~0, 0);
4397 + SPEX(stbcpo, SSB_SPROM8_STBCPO, ~0, 0);
4398 + SPEX(bwduppo, SSB_SPROM8_BWDUPPO, ~0, 0);
4400 + SPEX(tempthresh, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_TRESH,
4401 + SSB_SPROM8_THERMAL_TRESH_SHIFT);
4402 + SPEX(tempoffset, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_OFFSET,
4403 + SSB_SPROM8_THERMAL_OFFSET_SHIFT);
4404 + SPEX(phycal_tempdelta, SSB_SPROM8_TEMPDELTA,
4405 + SSB_SPROM8_TEMPDELTA_PHYCAL,
4406 + SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT);
4407 + SPEX(temps_period, SSB_SPROM8_TEMPDELTA, SSB_SPROM8_TEMPDELTA_PERIOD,
4408 + SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT);
4409 + SPEX(temps_hysteresis, SSB_SPROM8_TEMPDELTA,
4410 + SSB_SPROM8_TEMPDELTA_HYSTERESIS,
4411 + SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT);
4415 + * Indicates the presence of external SPROM.
4417 +static bool bcma_sprom_ext_available(struct bcma_bus *bus)
4423 + if (bus->drv_cc.core->id.rev >= 31) {
4424 + if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
4427 + srom_control = bcma_read32(bus->drv_cc.core,
4428 + BCMA_CC_SROM_CONTROL);
4429 + return srom_control & BCMA_CC_SROM_CONTROL_PRESENT;
4432 + /* older chipcommon revisions use chip status register */
4433 + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
4434 + switch (bus->chipinfo.id) {
4435 + case BCMA_CHIP_ID_BCM4313:
4436 + present_mask = BCMA_CC_CHIPST_4313_SPROM_PRESENT;
4439 + case BCMA_CHIP_ID_BCM4331:
4440 + present_mask = BCMA_CC_CHIPST_4331_SPROM_PRESENT;
4443 - bus->sprom.txpid2g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
4444 - SSB_SPROM4_TXPID2G0) >> SSB_SPROM4_TXPID2G0_SHIFT;
4445 - bus->sprom.txpid2g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
4446 - SSB_SPROM4_TXPID2G1) >> SSB_SPROM4_TXPID2G1_SHIFT;
4447 - bus->sprom.txpid2g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
4448 - SSB_SPROM4_TXPID2G2) >> SSB_SPROM4_TXPID2G2_SHIFT;
4449 - bus->sprom.txpid2g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
4450 - SSB_SPROM4_TXPID2G3) >> SSB_SPROM4_TXPID2G3_SHIFT;
4452 - bus->sprom.txpid5gl[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
4453 - SSB_SPROM4_TXPID5GL0) >> SSB_SPROM4_TXPID5GL0_SHIFT;
4454 - bus->sprom.txpid5gl[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
4455 - SSB_SPROM4_TXPID5GL1) >> SSB_SPROM4_TXPID5GL1_SHIFT;
4456 - bus->sprom.txpid5gl[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
4457 - SSB_SPROM4_TXPID5GL2) >> SSB_SPROM4_TXPID5GL2_SHIFT;
4458 - bus->sprom.txpid5gl[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
4459 - SSB_SPROM4_TXPID5GL3) >> SSB_SPROM4_TXPID5GL3_SHIFT;
4461 - bus->sprom.txpid5g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
4462 - SSB_SPROM4_TXPID5G0) >> SSB_SPROM4_TXPID5G0_SHIFT;
4463 - bus->sprom.txpid5g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
4464 - SSB_SPROM4_TXPID5G1) >> SSB_SPROM4_TXPID5G1_SHIFT;
4465 - bus->sprom.txpid5g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
4466 - SSB_SPROM4_TXPID5G2) >> SSB_SPROM4_TXPID5G2_SHIFT;
4467 - bus->sprom.txpid5g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
4468 - SSB_SPROM4_TXPID5G3) >> SSB_SPROM4_TXPID5G3_SHIFT;
4470 - bus->sprom.txpid5gh[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
4471 - SSB_SPROM4_TXPID5GH0) >> SSB_SPROM4_TXPID5GH0_SHIFT;
4472 - bus->sprom.txpid5gh[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
4473 - SSB_SPROM4_TXPID5GH1) >> SSB_SPROM4_TXPID5GH1_SHIFT;
4474 - bus->sprom.txpid5gh[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
4475 - SSB_SPROM4_TXPID5GH2) >> SSB_SPROM4_TXPID5GH2_SHIFT;
4476 - bus->sprom.txpid5gh[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
4477 - SSB_SPROM4_TXPID5GH3) >> SSB_SPROM4_TXPID5GH3_SHIFT;
4479 - bus->sprom.boardflags_lo = sprom[SPOFF(SSB_SPROM8_BFLLO)];
4480 - bus->sprom.boardflags_hi = sprom[SPOFF(SSB_SPROM8_BFLHI)];
4481 - bus->sprom.boardflags2_lo = sprom[SPOFF(SSB_SPROM8_BFL2LO)];
4482 - bus->sprom.boardflags2_hi = sprom[SPOFF(SSB_SPROM8_BFL2HI)];
4484 - bus->sprom.country_code = sprom[SPOFF(SSB_SPROM8_CCODE)];
4486 - bus->sprom.fem.ghz2.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
4487 - SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
4488 - bus->sprom.fem.ghz2.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
4489 - SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
4490 - bus->sprom.fem.ghz2.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
4491 - SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
4492 - bus->sprom.fem.ghz2.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
4493 - SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
4494 - bus->sprom.fem.ghz2.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
4495 - SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
4497 - bus->sprom.fem.ghz5.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
4498 - SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
4499 - bus->sprom.fem.ghz5.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
4500 - SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
4501 - bus->sprom.fem.ghz5.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
4502 - SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
4503 - bus->sprom.fem.ghz5.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
4504 - SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
4505 - bus->sprom.fem.ghz5.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
4506 - SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
4511 + return chip_status & present_mask;
4515 + * Indicates that on-chip OTP memory is present and enabled.
4517 +static bool bcma_sprom_onchip_available(struct bcma_bus *bus)
4523 + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
4524 + switch (bus->chipinfo.id) {
4525 + case BCMA_CHIP_ID_BCM4313:
4526 + present = chip_status & BCMA_CC_CHIPST_4313_OTP_PRESENT;
4529 + case BCMA_CHIP_ID_BCM4331:
4530 + present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
4532 + case BCMA_CHIP_ID_BCM43142:
4533 + case BCMA_CHIP_ID_BCM43224:
4534 + case BCMA_CHIP_ID_BCM43225:
4535 + /* for these chips OTP is always available */
4538 + case BCMA_CHIP_ID_BCM43227:
4539 + case BCMA_CHIP_ID_BCM43228:
4540 + case BCMA_CHIP_ID_BCM43428:
4541 + present = chip_status & BCMA_CC_CHIPST_43228_OTP_PRESENT;
4549 + otpsize = bus->drv_cc.capabilities & BCMA_CC_CAP_OTPS;
4550 + otpsize >>= BCMA_CC_CAP_OTPS_SHIFT;
4553 + return otpsize != 0;
4557 + * Verify OTP is filled and determine the byte
4558 + * offset where SPROM data is located.
4560 + * On error, returns 0; byte offset otherwise.
4562 +static int bcma_sprom_onchip_offset(struct bcma_bus *bus)
4564 + struct bcma_device *cc = bus->drv_cc.core;
4567 + /* verify OTP status */
4568 + if ((bcma_read32(cc, BCMA_CC_OTPS) & BCMA_CC_OTPS_GU_PROG_HW) == 0)
4571 + /* obtain bit offset from otplayout register */
4572 + offset = (bcma_read32(cc, BCMA_CC_OTPL) & BCMA_CC_OTPL_GURGN_OFFSET);
4573 + return BCMA_CC_SPROM + (offset >> 3);
4576 int bcma_sprom_get(struct bcma_bus *bus)
4579 + u16 offset = BCMA_CC_SPROM;
4582 + size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
4583 + SSB_SPROMSIZE_WORDS_R10, };
4586 if (!bus->drv_cc.core)
4589 - if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
4591 + if (!bcma_sprom_ext_available(bus)) {
4592 + bool sprom_onchip;
4594 - sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
4599 + * External SPROM takes precedence so check
4600 + * on-chip OTP only when no external SPROM
4603 + sprom_onchip = bcma_sprom_onchip_available(bus);
4604 + if (sprom_onchip) {
4605 + /* determine offset */
4606 + offset = bcma_sprom_onchip_offset(bus);
4608 + if (!offset || !sprom_onchip) {
4610 + * Maybe there is no SPROM on the device?
4611 + * Now we ask the arch code if there is some sprom
4612 + * available for this device in some other storage.
4614 + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
4619 - if (bus->chipinfo.id == 0x4331)
4620 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
4621 + bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
4622 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
4624 - /* Most cards have SPROM moved by additional offset 0x30 (48 dwords).
4625 - * According to brcm80211 this applies to cards with PCIe rev >= 6
4626 - * TODO: understand this condition and use it */
4627 - offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM :
4628 - BCMA_CC_SPROM_PCIE6;
4629 - bcma_sprom_read(bus, offset, sprom);
4630 + bcma_debug(bus, "SPROM offset 0x%x\n", offset);
4631 + for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
4632 + size_t words = sprom_sizes[i];
4634 + sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
4638 + bcma_sprom_read(bus, offset, sprom, words);
4639 + err = bcma_sprom_valid(bus, sprom, words);
4643 - if (bus->chipinfo.id == 0x4331)
4644 - bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
4648 - err = bcma_sprom_valid(sprom);
4651 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
4652 + bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
4653 + bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
4655 - bcma_sprom_extract_r8(bus, sprom);
4657 + bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n");
4658 + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
4660 + bcma_sprom_extract_r8(bus, sprom);
4668 --- a/include/linux/bcma/bcma.h
4669 +++ b/include/linux/bcma/bcma.h
4671 #include <linux/bcma/bcma_driver_chipcommon.h>
4672 #include <linux/bcma/bcma_driver_pci.h>
4673 #include <linux/bcma/bcma_driver_mips.h>
4674 +#include <linux/bcma/bcma_driver_gmac_cmn.h>
4675 #include <linux/ssb/ssb.h> /* SPROM sharing */
4677 -#include "bcma_regs.h"
4678 +#include <linux/bcma/bcma_regs.h>
4682 @@ -26,6 +27,11 @@ struct bcma_chipinfo {
4686 +struct bcma_boardinfo {
4693 BCMA_CLKMODE_DYNAMIC,
4694 @@ -65,6 +71,25 @@ struct bcma_host_ops {
4696 /* Core-ID values. */
4697 #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
4698 +#define BCMA_CORE_4706_CHIPCOMMON 0x500
4699 +#define BCMA_CORE_PCIEG2 0x501
4700 +#define BCMA_CORE_DMA 0x502
4701 +#define BCMA_CORE_SDIO3 0x503
4702 +#define BCMA_CORE_USB20 0x504
4703 +#define BCMA_CORE_USB30 0x505
4704 +#define BCMA_CORE_A9JTAG 0x506
4705 +#define BCMA_CORE_DDR23 0x507
4706 +#define BCMA_CORE_ROM 0x508
4707 +#define BCMA_CORE_NAND 0x509
4708 +#define BCMA_CORE_QSPI 0x50A
4709 +#define BCMA_CORE_CHIPCOMMON_B 0x50B
4710 +#define BCMA_CORE_4706_SOC_RAM 0x50E
4711 +#define BCMA_CORE_ARMCA9 0x510
4712 +#define BCMA_CORE_4706_MAC_GBIT 0x52D
4713 +#define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */
4714 +#define BCMA_CORE_ALTA 0x534 /* I2S core */
4715 +#define BCMA_CORE_4706_MAC_GBIT_COMMON 0x5DC
4716 +#define BCMA_CORE_DDR23_PHY 0x5DD
4717 #define BCMA_CORE_INVALID 0x700
4718 #define BCMA_CORE_CHIPCOMMON 0x800
4719 #define BCMA_CORE_ILINE20 0x801
4720 @@ -121,10 +146,112 @@ struct bcma_host_ops {
4721 #define BCMA_CORE_I2S 0x834
4722 #define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
4723 #define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
4724 +#define BCMA_CORE_PHY_AC 0x83B
4725 +#define BCMA_CORE_PCIE2 0x83C /* PCI Express Gen2 */
4726 +#define BCMA_CORE_USB30_DEV 0x83D
4727 +#define BCMA_CORE_ARM_CR4 0x83E
4728 #define BCMA_CORE_DEFAULT 0xFFF
4730 #define BCMA_MAX_NR_CORES 16
4732 +/* Chip IDs of PCIe devices */
4733 +#define BCMA_CHIP_ID_BCM4313 0x4313
4734 +#define BCMA_CHIP_ID_BCM43142 43142
4735 +#define BCMA_CHIP_ID_BCM43131 43131
4736 +#define BCMA_CHIP_ID_BCM43217 43217
4737 +#define BCMA_CHIP_ID_BCM43222 43222
4738 +#define BCMA_CHIP_ID_BCM43224 43224
4739 +#define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
4740 +#define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
4741 +#define BCMA_CHIP_ID_BCM43225 43225
4742 +#define BCMA_CHIP_ID_BCM43227 43227
4743 +#define BCMA_CHIP_ID_BCM43228 43228
4744 +#define BCMA_CHIP_ID_BCM43421 43421
4745 +#define BCMA_CHIP_ID_BCM43428 43428
4746 +#define BCMA_CHIP_ID_BCM43431 43431
4747 +#define BCMA_CHIP_ID_BCM43460 43460
4748 +#define BCMA_CHIP_ID_BCM4331 0x4331
4749 +#define BCMA_CHIP_ID_BCM6362 0x6362
4750 +#define BCMA_CHIP_ID_BCM4360 0x4360
4751 +#define BCMA_CHIP_ID_BCM4352 0x4352
4753 +/* Chip IDs of SoCs */
4754 +#define BCMA_CHIP_ID_BCM4706 0x5300
4755 +#define BCMA_PKG_ID_BCM4706L 1
4756 +#define BCMA_CHIP_ID_BCM4716 0x4716
4757 +#define BCMA_PKG_ID_BCM4716 8
4758 +#define BCMA_PKG_ID_BCM4717 9
4759 +#define BCMA_PKG_ID_BCM4718 10
4760 +#define BCMA_CHIP_ID_BCM47162 47162
4761 +#define BCMA_CHIP_ID_BCM4748 0x4748
4762 +#define BCMA_CHIP_ID_BCM4749 0x4749
4763 +#define BCMA_CHIP_ID_BCM5356 0x5356
4764 +#define BCMA_CHIP_ID_BCM5357 0x5357
4765 +#define BCMA_PKG_ID_BCM5358 9
4766 +#define BCMA_PKG_ID_BCM47186 10
4767 +#define BCMA_PKG_ID_BCM5357 11
4768 +#define BCMA_CHIP_ID_BCM53572 53572
4769 +#define BCMA_PKG_ID_BCM47188 9
4770 +#define BCMA_CHIP_ID_BCM4707 53010
4771 +#define BCMA_PKG_ID_BCM4707 1
4772 +#define BCMA_PKG_ID_BCM4708 2
4773 +#define BCMA_PKG_ID_BCM4709 0
4774 +#define BCMA_CHIP_ID_BCM53018 53018
4776 +/* Board types (on PCI usually equals to the subsystem dev id) */
4778 +#define BCMA_BOARD_TYPE_BCM94313BU 0X050F
4779 +#define BCMA_BOARD_TYPE_BCM94313HM 0X0510
4780 +#define BCMA_BOARD_TYPE_BCM94313EPA 0X0511
4781 +#define BCMA_BOARD_TYPE_BCM94313HMG 0X051C
4783 +#define BCMA_BOARD_TYPE_BCM94716NR2 0X04CD
4785 +#define BCMA_BOARD_TYPE_BCM943224X21 0X056E
4786 +#define BCMA_BOARD_TYPE_BCM943224X21_FCC 0X00D1
4787 +#define BCMA_BOARD_TYPE_BCM943224X21B 0X00E9
4788 +#define BCMA_BOARD_TYPE_BCM943224M93 0X008B
4789 +#define BCMA_BOARD_TYPE_BCM943224M93A 0X0090
4790 +#define BCMA_BOARD_TYPE_BCM943224X16 0X0093
4791 +#define BCMA_BOARD_TYPE_BCM94322X9 0X008D
4792 +#define BCMA_BOARD_TYPE_BCM94322M35E 0X008E
4794 +#define BCMA_BOARD_TYPE_BCM943228BU8 0X0540
4795 +#define BCMA_BOARD_TYPE_BCM943228BU9 0X0541
4796 +#define BCMA_BOARD_TYPE_BCM943228BU 0X0542
4797 +#define BCMA_BOARD_TYPE_BCM943227HM4L 0X0543
4798 +#define BCMA_BOARD_TYPE_BCM943227HMB 0X0544
4799 +#define BCMA_BOARD_TYPE_BCM943228HM4L 0X0545
4800 +#define BCMA_BOARD_TYPE_BCM943228SD 0X0573
4802 +#define BCMA_BOARD_TYPE_BCM94331X19 0X00D6
4803 +#define BCMA_BOARD_TYPE_BCM94331X28 0X00E4
4804 +#define BCMA_BOARD_TYPE_BCM94331X28B 0X010E
4805 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT3AX 0X00E4
4806 +#define BCMA_BOARD_TYPE_BCM94331X12_2G 0X00EC
4807 +#define BCMA_BOARD_TYPE_BCM94331X12_5G 0X00ED
4808 +#define BCMA_BOARD_TYPE_BCM94331X29B 0X00EF
4809 +#define BCMA_BOARD_TYPE_BCM94331CSAX 0X00EF
4810 +#define BCMA_BOARD_TYPE_BCM94331X19C 0X00F5
4811 +#define BCMA_BOARD_TYPE_BCM94331X33 0X00F4
4812 +#define BCMA_BOARD_TYPE_BCM94331BU 0X0523
4813 +#define BCMA_BOARD_TYPE_BCM94331S9BU 0X0524
4814 +#define BCMA_BOARD_TYPE_BCM94331MC 0X0525
4815 +#define BCMA_BOARD_TYPE_BCM94331MCI 0X0526
4816 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT4 0X0527
4817 +#define BCMA_BOARD_TYPE_BCM94331HM 0X0574
4818 +#define BCMA_BOARD_TYPE_BCM94331PCIEDUAL 0X059B
4819 +#define BCMA_BOARD_TYPE_BCM94331MCH5 0X05A9
4820 +#define BCMA_BOARD_TYPE_BCM94331CS 0X05C6
4821 +#define BCMA_BOARD_TYPE_BCM94331CD 0X05DA
4823 +#define BCMA_BOARD_TYPE_BCM953572BU 0X058D
4824 +#define BCMA_BOARD_TYPE_BCM953572NR2 0X058E
4825 +#define BCMA_BOARD_TYPE_BCM947188NR2 0X058F
4826 +#define BCMA_BOARD_TYPE_BCM953572SDRNR2 0X0590
4828 +#define BCMA_BOARD_TYPE_BCM943142HM 0X05E0
4830 struct bcma_device {
4831 struct bcma_bus *bus;
4832 struct bcma_device_id id;
4833 @@ -136,8 +263,10 @@ struct bcma_device {
4834 bool dev_registered;
4843 void __iomem *io_addr;
4844 @@ -175,6 +304,12 @@ int __bcma_driver_register(struct bcma_d
4846 extern void bcma_driver_unregister(struct bcma_driver *drv);
4848 +/* Set a fallback SPROM.
4849 + * See kdoc at the function definition for complete documentation. */
4850 +extern int bcma_arch_register_fallback_sprom(
4851 + int (*sprom_callback)(struct bcma_bus *bus,
4852 + struct ssb_sprom *out));
4855 /* The MMIO area. */
4857 @@ -191,14 +326,18 @@ struct bcma_bus {
4859 struct bcma_chipinfo chipinfo;
4861 + struct bcma_boardinfo boardinfo;
4863 struct bcma_device *mapped_core;
4864 struct list_head cores;
4869 struct bcma_drv_cc drv_cc;
4870 - struct bcma_drv_pci drv_pci;
4871 + struct bcma_drv_pci drv_pci[2];
4872 struct bcma_drv_mips drv_mips;
4873 + struct bcma_drv_gmac_cmn drv_gmac_cmn;
4875 /* We decided to share SPROM struct with SSB as long as we do not need
4876 * any hacks for BCMA. This simplifies drivers code. */
4877 @@ -282,6 +421,7 @@ static inline void bcma_maskset16(struct
4878 bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set);
4881 +extern struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid);
4882 extern bool bcma_core_is_enabled(struct bcma_device *core);
4883 extern void bcma_core_disable(struct bcma_device *core, u32 flags);
4884 extern int bcma_core_enable(struct bcma_device *core, u32 flags);
4885 @@ -289,6 +429,7 @@ extern void bcma_core_set_clockmode(stru
4886 enum bcma_clkmode clkmode);
4887 extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
4889 +extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
4890 #define BCMA_DMA_TRANSLATION_MASK 0xC0000000
4891 #define BCMA_DMA_TRANSLATION_NONE 0x00000000
4892 #define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
4893 --- a/include/linux/bcma/bcma_driver_chipcommon.h
4894 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
4896 #ifndef LINUX_BCMA_DRIVER_CC_H_
4897 #define LINUX_BCMA_DRIVER_CC_H_
4899 +#include <linux/platform_device.h>
4900 +#include <linux/gpio.h>
4902 /** ChipCommon core registers. **/
4903 #define BCMA_CC_ID 0x0000
4904 #define BCMA_CC_ID_ID 0x0000FFFF
4906 #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
4907 #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
4908 #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
4909 -#define BCMA_CC_FLASHT_NFLASH 0x00000200
4910 +#define BCMA_CC_FLASHT_NAND 0x00000300 /* NAND flash */
4911 #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
4912 #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
4913 #define BCMA_PLLTYPE_NONE 0x00000000
4915 #define BCMA_CC_CAP_PMU 0x10000000 /* PMU available (rev >= 20) */
4916 #define BCMA_CC_CAP_ECI 0x20000000 /* ECI available (rev >= 20) */
4917 #define BCMA_CC_CAP_SPROM 0x40000000 /* SPROM present */
4918 +#define BCMA_CC_CAP_NFLASH 0x80000000 /* NAND flash present (rev >= 35 or BCM4706?) */
4919 #define BCMA_CC_CORECTL 0x0008
4920 #define BCMA_CC_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */
4921 #define BCMA_CC_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
4923 #define BCMA_CC_OTPS_HW_PROTECT 0x00000001
4924 #define BCMA_CC_OTPS_SW_PROTECT 0x00000002
4925 #define BCMA_CC_OTPS_CID_PROTECT 0x00000004
4926 +#define BCMA_CC_OTPS_GU_PROG_IND 0x00000F00 /* General Use programmed indication */
4927 +#define BCMA_CC_OTPS_GU_PROG_IND_SHIFT 8
4928 +#define BCMA_CC_OTPS_GU_PROG_HW 0x00000100 /* HW region programmed */
4929 #define BCMA_CC_OTPC 0x0014 /* OTP control */
4930 #define BCMA_CC_OTPC_RECWAIT 0xFF000000
4931 #define BCMA_CC_OTPC_PROGWAIT 0x00FFFF00
4933 #define BCMA_CC_OTPP_READ 0x40000000
4934 #define BCMA_CC_OTPP_START 0x80000000
4935 #define BCMA_CC_OTPP_BUSY 0x80000000
4936 +#define BCMA_CC_OTPL 0x001C /* OTP layout */
4937 +#define BCMA_CC_OTPL_GURGN_OFFSET 0x00000FFF /* offset of general use region */
4938 #define BCMA_CC_IRQSTAT 0x0020
4939 #define BCMA_CC_IRQMASK 0x0024
4940 #define BCMA_CC_IRQ_GPIO 0x00000001 /* gpio intr */
4942 #define BCMA_CC_IRQ_WDRESET 0x80000000 /* watchdog reset occurred */
4943 #define BCMA_CC_CHIPCTL 0x0028 /* Rev >= 11 only */
4944 #define BCMA_CC_CHIPSTAT 0x002C /* Rev >= 11 only */
4945 +#define BCMA_CC_CHIPST_4313_SPROM_PRESENT 1
4946 +#define BCMA_CC_CHIPST_4313_OTP_PRESENT 2
4947 +#define BCMA_CC_CHIPST_4331_SPROM_PRESENT 2
4948 +#define BCMA_CC_CHIPST_4331_OTP_PRESENT 4
4949 +#define BCMA_CC_CHIPST_43228_ILP_DIV_EN 0x00000001
4950 +#define BCMA_CC_CHIPST_43228_OTP_PRESENT 0x00000002
4951 +#define BCMA_CC_CHIPST_43228_SERDES_REFCLK_PADSEL 0x00000004
4952 +#define BCMA_CC_CHIPST_43228_SDIO_MODE 0x00000008
4953 +#define BCMA_CC_CHIPST_43228_SDIO_OTP_PRESENT 0x00000010
4954 +#define BCMA_CC_CHIPST_43228_SDIO_RESET 0x00000020
4955 +#define BCMA_CC_CHIPST_4706_PKG_OPTION BIT(0) /* 0: full-featured package 1: low-cost package */
4956 +#define BCMA_CC_CHIPST_4706_SFLASH_PRESENT BIT(1) /* 0: parallel, 1: serial flash is present */
4957 +#define BCMA_CC_CHIPST_4706_SFLASH_TYPE BIT(2) /* 0: 8b-p/ST-s flash, 1: 16b-p/Atmal-s flash */
4958 +#define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
4959 +#define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
4960 +#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
4961 +#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
4962 #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
4963 #define BCMA_CC_JCMD_START 0x80000000
4964 #define BCMA_CC_JCMD_BUSY 0x80000000
4965 @@ -108,10 +134,58 @@
4966 #define BCMA_CC_JCTL_EXT_EN 2 /* Enable external targets */
4967 #define BCMA_CC_JCTL_EN 1 /* Enable Jtag master */
4968 #define BCMA_CC_FLASHCTL 0x0040
4969 +/* Start/busy bit in flashcontrol */
4970 +#define BCMA_CC_FLASHCTL_OPCODE 0x000000ff
4971 +#define BCMA_CC_FLASHCTL_ACTION 0x00000700
4972 +#define BCMA_CC_FLASHCTL_CS_ACTIVE 0x00001000 /* Chip Select Active, rev >= 20 */
4973 #define BCMA_CC_FLASHCTL_START 0x80000000
4974 #define BCMA_CC_FLASHCTL_BUSY BCMA_CC_FLASHCTL_START
4975 +/* Flashcontrol action + opcodes for ST flashes */
4976 +#define BCMA_CC_FLASHCTL_ST_WREN 0x0006 /* Write Enable */
4977 +#define BCMA_CC_FLASHCTL_ST_WRDIS 0x0004 /* Write Disable */
4978 +#define BCMA_CC_FLASHCTL_ST_RDSR 0x0105 /* Read Status Register */
4979 +#define BCMA_CC_FLASHCTL_ST_WRSR 0x0101 /* Write Status Register */
4980 +#define BCMA_CC_FLASHCTL_ST_READ 0x0303 /* Read Data Bytes */
4981 +#define BCMA_CC_FLASHCTL_ST_PP 0x0302 /* Page Program */
4982 +#define BCMA_CC_FLASHCTL_ST_SE 0x02d8 /* Sector Erase */
4983 +#define BCMA_CC_FLASHCTL_ST_BE 0x00c7 /* Bulk Erase */
4984 +#define BCMA_CC_FLASHCTL_ST_DP 0x00b9 /* Deep Power-down */
4985 +#define BCMA_CC_FLASHCTL_ST_RES 0x03ab /* Read Electronic Signature */
4986 +#define BCMA_CC_FLASHCTL_ST_CSA 0x1000 /* Keep chip select asserted */
4987 +#define BCMA_CC_FLASHCTL_ST_SSE 0x0220 /* Sub-sector Erase */
4988 +/* Flashcontrol action + opcodes for Atmel flashes */
4989 +#define BCMA_CC_FLASHCTL_AT_READ 0x07e8
4990 +#define BCMA_CC_FLASHCTL_AT_PAGE_READ 0x07d2
4991 +#define BCMA_CC_FLASHCTL_AT_STATUS 0x01d7
4992 +#define BCMA_CC_FLASHCTL_AT_BUF1_WRITE 0x0384
4993 +#define BCMA_CC_FLASHCTL_AT_BUF2_WRITE 0x0387
4994 +#define BCMA_CC_FLASHCTL_AT_BUF1_ERASE_PROGRAM 0x0283
4995 +#define BCMA_CC_FLASHCTL_AT_BUF2_ERASE_PROGRAM 0x0286
4996 +#define BCMA_CC_FLASHCTL_AT_BUF1_PROGRAM 0x0288
4997 +#define BCMA_CC_FLASHCTL_AT_BUF2_PROGRAM 0x0289
4998 +#define BCMA_CC_FLASHCTL_AT_PAGE_ERASE 0x0281
4999 +#define BCMA_CC_FLASHCTL_AT_BLOCK_ERASE 0x0250
5000 +#define BCMA_CC_FLASHCTL_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
5001 +#define BCMA_CC_FLASHCTL_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
5002 +#define BCMA_CC_FLASHCTL_AT_BUF1_LOAD 0x0253
5003 +#define BCMA_CC_FLASHCTL_AT_BUF2_LOAD 0x0255
5004 +#define BCMA_CC_FLASHCTL_AT_BUF1_COMPARE 0x0260
5005 +#define BCMA_CC_FLASHCTL_AT_BUF2_COMPARE 0x0261
5006 +#define BCMA_CC_FLASHCTL_AT_BUF1_REPROGRAM 0x0258
5007 +#define BCMA_CC_FLASHCTL_AT_BUF2_REPROGRAM 0x0259
5008 #define BCMA_CC_FLASHADDR 0x0044
5009 #define BCMA_CC_FLASHDATA 0x0048
5010 +/* Status register bits for ST flashes */
5011 +#define BCMA_CC_FLASHDATA_ST_WIP 0x01 /* Write In Progress */
5012 +#define BCMA_CC_FLASHDATA_ST_WEL 0x02 /* Write Enable Latch */
5013 +#define BCMA_CC_FLASHDATA_ST_BP_MASK 0x1c /* Block Protect */
5014 +#define BCMA_CC_FLASHDATA_ST_BP_SHIFT 2
5015 +#define BCMA_CC_FLASHDATA_ST_SRWD 0x80 /* Status Register Write Disable */
5016 +/* Status register bits for Atmel flashes */
5017 +#define BCMA_CC_FLASHDATA_AT_READY 0x80
5018 +#define BCMA_CC_FLASHDATA_AT_MISMATCH 0x40
5019 +#define BCMA_CC_FLASHDATA_AT_ID_MASK 0x38
5020 +#define BCMA_CC_FLASHDATA_AT_ID_SHIFT 3
5021 #define BCMA_CC_BCAST_ADDR 0x0050
5022 #define BCMA_CC_BCAST_DATA 0x0054
5023 #define BCMA_CC_GPIOPULLUP 0x0058 /* Rev >= 20 only */
5024 @@ -181,6 +255,45 @@
5025 #define BCMA_CC_FLASH_CFG 0x0128
5026 #define BCMA_CC_FLASH_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
5027 #define BCMA_CC_FLASH_WAITCNT 0x012C
5028 +#define BCMA_CC_SROM_CONTROL 0x0190
5029 +#define BCMA_CC_SROM_CONTROL_START 0x80000000
5030 +#define BCMA_CC_SROM_CONTROL_BUSY 0x80000000
5031 +#define BCMA_CC_SROM_CONTROL_OPCODE 0x60000000
5032 +#define BCMA_CC_SROM_CONTROL_OP_READ 0x00000000
5033 +#define BCMA_CC_SROM_CONTROL_OP_WRITE 0x20000000
5034 +#define BCMA_CC_SROM_CONTROL_OP_WRDIS 0x40000000
5035 +#define BCMA_CC_SROM_CONTROL_OP_WREN 0x60000000
5036 +#define BCMA_CC_SROM_CONTROL_OTPSEL 0x00000010
5037 +#define BCMA_CC_SROM_CONTROL_LOCK 0x00000008
5038 +#define BCMA_CC_SROM_CONTROL_SIZE_MASK 0x00000006
5039 +#define BCMA_CC_SROM_CONTROL_SIZE_1K 0x00000000
5040 +#define BCMA_CC_SROM_CONTROL_SIZE_4K 0x00000002
5041 +#define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004
5042 +#define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1
5043 +#define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001
5044 +/* Block 0x140 - 0x190 registers are chipset specific */
5045 +#define BCMA_CC_4706_FLASHSCFG 0x18C /* Flash struct configuration */
5046 +#define BCMA_CC_4706_FLASHSCFG_MASK 0x000000ff
5047 +#define BCMA_CC_4706_FLASHSCFG_SF1 0x00000001 /* 2nd serial flash present */
5048 +#define BCMA_CC_4706_FLASHSCFG_PF1 0x00000002 /* 2nd parallel flash present */
5049 +#define BCMA_CC_4706_FLASHSCFG_SF1_TYPE 0x00000004 /* 2nd serial flash type : 0 : ST, 1 : Atmel */
5050 +#define BCMA_CC_4706_FLASHSCFG_NF1 0x00000008 /* 2nd NAND flash present */
5051 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_MASK 0x000000f0
5052 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_4MB 0x00000010 /* 4MB */
5053 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_8MB 0x00000020 /* 8MB */
5054 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_16MB 0x00000030 /* 16MB */
5055 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_32MB 0x00000040 /* 32MB */
5056 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_64MB 0x00000050 /* 64MB */
5057 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_128MB 0x00000060 /* 128MB */
5058 +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_256MB 0x00000070 /* 256MB */
5059 +/* NAND flash registers for BCM4706 (corerev = 31) */
5060 +#define BCMA_CC_NFLASH_CTL 0x01A0
5061 +#define BCMA_CC_NFLASH_CTL_ERR 0x08000000
5062 +#define BCMA_CC_NFLASH_CONF 0x01A4
5063 +#define BCMA_CC_NFLASH_COL_ADDR 0x01A8
5064 +#define BCMA_CC_NFLASH_ROW_ADDR 0x01AC
5065 +#define BCMA_CC_NFLASH_DATA 0x01B0
5066 +#define BCMA_CC_NFLASH_WAITCNT0 0x01B4
5067 /* 0x1E0 is defined as shared BCMA_CLKCTLST */
5068 #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
5069 #define BCMA_CC_UART0_DATA 0x0300
5071 #define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
5072 #define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
5073 #define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
5074 +#define BCMA_CC_PMU_CTL_RES 0x00006000 /* reset control mask */
5075 +#define BCMA_CC_PMU_CTL_RES_SHIFT 13
5076 +#define BCMA_CC_PMU_CTL_RES_RELOAD 0x2 /* reload POR values */
5077 #define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
5078 #define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
5079 #define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
5081 #define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
5082 #define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
5083 #define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
5084 +#define BCMA_CC_PMU_STAT_EXT_LPO_AVAIL 0x00000100
5085 +#define BCMA_CC_PMU_STAT_WDRESET 0x00000080
5086 #define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
5087 #define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
5088 #define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
5089 @@ -239,8 +357,66 @@
5090 #define BCMA_CC_REGCTL_DATA 0x065C
5091 #define BCMA_CC_PLLCTL_ADDR 0x0660
5092 #define BCMA_CC_PLLCTL_DATA 0x0664
5093 +#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */
5094 +#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */
5095 +#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF
5096 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_MASK 0x80000000
5097 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT 31
5098 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
5099 -#define BCMA_CC_SPROM_PCIE6 0x0830 /* SPROM beginning on PCIe rev >= 6 */
5100 +/* NAND flash MLC controller registers (corerev >= 38) */
5101 +#define BCMA_CC_NAND_REVISION 0x0C00
5102 +#define BCMA_CC_NAND_CMD_START 0x0C04
5103 +#define BCMA_CC_NAND_CMD_ADDR_X 0x0C08
5104 +#define BCMA_CC_NAND_CMD_ADDR 0x0C0C
5105 +#define BCMA_CC_NAND_CMD_END_ADDR 0x0C10
5106 +#define BCMA_CC_NAND_CS_NAND_SELECT 0x0C14
5107 +#define BCMA_CC_NAND_CS_NAND_XOR 0x0C18
5108 +#define BCMA_CC_NAND_SPARE_RD0 0x0C20
5109 +#define BCMA_CC_NAND_SPARE_RD4 0x0C24
5110 +#define BCMA_CC_NAND_SPARE_RD8 0x0C28
5111 +#define BCMA_CC_NAND_SPARE_RD12 0x0C2C
5112 +#define BCMA_CC_NAND_SPARE_WR0 0x0C30
5113 +#define BCMA_CC_NAND_SPARE_WR4 0x0C34
5114 +#define BCMA_CC_NAND_SPARE_WR8 0x0C38
5115 +#define BCMA_CC_NAND_SPARE_WR12 0x0C3C
5116 +#define BCMA_CC_NAND_ACC_CONTROL 0x0C40
5117 +#define BCMA_CC_NAND_CONFIG 0x0C48
5118 +#define BCMA_CC_NAND_TIMING_1 0x0C50
5119 +#define BCMA_CC_NAND_TIMING_2 0x0C54
5120 +#define BCMA_CC_NAND_SEMAPHORE 0x0C58
5121 +#define BCMA_CC_NAND_DEVID 0x0C60
5122 +#define BCMA_CC_NAND_DEVID_X 0x0C64
5123 +#define BCMA_CC_NAND_BLOCK_LOCK_STATUS 0x0C68
5124 +#define BCMA_CC_NAND_INTFC_STATUS 0x0C6C
5125 +#define BCMA_CC_NAND_ECC_CORR_ADDR_X 0x0C70
5126 +#define BCMA_CC_NAND_ECC_CORR_ADDR 0x0C74
5127 +#define BCMA_CC_NAND_ECC_UNC_ADDR_X 0x0C78
5128 +#define BCMA_CC_NAND_ECC_UNC_ADDR 0x0C7C
5129 +#define BCMA_CC_NAND_READ_ERROR_COUNT 0x0C80
5130 +#define BCMA_CC_NAND_CORR_STAT_THRESHOLD 0x0C84
5131 +#define BCMA_CC_NAND_READ_ADDR_X 0x0C90
5132 +#define BCMA_CC_NAND_READ_ADDR 0x0C94
5133 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR_X 0x0C98
5134 +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR 0x0C9C
5135 +#define BCMA_CC_NAND_COPY_BACK_ADDR_X 0x0CA0
5136 +#define BCMA_CC_NAND_COPY_BACK_ADDR 0x0CA4
5137 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR_X 0x0CA8
5138 +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR 0x0CAC
5139 +#define BCMA_CC_NAND_INV_READ_ADDR_X 0x0CB0
5140 +#define BCMA_CC_NAND_INV_READ_ADDR 0x0CB4
5141 +#define BCMA_CC_NAND_BLK_WR_PROTECT 0x0CC0
5142 +#define BCMA_CC_NAND_ACC_CONTROL_CS1 0x0CD0
5143 +#define BCMA_CC_NAND_CONFIG_CS1 0x0CD4
5144 +#define BCMA_CC_NAND_TIMING_1_CS1 0x0CD8
5145 +#define BCMA_CC_NAND_TIMING_2_CS1 0x0CDC
5146 +#define BCMA_CC_NAND_SPARE_RD16 0x0D30
5147 +#define BCMA_CC_NAND_SPARE_RD20 0x0D34
5148 +#define BCMA_CC_NAND_SPARE_RD24 0x0D38
5149 +#define BCMA_CC_NAND_SPARE_RD28 0x0D3C
5150 +#define BCMA_CC_NAND_CACHE_ADDR 0x0D40
5151 +#define BCMA_CC_NAND_CACHE_DATA 0x0D44
5152 +#define BCMA_CC_NAND_CTRL_CONFIG 0x0D48
5153 +#define BCMA_CC_NAND_CTRL_STATUS 0x0D4C
5155 /* Divider allocation in 4716/47162/5356 */
5156 #define BCMA_CC_PMU5_MAINPLL_CPU 1
5157 @@ -256,6 +432,32 @@
5160 #define BCMA_CC_PMU4706_MAINPLL_PLL0 0
5161 +#define BCMA_CC_PMU6_4706_PROCPLL_OFF 4 /* The CPU PLL */
5162 +#define BCMA_CC_PMU6_4706_PROC_P2DIV_MASK 0x000f0000
5163 +#define BCMA_CC_PMU6_4706_PROC_P2DIV_SHIFT 16
5164 +#define BCMA_CC_PMU6_4706_PROC_P1DIV_MASK 0x0000f000
5165 +#define BCMA_CC_PMU6_4706_PROC_P1DIV_SHIFT 12
5166 +#define BCMA_CC_PMU6_4706_PROC_NDIV_INT_MASK 0x00000ff8
5167 +#define BCMA_CC_PMU6_4706_PROC_NDIV_INT_SHIFT 3
5168 +#define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007
5169 +#define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0
5172 +#define BCMA_CC_PMU15_PLL_PLLCTL0 0
5173 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_MASK 0x00000003
5174 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_SHIFT 0
5175 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK 0x003FFFFC
5176 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT 2
5177 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_MASK 0x00C00000
5178 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_SHIFT 22
5179 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_MASK 0x07000000
5180 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_SHIFT 24
5181 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_MASK 0x38000000
5182 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_SHIFT 27
5183 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_MASK 0x40000000
5184 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_SHIFT 30
5185 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_MASK 0x80000000
5186 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_SHIFT 31
5188 /* ALP clock on pre-PMU chips */
5189 #define BCMA_CC_PMU_ALP_CLOCK 20000000
5190 @@ -284,6 +486,19 @@
5191 #define BCMA_CC_PPL_PCHI_OFF 5
5192 #define BCMA_CC_PPL_PCHI_MASK 0x0000003f
5194 +#define BCMA_CC_PMU_PLL_CTL0 0
5195 +#define BCMA_CC_PMU_PLL_CTL1 1
5196 +#define BCMA_CC_PMU_PLL_CTL2 2
5197 +#define BCMA_CC_PMU_PLL_CTL3 3
5198 +#define BCMA_CC_PMU_PLL_CTL4 4
5199 +#define BCMA_CC_PMU_PLL_CTL5 5
5201 +#define BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK 0x00f00000
5202 +#define BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT 20
5204 +#define BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK 0x1ff00000
5205 +#define BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT 20
5207 /* BCM4331 ChipControl numbers. */
5208 #define BCMA_CHIPCTL_4331_BT_COEXIST BIT(0) /* 0 disable */
5209 #define BCMA_CHIPCTL_4331_SECI BIT(1) /* 0 SECI is disabled (JATG functional) */
5210 @@ -297,9 +512,56 @@
5211 #define BCMA_CHIPCTL_4331_OVR_PIPEAUXPWRDOWN BIT(9) /* override core control on pipe_AuxPowerDown */
5212 #define BCMA_CHIPCTL_4331_PCIE_AUXCLKEN BIT(10) /* pcie_auxclkenable */
5213 #define BCMA_CHIPCTL_4331_PCIE_PIPE_PLLDOWN BIT(11) /* pcie_pipe_pllpowerdown */
5214 +#define BCMA_CHIPCTL_4331_EXTPA_EN2 BIT(12) /* 0 ext pa disable, 1 ext pa enabled */
5215 #define BCMA_CHIPCTL_4331_BT_SHD0_ON_GPIO4 BIT(16) /* enable bt_shd0 at gpio4 */
5216 #define BCMA_CHIPCTL_4331_BT_SHD1_ON_GPIO5 BIT(17) /* enable bt_shd1 at gpio5 */
5218 +/* 43224 chip-specific ChipControl register bits */
5219 +#define BCMA_CCTRL_43224_GPIO_TOGGLE 0x8000 /* gpio[3:0] pins as btcoex or s/w gpio */
5220 +#define BCMA_CCTRL_43224A0_12MA_LED_DRIVE 0x00F000F0 /* 12 mA drive strength */
5221 +#define BCMA_CCTRL_43224B0_12MA_LED_DRIVE 0xF0 /* 12 mA drive strength for later 43224s */
5223 +/* 4313 Chip specific ChipControl register bits */
5224 +#define BCMA_CCTRL_4313_12MA_LED_DRIVE 0x00000007 /* 12 mA drive strengh for later 4313 */
5226 +/* BCM5357 ChipControl register bits */
5227 +#define BCMA_CHIPCTL_5357_EXTPA BIT(14)
5228 +#define BCMA_CHIPCTL_5357_ANT_MUX_2O3 BIT(15)
5229 +#define BCMA_CHIPCTL_5357_NFLASH BIT(16)
5230 +#define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
5231 +#define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
5233 +#define BCMA_RES_4314_LPLDO_PU BIT(0)
5234 +#define BCMA_RES_4314_PMU_SLEEP_DIS BIT(1)
5235 +#define BCMA_RES_4314_PMU_BG_PU BIT(2)
5236 +#define BCMA_RES_4314_CBUCK_LPOM_PU BIT(3)
5237 +#define BCMA_RES_4314_CBUCK_PFM_PU BIT(4)
5238 +#define BCMA_RES_4314_CLDO_PU BIT(5)
5239 +#define BCMA_RES_4314_LPLDO2_LVM BIT(6)
5240 +#define BCMA_RES_4314_WL_PMU_PU BIT(7)
5241 +#define BCMA_RES_4314_LNLDO_PU BIT(8)
5242 +#define BCMA_RES_4314_LDO3P3_PU BIT(9)
5243 +#define BCMA_RES_4314_OTP_PU BIT(10)
5244 +#define BCMA_RES_4314_XTAL_PU BIT(11)
5245 +#define BCMA_RES_4314_WL_PWRSW_PU BIT(12)
5246 +#define BCMA_RES_4314_LQ_AVAIL BIT(13)
5247 +#define BCMA_RES_4314_LOGIC_RET BIT(14)
5248 +#define BCMA_RES_4314_MEM_SLEEP BIT(15)
5249 +#define BCMA_RES_4314_MACPHY_RET BIT(16)
5250 +#define BCMA_RES_4314_WL_CORE_READY BIT(17)
5251 +#define BCMA_RES_4314_ILP_REQ BIT(18)
5252 +#define BCMA_RES_4314_ALP_AVAIL BIT(19)
5253 +#define BCMA_RES_4314_MISC_PWRSW_PU BIT(20)
5254 +#define BCMA_RES_4314_SYNTH_PWRSW_PU BIT(21)
5255 +#define BCMA_RES_4314_RX_PWRSW_PU BIT(22)
5256 +#define BCMA_RES_4314_RADIO_PU BIT(23)
5257 +#define BCMA_RES_4314_VCO_LDO_PU BIT(24)
5258 +#define BCMA_RES_4314_AFE_LDO_PU BIT(25)
5259 +#define BCMA_RES_4314_RX_LDO_PU BIT(26)
5260 +#define BCMA_RES_4314_TX_LDO_PU BIT(27)
5261 +#define BCMA_RES_4314_HT_AVAIL BIT(28)
5262 +#define BCMA_RES_4314_MACPHY_CLK_AVAIL BIT(29)
5264 /* Data for the PMU, if available.
5265 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
5267 @@ -310,11 +572,36 @@ struct bcma_chipcommon_pmu {
5269 #ifdef CONFIG_BCMA_DRIVER_MIPS
5270 struct bcma_pflash {
5277 +#ifdef CONFIG_BCMA_SFLASH
5278 +struct bcma_sflash {
5285 + struct mtd_info *mtd;
5290 +#ifdef CONFIG_BCMA_NFLASH
5293 +struct bcma_nflash {
5295 + bool boot; /* This is the flash the SoC boots from */
5297 + struct mtd_info *mtd;
5301 struct bcma_serial_port {
5303 unsigned long clockspeed;
5304 @@ -330,15 +617,30 @@ struct bcma_drv_cc {
5306 u32 capabilities_ext;
5308 + u8 early_setup_done:1;
5309 /* Fast Powerup Delay constant */
5310 u16 fast_pwrup_delay;
5311 struct bcma_chipcommon_pmu pmu;
5312 #ifdef CONFIG_BCMA_DRIVER_MIPS
5313 struct bcma_pflash pflash;
5314 +#ifdef CONFIG_BCMA_SFLASH
5315 + struct bcma_sflash sflash;
5317 +#ifdef CONFIG_BCMA_NFLASH
5318 + struct bcma_nflash nflash;
5321 int nr_serial_ports;
5322 struct bcma_serial_port serial_ports[4];
5323 #endif /* CONFIG_BCMA_DRIVER_MIPS */
5325 + struct platform_device *watchdog;
5327 + /* Lock for GPIO register access. */
5328 + spinlock_t gpio_lock;
5329 +#ifdef CONFIG_BCMA_DRIVER_GPIO
5330 + struct gpio_chip gpio;
5334 /* Register access */
5335 @@ -355,14 +657,16 @@ struct bcma_drv_cc {
5336 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
5338 extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
5339 +extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
5341 extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
5342 extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
5344 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
5346 -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
5348 +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
5350 +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
5352 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
5354 @@ -375,9 +679,12 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
5355 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
5356 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
5357 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
5358 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
5359 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
5362 extern void bcma_pmu_init(struct bcma_drv_cc *cc);
5363 +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
5365 extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
5367 @@ -387,5 +694,8 @@ extern void bcma_chipco_chipctl_maskset(
5368 u32 offset, u32 mask, u32 set);
5369 extern void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc,
5370 u32 offset, u32 mask, u32 set);
5371 +extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
5373 +extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
5375 #endif /* LINUX_BCMA_DRIVER_CC_H_ */
5377 +++ b/include/linux/bcma/bcma_driver_gmac_cmn.h
5379 +#ifndef LINUX_BCMA_DRIVER_GMAC_CMN_H_
5380 +#define LINUX_BCMA_DRIVER_GMAC_CMN_H_
5382 +#include <linux/types.h>
5384 +#define BCMA_GMAC_CMN_STAG0 0x000
5385 +#define BCMA_GMAC_CMN_STAG1 0x004
5386 +#define BCMA_GMAC_CMN_STAG2 0x008
5387 +#define BCMA_GMAC_CMN_STAG3 0x00C
5388 +#define BCMA_GMAC_CMN_PARSER_CTL 0x020
5389 +#define BCMA_GMAC_CMN_MIB_MAX_LEN 0x024
5390 +#define BCMA_GMAC_CMN_PHY_ACCESS 0x100
5391 +#define BCMA_GMAC_CMN_PA_DATA_MASK 0x0000ffff
5392 +#define BCMA_GMAC_CMN_PA_ADDR_MASK 0x001f0000
5393 +#define BCMA_GMAC_CMN_PA_ADDR_SHIFT 16
5394 +#define BCMA_GMAC_CMN_PA_REG_MASK 0x1f000000
5395 +#define BCMA_GMAC_CMN_PA_REG_SHIFT 24
5396 +#define BCMA_GMAC_CMN_PA_WRITE 0x20000000
5397 +#define BCMA_GMAC_CMN_PA_START 0x40000000
5398 +#define BCMA_GMAC_CMN_PHY_CTL 0x104
5399 +#define BCMA_GMAC_CMN_PC_EPA_MASK 0x0000001f
5400 +#define BCMA_GMAC_CMN_PC_MCT_MASK 0x007f0000
5401 +#define BCMA_GMAC_CMN_PC_MCT_SHIFT 16
5402 +#define BCMA_GMAC_CMN_PC_MTE 0x00800000
5403 +#define BCMA_GMAC_CMN_GMAC0_RGMII_CTL 0x110
5404 +#define BCMA_GMAC_CMN_CFP_ACCESS 0x200
5405 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA0 0x210
5406 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA1 0x214
5407 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA2 0x218
5408 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA3 0x21C
5409 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA4 0x220
5410 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA5 0x224
5411 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA6 0x228
5412 +#define BCMA_GMAC_CMN_CFP_TCAM_DATA7 0x22C
5413 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK0 0x230
5414 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK1 0x234
5415 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK2 0x238
5416 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK3 0x23C
5417 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK4 0x240
5418 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK5 0x244
5419 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK6 0x248
5420 +#define BCMA_GMAC_CMN_CFP_TCAM_MASK7 0x24C
5421 +#define BCMA_GMAC_CMN_CFP_ACTION_DATA 0x250
5422 +#define BCMA_GMAC_CMN_TCAM_BIST_CTL 0x2A0
5423 +#define BCMA_GMAC_CMN_TCAM_BIST_STATUS 0x2A4
5424 +#define BCMA_GMAC_CMN_TCAM_CMP_STATUS 0x2A8
5425 +#define BCMA_GMAC_CMN_TCAM_DISABLE 0x2AC
5426 +#define BCMA_GMAC_CMN_TCAM_TEST_CTL 0x2F0
5427 +#define BCMA_GMAC_CMN_UDF_0_A3_A0 0x300
5428 +#define BCMA_GMAC_CMN_UDF_0_A7_A4 0x304
5429 +#define BCMA_GMAC_CMN_UDF_0_A8 0x308
5430 +#define BCMA_GMAC_CMN_UDF_1_A3_A0 0x310
5431 +#define BCMA_GMAC_CMN_UDF_1_A7_A4 0x314
5432 +#define BCMA_GMAC_CMN_UDF_1_A8 0x318
5433 +#define BCMA_GMAC_CMN_UDF_2_A3_A0 0x320
5434 +#define BCMA_GMAC_CMN_UDF_2_A7_A4 0x324
5435 +#define BCMA_GMAC_CMN_UDF_2_A8 0x328
5436 +#define BCMA_GMAC_CMN_UDF_0_B3_B0 0x330
5437 +#define BCMA_GMAC_CMN_UDF_0_B7_B4 0x334
5438 +#define BCMA_GMAC_CMN_UDF_0_B8 0x338
5439 +#define BCMA_GMAC_CMN_UDF_1_B3_B0 0x340
5440 +#define BCMA_GMAC_CMN_UDF_1_B7_B4 0x344
5441 +#define BCMA_GMAC_CMN_UDF_1_B8 0x348
5442 +#define BCMA_GMAC_CMN_UDF_2_B3_B0 0x350
5443 +#define BCMA_GMAC_CMN_UDF_2_B7_B4 0x354
5444 +#define BCMA_GMAC_CMN_UDF_2_B8 0x358
5445 +#define BCMA_GMAC_CMN_UDF_0_C3_C0 0x360
5446 +#define BCMA_GMAC_CMN_UDF_0_C7_C4 0x364
5447 +#define BCMA_GMAC_CMN_UDF_0_C8 0x368
5448 +#define BCMA_GMAC_CMN_UDF_1_C3_C0 0x370
5449 +#define BCMA_GMAC_CMN_UDF_1_C7_C4 0x374
5450 +#define BCMA_GMAC_CMN_UDF_1_C8 0x378
5451 +#define BCMA_GMAC_CMN_UDF_2_C3_C0 0x380
5452 +#define BCMA_GMAC_CMN_UDF_2_C7_C4 0x384
5453 +#define BCMA_GMAC_CMN_UDF_2_C8 0x388
5454 +#define BCMA_GMAC_CMN_UDF_0_D3_D0 0x390
5455 +#define BCMA_GMAC_CMN_UDF_0_D7_D4 0x394
5456 +#define BCMA_GMAC_CMN_UDF_0_D11_D8 0x394
5458 +struct bcma_drv_gmac_cmn {
5459 + struct bcma_device *core;
5461 + /* Drivers accessing BCMA_GMAC_CMN_PHY_ACCESS and
5462 + * BCMA_GMAC_CMN_PHY_CTL need to take that mutex first. */
5463 + struct mutex phy_mutex;
5466 +/* Register access */
5467 +#define gmac_cmn_read16(gc, offset) bcma_read16((gc)->core, offset)
5468 +#define gmac_cmn_read32(gc, offset) bcma_read32((gc)->core, offset)
5469 +#define gmac_cmn_write16(gc, offset, val) bcma_write16((gc)->core, offset, val)
5470 +#define gmac_cmn_write32(gc, offset, val) bcma_write32((gc)->core, offset, val)
5472 +#ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
5473 +extern void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
5475 +static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc) { }
5478 +#endif /* LINUX_BCMA_DRIVER_GMAC_CMN_H_ */
5479 --- a/include/linux/bcma/bcma_driver_mips.h
5480 +++ b/include/linux/bcma/bcma_driver_mips.h
5482 #define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
5483 #define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
5485 +#define BCMA_MIPS_OOBSELINA74 0x004
5486 #define BCMA_MIPS_OOBSELOUTA30 0x100
5489 @@ -35,17 +36,24 @@ struct bcma_device;
5490 struct bcma_drv_mips {
5491 struct bcma_device *core;
5493 - unsigned int assigned_irqs;
5494 + u8 early_setup_done:1;
5497 #ifdef CONFIG_BCMA_DRIVER_MIPS
5498 extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
5499 +extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
5501 +extern unsigned int bcma_core_irq(struct bcma_device *core);
5503 static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
5504 +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
5506 +static inline unsigned int bcma_core_irq(struct bcma_device *core)
5512 extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
5514 -extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
5516 #endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
5517 --- a/include/linux/bcma/bcma_driver_pci.h
5518 +++ b/include/linux/bcma/bcma_driver_pci.h
5519 @@ -53,11 +53,47 @@ struct pci_dev;
5520 #define BCMA_CORE_PCI_SBTOPCI1_MASK 0xFC000000
5521 #define BCMA_CORE_PCI_SBTOPCI2 0x0108 /* Backplane to PCI translation 2 (sbtopci2) */
5522 #define BCMA_CORE_PCI_SBTOPCI2_MASK 0xC0000000
5523 +#define BCMA_CORE_PCI_CONFIG_ADDR 0x0120 /* pcie config space access */
5524 +#define BCMA_CORE_PCI_CONFIG_DATA 0x0124 /* pcie config space access */
5525 +#define BCMA_CORE_PCI_MDIO_CONTROL 0x0128 /* controls the mdio access */
5526 +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */
5527 +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL 0x2
5528 +#define BCMA_CORE_PCI_MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */
5529 +#define BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE 0x100 /* Tranaction complete */
5530 +#define BCMA_CORE_PCI_MDIO_DATA 0x012c /* Data to the mdio access */
5531 +#define BCMA_CORE_PCI_MDIODATA_MASK 0x0000ffff /* data 2 bytes */
5532 +#define BCMA_CORE_PCI_MDIODATA_TA 0x00020000 /* Turnaround */
5533 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD 18 /* Regaddr shift (rev < 10) */
5534 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK_OLD 0x003c0000 /* Regaddr Mask (rev < 10) */
5535 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD 22 /* Physmedia devaddr shift (rev < 10) */
5536 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK_OLD 0x0fc00000 /* Physmedia devaddr Mask (rev < 10) */
5537 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF 18 /* Regaddr shift */
5538 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK 0x007c0000 /* Regaddr Mask */
5539 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF 23 /* Physmedia devaddr shift */
5540 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK 0x0f800000 /* Physmedia devaddr Mask */
5541 +#define BCMA_CORE_PCI_MDIODATA_WRITE 0x10000000 /* write Transaction */
5542 +#define BCMA_CORE_PCI_MDIODATA_READ 0x20000000 /* Read Transaction */
5543 +#define BCMA_CORE_PCI_MDIODATA_START 0x40000000 /* start of Transaction */
5544 +#define BCMA_CORE_PCI_MDIODATA_DEV_ADDR 0x0 /* dev address for serdes */
5545 +#define BCMA_CORE_PCI_MDIODATA_BLK_ADDR 0x1F /* blk address for serdes */
5546 +#define BCMA_CORE_PCI_MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */
5547 +#define BCMA_CORE_PCI_MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */
5548 +#define BCMA_CORE_PCI_MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */
5549 +#define BCMA_CORE_PCI_PCIEIND_ADDR 0x0130 /* indirect access to the internal register */
5550 +#define BCMA_CORE_PCI_PCIEIND_DATA 0x0134 /* Data to/from the internal regsiter */
5551 +#define BCMA_CORE_PCI_CLKREQENCTRL 0x0138 /* >= rev 6, Clkreq rdma control */
5552 #define BCMA_CORE_PCI_PCICFG0 0x0400 /* PCI config space 0 (rev >= 8) */
5553 #define BCMA_CORE_PCI_PCICFG1 0x0500 /* PCI config space 1 (rev >= 8) */
5554 #define BCMA_CORE_PCI_PCICFG2 0x0600 /* PCI config space 2 (rev >= 8) */
5555 #define BCMA_CORE_PCI_PCICFG3 0x0700 /* PCI config space 3 (rev >= 8) */
5556 #define BCMA_CORE_PCI_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
5557 +#define BCMA_CORE_PCI_SPROM_PI_OFFSET 0 /* first word */
5558 +#define BCMA_CORE_PCI_SPROM_PI_MASK 0xf000 /* bit 15:12 */
5559 +#define BCMA_CORE_PCI_SPROM_PI_SHIFT 12 /* bit 15:12 */
5560 +#define BCMA_CORE_PCI_SPROM_MISC_CONFIG 5 /* word 5 */
5561 +#define BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST 0x8000 /* bit 15 */
5562 +#define BCMA_CORE_PCI_SPROM_CLKREQ_OFFSET_REV5 20 /* word 20 for srom rev <= 5 */
5563 +#define BCMA_CORE_PCI_SPROM_CLKREQ_ENB 0x0800 /* bit 11 */
5566 #define BCMA_CORE_PCI_SBTOPCI_MEM 0x00000000
5567 @@ -72,20 +108,143 @@ struct pci_dev;
5568 #define BCMA_CORE_PCI_SBTOPCI_RC_READL 0x00000010 /* Memory read line */
5569 #define BCMA_CORE_PCI_SBTOPCI_RC_READM 0x00000020 /* Memory read multiple */
5571 +/* PCIE protocol PHY diagnostic registers */
5572 +#define BCMA_CORE_PCI_PLP_MODEREG 0x200 /* Mode */
5573 +#define BCMA_CORE_PCI_PLP_STATUSREG 0x204 /* Status */
5574 +#define BCMA_CORE_PCI_PLP_POLARITYINV_STAT 0x10 /* Status reg PCIE_PLP_STATUSREG */
5575 +#define BCMA_CORE_PCI_PLP_LTSSMCTRLREG 0x208 /* LTSSM control */
5576 +#define BCMA_CORE_PCI_PLP_LTLINKNUMREG 0x20c /* Link Training Link number */
5577 +#define BCMA_CORE_PCI_PLP_LTLANENUMREG 0x210 /* Link Training Lane number */
5578 +#define BCMA_CORE_PCI_PLP_LTNFTSREG 0x214 /* Link Training N_FTS */
5579 +#define BCMA_CORE_PCI_PLP_ATTNREG 0x218 /* Attention */
5580 +#define BCMA_CORE_PCI_PLP_ATTNMASKREG 0x21C /* Attention Mask */
5581 +#define BCMA_CORE_PCI_PLP_RXERRCTR 0x220 /* Rx Error */
5582 +#define BCMA_CORE_PCI_PLP_RXFRMERRCTR 0x224 /* Rx Framing Error */
5583 +#define BCMA_CORE_PCI_PLP_RXERRTHRESHREG 0x228 /* Rx Error threshold */
5584 +#define BCMA_CORE_PCI_PLP_TESTCTRLREG 0x22C /* Test Control reg */
5585 +#define BCMA_CORE_PCI_PLP_SERDESCTRLOVRDREG 0x230 /* SERDES Control Override */
5586 +#define BCMA_CORE_PCI_PLP_TIMINGOVRDREG 0x234 /* Timing param override */
5587 +#define BCMA_CORE_PCI_PLP_RXTXSMDIAGREG 0x238 /* RXTX State Machine Diag */
5588 +#define BCMA_CORE_PCI_PLP_LTSSMDIAGREG 0x23C /* LTSSM State Machine Diag */
5590 +/* PCIE protocol DLLP diagnostic registers */
5591 +#define BCMA_CORE_PCI_DLLP_LCREG 0x100 /* Link Control */
5592 +#define BCMA_CORE_PCI_DLLP_LSREG 0x104 /* Link Status */
5593 +#define BCMA_CORE_PCI_DLLP_LAREG 0x108 /* Link Attention */
5594 +#define BCMA_CORE_PCI_DLLP_LSREG_LINKUP (1 << 16)
5595 +#define BCMA_CORE_PCI_DLLP_LAMASKREG 0x10C /* Link Attention Mask */
5596 +#define BCMA_CORE_PCI_DLLP_NEXTTXSEQNUMREG 0x110 /* Next Tx Seq Num */
5597 +#define BCMA_CORE_PCI_DLLP_ACKEDTXSEQNUMREG 0x114 /* Acked Tx Seq Num */
5598 +#define BCMA_CORE_PCI_DLLP_PURGEDTXSEQNUMREG 0x118 /* Purged Tx Seq Num */
5599 +#define BCMA_CORE_PCI_DLLP_RXSEQNUMREG 0x11C /* Rx Sequence Number */
5600 +#define BCMA_CORE_PCI_DLLP_LRREG 0x120 /* Link Replay */
5601 +#define BCMA_CORE_PCI_DLLP_LACKTOREG 0x124 /* Link Ack Timeout */
5602 +#define BCMA_CORE_PCI_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */
5603 +#define BCMA_CORE_PCI_ASPMTIMER_EXTEND 0x01000000 /* > rev7: enable extend ASPM timer */
5604 +#define BCMA_CORE_PCI_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr */
5605 +#define BCMA_CORE_PCI_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr */
5606 +#define BCMA_CORE_PCI_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr */
5607 +#define BCMA_CORE_PCI_DLLP_RTRRWREG 0x138 /* Retry buffer Read/Write */
5608 +#define BCMA_CORE_PCI_DLLP_ECTHRESHREG 0x13C /* Error Count Threshold */
5609 +#define BCMA_CORE_PCI_DLLP_TLPERRCTRREG 0x140 /* TLP Error Counter */
5610 +#define BCMA_CORE_PCI_DLLP_ERRCTRREG 0x144 /* Error Counter */
5611 +#define BCMA_CORE_PCI_DLLP_NAKRXCTRREG 0x148 /* NAK Received Counter */
5612 +#define BCMA_CORE_PCI_DLLP_TESTREG 0x14C /* Test */
5613 +#define BCMA_CORE_PCI_DLLP_PKTBIST 0x150 /* Packet BIST */
5614 +#define BCMA_CORE_PCI_DLLP_PCIE11 0x154 /* DLLP PCIE 1.1 reg */
5616 +/* SERDES RX registers */
5617 +#define BCMA_CORE_PCI_SERDES_RX_CTRL 1 /* Rx cntrl */
5618 +#define BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE 0x80 /* rxpolarity_force */
5619 +#define BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY 0x40 /* rxpolarity_value */
5620 +#define BCMA_CORE_PCI_SERDES_RX_TIMER1 2 /* Rx Timer1 */
5621 +#define BCMA_CORE_PCI_SERDES_RX_CDR 6 /* CDR */
5622 +#define BCMA_CORE_PCI_SERDES_RX_CDRBW 7 /* CDR BW */
5624 +/* SERDES PLL registers */
5625 +#define BCMA_CORE_PCI_SERDES_PLL_CTRL 1 /* PLL control reg */
5626 +#define BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN 0x4000 /* bit 14 is FREQDET on */
5628 /* PCIcore specific boardflags */
5629 #define BCMA_CORE_PCI_BFL_NOPCI 0x00000400 /* Board leaves PCI floating */
5631 +/* PCIE Config space accessing MACROS */
5632 +#define BCMA_CORE_PCI_CFG_BUS_SHIFT 24 /* Bus shift */
5633 +#define BCMA_CORE_PCI_CFG_SLOT_SHIFT 19 /* Slot/Device shift */
5634 +#define BCMA_CORE_PCI_CFG_FUN_SHIFT 16 /* Function shift */
5635 +#define BCMA_CORE_PCI_CFG_OFF_SHIFT 0 /* Register shift */
5637 +#define BCMA_CORE_PCI_CFG_BUS_MASK 0xff /* Bus mask */
5638 +#define BCMA_CORE_PCI_CFG_SLOT_MASK 0x1f /* Slot/Device mask */
5639 +#define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */
5640 +#define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */
5642 +#define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8
5644 +#define BCMA_CORE_PCI_
5646 +/* MDIO devices (SERDES modules) */
5647 +#define BCMA_CORE_PCI_MDIO_IEEE0 0x000
5648 +#define BCMA_CORE_PCI_MDIO_IEEE1 0x001
5649 +#define BCMA_CORE_PCI_MDIO_BLK0 0x800
5650 +#define BCMA_CORE_PCI_MDIO_BLK1 0x801
5651 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT0 0x16
5652 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT1 0x17
5653 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT2 0x18
5654 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT3 0x19
5655 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT4 0x1A
5656 +#define BCMA_CORE_PCI_MDIO_BLK2 0x802
5657 +#define BCMA_CORE_PCI_MDIO_BLK3 0x803
5658 +#define BCMA_CORE_PCI_MDIO_BLK4 0x804
5659 +#define BCMA_CORE_PCI_MDIO_TXPLL 0x808 /* TXPLL register block idx */
5660 +#define BCMA_CORE_PCI_MDIO_TXCTRL0 0x820
5661 +#define BCMA_CORE_PCI_MDIO_SERDESID 0x831
5662 +#define BCMA_CORE_PCI_MDIO_RXCTRL0 0x840
5664 +/* PCIE Root Capability Register bits (Host mode only) */
5665 +#define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
5667 +struct bcma_drv_pci;
5670 +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
5671 +struct bcma_drv_pci_host {
5672 + struct bcma_drv_pci *pdev;
5674 + u32 host_cfg_addr;
5675 + spinlock_t cfgspace_lock;
5677 + struct pci_controller pci_controller;
5678 + struct pci_ops pci_ops;
5679 + struct resource mem_resource;
5680 + struct resource io_resource;
5684 struct bcma_drv_pci {
5685 struct bcma_device *core;
5689 +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
5690 + struct bcma_drv_pci_host *host_controller;
5694 /* Register access */
5695 +#define pcicore_read16(pc, offset) bcma_read16((pc)->core, offset)
5696 #define pcicore_read32(pc, offset) bcma_read32((pc)->core, offset)
5697 +#define pcicore_write16(pc, offset, val) bcma_write16((pc)->core, offset, val)
5698 #define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
5700 -extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
5701 +extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
5702 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
5703 struct bcma_device *core, bool enable);
5704 +extern void bcma_core_pci_up(struct bcma_bus *bus);
5705 +extern void bcma_core_pci_down(struct bcma_bus *bus);
5706 +extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up);
5708 +extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
5709 +extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
5711 #endif /* LINUX_BCMA_DRIVER_PCI_H_ */
5712 --- a/include/linux/bcma/bcma_regs.h
5713 +++ b/include/linux/bcma/bcma_regs.h
5715 #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
5716 #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
5717 #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
5718 +#define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
5719 #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
5720 #define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
5721 #define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
5722 #define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
5723 #define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
5724 +#define BCMA_CLKCTLST_EXTRESST_SHIFT 24
5725 /* Is there any BCM4328 on BCMA bus? */
5726 #define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
5727 #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
5729 #define BCMA_IOST_BIST_DONE 0x8000
5730 #define BCMA_RESET_CTL 0x0800
5731 #define BCMA_RESET_CTL_RESET 0x0001
5732 +#define BCMA_RESET_ST 0x0804
5734 /* BCMA PCI config space registers. */
5735 #define BCMA_PCI_PMCSR 0x44
5737 #define BCMA_PCI_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
5738 #define BCMA_PCI_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
5740 +/* SiliconBackplane Address Map.
5741 + * All regions may not exist on all chips.
5743 +#define BCMA_SOC_SDRAM_BASE 0x00000000U /* Physical SDRAM */
5744 +#define BCMA_SOC_PCI_MEM 0x08000000U /* Host Mode sb2pcitranslation0 (64 MB) */
5745 +#define BCMA_SOC_PCI_MEM_SZ (64 * 1024 * 1024)
5746 +#define BCMA_SOC_PCI_CFG 0x0c000000U /* Host Mode sb2pcitranslation1 (64 MB) */
5747 +#define BCMA_SOC_SDRAM_SWAPPED 0x10000000U /* Byteswapped Physical SDRAM */
5748 +#define BCMA_SOC_SDRAM_R2 0x80000000U /* Region 2 for sdram (512 MB) */
5751 +#define BCMA_SOC_PCI_DMA 0x40000000U /* Client Mode sb2pcitranslation2 (1 GB) */
5752 +#define BCMA_SOC_PCI_DMA2 0x80000000U /* Client Mode sb2pcitranslation2 (1 GB) */
5753 +#define BCMA_SOC_PCI_DMA_SZ 0x40000000U /* Client Mode sb2pcitranslation2 size in bytes */
5754 +#define BCMA_SOC_PCIE_DMA_L32 0x00000000U /* PCIE Client Mode sb2pcitranslation2
5755 + * (2 ZettaBytes), low 32 bits
5757 +#define BCMA_SOC_PCIE_DMA_H32 0x80000000U /* PCIE Client Mode sb2pcitranslation2
5758 + * (2 ZettaBytes), high 32 bits
5761 +#define BCMA_SOC_PCI1_MEM 0x40000000U /* Host Mode sb2pcitranslation0 (64 MB) */
5762 +#define BCMA_SOC_PCI1_CFG 0x44000000U /* Host Mode sb2pcitranslation1 (64 MB) */
5763 +#define BCMA_SOC_PCIE1_DMA_H32 0xc0000000U /* PCIE Client Mode sb2pcitranslation2
5764 + * (2 ZettaBytes), high 32 bits
5767 +#define BCMA_SOC_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */
5768 +#define BCMA_SOC_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */
5769 +#define BCMA_SOC_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
5770 +#define BCMA_SOC_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
5772 #endif /* LINUX_BCMA_REGS_H_ */
5773 --- a/drivers/net/wireless/b43/main.c
5774 +++ b/drivers/net/wireless/b43/main.c
5775 @@ -4618,7 +4618,7 @@ static int b43_wireless_core_init(struct
5776 switch (dev->dev->bus_type) {
5777 #ifdef CONFIG_B43_BCMA
5779 - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
5780 + bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
5781 dev->dev->bdev, true);
5784 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
5785 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
5786 @@ -533,7 +533,7 @@ ai_buscore_setup(struct si_info *sii, st
5788 /* fixup necessary chip/core configurations */
5790 - sii->pch = pcicore_init(&sii->pub, sii->icbus->drv_pci.core);
5791 + sii->pch = pcicore_init(&sii->pub, sii->icbus->drv_pci[0].core);
5792 if (sii->pch == NULL)