2 +++ b/Documentation/ABI/testing/sysfs-bus-bcma
4 +What: /sys/bus/bcma/devices/.../manuf
7 +Contact: Rafał Miłecki <zajec5@gmail.com>
9 + Each BCMA core has it's manufacturer id. See
10 + include/linux/bcma/bcma.h for possible values.
12 +What: /sys/bus/bcma/devices/.../id
14 +KernelVersion: 2.6.40
15 +Contact: Rafał Miłecki <zajec5@gmail.com>
17 + There are a few types of BCMA cores, they can be identified by
20 +What: /sys/bus/bcma/devices/.../rev
22 +KernelVersion: 2.6.40
23 +Contact: Rafał Miłecki <zajec5@gmail.com>
25 + BCMA cores of the same type can still slightly differ depending
26 + on their revision. Use it for detailed programming.
28 +What: /sys/bus/bcma/devices/.../class
30 +KernelVersion: 2.6.40
31 +Contact: Rafał Miłecki <zajec5@gmail.com>
33 + Each BCMA core is identified by few fields, including class it
34 + belongs to. See include/linux/bcma/bcma.h for possible values.
37 @@ -5832,6 +5832,13 @@ S: Maintained
41 +BROADCOM SPECIFIC AMBA DRIVER (BCMA)
42 +M: Rafał Miłecki <zajec5@gmail.com>
43 +L: linux-wireless@vger.kernel.org
46 +F: include/linux/bcma/
48 SONY VAIO CONTROL DEVICE DRIVER
49 M: Mattia Dongili <malattia@linux.it>
50 L: platform-driver-x86@vger.kernel.org
53 @@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig"
55 source "drivers/ssb/Kconfig"
57 +source "drivers/bcma/Kconfig"
59 source "drivers/mfd/Kconfig"
61 source "drivers/regulator/Kconfig"
62 --- a/drivers/Makefile
63 +++ b/drivers/Makefile
64 @@ -110,6 +110,7 @@ obj-$(CONFIG_HID) += hid/
65 obj-$(CONFIG_PPC_PS3) += ps3/
66 obj-$(CONFIG_OF) += of/
67 obj-$(CONFIG_SSB) += ssb/
68 +obj-$(CONFIG_BCMA) += bcma/
69 obj-$(CONFIG_VHOST_NET) += vhost/
70 obj-$(CONFIG_VLYNQ) += vlynq/
71 obj-$(CONFIG_STAGING) += staging/
73 +++ b/drivers/bcma/Kconfig
77 + depends on HAS_IOMEM && HAS_DMA
80 +menu "Broadcom specific AMBA"
81 + depends on BCMA_POSSIBLE
84 + tristate "BCMA support"
85 + depends on BCMA_POSSIBLE
87 + Bus driver for Broadcom specific Advanced Microcontroller Bus
90 +# Support for Block-I/O. SELECT this from the driver that needs it.
95 +config BCMA_HOST_PCI_POSSIBLE
97 + depends on BCMA && PCI = y
100 +config BCMA_HOST_PCI
101 + bool "Support for BCMA on PCI-host bus"
102 + depends on BCMA_HOST_PCI_POSSIBLE
104 +config BCMA_DRIVER_PCI_HOSTMODE
105 + bool "Driver for PCI core working in hostmode"
106 + depends on BCMA && MIPS && BCMA_HOST_PCI
108 + PCI core hostmode operation (external PCI bus).
110 +config BCMA_HOST_SOC
112 + depends on BCMA_DRIVER_MIPS
114 +config BCMA_DRIVER_MIPS
115 + bool "BCMA Broadcom MIPS core driver"
116 + depends on BCMA && MIPS
118 + Driver for the Broadcom MIPS core attached to Broadcom specific
119 + Advanced Microcontroller Bus.
124 + bool "BCMA debugging"
127 + This turns on additional debugging messages.
133 +++ b/drivers/bcma/Makefile
135 +bcma-y += main.o scan.o core.o sprom.o
136 +bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
137 +bcma-y += driver_pci.o
138 +bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
139 +bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
140 +bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
141 +bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
142 +obj-$(CONFIG_BCMA) += bcma.o
144 +ccflags-$(CONFIG_BCMA_DEBUG) := -DDEBUG
146 +++ b/drivers/bcma/README
148 +Broadcom introduced new bus as replacement for older SSB. It is based on AMBA,
149 +however from programming point of view there is nothing AMBA specific we use.
151 +Standard AMBA drivers are platform specific, have hardcoded addresses and use
152 +AMBA standard fields like CID and PID.
154 +In case of Broadcom's cards every device consists of:
155 +1) Broadcom specific AMBA device. It is put on AMBA bus, but can not be treated
156 + as standard AMBA device. Reading it's CID or PID can cause machine lockup.
157 +2) AMBA standard devices called ports or wrappers. They have CIDs (AMBA_CID)
158 + and PIDs (0x103BB369), but we do not use that info for anything. One of that
159 + devices is used for managing Broadcom specific core.
161 +Addresses of AMBA devices are not hardcoded in driver and have to be read from
164 +In this situation we decided to introduce separated bus. It can contain up to
165 +16 devices identified by Broadcom specific fields: manufacturer, id, revision
168 +++ b/drivers/bcma/TODO
171 +- Defines for PCI core driver
172 +- Create kernel Documentation (use info from README)
174 +++ b/drivers/bcma/bcma_private.h
176 +#ifndef LINUX_BCMA_PRIVATE_H_
177 +#define LINUX_BCMA_PRIVATE_H_
180 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
183 +#include <linux/bcma/bcma.h>
184 +#include <linux/delay.h>
186 +#define BCMA_CORE_SIZE 0x1000
191 +int __devinit bcma_bus_register(struct bcma_bus *bus);
192 +void bcma_bus_unregister(struct bcma_bus *bus);
193 +int __init bcma_bus_early_register(struct bcma_bus *bus,
194 + struct bcma_device *core_cc,
195 + struct bcma_device *core_mips);
197 +int bcma_bus_suspend(struct bcma_bus *bus);
198 +int bcma_bus_resume(struct bcma_bus *bus);
202 +int bcma_bus_scan(struct bcma_bus *bus);
203 +int __init bcma_bus_scan_early(struct bcma_bus *bus,
204 + struct bcma_device_id *match,
205 + struct bcma_device *core);
206 +void bcma_init_bus(struct bcma_bus *bus);
209 +int bcma_sprom_get(struct bcma_bus *bus);
211 +/* driver_chipcommon.c */
212 +#ifdef CONFIG_BCMA_DRIVER_MIPS
213 +void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
214 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
216 +/* driver_chipcommon_pmu.c */
217 +u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
218 +u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
220 +#ifdef CONFIG_BCMA_HOST_PCI
222 +extern int __init bcma_host_pci_init(void);
223 +extern void __exit bcma_host_pci_exit(void);
224 +#endif /* CONFIG_BCMA_HOST_PCI */
227 +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
229 +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
230 +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
231 +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
232 +#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
236 +++ b/drivers/bcma/core.c
239 + * Broadcom specific AMBA
242 + * Licensed under the GNU/GPL. See COPYING for details.
245 +#include "bcma_private.h"
246 +#include <linux/bcma/bcma.h>
248 +bool bcma_core_is_enabled(struct bcma_device *core)
250 + if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC))
253 + if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
257 +EXPORT_SYMBOL_GPL(bcma_core_is_enabled);
259 +void bcma_core_disable(struct bcma_device *core, u32 flags)
261 + if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
264 + bcma_awrite32(core, BCMA_IOCTL, flags);
265 + bcma_aread32(core, BCMA_IOCTL);
268 + bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
271 +EXPORT_SYMBOL_GPL(bcma_core_disable);
273 +int bcma_core_enable(struct bcma_device *core, u32 flags)
275 + bcma_core_disable(core, flags);
277 + bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC | flags));
278 + bcma_aread32(core, BCMA_IOCTL);
280 + bcma_awrite32(core, BCMA_RESET_CTL, 0);
283 + bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
284 + bcma_aread32(core, BCMA_IOCTL);
289 +EXPORT_SYMBOL_GPL(bcma_core_enable);
291 +void bcma_core_set_clockmode(struct bcma_device *core,
292 + enum bcma_clkmode clkmode)
296 + WARN_ON(core->id.id != BCMA_CORE_CHIPCOMMON &&
297 + core->id.id != BCMA_CORE_PCIE &&
298 + core->id.id != BCMA_CORE_80211);
301 + case BCMA_CLKMODE_FAST:
302 + bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
304 + for (i = 0; i < 1500; i++) {
305 + if (bcma_read32(core, BCMA_CLKCTLST) &
306 + BCMA_CLKCTLST_HAVEHT) {
313 + pr_err("HT force timeout\n");
315 + case BCMA_CLKMODE_DYNAMIC:
316 + pr_warn("Dynamic clockmode not supported yet!\n");
320 +EXPORT_SYMBOL_GPL(bcma_core_set_clockmode);
322 +void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status, bool on)
326 + WARN_ON(req & ~BCMA_CLKCTLST_EXTRESREQ);
327 + WARN_ON(status & ~BCMA_CLKCTLST_EXTRESST);
330 + bcma_set32(core, BCMA_CLKCTLST, req);
331 + for (i = 0; i < 10000; i++) {
332 + if ((bcma_read32(core, BCMA_CLKCTLST) & status) ==
340 + pr_err("PLL enable timeout\n");
342 + pr_warn("Disabling PLL not supported yet!\n");
345 +EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
347 +u32 bcma_core_dma_translation(struct bcma_device *core)
349 + switch (core->bus->hosttype) {
350 + case BCMA_HOSTTYPE_SOC:
352 + case BCMA_HOSTTYPE_PCI:
353 + if (bcma_aread32(core, BCMA_IOST) & BCMA_IOST_DMA64)
354 + return BCMA_DMA_TRANSLATION_DMA64_CMT;
356 + return BCMA_DMA_TRANSLATION_DMA32_CMT;
358 + pr_err("DMA translation unknown for host %d\n",
359 + core->bus->hosttype);
361 + return BCMA_DMA_TRANSLATION_NONE;
363 +EXPORT_SYMBOL(bcma_core_dma_translation);
365 +++ b/drivers/bcma/driver_chipcommon.c
368 + * Broadcom specific AMBA
369 + * ChipCommon core driver
371 + * Copyright 2005, Broadcom Corporation
372 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
374 + * Licensed under the GNU/GPL. See COPYING for details.
377 +#include "bcma_private.h"
378 +#include <linux/bcma/bcma.h>
380 +static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
381 + u32 mask, u32 value)
384 + value |= bcma_cc_read32(cc, offset) & ~mask;
385 + bcma_cc_write32(cc, offset, value);
390 +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
393 + u32 leddc_off = 90;
395 + if (cc->setup_done)
398 + if (cc->core->id.rev >= 11)
399 + cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
400 + cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
401 + if (cc->core->id.rev >= 35)
402 + cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);
404 + if (cc->core->id.rev >= 20) {
405 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
406 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
409 + if (cc->capabilities & BCMA_CC_CAP_PMU)
411 + if (cc->capabilities & BCMA_CC_CAP_PCTL)
412 + pr_err("Power control not implemented!\n");
414 + if (cc->core->id.rev >= 16) {
415 + if (cc->core->bus->sprom.leddc_on_time &&
416 + cc->core->bus->sprom.leddc_off_time) {
417 + leddc_on = cc->core->bus->sprom.leddc_on_time;
418 + leddc_off = cc->core->bus->sprom.leddc_off_time;
420 + bcma_cc_write32(cc, BCMA_CC_GPIOTIMER,
421 + ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
422 + (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
425 + cc->setup_done = true;
428 +/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
429 +void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
432 + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
435 +void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
437 + bcma_cc_write32_masked(cc, BCMA_CC_IRQMASK, mask, value);
440 +u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask)
442 + return bcma_cc_read32(cc, BCMA_CC_IRQSTAT) & mask;
445 +u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask)
447 + return bcma_cc_read32(cc, BCMA_CC_GPIOIN) & mask;
450 +u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
452 + return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
455 +u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
457 + return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
460 +u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
462 + return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
464 +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
466 +u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
468 + return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
471 +u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
473 + return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
476 +#ifdef CONFIG_BCMA_DRIVER_MIPS
477 +void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
482 + unsigned int ccrev = cc->core->id.rev;
483 + struct bcma_serial_port *ports = cc->serial_ports;
485 + if (ccrev >= 11 && ccrev != 15) {
486 + /* Fixed ALP clock */
487 + baud_base = bcma_pmu_alp_clock(cc);
489 + /* Turn off UART clock before switching clocksource. */
490 + bcma_cc_write32(cc, BCMA_CC_CORECTL,
491 + bcma_cc_read32(cc, BCMA_CC_CORECTL)
492 + & ~BCMA_CC_CORECTL_UARTCLKEN);
494 + /* Set the override bit so we don't divide it */
495 + bcma_cc_write32(cc, BCMA_CC_CORECTL,
496 + bcma_cc_read32(cc, BCMA_CC_CORECTL)
497 + | BCMA_CC_CORECTL_UARTCLK0);
499 + /* Re-enable the UART clock. */
500 + bcma_cc_write32(cc, BCMA_CC_CORECTL,
501 + bcma_cc_read32(cc, BCMA_CC_CORECTL)
502 + | BCMA_CC_CORECTL_UARTCLKEN);
505 + pr_err("serial not supported on this device ccrev: 0x%x\n",
510 + irq = bcma_core_mips_irq(cc->core);
512 + /* Determine the registers of the UARTs */
513 + cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART);
514 + for (i = 0; i < cc->nr_serial_ports; i++) {
515 + ports[i].regs = cc->core->io_addr + BCMA_CC_UART0_DATA +
517 + ports[i].irq = irq;
518 + ports[i].baud_base = baud_base;
519 + ports[i].reg_shift = 0;
522 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
524 +++ b/drivers/bcma/driver_chipcommon_pmu.c
527 + * Broadcom specific AMBA
528 + * ChipCommon Power Management Unit driver
530 + * Copyright 2009, Michael Buesch <m@bues.ch>
531 + * Copyright 2007, Broadcom Corporation
533 + * Licensed under the GNU/GPL. See COPYING for details.
536 +#include "bcma_private.h"
537 +#include <linux/bcma/bcma.h>
539 +static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
541 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
542 + bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
543 + return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
546 +void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
548 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
549 + bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
550 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
552 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_write);
554 +void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
557 + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
558 + bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
559 + bcma_cc_maskset32(cc, BCMA_CC_PLLCTL_DATA, mask, set);
561 +EXPORT_SYMBOL_GPL(bcma_chipco_pll_maskset);
563 +void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
564 + u32 offset, u32 mask, u32 set)
566 + bcma_cc_write32(cc, BCMA_CC_CHIPCTL_ADDR, offset);
567 + bcma_cc_read32(cc, BCMA_CC_CHIPCTL_ADDR);
568 + bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL_DATA, mask, set);
570 +EXPORT_SYMBOL_GPL(bcma_chipco_chipctl_maskset);
572 +void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
575 + bcma_cc_write32(cc, BCMA_CC_REGCTL_ADDR, offset);
576 + bcma_cc_read32(cc, BCMA_CC_REGCTL_ADDR);
577 + bcma_cc_maskset32(cc, BCMA_CC_REGCTL_DATA, mask, set);
579 +EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
581 +static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
583 + struct bcma_bus *bus = cc->core->bus;
585 + switch (bus->chipinfo.id) {
592 + pr_err("PLL init unknown for device 0x%04X\n",
597 +static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
599 + struct bcma_bus *bus = cc->core->bus;
600 + u32 min_msk = 0, max_msk = 0;
602 + switch (bus->chipinfo.id) {
612 + pr_err("PMU resource config unknown for device 0x%04X\n",
616 + /* Set the resource masks. */
618 + bcma_cc_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
620 + bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
623 +void bcma_pmu_swreg_init(struct bcma_drv_cc *cc)
625 + struct bcma_bus *bus = cc->core->bus;
627 + switch (bus->chipinfo.id) {
634 + pr_err("PMU switch/regulators init unknown for device "
635 + "0x%04X\n", bus->chipinfo.id);
639 +/* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
640 +void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable)
642 + struct bcma_bus *bus = cc->core->bus;
645 + val = bcma_cc_read32(cc, BCMA_CC_CHIPCTL);
647 + val |= BCMA_CHIPCTL_4331_EXTPA_EN;
648 + if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11)
649 + val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
651 + val &= ~BCMA_CHIPCTL_4331_EXTPA_EN;
652 + val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
654 + bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
657 +void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
659 + struct bcma_bus *bus = cc->core->bus;
661 + switch (bus->chipinfo.id) {
663 + bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7);
666 + /* BCM4331 workaround is SPROM-related, we put it in sprom.c */
669 + if (bus->chipinfo.rev == 0) {
670 + pr_err("Workarounds for 43224 rev 0 not fully "
672 + bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x00F000F0);
674 + bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
680 + pr_err("Workarounds unknown for device 0x%04X\n",
685 +void bcma_pmu_init(struct bcma_drv_cc *cc)
689 + pmucap = bcma_cc_read32(cc, BCMA_CC_PMU_CAP);
690 + cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION);
692 + pr_debug("Found rev %u PMU (capabilities 0x%08X)\n", cc->pmu.rev,
695 + if (cc->pmu.rev == 1)
696 + bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
697 + ~BCMA_CC_PMU_CTL_NOILPONW);
699 + bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
700 + BCMA_CC_PMU_CTL_NOILPONW);
702 + if (cc->core->id.id == 0x4329 && cc->core->id.rev == 2)
703 + pr_err("Fix for 4329b0 bad LPOM state not implemented!\n");
705 + bcma_pmu_pll_init(cc);
706 + bcma_pmu_resources_init(cc);
707 + bcma_pmu_swreg_init(cc);
708 + bcma_pmu_workarounds(cc);
711 +u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
713 + struct bcma_bus *bus = cc->core->bus;
715 + switch (bus->chipinfo.id) {
724 + return 20000 * 1000;
728 + return 25000 * 1000;
730 + pr_warn("No ALP clock specified for %04X device, "
731 + "pmu rev. %d, using default %d Hz\n",
732 + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
734 + return BCMA_CC_PMU_ALP_CLOCK;
737 +/* Find the output of the "m" pll divider given pll controls that start with
738 + * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
740 +static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
742 + u32 tmp, div, ndiv, p1, p2, fc;
743 + struct bcma_bus *bus = cc->core->bus;
745 + BUG_ON((pll0 & 3) || (pll0 > BCMA_CC_PMU4716_MAINPLL_PLL0));
747 + BUG_ON(!m || m > 4);
749 + if (bus->chipinfo.id == 0x5357 || bus->chipinfo.id == 0x4749) {
750 + /* Detect failure in clock setting */
751 + tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
753 + return 133 * 1000000;
756 + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_P1P2_OFF);
757 + p1 = (tmp & BCMA_CC_PPL_P1_MASK) >> BCMA_CC_PPL_P1_SHIFT;
758 + p2 = (tmp & BCMA_CC_PPL_P2_MASK) >> BCMA_CC_PPL_P2_SHIFT;
760 + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_M14_OFF);
761 + div = (tmp >> ((m - 1) * BCMA_CC_PPL_MDIV_WIDTH)) &
762 + BCMA_CC_PPL_MDIV_MASK;
764 + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_NM5_OFF);
765 + ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
767 + /* Do calculation in Mhz */
768 + fc = bcma_pmu_alp_clock(cc) / 1000000;
769 + fc = (p1 * ndiv * fc) / p2;
771 + /* Return clock in Hertz */
772 + return (fc / div) * 1000000;
775 +/* query bus clock frequency for PMU-enabled chipcommon */
776 +u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
778 + struct bcma_bus *bus = cc->core->bus;
780 + switch (bus->chipinfo.id) {
784 + return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
785 + BCMA_CC_PMU5_MAINPLL_SSB);
787 + return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
788 + BCMA_CC_PMU5_MAINPLL_SSB);
791 + return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
792 + BCMA_CC_PMU5_MAINPLL_SSB);
794 + return bcma_pmu_clock(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
795 + BCMA_CC_PMU5_MAINPLL_SSB);
799 + pr_warn("No backplane clock specified for %04X device, "
800 + "pmu rev. %d, using default %d Hz\n",
801 + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
803 + return BCMA_CC_PMU_HT_CLOCK;
806 +/* query cpu clock frequency for PMU-enabled chipcommon */
807 +u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
809 + struct bcma_bus *bus = cc->core->bus;
811 + if (bus->chipinfo.id == 53572)
814 + if (cc->pmu.rev >= 5) {
816 + switch (bus->chipinfo.id) {
818 + pll = BCMA_CC_PMU5356_MAINPLL_PLL0;
822 + pll = BCMA_CC_PMU5357_MAINPLL_PLL0;
825 + pll = BCMA_CC_PMU4716_MAINPLL_PLL0;
829 + /* TODO: if (bus->chipinfo.id == 0x5300)
830 + return si_4706_pmu_clock(sih, osh, cc, PMU4706_MAINPLL_PLL0, PMU5_MAINPLL_CPU); */
831 + return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
834 + return bcma_pmu_get_clockcontrol(cc);
837 +++ b/drivers/bcma/driver_pci.c
840 + * Broadcom specific AMBA
843 + * Copyright 2005, 2011, Broadcom Corporation
844 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
845 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
847 + * Licensed under the GNU/GPL. See COPYING for details.
850 +#include "bcma_private.h"
851 +#include <linux/bcma/bcma.h>
853 +/**************************************************
855 + **************************************************/
857 +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
859 + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
860 + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
861 + return pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_DATA);
865 +static void bcma_pcie_write(struct bcma_drv_pci *pc, u32 address, u32 data)
867 + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
868 + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
869 + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
873 +static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
878 + v = BCMA_CORE_PCI_MDIODATA_START;
879 + v |= BCMA_CORE_PCI_MDIODATA_WRITE;
880 + v |= (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
881 + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
882 + v |= (BCMA_CORE_PCI_MDIODATA_BLK_ADDR <<
883 + BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
884 + v |= BCMA_CORE_PCI_MDIODATA_TA;
886 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
889 + for (i = 0; i < 200; i++) {
890 + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
891 + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
897 +static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
899 + int max_retries = 10;
904 + /* enable mdio access to SERDES */
905 + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
906 + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
907 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
909 + if (pc->core->id.rev >= 10) {
911 + bcma_pcie_mdio_set_phy(pc, device);
912 + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
913 + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
914 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
916 + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
917 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
920 + v = BCMA_CORE_PCI_MDIODATA_START;
921 + v |= BCMA_CORE_PCI_MDIODATA_READ;
922 + v |= BCMA_CORE_PCI_MDIODATA_TA;
924 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
925 + /* Wait for the device to complete the transaction */
927 + for (i = 0; i < max_retries; i++) {
928 + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
929 + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE) {
931 + ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
936 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
940 +static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
941 + u8 address, u16 data)
943 + int max_retries = 10;
947 + /* enable mdio access to SERDES */
948 + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
949 + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
950 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
952 + if (pc->core->id.rev >= 10) {
954 + bcma_pcie_mdio_set_phy(pc, device);
955 + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
956 + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
957 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
959 + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
960 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
963 + v = BCMA_CORE_PCI_MDIODATA_START;
964 + v |= BCMA_CORE_PCI_MDIODATA_WRITE;
965 + v |= BCMA_CORE_PCI_MDIODATA_TA;
967 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
968 + /* Wait for the device to complete the transaction */
970 + for (i = 0; i < max_retries; i++) {
971 + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
972 + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
976 + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
979 +/**************************************************
981 + **************************************************/
983 +static u8 bcma_pcicore_polarity_workaround(struct bcma_drv_pci *pc)
987 + tmp = bcma_pcie_read(pc, BCMA_CORE_PCI_PLP_STATUSREG);
988 + if (tmp & BCMA_CORE_PCI_PLP_POLARITYINV_STAT)
989 + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE |
990 + BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY;
992 + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE;
995 +static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
999 + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_RX,
1000 + BCMA_CORE_PCI_SERDES_RX_CTRL,
1001 + bcma_pcicore_polarity_workaround(pc));
1002 + tmp = bcma_pcie_mdio_read(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
1003 + BCMA_CORE_PCI_SERDES_PLL_CTRL);
1004 + if (tmp & BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN)
1005 + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
1006 + BCMA_CORE_PCI_SERDES_PLL_CTRL,
1007 + tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
1010 +/**************************************************
1012 + **************************************************/
1014 +static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
1016 + bcma_pcicore_serdes_workaround(pc);
1019 +void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
1021 + if (pc->setup_done)
1024 +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
1025 + pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
1027 + bcma_core_pci_hostmode_init(pc);
1028 +#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
1030 + if (!pc->hostmode)
1031 + bcma_core_pci_clientmode_init(pc);
1034 +int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
1037 + struct pci_dev *pdev = pc->core->bus->host_pci;
1038 + u32 coremask, tmp;
1041 + if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
1042 + /* This bcma device is not on a PCI host-bus. So the IRQs are
1043 + * not routed through the PCI core.
1044 + * So we must not enable routing through the PCI core. */
1048 + err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
1052 + coremask = BIT(core->core_index) << 8;
1058 + err = pci_write_config_dword(pdev, BCMA_PCI_IRQMASK, tmp);
1063 +EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
1065 +++ b/drivers/bcma/host_pci.c
1068 + * Broadcom specific AMBA
1071 + * Licensed under the GNU/GPL. See COPYING for details.
1074 +#include "bcma_private.h"
1075 +#include <linux/slab.h>
1076 +#include <linux/bcma/bcma.h>
1077 +#include <linux/pci.h>
1078 +#include <linux/module.h>
1080 +static void bcma_host_pci_switch_core(struct bcma_device *core)
1082 + pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN,
1084 + pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN2,
1086 + core->bus->mapped_core = core;
1087 + pr_debug("Switched to core: 0x%X\n", core->id.id);
1090 +/* Provides access to the requested core. Returns base offset that has to be
1091 + * used. It makes use of fixed windows when possible. */
1092 +static u16 bcma_host_pci_provide_access_to_core(struct bcma_device *core)
1094 + switch (core->id.id) {
1095 + case BCMA_CORE_CHIPCOMMON:
1096 + return 3 * BCMA_CORE_SIZE;
1097 + case BCMA_CORE_PCIE:
1098 + return 2 * BCMA_CORE_SIZE;
1101 + if (core->bus->mapped_core != core)
1102 + bcma_host_pci_switch_core(core);
1106 +static u8 bcma_host_pci_read8(struct bcma_device *core, u16 offset)
1108 + offset += bcma_host_pci_provide_access_to_core(core);
1109 + return ioread8(core->bus->mmio + offset);
1112 +static u16 bcma_host_pci_read16(struct bcma_device *core, u16 offset)
1114 + offset += bcma_host_pci_provide_access_to_core(core);
1115 + return ioread16(core->bus->mmio + offset);
1118 +static u32 bcma_host_pci_read32(struct bcma_device *core, u16 offset)
1120 + offset += bcma_host_pci_provide_access_to_core(core);
1121 + return ioread32(core->bus->mmio + offset);
1124 +static void bcma_host_pci_write8(struct bcma_device *core, u16 offset,
1127 + offset += bcma_host_pci_provide_access_to_core(core);
1128 + iowrite8(value, core->bus->mmio + offset);
1131 +static void bcma_host_pci_write16(struct bcma_device *core, u16 offset,
1134 + offset += bcma_host_pci_provide_access_to_core(core);
1135 + iowrite16(value, core->bus->mmio + offset);
1138 +static void bcma_host_pci_write32(struct bcma_device *core, u16 offset,
1141 + offset += bcma_host_pci_provide_access_to_core(core);
1142 + iowrite32(value, core->bus->mmio + offset);
1145 +#ifdef CONFIG_BCMA_BLOCKIO
1146 +void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
1147 + size_t count, u16 offset, u8 reg_width)
1149 + void __iomem *addr = core->bus->mmio + offset;
1150 + if (core->bus->mapped_core != core)
1151 + bcma_host_pci_switch_core(core);
1152 + switch (reg_width) {
1154 + ioread8_rep(addr, buffer, count);
1157 + WARN_ON(count & 1);
1158 + ioread16_rep(addr, buffer, count >> 1);
1161 + WARN_ON(count & 3);
1162 + ioread32_rep(addr, buffer, count >> 2);
1169 +void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
1170 + size_t count, u16 offset, u8 reg_width)
1172 + void __iomem *addr = core->bus->mmio + offset;
1173 + if (core->bus->mapped_core != core)
1174 + bcma_host_pci_switch_core(core);
1175 + switch (reg_width) {
1177 + iowrite8_rep(addr, buffer, count);
1180 + WARN_ON(count & 1);
1181 + iowrite16_rep(addr, buffer, count >> 1);
1184 + WARN_ON(count & 3);
1185 + iowrite32_rep(addr, buffer, count >> 2);
1193 +static u32 bcma_host_pci_aread32(struct bcma_device *core, u16 offset)
1195 + if (core->bus->mapped_core != core)
1196 + bcma_host_pci_switch_core(core);
1197 + return ioread32(core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
1200 +static void bcma_host_pci_awrite32(struct bcma_device *core, u16 offset,
1203 + if (core->bus->mapped_core != core)
1204 + bcma_host_pci_switch_core(core);
1205 + iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
1208 +const struct bcma_host_ops bcma_host_pci_ops = {
1209 + .read8 = bcma_host_pci_read8,
1210 + .read16 = bcma_host_pci_read16,
1211 + .read32 = bcma_host_pci_read32,
1212 + .write8 = bcma_host_pci_write8,
1213 + .write16 = bcma_host_pci_write16,
1214 + .write32 = bcma_host_pci_write32,
1215 +#ifdef CONFIG_BCMA_BLOCKIO
1216 + .block_read = bcma_host_pci_block_read,
1217 + .block_write = bcma_host_pci_block_write,
1219 + .aread32 = bcma_host_pci_aread32,
1220 + .awrite32 = bcma_host_pci_awrite32,
1223 +static int __devinit bcma_host_pci_probe(struct pci_dev *dev,
1224 + const struct pci_device_id *id)
1226 + struct bcma_bus *bus;
1227 + int err = -ENOMEM;
1232 + bus = kzalloc(sizeof(*bus), GFP_KERNEL);
1236 + /* Basic PCI configuration */
1237 + err = pci_enable_device(dev);
1239 + goto err_kfree_bus;
1241 + name = dev_name(&dev->dev);
1242 + if (dev->driver && dev->driver->name)
1243 + name = dev->driver->name;
1244 + err = pci_request_regions(dev, name);
1246 + goto err_pci_disable;
1247 + pci_set_master(dev);
1249 + /* Disable the RETRY_TIMEOUT register (0x41) to keep
1250 + * PCI Tx retries from interfering with C3 CPU state */
1251 + pci_read_config_dword(dev, 0x40, &val);
1252 + if ((val & 0x0000ff00) != 0)
1253 + pci_write_config_dword(dev, 0x40, val & 0xffff00ff);
1255 + /* SSB needed additional powering up, do we have any AMBA PCI cards? */
1256 + if (!pci_is_pcie(dev))
1257 + pr_err("PCI card detected, report problems.\n");
1261 + bus->mmio = pci_iomap(dev, 0, ~0UL);
1263 + goto err_pci_release_regions;
1265 + /* Host specific */
1266 + bus->host_pci = dev;
1267 + bus->hosttype = BCMA_HOSTTYPE_PCI;
1268 + bus->ops = &bcma_host_pci_ops;
1271 + err = bcma_bus_register(bus);
1273 + goto err_pci_unmap_mmio;
1275 + pci_set_drvdata(dev, bus);
1280 +err_pci_unmap_mmio:
1281 + pci_iounmap(dev, bus->mmio);
1282 +err_pci_release_regions:
1283 + pci_release_regions(dev);
1285 + pci_disable_device(dev);
1291 +static void bcma_host_pci_remove(struct pci_dev *dev)
1293 + struct bcma_bus *bus = pci_get_drvdata(dev);
1295 + bcma_bus_unregister(bus);
1296 + pci_iounmap(dev, bus->mmio);
1297 + pci_release_regions(dev);
1298 + pci_disable_device(dev);
1300 + pci_set_drvdata(dev, NULL);
1304 +static int bcma_host_pci_suspend(struct device *dev)
1306 + struct pci_dev *pdev = to_pci_dev(dev);
1307 + struct bcma_bus *bus = pci_get_drvdata(pdev);
1309 + bus->mapped_core = NULL;
1311 + return bcma_bus_suspend(bus);
1314 +static int bcma_host_pci_resume(struct device *dev)
1316 + struct pci_dev *pdev = to_pci_dev(dev);
1317 + struct bcma_bus *bus = pci_get_drvdata(pdev);
1319 + return bcma_bus_resume(bus);
1322 +static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bcma_host_pci_suspend,
1323 + bcma_host_pci_resume);
1324 +#define BCMA_PM_OPS (&bcma_pm_ops)
1326 +#else /* CONFIG_PM */
1328 +#define BCMA_PM_OPS NULL
1330 +#endif /* CONFIG_PM */
1332 +static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
1333 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
1334 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
1335 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
1336 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
1337 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
1340 +MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl);
1342 +static struct pci_driver bcma_pci_bridge_driver = {
1343 + .name = "bcma-pci-bridge",
1344 + .id_table = bcma_pci_bridge_tbl,
1345 + .probe = bcma_host_pci_probe,
1346 + .remove = bcma_host_pci_remove,
1347 + .driver.pm = BCMA_PM_OPS,
1350 +int __init bcma_host_pci_init(void)
1352 + return pci_register_driver(&bcma_pci_bridge_driver);
1355 +void __exit bcma_host_pci_exit(void)
1357 + pci_unregister_driver(&bcma_pci_bridge_driver);
1360 +++ b/drivers/bcma/main.c
1363 + * Broadcom specific AMBA
1366 + * Licensed under the GNU/GPL. See COPYING for details.
1369 +#include "bcma_private.h"
1370 +#include <linux/module.h>
1371 +#include <linux/bcma/bcma.h>
1372 +#include <linux/slab.h>
1374 +MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
1375 +MODULE_LICENSE("GPL");
1377 +/* contains the number the next bus should get. */
1378 +static unsigned int bcma_bus_next_num = 0;
1380 +/* bcma_buses_mutex locks the bcma_bus_next_num */
1381 +static DEFINE_MUTEX(bcma_buses_mutex);
1383 +static int bcma_bus_match(struct device *dev, struct device_driver *drv);
1384 +static int bcma_device_probe(struct device *dev);
1385 +static int bcma_device_remove(struct device *dev);
1386 +static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env);
1388 +static ssize_t manuf_show(struct device *dev, struct device_attribute *attr, char *buf)
1390 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1391 + return sprintf(buf, "0x%03X\n", core->id.manuf);
1393 +static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf)
1395 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1396 + return sprintf(buf, "0x%03X\n", core->id.id);
1398 +static ssize_t rev_show(struct device *dev, struct device_attribute *attr, char *buf)
1400 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1401 + return sprintf(buf, "0x%02X\n", core->id.rev);
1403 +static ssize_t class_show(struct device *dev, struct device_attribute *attr, char *buf)
1405 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1406 + return sprintf(buf, "0x%X\n", core->id.class);
1408 +static struct device_attribute bcma_device_attrs[] = {
1416 +static struct bus_type bcma_bus_type = {
1418 + .match = bcma_bus_match,
1419 + .probe = bcma_device_probe,
1420 + .remove = bcma_device_remove,
1421 + .uevent = bcma_device_uevent,
1422 + .dev_attrs = bcma_device_attrs,
1425 +struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
1427 + struct bcma_device *core;
1429 + list_for_each_entry(core, &bus->cores, list) {
1430 + if (core->id.id == coreid)
1435 +EXPORT_SYMBOL_GPL(bcma_find_core);
1437 +static void bcma_release_core_dev(struct device *dev)
1439 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1440 + if (core->io_addr)
1441 + iounmap(core->io_addr);
1442 + if (core->io_wrap)
1443 + iounmap(core->io_wrap);
1447 +static int bcma_register_cores(struct bcma_bus *bus)
1449 + struct bcma_device *core;
1450 + int err, dev_id = 0;
1452 + list_for_each_entry(core, &bus->cores, list) {
1453 + /* We support that cores ourself */
1454 + switch (core->id.id) {
1455 + case BCMA_CORE_CHIPCOMMON:
1456 + case BCMA_CORE_PCI:
1457 + case BCMA_CORE_PCIE:
1458 + case BCMA_CORE_MIPS_74K:
1462 + core->dev.release = bcma_release_core_dev;
1463 + core->dev.bus = &bcma_bus_type;
1464 + dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
1466 + switch (bus->hosttype) {
1467 + case BCMA_HOSTTYPE_PCI:
1468 + core->dev.parent = &bus->host_pci->dev;
1469 + core->dma_dev = &bus->host_pci->dev;
1470 + core->irq = bus->host_pci->irq;
1472 + case BCMA_HOSTTYPE_SOC:
1473 + core->dev.dma_mask = &core->dev.coherent_dma_mask;
1474 + core->dma_dev = &core->dev;
1476 + case BCMA_HOSTTYPE_SDIO:
1480 + err = device_register(&core->dev);
1482 + pr_err("Could not register dev for core 0x%03X\n",
1486 + core->dev_registered = true;
1493 +static void bcma_unregister_cores(struct bcma_bus *bus)
1495 + struct bcma_device *core;
1497 + list_for_each_entry(core, &bus->cores, list) {
1498 + if (core->dev_registered)
1499 + device_unregister(&core->dev);
1503 +int __devinit bcma_bus_register(struct bcma_bus *bus)
1506 + struct bcma_device *core;
1508 + mutex_lock(&bcma_buses_mutex);
1509 + bus->num = bcma_bus_next_num++;
1510 + mutex_unlock(&bcma_buses_mutex);
1512 + /* Scan for devices (cores) */
1513 + err = bcma_bus_scan(bus);
1515 + pr_err("Failed to scan: %d\n", err);
1519 + /* Init CC core */
1520 + core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
1522 + bus->drv_cc.core = core;
1523 + bcma_core_chipcommon_init(&bus->drv_cc);
1526 + /* Init MIPS core */
1527 + core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1529 + bus->drv_mips.core = core;
1530 + bcma_core_mips_init(&bus->drv_mips);
1533 + /* Init PCIE core */
1534 + core = bcma_find_core(bus, BCMA_CORE_PCIE);
1536 + bus->drv_pci.core = core;
1537 + bcma_core_pci_init(&bus->drv_pci);
1540 + /* Try to get SPROM */
1541 + err = bcma_sprom_get(bus);
1542 + if (err == -ENOENT) {
1543 + pr_err("No SPROM available\n");
1545 + pr_err("Failed to get SPROM: %d\n", err);
1547 + /* Register found cores */
1548 + bcma_register_cores(bus);
1550 + pr_info("Bus registered\n");
1555 +void bcma_bus_unregister(struct bcma_bus *bus)
1557 + bcma_unregister_cores(bus);
1560 +int __init bcma_bus_early_register(struct bcma_bus *bus,
1561 + struct bcma_device *core_cc,
1562 + struct bcma_device *core_mips)
1565 + struct bcma_device *core;
1566 + struct bcma_device_id match;
1568 + bcma_init_bus(bus);
1570 + match.manuf = BCMA_MANUF_BCM;
1571 + match.id = BCMA_CORE_CHIPCOMMON;
1572 + match.class = BCMA_CL_SIM;
1573 + match.rev = BCMA_ANY_REV;
1575 + /* Scan for chip common core */
1576 + err = bcma_bus_scan_early(bus, &match, core_cc);
1578 + pr_err("Failed to scan for common core: %d\n", err);
1582 + match.manuf = BCMA_MANUF_MIPS;
1583 + match.id = BCMA_CORE_MIPS_74K;
1584 + match.class = BCMA_CL_SIM;
1585 + match.rev = BCMA_ANY_REV;
1587 + /* Scan for mips core */
1588 + err = bcma_bus_scan_early(bus, &match, core_mips);
1590 + pr_err("Failed to scan for mips core: %d\n", err);
1594 + /* Init CC core */
1595 + core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
1597 + bus->drv_cc.core = core;
1598 + bcma_core_chipcommon_init(&bus->drv_cc);
1601 + /* Init MIPS core */
1602 + core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
1604 + bus->drv_mips.core = core;
1605 + bcma_core_mips_init(&bus->drv_mips);
1608 + pr_info("Early bus registered\n");
1614 +int bcma_bus_suspend(struct bcma_bus *bus)
1616 + struct bcma_device *core;
1618 + list_for_each_entry(core, &bus->cores, list) {
1619 + struct device_driver *drv = core->dev.driver;
1621 + struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
1622 + if (adrv->suspend)
1623 + adrv->suspend(core);
1629 +int bcma_bus_resume(struct bcma_bus *bus)
1631 + struct bcma_device *core;
1633 + /* Init CC core */
1634 + core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
1636 + bus->drv_cc.setup_done = false;
1637 + bcma_core_chipcommon_init(&bus->drv_cc);
1640 + list_for_each_entry(core, &bus->cores, list) {
1641 + struct device_driver *drv = core->dev.driver;
1643 + struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
1645 + adrv->resume(core);
1653 +int __bcma_driver_register(struct bcma_driver *drv, struct module *owner)
1655 + drv->drv.name = drv->name;
1656 + drv->drv.bus = &bcma_bus_type;
1657 + drv->drv.owner = owner;
1659 + return driver_register(&drv->drv);
1661 +EXPORT_SYMBOL_GPL(__bcma_driver_register);
1663 +void bcma_driver_unregister(struct bcma_driver *drv)
1665 + driver_unregister(&drv->drv);
1667 +EXPORT_SYMBOL_GPL(bcma_driver_unregister);
1669 +static int bcma_bus_match(struct device *dev, struct device_driver *drv)
1671 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1672 + struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
1673 + const struct bcma_device_id *cid = &core->id;
1674 + const struct bcma_device_id *did;
1676 + for (did = adrv->id_table; did->manuf || did->id || did->rev; did++) {
1677 + if ((did->manuf == cid->manuf || did->manuf == BCMA_ANY_MANUF) &&
1678 + (did->id == cid->id || did->id == BCMA_ANY_ID) &&
1679 + (did->rev == cid->rev || did->rev == BCMA_ANY_REV) &&
1680 + (did->class == cid->class || did->class == BCMA_ANY_CLASS))
1686 +static int bcma_device_probe(struct device *dev)
1688 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1689 + struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver,
1694 + err = adrv->probe(core);
1699 +static int bcma_device_remove(struct device *dev)
1701 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1702 + struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver,
1706 + adrv->remove(core);
1711 +static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env)
1713 + struct bcma_device *core = container_of(dev, struct bcma_device, dev);
1715 + return add_uevent_var(env,
1716 + "MODALIAS=bcma:m%04Xid%04Xrev%02Xcl%02X",
1717 + core->id.manuf, core->id.id,
1718 + core->id.rev, core->id.class);
1721 +static int __init bcma_modinit(void)
1725 + err = bus_register(&bcma_bus_type);
1729 +#ifdef CONFIG_BCMA_HOST_PCI
1730 + err = bcma_host_pci_init();
1732 + pr_err("PCI host initialization failed\n");
1739 +fs_initcall(bcma_modinit);
1741 +static void __exit bcma_modexit(void)
1743 +#ifdef CONFIG_BCMA_HOST_PCI
1744 + bcma_host_pci_exit();
1746 + bus_unregister(&bcma_bus_type);
1748 +module_exit(bcma_modexit)
1750 +++ b/drivers/bcma/scan.c
1753 + * Broadcom specific AMBA
1756 + * Licensed under the GNU/GPL. See COPYING for details.
1760 +#include "bcma_private.h"
1762 +#include <linux/bcma/bcma.h>
1763 +#include <linux/bcma/bcma_regs.h>
1764 +#include <linux/pci.h>
1765 +#include <linux/io.h>
1766 +#include <linux/dma-mapping.h>
1767 +#include <linux/slab.h>
1769 +struct bcma_device_id_name {
1773 +struct bcma_device_id_name bcma_device_names[] = {
1774 + { BCMA_CORE_OOB_ROUTER, "OOB Router" },
1775 + { BCMA_CORE_INVALID, "Invalid" },
1776 + { BCMA_CORE_CHIPCOMMON, "ChipCommon" },
1777 + { BCMA_CORE_ILINE20, "ILine 20" },
1778 + { BCMA_CORE_SRAM, "SRAM" },
1779 + { BCMA_CORE_SDRAM, "SDRAM" },
1780 + { BCMA_CORE_PCI, "PCI" },
1781 + { BCMA_CORE_MIPS, "MIPS" },
1782 + { BCMA_CORE_ETHERNET, "Fast Ethernet" },
1783 + { BCMA_CORE_V90, "V90" },
1784 + { BCMA_CORE_USB11_HOSTDEV, "USB 1.1 Hostdev" },
1785 + { BCMA_CORE_ADSL, "ADSL" },
1786 + { BCMA_CORE_ILINE100, "ILine 100" },
1787 + { BCMA_CORE_IPSEC, "IPSEC" },
1788 + { BCMA_CORE_UTOPIA, "UTOPIA" },
1789 + { BCMA_CORE_PCMCIA, "PCMCIA" },
1790 + { BCMA_CORE_INTERNAL_MEM, "Internal Memory" },
1791 + { BCMA_CORE_MEMC_SDRAM, "MEMC SDRAM" },
1792 + { BCMA_CORE_OFDM, "OFDM" },
1793 + { BCMA_CORE_EXTIF, "EXTIF" },
1794 + { BCMA_CORE_80211, "IEEE 802.11" },
1795 + { BCMA_CORE_PHY_A, "PHY A" },
1796 + { BCMA_CORE_PHY_B, "PHY B" },
1797 + { BCMA_CORE_PHY_G, "PHY G" },
1798 + { BCMA_CORE_MIPS_3302, "MIPS 3302" },
1799 + { BCMA_CORE_USB11_HOST, "USB 1.1 Host" },
1800 + { BCMA_CORE_USB11_DEV, "USB 1.1 Device" },
1801 + { BCMA_CORE_USB20_HOST, "USB 2.0 Host" },
1802 + { BCMA_CORE_USB20_DEV, "USB 2.0 Device" },
1803 + { BCMA_CORE_SDIO_HOST, "SDIO Host" },
1804 + { BCMA_CORE_ROBOSWITCH, "Roboswitch" },
1805 + { BCMA_CORE_PARA_ATA, "PATA" },
1806 + { BCMA_CORE_SATA_XORDMA, "SATA XOR-DMA" },
1807 + { BCMA_CORE_ETHERNET_GBIT, "GBit Ethernet" },
1808 + { BCMA_CORE_PCIE, "PCIe" },
1809 + { BCMA_CORE_PHY_N, "PHY N" },
1810 + { BCMA_CORE_SRAM_CTL, "SRAM Controller" },
1811 + { BCMA_CORE_MINI_MACPHY, "Mini MACPHY" },
1812 + { BCMA_CORE_ARM_1176, "ARM 1176" },
1813 + { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
1814 + { BCMA_CORE_PHY_LP, "PHY LP" },
1815 + { BCMA_CORE_PMU, "PMU" },
1816 + { BCMA_CORE_PHY_SSN, "PHY SSN" },
1817 + { BCMA_CORE_SDIO_DEV, "SDIO Device" },
1818 + { BCMA_CORE_ARM_CM3, "ARM CM3" },
1819 + { BCMA_CORE_PHY_HT, "PHY HT" },
1820 + { BCMA_CORE_MIPS_74K, "MIPS 74K" },
1821 + { BCMA_CORE_MAC_GBIT, "GBit MAC" },
1822 + { BCMA_CORE_DDR12_MEM_CTL, "DDR1/DDR2 Memory Controller" },
1823 + { BCMA_CORE_PCIE_RC, "PCIe Root Complex" },
1824 + { BCMA_CORE_OCP_OCP_BRIDGE, "OCP to OCP Bridge" },
1825 + { BCMA_CORE_SHARED_COMMON, "Common Shared" },
1826 + { BCMA_CORE_OCP_AHB_BRIDGE, "OCP to AHB Bridge" },
1827 + { BCMA_CORE_SPI_HOST, "SPI Host" },
1828 + { BCMA_CORE_I2S, "I2S" },
1829 + { BCMA_CORE_SDR_DDR1_MEM_CTL, "SDR/DDR1 Memory Controller" },
1830 + { BCMA_CORE_SHIM, "SHIM" },
1831 + { BCMA_CORE_DEFAULT, "Default" },
1833 +const char *bcma_device_name(struct bcma_device_id *id)
1837 + if (id->manuf == BCMA_MANUF_BCM) {
1838 + for (i = 0; i < ARRAY_SIZE(bcma_device_names); i++) {
1839 + if (bcma_device_names[i].id == id->id)
1840 + return bcma_device_names[i].name;
1846 +static u32 bcma_scan_read32(struct bcma_bus *bus, u8 current_coreidx,
1849 + return readl(bus->mmio + offset);
1852 +static void bcma_scan_switch_core(struct bcma_bus *bus, u32 addr)
1854 + if (bus->hosttype == BCMA_HOSTTYPE_PCI)
1855 + pci_write_config_dword(bus->host_pci, BCMA_PCI_BAR0_WIN,
1859 +static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 **eromptr)
1861 + u32 ent = readl(*eromptr);
1866 +static void bcma_erom_push_ent(u32 **eromptr)
1871 +static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 **eromptr)
1873 + u32 ent = bcma_erom_get_ent(bus, eromptr);
1874 + if (!(ent & SCAN_ER_VALID))
1876 + if ((ent & SCAN_ER_TAG) != SCAN_ER_TAG_CI)
1881 +static bool bcma_erom_is_end(struct bcma_bus *bus, u32 **eromptr)
1883 + u32 ent = bcma_erom_get_ent(bus, eromptr);
1884 + bcma_erom_push_ent(eromptr);
1885 + return (ent == (SCAN_ER_TAG_END | SCAN_ER_VALID));
1888 +static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 **eromptr)
1890 + u32 ent = bcma_erom_get_ent(bus, eromptr);
1891 + bcma_erom_push_ent(eromptr);
1892 + return (((ent & SCAN_ER_VALID)) &&
1893 + ((ent & SCAN_ER_TAGX) == SCAN_ER_TAG_ADDR) &&
1894 + ((ent & SCAN_ADDR_TYPE) == SCAN_ADDR_TYPE_BRIDGE));
1897 +static void bcma_erom_skip_component(struct bcma_bus *bus, u32 **eromptr)
1901 + ent = bcma_erom_get_ent(bus, eromptr);
1902 + if ((ent & SCAN_ER_VALID) &&
1903 + ((ent & SCAN_ER_TAG) == SCAN_ER_TAG_CI))
1905 + if (ent == (SCAN_ER_TAG_END | SCAN_ER_VALID))
1908 + bcma_erom_push_ent(eromptr);
1911 +static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr)
1913 + u32 ent = bcma_erom_get_ent(bus, eromptr);
1914 + if (!(ent & SCAN_ER_VALID))
1916 + if ((ent & SCAN_ER_TAG) != SCAN_ER_TAG_MP)
1921 +static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 **eromptr,
1922 + u32 type, u8 port)
1924 + u32 addrl, addrh, sizel, sizeh = 0;
1927 + u32 ent = bcma_erom_get_ent(bus, eromptr);
1928 + if ((!(ent & SCAN_ER_VALID)) ||
1929 + ((ent & SCAN_ER_TAGX) != SCAN_ER_TAG_ADDR) ||
1930 + ((ent & SCAN_ADDR_TYPE) != type) ||
1931 + (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
1932 + bcma_erom_push_ent(eromptr);
1936 + addrl = ent & SCAN_ADDR_ADDR;
1937 + if (ent & SCAN_ADDR_AG32)
1938 + addrh = bcma_erom_get_ent(bus, eromptr);
1942 + if ((ent & SCAN_ADDR_SZ) == SCAN_ADDR_SZ_SZD) {
1943 + size = bcma_erom_get_ent(bus, eromptr);
1944 + sizel = size & SCAN_SIZE_SZ;
1945 + if (size & SCAN_SIZE_SG32)
1946 + sizeh = bcma_erom_get_ent(bus, eromptr);
1948 + sizel = SCAN_ADDR_SZ_BASE <<
1949 + ((ent & SCAN_ADDR_SZ) >> SCAN_ADDR_SZ_SHIFT);
1954 +static struct bcma_device *bcma_find_core_by_index(struct bcma_bus *bus,
1957 + struct bcma_device *core;
1959 + list_for_each_entry(core, &bus->cores, list) {
1960 + if (core->core_index == index)
1966 +static struct bcma_device *bcma_find_core_reverse(struct bcma_bus *bus, u16 coreid)
1968 + struct bcma_device *core;
1970 + list_for_each_entry_reverse(core, &bus->cores, list) {
1971 + if (core->id.id == coreid)
1977 +static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
1978 + struct bcma_device_id *match, int core_num,
1979 + struct bcma_device *core)
1984 + u8 ports[2], wrappers[2];
1987 + cia = bcma_erom_get_ci(bus, eromptr);
1989 + bcma_erom_push_ent(eromptr);
1990 + if (bcma_erom_is_end(bus, eromptr))
1994 + cib = bcma_erom_get_ci(bus, eromptr);
1999 + core->id.class = (cia & SCAN_CIA_CLASS) >> SCAN_CIA_CLASS_SHIFT;
2000 + core->id.id = (cia & SCAN_CIA_ID) >> SCAN_CIA_ID_SHIFT;
2001 + core->id.manuf = (cia & SCAN_CIA_MANUF) >> SCAN_CIA_MANUF_SHIFT;
2002 + ports[0] = (cib & SCAN_CIB_NMP) >> SCAN_CIB_NMP_SHIFT;
2003 + ports[1] = (cib & SCAN_CIB_NSP) >> SCAN_CIB_NSP_SHIFT;
2004 + wrappers[0] = (cib & SCAN_CIB_NMW) >> SCAN_CIB_NMW_SHIFT;
2005 + wrappers[1] = (cib & SCAN_CIB_NSW) >> SCAN_CIB_NSW_SHIFT;
2006 + core->id.rev = (cib & SCAN_CIB_REV) >> SCAN_CIB_REV_SHIFT;
2008 + if (((core->id.manuf == BCMA_MANUF_ARM) &&
2009 + (core->id.id == 0xFFF)) ||
2010 + (ports[1] == 0)) {
2011 + bcma_erom_skip_component(bus, eromptr);
2015 + /* check if component is a core at all */
2016 + if (wrappers[0] + wrappers[1] == 0) {
2017 + /* we could save addrl of the router
2018 + if (cid == BCMA_CORE_OOB_ROUTER)
2020 + bcma_erom_skip_component(bus, eromptr);
2024 + if (bcma_erom_is_bridge(bus, eromptr)) {
2025 + bcma_erom_skip_component(bus, eromptr);
2029 + if (bcma_find_core_by_index(bus, core_num)) {
2030 + bcma_erom_skip_component(bus, eromptr);
2034 + if (match && ((match->manuf != BCMA_ANY_MANUF &&
2035 + match->manuf != core->id.manuf) ||
2036 + (match->id != BCMA_ANY_ID && match->id != core->id.id) ||
2037 + (match->rev != BCMA_ANY_REV && match->rev != core->id.rev) ||
2038 + (match->class != BCMA_ANY_CLASS && match->class != core->id.class)
2040 + bcma_erom_skip_component(bus, eromptr);
2044 + /* get & parse master ports */
2045 + for (i = 0; i < ports[0]; i++) {
2046 + s32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
2047 + if (mst_port_d < 0)
2051 + /* get & parse slave ports */
2052 + for (i = 0; i < ports[1]; i++) {
2053 + for (j = 0; ; j++) {
2054 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
2055 + SCAN_ADDR_TYPE_SLAVE, i);
2057 + /* no more entries for port _i_ */
2058 + /* pr_debug("erom: slave port %d "
2059 + * "has %d descriptors\n", i, j); */
2062 + if (i == 0 && j == 0)
2068 + /* get & parse master wrappers */
2069 + for (i = 0; i < wrappers[0]; i++) {
2070 + for (j = 0; ; j++) {
2071 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
2072 + SCAN_ADDR_TYPE_MWRAP, i);
2074 + /* no more entries for port _i_ */
2075 + /* pr_debug("erom: master wrapper %d "
2076 + * "has %d descriptors\n", i, j); */
2079 + if (i == 0 && j == 0)
2085 + /* get & parse slave wrappers */
2086 + for (i = 0; i < wrappers[1]; i++) {
2087 + u8 hack = (ports[1] == 1) ? 0 : 1;
2088 + for (j = 0; ; j++) {
2089 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
2090 + SCAN_ADDR_TYPE_SWRAP, i + hack);
2092 + /* no more entries for port _i_ */
2093 + /* pr_debug("erom: master wrapper %d "
2094 + * has %d descriptors\n", i, j); */
2097 + if (wrappers[0] == 0 && !i && !j)
2102 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
2103 + core->io_addr = ioremap_nocache(core->addr, BCMA_CORE_SIZE);
2104 + if (!core->io_addr)
2106 + core->io_wrap = ioremap_nocache(core->wrap, BCMA_CORE_SIZE);
2107 + if (!core->io_wrap) {
2108 + iounmap(core->io_addr);
2115 +void bcma_init_bus(struct bcma_bus *bus)
2118 + struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
2120 + if (bus->init_done)
2123 + INIT_LIST_HEAD(&bus->cores);
2124 + bus->nr_cores = 0;
2126 + bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
2128 + tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
2129 + chipinfo->id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
2130 + chipinfo->rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
2131 + chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
2132 + pr_info("Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
2133 + chipinfo->id, chipinfo->rev, chipinfo->pkg);
2135 + bus->init_done = true;
2138 +int bcma_bus_scan(struct bcma_bus *bus)
2141 + u32 __iomem *eromptr, *eromend;
2143 + int err, core_num = 0;
2145 + bcma_init_bus(bus);
2147 + erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
2148 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
2149 + eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
2153 + eromptr = bus->mmio;
2156 + eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);
2158 + bcma_scan_switch_core(bus, erombase);
2160 + while (eromptr < eromend) {
2161 + struct bcma_device *other_core;
2162 + struct bcma_device *core = kzalloc(sizeof(*core), GFP_KERNEL);
2165 + INIT_LIST_HEAD(&core->list);
2168 + err = bcma_get_next_core(bus, &eromptr, NULL, core_num, core);
2171 + if (err == -ENODEV) {
2174 + } else if (err == -ENXIO) {
2176 + } else if (err == -ESPIPE) {
2182 + core->core_index = core_num++;
2184 + other_core = bcma_find_core_reverse(bus, core->id.id);
2185 + core->core_unit = (other_core == NULL) ? 0 : other_core->core_unit + 1;
2187 + pr_info("Core %d found: %s "
2188 + "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
2189 + core->core_index, bcma_device_name(&core->id),
2190 + core->id.manuf, core->id.id, core->id.rev,
2193 + list_add(&core->list, &bus->cores);
2196 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
2202 +int __init bcma_bus_scan_early(struct bcma_bus *bus,
2203 + struct bcma_device_id *match,
2204 + struct bcma_device *core)
2207 + u32 __iomem *eromptr, *eromend;
2209 + int err = -ENODEV;
2212 + erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
2213 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
2214 + eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
2218 + eromptr = bus->mmio;
2221 + eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);
2223 + bcma_scan_switch_core(bus, erombase);
2225 + while (eromptr < eromend) {
2226 + memset(core, 0, sizeof(*core));
2227 + INIT_LIST_HEAD(&core->list);
2230 + err = bcma_get_next_core(bus, &eromptr, match, core_num, core);
2231 + if (err == -ENODEV) {
2234 + } else if (err == -ENXIO)
2236 + else if (err == -ESPIPE)
2241 + core->core_index = core_num++;
2243 + pr_info("Core %d found: %s "
2244 + "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
2245 + core->core_index, bcma_device_name(&core->id),
2246 + core->id.manuf, core->id.id, core->id.rev,
2249 + list_add(&core->list, &bus->cores);
2254 + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
2260 +++ b/drivers/bcma/scan.h
2262 +#ifndef BCMA_SCAN_H_
2263 +#define BCMA_SCAN_H_
2265 +#define BCMA_ADDR_BASE 0x18000000
2266 +#define BCMA_WRAP_BASE 0x18100000
2268 +#define SCAN_ER_VALID 0x00000001
2269 +#define SCAN_ER_TAGX 0x00000006 /* we have to ignore 0x8 bit when checking tag for SCAN_ER_TAG_ADDR */
2270 +#define SCAN_ER_TAG 0x0000000E
2271 +#define SCAN_ER_TAG_CI 0x00000000
2272 +#define SCAN_ER_TAG_MP 0x00000002
2273 +#define SCAN_ER_TAG_ADDR 0x00000004
2274 +#define SCAN_ER_TAG_END 0x0000000E
2275 +#define SCAN_ER_BAD 0xFFFFFFFF
2277 +#define SCAN_CIA_CLASS 0x000000F0
2278 +#define SCAN_CIA_CLASS_SHIFT 4
2279 +#define SCAN_CIA_ID 0x000FFF00
2280 +#define SCAN_CIA_ID_SHIFT 8
2281 +#define SCAN_CIA_MANUF 0xFFF00000
2282 +#define SCAN_CIA_MANUF_SHIFT 20
2284 +#define SCAN_CIB_NMP 0x000001F0
2285 +#define SCAN_CIB_NMP_SHIFT 4
2286 +#define SCAN_CIB_NSP 0x00003E00
2287 +#define SCAN_CIB_NSP_SHIFT 9
2288 +#define SCAN_CIB_NMW 0x0007C000
2289 +#define SCAN_CIB_NMW_SHIFT 14
2290 +#define SCAN_CIB_NSW 0x00F80000
2291 +#define SCAN_CIB_NSW_SHIFT 17
2292 +#define SCAN_CIB_REV 0xFF000000
2293 +#define SCAN_CIB_REV_SHIFT 24
2295 +#define SCAN_ADDR_AG32 0x00000008
2296 +#define SCAN_ADDR_SZ 0x00000030
2297 +#define SCAN_ADDR_SZ_SHIFT 4
2298 +#define SCAN_ADDR_SZ_4K 0x00000000
2299 +#define SCAN_ADDR_SZ_8K 0x00000010
2300 +#define SCAN_ADDR_SZ_16K 0x00000020
2301 +#define SCAN_ADDR_SZ_SZD 0x00000030
2302 +#define SCAN_ADDR_TYPE 0x000000C0
2303 +#define SCAN_ADDR_TYPE_SLAVE 0x00000000
2304 +#define SCAN_ADDR_TYPE_BRIDGE 0x00000040
2305 +#define SCAN_ADDR_TYPE_SWRAP 0x00000080
2306 +#define SCAN_ADDR_TYPE_MWRAP 0x000000C0
2307 +#define SCAN_ADDR_PORT 0x00000F00
2308 +#define SCAN_ADDR_PORT_SHIFT 8
2309 +#define SCAN_ADDR_ADDR 0xFFFFF000
2311 +#define SCAN_ADDR_SZ_BASE 0x00001000 /* 4KB */
2313 +#define SCAN_SIZE_SZ_ALIGN 0x00000FFF
2314 +#define SCAN_SIZE_SZ 0xFFFFF000
2315 +#define SCAN_SIZE_SG32 0x00000008
2317 +#endif /* BCMA_SCAN_H_ */
2319 +++ b/include/linux/bcma/bcma.h
2321 +#ifndef LINUX_BCMA_H_
2322 +#define LINUX_BCMA_H_
2324 +#include <linux/pci.h>
2325 +#include <linux/mod_devicetable.h>
2327 +#include <linux/bcma/bcma_driver_chipcommon.h>
2328 +#include <linux/bcma/bcma_driver_pci.h>
2329 +#include <linux/bcma/bcma_driver_mips.h>
2330 +#include <linux/ssb/ssb.h> /* SPROM sharing */
2332 +#include "bcma_regs.h"
2334 +struct bcma_device;
2337 +enum bcma_hosttype {
2338 + BCMA_HOSTTYPE_PCI,
2339 + BCMA_HOSTTYPE_SDIO,
2340 + BCMA_HOSTTYPE_SOC,
2343 +struct bcma_chipinfo {
2349 +enum bcma_clkmode {
2350 + BCMA_CLKMODE_FAST,
2351 + BCMA_CLKMODE_DYNAMIC,
2354 +struct bcma_host_ops {
2355 + u8 (*read8)(struct bcma_device *core, u16 offset);
2356 + u16 (*read16)(struct bcma_device *core, u16 offset);
2357 + u32 (*read32)(struct bcma_device *core, u16 offset);
2358 + void (*write8)(struct bcma_device *core, u16 offset, u8 value);
2359 + void (*write16)(struct bcma_device *core, u16 offset, u16 value);
2360 + void (*write32)(struct bcma_device *core, u16 offset, u32 value);
2361 +#ifdef CONFIG_BCMA_BLOCKIO
2362 + void (*block_read)(struct bcma_device *core, void *buffer,
2363 + size_t count, u16 offset, u8 reg_width);
2364 + void (*block_write)(struct bcma_device *core, const void *buffer,
2365 + size_t count, u16 offset, u8 reg_width);
2368 + u32 (*aread32)(struct bcma_device *core, u16 offset);
2369 + void (*awrite32)(struct bcma_device *core, u16 offset, u32 value);
2372 +/* Core manufacturers */
2373 +#define BCMA_MANUF_ARM 0x43B
2374 +#define BCMA_MANUF_MIPS 0x4A7
2375 +#define BCMA_MANUF_BCM 0x4BF
2377 +/* Core class values. */
2378 +#define BCMA_CL_SIM 0x0
2379 +#define BCMA_CL_EROM 0x1
2380 +#define BCMA_CL_CORESIGHT 0x9
2381 +#define BCMA_CL_VERIF 0xB
2382 +#define BCMA_CL_OPTIMO 0xD
2383 +#define BCMA_CL_GEN 0xE
2384 +#define BCMA_CL_PRIMECELL 0xF
2386 +/* Core-ID values. */
2387 +#define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
2388 +#define BCMA_CORE_INVALID 0x700
2389 +#define BCMA_CORE_CHIPCOMMON 0x800
2390 +#define BCMA_CORE_ILINE20 0x801
2391 +#define BCMA_CORE_SRAM 0x802
2392 +#define BCMA_CORE_SDRAM 0x803
2393 +#define BCMA_CORE_PCI 0x804
2394 +#define BCMA_CORE_MIPS 0x805
2395 +#define BCMA_CORE_ETHERNET 0x806
2396 +#define BCMA_CORE_V90 0x807
2397 +#define BCMA_CORE_USB11_HOSTDEV 0x808
2398 +#define BCMA_CORE_ADSL 0x809
2399 +#define BCMA_CORE_ILINE100 0x80A
2400 +#define BCMA_CORE_IPSEC 0x80B
2401 +#define BCMA_CORE_UTOPIA 0x80C
2402 +#define BCMA_CORE_PCMCIA 0x80D
2403 +#define BCMA_CORE_INTERNAL_MEM 0x80E
2404 +#define BCMA_CORE_MEMC_SDRAM 0x80F
2405 +#define BCMA_CORE_OFDM 0x810
2406 +#define BCMA_CORE_EXTIF 0x811
2407 +#define BCMA_CORE_80211 0x812
2408 +#define BCMA_CORE_PHY_A 0x813
2409 +#define BCMA_CORE_PHY_B 0x814
2410 +#define BCMA_CORE_PHY_G 0x815
2411 +#define BCMA_CORE_MIPS_3302 0x816
2412 +#define BCMA_CORE_USB11_HOST 0x817
2413 +#define BCMA_CORE_USB11_DEV 0x818
2414 +#define BCMA_CORE_USB20_HOST 0x819
2415 +#define BCMA_CORE_USB20_DEV 0x81A
2416 +#define BCMA_CORE_SDIO_HOST 0x81B
2417 +#define BCMA_CORE_ROBOSWITCH 0x81C
2418 +#define BCMA_CORE_PARA_ATA 0x81D
2419 +#define BCMA_CORE_SATA_XORDMA 0x81E
2420 +#define BCMA_CORE_ETHERNET_GBIT 0x81F
2421 +#define BCMA_CORE_PCIE 0x820
2422 +#define BCMA_CORE_PHY_N 0x821
2423 +#define BCMA_CORE_SRAM_CTL 0x822
2424 +#define BCMA_CORE_MINI_MACPHY 0x823
2425 +#define BCMA_CORE_ARM_1176 0x824
2426 +#define BCMA_CORE_ARM_7TDMI 0x825
2427 +#define BCMA_CORE_PHY_LP 0x826
2428 +#define BCMA_CORE_PMU 0x827
2429 +#define BCMA_CORE_PHY_SSN 0x828
2430 +#define BCMA_CORE_SDIO_DEV 0x829
2431 +#define BCMA_CORE_ARM_CM3 0x82A
2432 +#define BCMA_CORE_PHY_HT 0x82B
2433 +#define BCMA_CORE_MIPS_74K 0x82C
2434 +#define BCMA_CORE_MAC_GBIT 0x82D
2435 +#define BCMA_CORE_DDR12_MEM_CTL 0x82E
2436 +#define BCMA_CORE_PCIE_RC 0x82F /* PCIe Root Complex */
2437 +#define BCMA_CORE_OCP_OCP_BRIDGE 0x830
2438 +#define BCMA_CORE_SHARED_COMMON 0x831
2439 +#define BCMA_CORE_OCP_AHB_BRIDGE 0x832
2440 +#define BCMA_CORE_SPI_HOST 0x833
2441 +#define BCMA_CORE_I2S 0x834
2442 +#define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
2443 +#define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
2444 +#define BCMA_CORE_DEFAULT 0xFFF
2446 +#define BCMA_MAX_NR_CORES 16
2448 +struct bcma_device {
2449 + struct bcma_bus *bus;
2450 + struct bcma_device_id id;
2452 + struct device dev;
2453 + struct device *dma_dev;
2456 + bool dev_registered;
2464 + void __iomem *io_addr;
2465 + void __iomem *io_wrap;
2468 + struct list_head list;
2471 +static inline void *bcma_get_drvdata(struct bcma_device *core)
2473 + return core->drvdata;
2475 +static inline void bcma_set_drvdata(struct bcma_device *core, void *drvdata)
2477 + core->drvdata = drvdata;
2480 +struct bcma_driver {
2482 + const struct bcma_device_id *id_table;
2484 + int (*probe)(struct bcma_device *dev);
2485 + void (*remove)(struct bcma_device *dev);
2486 + int (*suspend)(struct bcma_device *dev);
2487 + int (*resume)(struct bcma_device *dev);
2488 + void (*shutdown)(struct bcma_device *dev);
2490 + struct device_driver drv;
2493 +int __bcma_driver_register(struct bcma_driver *drv, struct module *owner);
2494 +#define bcma_driver_register(drv) \
2495 + __bcma_driver_register(drv, THIS_MODULE)
2497 +extern void bcma_driver_unregister(struct bcma_driver *drv);
2499 +/* Set a fallback SPROM.
2500 + * See kdoc at the function definition for complete documentation. */
2501 +extern int bcma_arch_register_fallback_sprom(
2502 + int (*sprom_callback)(struct bcma_bus *bus,
2503 + struct ssb_sprom *out));
2506 + /* The MMIO area. */
2507 + void __iomem *mmio;
2509 + const struct bcma_host_ops *ops;
2511 + enum bcma_hosttype hosttype;
2513 + /* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
2514 + struct pci_dev *host_pci;
2515 + /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
2516 + struct sdio_func *host_sdio;
2519 + struct bcma_chipinfo chipinfo;
2521 + struct bcma_device *mapped_core;
2522 + struct list_head cores;
2527 + struct bcma_drv_cc drv_cc;
2528 + struct bcma_drv_pci drv_pci;
2529 + struct bcma_drv_mips drv_mips;
2531 + /* We decided to share SPROM struct with SSB as long as we do not need
2532 + * any hacks for BCMA. This simplifies drivers code. */
2533 + struct ssb_sprom sprom;
2536 +static inline u32 bcma_read8(struct bcma_device *core, u16 offset)
2538 + return core->bus->ops->read8(core, offset);
2540 +static inline u32 bcma_read16(struct bcma_device *core, u16 offset)
2542 + return core->bus->ops->read16(core, offset);
2544 +static inline u32 bcma_read32(struct bcma_device *core, u16 offset)
2546 + return core->bus->ops->read32(core, offset);
2549 +void bcma_write8(struct bcma_device *core, u16 offset, u32 value)
2551 + core->bus->ops->write8(core, offset, value);
2554 +void bcma_write16(struct bcma_device *core, u16 offset, u32 value)
2556 + core->bus->ops->write16(core, offset, value);
2559 +void bcma_write32(struct bcma_device *core, u16 offset, u32 value)
2561 + core->bus->ops->write32(core, offset, value);
2563 +#ifdef CONFIG_BCMA_BLOCKIO
2564 +static inline void bcma_block_read(struct bcma_device *core, void *buffer,
2565 + size_t count, u16 offset, u8 reg_width)
2567 + core->bus->ops->block_read(core, buffer, count, offset, reg_width);
2569 +static inline void bcma_block_write(struct bcma_device *core,
2570 + const void *buffer, size_t count,
2571 + u16 offset, u8 reg_width)
2573 + core->bus->ops->block_write(core, buffer, count, offset, reg_width);
2576 +static inline u32 bcma_aread32(struct bcma_device *core, u16 offset)
2578 + return core->bus->ops->aread32(core, offset);
2581 +void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value)
2583 + core->bus->ops->awrite32(core, offset, value);
2586 +static inline void bcma_mask32(struct bcma_device *cc, u16 offset, u32 mask)
2588 + bcma_write32(cc, offset, bcma_read32(cc, offset) & mask);
2590 +static inline void bcma_set32(struct bcma_device *cc, u16 offset, u32 set)
2592 + bcma_write32(cc, offset, bcma_read32(cc, offset) | set);
2594 +static inline void bcma_maskset32(struct bcma_device *cc,
2595 + u16 offset, u32 mask, u32 set)
2597 + bcma_write32(cc, offset, (bcma_read32(cc, offset) & mask) | set);
2599 +static inline void bcma_mask16(struct bcma_device *cc, u16 offset, u16 mask)
2601 + bcma_write16(cc, offset, bcma_read16(cc, offset) & mask);
2603 +static inline void bcma_set16(struct bcma_device *cc, u16 offset, u16 set)
2605 + bcma_write16(cc, offset, bcma_read16(cc, offset) | set);
2607 +static inline void bcma_maskset16(struct bcma_device *cc,
2608 + u16 offset, u16 mask, u16 set)
2610 + bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set);
2613 +extern struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid);
2614 +extern bool bcma_core_is_enabled(struct bcma_device *core);
2615 +extern void bcma_core_disable(struct bcma_device *core, u32 flags);
2616 +extern int bcma_core_enable(struct bcma_device *core, u32 flags);
2617 +extern void bcma_core_set_clockmode(struct bcma_device *core,
2618 + enum bcma_clkmode clkmode);
2619 +extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
2621 +#define BCMA_DMA_TRANSLATION_MASK 0xC0000000
2622 +#define BCMA_DMA_TRANSLATION_NONE 0x00000000
2623 +#define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
2624 +#define BCMA_DMA_TRANSLATION_DMA64_CMT 0x80000000 /* Client Mode Translation for 64-bit DMA */
2625 +extern u32 bcma_core_dma_translation(struct bcma_device *core);
2627 +#endif /* LINUX_BCMA_H_ */
2629 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
2631 +#ifndef LINUX_BCMA_DRIVER_CC_H_
2632 +#define LINUX_BCMA_DRIVER_CC_H_
2634 +/** ChipCommon core registers. **/
2635 +#define BCMA_CC_ID 0x0000
2636 +#define BCMA_CC_ID_ID 0x0000FFFF
2637 +#define BCMA_CC_ID_ID_SHIFT 0
2638 +#define BCMA_CC_ID_REV 0x000F0000
2639 +#define BCMA_CC_ID_REV_SHIFT 16
2640 +#define BCMA_CC_ID_PKG 0x00F00000
2641 +#define BCMA_CC_ID_PKG_SHIFT 20
2642 +#define BCMA_CC_ID_NRCORES 0x0F000000
2643 +#define BCMA_CC_ID_NRCORES_SHIFT 24
2644 +#define BCMA_CC_ID_TYPE 0xF0000000
2645 +#define BCMA_CC_ID_TYPE_SHIFT 28
2646 +#define BCMA_CC_CAP 0x0004 /* Capabilities */
2647 +#define BCMA_CC_CAP_NRUART 0x00000003 /* # of UARTs */
2648 +#define BCMA_CC_CAP_MIPSEB 0x00000004 /* MIPS in BigEndian Mode */
2649 +#define BCMA_CC_CAP_UARTCLK 0x00000018 /* UART clock select */
2650 +#define BCMA_CC_CAP_UARTCLK_INT 0x00000008 /* UARTs are driven by internal divided clock */
2651 +#define BCMA_CC_CAP_UARTGPIO 0x00000020 /* UARTs on GPIO 15-12 */
2652 +#define BCMA_CC_CAP_EXTBUS 0x000000C0 /* External buses present */
2653 +#define BCMA_CC_CAP_FLASHT 0x00000700 /* Flash Type */
2654 +#define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
2655 +#define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
2656 +#define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
2657 +#define BCMA_CC_FLASHT_NFLASH 0x00000200
2658 +#define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
2659 +#define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
2660 +#define BCMA_PLLTYPE_NONE 0x00000000
2661 +#define BCMA_PLLTYPE_1 0x00010000 /* 48Mhz base, 3 dividers */
2662 +#define BCMA_PLLTYPE_2 0x00020000 /* 48Mhz, 4 dividers */
2663 +#define BCMA_PLLTYPE_3 0x00030000 /* 25Mhz, 2 dividers */
2664 +#define BCMA_PLLTYPE_4 0x00008000 /* 48Mhz, 4 dividers */
2665 +#define BCMA_PLLTYPE_5 0x00018000 /* 25Mhz, 4 dividers */
2666 +#define BCMA_PLLTYPE_6 0x00028000 /* 100/200 or 120/240 only */
2667 +#define BCMA_PLLTYPE_7 0x00038000 /* 25Mhz, 4 dividers */
2668 +#define BCMA_CC_CAP_PCTL 0x00040000 /* Power Control */
2669 +#define BCMA_CC_CAP_OTPS 0x00380000 /* OTP size */
2670 +#define BCMA_CC_CAP_OTPS_SHIFT 19
2671 +#define BCMA_CC_CAP_OTPS_BASE 5
2672 +#define BCMA_CC_CAP_JTAGM 0x00400000 /* JTAG master present */
2673 +#define BCMA_CC_CAP_BROM 0x00800000 /* Internal boot ROM active */
2674 +#define BCMA_CC_CAP_64BIT 0x08000000 /* 64-bit Backplane */
2675 +#define BCMA_CC_CAP_PMU 0x10000000 /* PMU available (rev >= 20) */
2676 +#define BCMA_CC_CAP_ECI 0x20000000 /* ECI available (rev >= 20) */
2677 +#define BCMA_CC_CAP_SPROM 0x40000000 /* SPROM present */
2678 +#define BCMA_CC_CORECTL 0x0008
2679 +#define BCMA_CC_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */
2680 +#define BCMA_CC_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
2681 +#define BCMA_CC_CORECTL_UARTCLKEN 0x00000008 /* UART clock enable (rev >= 21) */
2682 +#define BCMA_CC_BIST 0x000C
2683 +#define BCMA_CC_OTPS 0x0010 /* OTP status */
2684 +#define BCMA_CC_OTPS_PROGFAIL 0x80000000
2685 +#define BCMA_CC_OTPS_PROTECT 0x00000007
2686 +#define BCMA_CC_OTPS_HW_PROTECT 0x00000001
2687 +#define BCMA_CC_OTPS_SW_PROTECT 0x00000002
2688 +#define BCMA_CC_OTPS_CID_PROTECT 0x00000004
2689 +#define BCMA_CC_OTPS_GU_PROG_IND 0x00000F00 /* General Use programmed indication */
2690 +#define BCMA_CC_OTPS_GU_PROG_IND_SHIFT 8
2691 +#define BCMA_CC_OTPS_GU_PROG_HW 0x00000100 /* HW region programmed */
2692 +#define BCMA_CC_OTPC 0x0014 /* OTP control */
2693 +#define BCMA_CC_OTPC_RECWAIT 0xFF000000
2694 +#define BCMA_CC_OTPC_PROGWAIT 0x00FFFF00
2695 +#define BCMA_CC_OTPC_PRW_SHIFT 8
2696 +#define BCMA_CC_OTPC_MAXFAIL 0x00000038
2697 +#define BCMA_CC_OTPC_VSEL 0x00000006
2698 +#define BCMA_CC_OTPC_SELVL 0x00000001
2699 +#define BCMA_CC_OTPP 0x0018 /* OTP prog */
2700 +#define BCMA_CC_OTPP_COL 0x000000FF
2701 +#define BCMA_CC_OTPP_ROW 0x0000FF00
2702 +#define BCMA_CC_OTPP_ROW_SHIFT 8
2703 +#define BCMA_CC_OTPP_READERR 0x10000000
2704 +#define BCMA_CC_OTPP_VALUE 0x20000000
2705 +#define BCMA_CC_OTPP_READ 0x40000000
2706 +#define BCMA_CC_OTPP_START 0x80000000
2707 +#define BCMA_CC_OTPP_BUSY 0x80000000
2708 +#define BCMA_CC_OTPL 0x001C /* OTP layout */
2709 +#define BCMA_CC_OTPL_GURGN_OFFSET 0x00000FFF /* offset of general use region */
2710 +#define BCMA_CC_IRQSTAT 0x0020
2711 +#define BCMA_CC_IRQMASK 0x0024
2712 +#define BCMA_CC_IRQ_GPIO 0x00000001 /* gpio intr */
2713 +#define BCMA_CC_IRQ_EXT 0x00000002 /* ro: ext intr pin (corerev >= 3) */
2714 +#define BCMA_CC_IRQ_WDRESET 0x80000000 /* watchdog reset occurred */
2715 +#define BCMA_CC_CHIPCTL 0x0028 /* Rev >= 11 only */
2716 +#define BCMA_CC_CHIPSTAT 0x002C /* Rev >= 11 only */
2717 +#define BCMA_CC_CHIPST_4313_SPROM_PRESENT 1
2718 +#define BCMA_CC_CHIPST_4313_OTP_PRESENT 2
2719 +#define BCMA_CC_CHIPST_4331_SPROM_PRESENT 2
2720 +#define BCMA_CC_CHIPST_4331_OTP_PRESENT 4
2721 +#define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
2722 +#define BCMA_CC_JCMD_START 0x80000000
2723 +#define BCMA_CC_JCMD_BUSY 0x80000000
2724 +#define BCMA_CC_JCMD_PAUSE 0x40000000
2725 +#define BCMA_CC_JCMD0_ACC_MASK 0x0000F000
2726 +#define BCMA_CC_JCMD0_ACC_IRDR 0x00000000
2727 +#define BCMA_CC_JCMD0_ACC_DR 0x00001000
2728 +#define BCMA_CC_JCMD0_ACC_IR 0x00002000
2729 +#define BCMA_CC_JCMD0_ACC_RESET 0x00003000
2730 +#define BCMA_CC_JCMD0_ACC_IRPDR 0x00004000
2731 +#define BCMA_CC_JCMD0_ACC_PDR 0x00005000
2732 +#define BCMA_CC_JCMD0_IRW_MASK 0x00000F00
2733 +#define BCMA_CC_JCMD_ACC_MASK 0x000F0000 /* Changes for corerev 11 */
2734 +#define BCMA_CC_JCMD_ACC_IRDR 0x00000000
2735 +#define BCMA_CC_JCMD_ACC_DR 0x00010000
2736 +#define BCMA_CC_JCMD_ACC_IR 0x00020000
2737 +#define BCMA_CC_JCMD_ACC_RESET 0x00030000
2738 +#define BCMA_CC_JCMD_ACC_IRPDR 0x00040000
2739 +#define BCMA_CC_JCMD_ACC_PDR 0x00050000
2740 +#define BCMA_CC_JCMD_IRW_MASK 0x00001F00
2741 +#define BCMA_CC_JCMD_IRW_SHIFT 8
2742 +#define BCMA_CC_JCMD_DRW_MASK 0x0000003F
2743 +#define BCMA_CC_JIR 0x0034 /* Rev >= 10 only */
2744 +#define BCMA_CC_JDR 0x0038 /* Rev >= 10 only */
2745 +#define BCMA_CC_JCTL 0x003C /* Rev >= 10 only */
2746 +#define BCMA_CC_JCTL_FORCE_CLK 4 /* Force clock */
2747 +#define BCMA_CC_JCTL_EXT_EN 2 /* Enable external targets */
2748 +#define BCMA_CC_JCTL_EN 1 /* Enable Jtag master */
2749 +#define BCMA_CC_FLASHCTL 0x0040
2750 +#define BCMA_CC_FLASHCTL_START 0x80000000
2751 +#define BCMA_CC_FLASHCTL_BUSY BCMA_CC_FLASHCTL_START
2752 +#define BCMA_CC_FLASHADDR 0x0044
2753 +#define BCMA_CC_FLASHDATA 0x0048
2754 +#define BCMA_CC_BCAST_ADDR 0x0050
2755 +#define BCMA_CC_BCAST_DATA 0x0054
2756 +#define BCMA_CC_GPIOPULLUP 0x0058 /* Rev >= 20 only */
2757 +#define BCMA_CC_GPIOPULLDOWN 0x005C /* Rev >= 20 only */
2758 +#define BCMA_CC_GPIOIN 0x0060
2759 +#define BCMA_CC_GPIOOUT 0x0064
2760 +#define BCMA_CC_GPIOOUTEN 0x0068
2761 +#define BCMA_CC_GPIOCTL 0x006C
2762 +#define BCMA_CC_GPIOPOL 0x0070
2763 +#define BCMA_CC_GPIOIRQ 0x0074
2764 +#define BCMA_CC_WATCHDOG 0x0080
2765 +#define BCMA_CC_GPIOTIMER 0x0088 /* LED powersave (corerev >= 16) */
2766 +#define BCMA_CC_GPIOTIMER_OFFTIME 0x0000FFFF
2767 +#define BCMA_CC_GPIOTIMER_OFFTIME_SHIFT 0
2768 +#define BCMA_CC_GPIOTIMER_ONTIME 0xFFFF0000
2769 +#define BCMA_CC_GPIOTIMER_ONTIME_SHIFT 16
2770 +#define BCMA_CC_GPIOTOUTM 0x008C /* LED powersave (corerev >= 16) */
2771 +#define BCMA_CC_CLOCK_N 0x0090
2772 +#define BCMA_CC_CLOCK_SB 0x0094
2773 +#define BCMA_CC_CLOCK_PCI 0x0098
2774 +#define BCMA_CC_CLOCK_M2 0x009C
2775 +#define BCMA_CC_CLOCK_MIPS 0x00A0
2776 +#define BCMA_CC_CLKDIV 0x00A4 /* Rev >= 3 only */
2777 +#define BCMA_CC_CLKDIV_SFLASH 0x0F000000
2778 +#define BCMA_CC_CLKDIV_SFLASH_SHIFT 24
2779 +#define BCMA_CC_CLKDIV_OTP 0x000F0000
2780 +#define BCMA_CC_CLKDIV_OTP_SHIFT 16
2781 +#define BCMA_CC_CLKDIV_JTAG 0x00000F00
2782 +#define BCMA_CC_CLKDIV_JTAG_SHIFT 8
2783 +#define BCMA_CC_CLKDIV_UART 0x000000FF
2784 +#define BCMA_CC_CAP_EXT 0x00AC /* Capabilities */
2785 +#define BCMA_CC_PLLONDELAY 0x00B0 /* Rev >= 4 only */
2786 +#define BCMA_CC_FREFSELDELAY 0x00B4 /* Rev >= 4 only */
2787 +#define BCMA_CC_SLOWCLKCTL 0x00B8 /* 6 <= Rev <= 9 only */
2788 +#define BCMA_CC_SLOWCLKCTL_SRC 0x00000007 /* slow clock source mask */
2789 +#define BCMA_CC_SLOWCLKCTL_SRC_LPO 0x00000000 /* source of slow clock is LPO */
2790 +#define BCMA_CC_SLOWCLKCTL_SRC_XTAL 0x00000001 /* source of slow clock is crystal */
2791 +#define BCMA_CC_SLOECLKCTL_SRC_PCI 0x00000002 /* source of slow clock is PCI */
2792 +#define BCMA_CC_SLOWCLKCTL_LPOFREQ 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
2793 +#define BCMA_CC_SLOWCLKCTL_LPOPD 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
2794 +#define BCMA_CC_SLOWCLKCTL_FSLOW 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
2795 +#define BCMA_CC_SLOWCLKCTL_IPLL 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
2796 +#define BCMA_CC_SLOWCLKCTL_ENXTAL 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
2797 +#define BCMA_CC_SLOWCLKCTL_XTALPU 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
2798 +#define BCMA_CC_SLOWCLKCTL_CLKDIV 0xFFFF0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */
2799 +#define BCMA_CC_SLOWCLKCTL_CLKDIV_SHIFT 16
2800 +#define BCMA_CC_SYSCLKCTL 0x00C0 /* Rev >= 3 only */
2801 +#define BCMA_CC_SYSCLKCTL_IDLPEN 0x00000001 /* ILPen: Enable Idle Low Power */
2802 +#define BCMA_CC_SYSCLKCTL_ALPEN 0x00000002 /* ALPen: Enable Active Low Power */
2803 +#define BCMA_CC_SYSCLKCTL_PLLEN 0x00000004 /* ForcePLLOn */
2804 +#define BCMA_CC_SYSCLKCTL_FORCEALP 0x00000008 /* Force ALP (or HT if ALPen is not set */
2805 +#define BCMA_CC_SYSCLKCTL_FORCEHT 0x00000010 /* Force HT */
2806 +#define BCMA_CC_SYSCLKCTL_CLKDIV 0xFFFF0000 /* ClkDiv (ILP = 1/(4+divisor)) */
2807 +#define BCMA_CC_SYSCLKCTL_CLKDIV_SHIFT 16
2808 +#define BCMA_CC_CLKSTSTR 0x00C4 /* Rev >= 3 only */
2809 +#define BCMA_CC_EROM 0x00FC
2810 +#define BCMA_CC_PCMCIA_CFG 0x0100
2811 +#define BCMA_CC_PCMCIA_MEMWAIT 0x0104
2812 +#define BCMA_CC_PCMCIA_ATTRWAIT 0x0108
2813 +#define BCMA_CC_PCMCIA_IOWAIT 0x010C
2814 +#define BCMA_CC_IDE_CFG 0x0110
2815 +#define BCMA_CC_IDE_MEMWAIT 0x0114
2816 +#define BCMA_CC_IDE_ATTRWAIT 0x0118
2817 +#define BCMA_CC_IDE_IOWAIT 0x011C
2818 +#define BCMA_CC_PROG_CFG 0x0120
2819 +#define BCMA_CC_PROG_WAITCNT 0x0124
2820 +#define BCMA_CC_FLASH_CFG 0x0128
2821 +#define BCMA_CC_FLASH_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
2822 +#define BCMA_CC_FLASH_WAITCNT 0x012C
2823 +#define BCMA_CC_SROM_CONTROL 0x0190
2824 +#define BCMA_CC_SROM_CONTROL_START 0x80000000
2825 +#define BCMA_CC_SROM_CONTROL_BUSY 0x80000000
2826 +#define BCMA_CC_SROM_CONTROL_OPCODE 0x60000000
2827 +#define BCMA_CC_SROM_CONTROL_OP_READ 0x00000000
2828 +#define BCMA_CC_SROM_CONTROL_OP_WRITE 0x20000000
2829 +#define BCMA_CC_SROM_CONTROL_OP_WRDIS 0x40000000
2830 +#define BCMA_CC_SROM_CONTROL_OP_WREN 0x60000000
2831 +#define BCMA_CC_SROM_CONTROL_OTPSEL 0x00000010
2832 +#define BCMA_CC_SROM_CONTROL_LOCK 0x00000008
2833 +#define BCMA_CC_SROM_CONTROL_SIZE_MASK 0x00000006
2834 +#define BCMA_CC_SROM_CONTROL_SIZE_1K 0x00000000
2835 +#define BCMA_CC_SROM_CONTROL_SIZE_4K 0x00000002
2836 +#define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004
2837 +#define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1
2838 +#define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001
2839 +/* 0x1E0 is defined as shared BCMA_CLKCTLST */
2840 +#define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
2841 +#define BCMA_CC_UART0_DATA 0x0300
2842 +#define BCMA_CC_UART0_IMR 0x0304
2843 +#define BCMA_CC_UART0_FCR 0x0308
2844 +#define BCMA_CC_UART0_LCR 0x030C
2845 +#define BCMA_CC_UART0_MCR 0x0310
2846 +#define BCMA_CC_UART0_LSR 0x0314
2847 +#define BCMA_CC_UART0_MSR 0x0318
2848 +#define BCMA_CC_UART0_SCRATCH 0x031C
2849 +#define BCMA_CC_UART1_DATA 0x0400
2850 +#define BCMA_CC_UART1_IMR 0x0404
2851 +#define BCMA_CC_UART1_FCR 0x0408
2852 +#define BCMA_CC_UART1_LCR 0x040C
2853 +#define BCMA_CC_UART1_MCR 0x0410
2854 +#define BCMA_CC_UART1_LSR 0x0414
2855 +#define BCMA_CC_UART1_MSR 0x0418
2856 +#define BCMA_CC_UART1_SCRATCH 0x041C
2857 +/* PMU registers (rev >= 20) */
2858 +#define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
2859 +#define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
2860 +#define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
2861 +#define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
2862 +#define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
2863 +#define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
2864 +#define BCMA_CC_PMU_CTL_ALPREQEN 0x00000080 /* ALP req enable */
2865 +#define BCMA_CC_PMU_CTL_XTALFREQ 0x0000007C /* Crystal freq */
2866 +#define BCMA_CC_PMU_CTL_XTALFREQ_SHIFT 2
2867 +#define BCMA_CC_PMU_CTL_ILPDIVEN 0x00000002 /* ILP div enable */
2868 +#define BCMA_CC_PMU_CTL_LPOSEL 0x00000001 /* LPO sel */
2869 +#define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
2870 +#define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
2871 +#define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
2872 +#define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
2873 +#define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
2874 +#define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
2875 +#define BCMA_CC_PMU_STAT_HAVEHT 0x00000004 /* HT available */
2876 +#define BCMA_CC_PMU_STAT_RESINIT 0x00000003 /* Res init */
2877 +#define BCMA_CC_PMU_RES_STAT 0x060C /* PMU res status */
2878 +#define BCMA_CC_PMU_RES_PEND 0x0610 /* PMU res pending */
2879 +#define BCMA_CC_PMU_TIMER 0x0614 /* PMU timer */
2880 +#define BCMA_CC_PMU_MINRES_MSK 0x0618 /* PMU min res mask */
2881 +#define BCMA_CC_PMU_MAXRES_MSK 0x061C /* PMU max res mask */
2882 +#define BCMA_CC_PMU_RES_TABSEL 0x0620 /* PMU res table sel */
2883 +#define BCMA_CC_PMU_RES_DEPMSK 0x0624 /* PMU res dep mask */
2884 +#define BCMA_CC_PMU_RES_UPDNTM 0x0628 /* PMU res updown timer */
2885 +#define BCMA_CC_PMU_RES_TIMER 0x062C /* PMU res timer */
2886 +#define BCMA_CC_PMU_CLKSTRETCH 0x0630 /* PMU clockstretch */
2887 +#define BCMA_CC_PMU_WATCHDOG 0x0634 /* PMU watchdog */
2888 +#define BCMA_CC_PMU_RES_REQTS 0x0640 /* PMU res req timer sel */
2889 +#define BCMA_CC_PMU_RES_REQT 0x0644 /* PMU res req timer */
2890 +#define BCMA_CC_PMU_RES_REQM 0x0648 /* PMU res req mask */
2891 +#define BCMA_CC_CHIPCTL_ADDR 0x0650
2892 +#define BCMA_CC_CHIPCTL_DATA 0x0654
2893 +#define BCMA_CC_REGCTL_ADDR 0x0658
2894 +#define BCMA_CC_REGCTL_DATA 0x065C
2895 +#define BCMA_CC_PLLCTL_ADDR 0x0660
2896 +#define BCMA_CC_PLLCTL_DATA 0x0664
2897 +#define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
2899 +/* Divider allocation in 4716/47162/5356 */
2900 +#define BCMA_CC_PMU5_MAINPLL_CPU 1
2901 +#define BCMA_CC_PMU5_MAINPLL_MEM 2
2902 +#define BCMA_CC_PMU5_MAINPLL_SSB 3
2904 +/* PLL usage in 4716/47162 */
2905 +#define BCMA_CC_PMU4716_MAINPLL_PLL0 12
2907 +/* PLL usage in 5356/5357 */
2908 +#define BCMA_CC_PMU5356_MAINPLL_PLL0 0
2909 +#define BCMA_CC_PMU5357_MAINPLL_PLL0 0
2912 +#define BCMA_CC_PMU4706_MAINPLL_PLL0 0
2914 +/* ALP clock on pre-PMU chips */
2915 +#define BCMA_CC_PMU_ALP_CLOCK 20000000
2916 +/* HT clock for systems with PMU-enabled chipcommon */
2917 +#define BCMA_CC_PMU_HT_CLOCK 80000000
2919 +/* PMU rev 5 (& 6) */
2920 +#define BCMA_CC_PPL_P1P2_OFF 0
2921 +#define BCMA_CC_PPL_P1_MASK 0x0f000000
2922 +#define BCMA_CC_PPL_P1_SHIFT 24
2923 +#define BCMA_CC_PPL_P2_MASK 0x00f00000
2924 +#define BCMA_CC_PPL_P2_SHIFT 20
2925 +#define BCMA_CC_PPL_M14_OFF 1
2926 +#define BCMA_CC_PPL_MDIV_MASK 0x000000ff
2927 +#define BCMA_CC_PPL_MDIV_WIDTH 8
2928 +#define BCMA_CC_PPL_NM5_OFF 2
2929 +#define BCMA_CC_PPL_NDIV_MASK 0xfff00000
2930 +#define BCMA_CC_PPL_NDIV_SHIFT 20
2931 +#define BCMA_CC_PPL_FMAB_OFF 3
2932 +#define BCMA_CC_PPL_MRAT_MASK 0xf0000000
2933 +#define BCMA_CC_PPL_MRAT_SHIFT 28
2934 +#define BCMA_CC_PPL_ABRAT_MASK 0x08000000
2935 +#define BCMA_CC_PPL_ABRAT_SHIFT 27
2936 +#define BCMA_CC_PPL_FDIV_MASK 0x07ffffff
2937 +#define BCMA_CC_PPL_PLLCTL_OFF 4
2938 +#define BCMA_CC_PPL_PCHI_OFF 5
2939 +#define BCMA_CC_PPL_PCHI_MASK 0x0000003f
2941 +/* BCM4331 ChipControl numbers. */
2942 +#define BCMA_CHIPCTL_4331_BT_COEXIST BIT(0) /* 0 disable */
2943 +#define BCMA_CHIPCTL_4331_SECI BIT(1) /* 0 SECI is disabled (JATG functional) */
2944 +#define BCMA_CHIPCTL_4331_EXT_LNA BIT(2) /* 0 disable */
2945 +#define BCMA_CHIPCTL_4331_SPROM_GPIO13_15 BIT(3) /* sprom/gpio13-15 mux */
2946 +#define BCMA_CHIPCTL_4331_EXTPA_EN BIT(4) /* 0 ext pa disable, 1 ext pa enabled */
2947 +#define BCMA_CHIPCTL_4331_GPIOCLK_ON_SPROMCS BIT(5) /* set drive out GPIO_CLK on sprom_cs pin */
2948 +#define BCMA_CHIPCTL_4331_PCIE_MDIO_ON_SPROMCS BIT(6) /* use sprom_cs pin as PCIE mdio interface */
2949 +#define BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5 BIT(7) /* aband extpa will be at gpio2/5 and sprom_dout */
2950 +#define BCMA_CHIPCTL_4331_OVR_PIPEAUXCLKEN BIT(8) /* override core control on pipe_AuxClkEnable */
2951 +#define BCMA_CHIPCTL_4331_OVR_PIPEAUXPWRDOWN BIT(9) /* override core control on pipe_AuxPowerDown */
2952 +#define BCMA_CHIPCTL_4331_PCIE_AUXCLKEN BIT(10) /* pcie_auxclkenable */
2953 +#define BCMA_CHIPCTL_4331_PCIE_PIPE_PLLDOWN BIT(11) /* pcie_pipe_pllpowerdown */
2954 +#define BCMA_CHIPCTL_4331_BT_SHD0_ON_GPIO4 BIT(16) /* enable bt_shd0 at gpio4 */
2955 +#define BCMA_CHIPCTL_4331_BT_SHD1_ON_GPIO5 BIT(17) /* enable bt_shd1 at gpio5 */
2957 +/* Data for the PMU, if available.
2958 + * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
2960 +struct bcma_chipcommon_pmu {
2961 + u8 rev; /* PMU revision */
2962 + u32 crystalfreq; /* The active crystal frequency (in kHz) */
2965 +#ifdef CONFIG_BCMA_DRIVER_MIPS
2966 +struct bcma_pflash {
2972 +struct bcma_serial_port {
2974 + unsigned long clockspeed;
2976 + unsigned int baud_base;
2977 + unsigned int reg_shift;
2979 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
2981 +struct bcma_drv_cc {
2982 + struct bcma_device *core;
2985 + u32 capabilities_ext;
2987 + /* Fast Powerup Delay constant */
2988 + u16 fast_pwrup_delay;
2989 + struct bcma_chipcommon_pmu pmu;
2990 +#ifdef CONFIG_BCMA_DRIVER_MIPS
2991 + struct bcma_pflash pflash;
2993 + int nr_serial_ports;
2994 + struct bcma_serial_port serial_ports[4];
2995 +#endif /* CONFIG_BCMA_DRIVER_MIPS */
2998 +/* Register access */
2999 +#define bcma_cc_read32(cc, offset) \
3000 + bcma_read32((cc)->core, offset)
3001 +#define bcma_cc_write32(cc, offset, val) \
3002 + bcma_write32((cc)->core, offset, val)
3004 +#define bcma_cc_mask32(cc, offset, mask) \
3005 + bcma_cc_write32(cc, offset, bcma_cc_read32(cc, offset) & (mask))
3006 +#define bcma_cc_set32(cc, offset, set) \
3007 + bcma_cc_write32(cc, offset, bcma_cc_read32(cc, offset) | (set))
3008 +#define bcma_cc_maskset32(cc, offset, mask, set) \
3009 + bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
3011 +extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
3013 +extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
3014 +extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
3016 +void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
3018 +extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
3021 +void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
3023 +u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask);
3025 +/* Chipcommon GPIO pin access. */
3026 +u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask);
3027 +u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value);
3028 +u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value);
3029 +u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
3030 +u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
3031 +u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
3034 +extern void bcma_pmu_init(struct bcma_drv_cc *cc);
3036 +extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
3038 +extern void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset,
3039 + u32 mask, u32 set);
3040 +extern void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
3041 + u32 offset, u32 mask, u32 set);
3042 +extern void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc,
3043 + u32 offset, u32 mask, u32 set);
3045 +#endif /* LINUX_BCMA_DRIVER_CC_H_ */
3047 +++ b/include/linux/bcma/bcma_driver_pci.h
3049 +#ifndef LINUX_BCMA_DRIVER_PCI_H_
3050 +#define LINUX_BCMA_DRIVER_PCI_H_
3052 +#include <linux/types.h>
3056 +/** PCI core registers. **/
3057 +#define BCMA_CORE_PCI_CTL 0x0000 /* PCI Control */
3058 +#define BCMA_CORE_PCI_CTL_RST_OE 0x00000001 /* PCI_RESET Output Enable */
3059 +#define BCMA_CORE_PCI_CTL_RST 0x00000002 /* PCI_RESET driven out to pin */
3060 +#define BCMA_CORE_PCI_CTL_CLK_OE 0x00000004 /* Clock gate Output Enable */
3061 +#define BCMA_CORE_PCI_CTL_CLK 0x00000008 /* Gate for clock driven out to pin */
3062 +#define BCMA_CORE_PCI_ARBCTL 0x0010 /* PCI Arbiter Control */
3063 +#define BCMA_CORE_PCI_ARBCTL_INTERN 0x00000001 /* Use internal arbiter */
3064 +#define BCMA_CORE_PCI_ARBCTL_EXTERN 0x00000002 /* Use external arbiter */
3065 +#define BCMA_CORE_PCI_ARBCTL_PARKID 0x00000006 /* Mask, selects which agent is parked on an idle bus */
3066 +#define BCMA_CORE_PCI_ARBCTL_PARKID_LAST 0x00000000 /* Last requestor */
3067 +#define BCMA_CORE_PCI_ARBCTL_PARKID_4710 0x00000002 /* 4710 */
3068 +#define BCMA_CORE_PCI_ARBCTL_PARKID_EXT0 0x00000004 /* External requestor 0 */
3069 +#define BCMA_CORE_PCI_ARBCTL_PARKID_EXT1 0x00000006 /* External requestor 1 */
3070 +#define BCMA_CORE_PCI_ISTAT 0x0020 /* Interrupt status */
3071 +#define BCMA_CORE_PCI_ISTAT_INTA 0x00000001 /* PCI INTA# */
3072 +#define BCMA_CORE_PCI_ISTAT_INTB 0x00000002 /* PCI INTB# */
3073 +#define BCMA_CORE_PCI_ISTAT_SERR 0x00000004 /* PCI SERR# (write to clear) */
3074 +#define BCMA_CORE_PCI_ISTAT_PERR 0x00000008 /* PCI PERR# (write to clear) */
3075 +#define BCMA_CORE_PCI_ISTAT_PME 0x00000010 /* PCI PME# */
3076 +#define BCMA_CORE_PCI_IMASK 0x0024 /* Interrupt mask */
3077 +#define BCMA_CORE_PCI_IMASK_INTA 0x00000001 /* PCI INTA# */
3078 +#define BCMA_CORE_PCI_IMASK_INTB 0x00000002 /* PCI INTB# */
3079 +#define BCMA_CORE_PCI_IMASK_SERR 0x00000004 /* PCI SERR# */
3080 +#define BCMA_CORE_PCI_IMASK_PERR 0x00000008 /* PCI PERR# */
3081 +#define BCMA_CORE_PCI_IMASK_PME 0x00000010 /* PCI PME# */
3082 +#define BCMA_CORE_PCI_MBOX 0x0028 /* Backplane to PCI Mailbox */
3083 +#define BCMA_CORE_PCI_MBOX_F0_0 0x00000100 /* PCI function 0, INT 0 */
3084 +#define BCMA_CORE_PCI_MBOX_F0_1 0x00000200 /* PCI function 0, INT 1 */
3085 +#define BCMA_CORE_PCI_MBOX_F1_0 0x00000400 /* PCI function 1, INT 0 */
3086 +#define BCMA_CORE_PCI_MBOX_F1_1 0x00000800 /* PCI function 1, INT 1 */
3087 +#define BCMA_CORE_PCI_MBOX_F2_0 0x00001000 /* PCI function 2, INT 0 */
3088 +#define BCMA_CORE_PCI_MBOX_F2_1 0x00002000 /* PCI function 2, INT 1 */
3089 +#define BCMA_CORE_PCI_MBOX_F3_0 0x00004000 /* PCI function 3, INT 0 */
3090 +#define BCMA_CORE_PCI_MBOX_F3_1 0x00008000 /* PCI function 3, INT 1 */
3091 +#define BCMA_CORE_PCI_BCAST_ADDR 0x0050 /* Backplane Broadcast Address */
3092 +#define BCMA_CORE_PCI_BCAST_ADDR_MASK 0x000000FF
3093 +#define BCMA_CORE_PCI_BCAST_DATA 0x0054 /* Backplane Broadcast Data */
3094 +#define BCMA_CORE_PCI_GPIO_IN 0x0060 /* rev >= 2 only */
3095 +#define BCMA_CORE_PCI_GPIO_OUT 0x0064 /* rev >= 2 only */
3096 +#define BCMA_CORE_PCI_GPIO_ENABLE 0x0068 /* rev >= 2 only */
3097 +#define BCMA_CORE_PCI_GPIO_CTL 0x006C /* rev >= 2 only */
3098 +#define BCMA_CORE_PCI_SBTOPCI0 0x0100 /* Backplane to PCI translation 0 (sbtopci0) */
3099 +#define BCMA_CORE_PCI_SBTOPCI0_MASK 0xFC000000
3100 +#define BCMA_CORE_PCI_SBTOPCI1 0x0104 /* Backplane to PCI translation 1 (sbtopci1) */
3101 +#define BCMA_CORE_PCI_SBTOPCI1_MASK 0xFC000000
3102 +#define BCMA_CORE_PCI_SBTOPCI2 0x0108 /* Backplane to PCI translation 2 (sbtopci2) */
3103 +#define BCMA_CORE_PCI_SBTOPCI2_MASK 0xC0000000
3104 +#define BCMA_CORE_PCI_CONFIG_ADDR 0x0120 /* pcie config space access */
3105 +#define BCMA_CORE_PCI_CONFIG_DATA 0x0124 /* pcie config space access */
3106 +#define BCMA_CORE_PCI_MDIO_CONTROL 0x0128 /* controls the mdio access */
3107 +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */
3108 +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL 0x2
3109 +#define BCMA_CORE_PCI_MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */
3110 +#define BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE 0x100 /* Tranaction complete */
3111 +#define BCMA_CORE_PCI_MDIO_DATA 0x012c /* Data to the mdio access */
3112 +#define BCMA_CORE_PCI_MDIODATA_MASK 0x0000ffff /* data 2 bytes */
3113 +#define BCMA_CORE_PCI_MDIODATA_TA 0x00020000 /* Turnaround */
3114 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD 18 /* Regaddr shift (rev < 10) */
3115 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK_OLD 0x003c0000 /* Regaddr Mask (rev < 10) */
3116 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD 22 /* Physmedia devaddr shift (rev < 10) */
3117 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK_OLD 0x0fc00000 /* Physmedia devaddr Mask (rev < 10) */
3118 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF 18 /* Regaddr shift */
3119 +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK 0x007c0000 /* Regaddr Mask */
3120 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF 23 /* Physmedia devaddr shift */
3121 +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK 0x0f800000 /* Physmedia devaddr Mask */
3122 +#define BCMA_CORE_PCI_MDIODATA_WRITE 0x10000000 /* write Transaction */
3123 +#define BCMA_CORE_PCI_MDIODATA_READ 0x20000000 /* Read Transaction */
3124 +#define BCMA_CORE_PCI_MDIODATA_START 0x40000000 /* start of Transaction */
3125 +#define BCMA_CORE_PCI_MDIODATA_DEV_ADDR 0x0 /* dev address for serdes */
3126 +#define BCMA_CORE_PCI_MDIODATA_BLK_ADDR 0x1F /* blk address for serdes */
3127 +#define BCMA_CORE_PCI_MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */
3128 +#define BCMA_CORE_PCI_MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */
3129 +#define BCMA_CORE_PCI_MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */
3130 +#define BCMA_CORE_PCI_PCIEIND_ADDR 0x0130 /* indirect access to the internal register */
3131 +#define BCMA_CORE_PCI_PCIEIND_DATA 0x0134 /* Data to/from the internal regsiter */
3132 +#define BCMA_CORE_PCI_CLKREQENCTRL 0x0138 /* >= rev 6, Clkreq rdma control */
3133 +#define BCMA_CORE_PCI_PCICFG0 0x0400 /* PCI config space 0 (rev >= 8) */
3134 +#define BCMA_CORE_PCI_PCICFG1 0x0500 /* PCI config space 1 (rev >= 8) */
3135 +#define BCMA_CORE_PCI_PCICFG2 0x0600 /* PCI config space 2 (rev >= 8) */
3136 +#define BCMA_CORE_PCI_PCICFG3 0x0700 /* PCI config space 3 (rev >= 8) */
3137 +#define BCMA_CORE_PCI_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
3140 +#define BCMA_CORE_PCI_SBTOPCI_MEM 0x00000000
3141 +#define BCMA_CORE_PCI_SBTOPCI_IO 0x00000001
3142 +#define BCMA_CORE_PCI_SBTOPCI_CFG0 0x00000002
3143 +#define BCMA_CORE_PCI_SBTOPCI_CFG1 0x00000003
3144 +#define BCMA_CORE_PCI_SBTOPCI_PREF 0x00000004 /* Prefetch enable */
3145 +#define BCMA_CORE_PCI_SBTOPCI_BURST 0x00000008 /* Burst enable */
3146 +#define BCMA_CORE_PCI_SBTOPCI_MRM 0x00000020 /* Memory Read Multiple */
3147 +#define BCMA_CORE_PCI_SBTOPCI_RC 0x00000030 /* Read Command mask (rev >= 11) */
3148 +#define BCMA_CORE_PCI_SBTOPCI_RC_READ 0x00000000 /* Memory read */
3149 +#define BCMA_CORE_PCI_SBTOPCI_RC_READL 0x00000010 /* Memory read line */
3150 +#define BCMA_CORE_PCI_SBTOPCI_RC_READM 0x00000020 /* Memory read multiple */
3152 +/* PCIE protocol PHY diagnostic registers */
3153 +#define BCMA_CORE_PCI_PLP_MODEREG 0x200 /* Mode */
3154 +#define BCMA_CORE_PCI_PLP_STATUSREG 0x204 /* Status */
3155 +#define BCMA_CORE_PCI_PLP_POLARITYINV_STAT 0x10 /* Status reg PCIE_PLP_STATUSREG */
3156 +#define BCMA_CORE_PCI_PLP_LTSSMCTRLREG 0x208 /* LTSSM control */
3157 +#define BCMA_CORE_PCI_PLP_LTLINKNUMREG 0x20c /* Link Training Link number */
3158 +#define BCMA_CORE_PCI_PLP_LTLANENUMREG 0x210 /* Link Training Lane number */
3159 +#define BCMA_CORE_PCI_PLP_LTNFTSREG 0x214 /* Link Training N_FTS */
3160 +#define BCMA_CORE_PCI_PLP_ATTNREG 0x218 /* Attention */
3161 +#define BCMA_CORE_PCI_PLP_ATTNMASKREG 0x21C /* Attention Mask */
3162 +#define BCMA_CORE_PCI_PLP_RXERRCTR 0x220 /* Rx Error */
3163 +#define BCMA_CORE_PCI_PLP_RXFRMERRCTR 0x224 /* Rx Framing Error */
3164 +#define BCMA_CORE_PCI_PLP_RXERRTHRESHREG 0x228 /* Rx Error threshold */
3165 +#define BCMA_CORE_PCI_PLP_TESTCTRLREG 0x22C /* Test Control reg */
3166 +#define BCMA_CORE_PCI_PLP_SERDESCTRLOVRDREG 0x230 /* SERDES Control Override */
3167 +#define BCMA_CORE_PCI_PLP_TIMINGOVRDREG 0x234 /* Timing param override */
3168 +#define BCMA_CORE_PCI_PLP_RXTXSMDIAGREG 0x238 /* RXTX State Machine Diag */
3169 +#define BCMA_CORE_PCI_PLP_LTSSMDIAGREG 0x23C /* LTSSM State Machine Diag */
3171 +/* PCIE protocol DLLP diagnostic registers */
3172 +#define BCMA_CORE_PCI_DLLP_LCREG 0x100 /* Link Control */
3173 +#define BCMA_CORE_PCI_DLLP_LSREG 0x104 /* Link Status */
3174 +#define BCMA_CORE_PCI_DLLP_LAREG 0x108 /* Link Attention */
3175 +#define BCMA_CORE_PCI_DLLP_LSREG_LINKUP (1 << 16)
3176 +#define BCMA_CORE_PCI_DLLP_LAMASKREG 0x10C /* Link Attention Mask */
3177 +#define BCMA_CORE_PCI_DLLP_NEXTTXSEQNUMREG 0x110 /* Next Tx Seq Num */
3178 +#define BCMA_CORE_PCI_DLLP_ACKEDTXSEQNUMREG 0x114 /* Acked Tx Seq Num */
3179 +#define BCMA_CORE_PCI_DLLP_PURGEDTXSEQNUMREG 0x118 /* Purged Tx Seq Num */
3180 +#define BCMA_CORE_PCI_DLLP_RXSEQNUMREG 0x11C /* Rx Sequence Number */
3181 +#define BCMA_CORE_PCI_DLLP_LRREG 0x120 /* Link Replay */
3182 +#define BCMA_CORE_PCI_DLLP_LACKTOREG 0x124 /* Link Ack Timeout */
3183 +#define BCMA_CORE_PCI_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */
3184 +#define BCMA_CORE_PCI_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr */
3185 +#define BCMA_CORE_PCI_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr */
3186 +#define BCMA_CORE_PCI_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr */
3187 +#define BCMA_CORE_PCI_DLLP_RTRRWREG 0x138 /* Retry buffer Read/Write */
3188 +#define BCMA_CORE_PCI_DLLP_ECTHRESHREG 0x13C /* Error Count Threshold */
3189 +#define BCMA_CORE_PCI_DLLP_TLPERRCTRREG 0x140 /* TLP Error Counter */
3190 +#define BCMA_CORE_PCI_DLLP_ERRCTRREG 0x144 /* Error Counter */
3191 +#define BCMA_CORE_PCI_DLLP_NAKRXCTRREG 0x148 /* NAK Received Counter */
3192 +#define BCMA_CORE_PCI_DLLP_TESTREG 0x14C /* Test */
3193 +#define BCMA_CORE_PCI_DLLP_PKTBIST 0x150 /* Packet BIST */
3194 +#define BCMA_CORE_PCI_DLLP_PCIE11 0x154 /* DLLP PCIE 1.1 reg */
3196 +/* SERDES RX registers */
3197 +#define BCMA_CORE_PCI_SERDES_RX_CTRL 1 /* Rx cntrl */
3198 +#define BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE 0x80 /* rxpolarity_force */
3199 +#define BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY 0x40 /* rxpolarity_value */
3200 +#define BCMA_CORE_PCI_SERDES_RX_TIMER1 2 /* Rx Timer1 */
3201 +#define BCMA_CORE_PCI_SERDES_RX_CDR 6 /* CDR */
3202 +#define BCMA_CORE_PCI_SERDES_RX_CDRBW 7 /* CDR BW */
3204 +/* SERDES PLL registers */
3205 +#define BCMA_CORE_PCI_SERDES_PLL_CTRL 1 /* PLL control reg */
3206 +#define BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN 0x4000 /* bit 14 is FREQDET on */
3208 +/* PCIcore specific boardflags */
3209 +#define BCMA_CORE_PCI_BFL_NOPCI 0x00000400 /* Board leaves PCI floating */
3211 +/* PCIE Config space accessing MACROS */
3212 +#define BCMA_CORE_PCI_CFG_BUS_SHIFT 24 /* Bus shift */
3213 +#define BCMA_CORE_PCI_CFG_SLOT_SHIFT 19 /* Slot/Device shift */
3214 +#define BCMA_CORE_PCI_CFG_FUN_SHIFT 16 /* Function shift */
3215 +#define BCMA_CORE_PCI_CFG_OFF_SHIFT 0 /* Register shift */
3217 +#define BCMA_CORE_PCI_CFG_BUS_MASK 0xff /* Bus mask */
3218 +#define BCMA_CORE_PCI_CFG_SLOT_MASK 0x1f /* Slot/Device mask */
3219 +#define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */
3220 +#define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */
3222 +/* PCIE Root Capability Register bits (Host mode only) */
3223 +#define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
3225 +struct bcma_drv_pci;
3227 +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
3228 +struct bcma_drv_pci_host {
3229 + struct bcma_drv_pci *pdev;
3231 + u32 host_cfg_addr;
3232 + spinlock_t cfgspace_lock;
3234 + struct pci_controller pci_controller;
3235 + struct pci_ops pci_ops;
3236 + struct resource mem_resource;
3237 + struct resource io_resource;
3241 +struct bcma_drv_pci {
3242 + struct bcma_device *core;
3246 +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
3247 + struct bcma_drv_pci_host *host_controller;
3251 +/* Register access */
3252 +#define pcicore_read32(pc, offset) bcma_read32((pc)->core, offset)
3253 +#define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
3255 +extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
3256 +extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
3257 + struct bcma_device *core, bool enable);
3259 +extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
3260 +extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
3262 +#endif /* LINUX_BCMA_DRIVER_PCI_H_ */
3264 +++ b/include/linux/bcma/bcma_regs.h
3266 +#ifndef LINUX_BCMA_REGS_H_
3267 +#define LINUX_BCMA_REGS_H_
3269 +/* Some single registers are shared between many cores */
3270 +/* BCMA_CLKCTLST: ChipCommon (rev >= 20), PCIe, 80211 */
3271 +#define BCMA_CLKCTLST 0x01E0 /* Clock control and status */
3272 +#define BCMA_CLKCTLST_FORCEALP 0x00000001 /* Force ALP request */
3273 +#define BCMA_CLKCTLST_FORCEHT 0x00000002 /* Force HT request */
3274 +#define BCMA_CLKCTLST_FORCEILP 0x00000004 /* Force ILP request */
3275 +#define BCMA_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
3276 +#define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
3277 +#define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
3278 +#define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
3279 +#define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
3280 +#define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
3281 +#define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
3282 +#define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
3283 +#define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
3284 +/* Is there any BCM4328 on BCMA bus? */
3285 +#define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
3286 +#define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
3288 +/* Agent registers (common for every core) */
3289 +#define BCMA_IOCTL 0x0408 /* IO control */
3290 +#define BCMA_IOCTL_CLK 0x0001
3291 +#define BCMA_IOCTL_FGC 0x0002
3292 +#define BCMA_IOCTL_CORE_BITS 0x3FFC
3293 +#define BCMA_IOCTL_PME_EN 0x4000
3294 +#define BCMA_IOCTL_BIST_EN 0x8000
3295 +#define BCMA_IOST 0x0500 /* IO status */
3296 +#define BCMA_IOST_CORE_BITS 0x0FFF
3297 +#define BCMA_IOST_DMA64 0x1000
3298 +#define BCMA_IOST_GATED_CLK 0x2000
3299 +#define BCMA_IOST_BIST_ERROR 0x4000
3300 +#define BCMA_IOST_BIST_DONE 0x8000
3301 +#define BCMA_RESET_CTL 0x0800
3302 +#define BCMA_RESET_CTL_RESET 0x0001
3304 +/* BCMA PCI config space registers. */
3305 +#define BCMA_PCI_PMCSR 0x44
3306 +#define BCMA_PCI_PE 0x100
3307 +#define BCMA_PCI_BAR0_WIN 0x80 /* Backplane address space 0 */
3308 +#define BCMA_PCI_BAR1_WIN 0x84 /* Backplane address space 1 */
3309 +#define BCMA_PCI_SPROMCTL 0x88 /* SPROM control */
3310 +#define BCMA_PCI_SPROMCTL_WE 0x10 /* SPROM write enable */
3311 +#define BCMA_PCI_BAR1_CONTROL 0x8c /* Address space 1 burst control */
3312 +#define BCMA_PCI_IRQS 0x90 /* PCI interrupts */
3313 +#define BCMA_PCI_IRQMASK 0x94 /* PCI IRQ control and mask (pcirev >= 6 only) */
3314 +#define BCMA_PCI_BACKPLANE_IRQS 0x98 /* Backplane Interrupts */
3315 +#define BCMA_PCI_BAR0_WIN2 0xAC
3316 +#define BCMA_PCI_GPIO_IN 0xB0 /* GPIO Input (pcirev >= 3 only) */
3317 +#define BCMA_PCI_GPIO_OUT 0xB4 /* GPIO Output (pcirev >= 3 only) */
3318 +#define BCMA_PCI_GPIO_OUT_ENABLE 0xB8 /* GPIO Output Enable/Disable (pcirev >= 3 only) */
3319 +#define BCMA_PCI_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
3320 +#define BCMA_PCI_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
3321 +#define BCMA_PCI_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
3322 +#define BCMA_PCI_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
3324 +/* SiliconBackplane Address Map.
3325 + * All regions may not exist on all chips.
3327 +#define BCMA_SOC_SDRAM_BASE 0x00000000U /* Physical SDRAM */
3328 +#define BCMA_SOC_PCI_MEM 0x08000000U /* Host Mode sb2pcitranslation0 (64 MB) */
3329 +#define BCMA_SOC_PCI_MEM_SZ (64 * 1024 * 1024)
3330 +#define BCMA_SOC_PCI_CFG 0x0c000000U /* Host Mode sb2pcitranslation1 (64 MB) */
3331 +#define BCMA_SOC_SDRAM_SWAPPED 0x10000000U /* Byteswapped Physical SDRAM */
3332 +#define BCMA_SOC_SDRAM_R2 0x80000000U /* Region 2 for sdram (512 MB) */
3335 +#define BCMA_SOC_PCI_DMA 0x40000000U /* Client Mode sb2pcitranslation2 (1 GB) */
3336 +#define BCMA_SOC_PCI_DMA2 0x80000000U /* Client Mode sb2pcitranslation2 (1 GB) */
3337 +#define BCMA_SOC_PCI_DMA_SZ 0x40000000U /* Client Mode sb2pcitranslation2 size in bytes */
3338 +#define BCMA_SOC_PCIE_DMA_L32 0x00000000U /* PCIE Client Mode sb2pcitranslation2
3339 + * (2 ZettaBytes), low 32 bits
3341 +#define BCMA_SOC_PCIE_DMA_H32 0x80000000U /* PCIE Client Mode sb2pcitranslation2
3342 + * (2 ZettaBytes), high 32 bits
3345 +#define BCMA_SOC_PCI1_MEM 0x40000000U /* Host Mode sb2pcitranslation0 (64 MB) */
3346 +#define BCMA_SOC_PCI1_CFG 0x44000000U /* Host Mode sb2pcitranslation1 (64 MB) */
3347 +#define BCMA_SOC_PCIE1_DMA_H32 0xc0000000U /* PCIE Client Mode sb2pcitranslation2
3348 + * (2 ZettaBytes), high 32 bits
3351 +#endif /* LINUX_BCMA_REGS_H_ */
3352 --- a/include/linux/mod_devicetable.h
3353 +++ b/include/linux/mod_devicetable.h
3354 @@ -382,6 +382,23 @@ struct ssb_device_id {
3355 #define SSB_ANY_ID 0xFFFF
3356 #define SSB_ANY_REV 0xFF
3358 +/* Broadcom's specific AMBA core, see drivers/bcma/ */
3359 +struct bcma_device_id {
3365 +#define BCMA_CORE(_manuf, _id, _rev, _class) \
3366 + { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, }
3367 +#define BCMA_CORETABLE_END \
3370 +#define BCMA_ANY_MANUF 0xFFFF
3371 +#define BCMA_ANY_ID 0xFFFF
3372 +#define BCMA_ANY_REV 0xFF
3373 +#define BCMA_ANY_CLASS 0xFF
3375 struct virtio_device_id {
3378 --- a/scripts/mod/file2alias.c
3379 +++ b/scripts/mod/file2alias.c
3380 @@ -702,6 +702,24 @@ static int do_ssb_entry(const char *file
3384 +/* Looks like: bcma:mNidNrevNclN. */
3385 +static int do_bcma_entry(const char *filename,
3386 + struct bcma_device_id *id, char *alias)
3388 + id->manuf = TO_NATIVE(id->manuf);
3389 + id->id = TO_NATIVE(id->id);
3390 + id->rev = TO_NATIVE(id->rev);
3391 + id->class = TO_NATIVE(id->class);
3393 + strcpy(alias, "bcma:");
3394 + ADD(alias, "m", id->manuf != BCMA_ANY_MANUF, id->manuf);
3395 + ADD(alias, "id", id->id != BCMA_ANY_ID, id->id);
3396 + ADD(alias, "rev", id->rev != BCMA_ANY_REV, id->rev);
3397 + ADD(alias, "cl", id->class != BCMA_ANY_CLASS, id->class);
3398 + add_wildcard(alias);
3402 /* Looks like: virtio:dNvN */
3403 static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
3405 @@ -968,6 +986,10 @@ void handle_moddevtable(struct module *m
3406 do_table(symval, sym->st_size,
3407 sizeof(struct ssb_device_id), "ssb",
3409 + else if (sym_is(symname, "__mod_bcma_device_table"))
3410 + do_table(symval, sym->st_size,
3411 + sizeof(struct bcma_device_id), "bcma",
3412 + do_bcma_entry, mod);
3413 else if (sym_is(symname, "__mod_virtio_device_table"))
3414 do_table(symval, sym->st_size,
3415 sizeof(struct virtio_device_id), "virtio",
3417 +++ b/drivers/bcma/sprom.c
3420 + * Broadcom specific AMBA
3423 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
3425 + * Licensed under the GNU/GPL. See COPYING for details.
3428 +#include "bcma_private.h"
3430 +#include <linux/bcma/bcma.h>
3431 +#include <linux/bcma/bcma_regs.h>
3432 +#include <linux/pci.h>
3433 +#include <linux/io.h>
3434 +#include <linux/dma-mapping.h>
3435 +#include <linux/slab.h>
3437 +static int(*get_fallback_sprom)(struct bcma_bus *dev, struct ssb_sprom *out);
3440 + * bcma_arch_register_fallback_sprom - Registers a method providing a
3441 + * fallback SPROM if no SPROM is found.
3443 + * @sprom_callback: The callback function.
3445 + * With this function the architecture implementation may register a
3446 + * callback handler which fills the SPROM data structure. The fallback is
3447 + * used for PCI based BCMA devices, where no valid SPROM can be found
3448 + * in the shadow registers and to provide the SPROM for SoCs where BCMA is
3449 + * to controll the system bus.
3451 + * This function is useful for weird architectures that have a half-assed
3452 + * BCMA device hardwired to their PCI bus.
3454 + * This function is available for architecture code, only. So it is not
3457 +int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus,
3458 + struct ssb_sprom *out))
3460 + if (get_fallback_sprom)
3462 + get_fallback_sprom = sprom_callback;
3467 +static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus,
3468 + struct ssb_sprom *out)
3472 + if (!get_fallback_sprom) {
3477 + err = get_fallback_sprom(bus, out);
3481 + pr_debug("Using SPROM revision %d provided by"
3482 + " platform.\n", bus->sprom.revision);
3485 + pr_warn("Using fallback SPROM failed (err %d)\n", err);
3489 +/**************************************************
3491 + **************************************************/
3493 +static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
3496 + for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
3497 + sprom[i] = bcma_read16(bus->drv_cc.core,
3498 + offset + (i * 2));
3501 +/**************************************************
3503 + **************************************************/
3505 +static inline u8 bcma_crc8(u8 crc, u8 data)
3507 + /* Polynomial: x^8 + x^7 + x^6 + x^4 + x^2 + 1 */
3508 + static const u8 t[] = {
3509 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
3510 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
3511 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
3512 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
3513 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
3514 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
3515 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
3516 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
3517 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
3518 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
3519 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
3520 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
3521 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
3522 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
3523 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
3524 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
3525 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
3526 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
3527 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
3528 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
3529 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
3530 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
3531 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
3532 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
3533 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
3534 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
3535 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
3536 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
3537 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
3538 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
3539 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
3540 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F,
3542 + return t[crc ^ data];
3545 +static u8 bcma_sprom_crc(const u16 *sprom)
3550 + for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
3551 + crc = bcma_crc8(crc, sprom[word] & 0x00FF);
3552 + crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
3554 + crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
3560 +static int bcma_sprom_check_crc(const u16 *sprom)
3566 + crc = bcma_sprom_crc(sprom);
3567 + tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
3568 + expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
3569 + if (crc != expected_crc)
3575 +static int bcma_sprom_valid(const u16 *sprom)
3580 + err = bcma_sprom_check_crc(sprom);
3584 + revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
3585 + if (revision != 8 && revision != 9) {
3586 + pr_err("Unsupported SPROM revision: %d\n", revision);
3593 +/**************************************************
3594 + * SPROM extraction.
3595 + **************************************************/
3597 +#define SPOFF(offset) ((offset) / sizeof(u16))
3599 +#define SPEX(_field, _offset, _mask, _shift) \
3600 + bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
3602 +static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
3606 + u16 pwr_info_offset[] = {
3607 + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
3608 + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
3610 + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
3611 + ARRAY_SIZE(bus->sprom.core_pwr_info));
3613 + bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
3614 + SSB_SPROM_REVISION_REV;
3616 + for (i = 0; i < 3; i++) {
3617 + v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
3618 + *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
3621 + SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
3623 + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
3624 + SSB_SPROM4_TXPID2G0_SHIFT);
3625 + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1,
3626 + SSB_SPROM4_TXPID2G1_SHIFT);
3627 + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2,
3628 + SSB_SPROM4_TXPID2G2_SHIFT);
3629 + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3,
3630 + SSB_SPROM4_TXPID2G3_SHIFT);
3632 + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0,
3633 + SSB_SPROM4_TXPID5GL0_SHIFT);
3634 + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1,
3635 + SSB_SPROM4_TXPID5GL1_SHIFT);
3636 + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2,
3637 + SSB_SPROM4_TXPID5GL2_SHIFT);
3638 + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3,
3639 + SSB_SPROM4_TXPID5GL3_SHIFT);
3641 + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0,
3642 + SSB_SPROM4_TXPID5G0_SHIFT);
3643 + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1,
3644 + SSB_SPROM4_TXPID5G1_SHIFT);
3645 + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2,
3646 + SSB_SPROM4_TXPID5G2_SHIFT);
3647 + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3,
3648 + SSB_SPROM4_TXPID5G3_SHIFT);
3650 + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0,
3651 + SSB_SPROM4_TXPID5GH0_SHIFT);
3652 + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1,
3653 + SSB_SPROM4_TXPID5GH1_SHIFT);
3654 + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2,
3655 + SSB_SPROM4_TXPID5GH2_SHIFT);
3656 + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3,
3657 + SSB_SPROM4_TXPID5GH3_SHIFT);
3659 + SPEX(boardflags_lo, SSB_SPROM8_BFLLO, ~0, 0);
3660 + SPEX(boardflags_hi, SSB_SPROM8_BFLHI, ~0, 0);
3661 + SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0);
3662 + SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0);
3664 + SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0);
3666 + /* Extract cores power info info */
3667 + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
3668 + o = pwr_info_offset[i];
3669 + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
3670 + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
3671 + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
3672 + SSB_SPROM8_2G_MAXP, 0);
3674 + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
3675 + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
3676 + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
3678 + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
3679 + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
3680 + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
3681 + SSB_SPROM8_5G_MAXP, 0);
3682 + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
3683 + SSB_SPROM8_5GH_MAXP, 0);
3684 + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
3685 + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
3687 + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
3688 + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
3689 + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
3690 + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
3691 + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
3692 + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
3693 + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
3694 + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
3695 + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
3698 + SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS,
3699 + SSB_SROM8_FEM_TSSIPOS_SHIFT);
3700 + SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN,
3701 + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
3702 + SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE,
3703 + SSB_SROM8_FEM_PDET_RANGE_SHIFT);
3704 + SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO,
3705 + SSB_SROM8_FEM_TR_ISO_SHIFT);
3706 + SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT,
3707 + SSB_SROM8_FEM_ANTSWLUT_SHIFT);
3709 + SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS,
3710 + SSB_SROM8_FEM_TSSIPOS_SHIFT);
3711 + SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN,
3712 + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
3713 + SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE,
3714 + SSB_SROM8_FEM_PDET_RANGE_SHIFT);
3715 + SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO,
3716 + SSB_SROM8_FEM_TR_ISO_SHIFT);
3717 + SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT,
3718 + SSB_SROM8_FEM_ANTSWLUT_SHIFT);
3722 + * Indicates the presence of external SPROM.
3724 +static bool bcma_sprom_ext_available(struct bcma_bus *bus)
3730 + if (bus->drv_cc.core->id.rev >= 31) {
3731 + if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
3734 + srom_control = bcma_read32(bus->drv_cc.core,
3735 + BCMA_CC_SROM_CONTROL);
3736 + return srom_control & BCMA_CC_SROM_CONTROL_PRESENT;
3739 + /* older chipcommon revisions use chip status register */
3740 + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
3741 + switch (bus->chipinfo.id) {
3743 + present_mask = BCMA_CC_CHIPST_4313_SPROM_PRESENT;
3747 + present_mask = BCMA_CC_CHIPST_4331_SPROM_PRESENT;
3754 + return chip_status & present_mask;
3758 + * Indicates that on-chip OTP memory is present and enabled.
3760 +static bool bcma_sprom_onchip_available(struct bcma_bus *bus)
3766 + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
3767 + switch (bus->chipinfo.id) {
3769 + present = chip_status & BCMA_CC_CHIPST_4313_OTP_PRESENT;
3773 + present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
3778 + /* for these chips OTP is always available */
3788 + otpsize = bus->drv_cc.capabilities & BCMA_CC_CAP_OTPS;
3789 + otpsize >>= BCMA_CC_CAP_OTPS_SHIFT;
3792 + return otpsize != 0;
3796 + * Verify OTP is filled and determine the byte
3797 + * offset where SPROM data is located.
3799 + * On error, returns 0; byte offset otherwise.
3801 +static int bcma_sprom_onchip_offset(struct bcma_bus *bus)
3803 + struct bcma_device *cc = bus->drv_cc.core;
3806 + /* verify OTP status */
3807 + if ((bcma_read32(cc, BCMA_CC_OTPS) & BCMA_CC_OTPS_GU_PROG_HW) == 0)
3810 + /* obtain bit offset from otplayout register */
3811 + offset = (bcma_read32(cc, BCMA_CC_OTPL) & BCMA_CC_OTPL_GURGN_OFFSET);
3812 + return BCMA_CC_SPROM + (offset >> 3);
3815 +int bcma_sprom_get(struct bcma_bus *bus)
3817 + u16 offset = BCMA_CC_SPROM;
3821 + if (!bus->drv_cc.core)
3822 + return -EOPNOTSUPP;
3824 + if (!bcma_sprom_ext_available(bus)) {
3826 + * External SPROM takes precedence so check
3827 + * on-chip OTP only when no external SPROM
3830 + if (bcma_sprom_onchip_available(bus)) {
3831 + /* determine offset */
3832 + offset = bcma_sprom_onchip_offset(bus);
3836 + * Maybe there is no SPROM on the device?
3837 + * Now we ask the arch code if there is some sprom
3838 + * available for this device in some other storage.
3840 + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
3845 + sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
3850 + if (bus->chipinfo.id == 0x4331)
3851 + bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
3853 + pr_debug("SPROM offset 0x%x\n", offset);
3854 + bcma_sprom_read(bus, offset, sprom);
3856 + if (bus->chipinfo.id == 0x4331)
3857 + bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
3859 + err = bcma_sprom_valid(sprom);
3863 + bcma_sprom_extract_r8(bus, sprom);
3870 +++ b/drivers/bcma/driver_pci_host.c
3873 + * Broadcom specific AMBA
3874 + * PCI Core in hostmode
3876 + * Copyright 2005 - 2011, Broadcom Corporation
3877 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
3878 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
3880 + * Licensed under the GNU/GPL. See COPYING for details.
3883 +#include "bcma_private.h"
3884 +#include <linux/pci.h>
3885 +#include <linux/export.h>
3886 +#include <linux/bcma/bcma.h>
3887 +#include <asm/paccess.h>
3889 +/* Probe a 32bit value on the bus and catch bus exceptions.
3890 + * Returns nonzero on a bus exception.
3891 + * This is MIPS specific */
3892 +#define mips_busprobe32(val, addr) get_dbe((val), ((u32 *)(addr)))
3894 +/* Assume one-hot slot wiring */
3895 +#define BCMA_PCI_SLOT_MAX 16
3896 +#define PCI_CONFIG_SPACE_SIZE 256
3898 +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
3900 + struct bcma_bus *bus = pc->core->bus;
3904 + chipid_top = (bus->chipinfo.id & 0xFF00);
3905 + if (chipid_top != 0x4700 &&
3906 + chipid_top != 0x5300)
3909 + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
3910 + pr_info("This PCI core is disabled and not working\n");
3914 + bcma_core_enable(pc->core, 0);
3916 + return !mips_busprobe32(tmp, pc->core->io_addr);
3919 +static u32 bcma_pcie_read_config(struct bcma_drv_pci *pc, u32 address)
3921 + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
3922 + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
3923 + return pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_DATA);
3926 +static void bcma_pcie_write_config(struct bcma_drv_pci *pc, u32 address,
3929 + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
3930 + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
3931 + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_DATA, data);
3934 +static u32 bcma_get_cfgspace_addr(struct bcma_drv_pci *pc, unsigned int dev,
3935 + unsigned int func, unsigned int off)
3939 + /* Issue config commands only when the data link is up (atleast
3940 + * one external pcie device is present).
3942 + if (dev >= 2 || !(bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_LSREG)
3943 + & BCMA_CORE_PCI_DLLP_LSREG_LINKUP))
3946 + /* Type 0 transaction */
3947 + /* Slide the PCI window to the appropriate slot */
3948 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
3949 + /* Calculate the address */
3950 + addr = pc->host_controller->host_cfg_addr;
3951 + addr |= (dev << BCMA_CORE_PCI_CFG_SLOT_SHIFT);
3952 + addr |= (func << BCMA_CORE_PCI_CFG_FUN_SHIFT);
3953 + addr |= (off & ~3);
3959 +static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
3960 + unsigned int func, unsigned int off,
3961 + void *buf, int len)
3963 + int err = -EINVAL;
3965 + void __iomem *mmio = 0;
3967 + WARN_ON(!pc->hostmode);
3968 + if (unlikely(len != 1 && len != 2 && len != 4))
3971 + /* we support only two functions on device 0 */
3975 + /* accesses to config registers with offsets >= 256
3976 + * requires indirect access.
3978 + if (off >= PCI_CONFIG_SPACE_SIZE) {
3979 + addr = (func << 12);
3980 + addr |= (off & 0x0FFF);
3981 + val = bcma_pcie_read_config(pc, addr);
3983 + addr = BCMA_CORE_PCI_PCICFG0;
3984 + addr |= (func << 8);
3985 + addr |= (off & 0xfc);
3986 + val = pcicore_read32(pc, addr);
3989 + addr = bcma_get_cfgspace_addr(pc, dev, func, off);
3990 + if (unlikely(!addr))
3993 + mmio = ioremap_nocache(addr, len);
3997 + if (mips_busprobe32(val, mmio)) {
4002 + val = readl(mmio);
4004 + val >>= (8 * (off & 3));
4008 + *((u8 *)buf) = (u8)val;
4011 + *((u16 *)buf) = (u16)val;
4014 + *((u32 *)buf) = (u32)val;
4025 +static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
4026 + unsigned int func, unsigned int off,
4027 + const void *buf, int len)
4029 + int err = -EINVAL;
4030 + u32 addr = 0, val = 0;
4031 + void __iomem *mmio = 0;
4032 + u16 chipid = pc->core->bus->chipinfo.id;
4034 + WARN_ON(!pc->hostmode);
4035 + if (unlikely(len != 1 && len != 2 && len != 4))
4038 + /* accesses to config registers with offsets >= 256
4039 + * requires indirect access.
4041 + if (off < PCI_CONFIG_SPACE_SIZE) {
4042 + addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
4043 + addr |= (func << 8);
4044 + addr |= (off & 0xfc);
4045 + mmio = ioremap_nocache(addr, len);
4050 + addr = bcma_get_cfgspace_addr(pc, dev, func, off);
4051 + if (unlikely(!addr))
4054 + mmio = ioremap_nocache(addr, len);
4058 + if (mips_busprobe32(val, mmio)) {
4066 + val = readl(mmio);
4067 + val &= ~(0xFF << (8 * (off & 3)));
4068 + val |= *((const u8 *)buf) << (8 * (off & 3));
4071 + val = readl(mmio);
4072 + val &= ~(0xFFFF << (8 * (off & 3)));
4073 + val |= *((const u16 *)buf) << (8 * (off & 3));
4076 + val = *((const u32 *)buf);
4079 + if (dev == 0 && !addr) {
4080 + /* accesses to config registers with offsets >= 256
4081 + * requires indirect access.
4083 + addr = (func << 12);
4084 + addr |= (off & 0x0FFF);
4085 + bcma_pcie_write_config(pc, addr, val);
4087 + writel(val, mmio);
4089 + if (chipid == 0x4716 || chipid == 0x4748)
4101 +static int bcma_core_pci_hostmode_read_config(struct pci_bus *bus,
4102 + unsigned int devfn,
4103 + int reg, int size, u32 *val)
4105 + unsigned long flags;
4107 + struct bcma_drv_pci *pc;
4108 + struct bcma_drv_pci_host *pc_host;
4110 + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
4111 + pc = pc_host->pdev;
4113 + spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
4114 + err = bcma_extpci_read_config(pc, PCI_SLOT(devfn),
4115 + PCI_FUNC(devfn), reg, val, size);
4116 + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
4118 + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
4121 +static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus,
4122 + unsigned int devfn,
4123 + int reg, int size, u32 val)
4125 + unsigned long flags;
4127 + struct bcma_drv_pci *pc;
4128 + struct bcma_drv_pci_host *pc_host;
4130 + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
4131 + pc = pc_host->pdev;
4133 + spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
4134 + err = bcma_extpci_write_config(pc, PCI_SLOT(devfn),
4135 + PCI_FUNC(devfn), reg, &val, size);
4136 + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
4138 + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
4141 +/* return cap_offset if requested capability exists in the PCI config space */
4142 +static u8 __devinit bcma_find_pci_capability(struct bcma_drv_pci *pc,
4144 + unsigned int func, u8 req_cap_id,
4145 + unsigned char *buf, u32 *buflen)
4152 + /* check for Header type 0 */
4153 + bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
4155 + if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
4158 + /* check if the capability pointer field exists */
4159 + bcma_extpci_read_config(pc, dev, func, PCI_STATUS, &byte_val,
4161 + if (!(byte_val & PCI_STATUS_CAP_LIST))
4164 + /* check if the capability pointer is 0x00 */
4165 + bcma_extpci_read_config(pc, dev, func, PCI_CAPABILITY_LIST, &cap_ptr,
4167 + if (cap_ptr == 0x00)
4170 + /* loop thr'u the capability list and see if the requested capabilty
4172 + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id, sizeof(u8));
4173 + while (cap_id != req_cap_id) {
4174 + bcma_extpci_read_config(pc, dev, func, cap_ptr + 1, &cap_ptr,
4176 + if (cap_ptr == 0x00)
4178 + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id,
4182 + /* found the caller requested capability */
4183 + if ((buf != NULL) && (buflen != NULL)) {
4186 + bufsize = *buflen;
4192 + /* copy the cpability data excluding cap ID and next ptr */
4193 + cap_data = cap_ptr + 2;
4194 + if ((bufsize + cap_data) > PCI_CONFIG_SPACE_SIZE)
4195 + bufsize = PCI_CONFIG_SPACE_SIZE - cap_data;
4196 + *buflen = bufsize;
4197 + while (bufsize--) {
4198 + bcma_extpci_read_config(pc, dev, func, cap_data, buf,
4208 +/* If the root port is capable of returning Config Request
4209 + * Retry Status (CRS) Completion Status to software then
4210 + * enable the feature.
4212 +static void __devinit bcma_core_pci_enable_crs(struct bcma_drv_pci *pc)
4214 + u8 cap_ptr, root_ctrl, root_cap, dev;
4218 + cap_ptr = bcma_find_pci_capability(pc, 0, 0, PCI_CAP_ID_EXP, NULL,
4220 + root_cap = cap_ptr + PCI_EXP_RTCAP;
4221 + bcma_extpci_read_config(pc, 0, 0, root_cap, &val16, sizeof(u16));
4222 + if (val16 & BCMA_CORE_PCI_RC_CRS_VISIBILITY) {
4223 + /* Enable CRS software visibility */
4224 + root_ctrl = cap_ptr + PCI_EXP_RTCTL;
4225 + val16 = PCI_EXP_RTCTL_CRSSVE;
4226 + bcma_extpci_read_config(pc, 0, 0, root_ctrl, &val16,
4229 + /* Initiate a configuration request to read the vendor id
4230 + * field of the device function's config space header after
4231 + * 100 ms wait time from the end of Reset. If the device is
4232 + * not done with its internal initialization, it must at
4233 + * least return a completion TLP, with a completion status
4234 + * of "Configuration Request Retry Status (CRS)". The root
4235 + * complex must complete the request to the host by returning
4236 + * a read-data value of 0001h for the Vendor ID field and
4237 + * all 1s for any additional bytes included in the request.
4238 + * Poll using the config reads for max wait time of 1 sec or
4239 + * until we receive the successful completion status. Repeat
4240 + * the procedure for all the devices.
4242 + for (dev = 1; dev < BCMA_PCI_SLOT_MAX; dev++) {
4243 + for (i = 0; i < 100000; i++) {
4244 + bcma_extpci_read_config(pc, dev, 0,
4245 + PCI_VENDOR_ID, &val16,
4252 + pr_err("PCI: Broken device in slot %d\n", dev);
4257 +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
4259 + struct bcma_bus *bus = pc->core->bus;
4260 + struct bcma_drv_pci_host *pc_host;
4262 + u32 pci_membase_1G;
4263 + unsigned long io_map_base;
4265 + pr_info("PCIEcore in host mode found\n");
4267 + pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
4269 + pr_err("can not allocate memory");
4273 + pc->host_controller = pc_host;
4274 + pc_host->pci_controller.io_resource = &pc_host->io_resource;
4275 + pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
4276 + pc_host->pci_controller.pci_ops = &pc_host->pci_ops;
4277 + pc_host->pdev = pc;
4279 + pci_membase_1G = BCMA_SOC_PCI_DMA;
4280 + pc_host->host_cfg_addr = BCMA_SOC_PCI_CFG;
4282 + pc_host->pci_ops.read = bcma_core_pci_hostmode_read_config;
4283 + pc_host->pci_ops.write = bcma_core_pci_hostmode_write_config;
4285 + pc_host->mem_resource.name = "BCMA PCIcore external memory",
4286 + pc_host->mem_resource.start = BCMA_SOC_PCI_DMA;
4287 + pc_host->mem_resource.end = BCMA_SOC_PCI_DMA + BCMA_SOC_PCI_DMA_SZ - 1;
4288 + pc_host->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
4290 + pc_host->io_resource.name = "BCMA PCIcore external I/O",
4291 + pc_host->io_resource.start = 0x100;
4292 + pc_host->io_resource.end = 0x7FF;
4293 + pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
4297 + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
4299 + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
4300 + BCMA_CORE_PCI_CTL_RST_OE);
4302 + /* 64 MB I/O access window. On 4716, use
4303 + * sbtopcie0 to access the device registers. We
4304 + * can't use address match 2 (1 GB window) region
4305 + * as mips can't generate 64-bit address on the
4308 + if (bus->chipinfo.id == 0x4716 || bus->chipinfo.id == 0x4748) {
4309 + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
4310 + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
4311 + BCMA_SOC_PCI_MEM_SZ - 1;
4312 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
4313 + BCMA_CORE_PCI_SBTOPCI_MEM | BCMA_SOC_PCI_MEM);
4314 + } else if (bus->chipinfo.id == 0x5300) {
4315 + tmp = BCMA_CORE_PCI_SBTOPCI_MEM;
4316 + tmp |= BCMA_CORE_PCI_SBTOPCI_PREF;
4317 + tmp |= BCMA_CORE_PCI_SBTOPCI_BURST;
4318 + if (pc->core->core_unit == 0) {
4319 + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
4320 + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
4321 + BCMA_SOC_PCI_MEM_SZ - 1;
4322 + pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
4323 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
4324 + tmp | BCMA_SOC_PCI_MEM);
4325 + } else if (pc->core->core_unit == 1) {
4326 + pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
4327 + pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
4328 + BCMA_SOC_PCI_MEM_SZ - 1;
4329 + pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
4330 + pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
4331 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
4332 + tmp | BCMA_SOC_PCI1_MEM);
4335 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
4336 + BCMA_CORE_PCI_SBTOPCI_IO);
4338 + /* 64 MB configuration access window */
4339 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
4341 + /* 1 GB memory access window */
4342 + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI2,
4343 + BCMA_CORE_PCI_SBTOPCI_MEM | pci_membase_1G);
4346 + /* As per PCI Express Base Spec 1.1 we need to wait for
4347 + * at least 100 ms from the end of a reset (cold/warm/hot)
4348 + * before issuing configuration requests to PCI Express
4353 + bcma_core_pci_enable_crs(pc);
4355 + /* Enable PCI bridge BAR0 memory & master access */
4356 + tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
4357 + bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
4359 + /* Enable PCI interrupts */
4360 + pcicore_write32(pc, BCMA_CORE_PCI_IMASK, BCMA_CORE_PCI_IMASK_INTA);
4362 + /* Ok, ready to run, register it to the system.
4363 + * The following needs change, if we want to port hostmode
4364 + * to non-MIPS platform. */
4365 + io_map_base = (unsigned long)ioremap_nocache(BCMA_SOC_PCI_MEM,
4367 + pc_host->pci_controller.io_map_base = io_map_base;
4368 + set_io_port_base(pc_host->pci_controller.io_map_base);
4369 + /* Give some time to the PCI controller to configure itself with the new
4370 + * values. Not waiting at this point causes crashes of the machine. */
4372 + register_pci_controller(&pc_host->pci_controller);
4376 +/* Early PCI fixup for a device on the PCI-core bridge. */
4377 +static void bcma_core_pci_fixup_pcibridge(struct pci_dev *dev)
4379 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
4380 + /* This is not a device on the PCI-core bridge. */
4383 + if (PCI_SLOT(dev->devfn) != 0)
4386 + pr_info("PCI: Fixing up bridge %s\n", pci_name(dev));
4388 + /* Enable PCI bridge bus mastering and memory space */
4389 + pci_set_master(dev);
4390 + if (pcibios_enable_device(dev, ~0) < 0) {
4391 + pr_err("PCI: BCMA bridge enable failed\n");
4395 + /* Enable PCI bridge BAR1 prefetch and burst */
4396 + pci_write_config_dword(dev, BCMA_PCI_BAR1_CONTROL, 3);
4398 +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_pcibridge);
4400 +/* Early PCI fixup for all PCI-cores to set the correct memory address. */
4401 +static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
4403 + struct resource *res;
4406 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
4407 + /* This is not a device on the PCI-core bridge. */
4410 + if (PCI_SLOT(dev->devfn) == 0)
4413 + pr_info("PCI: Fixing up addresses %s\n", pci_name(dev));
4415 + for (pos = 0; pos < 6; pos++) {
4416 + res = &dev->resource[pos];
4417 + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM))
4418 + pci_assign_resource(dev, pos);
4421 +DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
4423 +/* This function is called when doing a pci_enable_device().
4424 + * We must first check if the device is a device on the PCI-core bridge. */
4425 +int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
4427 + struct bcma_drv_pci_host *pc_host;
4429 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
4430 + /* This is not a device on the PCI-core bridge. */
4433 + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
4436 + pr_info("PCI: Fixing up device %s\n", pci_name(dev));
4438 + /* Fix up interrupt lines */
4439 + dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2;
4440 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
4444 +EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
4446 +/* PCI device IRQ mapping. */
4447 +int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev)
4449 + struct bcma_drv_pci_host *pc_host;
4451 + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
4452 + /* This is not a device on the PCI-core bridge. */
4456 + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
4458 + return bcma_core_mips_irq(pc_host->pdev->core) + 2;
4460 +EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
4462 +++ b/drivers/bcma/driver_mips.c
4465 + * Broadcom specific AMBA
4466 + * Broadcom MIPS32 74K core driver
4468 + * Copyright 2009, Broadcom Corporation
4469 + * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
4470 + * Copyright 2010, Bernhard Loos <bernhardloos@googlemail.com>
4471 + * Copyright 2011, Hauke Mehrtens <hauke@hauke-m.de>
4473 + * Licensed under the GNU/GPL. See COPYING for details.
4476 +#include "bcma_private.h"
4478 +#include <linux/bcma/bcma.h>
4480 +#include <linux/serial.h>
4481 +#include <linux/serial_core.h>
4482 +#include <linux/serial_reg.h>
4483 +#include <linux/time.h>
4485 +/* The 47162a0 hangs when reading MIPS DMP registers registers */
4486 +static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
4488 + return dev->bus->chipinfo.id == 47162 && dev->bus->chipinfo.rev == 0 &&
4489 + dev->id.id == BCMA_CORE_MIPS_74K;
4492 +/* The 5357b0 hangs when reading USB20H DMP registers */
4493 +static inline bool bcma_core_mips_bcm5357b0_quirk(struct bcma_device *dev)
4495 + return (dev->bus->chipinfo.id == 0x5357 ||
4496 + dev->bus->chipinfo.id == 0x4749) &&
4497 + dev->bus->chipinfo.pkg == 11 &&
4498 + dev->id.id == BCMA_CORE_USB20_HOST;
4501 +static inline u32 mips_read32(struct bcma_drv_mips *mcore,
4504 + return bcma_read32(mcore->core, offset);
4507 +static inline void mips_write32(struct bcma_drv_mips *mcore,
4511 + bcma_write32(mcore->core, offset, value);
4514 +static const u32 ipsflag_irq_mask[] = {
4516 + BCMA_MIPS_IPSFLAG_IRQ1,
4517 + BCMA_MIPS_IPSFLAG_IRQ2,
4518 + BCMA_MIPS_IPSFLAG_IRQ3,
4519 + BCMA_MIPS_IPSFLAG_IRQ4,
4522 +static const u32 ipsflag_irq_shift[] = {
4524 + BCMA_MIPS_IPSFLAG_IRQ1_SHIFT,
4525 + BCMA_MIPS_IPSFLAG_IRQ2_SHIFT,
4526 + BCMA_MIPS_IPSFLAG_IRQ3_SHIFT,
4527 + BCMA_MIPS_IPSFLAG_IRQ4_SHIFT,
4530 +static u32 bcma_core_mips_irqflag(struct bcma_device *dev)
4534 + if (bcma_core_mips_bcm47162a0_quirk(dev))
4535 + return dev->core_index;
4536 + if (bcma_core_mips_bcm5357b0_quirk(dev))
4537 + return dev->core_index;
4538 + flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
4540 + return flag & 0x1F;
4543 +/* Get the MIPS IRQ assignment for a specified device.
4544 + * If unassigned, 0 is returned.
4546 +unsigned int bcma_core_mips_irq(struct bcma_device *dev)
4548 + struct bcma_device *mdev = dev->bus->drv_mips.core;
4552 + irqflag = bcma_core_mips_irqflag(dev);
4554 + for (irq = 1; irq <= 4; irq++)
4555 + if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
4561 +EXPORT_SYMBOL(bcma_core_mips_irq);
4563 +static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
4565 + unsigned int oldirq = bcma_core_mips_irq(dev);
4566 + struct bcma_bus *bus = dev->bus;
4567 + struct bcma_device *mdev = bus->drv_mips.core;
4570 + irqflag = bcma_core_mips_irqflag(dev);
4571 + BUG_ON(oldirq == 6);
4573 + dev->irq = irq + 2;
4575 + /* clear the old irq */
4577 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
4578 + bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
4581 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
4583 + /* assign the new one */
4585 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
4586 + bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
4589 + u32 oldirqflag = bcma_read32(mdev,
4590 + BCMA_MIPS_MIPS74K_INTMASK(irq));
4592 + struct bcma_device *core;
4594 + /* backplane irq line is in use, find out who uses
4595 + * it and set user to irq 0
4597 + list_for_each_entry_reverse(core, &bus->cores, list) {
4598 + if ((1 << bcma_core_mips_irqflag(core)) ==
4600 + bcma_core_mips_set_irq(core, 0);
4605 + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq),
4609 + pr_info("set_irq: core 0x%04x, irq %d => %d\n",
4610 + dev->id.id, oldirq + 2, irq + 2);
4613 +static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
4616 + static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
4617 + printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
4618 + for (i = 0; i <= 6; i++)
4619 + printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
4623 +static void bcma_core_mips_dump_irq(struct bcma_bus *bus)
4625 + struct bcma_device *core;
4627 + list_for_each_entry_reverse(core, &bus->cores, list) {
4628 + bcma_core_mips_print_irq(core, bcma_core_mips_irq(core));
4632 +u32 bcma_cpu_clock(struct bcma_drv_mips *mcore)
4634 + struct bcma_bus *bus = mcore->core->bus;
4636 + if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
4637 + return bcma_pmu_get_clockcpu(&bus->drv_cc);
4639 + pr_err("No PMU available, need this to get the cpu clock\n");
4642 +EXPORT_SYMBOL(bcma_cpu_clock);
4644 +static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
4646 + struct bcma_bus *bus = mcore->core->bus;
4648 + switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
4649 + case BCMA_CC_FLASHT_STSER:
4650 + case BCMA_CC_FLASHT_ATSER:
4651 + pr_err("Serial flash not supported.\n");
4653 + case BCMA_CC_FLASHT_PARA:
4654 + pr_info("found parallel flash.\n");
4655 + bus->drv_cc.pflash.window = 0x1c000000;
4656 + bus->drv_cc.pflash.window_size = 0x02000000;
4658 + if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
4659 + BCMA_CC_FLASH_CFG_DS) == 0)
4660 + bus->drv_cc.pflash.buswidth = 1;
4662 + bus->drv_cc.pflash.buswidth = 2;
4665 + pr_err("flash not supported.\n");
4669 +void bcma_core_mips_init(struct bcma_drv_mips *mcore)
4671 + struct bcma_bus *bus;
4672 + struct bcma_device *core;
4673 + bus = mcore->core->bus;
4675 + pr_info("Initializing MIPS core...\n");
4677 + if (!mcore->setup_done)
4678 + mcore->assigned_irqs = 1;
4680 + /* Assign IRQs to all cores on the bus */
4681 + list_for_each_entry_reverse(core, &bus->cores, list) {
4686 + mips_irq = bcma_core_mips_irq(core);
4690 + core->irq = mips_irq + 2;
4691 + if (core->irq > 5)
4693 + switch (core->id.id) {
4694 + case BCMA_CORE_PCI:
4695 + case BCMA_CORE_PCIE:
4696 + case BCMA_CORE_ETHERNET:
4697 + case BCMA_CORE_ETHERNET_GBIT:
4698 + case BCMA_CORE_MAC_GBIT:
4699 + case BCMA_CORE_80211:
4700 + case BCMA_CORE_USB20_HOST:
4701 + /* These devices get their own IRQ line if available,
4702 + * the rest goes on IRQ0
4704 + if (mcore->assigned_irqs <= 4)
4705 + bcma_core_mips_set_irq(core,
4706 + mcore->assigned_irqs++);
4710 + pr_info("IRQ reconfiguration done\n");
4711 + bcma_core_mips_dump_irq(bus);
4713 + if (mcore->setup_done)
4716 + bcma_chipco_serial_init(&bus->drv_cc);
4717 + bcma_core_mips_flash_detect(mcore);
4718 + mcore->setup_done = true;
4721 +++ b/drivers/bcma/host_soc.c
4724 + * Broadcom specific AMBA
4725 + * System on Chip (SoC) Host
4727 + * Licensed under the GNU/GPL. See COPYING for details.
4730 +#include "bcma_private.h"
4732 +#include <linux/bcma/bcma.h>
4733 +#include <linux/bcma/bcma_soc.h>
4735 +static u8 bcma_host_soc_read8(struct bcma_device *core, u16 offset)
4737 + return readb(core->io_addr + offset);
4740 +static u16 bcma_host_soc_read16(struct bcma_device *core, u16 offset)
4742 + return readw(core->io_addr + offset);
4745 +static u32 bcma_host_soc_read32(struct bcma_device *core, u16 offset)
4747 + return readl(core->io_addr + offset);
4750 +static void bcma_host_soc_write8(struct bcma_device *core, u16 offset,
4753 + writeb(value, core->io_addr + offset);
4756 +static void bcma_host_soc_write16(struct bcma_device *core, u16 offset,
4759 + writew(value, core->io_addr + offset);
4762 +static void bcma_host_soc_write32(struct bcma_device *core, u16 offset,
4765 + writel(value, core->io_addr + offset);
4768 +#ifdef CONFIG_BCMA_BLOCKIO
4769 +static void bcma_host_soc_block_read(struct bcma_device *core, void *buffer,
4770 + size_t count, u16 offset, u8 reg_width)
4772 + void __iomem *addr = core->io_addr + offset;
4774 + switch (reg_width) {
4775 + case sizeof(u8): {
4779 + *buf = __raw_readb(addr);
4785 + case sizeof(u16): {
4786 + __le16 *buf = buffer;
4788 + WARN_ON(count & 1);
4790 + *buf = (__force __le16)__raw_readw(addr);
4796 + case sizeof(u32): {
4797 + __le32 *buf = buffer;
4799 + WARN_ON(count & 3);
4801 + *buf = (__force __le32)__raw_readl(addr);
4812 +static void bcma_host_soc_block_write(struct bcma_device *core,
4813 + const void *buffer,
4814 + size_t count, u16 offset, u8 reg_width)
4816 + void __iomem *addr = core->io_addr + offset;
4818 + switch (reg_width) {
4819 + case sizeof(u8): {
4820 + const u8 *buf = buffer;
4823 + __raw_writeb(*buf, addr);
4829 + case sizeof(u16): {
4830 + const __le16 *buf = buffer;
4832 + WARN_ON(count & 1);
4834 + __raw_writew((__force u16)(*buf), addr);
4840 + case sizeof(u32): {
4841 + const __le32 *buf = buffer;
4843 + WARN_ON(count & 3);
4845 + __raw_writel((__force u32)(*buf), addr);
4855 +#endif /* CONFIG_BCMA_BLOCKIO */
4857 +static u32 bcma_host_soc_aread32(struct bcma_device *core, u16 offset)
4859 + return readl(core->io_wrap + offset);
4862 +static void bcma_host_soc_awrite32(struct bcma_device *core, u16 offset,
4865 + writel(value, core->io_wrap + offset);
4868 +const struct bcma_host_ops bcma_host_soc_ops = {
4869 + .read8 = bcma_host_soc_read8,
4870 + .read16 = bcma_host_soc_read16,
4871 + .read32 = bcma_host_soc_read32,
4872 + .write8 = bcma_host_soc_write8,
4873 + .write16 = bcma_host_soc_write16,
4874 + .write32 = bcma_host_soc_write32,
4875 +#ifdef CONFIG_BCMA_BLOCKIO
4876 + .block_read = bcma_host_soc_block_read,
4877 + .block_write = bcma_host_soc_block_write,
4879 + .aread32 = bcma_host_soc_aread32,
4880 + .awrite32 = bcma_host_soc_awrite32,
4883 +int __init bcma_host_soc_register(struct bcma_soc *soc)
4885 + struct bcma_bus *bus = &soc->bus;
4888 + /* iomap only first core. We have to read some register on this core
4889 + * to scan the bus.
4891 + bus->mmio = ioremap_nocache(BCMA_ADDR_BASE, BCMA_CORE_SIZE * 1);
4895 + /* Host specific */
4896 + bus->hosttype = BCMA_HOSTTYPE_SOC;
4897 + bus->ops = &bcma_host_soc_ops;
4900 + err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
4902 + iounmap(bus->mmio);
4907 +++ b/include/linux/bcma/bcma_driver_mips.h
4909 +#ifndef LINUX_BCMA_DRIVER_MIPS_H_
4910 +#define LINUX_BCMA_DRIVER_MIPS_H_
4912 +#define BCMA_MIPS_IPSFLAG 0x0F08
4913 +/* which sbflags get routed to mips interrupt 1 */
4914 +#define BCMA_MIPS_IPSFLAG_IRQ1 0x0000003F
4915 +#define BCMA_MIPS_IPSFLAG_IRQ1_SHIFT 0
4916 +/* which sbflags get routed to mips interrupt 2 */
4917 +#define BCMA_MIPS_IPSFLAG_IRQ2 0x00003F00
4918 +#define BCMA_MIPS_IPSFLAG_IRQ2_SHIFT 8
4919 +/* which sbflags get routed to mips interrupt 3 */
4920 +#define BCMA_MIPS_IPSFLAG_IRQ3 0x003F0000
4921 +#define BCMA_MIPS_IPSFLAG_IRQ3_SHIFT 16
4922 +/* which sbflags get routed to mips interrupt 4 */
4923 +#define BCMA_MIPS_IPSFLAG_IRQ4 0x3F000000
4924 +#define BCMA_MIPS_IPSFLAG_IRQ4_SHIFT 24
4926 +/* MIPS 74K core registers */
4927 +#define BCMA_MIPS_MIPS74K_CORECTL 0x0000
4928 +#define BCMA_MIPS_MIPS74K_EXCEPTBASE 0x0004
4929 +#define BCMA_MIPS_MIPS74K_BIST 0x000C
4930 +#define BCMA_MIPS_MIPS74K_INTMASK_INT0 0x0014
4931 +#define BCMA_MIPS_MIPS74K_INTMASK(int) \
4932 + ((int) * 4 + BCMA_MIPS_MIPS74K_INTMASK_INT0)
4933 +#define BCMA_MIPS_MIPS74K_NMIMASK 0x002C
4934 +#define BCMA_MIPS_MIPS74K_GPIOSEL 0x0040
4935 +#define BCMA_MIPS_MIPS74K_GPIOOUT 0x0044
4936 +#define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
4937 +#define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
4939 +#define BCMA_MIPS_OOBSELOUTA30 0x100
4941 +struct bcma_device;
4943 +struct bcma_drv_mips {
4944 + struct bcma_device *core;
4946 + unsigned int assigned_irqs;
4949 +#ifdef CONFIG_BCMA_DRIVER_MIPS
4950 +extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
4952 +static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
4955 +extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
4957 +extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
4959 +#endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
4961 +++ b/include/linux/bcma/bcma_soc.h
4963 +#ifndef LINUX_BCMA_SOC_H_
4964 +#define LINUX_BCMA_SOC_H_
4966 +#include <linux/bcma/bcma.h>
4969 + struct bcma_bus bus;
4970 + struct bcma_device core_cc;
4971 + struct bcma_device core_mips;
4974 +int __init bcma_host_soc_register(struct bcma_soc *soc);
4976 +int bcma_bus_register(struct bcma_bus *bus);
4978 +#endif /* LINUX_BCMA_SOC_H_ */