1 --- a/drivers/bcma/Kconfig
2 +++ b/drivers/bcma/Kconfig
3 @@ -33,6 +33,19 @@ config BCMA_DRIVER_PCI_HOSTMODE
5 PCI core hostmode operation (external PCI bus).
9 + depends on BCMA_DRIVER_MIPS
11 +config BCMA_DRIVER_MIPS
12 + bool "BCMA Broadcom MIPS core driver"
13 + depends on BCMA && MIPS
15 + Driver for the Broadcom MIPS core attached to Broadcom specific
16 + Advanced Microcontroller Bus.
23 --- a/drivers/bcma/Makefile
24 +++ b/drivers/bcma/Makefile
25 @@ -2,7 +2,9 @@ bcma-y += main.o scan.o core.o sprom
26 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
27 bcma-y += driver_pci.o
28 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
29 +bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
30 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
31 +bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
32 obj-$(CONFIG_BCMA) += bcma.o
34 ccflags-$(CONFIG_BCMA_DEBUG) := -DDEBUG
35 --- a/drivers/bcma/bcma_private.h
36 +++ b/drivers/bcma/bcma_private.h
37 @@ -15,13 +15,32 @@ struct bcma_bus;
39 int bcma_bus_register(struct bcma_bus *bus);
40 void bcma_bus_unregister(struct bcma_bus *bus);
41 +int __init bcma_bus_early_register(struct bcma_bus *bus,
42 + struct bcma_device *core_cc,
43 + struct bcma_device *core_mips);
45 +int bcma_bus_resume(struct bcma_bus *bus);
49 int bcma_bus_scan(struct bcma_bus *bus);
50 +int __init bcma_bus_scan_early(struct bcma_bus *bus,
51 + struct bcma_device_id *match,
52 + struct bcma_device *core);
53 +void bcma_init_bus(struct bcma_bus *bus);
56 int bcma_sprom_get(struct bcma_bus *bus);
58 +/* driver_chipcommon.c */
59 +#ifdef CONFIG_BCMA_DRIVER_MIPS
60 +void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
61 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
63 +/* driver_chipcommon_pmu.c */
64 +u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
65 +u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
67 #ifdef CONFIG_BCMA_HOST_PCI
69 extern int __init bcma_host_pci_init(void);
70 --- a/drivers/bcma/core.c
71 +++ b/drivers/bcma/core.c
72 @@ -110,6 +110,8 @@ EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
73 u32 bcma_core_dma_translation(struct bcma_device *core)
75 switch (core->bus->hosttype) {
76 + case BCMA_HOSTTYPE_SOC:
78 case BCMA_HOSTTYPE_PCI:
79 if (bcma_aread32(core, BCMA_IOST) & BCMA_IOST_DMA64)
80 return BCMA_DMA_TRANSLATION_DMA64_CMT;
81 --- a/drivers/bcma/driver_chipcommon.c
82 +++ b/drivers/bcma/driver_chipcommon.c
83 @@ -26,6 +26,9 @@ void bcma_core_chipcommon_init(struct bc
90 if (cc->core->id.rev >= 11)
91 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
92 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
93 @@ -52,6 +55,8 @@ void bcma_core_chipcommon_init(struct bc
94 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
95 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
98 + cc->setup_done = true;
101 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
102 @@ -101,3 +106,51 @@ u32 bcma_chipco_gpio_polarity(struct bcm
104 return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
107 +#ifdef CONFIG_BCMA_DRIVER_MIPS
108 +void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
113 + unsigned int ccrev = cc->core->id.rev;
114 + struct bcma_serial_port *ports = cc->serial_ports;
116 + if (ccrev >= 11 && ccrev != 15) {
117 + /* Fixed ALP clock */
118 + baud_base = bcma_pmu_alp_clock(cc);
120 + /* Turn off UART clock before switching clocksource. */
121 + bcma_cc_write32(cc, BCMA_CC_CORECTL,
122 + bcma_cc_read32(cc, BCMA_CC_CORECTL)
123 + & ~BCMA_CC_CORECTL_UARTCLKEN);
125 + /* Set the override bit so we don't divide it */
126 + bcma_cc_write32(cc, BCMA_CC_CORECTL,
127 + bcma_cc_read32(cc, BCMA_CC_CORECTL)
128 + | BCMA_CC_CORECTL_UARTCLK0);
130 + /* Re-enable the UART clock. */
131 + bcma_cc_write32(cc, BCMA_CC_CORECTL,
132 + bcma_cc_read32(cc, BCMA_CC_CORECTL)
133 + | BCMA_CC_CORECTL_UARTCLKEN);
136 + pr_err("serial not supported on this device ccrev: 0x%x\n",
141 + irq = bcma_core_mips_irq(cc->core);
143 + /* Determine the registers of the UARTs */
144 + cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART);
145 + for (i = 0; i < cc->nr_serial_ports; i++) {
146 + ports[i].regs = cc->core->io_addr + BCMA_CC_UART0_DATA +
148 + ports[i].irq = irq;
149 + ports[i].baud_base = baud_base;
150 + ports[i].reg_shift = 0;
153 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
154 --- a/drivers/bcma/driver_chipcommon_pmu.c
155 +++ b/drivers/bcma/driver_chipcommon_pmu.c
157 #include "bcma_private.h"
158 #include <linux/bcma/bcma.h>
160 -static void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
161 - u32 offset, u32 mask, u32 set)
162 +static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
165 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
166 + bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
167 + return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
170 - bcma_cc_read32(cc, BCMA_CC_CHIPCTL_ADDR);
171 +void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
173 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
174 + bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
175 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
177 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_write);
179 +void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
182 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
183 + bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
184 + bcma_cc_maskset32(cc, BCMA_CC_PLLCTL_DATA, mask, set);
186 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_maskset);
188 +void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
189 + u32 offset, u32 mask, u32 set)
191 bcma_cc_write32(cc, BCMA_CC_CHIPCTL_ADDR, offset);
192 bcma_cc_read32(cc, BCMA_CC_CHIPCTL_ADDR);
193 - value = bcma_cc_read32(cc, BCMA_CC_CHIPCTL_DATA);
196 - bcma_cc_write32(cc, BCMA_CC_CHIPCTL_DATA, value);
197 - bcma_cc_read32(cc, BCMA_CC_CHIPCTL_DATA);
198 + bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL_DATA, mask, set);
200 +EXPORT_SYMBOL_GPL(bcma_chipco_chipctl_maskset);
202 +void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
205 + bcma_cc_write32(cc, BCMA_CC_REGCTL_ADDR, offset);
206 + bcma_cc_read32(cc, BCMA_CC_REGCTL_ADDR);
207 + bcma_cc_maskset32(cc, BCMA_CC_REGCTL_DATA, mask, set);
209 +EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
211 static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
213 @@ -83,6 +110,24 @@ void bcma_pmu_swreg_init(struct bcma_drv
217 +/* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
218 +void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable)
220 + struct bcma_bus *bus = cc->core->bus;
223 + val = bcma_cc_read32(cc, BCMA_CC_CHIPCTL);
225 + val |= BCMA_CHIPCTL_4331_EXTPA_EN;
226 + if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11)
227 + val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
229 + val &= ~BCMA_CHIPCTL_4331_EXTPA_EN;
230 + val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
232 + bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
235 void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
237 struct bcma_bus *bus = cc->core->bus;
238 @@ -92,7 +137,7 @@ void bcma_pmu_workarounds(struct bcma_dr
239 bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7);
242 - pr_err("Enabling Ext PA lines not implemented\n");
243 + /* BCM4331 workaround is SPROM-related, we put it in sprom.c */
246 if (bus->chipinfo.rev == 0) {
247 @@ -136,3 +181,129 @@ void bcma_pmu_init(struct bcma_drv_cc *c
248 bcma_pmu_swreg_init(cc);
249 bcma_pmu_workarounds(cc);
252 +u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
254 + struct bcma_bus *bus = cc->core->bus;
256 + switch (bus->chipinfo.id) {
265 + return 20000 * 1000;
269 + return 25000 * 1000;
271 + pr_warn("No ALP clock specified for %04X device, "
272 + "pmu rev. %d, using default %d Hz\n",
273 + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
275 + return BCMA_CC_PMU_ALP_CLOCK;
278 +/* Find the output of the "m" pll divider given pll controls that start with
279 + * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
281 +static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
283 + u32 tmp, div, ndiv, p1, p2, fc;
284 + struct bcma_bus *bus = cc->core->bus;
286 + BUG_ON((pll0 & 3) || (pll0 > BCMA_CC_PMU4716_MAINPLL_PLL0));
288 + BUG_ON(!m || m > 4);
290 + if (bus->chipinfo.id == 0x5357 || bus->chipinfo.id == 0x4749) {
291 + /* Detect failure in clock setting */
292 + tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
294 + return 133 * 1000000;
297 + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_P1P2_OFF);
298 + p1 = (tmp & BCMA_CC_PPL_P1_MASK) >> BCMA_CC_PPL_P1_SHIFT;
299 + p2 = (tmp & BCMA_CC_PPL_P2_MASK) >> BCMA_CC_PPL_P2_SHIFT;
301 + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_M14_OFF);
302 + div = (tmp >> ((m - 1) * BCMA_CC_PPL_MDIV_WIDTH)) &
303 + BCMA_CC_PPL_MDIV_MASK;
305 + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_NM5_OFF);
306 + ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
308 + /* Do calculation in Mhz */
309 + fc = bcma_pmu_alp_clock(cc) / 1000000;
310 + fc = (p1 * ndiv * fc) / p2;
312 + /* Return clock in Hertz */
313 + return (fc / div) * 1000000;
316 +/* query bus clock frequency for PMU-enabled chipcommon */
317 +u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
319 + struct bcma_bus *bus = cc->core->bus;
321 + switch (bus->chipinfo.id) {
325 + return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
326 + BCMA_CC_PMU5_MAINPLL_SSB);
328 + return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
329 + BCMA_CC_PMU5_MAINPLL_SSB);
332 + return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
333 + BCMA_CC_PMU5_MAINPLL_SSB);
335 + return bcma_pmu_clock(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
336 + BCMA_CC_PMU5_MAINPLL_SSB);
340 + pr_warn("No backplane clock specified for %04X device, "
341 + "pmu rev. %d, using default %d Hz\n",
342 + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
344 + return BCMA_CC_PMU_HT_CLOCK;
347 +/* query cpu clock frequency for PMU-enabled chipcommon */
348 +u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
350 + struct bcma_bus *bus = cc->core->bus;
352 + if (bus->chipinfo.id == 53572)
355 + if (cc->pmu.rev >= 5) {
357 + switch (bus->chipinfo.id) {
359 + pll = BCMA_CC_PMU5356_MAINPLL_PLL0;
363 + pll = BCMA_CC_PMU5357_MAINPLL_PLL0;
366 + pll = BCMA_CC_PMU4716_MAINPLL_PLL0;
370 + /* TODO: if (bus->chipinfo.id == 0x5300)
371 + return si_4706_pmu_clock(sih, osh, cc, PMU4706_MAINPLL_PLL0, PMU5_MAINPLL_CPU); */
372 + return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
375 + return bcma_pmu_get_clockcontrol(cc);
378 +++ b/drivers/bcma/driver_mips.c
381 + * Broadcom specific AMBA
382 + * Broadcom MIPS32 74K core driver
384 + * Copyright 2009, Broadcom Corporation
385 + * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
386 + * Copyright 2010, Bernhard Loos <bernhardloos@googlemail.com>
387 + * Copyright 2011, Hauke Mehrtens <hauke@hauke-m.de>
389 + * Licensed under the GNU/GPL. See COPYING for details.
392 +#include "bcma_private.h"
394 +#include <linux/bcma/bcma.h>
396 +#include <linux/serial.h>
397 +#include <linux/serial_core.h>
398 +#include <linux/serial_reg.h>
399 +#include <linux/time.h>
401 +/* The 47162a0 hangs when reading MIPS DMP registers registers */
402 +static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
404 + return dev->bus->chipinfo.id == 47162 && dev->bus->chipinfo.rev == 0 &&
405 + dev->id.id == BCMA_CORE_MIPS_74K;
408 +/* The 5357b0 hangs when reading USB20H DMP registers */
409 +static inline bool bcma_core_mips_bcm5357b0_quirk(struct bcma_device *dev)
411 + return (dev->bus->chipinfo.id == 0x5357 ||
412 + dev->bus->chipinfo.id == 0x4749) &&
413 + dev->bus->chipinfo.pkg == 11 &&
414 + dev->id.id == BCMA_CORE_USB20_HOST;
417 +static inline u32 mips_read32(struct bcma_drv_mips *mcore,
420 + return bcma_read32(mcore->core, offset);
423 +static inline void mips_write32(struct bcma_drv_mips *mcore,
427 + bcma_write32(mcore->core, offset, value);
430 +static const u32 ipsflag_irq_mask[] = {
432 + BCMA_MIPS_IPSFLAG_IRQ1,
433 + BCMA_MIPS_IPSFLAG_IRQ2,
434 + BCMA_MIPS_IPSFLAG_IRQ3,
435 + BCMA_MIPS_IPSFLAG_IRQ4,
438 +static const u32 ipsflag_irq_shift[] = {
440 + BCMA_MIPS_IPSFLAG_IRQ1_SHIFT,
441 + BCMA_MIPS_IPSFLAG_IRQ2_SHIFT,
442 + BCMA_MIPS_IPSFLAG_IRQ3_SHIFT,
443 + BCMA_MIPS_IPSFLAG_IRQ4_SHIFT,
446 +static u32 bcma_core_mips_irqflag(struct bcma_device *dev)
450 + if (bcma_core_mips_bcm47162a0_quirk(dev))
451 + return dev->core_index;
452 + if (bcma_core_mips_bcm5357b0_quirk(dev))
453 + return dev->core_index;
454 + flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
456 + return flag & 0x1F;
459 +/* Get the MIPS IRQ assignment for a specified device.
460 + * If unassigned, 0 is returned.
462 +unsigned int bcma_core_mips_irq(struct bcma_device *dev)
464 + struct bcma_device *mdev = dev->bus->drv_mips.core;
468 + irqflag = bcma_core_mips_irqflag(dev);
470 + for (irq = 1; irq <= 4; irq++)
471 + if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
477 +EXPORT_SYMBOL(bcma_core_mips_irq);
479 +static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
481 + unsigned int oldirq = bcma_core_mips_irq(dev);
482 + struct bcma_bus *bus = dev->bus;
483 + struct bcma_device *mdev = bus->drv_mips.core;
486 + irqflag = bcma_core_mips_irqflag(dev);
487 + BUG_ON(oldirq == 6);
489 + dev->irq = irq + 2;
491 + /* clear the old irq */
493 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
494 + bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
497 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
499 + /* assign the new one */
501 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
502 + bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
505 + u32 oldirqflag = bcma_read32(mdev,
506 + BCMA_MIPS_MIPS74K_INTMASK(irq));
508 + struct bcma_device *core;
510 + /* backplane irq line is in use, find out who uses
511 + * it and set user to irq 0
513 + list_for_each_entry_reverse(core, &bus->cores, list) {
514 + if ((1 << bcma_core_mips_irqflag(core)) ==
516 + bcma_core_mips_set_irq(core, 0);
521 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq),
525 + pr_info("set_irq: core 0x%04x, irq %d => %d\n",
526 + dev->id.id, oldirq + 2, irq + 2);
529 +static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
532 + static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
533 + printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
534 + for (i = 0; i <= 6; i++)
535 + printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
539 +static void bcma_core_mips_dump_irq(struct bcma_bus *bus)
541 + struct bcma_device *core;
543 + list_for_each_entry_reverse(core, &bus->cores, list) {
544 + bcma_core_mips_print_irq(core, bcma_core_mips_irq(core));
548 +u32 bcma_cpu_clock(struct bcma_drv_mips *mcore)
550 + struct bcma_bus *bus = mcore->core->bus;
552 + if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
553 + return bcma_pmu_get_clockcpu(&bus->drv_cc);
555 + pr_err("No PMU available, need this to get the cpu clock\n");
558 +EXPORT_SYMBOL(bcma_cpu_clock);
560 +static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
562 + struct bcma_bus *bus = mcore->core->bus;
564 + switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
565 + case BCMA_CC_FLASHT_STSER:
566 + case BCMA_CC_FLASHT_ATSER:
567 + pr_err("Serial flash not supported.\n");
569 + case BCMA_CC_FLASHT_PARA:
570 + pr_info("found parallel flash.\n");
571 + bus->drv_cc.pflash.window = 0x1c000000;
572 + bus->drv_cc.pflash.window_size = 0x02000000;
574 + if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
575 + BCMA_CC_FLASH_CFG_DS) == 0)
576 + bus->drv_cc.pflash.buswidth = 1;
578 + bus->drv_cc.pflash.buswidth = 2;
581 + pr_err("flash not supported.\n");
585 +void bcma_core_mips_init(struct bcma_drv_mips *mcore)
587 + struct bcma_bus *bus;
588 + struct bcma_device *core;
589 + bus = mcore->core->bus;
591 + pr_info("Initializing MIPS core...\n");
593 + if (!mcore->setup_done)
594 + mcore->assigned_irqs = 1;
596 + /* Assign IRQs to all cores on the bus */
597 + list_for_each_entry_reverse(core, &bus->cores, list) {
602 + mips_irq = bcma_core_mips_irq(core);
606 + core->irq = mips_irq + 2;
609 + switch (core->id.id) {
610 + case BCMA_CORE_PCI:
611 + case BCMA_CORE_PCIE:
612 + case BCMA_CORE_ETHERNET:
613 + case BCMA_CORE_ETHERNET_GBIT:
614 + case BCMA_CORE_MAC_GBIT:
615 + case BCMA_CORE_80211:
616 + case BCMA_CORE_USB20_HOST:
617 + /* These devices get their own IRQ line if available,
618 + * the rest goes on IRQ0
620 + if (mcore->assigned_irqs <= 4)
621 + bcma_core_mips_set_irq(core,
622 + mcore->assigned_irqs++);
626 + pr_info("IRQ reconfiguration done\n");
627 + bcma_core_mips_dump_irq(bus);
629 + if (mcore->setup_done)
632 + bcma_chipco_serial_init(&bus->drv_cc);
633 + bcma_core_mips_flash_detect(mcore);
634 + mcore->setup_done = true;
636 --- a/drivers/bcma/driver_pci.c
637 +++ b/drivers/bcma/driver_pci.c
638 @@ -173,7 +173,7 @@ static bool bcma_core_pci_is_in_hostmode
641 #ifdef CONFIG_SSB_DRIVER_PCICORE
642 - if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
643 + if (bus->sprom.boardflags_lo & SSB_BFL_NOPCI)
645 #endif /* CONFIG_SSB_DRIVER_PCICORE */
647 @@ -189,6 +189,9 @@ static bool bcma_core_pci_is_in_hostmode
649 void bcma_core_pci_init(struct bcma_drv_pci *pc)
651 + if (pc->setup_done)
654 if (bcma_core_pci_is_in_hostmode(pc)) {
655 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
656 bcma_core_pci_hostmode_init(pc);
657 @@ -198,6 +201,8 @@ void bcma_core_pci_init(struct bcma_drv_
659 bcma_core_pci_clientmode_init(pc);
662 + pc->setup_done = true;
665 int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
666 @@ -205,7 +210,14 @@ int bcma_core_pci_irq_ctl(struct bcma_dr
668 struct pci_dev *pdev = pc->core->bus->host_pci;
673 + if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
674 + /* This bcma device is not on a PCI host-bus. So the IRQs are
675 + * not routed through the PCI core.
676 + * So we must not enable routing through the PCI core. */
680 err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
682 --- a/drivers/bcma/host_pci.c
683 +++ b/drivers/bcma/host_pci.c
685 #include <linux/slab.h>
686 #include <linux/bcma/bcma.h>
687 #include <linux/pci.h>
688 +#include <linux/module.h>
690 static void bcma_host_pci_switch_core(struct bcma_device *core)
692 @@ -20,48 +21,58 @@ static void bcma_host_pci_switch_core(st
693 pr_debug("Switched to core: 0x%X\n", core->id.id);
696 -static u8 bcma_host_pci_read8(struct bcma_device *core, u16 offset)
698 +/* Provides access to the requested core. Returns base offset that has to be
699 + * used. It makes use of fixed windows when possible. */
700 +static u16 bcma_host_pci_provide_access_to_core(struct bcma_device *core)
702 + switch (core->id.id) {
703 + case BCMA_CORE_CHIPCOMMON:
704 + return 3 * BCMA_CORE_SIZE;
705 + case BCMA_CORE_PCIE:
706 + return 2 * BCMA_CORE_SIZE;
709 if (core->bus->mapped_core != core)
710 bcma_host_pci_switch_core(core);
714 +static u8 bcma_host_pci_read8(struct bcma_device *core, u16 offset)
716 + offset += bcma_host_pci_provide_access_to_core(core);
717 return ioread8(core->bus->mmio + offset);
720 static u16 bcma_host_pci_read16(struct bcma_device *core, u16 offset)
722 - if (core->bus->mapped_core != core)
723 - bcma_host_pci_switch_core(core);
724 + offset += bcma_host_pci_provide_access_to_core(core);
725 return ioread16(core->bus->mmio + offset);
728 static u32 bcma_host_pci_read32(struct bcma_device *core, u16 offset)
730 - if (core->bus->mapped_core != core)
731 - bcma_host_pci_switch_core(core);
732 + offset += bcma_host_pci_provide_access_to_core(core);
733 return ioread32(core->bus->mmio + offset);
736 static void bcma_host_pci_write8(struct bcma_device *core, u16 offset,
739 - if (core->bus->mapped_core != core)
740 - bcma_host_pci_switch_core(core);
741 + offset += bcma_host_pci_provide_access_to_core(core);
742 iowrite8(value, core->bus->mmio + offset);
745 static void bcma_host_pci_write16(struct bcma_device *core, u16 offset,
748 - if (core->bus->mapped_core != core)
749 - bcma_host_pci_switch_core(core);
750 + offset += bcma_host_pci_provide_access_to_core(core);
751 iowrite16(value, core->bus->mmio + offset);
754 static void bcma_host_pci_write32(struct bcma_device *core, u16 offset,
757 - if (core->bus->mapped_core != core)
758 - bcma_host_pci_switch_core(core);
759 + offset += bcma_host_pci_provide_access_to_core(core);
760 iowrite32(value, core->bus->mmio + offset);
763 @@ -223,6 +234,41 @@ static void bcma_host_pci_remove(struct
764 pci_set_drvdata(dev, NULL);
768 +static int bcma_host_pci_suspend(struct pci_dev *dev, pm_message_t state)
770 + /* Host specific */
771 + pci_save_state(dev);
772 + pci_disable_device(dev);
773 + pci_set_power_state(dev, pci_choose_state(dev, state));
778 +static int bcma_host_pci_resume(struct pci_dev *dev)
780 + struct bcma_bus *bus = pci_get_drvdata(dev);
783 + /* Host specific */
784 + pci_set_power_state(dev, 0);
785 + err = pci_enable_device(dev);
788 + pci_restore_state(dev);
791 + err = bcma_bus_resume(bus);
797 +#else /* CONFIG_PM */
798 +# define bcma_host_pci_suspend NULL
799 +# define bcma_host_pci_resume NULL
800 +#endif /* CONFIG_PM */
802 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
803 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
804 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
805 @@ -238,6 +284,8 @@ static struct pci_driver bcma_pci_bridge
806 .id_table = bcma_pci_bridge_tbl,
807 .probe = bcma_host_pci_probe,
808 .remove = bcma_host_pci_remove,
809 + .suspend = bcma_host_pci_suspend,
810 + .resume = bcma_host_pci_resume,
813 int __init bcma_host_pci_init(void)
815 +++ b/drivers/bcma/host_soc.c
818 + * Broadcom specific AMBA
819 + * System on Chip (SoC) Host
821 + * Licensed under the GNU/GPL. See COPYING for details.
824 +#include "bcma_private.h"
826 +#include <linux/bcma/bcma.h>
827 +#include <linux/bcma/bcma_soc.h>
829 +static u8 bcma_host_soc_read8(struct bcma_device *core, u16 offset)
831 + return readb(core->io_addr + offset);
834 +static u16 bcma_host_soc_read16(struct bcma_device *core, u16 offset)
836 + return readw(core->io_addr + offset);
839 +static u32 bcma_host_soc_read32(struct bcma_device *core, u16 offset)
841 + return readl(core->io_addr + offset);
844 +static void bcma_host_soc_write8(struct bcma_device *core, u16 offset,
847 + writeb(value, core->io_addr + offset);
850 +static void bcma_host_soc_write16(struct bcma_device *core, u16 offset,
853 + writew(value, core->io_addr + offset);
856 +static void bcma_host_soc_write32(struct bcma_device *core, u16 offset,
859 + writel(value, core->io_addr + offset);
862 +#ifdef CONFIG_BCMA_BLOCKIO
863 +static void bcma_host_soc_block_read(struct bcma_device *core, void *buffer,
864 + size_t count, u16 offset, u8 reg_width)
866 + void __iomem *addr = core->io_addr + offset;
868 + switch (reg_width) {
873 + *buf = __raw_readb(addr);
879 + case sizeof(u16): {
880 + __le16 *buf = buffer;
882 + WARN_ON(count & 1);
884 + *buf = (__force __le16)__raw_readw(addr);
890 + case sizeof(u32): {
891 + __le32 *buf = buffer;
893 + WARN_ON(count & 3);
895 + *buf = (__force __le32)__raw_readl(addr);
906 +static void bcma_host_soc_block_write(struct bcma_device *core,
907 + const void *buffer,
908 + size_t count, u16 offset, u8 reg_width)
910 + void __iomem *addr = core->io_addr + offset;
912 + switch (reg_width) {
914 + const u8 *buf = buffer;
917 + __raw_writeb(*buf, addr);
923 + case sizeof(u16): {
924 + const __le16 *buf = buffer;
926 + WARN_ON(count & 1);
928 + __raw_writew((__force u16)(*buf), addr);
934 + case sizeof(u32): {
935 + const __le32 *buf = buffer;
937 + WARN_ON(count & 3);
939 + __raw_writel((__force u32)(*buf), addr);
949 +#endif /* CONFIG_BCMA_BLOCKIO */
951 +static u32 bcma_host_soc_aread32(struct bcma_device *core, u16 offset)
953 + return readl(core->io_wrap + offset);
956 +static void bcma_host_soc_awrite32(struct bcma_device *core, u16 offset,
959 + writel(value, core->io_wrap + offset);
962 +const struct bcma_host_ops bcma_host_soc_ops = {
963 + .read8 = bcma_host_soc_read8,
964 + .read16 = bcma_host_soc_read16,
965 + .read32 = bcma_host_soc_read32,
966 + .write8 = bcma_host_soc_write8,
967 + .write16 = bcma_host_soc_write16,
968 + .write32 = bcma_host_soc_write32,
969 +#ifdef CONFIG_BCMA_BLOCKIO
970 + .block_read = bcma_host_soc_block_read,
971 + .block_write = bcma_host_soc_block_write,
973 + .aread32 = bcma_host_soc_aread32,
974 + .awrite32 = bcma_host_soc_awrite32,
977 +int __init bcma_host_soc_register(struct bcma_soc *soc)
979 + struct bcma_bus *bus = &soc->bus;
982 + /* iomap only first core. We have to read some register on this core
985 + bus->mmio = ioremap_nocache(BCMA_ADDR_BASE, BCMA_CORE_SIZE * 1);
989 + /* Host specific */
990 + bus->hosttype = BCMA_HOSTTYPE_SOC;
991 + bus->ops = &bcma_host_soc_ops;
994 + err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
996 + iounmap(bus->mmio);
1000 --- a/drivers/bcma/main.c
1001 +++ b/drivers/bcma/main.c
1005 #include "bcma_private.h"
1006 +#include <linux/module.h>
1007 #include <linux/bcma/bcma.h>
1008 #include <linux/slab.h>
1010 @@ -68,6 +69,10 @@ static struct bcma_device *bcma_find_cor
1011 static void bcma_release_core_dev(struct device *dev)
1013 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1014 + if (core->io_addr)
1015 + iounmap(core->io_addr);
1016 + if (core->io_wrap)
1017 + iounmap(core->io_wrap);
1021 @@ -82,6 +87,7 @@ static int bcma_register_cores(struct bc
1022 case BCMA_CORE_CHIPCOMMON:
1024 case BCMA_CORE_PCIE:
1025 + case BCMA_CORE_MIPS_74K:
1029 @@ -95,7 +101,10 @@ static int bcma_register_cores(struct bc
1030 core->dma_dev = &bus->host_pci->dev;
1031 core->irq = bus->host_pci->irq;
1033 - case BCMA_HOSTTYPE_NONE:
1034 + case BCMA_HOSTTYPE_SOC:
1035 + core->dev.dma_mask = &core->dev.coherent_dma_mask;
1036 + core->dma_dev = &core->dev;
1038 case BCMA_HOSTTYPE_SDIO:
1041 @@ -142,6 +151,13 @@ int bcma_bus_register(struct bcma_bus *b
1042 bcma_core_chipcommon_init(&bus->drv_cc);
1045 + /* Init MIPS core */
1046 + core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1048 + bus->drv_mips.core = core;
1049 + bcma_core_mips_init(&bus->drv_mips);
1052 /* Init PCIE core */
1053 core = bcma_find_core(bus, BCMA_CORE_PCIE);
1055 @@ -171,6 +187,75 @@ void bcma_bus_unregister(struct bcma_bus
1056 bcma_unregister_cores(bus);
1059 +int __init bcma_bus_early_register(struct bcma_bus *bus,
1060 + struct bcma_device *core_cc,
1061 + struct bcma_device *core_mips)
1064 + struct bcma_device *core;
1065 + struct bcma_device_id match;
1067 + bcma_init_bus(bus);
1069 + match.manuf = BCMA_MANUF_BCM;
1070 + match.id = BCMA_CORE_CHIPCOMMON;
1071 + match.class = BCMA_CL_SIM;
1072 + match.rev = BCMA_ANY_REV;
1074 + /* Scan for chip common core */
1075 + err = bcma_bus_scan_early(bus, &match, core_cc);
1077 + pr_err("Failed to scan for common core: %d\n", err);
1081 + match.manuf = BCMA_MANUF_MIPS;
1082 + match.id = BCMA_CORE_MIPS_74K;
1083 + match.class = BCMA_CL_SIM;
1084 + match.rev = BCMA_ANY_REV;
1086 + /* Scan for mips core */
1087 + err = bcma_bus_scan_early(bus, &match, core_mips);
1089 + pr_err("Failed to scan for mips core: %d\n", err);
1093 + /* Init CC core */
1094 + core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
1096 + bus->drv_cc.core = core;
1097 + bcma_core_chipcommon_init(&bus->drv_cc);
1100 + /* Init MIPS core */
1101 + core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1103 + bus->drv_mips.core = core;
1104 + bcma_core_mips_init(&bus->drv_mips);
1107 + pr_info("Early bus registered\n");
1113 +int bcma_bus_resume(struct bcma_bus *bus)
1115 + struct bcma_device *core;
1117 + /* Init CC core */
1118 + core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
1120 + bus->drv_cc.setup_done = false;
1121 + bcma_core_chipcommon_init(&bus->drv_cc);
1128 int __bcma_driver_register(struct bcma_driver *drv, struct module *owner)
1130 drv->drv.name = drv->name;
1131 --- a/drivers/bcma/scan.c
1132 +++ b/drivers/bcma/scan.c
1133 @@ -200,18 +200,162 @@ static s32 bcma_erom_get_addr_desc(struc
1137 -int bcma_bus_scan(struct bcma_bus *bus)
1138 +static struct bcma_device *bcma_find_core_by_index(struct bcma_bus *bus,
1142 - u32 __iomem *eromptr, *eromend;
1143 + struct bcma_device *core;
1145 + list_for_each_entry(core, &bus->cores, list) {
1146 + if (core->core_index == index)
1152 +static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
1153 + struct bcma_device_id *match, int core_num,
1154 + struct bcma_device *core)
1159 u8 ports[2], wrappers[2];
1162 + cia = bcma_erom_get_ci(bus, eromptr);
1164 + bcma_erom_push_ent(eromptr);
1165 + if (bcma_erom_is_end(bus, eromptr))
1169 + cib = bcma_erom_get_ci(bus, eromptr);
1174 + core->id.class = (cia & SCAN_CIA_CLASS) >> SCAN_CIA_CLASS_SHIFT;
1175 + core->id.id = (cia & SCAN_CIA_ID) >> SCAN_CIA_ID_SHIFT;
1176 + core->id.manuf = (cia & SCAN_CIA_MANUF) >> SCAN_CIA_MANUF_SHIFT;
1177 + ports[0] = (cib & SCAN_CIB_NMP) >> SCAN_CIB_NMP_SHIFT;
1178 + ports[1] = (cib & SCAN_CIB_NSP) >> SCAN_CIB_NSP_SHIFT;
1179 + wrappers[0] = (cib & SCAN_CIB_NMW) >> SCAN_CIB_NMW_SHIFT;
1180 + wrappers[1] = (cib & SCAN_CIB_NSW) >> SCAN_CIB_NSW_SHIFT;
1181 + core->id.rev = (cib & SCAN_CIB_REV) >> SCAN_CIB_REV_SHIFT;
1183 + if (((core->id.manuf == BCMA_MANUF_ARM) &&
1184 + (core->id.id == 0xFFF)) ||
1185 + (ports[1] == 0)) {
1186 + bcma_erom_skip_component(bus, eromptr);
1190 + /* check if component is a core at all */
1191 + if (wrappers[0] + wrappers[1] == 0) {
1192 + /* we could save addrl of the router
1193 + if (cid == BCMA_CORE_OOB_ROUTER)
1195 + bcma_erom_skip_component(bus, eromptr);
1199 + if (bcma_erom_is_bridge(bus, eromptr)) {
1200 + bcma_erom_skip_component(bus, eromptr);
1204 + if (bcma_find_core_by_index(bus, core_num)) {
1205 + bcma_erom_skip_component(bus, eromptr);
1209 + if (match && ((match->manuf != BCMA_ANY_MANUF &&
1210 + match->manuf != core->id.manuf) ||
1211 + (match->id != BCMA_ANY_ID && match->id != core->id.id) ||
1212 + (match->rev != BCMA_ANY_REV && match->rev != core->id.rev) ||
1213 + (match->class != BCMA_ANY_CLASS && match->class != core->id.class)
1215 + bcma_erom_skip_component(bus, eromptr);
1219 + /* get & parse master ports */
1220 + for (i = 0; i < ports[0]; i++) {
1221 + s32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
1222 + if (mst_port_d < 0)
1226 + /* get & parse slave ports */
1227 + for (i = 0; i < ports[1]; i++) {
1228 + for (j = 0; ; j++) {
1229 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
1230 + SCAN_ADDR_TYPE_SLAVE, i);
1232 + /* no more entries for port _i_ */
1233 + /* pr_debug("erom: slave port %d "
1234 + * "has %d descriptors\n", i, j); */
1237 + if (i == 0 && j == 0)
1243 + /* get & parse master wrappers */
1244 + for (i = 0; i < wrappers[0]; i++) {
1245 + for (j = 0; ; j++) {
1246 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
1247 + SCAN_ADDR_TYPE_MWRAP, i);
1249 + /* no more entries for port _i_ */
1250 + /* pr_debug("erom: master wrapper %d "
1251 + * "has %d descriptors\n", i, j); */
1254 + if (i == 0 && j == 0)
1260 + /* get & parse slave wrappers */
1261 + for (i = 0; i < wrappers[1]; i++) {
1262 + u8 hack = (ports[1] == 1) ? 0 : 1;
1263 + for (j = 0; ; j++) {
1264 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
1265 + SCAN_ADDR_TYPE_SWRAP, i + hack);
1267 + /* no more entries for port _i_ */
1268 + /* pr_debug("erom: master wrapper %d "
1269 + * has %d descriptors\n", i, j); */
1272 + if (wrappers[0] == 0 && !i && !j)
1277 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
1278 + core->io_addr = ioremap_nocache(core->addr, BCMA_CORE_SIZE);
1279 + if (!core->io_addr)
1281 + core->io_wrap = ioremap_nocache(core->wrap, BCMA_CORE_SIZE);
1282 + if (!core->io_wrap) {
1283 + iounmap(core->io_addr);
1290 +void bcma_init_bus(struct bcma_bus *bus)
1296 + if (bus->init_done)
1299 INIT_LIST_HEAD(&bus->cores);
1301 @@ -222,9 +366,27 @@ int bcma_bus_scan(struct bcma_bus *bus)
1302 bus->chipinfo.id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
1303 bus->chipinfo.rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
1304 bus->chipinfo.pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
1305 + bus->init_done = true;
1308 +int bcma_bus_scan(struct bcma_bus *bus)
1311 + u32 __iomem *eromptr, *eromend;
1313 + int err, core_num = 0;
1315 + bcma_init_bus(bus);
1317 erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
1318 - eromptr = bus->mmio;
1319 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
1320 + eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
1324 + eromptr = bus->mmio;
1327 eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);
1329 bcma_scan_switch_core(bus, erombase);
1330 @@ -236,125 +398,89 @@ int bcma_bus_scan(struct bcma_bus *bus)
1331 INIT_LIST_HEAD(&core->list);
1335 - cia = bcma_erom_get_ci(bus, &eromptr);
1337 - bcma_erom_push_ent(&eromptr);
1338 - if (bcma_erom_is_end(bus, &eromptr))
1343 - cib = bcma_erom_get_ci(bus, &eromptr);
1350 - core->id.class = (cia & SCAN_CIA_CLASS) >> SCAN_CIA_CLASS_SHIFT;
1351 - core->id.id = (cia & SCAN_CIA_ID) >> SCAN_CIA_ID_SHIFT;
1352 - core->id.manuf = (cia & SCAN_CIA_MANUF) >> SCAN_CIA_MANUF_SHIFT;
1353 - ports[0] = (cib & SCAN_CIB_NMP) >> SCAN_CIB_NMP_SHIFT;
1354 - ports[1] = (cib & SCAN_CIB_NSP) >> SCAN_CIB_NSP_SHIFT;
1355 - wrappers[0] = (cib & SCAN_CIB_NMW) >> SCAN_CIB_NMW_SHIFT;
1356 - wrappers[1] = (cib & SCAN_CIB_NSW) >> SCAN_CIB_NSW_SHIFT;
1357 - core->id.rev = (cib & SCAN_CIB_REV) >> SCAN_CIB_REV_SHIFT;
1359 - if (((core->id.manuf == BCMA_MANUF_ARM) &&
1360 - (core->id.id == 0xFFF)) ||
1361 - (ports[1] == 0)) {
1362 - bcma_erom_skip_component(bus, &eromptr);
1363 + err = bcma_get_next_core(bus, &eromptr, NULL, core_num, core);
1364 + if (err == -ENODEV) {
1369 - /* check if component is a core at all */
1370 - if (wrappers[0] + wrappers[1] == 0) {
1371 - /* we could save addrl of the router
1372 - if (cid == BCMA_CORE_OOB_ROUTER)
1374 - bcma_erom_skip_component(bus, &eromptr);
1375 + } else if (err == -ENXIO)
1378 + else if (err == -ESPIPE)
1383 - if (bcma_erom_is_bridge(bus, &eromptr)) {
1384 - bcma_erom_skip_component(bus, &eromptr);
1387 + core->core_index = core_num++;
1390 - /* get & parse master ports */
1391 - for (i = 0; i < ports[0]; i++) {
1392 - u32 mst_port_d = bcma_erom_get_mst_port(bus, &eromptr);
1393 - if (mst_port_d < 0) {
1398 + pr_info("Core %d found: %s "
1399 + "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
1400 + core->core_index, bcma_device_name(&core->id),
1401 + core->id.manuf, core->id.id, core->id.rev,
1404 - /* get & parse slave ports */
1405 - for (i = 0; i < ports[1]; i++) {
1406 - for (j = 0; ; j++) {
1407 - tmp = bcma_erom_get_addr_desc(bus, &eromptr,
1408 - SCAN_ADDR_TYPE_SLAVE, i);
1410 - /* no more entries for port _i_ */
1411 - /* pr_debug("erom: slave port %d "
1412 - * "has %d descriptors\n", i, j); */
1415 - if (i == 0 && j == 0)
1420 + list_add(&core->list, &bus->cores);
1423 - /* get & parse master wrappers */
1424 - for (i = 0; i < wrappers[0]; i++) {
1425 - for (j = 0; ; j++) {
1426 - tmp = bcma_erom_get_addr_desc(bus, &eromptr,
1427 - SCAN_ADDR_TYPE_MWRAP, i);
1429 - /* no more entries for port _i_ */
1430 - /* pr_debug("erom: master wrapper %d "
1431 - * "has %d descriptors\n", i, j); */
1434 - if (i == 0 && j == 0)
1439 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
1442 - /* get & parse slave wrappers */
1443 - for (i = 0; i < wrappers[1]; i++) {
1444 - u8 hack = (ports[1] == 1) ? 0 : 1;
1445 - for (j = 0; ; j++) {
1446 - tmp = bcma_erom_get_addr_desc(bus, &eromptr,
1447 - SCAN_ADDR_TYPE_SWRAP, i + hack);
1449 - /* no more entries for port _i_ */
1450 - /* pr_debug("erom: master wrapper %d "
1451 - * has %d descriptors\n", i, j); */
1454 - if (wrappers[0] == 0 && !i && !j)
1462 +int __init bcma_bus_scan_early(struct bcma_bus *bus,
1463 + struct bcma_device_id *match,
1464 + struct bcma_device *core)
1467 + u32 __iomem *eromptr, *eromend;
1469 + int err = -ENODEV;
1472 + erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
1473 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
1474 + eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
1478 + eromptr = bus->mmio;
1481 + eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);
1483 + bcma_scan_switch_core(bus, erombase);
1485 + while (eromptr < eromend) {
1486 + memset(core, 0, sizeof(*core));
1487 + INIT_LIST_HEAD(&core->list);
1490 + err = bcma_get_next_core(bus, &eromptr, match, core_num, core);
1491 + if (err == -ENODEV) {
1494 + } else if (err == -ENXIO)
1496 + else if (err == -ESPIPE)
1501 + core->core_index = core_num++;
1503 pr_info("Core %d found: %s "
1504 "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
1505 - bus->nr_cores, bcma_device_name(&core->id),
1506 + core->core_index, bcma_device_name(&core->id),
1507 core->id.manuf, core->id.id, core->id.rev,
1510 - core->core_index = bus->nr_cores++;
1511 list_add(&core->list, &bus->cores);
1520 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
1525 --- a/drivers/bcma/sprom.c
1526 +++ b/drivers/bcma/sprom.c
1527 @@ -129,10 +129,80 @@ static void bcma_sprom_extract_r8(struct
1531 + bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
1532 + SSB_SPROM_REVISION_REV;
1534 for (i = 0; i < 3; i++) {
1535 v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
1536 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
1539 + bus->sprom.board_rev = sprom[SPOFF(SSB_SPROM8_BOARDREV)];
1541 + bus->sprom.txpid2g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
1542 + SSB_SPROM4_TXPID2G0) >> SSB_SPROM4_TXPID2G0_SHIFT;
1543 + bus->sprom.txpid2g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
1544 + SSB_SPROM4_TXPID2G1) >> SSB_SPROM4_TXPID2G1_SHIFT;
1545 + bus->sprom.txpid2g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
1546 + SSB_SPROM4_TXPID2G2) >> SSB_SPROM4_TXPID2G2_SHIFT;
1547 + bus->sprom.txpid2g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
1548 + SSB_SPROM4_TXPID2G3) >> SSB_SPROM4_TXPID2G3_SHIFT;
1550 + bus->sprom.txpid5gl[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
1551 + SSB_SPROM4_TXPID5GL0) >> SSB_SPROM4_TXPID5GL0_SHIFT;
1552 + bus->sprom.txpid5gl[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
1553 + SSB_SPROM4_TXPID5GL1) >> SSB_SPROM4_TXPID5GL1_SHIFT;
1554 + bus->sprom.txpid5gl[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
1555 + SSB_SPROM4_TXPID5GL2) >> SSB_SPROM4_TXPID5GL2_SHIFT;
1556 + bus->sprom.txpid5gl[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
1557 + SSB_SPROM4_TXPID5GL3) >> SSB_SPROM4_TXPID5GL3_SHIFT;
1559 + bus->sprom.txpid5g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
1560 + SSB_SPROM4_TXPID5G0) >> SSB_SPROM4_TXPID5G0_SHIFT;
1561 + bus->sprom.txpid5g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
1562 + SSB_SPROM4_TXPID5G1) >> SSB_SPROM4_TXPID5G1_SHIFT;
1563 + bus->sprom.txpid5g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
1564 + SSB_SPROM4_TXPID5G2) >> SSB_SPROM4_TXPID5G2_SHIFT;
1565 + bus->sprom.txpid5g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
1566 + SSB_SPROM4_TXPID5G3) >> SSB_SPROM4_TXPID5G3_SHIFT;
1568 + bus->sprom.txpid5gh[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
1569 + SSB_SPROM4_TXPID5GH0) >> SSB_SPROM4_TXPID5GH0_SHIFT;
1570 + bus->sprom.txpid5gh[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
1571 + SSB_SPROM4_TXPID5GH1) >> SSB_SPROM4_TXPID5GH1_SHIFT;
1572 + bus->sprom.txpid5gh[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
1573 + SSB_SPROM4_TXPID5GH2) >> SSB_SPROM4_TXPID5GH2_SHIFT;
1574 + bus->sprom.txpid5gh[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
1575 + SSB_SPROM4_TXPID5GH3) >> SSB_SPROM4_TXPID5GH3_SHIFT;
1577 + bus->sprom.boardflags_lo = sprom[SPOFF(SSB_SPROM8_BFLLO)];
1578 + bus->sprom.boardflags_hi = sprom[SPOFF(SSB_SPROM8_BFLHI)];
1579 + bus->sprom.boardflags2_lo = sprom[SPOFF(SSB_SPROM8_BFL2LO)];
1580 + bus->sprom.boardflags2_hi = sprom[SPOFF(SSB_SPROM8_BFL2HI)];
1582 + bus->sprom.country_code = sprom[SPOFF(SSB_SPROM8_CCODE)];
1584 + bus->sprom.fem.ghz2.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
1585 + SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
1586 + bus->sprom.fem.ghz2.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
1587 + SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
1588 + bus->sprom.fem.ghz2.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
1589 + SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
1590 + bus->sprom.fem.ghz2.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
1591 + SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
1592 + bus->sprom.fem.ghz2.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
1593 + SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
1595 + bus->sprom.fem.ghz5.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
1596 + SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
1597 + bus->sprom.fem.ghz5.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
1598 + SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
1599 + bus->sprom.fem.ghz5.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
1600 + SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
1601 + bus->sprom.fem.ghz5.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
1602 + SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
1603 + bus->sprom.fem.ghz5.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
1604 + SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
1607 int bcma_sprom_get(struct bcma_bus *bus)
1608 @@ -152,6 +222,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
1612 + if (bus->chipinfo.id == 0x4331)
1613 + bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
1615 /* Most cards have SPROM moved by additional offset 0x30 (48 dwords).
1616 * According to brcm80211 this applies to cards with PCIe rev >= 6
1617 * TODO: understand this condition and use it */
1618 @@ -159,6 +232,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
1619 BCMA_CC_SPROM_PCIE6;
1620 bcma_sprom_read(bus, offset, sprom);
1622 + if (bus->chipinfo.id == 0x4331)
1623 + bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
1625 err = bcma_sprom_valid(sprom);
1628 --- a/include/linux/bcma/bcma.h
1629 +++ b/include/linux/bcma/bcma.h
1632 #include <linux/bcma/bcma_driver_chipcommon.h>
1633 #include <linux/bcma/bcma_driver_pci.h>
1634 +#include <linux/bcma/bcma_driver_mips.h>
1635 #include <linux/ssb/ssb.h> /* SPROM sharing */
1637 #include "bcma_regs.h"
1638 @@ -14,9 +15,9 @@ struct bcma_device;
1641 enum bcma_hosttype {
1642 - BCMA_HOSTTYPE_NONE,
1645 + BCMA_HOSTTYPE_SOC,
1648 struct bcma_chipinfo {
1649 @@ -130,6 +131,7 @@ struct bcma_device {
1652 struct device *dma_dev;
1655 bool dev_registered;
1657 @@ -138,6 +140,9 @@ struct bcma_device {
1661 + void __iomem *io_addr;
1662 + void __iomem *io_wrap;
1665 struct list_head list;
1667 @@ -165,10 +170,9 @@ struct bcma_driver {
1670 int __bcma_driver_register(struct bcma_driver *drv, struct module *owner);
1671 -static inline int bcma_driver_register(struct bcma_driver *drv)
1673 - return __bcma_driver_register(drv, THIS_MODULE);
1675 +#define bcma_driver_register(drv) \
1676 + __bcma_driver_register(drv, THIS_MODULE)
1678 extern void bcma_driver_unregister(struct bcma_driver *drv);
1681 @@ -190,70 +194,93 @@ struct bcma_bus {
1682 struct bcma_device *mapped_core;
1683 struct list_head cores;
1687 struct bcma_drv_cc drv_cc;
1688 struct bcma_drv_pci drv_pci;
1689 + struct bcma_drv_mips drv_mips;
1691 /* We decided to share SPROM struct with SSB as long as we do not need
1692 * any hacks for BCMA. This simplifies drivers code. */
1693 struct ssb_sprom sprom;
1696 -extern inline u32 bcma_read8(struct bcma_device *core, u16 offset)
1697 +static inline u32 bcma_read8(struct bcma_device *core, u16 offset)
1699 return core->bus->ops->read8(core, offset);
1701 -extern inline u32 bcma_read16(struct bcma_device *core, u16 offset)
1702 +static inline u32 bcma_read16(struct bcma_device *core, u16 offset)
1704 return core->bus->ops->read16(core, offset);
1706 -extern inline u32 bcma_read32(struct bcma_device *core, u16 offset)
1707 +static inline u32 bcma_read32(struct bcma_device *core, u16 offset)
1709 return core->bus->ops->read32(core, offset);
1713 void bcma_write8(struct bcma_device *core, u16 offset, u32 value)
1715 core->bus->ops->write8(core, offset, value);
1719 void bcma_write16(struct bcma_device *core, u16 offset, u32 value)
1721 core->bus->ops->write16(core, offset, value);
1725 void bcma_write32(struct bcma_device *core, u16 offset, u32 value)
1727 core->bus->ops->write32(core, offset, value);
1729 #ifdef CONFIG_BCMA_BLOCKIO
1730 -extern inline void bcma_block_read(struct bcma_device *core, void *buffer,
1731 +static inline void bcma_block_read(struct bcma_device *core, void *buffer,
1732 size_t count, u16 offset, u8 reg_width)
1734 core->bus->ops->block_read(core, buffer, count, offset, reg_width);
1736 -extern inline void bcma_block_write(struct bcma_device *core, const void *buffer,
1737 - size_t count, u16 offset, u8 reg_width)
1738 +static inline void bcma_block_write(struct bcma_device *core,
1739 + const void *buffer, size_t count,
1740 + u16 offset, u8 reg_width)
1742 core->bus->ops->block_write(core, buffer, count, offset, reg_width);
1745 -extern inline u32 bcma_aread32(struct bcma_device *core, u16 offset)
1746 +static inline u32 bcma_aread32(struct bcma_device *core, u16 offset)
1748 return core->bus->ops->aread32(core, offset);
1752 void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value)
1754 core->bus->ops->awrite32(core, offset, value);
1757 -#define bcma_mask32(cc, offset, mask) \
1758 - bcma_write32(cc, offset, bcma_read32(cc, offset) & (mask))
1759 -#define bcma_set32(cc, offset, set) \
1760 - bcma_write32(cc, offset, bcma_read32(cc, offset) | (set))
1761 -#define bcma_maskset32(cc, offset, mask, set) \
1762 - bcma_write32(cc, offset, (bcma_read32(cc, offset) & (mask)) | (set))
1763 +static inline void bcma_mask32(struct bcma_device *cc, u16 offset, u32 mask)
1765 + bcma_write32(cc, offset, bcma_read32(cc, offset) & mask);
1767 +static inline void bcma_set32(struct bcma_device *cc, u16 offset, u32 set)
1769 + bcma_write32(cc, offset, bcma_read32(cc, offset) | set);
1771 +static inline void bcma_maskset32(struct bcma_device *cc,
1772 + u16 offset, u32 mask, u32 set)
1774 + bcma_write32(cc, offset, (bcma_read32(cc, offset) & mask) | set);
1776 +static inline void bcma_mask16(struct bcma_device *cc, u16 offset, u16 mask)
1778 + bcma_write16(cc, offset, bcma_read16(cc, offset) & mask);
1780 +static inline void bcma_set16(struct bcma_device *cc, u16 offset, u16 set)
1782 + bcma_write16(cc, offset, bcma_read16(cc, offset) | set);
1784 +static inline void bcma_maskset16(struct bcma_device *cc,
1785 + u16 offset, u16 mask, u16 set)
1787 + bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set);
1790 extern bool bcma_core_is_enabled(struct bcma_device *core);
1791 extern void bcma_core_disable(struct bcma_device *core, u32 flags);
1792 --- a/include/linux/bcma/bcma_driver_chipcommon.h
1793 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
1795 #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
1796 #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
1797 #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
1798 +#define BCMA_CC_FLASHT_NFLASH 0x00000200
1799 #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
1800 #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
1801 #define BCMA_PLLTYPE_NONE 0x00000000
1803 #define BCMA_CC_PROG_CFG 0x0120
1804 #define BCMA_CC_PROG_WAITCNT 0x0124
1805 #define BCMA_CC_FLASH_CFG 0x0128
1806 +#define BCMA_CC_FLASH_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
1807 #define BCMA_CC_FLASH_WAITCNT 0x012C
1808 /* 0x1E0 is defined as shared BCMA_CLKCTLST */
1809 #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
1811 #define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
1812 #define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
1813 #define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
1814 +#define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
1815 #define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
1816 #define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
1817 #define BCMA_CC_PMU_CTL_ALPREQEN 0x00000080 /* ALP req enable */
1818 @@ -239,6 +242,64 @@
1819 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
1820 #define BCMA_CC_SPROM_PCIE6 0x0830 /* SPROM beginning on PCIe rev >= 6 */
1822 +/* Divider allocation in 4716/47162/5356 */
1823 +#define BCMA_CC_PMU5_MAINPLL_CPU 1
1824 +#define BCMA_CC_PMU5_MAINPLL_MEM 2
1825 +#define BCMA_CC_PMU5_MAINPLL_SSB 3
1827 +/* PLL usage in 4716/47162 */
1828 +#define BCMA_CC_PMU4716_MAINPLL_PLL0 12
1830 +/* PLL usage in 5356/5357 */
1831 +#define BCMA_CC_PMU5356_MAINPLL_PLL0 0
1832 +#define BCMA_CC_PMU5357_MAINPLL_PLL0 0
1835 +#define BCMA_CC_PMU4706_MAINPLL_PLL0 0
1837 +/* ALP clock on pre-PMU chips */
1838 +#define BCMA_CC_PMU_ALP_CLOCK 20000000
1839 +/* HT clock for systems with PMU-enabled chipcommon */
1840 +#define BCMA_CC_PMU_HT_CLOCK 80000000
1842 +/* PMU rev 5 (& 6) */
1843 +#define BCMA_CC_PPL_P1P2_OFF 0
1844 +#define BCMA_CC_PPL_P1_MASK 0x0f000000
1845 +#define BCMA_CC_PPL_P1_SHIFT 24
1846 +#define BCMA_CC_PPL_P2_MASK 0x00f00000
1847 +#define BCMA_CC_PPL_P2_SHIFT 20
1848 +#define BCMA_CC_PPL_M14_OFF 1
1849 +#define BCMA_CC_PPL_MDIV_MASK 0x000000ff
1850 +#define BCMA_CC_PPL_MDIV_WIDTH 8
1851 +#define BCMA_CC_PPL_NM5_OFF 2
1852 +#define BCMA_CC_PPL_NDIV_MASK 0xfff00000
1853 +#define BCMA_CC_PPL_NDIV_SHIFT 20
1854 +#define BCMA_CC_PPL_FMAB_OFF 3
1855 +#define BCMA_CC_PPL_MRAT_MASK 0xf0000000
1856 +#define BCMA_CC_PPL_MRAT_SHIFT 28
1857 +#define BCMA_CC_PPL_ABRAT_MASK 0x08000000
1858 +#define BCMA_CC_PPL_ABRAT_SHIFT 27
1859 +#define BCMA_CC_PPL_FDIV_MASK 0x07ffffff
1860 +#define BCMA_CC_PPL_PLLCTL_OFF 4
1861 +#define BCMA_CC_PPL_PCHI_OFF 5
1862 +#define BCMA_CC_PPL_PCHI_MASK 0x0000003f
1864 +/* BCM4331 ChipControl numbers. */
1865 +#define BCMA_CHIPCTL_4331_BT_COEXIST BIT(0) /* 0 disable */
1866 +#define BCMA_CHIPCTL_4331_SECI BIT(1) /* 0 SECI is disabled (JATG functional) */
1867 +#define BCMA_CHIPCTL_4331_EXT_LNA BIT(2) /* 0 disable */
1868 +#define BCMA_CHIPCTL_4331_SPROM_GPIO13_15 BIT(3) /* sprom/gpio13-15 mux */
1869 +#define BCMA_CHIPCTL_4331_EXTPA_EN BIT(4) /* 0 ext pa disable, 1 ext pa enabled */
1870 +#define BCMA_CHIPCTL_4331_GPIOCLK_ON_SPROMCS BIT(5) /* set drive out GPIO_CLK on sprom_cs pin */
1871 +#define BCMA_CHIPCTL_4331_PCIE_MDIO_ON_SPROMCS BIT(6) /* use sprom_cs pin as PCIE mdio interface */
1872 +#define BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5 BIT(7) /* aband extpa will be at gpio2/5 and sprom_dout */
1873 +#define BCMA_CHIPCTL_4331_OVR_PIPEAUXCLKEN BIT(8) /* override core control on pipe_AuxClkEnable */
1874 +#define BCMA_CHIPCTL_4331_OVR_PIPEAUXPWRDOWN BIT(9) /* override core control on pipe_AuxPowerDown */
1875 +#define BCMA_CHIPCTL_4331_PCIE_AUXCLKEN BIT(10) /* pcie_auxclkenable */
1876 +#define BCMA_CHIPCTL_4331_PCIE_PIPE_PLLDOWN BIT(11) /* pcie_pipe_pllpowerdown */
1877 +#define BCMA_CHIPCTL_4331_BT_SHD0_ON_GPIO4 BIT(16) /* enable bt_shd0 at gpio4 */
1878 +#define BCMA_CHIPCTL_4331_BT_SHD1_ON_GPIO5 BIT(17) /* enable bt_shd1 at gpio5 */
1880 /* Data for the PMU, if available.
1881 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
1883 @@ -247,14 +308,37 @@ struct bcma_chipcommon_pmu {
1884 u32 crystalfreq; /* The active crystal frequency (in kHz) */
1887 +#ifdef CONFIG_BCMA_DRIVER_MIPS
1888 +struct bcma_pflash {
1894 +struct bcma_serial_port {
1896 + unsigned long clockspeed;
1898 + unsigned int baud_base;
1899 + unsigned int reg_shift;
1901 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
1903 struct bcma_drv_cc {
1904 struct bcma_device *core;
1907 u32 capabilities_ext;
1909 /* Fast Powerup Delay constant */
1910 u16 fast_pwrup_delay;
1911 struct bcma_chipcommon_pmu pmu;
1912 +#ifdef CONFIG_BCMA_DRIVER_MIPS
1913 + struct bcma_pflash pflash;
1915 + int nr_serial_ports;
1916 + struct bcma_serial_port serial_ports[4];
1917 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
1920 /* Register access */
1921 @@ -275,6 +359,8 @@ extern void bcma_core_chipcommon_init(st
1922 extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
1923 extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
1925 +void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
1927 extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
1930 @@ -293,4 +379,13 @@ u32 bcma_chipco_gpio_polarity(struct bcm
1932 extern void bcma_pmu_init(struct bcma_drv_cc *cc);
1934 +extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
1936 +extern void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset,
1937 + u32 mask, u32 set);
1938 +extern void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
1939 + u32 offset, u32 mask, u32 set);
1940 +extern void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc,
1941 + u32 offset, u32 mask, u32 set);
1943 #endif /* LINUX_BCMA_DRIVER_CC_H_ */
1945 +++ b/include/linux/bcma/bcma_driver_mips.h
1947 +#ifndef LINUX_BCMA_DRIVER_MIPS_H_
1948 +#define LINUX_BCMA_DRIVER_MIPS_H_
1950 +#define BCMA_MIPS_IPSFLAG 0x0F08
1951 +/* which sbflags get routed to mips interrupt 1 */
1952 +#define BCMA_MIPS_IPSFLAG_IRQ1 0x0000003F
1953 +#define BCMA_MIPS_IPSFLAG_IRQ1_SHIFT 0
1954 +/* which sbflags get routed to mips interrupt 2 */
1955 +#define BCMA_MIPS_IPSFLAG_IRQ2 0x00003F00
1956 +#define BCMA_MIPS_IPSFLAG_IRQ2_SHIFT 8
1957 +/* which sbflags get routed to mips interrupt 3 */
1958 +#define BCMA_MIPS_IPSFLAG_IRQ3 0x003F0000
1959 +#define BCMA_MIPS_IPSFLAG_IRQ3_SHIFT 16
1960 +/* which sbflags get routed to mips interrupt 4 */
1961 +#define BCMA_MIPS_IPSFLAG_IRQ4 0x3F000000
1962 +#define BCMA_MIPS_IPSFLAG_IRQ4_SHIFT 24
1964 +/* MIPS 74K core registers */
1965 +#define BCMA_MIPS_MIPS74K_CORECTL 0x0000
1966 +#define BCMA_MIPS_MIPS74K_EXCEPTBASE 0x0004
1967 +#define BCMA_MIPS_MIPS74K_BIST 0x000C
1968 +#define BCMA_MIPS_MIPS74K_INTMASK_INT0 0x0014
1969 +#define BCMA_MIPS_MIPS74K_INTMASK(int) \
1970 + ((int) * 4 + BCMA_MIPS_MIPS74K_INTMASK_INT0)
1971 +#define BCMA_MIPS_MIPS74K_NMIMASK 0x002C
1972 +#define BCMA_MIPS_MIPS74K_GPIOSEL 0x0040
1973 +#define BCMA_MIPS_MIPS74K_GPIOOUT 0x0044
1974 +#define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
1975 +#define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
1977 +#define BCMA_MIPS_OOBSELOUTA30 0x100
1979 +struct bcma_device;
1981 +struct bcma_drv_mips {
1982 + struct bcma_device *core;
1984 + unsigned int assigned_irqs;
1987 +#ifdef CONFIG_BCMA_DRIVER_MIPS
1988 +extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
1990 +static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
1993 +extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
1995 +extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
1997 +#endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
1999 +++ b/include/linux/bcma/bcma_soc.h
2001 +#ifndef LINUX_BCMA_SOC_H_
2002 +#define LINUX_BCMA_SOC_H_
2004 +#include <linux/bcma/bcma.h>
2007 + struct bcma_bus bus;
2008 + struct bcma_device core_cc;
2009 + struct bcma_device core_mips;
2012 +int __init bcma_host_soc_register(struct bcma_soc *soc);
2014 +int bcma_bus_register(struct bcma_bus *bus);
2016 +#endif /* LINUX_BCMA_SOC_H_ */