1 --- a/arch/mips/bcm47xx/serial.c
2 +++ b/arch/mips/bcm47xx/serial.c
3 @@ -62,7 +62,7 @@ static int __init uart8250_init_bcma(voi
5 p->mapbase = (unsigned int) bcma_port->regs;
6 p->membase = (void *) bcma_port->regs;
7 - p->irq = bcma_port->irq + 2;
8 + p->irq = bcma_port->irq;
9 p->uartclk = bcma_port->baud_base;
10 p->regshift = bcma_port->reg_shift;
12 --- a/drivers/bcma/Kconfig
13 +++ b/drivers/bcma/Kconfig
14 @@ -26,6 +26,7 @@ config BCMA_HOST_PCI_POSSIBLE
16 bool "Support for BCMA on PCI-host bus"
17 depends on BCMA_HOST_PCI_POSSIBLE
20 config BCMA_DRIVER_PCI_HOSTMODE
21 bool "Driver for PCI core working in hostmode"
22 @@ -65,6 +66,14 @@ config BCMA_DRIVER_GMAC_CMN
26 +config BCMA_DRIVER_GPIO
27 + bool "BCMA GPIO driver"
28 + depends on BCMA && GPIOLIB
30 + Driver to provide access to the GPIO pins of the bcma bus.
37 --- a/drivers/bcma/Makefile
38 +++ b/drivers/bcma/Makefile
39 @@ -6,6 +6,7 @@ bcma-y += driver_pci.o
40 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
41 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
42 bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
43 +bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
44 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
45 bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
46 obj-$(CONFIG_BCMA) += bcma.o
47 --- a/drivers/bcma/bcma_private.h
48 +++ b/drivers/bcma/bcma_private.h
53 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
55 int __devinit bcma_bus_register(struct bcma_bus *bus);
56 void bcma_bus_unregister(struct bcma_bus *bus);
57 int __init bcma_bus_early_register(struct bcma_bus *bus,
58 @@ -31,6 +33,8 @@ int __init bcma_bus_early_register(struc
59 int bcma_bus_suspend(struct bcma_bus *bus);
60 int bcma_bus_resume(struct bcma_bus *bus);
62 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
66 int bcma_bus_scan(struct bcma_bus *bus);
67 @@ -45,11 +49,12 @@ int bcma_sprom_get(struct bcma_bus *bus)
68 /* driver_chipcommon.c */
69 #ifdef CONFIG_BCMA_DRIVER_MIPS
70 void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
71 +extern struct platform_device bcma_pflash_dev;
72 #endif /* CONFIG_BCMA_DRIVER_MIPS */
74 /* driver_chipcommon_pmu.c */
75 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
76 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
77 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
78 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
80 #ifdef CONFIG_BCMA_SFLASH
81 /* driver_chipcommon_sflash.c */
82 @@ -84,9 +89,26 @@ extern void __exit bcma_host_pci_exit(vo
84 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
86 +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
88 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
89 bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
90 void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
91 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
93 +#ifdef CONFIG_BCMA_DRIVER_GPIO
95 +int bcma_gpio_init(struct bcma_drv_cc *cc);
96 +int bcma_gpio_unregister(struct bcma_drv_cc *cc);
98 +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
102 +static inline int bcma_gpio_unregister(struct bcma_drv_cc *cc)
106 +#endif /* CONFIG_BCMA_DRIVER_GPIO */
109 --- a/drivers/bcma/core.c
110 +++ b/drivers/bcma/core.c
112 #include <linux/export.h>
113 #include <linux/bcma/bcma.h>
115 +static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask,
116 + u32 value, int timeout)
118 + unsigned long deadline = jiffies + timeout;
122 + val = bcma_aread32(core, reg);
123 + if ((val & mask) == value)
127 + } while (!time_after_eq(jiffies, deadline));
129 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
134 bool bcma_core_is_enabled(struct bcma_device *core)
136 if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC))
137 @@ -25,13 +44,15 @@ void bcma_core_disable(struct bcma_devic
138 if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
141 - bcma_awrite32(core, BCMA_IOCTL, flags);
142 - bcma_aread32(core, BCMA_IOCTL);
144 + bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300);
146 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
147 bcma_aread32(core, BCMA_RESET_CTL);
150 + bcma_awrite32(core, BCMA_IOCTL, flags);
151 + bcma_aread32(core, BCMA_IOCTL);
154 EXPORT_SYMBOL_GPL(bcma_core_disable);
156 @@ -43,6 +64,7 @@ int bcma_core_enable(struct bcma_device
157 bcma_aread32(core, BCMA_IOCTL);
159 bcma_awrite32(core, BCMA_RESET_CTL, 0);
160 + bcma_aread32(core, BCMA_RESET_CTL);
163 bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
164 @@ -104,7 +126,13 @@ void bcma_core_pll_ctl(struct bcma_devic
166 bcma_err(core->bus, "PLL enable timeout\n");
168 - bcma_warn(core->bus, "Disabling PLL not supported yet!\n");
170 + * Mask the PLL but don't wait for it to be disabled. PLL may be
171 + * shared between cores and will be still up if there is another
174 + bcma_mask32(core, BCMA_CLKCTLST, ~req);
175 + bcma_read32(core, BCMA_CLKCTLST);
178 EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
179 --- a/drivers/bcma/driver_chipcommon.c
180 +++ b/drivers/bcma/driver_chipcommon.c
183 * Copyright 2005, Broadcom Corporation
184 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
185 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
187 * Licensed under the GNU/GPL. See COPYING for details.
190 #include "bcma_private.h"
191 +#include <linux/bcm47xx_wdt.h>
192 #include <linux/export.h>
193 +#include <linux/platform_device.h>
194 #include <linux/bcma/bcma.h>
196 static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
197 @@ -22,23 +25,130 @@ static inline u32 bcma_cc_write32_masked
201 -void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
202 +u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
205 - u32 leddc_off = 90;
206 + if (cc->capabilities & BCMA_CC_CAP_PMU)
207 + return bcma_pmu_get_alp_clock(cc);
209 - if (cc->setup_done)
212 +EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
214 +static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
216 + struct bcma_bus *bus = cc->core->bus;
219 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
220 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
222 + else if (cc->core->id.rev < 26)
225 + nb = (cc->core->id.rev >= 37) ? 32 : 24;
232 + return (1 << nb) - 1;
235 +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
238 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
240 + return bcma_chipco_watchdog_timer_set(cc, ticks);
243 +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
246 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
249 + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
250 + return ticks / cc->ticks_per_ms;
253 +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
255 + struct bcma_bus *bus = cc->core->bus;
257 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
258 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
259 + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
260 + return bcma_chipco_get_alp_clock(cc) / 4000;
262 + /* based on 32KHz ILP clock */
265 + return bcma_chipco_get_alp_clock(cc) / 1000;
269 +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
271 + struct bcm47xx_wdt wdt = {};
272 + struct platform_device *pdev;
274 + wdt.driver_data = cc;
275 + wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
276 + wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
277 + wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
279 + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
280 + cc->core->bus->num, &wdt,
283 + return PTR_ERR(pdev);
285 + cc->watchdog = pdev;
290 +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
292 + if (cc->early_setup_done)
295 + spin_lock_init(&cc->gpio_lock);
297 if (cc->core->id.rev >= 11)
298 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
299 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
300 if (cc->core->id.rev >= 35)
301 cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);
303 + if (cc->capabilities & BCMA_CC_CAP_PMU)
304 + bcma_pmu_early_init(cc);
306 + cc->early_setup_done = true;
309 +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
312 + u32 leddc_off = 90;
314 + if (cc->setup_done)
317 + bcma_core_chipcommon_early_init(cc);
319 if (cc->core->id.rev >= 20) {
320 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
321 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
322 + u32 pullup = 0, pulldown = 0;
324 + if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) {
326 + pulldown = 0x20500;
329 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup);
330 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown);
333 if (cc->capabilities & BCMA_CC_CAP_PMU)
334 @@ -56,15 +166,33 @@ void bcma_core_chipcommon_init(struct bc
335 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
336 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
338 + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
340 cc->setup_done = true;
343 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
344 -void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
345 +u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
348 - bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
350 + enum bcma_clkmode clkmode;
352 + maxt = bcma_chipco_watchdog_get_max_timer(cc);
353 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
356 + else if (ticks > maxt)
358 + bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
360 + clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
361 + bcma_core_set_clockmode(cc->core, clkmode);
365 + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
370 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
371 @@ -84,28 +212,99 @@ u32 bcma_chipco_gpio_in(struct bcma_drv_
373 u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
375 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
376 + unsigned long flags;
379 + spin_lock_irqsave(&cc->gpio_lock, flags);
380 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
381 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
385 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
387 u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
389 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
390 + unsigned long flags;
393 + spin_lock_irqsave(&cc->gpio_lock, flags);
394 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
395 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
399 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
402 + * If the bit is set to 0, chipcommon controlls this GPIO,
403 + * if the bit is set to 1, it is used by some part of the chip and not our code.
405 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
407 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
408 + unsigned long flags;
411 + spin_lock_irqsave(&cc->gpio_lock, flags);
412 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
413 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
417 EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
419 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
421 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
422 + unsigned long flags;
425 + spin_lock_irqsave(&cc->gpio_lock, flags);
426 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
427 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
432 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
434 - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
435 + unsigned long flags;
438 + spin_lock_irqsave(&cc->gpio_lock, flags);
439 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
440 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
445 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value)
447 + unsigned long flags;
450 + if (cc->core->id.rev < 20)
453 + spin_lock_irqsave(&cc->gpio_lock, flags);
454 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value);
455 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
460 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value)
462 + unsigned long flags;
465 + if (cc->core->id.rev < 20)
468 + spin_lock_irqsave(&cc->gpio_lock, flags);
469 + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value);
470 + spin_unlock_irqrestore(&cc->gpio_lock, flags);
475 #ifdef CONFIG_BCMA_DRIVER_MIPS
476 @@ -118,8 +317,7 @@ void bcma_chipco_serial_init(struct bcma
477 struct bcma_serial_port *ports = cc->serial_ports;
479 if (ccrev >= 11 && ccrev != 15) {
480 - /* Fixed ALP clock */
481 - baud_base = bcma_pmu_alp_clock(cc);
482 + baud_base = bcma_chipco_get_alp_clock(cc);
484 /* Turn off UART clock before switching clocksource. */
485 bcma_cc_write32(cc, BCMA_CC_CORECTL,
486 @@ -141,7 +339,7 @@ void bcma_chipco_serial_init(struct bcma
490 - irq = bcma_core_mips_irq(cc->core);
491 + irq = bcma_core_irq(cc->core);
493 /* Determine the registers of the UARTs */
494 cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART);
495 --- a/drivers/bcma/driver_chipcommon_nflash.c
496 +++ b/drivers/bcma/driver_chipcommon_nflash.c
498 * Licensed under the GNU/GPL. See COPYING for details.
501 +#include "bcma_private.h"
503 #include <linux/platform_device.h>
504 #include <linux/bcma/bcma.h>
506 -#include "bcma_private.h"
508 struct platform_device bcma_nflash_dev = {
509 .name = "bcma_nflash",
511 @@ -21,7 +21,7 @@ int bcma_nflash_init(struct bcma_drv_cc
512 struct bcma_bus *bus = cc->core->bus;
514 if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
515 - cc->core->id.rev != 0x38) {
516 + cc->core->id.rev != 38) {
517 bcma_err(bus, "NAND flash on unsupported board!\n");
520 @@ -32,6 +32,9 @@ int bcma_nflash_init(struct bcma_drv_cc
523 cc->nflash.present = true;
524 + if (cc->core->id.rev == 38 &&
525 + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
526 + cc->nflash.boot = true;
528 /* Prepare platform device, but don't register it yet. It's too early,
529 * malloc (required by device_private_init) is not available yet. */
530 --- a/drivers/bcma/driver_chipcommon_pmu.c
531 +++ b/drivers/bcma/driver_chipcommon_pmu.c
533 #include <linux/export.h>
534 #include <linux/bcma/bcma.h>
536 -static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
537 +u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
539 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
540 bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
541 return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
543 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
545 void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
547 @@ -55,6 +56,109 @@ void bcma_chipco_regctl_maskset(struct b
549 EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
551 +static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc)
553 + u32 ilp_ctl, alp_hz;
555 + if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) &
556 + BCMA_CC_PMU_STAT_EXT_LPO_AVAIL))
559 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
560 + BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
561 + usleep_range(1000, 2000);
563 + ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
564 + ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK;
566 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
568 + alp_hz = ilp_ctl * 32768 / 4;
569 + return (alp_hz + 50000) / 100000 * 100;
572 +static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq)
574 + struct bcma_bus *bus = cc->core->bus;
575 + u32 freq_tgt_target = 0, freq_tgt_current;
578 + switch (bus->chipinfo.id) {
579 + case BCMA_CHIP_ID_BCM43142:
580 + /* pmu2_xtaltab0_adfll_485 */
581 + switch (xtalfreq) {
583 + freq_tgt_target = 0x50D52;
586 + freq_tgt_target = 0x307FE;
589 + freq_tgt_target = 0x254EA;
592 + freq_tgt_target = 0x19EF8;
595 + freq_tgt_target = 0x12A75;
601 + if (!freq_tgt_target) {
602 + bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n",
607 + pll0 = bcma_chipco_pll_read(cc, BCMA_CC_PMU15_PLL_PLLCTL0);
608 + freq_tgt_current = (pll0 & BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK) >>
609 + BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
611 + if (freq_tgt_current == freq_tgt_target) {
612 + bcma_debug(bus, "Target TGT frequency already set\n");
617 + switch (bus->chipinfo.id) {
618 + case BCMA_CHIP_ID_BCM43142:
619 + mask = (u32)~(BCMA_RES_4314_HT_AVAIL |
620 + BCMA_RES_4314_MACPHY_CLK_AVAIL);
622 + bcma_cc_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask);
623 + bcma_cc_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask);
624 + bcma_wait_value(cc->core, BCMA_CLKCTLST,
625 + BCMA_CLKCTLST_HAVEHT, 0, 20000);
629 + pll0 &= ~BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK;
630 + pll0 |= freq_tgt_target << BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
631 + bcma_chipco_pll_write(cc, BCMA_CC_PMU15_PLL_PLLCTL0, pll0);
634 + if (cc->pmu.rev >= 2)
635 + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
637 + /* TODO: Do we need to update OTP? */
640 +static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
642 + struct bcma_bus *bus = cc->core->bus;
643 + u32 xtalfreq = bcma_pmu_xtalfreq(cc);
645 + switch (bus->chipinfo.id) {
646 + case BCMA_CHIP_ID_BCM43142:
649 + bcma_pmu2_pll_init0(cc, xtalfreq);
654 static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
656 struct bcma_bus *bus = cc->core->bus;
657 @@ -65,6 +169,25 @@ static void bcma_pmu_resources_init(stru
661 + case BCMA_CHIP_ID_BCM43142:
662 + min_msk = BCMA_RES_4314_LPLDO_PU |
663 + BCMA_RES_4314_PMU_SLEEP_DIS |
664 + BCMA_RES_4314_PMU_BG_PU |
665 + BCMA_RES_4314_CBUCK_LPOM_PU |
666 + BCMA_RES_4314_CBUCK_PFM_PU |
667 + BCMA_RES_4314_CLDO_PU |
668 + BCMA_RES_4314_LPLDO2_LVM |
669 + BCMA_RES_4314_WL_PMU_PU |
670 + BCMA_RES_4314_LDO3P3_PU |
671 + BCMA_RES_4314_OTP_PU |
672 + BCMA_RES_4314_WL_PWRSW_PU |
673 + BCMA_RES_4314_LQ_AVAIL |
674 + BCMA_RES_4314_LOGIC_RET |
675 + BCMA_RES_4314_MEM_SLEEP |
676 + BCMA_RES_4314_MACPHY_RET |
677 + BCMA_RES_4314_WL_CORE_READY;
678 + max_msk = 0x3FFFFFFF;
681 bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
683 @@ -144,7 +267,7 @@ static void bcma_pmu_workarounds(struct
687 -void bcma_pmu_init(struct bcma_drv_cc *cc)
688 +void bcma_pmu_early_init(struct bcma_drv_cc *cc)
692 @@ -153,7 +276,10 @@ void bcma_pmu_init(struct bcma_drv_cc *c
694 bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
695 cc->pmu.rev, pmucap);
698 +void bcma_pmu_init(struct bcma_drv_cc *cc)
700 if (cc->pmu.rev == 1)
701 bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
702 ~BCMA_CC_PMU_CTL_NOILPONW);
703 @@ -161,28 +287,45 @@ void bcma_pmu_init(struct bcma_drv_cc *c
704 bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
705 BCMA_CC_PMU_CTL_NOILPONW);
707 + bcma_pmu_pll_init(cc);
708 bcma_pmu_resources_init(cc);
709 bcma_pmu_workarounds(cc);
712 -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
713 +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
715 struct bcma_bus *bus = cc->core->bus;
717 switch (bus->chipinfo.id) {
718 + case BCMA_CHIP_ID_BCM4313:
719 + case BCMA_CHIP_ID_BCM43224:
720 + case BCMA_CHIP_ID_BCM43225:
721 + case BCMA_CHIP_ID_BCM43227:
722 + case BCMA_CHIP_ID_BCM43228:
723 + case BCMA_CHIP_ID_BCM4331:
724 + case BCMA_CHIP_ID_BCM43421:
725 + case BCMA_CHIP_ID_BCM43428:
726 + case BCMA_CHIP_ID_BCM43431:
727 case BCMA_CHIP_ID_BCM4716:
728 - case BCMA_CHIP_ID_BCM4748:
729 case BCMA_CHIP_ID_BCM47162:
730 - case BCMA_CHIP_ID_BCM4313:
731 - case BCMA_CHIP_ID_BCM5357:
732 + case BCMA_CHIP_ID_BCM4748:
733 case BCMA_CHIP_ID_BCM4749:
734 + case BCMA_CHIP_ID_BCM5357:
735 case BCMA_CHIP_ID_BCM53572:
736 + case BCMA_CHIP_ID_BCM6362:
739 - case BCMA_CHIP_ID_BCM5356:
740 case BCMA_CHIP_ID_BCM4706:
741 + case BCMA_CHIP_ID_BCM5356:
744 + case BCMA_CHIP_ID_BCM43460:
745 + case BCMA_CHIP_ID_BCM4352:
746 + case BCMA_CHIP_ID_BCM4360:
747 + if (cc->status & BCMA_CC_CHIPST_4360_XTAL_40MZ)
748 + return 40000 * 1000;
750 + return 20000 * 1000;
752 bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
753 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
754 @@ -193,7 +336,7 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_c
755 /* Find the output of the "m" pll divider given pll controls that start with
756 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
758 -static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
759 +static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
761 u32 tmp, div, ndiv, p1, p2, fc;
762 struct bcma_bus *bus = cc->core->bus;
763 @@ -222,14 +365,14 @@ static u32 bcma_pmu_clock(struct bcma_dr
764 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
766 /* Do calculation in Mhz */
767 - fc = bcma_pmu_alp_clock(cc) / 1000000;
768 + fc = bcma_pmu_get_alp_clock(cc) / 1000000;
769 fc = (p1 * ndiv * fc) / p2;
771 /* Return clock in Hertz */
772 return (fc / div) * 1000000;
775 -static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
776 +static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
778 u32 tmp, ndiv, p1div, p2div;
780 @@ -260,7 +403,7 @@ static u32 bcma_pmu_clock_bcm4706(struct
783 /* query bus clock frequency for PMU-enabled chipcommon */
784 -static u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
785 +u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
787 struct bcma_bus *bus = cc->core->bus;
789 @@ -268,40 +411,43 @@ static u32 bcma_pmu_get_clockcontrol(str
790 case BCMA_CHIP_ID_BCM4716:
791 case BCMA_CHIP_ID_BCM4748:
792 case BCMA_CHIP_ID_BCM47162:
793 - return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
794 - BCMA_CC_PMU5_MAINPLL_SSB);
795 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
796 + BCMA_CC_PMU5_MAINPLL_SSB);
797 case BCMA_CHIP_ID_BCM5356:
798 - return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
799 - BCMA_CC_PMU5_MAINPLL_SSB);
800 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
801 + BCMA_CC_PMU5_MAINPLL_SSB);
802 case BCMA_CHIP_ID_BCM5357:
803 case BCMA_CHIP_ID_BCM4749:
804 - return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
805 - BCMA_CC_PMU5_MAINPLL_SSB);
806 + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
807 + BCMA_CC_PMU5_MAINPLL_SSB);
808 case BCMA_CHIP_ID_BCM4706:
809 - return bcma_pmu_clock_bcm4706(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
810 - BCMA_CC_PMU5_MAINPLL_SSB);
811 + return bcma_pmu_pll_clock_bcm4706(cc,
812 + BCMA_CC_PMU4706_MAINPLL_PLL0,
813 + BCMA_CC_PMU5_MAINPLL_SSB);
814 case BCMA_CHIP_ID_BCM53572:
817 - bcma_warn(bus, "No backplane clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
818 + bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
819 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
821 return BCMA_CC_PMU_HT_CLOCK;
823 +EXPORT_SYMBOL_GPL(bcma_pmu_get_bus_clock);
825 /* query cpu clock frequency for PMU-enabled chipcommon */
826 -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
827 +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
829 struct bcma_bus *bus = cc->core->bus;
831 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
834 + /* New PMUs can have different clock for bus and CPU */
835 if (cc->pmu.rev >= 5) {
837 switch (bus->chipinfo.id) {
838 case BCMA_CHIP_ID_BCM4706:
839 - return bcma_pmu_clock_bcm4706(cc,
840 + return bcma_pmu_pll_clock_bcm4706(cc,
841 BCMA_CC_PMU4706_MAINPLL_PLL0,
842 BCMA_CC_PMU5_MAINPLL_CPU);
843 case BCMA_CHIP_ID_BCM5356:
844 @@ -316,10 +462,11 @@ u32 bcma_pmu_get_clockcpu(struct bcma_dr
848 - return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
849 + return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
852 - return bcma_pmu_get_clockcontrol(cc);
853 + /* On old PMUs CPU has the same clock as the bus */
854 + return bcma_pmu_get_bus_clock(cc);
857 static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
858 @@ -365,7 +512,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
859 tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
860 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
863 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
866 case BCMA_CHIP_ID_BCM4331:
867 @@ -386,7 +533,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
868 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
872 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
875 case BCMA_CHIP_ID_BCM43224:
876 @@ -419,7 +566,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
877 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
881 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
884 case BCMA_CHIP_ID_BCM4716:
885 @@ -453,7 +600,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
890 + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
893 case BCMA_CHIP_ID_BCM43227:
894 @@ -489,7 +636,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
895 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
899 + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
902 bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
903 --- a/drivers/bcma/driver_chipcommon_sflash.c
904 +++ b/drivers/bcma/driver_chipcommon_sflash.c
906 * Licensed under the GNU/GPL. See COPYING for details.
909 +#include "bcma_private.h"
911 #include <linux/platform_device.h>
912 #include <linux/bcma/bcma.h>
914 -#include "bcma_private.h"
916 static struct resource bcma_sflash_resource = {
917 .name = "bcma_sflash",
918 - .start = BCMA_SFLASH,
919 + .start = BCMA_SOC_FLASH2,
921 .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
923 @@ -30,16 +30,43 @@ struct bcma_sflash_tbl_e {
927 -static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
928 - { "", 0x14, 0x10000, 32, },
929 +static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
930 + { "M25P20", 0x11, 0x10000, 4, },
931 + { "M25P40", 0x12, 0x10000, 8, },
933 + { "M25P16", 0x14, 0x10000, 32, },
934 + { "M25P32", 0x15, 0x10000, 64, },
935 + { "M25P64", 0x16, 0x10000, 128, },
936 + { "M25FL128", 0x17, 0x10000, 256, },
940 -static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
941 +static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
942 + { "SST25WF512", 1, 0x1000, 16, },
943 + { "SST25VF512", 0x48, 0x1000, 16, },
944 + { "SST25WF010", 2, 0x1000, 32, },
945 + { "SST25VF010", 0x49, 0x1000, 32, },
946 + { "SST25WF020", 3, 0x1000, 64, },
947 + { "SST25VF020", 0x43, 0x1000, 64, },
948 + { "SST25WF040", 4, 0x1000, 128, },
949 + { "SST25VF040", 0x44, 0x1000, 128, },
950 + { "SST25VF040B", 0x8d, 0x1000, 128, },
951 + { "SST25WF080", 5, 0x1000, 256, },
952 + { "SST25VF080B", 0x8e, 0x1000, 256, },
953 + { "SST25VF016", 0x41, 0x1000, 512, },
954 + { "SST25VF032", 0x4a, 0x1000, 1024, },
955 + { "SST25VF064", 0x4b, 0x1000, 2048, },
959 -static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
960 +static const struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
961 + { "AT45DB011", 0xc, 256, 512, },
962 + { "AT45DB021", 0x14, 256, 1024, },
963 + { "AT45DB041", 0x1c, 256, 2048, },
964 + { "AT45DB081", 0x24, 256, 4096, },
965 + { "AT45DB161", 0x2c, 512, 4096, },
966 + { "AT45DB321", 0x34, 512, 8192, },
967 + { "AT45DB642", 0x3c, 1024, 8192, },
971 @@ -62,7 +89,7 @@ int bcma_sflash_init(struct bcma_drv_cc
973 struct bcma_bus *bus = cc->core->bus;
974 struct bcma_sflash *sflash = &cc->sflash;
975 - struct bcma_sflash_tbl_e *e;
976 + const struct bcma_sflash_tbl_e *e;
979 switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
980 @@ -84,6 +111,8 @@ int bcma_sflash_init(struct bcma_drv_cc
987 for (e = bcma_sflash_st_tbl; e->name; e++) {
989 @@ -116,7 +145,7 @@ int bcma_sflash_init(struct bcma_drv_cc
993 - sflash->window = BCMA_SFLASH;
994 + sflash->window = BCMA_SOC_FLASH2;
995 sflash->blocksize = e->blocksize;
996 sflash->numblocks = e->numblocks;
997 sflash->size = sflash->blocksize * sflash->numblocks;
999 +++ b/drivers/bcma/driver_gpio.c
1002 + * Broadcom specific AMBA
1005 + * Copyright 2011, Broadcom Corporation
1006 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
1008 + * Licensed under the GNU/GPL. See COPYING for details.
1011 +#include <linux/gpio.h>
1012 +#include <linux/export.h>
1013 +#include <linux/bcma/bcma.h>
1015 +#include "bcma_private.h"
1017 +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
1019 + return container_of(chip, struct bcma_drv_cc, gpio);
1022 +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
1024 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1026 + return !!bcma_chipco_gpio_in(cc, 1 << gpio);
1029 +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
1032 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1034 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1037 +static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
1039 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1041 + bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
1045 +static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
1048 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1050 + bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
1051 + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
1055 +static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
1057 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1059 + bcma_chipco_gpio_control(cc, 1 << gpio, 0);
1060 + /* clear pulldown */
1061 + bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
1063 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
1068 +static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
1070 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1072 + /* clear pullup */
1073 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
1076 +static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
1078 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
1080 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
1081 + return bcma_core_irq(cc->core);
1086 +int bcma_gpio_init(struct bcma_drv_cc *cc)
1088 + struct gpio_chip *chip = &cc->gpio;
1090 + chip->label = "bcma_gpio";
1091 + chip->owner = THIS_MODULE;
1092 + chip->request = bcma_gpio_request;
1093 + chip->free = bcma_gpio_free;
1094 + chip->get = bcma_gpio_get_value;
1095 + chip->set = bcma_gpio_set_value;
1096 + chip->direction_input = bcma_gpio_direction_input;
1097 + chip->direction_output = bcma_gpio_direction_output;
1098 + chip->to_irq = bcma_gpio_to_irq;
1100 + /* There is just one SoC in one device and its GPIO addresses should be
1101 + * deterministic to address them more easily. The other buses could get
1102 + * a random base number. */
1103 + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
1108 + return gpiochip_add(chip);
1111 +int bcma_gpio_unregister(struct bcma_drv_cc *cc)
1113 + return gpiochip_remove(&cc->gpio);
1115 --- a/drivers/bcma/driver_mips.c
1116 +++ b/drivers/bcma/driver_mips.c
1119 #include <linux/bcma/bcma.h>
1121 +#include <linux/mtd/physmap.h>
1122 +#include <linux/platform_device.h>
1123 #include <linux/serial.h>
1124 #include <linux/serial_core.h>
1125 #include <linux/serial_reg.h>
1126 #include <linux/time.h>
1128 +static const char * const part_probes[] = { "bcm47xxpart", NULL };
1130 +static struct physmap_flash_data bcma_pflash_data = {
1131 + .part_probe_types = part_probes,
1134 +static struct resource bcma_pflash_resource = {
1135 + .name = "bcma_pflash",
1136 + .flags = IORESOURCE_MEM,
1139 +struct platform_device bcma_pflash_dev = {
1140 + .name = "physmap-flash",
1142 + .platform_data = &bcma_pflash_data,
1144 + .resource = &bcma_pflash_resource,
1145 + .num_resources = 1,
1148 /* The 47162a0 hangs when reading MIPS DMP registers registers */
1149 static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
1151 @@ -74,28 +96,41 @@ static u32 bcma_core_mips_irqflag(struct
1152 return dev->core_index;
1153 flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
1155 - return flag & 0x1F;
1157 + return flag & 0x1F;
1162 /* Get the MIPS IRQ assignment for a specified device.
1163 * If unassigned, 0 is returned.
1164 + * If disabled, 5 is returned.
1165 + * If not supported, 6 is returned.
1167 -unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1168 +static unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1170 struct bcma_device *mdev = dev->bus->drv_mips.core;
1174 irqflag = bcma_core_mips_irqflag(dev);
1175 + if (irqflag == 0x3f)
1178 - for (irq = 1; irq <= 4; irq++)
1179 + for (irq = 0; irq <= 4; irq++)
1180 if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
1188 +unsigned int bcma_core_irq(struct bcma_device *dev)
1190 + unsigned int mips_irq = bcma_core_mips_irq(dev);
1191 + return mips_irq <= 4 ? mips_irq + 2 : 0;
1193 -EXPORT_SYMBOL(bcma_core_mips_irq);
1194 +EXPORT_SYMBOL(bcma_core_irq);
1196 static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
1198 @@ -114,7 +149,7 @@ static void bcma_core_mips_set_irq(struc
1199 bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
1200 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
1203 + else if (oldirq != 5)
1204 bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
1206 /* assign the new one */
1207 @@ -123,9 +158,9 @@ static void bcma_core_mips_set_irq(struc
1208 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
1211 - u32 oldirqflag = bcma_read32(mdev,
1212 - BCMA_MIPS_MIPS74K_INTMASK(irq));
1214 + u32 irqinitmask = bcma_read32(mdev,
1215 + BCMA_MIPS_MIPS74K_INTMASK(irq));
1216 + if (irqinitmask) {
1217 struct bcma_device *core;
1219 /* backplane irq line is in use, find out who uses
1220 @@ -133,7 +168,7 @@ static void bcma_core_mips_set_irq(struc
1222 list_for_each_entry(core, &bus->cores, list) {
1223 if ((1 << bcma_core_mips_irqflag(core)) ==
1226 bcma_core_mips_set_irq(core, 0);
1229 @@ -143,15 +178,31 @@ static void bcma_core_mips_set_irq(struc
1233 - bcma_info(bus, "set_irq: core 0x%04x, irq %d => %d\n",
1234 - dev->id.id, oldirq + 2, irq + 2);
1235 + bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n",
1236 + dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2);
1239 +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
1240 + u16 coreid, u8 unit)
1242 + struct bcma_device *core;
1244 + core = bcma_find_core_unit(bus, coreid, unit);
1247 + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
1252 + bcma_core_mips_set_irq(core, irq);
1255 static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
1258 static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
1259 - printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
1260 + printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
1261 for (i = 0; i <= 6; i++)
1262 printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
1264 @@ -171,7 +222,7 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
1265 struct bcma_bus *bus = mcore->core->bus;
1267 if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
1268 - return bcma_pmu_get_clockcpu(&bus->drv_cc);
1269 + return bcma_pmu_get_cpu_clock(&bus->drv_cc);
1271 bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
1273 @@ -181,85 +232,143 @@ EXPORT_SYMBOL(bcma_cpu_clock);
1274 static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
1276 struct bcma_bus *bus = mcore->core->bus;
1277 + struct bcma_drv_cc *cc = &bus->drv_cc;
1278 + struct bcma_pflash *pflash = &cc->pflash;
1280 - switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
1281 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
1282 case BCMA_CC_FLASHT_STSER:
1283 case BCMA_CC_FLASHT_ATSER:
1284 bcma_debug(bus, "Found serial flash\n");
1285 - bcma_sflash_init(&bus->drv_cc);
1286 + bcma_sflash_init(cc);
1288 case BCMA_CC_FLASHT_PARA:
1289 bcma_debug(bus, "Found parallel flash\n");
1290 - bus->drv_cc.pflash.window = 0x1c000000;
1291 - bus->drv_cc.pflash.window_size = 0x02000000;
1292 + pflash->present = true;
1293 + pflash->window = BCMA_SOC_FLASH2;
1294 + pflash->window_size = BCMA_SOC_FLASH2_SZ;
1296 - if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
1297 + if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
1298 BCMA_CC_FLASH_CFG_DS) == 0)
1299 - bus->drv_cc.pflash.buswidth = 1;
1300 + pflash->buswidth = 1;
1302 - bus->drv_cc.pflash.buswidth = 2;
1303 + pflash->buswidth = 2;
1305 + bcma_pflash_data.width = pflash->buswidth;
1306 + bcma_pflash_resource.start = pflash->window;
1307 + bcma_pflash_resource.end = pflash->window + pflash->window_size;
1311 bcma_err(bus, "Flash type not supported\n");
1314 - if (bus->drv_cc.core->id.rev == 38 ||
1315 + if (cc->core->id.rev == 38 ||
1316 bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
1317 - if (bus->drv_cc.capabilities & BCMA_CC_CAP_NFLASH) {
1318 + if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
1319 bcma_debug(bus, "Found NAND flash\n");
1320 - bcma_nflash_init(&bus->drv_cc);
1321 + bcma_nflash_init(cc);
1326 +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
1328 + struct bcma_bus *bus = mcore->core->bus;
1330 + if (mcore->early_setup_done)
1333 + bcma_chipco_serial_init(&bus->drv_cc);
1334 + bcma_core_mips_flash_detect(mcore);
1336 + mcore->early_setup_done = true;
1339 +static void bcma_fix_i2s_irqflag(struct bcma_bus *bus)
1341 + struct bcma_device *cpu, *pcie, *i2s;
1343 + /* Fixup the interrupts in 4716/4748 for i2s core (2010 Broadcom SDK)
1344 + * (IRQ flags > 7 are ignored when setting the interrupt masks)
1346 + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4716 &&
1347 + bus->chipinfo.id != BCMA_CHIP_ID_BCM4748)
1350 + cpu = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1351 + pcie = bcma_find_core(bus, BCMA_CORE_PCIE);
1352 + i2s = bcma_find_core(bus, BCMA_CORE_I2S);
1353 + if (cpu && pcie && i2s &&
1354 + bcma_aread32(cpu, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
1355 + bcma_aread32(pcie, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
1356 + bcma_aread32(i2s, BCMA_MIPS_OOBSELOUTA30) == 0x88) {
1357 + bcma_awrite32(cpu, BCMA_MIPS_OOBSELINA74, 0x07060504);
1358 + bcma_awrite32(pcie, BCMA_MIPS_OOBSELINA74, 0x07060504);
1359 + bcma_awrite32(i2s, BCMA_MIPS_OOBSELOUTA30, 0x87);
1361 + "Moved i2s interrupt to oob line 7 instead of 8\n");
1365 void bcma_core_mips_init(struct bcma_drv_mips *mcore)
1367 struct bcma_bus *bus;
1368 struct bcma_device *core;
1369 bus = mcore->core->bus;
1371 - bcma_info(bus, "Initializing MIPS core...\n");
1372 + if (mcore->setup_done)
1375 - if (!mcore->setup_done)
1376 - mcore->assigned_irqs = 1;
1377 + bcma_debug(bus, "Initializing MIPS core...\n");
1379 - /* Assign IRQs to all cores on the bus */
1380 - list_for_each_entry(core, &bus->cores, list) {
1385 - mips_irq = bcma_core_mips_irq(core);
1389 - core->irq = mips_irq + 2;
1390 - if (core->irq > 5)
1392 - switch (core->id.id) {
1393 - case BCMA_CORE_PCI:
1394 - case BCMA_CORE_PCIE:
1395 - case BCMA_CORE_ETHERNET:
1396 - case BCMA_CORE_ETHERNET_GBIT:
1397 - case BCMA_CORE_MAC_GBIT:
1398 - case BCMA_CORE_80211:
1399 - case BCMA_CORE_USB20_HOST:
1400 - /* These devices get their own IRQ line if available,
1401 - * the rest goes on IRQ0
1403 - if (mcore->assigned_irqs <= 4)
1404 - bcma_core_mips_set_irq(core,
1405 - mcore->assigned_irqs++);
1407 + bcma_core_mips_early_init(mcore);
1409 + bcma_fix_i2s_irqflag(bus);
1411 + switch (bus->chipinfo.id) {
1412 + case BCMA_CHIP_ID_BCM4716:
1413 + case BCMA_CHIP_ID_BCM4748:
1414 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1415 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1416 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
1417 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
1418 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1419 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
1421 + case BCMA_CHIP_ID_BCM5356:
1422 + case BCMA_CHIP_ID_BCM47162:
1423 + case BCMA_CHIP_ID_BCM53572:
1424 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1425 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1426 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1428 + case BCMA_CHIP_ID_BCM5357:
1429 + case BCMA_CHIP_ID_BCM4749:
1430 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
1431 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
1432 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
1433 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
1434 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
1436 + case BCMA_CHIP_ID_BCM4706:
1437 + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
1438 + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
1440 + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
1441 + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
1442 + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
1446 + list_for_each_entry(core, &bus->cores, list) {
1447 + core->irq = bcma_core_irq(core);
1450 + "Unknown device (0x%x) found, can not configure IRQs\n",
1451 + bus->chipinfo.id);
1453 - bcma_info(bus, "IRQ reconfiguration done\n");
1454 + bcma_debug(bus, "IRQ reconfiguration done\n");
1455 bcma_core_mips_dump_irq(bus);
1457 - if (mcore->setup_done)
1460 - bcma_chipco_serial_init(&bus->drv_cc);
1461 - bcma_core_mips_flash_detect(mcore);
1462 mcore->setup_done = true;
1464 --- a/drivers/bcma/driver_pci_host.c
1465 +++ b/drivers/bcma/driver_pci_host.c
1466 @@ -35,11 +35,6 @@ bool __devinit bcma_core_pci_is_in_hostm
1467 chipid_top != 0x5300)
1470 - if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1471 - bcma_info(bus, "This PCI core is disabled and not working\n");
1475 bcma_core_enable(pc->core, 0);
1477 return !mips_busprobe32(tmp, pc->core->io_addr);
1478 @@ -99,19 +94,19 @@ static int bcma_extpci_read_config(struc
1480 /* we support only two functions on device 0 */
1485 /* accesses to config registers with offsets >= 256
1486 * requires indirect access.
1488 if (off >= PCI_CONFIG_SPACE_SIZE) {
1489 addr = (func << 12);
1490 - addr |= (off & 0x0FFF);
1491 + addr |= (off & 0x0FFC);
1492 val = bcma_pcie_read_config(pc, addr);
1494 addr = BCMA_CORE_PCI_PCICFG0;
1495 addr |= (func << 8);
1496 - addr |= (off & 0xfc);
1497 + addr |= (off & 0xFC);
1498 val = pcicore_read32(pc, addr);
1501 @@ -124,11 +119,9 @@ static int bcma_extpci_read_config(struc
1504 if (mips_busprobe32(val, mmio)) {
1510 - val = readl(mmio);
1512 val >>= (8 * (off & 3));
1514 @@ -156,7 +149,7 @@ static int bcma_extpci_write_config(stru
1515 const void *buf, int len)
1518 - u32 addr = 0, val = 0;
1520 void __iomem *mmio = 0;
1521 u16 chipid = pc->core->bus->chipinfo.id;
1523 @@ -164,16 +157,22 @@ static int bcma_extpci_write_config(stru
1524 if (unlikely(len != 1 && len != 2 && len != 4))
1527 + /* we support only two functions on device 0 */
1531 /* accesses to config registers with offsets >= 256
1532 * requires indirect access.
1534 - if (off < PCI_CONFIG_SPACE_SIZE) {
1535 - addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
1536 + if (off >= PCI_CONFIG_SPACE_SIZE) {
1537 + addr = (func << 12);
1538 + addr |= (off & 0x0FFC);
1539 + val = bcma_pcie_read_config(pc, addr);
1541 + addr = BCMA_CORE_PCI_PCICFG0;
1542 addr |= (func << 8);
1543 - addr |= (off & 0xfc);
1544 - mmio = ioremap_nocache(addr, sizeof(val));
1547 + addr |= (off & 0xFC);
1548 + val = pcicore_read32(pc, addr);
1551 addr = bcma_get_cfgspace_addr(pc, dev, func, off);
1552 @@ -185,19 +184,17 @@ static int bcma_extpci_write_config(stru
1555 if (mips_busprobe32(val, mmio)) {
1564 - val = readl(mmio);
1565 val &= ~(0xFF << (8 * (off & 3)));
1566 val |= *((const u8 *)buf) << (8 * (off & 3));
1569 - val = readl(mmio);
1570 val &= ~(0xFFFF << (8 * (off & 3)));
1571 val |= *((const u16 *)buf) << (8 * (off & 3));
1573 @@ -205,13 +202,14 @@ static int bcma_extpci_write_config(stru
1574 val = *((const u32 *)buf);
1577 - if (dev == 0 && !addr) {
1579 /* accesses to config registers with offsets >= 256
1580 * requires indirect access.
1582 - addr = (func << 12);
1583 - addr |= (off & 0x0FFF);
1584 - bcma_pcie_write_config(pc, addr, val);
1585 + if (off >= PCI_CONFIG_SPACE_SIZE)
1586 + bcma_pcie_write_config(pc, addr, val);
1588 + pcicore_write32(pc, addr, val);
1592 @@ -282,7 +280,7 @@ static u8 __devinit bcma_find_pci_capabi
1593 /* check for Header type 0 */
1594 bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
1596 - if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
1597 + if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
1600 /* check if the capability pointer field exists */
1601 @@ -396,12 +394,19 @@ void __devinit bcma_core_pci_hostmode_in
1603 bcma_info(bus, "PCIEcore in host mode found\n");
1605 + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
1606 + bcma_info(bus, "This PCIE core is disabled and not working\n");
1610 pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
1612 bcma_err(bus, "can not allocate memory");
1616 + spin_lock_init(&pc_host->cfgspace_lock);
1618 pc->host_controller = pc_host;
1619 pc_host->pci_controller.io_resource = &pc_host->io_resource;
1620 pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
1621 @@ -427,7 +432,7 @@ void __devinit bcma_core_pci_hostmode_in
1623 usleep_range(3000, 5000);
1624 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
1625 - usleep_range(1000, 2000);
1627 pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
1628 BCMA_CORE_PCI_CTL_RST_OE);
1630 @@ -452,6 +457,8 @@ void __devinit bcma_core_pci_hostmode_in
1631 pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
1632 pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
1633 BCMA_SOC_PCI_MEM_SZ - 1;
1634 + pc_host->io_resource.start = 0x100;
1635 + pc_host->io_resource.end = 0x47F;
1636 pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
1637 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1638 tmp | BCMA_SOC_PCI_MEM);
1639 @@ -459,6 +466,8 @@ void __devinit bcma_core_pci_hostmode_in
1640 pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
1641 pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
1642 BCMA_SOC_PCI_MEM_SZ - 1;
1643 + pc_host->io_resource.start = 0x480;
1644 + pc_host->io_resource.end = 0x7FF;
1645 pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
1646 pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
1647 pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
1648 @@ -485,6 +494,17 @@ void __devinit bcma_core_pci_hostmode_in
1650 bcma_core_pci_enable_crs(pc);
1652 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706 ||
1653 + bus->chipinfo.id == BCMA_CHIP_ID_BCM4716) {
1655 + bcma_extpci_read_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
1656 + &val16, sizeof(val16));
1657 + val16 |= (2 << 5); /* Max payload size of 512 */
1658 + val16 |= (2 << 12); /* MRRS 512 */
1659 + bcma_extpci_write_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
1660 + &val16, sizeof(val16));
1663 /* Enable PCI bridge BAR0 memory & master access */
1664 tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
1665 bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
1666 @@ -534,7 +554,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_
1667 static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
1669 struct resource *res;
1673 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
1674 /* This is not a device on the PCI-core bridge. */
1675 @@ -547,8 +567,12 @@ static void bcma_core_pci_fixup_addresse
1677 for (pos = 0; pos < 6; pos++) {
1678 res = &dev->resource[pos];
1679 - if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM))
1680 - pci_assign_resource(dev, pos);
1681 + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) {
1682 + err = pci_assign_resource(dev, pos);
1684 + pr_err("PCI: Problem fixing up the addresses on %s\n",
1689 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
1690 @@ -569,7 +593,7 @@ int bcma_core_pci_plat_dev_init(struct p
1691 pr_info("PCI: Fixing up device %s\n", pci_name(dev));
1693 /* Fix up interrupt lines */
1694 - dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2;
1695 + dev->irq = bcma_core_irq(pc_host->pdev->core);
1696 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
1699 @@ -588,6 +612,6 @@ int bcma_core_pci_pcibios_map_irq(const
1701 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
1703 - return bcma_core_mips_irq(pc_host->pdev->core) + 2;
1704 + return bcma_core_irq(pc_host->pdev->core);
1706 EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
1707 --- a/drivers/bcma/host_pci.c
1708 +++ b/drivers/bcma/host_pci.c
1709 @@ -238,7 +238,7 @@ static void __devexit bcma_host_pci_remo
1710 pci_set_drvdata(dev, NULL);
1714 +#ifdef CONFIG_PM_SLEEP
1715 static int bcma_host_pci_suspend(struct device *dev)
1717 struct pci_dev *pdev = to_pci_dev(dev);
1718 @@ -261,11 +261,11 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
1719 bcma_host_pci_resume);
1720 #define BCMA_PM_OPS (&bcma_pm_ops)
1722 -#else /* CONFIG_PM */
1723 +#else /* CONFIG_PM_SLEEP */
1725 #define BCMA_PM_OPS NULL
1727 -#endif /* CONFIG_PM */
1728 +#endif /* CONFIG_PM_SLEEP */
1730 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
1731 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
1732 @@ -275,6 +275,7 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_
1733 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
1734 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
1735 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
1736 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
1737 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
1740 --- a/drivers/bcma/main.c
1741 +++ b/drivers/bcma/main.c
1742 @@ -81,6 +81,37 @@ struct bcma_device *bcma_find_core(struc
1744 EXPORT_SYMBOL_GPL(bcma_find_core);
1746 +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
1749 + struct bcma_device *core;
1751 + list_for_each_entry(core, &bus->cores, list) {
1752 + if (core->id.id == coreid && core->core_unit == unit)
1758 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
1761 + unsigned long deadline = jiffies + timeout;
1765 + val = bcma_read32(core, reg);
1766 + if ((val & mask) == value)
1770 + } while (!time_after_eq(jiffies, deadline));
1772 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
1777 static void bcma_release_core_dev(struct device *dev)
1779 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1780 @@ -108,6 +139,11 @@ static int bcma_register_cores(struct bc
1784 + /* Only first GMAC core on BCM4706 is connected and working */
1785 + if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
1786 + core->core_unit > 0)
1789 core->dev.release = bcma_release_core_dev;
1790 core->dev.bus = &bcma_bus_type;
1791 dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
1792 @@ -137,6 +173,14 @@ static int bcma_register_cores(struct bc
1796 +#ifdef CONFIG_BCMA_DRIVER_MIPS
1797 + if (bus->drv_cc.pflash.present) {
1798 + err = platform_device_register(&bcma_pflash_dev);
1800 + bcma_err(bus, "Error registering parallel flash\n");
1804 #ifdef CONFIG_BCMA_SFLASH
1805 if (bus->drv_cc.sflash.present) {
1806 err = platform_device_register(&bcma_sflash_dev);
1807 @@ -152,6 +196,17 @@ static int bcma_register_cores(struct bc
1808 bcma_err(bus, "Error registering NAND flash\n");
1811 + err = bcma_gpio_init(&bus->drv_cc);
1812 + if (err == -ENOTSUPP)
1813 + bcma_debug(bus, "GPIO driver not activated\n");
1815 + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
1817 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
1818 + err = bcma_chipco_watchdog_register(&bus->drv_cc);
1820 + bcma_err(bus, "Error registering watchdog driver\n");
1825 @@ -165,6 +220,8 @@ static void bcma_unregister_cores(struct
1826 if (core->dev_registered)
1827 device_unregister(&core->dev);
1829 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
1830 + platform_device_unregister(bus->drv_cc.watchdog);
1833 int __devinit bcma_bus_register(struct bcma_bus *bus)
1834 @@ -183,6 +240,20 @@ int __devinit bcma_bus_register(struct b
1838 + /* Early init CC core */
1839 + core = bcma_find_core(bus, bcma_cc_core_id(bus));
1841 + bus->drv_cc.core = core;
1842 + bcma_core_chipcommon_early_init(&bus->drv_cc);
1845 + /* Try to get SPROM */
1846 + err = bcma_sprom_get(bus);
1847 + if (err == -ENOENT) {
1848 + bcma_err(bus, "No SPROM available\n");
1850 + bcma_err(bus, "Failed to get SPROM: %d\n", err);
1853 core = bcma_find_core(bus, bcma_cc_core_id(bus));
1855 @@ -198,10 +269,17 @@ int __devinit bcma_bus_register(struct b
1858 /* Init PCIE core */
1859 - core = bcma_find_core(bus, BCMA_CORE_PCIE);
1860 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
1862 + bus->drv_pci[0].core = core;
1863 + bcma_core_pci_init(&bus->drv_pci[0]);
1866 + /* Init PCIE core */
1867 + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
1869 - bus->drv_pci.core = core;
1870 - bcma_core_pci_init(&bus->drv_pci);
1871 + bus->drv_pci[1].core = core;
1872 + bcma_core_pci_init(&bus->drv_pci[1]);
1875 /* Init GBIT MAC COMMON core */
1876 @@ -211,13 +289,6 @@ int __devinit bcma_bus_register(struct b
1877 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
1880 - /* Try to get SPROM */
1881 - err = bcma_sprom_get(bus);
1882 - if (err == -ENOENT) {
1883 - bcma_err(bus, "No SPROM available\n");
1885 - bcma_err(bus, "Failed to get SPROM: %d\n", err);
1887 /* Register found cores */
1888 bcma_register_cores(bus);
1890 @@ -229,6 +300,13 @@ int __devinit bcma_bus_register(struct b
1891 void bcma_bus_unregister(struct bcma_bus *bus)
1893 struct bcma_device *cores[3];
1896 + err = bcma_gpio_unregister(&bus->drv_cc);
1897 + if (err == -EBUSY)
1898 + bcma_err(bus, "Some GPIOs are still in use.\n");
1900 + bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
1902 cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1903 cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
1904 @@ -275,18 +353,18 @@ int __init bcma_bus_early_register(struc
1908 - /* Init CC core */
1909 + /* Early init CC core */
1910 core = bcma_find_core(bus, bcma_cc_core_id(bus));
1912 bus->drv_cc.core = core;
1913 - bcma_core_chipcommon_init(&bus->drv_cc);
1914 + bcma_core_chipcommon_early_init(&bus->drv_cc);
1917 - /* Init MIPS core */
1918 + /* Early init MIPS core */
1919 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1921 bus->drv_mips.core = core;
1922 - bcma_core_mips_init(&bus->drv_mips);
1923 + bcma_core_mips_early_init(&bus->drv_mips);
1926 bcma_info(bus, "Early bus registered\n");
1927 --- a/drivers/bcma/scan.c
1928 +++ b/drivers/bcma/scan.c
1929 @@ -84,6 +84,8 @@ static const struct bcma_device_id_name
1930 { BCMA_CORE_I2S, "I2S" },
1931 { BCMA_CORE_SDR_DDR1_MEM_CTL, "SDR/DDR1 Memory Controller" },
1932 { BCMA_CORE_SHIM, "SHIM" },
1933 + { BCMA_CORE_PCIE2, "PCIe Gen2" },
1934 + { BCMA_CORE_ARM_CR4, "ARM CR4" },
1935 { BCMA_CORE_DEFAULT, "Default" },
1938 @@ -137,19 +139,19 @@ static void bcma_scan_switch_core(struct
1942 -static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 **eromptr)
1943 +static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 __iomem **eromptr)
1945 u32 ent = readl(*eromptr);
1950 -static void bcma_erom_push_ent(u32 **eromptr)
1951 +static void bcma_erom_push_ent(u32 __iomem **eromptr)
1956 -static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 **eromptr)
1957 +static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 __iomem **eromptr)
1959 u32 ent = bcma_erom_get_ent(bus, eromptr);
1960 if (!(ent & SCAN_ER_VALID))
1961 @@ -159,14 +161,14 @@ static s32 bcma_erom_get_ci(struct bcma_
1965 -static bool bcma_erom_is_end(struct bcma_bus *bus, u32 **eromptr)
1966 +static bool bcma_erom_is_end(struct bcma_bus *bus, u32 __iomem **eromptr)
1968 u32 ent = bcma_erom_get_ent(bus, eromptr);
1969 bcma_erom_push_ent(eromptr);
1970 return (ent == (SCAN_ER_TAG_END | SCAN_ER_VALID));
1973 -static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 **eromptr)
1974 +static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 __iomem **eromptr)
1976 u32 ent = bcma_erom_get_ent(bus, eromptr);
1977 bcma_erom_push_ent(eromptr);
1978 @@ -175,7 +177,7 @@ static bool bcma_erom_is_bridge(struct b
1979 ((ent & SCAN_ADDR_TYPE) == SCAN_ADDR_TYPE_BRIDGE));
1982 -static void bcma_erom_skip_component(struct bcma_bus *bus, u32 **eromptr)
1983 +static void bcma_erom_skip_component(struct bcma_bus *bus, u32 __iomem **eromptr)
1987 @@ -189,7 +191,7 @@ static void bcma_erom_skip_component(str
1988 bcma_erom_push_ent(eromptr);
1991 -static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr)
1992 +static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 __iomem **eromptr)
1994 u32 ent = bcma_erom_get_ent(bus, eromptr);
1995 if (!(ent & SCAN_ER_VALID))
1996 @@ -199,7 +201,7 @@ static s32 bcma_erom_get_mst_port(struct
2000 -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 **eromptr,
2001 +static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
2004 u32 addrl, addrh, sizel, sizeh = 0;
2005 --- a/drivers/bcma/sprom.c
2006 +++ b/drivers/bcma/sprom.c
2007 @@ -72,12 +72,12 @@ fail:
2009 **************************************************/
2011 -static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
2012 +static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom,
2016 - for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
2017 - sprom[i] = bcma_read16(bus->drv_cc.core,
2018 - offset + (i * 2));
2019 + for (i = 0; i < words; i++)
2020 + sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2));
2023 /**************************************************
2024 @@ -124,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da
2025 return t[crc ^ data];
2028 -static u8 bcma_sprom_crc(const u16 *sprom)
2029 +static u8 bcma_sprom_crc(const u16 *sprom, size_t words)
2034 - for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
2035 + for (word = 0; word < words - 1; word++) {
2036 crc = bcma_crc8(crc, sprom[word] & 0x00FF);
2037 crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
2039 - crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
2040 + crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF);
2046 -static int bcma_sprom_check_crc(const u16 *sprom)
2047 +static int bcma_sprom_check_crc(const u16 *sprom, size_t words)
2053 - crc = bcma_sprom_crc(sprom);
2054 - tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
2055 + crc = bcma_sprom_crc(sprom, words);
2056 + tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC;
2057 expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
2058 if (crc != expected_crc)
2060 @@ -154,21 +154,25 @@ static int bcma_sprom_check_crc(const u1
2064 -static int bcma_sprom_valid(const u16 *sprom)
2065 +static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom,
2071 - err = bcma_sprom_check_crc(sprom);
2072 + err = bcma_sprom_check_crc(sprom, words);
2076 - revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
2077 - if (revision != 8 && revision != 9) {
2078 + revision = sprom[words - 1] & SSB_SPROM_REVISION_REV;
2079 + if (revision != 8 && revision != 9 && revision != 10) {
2080 pr_err("Unsupported SPROM revision: %d\n", revision);
2084 + bus->sprom.revision = revision;
2085 + bcma_debug(bus, "Found SPROM revision %d\n", revision);
2090 @@ -208,15 +212,13 @@ static void bcma_sprom_extract_r8(struct
2091 BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
2092 ARRAY_SIZE(bus->sprom.core_pwr_info));
2094 - bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
2095 - SSB_SPROM_REVISION_REV;
2097 for (i = 0; i < 3; i++) {
2098 v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
2099 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
2102 SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
2103 + SPEX(board_type, SSB_SPROM1_SPID, ~0, 0);
2105 SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
2106 SSB_SPROM4_TXPID2G0_SHIFT);
2107 @@ -501,7 +503,7 @@ static bool bcma_sprom_onchip_available(
2108 case BCMA_CHIP_ID_BCM4331:
2109 present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
2112 + case BCMA_CHIP_ID_BCM43142:
2113 case BCMA_CHIP_ID_BCM43224:
2114 case BCMA_CHIP_ID_BCM43225:
2115 /* for these chips OTP is always available */
2116 @@ -549,7 +551,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
2118 u16 offset = BCMA_CC_SPROM;
2121 + size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
2122 + SSB_SPROMSIZE_WORDS_R10, };
2125 if (!bus->drv_cc.core)
2127 @@ -578,29 +582,37 @@ int bcma_sprom_get(struct bcma_bus *bus)
2131 - sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
2136 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
2137 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
2138 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
2140 bcma_debug(bus, "SPROM offset 0x%x\n", offset);
2141 - bcma_sprom_read(bus, offset, sprom);
2142 + for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
2143 + size_t words = sprom_sizes[i];
2145 + sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
2149 + bcma_sprom_read(bus, offset, sprom, words);
2150 + err = bcma_sprom_valid(bus, sprom, words);
2157 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
2158 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
2159 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
2161 - err = bcma_sprom_valid(sprom);
2165 - bcma_sprom_extract_r8(bus, sprom);
2167 + bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n");
2168 + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
2170 + bcma_sprom_extract_r8(bus, sprom);
2178 --- a/include/linux/bcma/bcma.h
2179 +++ b/include/linux/bcma/bcma.h
2180 @@ -134,12 +134,17 @@ struct bcma_host_ops {
2181 #define BCMA_CORE_I2S 0x834
2182 #define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
2183 #define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
2184 +#define BCMA_CORE_PHY_AC 0x83B
2185 +#define BCMA_CORE_PCIE2 0x83C /* PCI Express Gen2 */
2186 +#define BCMA_CORE_USB30_DEV 0x83D
2187 +#define BCMA_CORE_ARM_CR4 0x83E
2188 #define BCMA_CORE_DEFAULT 0xFFF
2190 #define BCMA_MAX_NR_CORES 16
2192 /* Chip IDs of PCIe devices */
2193 #define BCMA_CHIP_ID_BCM4313 0x4313
2194 +#define BCMA_CHIP_ID_BCM43142 43142
2195 #define BCMA_CHIP_ID_BCM43224 43224
2196 #define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
2197 #define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
2198 @@ -157,6 +162,7 @@ struct bcma_host_ops {
2200 /* Chip IDs of SoCs */
2201 #define BCMA_CHIP_ID_BCM4706 0x5300
2202 +#define BCMA_PKG_ID_BCM4706L 1
2203 #define BCMA_CHIP_ID_BCM4716 0x4716
2204 #define BCMA_PKG_ID_BCM4716 8
2205 #define BCMA_PKG_ID_BCM4717 9
2206 @@ -166,7 +172,65 @@ struct bcma_host_ops {
2207 #define BCMA_CHIP_ID_BCM4749 0x4749
2208 #define BCMA_CHIP_ID_BCM5356 0x5356
2209 #define BCMA_CHIP_ID_BCM5357 0x5357
2210 +#define BCMA_PKG_ID_BCM5358 9
2211 +#define BCMA_PKG_ID_BCM47186 10
2212 +#define BCMA_PKG_ID_BCM5357 11
2213 #define BCMA_CHIP_ID_BCM53572 53572
2214 +#define BCMA_PKG_ID_BCM47188 9
2216 +/* Board types (on PCI usually equals to the subsystem dev id) */
2218 +#define BCMA_BOARD_TYPE_BCM94313BU 0X050F
2219 +#define BCMA_BOARD_TYPE_BCM94313HM 0X0510
2220 +#define BCMA_BOARD_TYPE_BCM94313EPA 0X0511
2221 +#define BCMA_BOARD_TYPE_BCM94313HMG 0X051C
2223 +#define BCMA_BOARD_TYPE_BCM94716NR2 0X04CD
2225 +#define BCMA_BOARD_TYPE_BCM943224X21 0X056E
2226 +#define BCMA_BOARD_TYPE_BCM943224X21_FCC 0X00D1
2227 +#define BCMA_BOARD_TYPE_BCM943224X21B 0X00E9
2228 +#define BCMA_BOARD_TYPE_BCM943224M93 0X008B
2229 +#define BCMA_BOARD_TYPE_BCM943224M93A 0X0090
2230 +#define BCMA_BOARD_TYPE_BCM943224X16 0X0093
2231 +#define BCMA_BOARD_TYPE_BCM94322X9 0X008D
2232 +#define BCMA_BOARD_TYPE_BCM94322M35E 0X008E
2234 +#define BCMA_BOARD_TYPE_BCM943228BU8 0X0540
2235 +#define BCMA_BOARD_TYPE_BCM943228BU9 0X0541
2236 +#define BCMA_BOARD_TYPE_BCM943228BU 0X0542
2237 +#define BCMA_BOARD_TYPE_BCM943227HM4L 0X0543
2238 +#define BCMA_BOARD_TYPE_BCM943227HMB 0X0544
2239 +#define BCMA_BOARD_TYPE_BCM943228HM4L 0X0545
2240 +#define BCMA_BOARD_TYPE_BCM943228SD 0X0573
2242 +#define BCMA_BOARD_TYPE_BCM94331X19 0X00D6
2243 +#define BCMA_BOARD_TYPE_BCM94331X28 0X00E4
2244 +#define BCMA_BOARD_TYPE_BCM94331X28B 0X010E
2245 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT3AX 0X00E4
2246 +#define BCMA_BOARD_TYPE_BCM94331X12_2G 0X00EC
2247 +#define BCMA_BOARD_TYPE_BCM94331X12_5G 0X00ED
2248 +#define BCMA_BOARD_TYPE_BCM94331X29B 0X00EF
2249 +#define BCMA_BOARD_TYPE_BCM94331CSAX 0X00EF
2250 +#define BCMA_BOARD_TYPE_BCM94331X19C 0X00F5
2251 +#define BCMA_BOARD_TYPE_BCM94331X33 0X00F4
2252 +#define BCMA_BOARD_TYPE_BCM94331BU 0X0523
2253 +#define BCMA_BOARD_TYPE_BCM94331S9BU 0X0524
2254 +#define BCMA_BOARD_TYPE_BCM94331MC 0X0525
2255 +#define BCMA_BOARD_TYPE_BCM94331MCI 0X0526
2256 +#define BCMA_BOARD_TYPE_BCM94331PCIEBT4 0X0527
2257 +#define BCMA_BOARD_TYPE_BCM94331HM 0X0574
2258 +#define BCMA_BOARD_TYPE_BCM94331PCIEDUAL 0X059B
2259 +#define BCMA_BOARD_TYPE_BCM94331MCH5 0X05A9
2260 +#define BCMA_BOARD_TYPE_BCM94331CS 0X05C6
2261 +#define BCMA_BOARD_TYPE_BCM94331CD 0X05DA
2263 +#define BCMA_BOARD_TYPE_BCM953572BU 0X058D
2264 +#define BCMA_BOARD_TYPE_BCM953572NR2 0X058E
2265 +#define BCMA_BOARD_TYPE_BCM947188NR2 0X058F
2266 +#define BCMA_BOARD_TYPE_BCM953572SDRNR2 0X0590
2268 +#define BCMA_BOARD_TYPE_BCM943142HM 0X05E0
2270 struct bcma_device {
2271 struct bcma_bus *bus;
2272 @@ -251,7 +315,7 @@ struct bcma_bus {
2275 struct bcma_drv_cc drv_cc;
2276 - struct bcma_drv_pci drv_pci;
2277 + struct bcma_drv_pci drv_pci[2];
2278 struct bcma_drv_mips drv_mips;
2279 struct bcma_drv_gmac_cmn drv_gmac_cmn;
2281 @@ -345,6 +409,7 @@ extern void bcma_core_set_clockmode(stru
2282 enum bcma_clkmode clkmode);
2283 extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
2285 +extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
2286 #define BCMA_DMA_TRANSLATION_MASK 0xC0000000
2287 #define BCMA_DMA_TRANSLATION_NONE 0x00000000
2288 #define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
2289 --- a/include/linux/bcma/bcma_driver_chipcommon.h
2290 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
2292 #ifndef LINUX_BCMA_DRIVER_CC_H_
2293 #define LINUX_BCMA_DRIVER_CC_H_
2295 +#include <linux/platform_device.h>
2296 +#include <linux/gpio.h>
2298 /** ChipCommon core registers. **/
2299 #define BCMA_CC_ID 0x0000
2300 #define BCMA_CC_ID_ID 0x0000FFFF
2302 #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
2303 #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
2304 #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
2305 -#define BCMA_CC_FLASHT_NFLASH 0x00000200 /* NAND flash */
2306 +#define BCMA_CC_FLASHT_NAND 0x00000300 /* NAND flash */
2307 #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
2308 #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
2309 #define BCMA_PLLTYPE_NONE 0x00000000
2311 #define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
2312 #define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
2313 #define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
2314 +#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
2315 #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
2316 #define BCMA_CC_JCMD_START 0x80000000
2317 #define BCMA_CC_JCMD_BUSY 0x80000000
2319 #define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
2320 #define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
2321 #define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
2322 +#define BCMA_CC_PMU_CTL_RES 0x00006000 /* reset control mask */
2323 +#define BCMA_CC_PMU_CTL_RES_SHIFT 13
2324 +#define BCMA_CC_PMU_CTL_RES_RELOAD 0x2 /* reload POR values */
2325 #define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
2326 #define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
2327 #define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
2329 #define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
2330 #define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
2331 #define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
2332 +#define BCMA_CC_PMU_STAT_EXT_LPO_AVAIL 0x00000100
2333 +#define BCMA_CC_PMU_STAT_WDRESET 0x00000080
2334 #define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
2335 #define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
2336 #define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
2337 @@ -348,6 +357,11 @@
2338 #define BCMA_CC_REGCTL_DATA 0x065C
2339 #define BCMA_CC_PLLCTL_ADDR 0x0660
2340 #define BCMA_CC_PLLCTL_DATA 0x0664
2341 +#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */
2342 +#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */
2343 +#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF
2344 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_MASK 0x80000000
2345 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT 31
2346 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
2347 /* NAND flash MLC controller registers (corerev >= 38) */
2348 #define BCMA_CC_NAND_REVISION 0x0C00
2349 @@ -428,6 +442,23 @@
2350 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007
2351 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0
2354 +#define BCMA_CC_PMU15_PLL_PLLCTL0 0
2355 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_MASK 0x00000003
2356 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_SHIFT 0
2357 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK 0x003FFFFC
2358 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT 2
2359 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_MASK 0x00C00000
2360 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_SHIFT 22
2361 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_MASK 0x07000000
2362 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_SHIFT 24
2363 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_MASK 0x38000000
2364 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_SHIFT 27
2365 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_MASK 0x40000000
2366 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_SHIFT 30
2367 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_MASK 0x80000000
2368 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_SHIFT 31
2370 /* ALP clock on pre-PMU chips */
2371 #define BCMA_CC_PMU_ALP_CLOCK 20000000
2372 /* HT clock for systems with PMU-enabled chipcommon */
2373 @@ -500,6 +531,37 @@
2374 #define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
2375 #define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
2377 +#define BCMA_RES_4314_LPLDO_PU BIT(0)
2378 +#define BCMA_RES_4314_PMU_SLEEP_DIS BIT(1)
2379 +#define BCMA_RES_4314_PMU_BG_PU BIT(2)
2380 +#define BCMA_RES_4314_CBUCK_LPOM_PU BIT(3)
2381 +#define BCMA_RES_4314_CBUCK_PFM_PU BIT(4)
2382 +#define BCMA_RES_4314_CLDO_PU BIT(5)
2383 +#define BCMA_RES_4314_LPLDO2_LVM BIT(6)
2384 +#define BCMA_RES_4314_WL_PMU_PU BIT(7)
2385 +#define BCMA_RES_4314_LNLDO_PU BIT(8)
2386 +#define BCMA_RES_4314_LDO3P3_PU BIT(9)
2387 +#define BCMA_RES_4314_OTP_PU BIT(10)
2388 +#define BCMA_RES_4314_XTAL_PU BIT(11)
2389 +#define BCMA_RES_4314_WL_PWRSW_PU BIT(12)
2390 +#define BCMA_RES_4314_LQ_AVAIL BIT(13)
2391 +#define BCMA_RES_4314_LOGIC_RET BIT(14)
2392 +#define BCMA_RES_4314_MEM_SLEEP BIT(15)
2393 +#define BCMA_RES_4314_MACPHY_RET BIT(16)
2394 +#define BCMA_RES_4314_WL_CORE_READY BIT(17)
2395 +#define BCMA_RES_4314_ILP_REQ BIT(18)
2396 +#define BCMA_RES_4314_ALP_AVAIL BIT(19)
2397 +#define BCMA_RES_4314_MISC_PWRSW_PU BIT(20)
2398 +#define BCMA_RES_4314_SYNTH_PWRSW_PU BIT(21)
2399 +#define BCMA_RES_4314_RX_PWRSW_PU BIT(22)
2400 +#define BCMA_RES_4314_RADIO_PU BIT(23)
2401 +#define BCMA_RES_4314_VCO_LDO_PU BIT(24)
2402 +#define BCMA_RES_4314_AFE_LDO_PU BIT(25)
2403 +#define BCMA_RES_4314_RX_LDO_PU BIT(26)
2404 +#define BCMA_RES_4314_TX_LDO_PU BIT(27)
2405 +#define BCMA_RES_4314_HT_AVAIL BIT(28)
2406 +#define BCMA_RES_4314_MACPHY_CLK_AVAIL BIT(29)
2408 /* Data for the PMU, if available.
2409 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
2411 @@ -510,6 +572,7 @@ struct bcma_chipcommon_pmu {
2413 #ifdef CONFIG_BCMA_DRIVER_MIPS
2414 struct bcma_pflash {
2419 @@ -524,6 +587,7 @@ struct bcma_sflash {
2422 struct mtd_info *mtd;
2427 @@ -532,6 +596,7 @@ struct mtd_info;
2429 struct bcma_nflash {
2431 + bool boot; /* This is the flash the SoC boots from */
2433 struct mtd_info *mtd;
2435 @@ -552,6 +617,7 @@ struct bcma_drv_cc {
2437 u32 capabilities_ext;
2439 + u8 early_setup_done:1;
2440 /* Fast Powerup Delay constant */
2441 u16 fast_pwrup_delay;
2442 struct bcma_chipcommon_pmu pmu;
2443 @@ -567,6 +633,14 @@ struct bcma_drv_cc {
2444 int nr_serial_ports;
2445 struct bcma_serial_port serial_ports[4];
2446 #endif /* CONFIG_BCMA_DRIVER_MIPS */
2448 + struct platform_device *watchdog;
2450 + /* Lock for GPIO register access. */
2451 + spinlock_t gpio_lock;
2452 +#ifdef CONFIG_BCMA_DRIVER_GPIO
2453 + struct gpio_chip gpio;
2457 /* Register access */
2458 @@ -583,14 +657,16 @@ struct bcma_drv_cc {
2459 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
2461 extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
2462 +extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
2464 extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
2465 extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
2467 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
2469 -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
2471 +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
2473 +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
2475 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
2477 @@ -603,9 +679,12 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
2478 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
2479 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
2480 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
2481 +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
2482 +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
2485 extern void bcma_pmu_init(struct bcma_drv_cc *cc);
2486 +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
2488 extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
2490 @@ -617,4 +696,6 @@ extern void bcma_chipco_regctl_maskset(s
2491 u32 offset, u32 mask, u32 set);
2492 extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
2494 +extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
2496 #endif /* LINUX_BCMA_DRIVER_CC_H_ */
2497 --- a/include/linux/bcma/bcma_driver_mips.h
2498 +++ b/include/linux/bcma/bcma_driver_mips.h
2500 #define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
2501 #define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
2503 +#define BCMA_MIPS_OOBSELINA74 0x004
2504 #define BCMA_MIPS_OOBSELOUTA30 0x100
2507 @@ -35,17 +36,24 @@ struct bcma_device;
2508 struct bcma_drv_mips {
2509 struct bcma_device *core;
2511 - unsigned int assigned_irqs;
2512 + u8 early_setup_done:1;
2515 #ifdef CONFIG_BCMA_DRIVER_MIPS
2516 extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
2517 +extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
2519 +extern unsigned int bcma_core_irq(struct bcma_device *core);
2521 static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
2522 +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
2524 +static inline unsigned int bcma_core_irq(struct bcma_device *core)
2530 extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
2532 -extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
2534 #endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
2535 --- a/include/linux/bcma/bcma_driver_pci.h
2536 +++ b/include/linux/bcma/bcma_driver_pci.h
2537 @@ -179,6 +179,8 @@ struct pci_dev;
2538 #define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */
2539 #define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */
2541 +#define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8
2543 /* PCIE Root Capability Register bits (Host mode only) */
2544 #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
2546 --- a/include/linux/bcma/bcma_regs.h
2547 +++ b/include/linux/bcma/bcma_regs.h
2549 #define BCMA_IOST_BIST_DONE 0x8000
2550 #define BCMA_RESET_CTL 0x0800
2551 #define BCMA_RESET_CTL_RESET 0x0001
2552 +#define BCMA_RESET_ST 0x0804
2554 /* BCMA PCI config space registers. */
2555 #define BCMA_PCI_PMCSR 0x44
2557 * (2 ZettaBytes), high 32 bits
2560 -#define BCMA_SFLASH 0x1c000000
2561 +#define BCMA_SOC_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */
2562 +#define BCMA_SOC_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */
2563 +#define BCMA_SOC_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
2564 +#define BCMA_SOC_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
2566 #endif /* LINUX_BCMA_REGS_H_ */
2567 --- a/drivers/net/wireless/b43/main.c
2568 +++ b/drivers/net/wireless/b43/main.c
2569 @@ -4684,7 +4684,7 @@ static int b43_wireless_core_init(struct
2570 switch (dev->dev->bus_type) {
2571 #ifdef CONFIG_B43_BCMA
2573 - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
2574 + bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
2575 dev->dev->bdev, true);
2578 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
2579 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
2580 @@ -692,7 +692,7 @@ void ai_pci_up(struct si_pub *sih)
2581 sii = container_of(sih, struct si_info, pub);
2583 if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
2584 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, true);
2585 + bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], true);
2588 /* Unconfigure and/or apply various WARs when going down */
2589 @@ -703,7 +703,7 @@ void ai_pci_down(struct si_pub *sih)
2590 sii = container_of(sih, struct si_info, pub);
2592 if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
2593 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, false);
2594 + bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], false);
2597 /* Enable BT-COEX & Ex-PA for 4313 */
2598 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
2599 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
2600 @@ -5077,7 +5077,7 @@ static int brcms_b_up_prep(struct brcms_
2601 * Configure pci/pcmcia here instead of in brcms_c_attach()
2602 * to allow mfg hotswap: down, hotswap (chip power cycle), up.
2604 - bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci, wlc_hw->d11core,
2605 + bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,