1 --- a/drivers/ssb/Kconfig
2 +++ b/drivers/ssb/Kconfig
3 @@ -66,6 +66,20 @@ config SSB_PCMCIAHOST
7 +config SSB_SDIOHOST_POSSIBLE
9 + depends on SSB && (MMC = y || MMC = SSB)
13 + bool "Support for SSB on SDIO-bus host"
14 + depends on SSB_SDIOHOST_POSSIBLE
16 + Support for a Sonics Silicon Backplane on top
22 bool "No SSB kernel messages"
23 depends on SSB && EMBEDDED
24 --- a/drivers/ssb/Makefile
25 +++ b/drivers/ssb/Makefile
26 @@ -6,6 +6,7 @@ ssb-$(CONFIG_SSB_SPROM) += sprom.o
28 ssb-$(CONFIG_SSB_PCIHOST) += pci.o pcihost_wrapper.o
29 ssb-$(CONFIG_SSB_PCMCIAHOST) += pcmcia.o
30 +ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o
33 ssb-y += driver_chipcommon.o
34 --- a/drivers/ssb/b43_pci_bridge.c
35 +++ b/drivers/ssb/b43_pci_bridge.c
36 @@ -24,6 +24,7 @@ static const struct pci_device_id b43_pc
37 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4312) },
38 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4315) },
39 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4318) },
40 + { PCI_DEVICE(PCI_VENDOR_ID_BCM_GVC, 0x4318) },
41 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4319) },
42 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4320) },
43 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) },
44 --- a/drivers/ssb/driver_chipcommon.c
45 +++ b/drivers/ssb/driver_chipcommon.c
46 @@ -46,40 +46,66 @@ void ssb_chipco_set_clockmode(struct ssb
51 + /* We support SLOW only on 6..9 */
52 + if (ccdev->id.revision >= 10 && mode == SSB_CLKMODE_SLOW)
53 + mode = SSB_CLKMODE_DYNAMIC;
55 + if (cc->capabilities & SSB_CHIPCO_CAP_PMU)
56 + return; /* PMU controls clockmode, separated function needed */
57 + SSB_WARN_ON(ccdev->id.revision >= 20);
59 /* chipcommon cores prior to rev6 don't support dynamic clock control */
60 if (ccdev->id.revision < 6)
62 - /* chipcommon cores rev10 are a whole new ball game */
64 + /* ChipCommon cores rev10+ need testing */
65 if (ccdev->id.revision >= 10)
68 if (!(cc->capabilities & SSB_CHIPCO_CAP_PCTL))
72 - case SSB_CLKMODE_SLOW:
73 + case SSB_CLKMODE_SLOW: /* For revs 6..9 only */
74 tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
75 tmp |= SSB_CHIPCO_SLOWCLKCTL_FSLOW;
76 chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
78 case SSB_CLKMODE_FAST:
79 - ssb_pci_xtal(bus, SSB_GPIO_XTAL, 1); /* Force crystal on */
80 - tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
81 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
82 - tmp |= SSB_CHIPCO_SLOWCLKCTL_IPLL;
83 - chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
84 + if (ccdev->id.revision < 10) {
85 + ssb_pci_xtal(bus, SSB_GPIO_XTAL, 1); /* Force crystal on */
86 + tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
87 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
88 + tmp |= SSB_CHIPCO_SLOWCLKCTL_IPLL;
89 + chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
91 + chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
92 + (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) |
93 + SSB_CHIPCO_SYSCLKCTL_FORCEHT));
94 + /* udelay(150); TODO: not available in early init */
97 case SSB_CLKMODE_DYNAMIC:
98 - tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
99 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
100 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_IPLL;
101 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
102 - if ((tmp & SSB_CHIPCO_SLOWCLKCTL_SRC) != SSB_CHIPCO_SLOWCLKCTL_SRC_XTAL)
103 - tmp |= SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
104 - chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
106 - /* for dynamic control, we have to release our xtal_pu "force on" */
107 - if (tmp & SSB_CHIPCO_SLOWCLKCTL_ENXTAL)
108 - ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
109 + if (ccdev->id.revision < 10) {
110 + tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
111 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
112 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_IPLL;
113 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
114 + if ((tmp & SSB_CHIPCO_SLOWCLKCTL_SRC) !=
115 + SSB_CHIPCO_SLOWCLKCTL_SRC_XTAL)
116 + tmp |= SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
117 + chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
119 + /* For dynamic control, we have to release our xtal_pu
121 + if (tmp & SSB_CHIPCO_SLOWCLKCTL_ENXTAL)
122 + ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
124 + chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
125 + (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) &
126 + ~SSB_CHIPCO_SYSCLKCTL_FORCEHT));
131 @@ -209,6 +235,24 @@ static void chipco_powercontrol_init(str
135 +/* http://bcm-v4.sipsolutions.net/802.11/PmuFastPwrupDelay */
136 +static u16 pmu_fast_powerup_delay(struct ssb_chipcommon *cc)
138 + struct ssb_bus *bus = cc->dev->bus;
140 + switch (bus->chip_id) {
152 +/* http://bcm-v4.sipsolutions.net/802.11/ClkctlFastPwrupDelay */
153 static void calc_fast_powerup_delay(struct ssb_chipcommon *cc)
155 struct ssb_bus *bus = cc->dev->bus;
156 @@ -218,6 +262,12 @@ static void calc_fast_powerup_delay(stru
158 if (bus->bustype != SSB_BUSTYPE_PCI)
161 + if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
162 + cc->fast_pwrup_delay = pmu_fast_powerup_delay(cc);
166 if (!(cc->capabilities & SSB_CHIPCO_CAP_PCTL))
169 @@ -233,6 +283,15 @@ void ssb_chipcommon_init(struct ssb_chip
172 return; /* We don't have a ChipCommon */
173 + if (cc->dev->id.revision >= 11)
174 + cc->status = chipco_read32(cc, SSB_CHIPCO_CHIPSTAT);
175 + ssb_dprintk(KERN_INFO PFX "chipcommon status is 0x%x\n", cc->status);
177 + if (cc->dev->id.revision >= 20) {
178 + chipco_write32(cc, SSB_CHIPCO_GPIOPULLUP, 0);
179 + chipco_write32(cc, SSB_CHIPCO_GPIOPULLDOWN, 0);
183 chipco_powercontrol_init(cc);
184 ssb_chipco_set_clockmode(cc, SSB_CLKMODE_FAST);
185 @@ -370,6 +429,7 @@ u32 ssb_chipco_gpio_control(struct ssb_c
187 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
189 +EXPORT_SYMBOL(ssb_chipco_gpio_control);
191 u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value)
193 --- a/drivers/ssb/driver_chipcommon_pmu.c
194 +++ b/drivers/ssb/driver_chipcommon_pmu.c
195 @@ -28,6 +28,21 @@ static void ssb_chipco_pll_write(struct
196 chipco_write32(cc, SSB_CHIPCO_PLLCTL_DATA, value);
199 +static void ssb_chipco_regctl_maskset(struct ssb_chipcommon *cc,
200 + u32 offset, u32 mask, u32 set)
204 + chipco_read32(cc, SSB_CHIPCO_REGCTL_ADDR);
205 + chipco_write32(cc, SSB_CHIPCO_REGCTL_ADDR, offset);
206 + chipco_read32(cc, SSB_CHIPCO_REGCTL_ADDR);
207 + value = chipco_read32(cc, SSB_CHIPCO_REGCTL_DATA);
210 + chipco_write32(cc, SSB_CHIPCO_REGCTL_DATA, value);
211 + chipco_read32(cc, SSB_CHIPCO_REGCTL_DATA);
214 struct pmu0_plltab_entry {
215 u16 freq; /* Crystal frequency in kHz.*/
216 u8 xf; /* Crystal frequency value for PMU control */
217 @@ -317,6 +332,12 @@ static void ssb_pmu_pll_init(struct ssb_
219 ssb_pmu0_pllinit_r0(cc, crystalfreq);
222 + if (cc->pmu.rev == 2) {
223 + chipco_write32(cc, SSB_CHIPCO_PLLCTL_ADDR, 0x0000000A);
224 + chipco_write32(cc, SSB_CHIPCO_PLLCTL_DATA, 0x380005C0);
228 ssb_printk(KERN_ERR PFX
229 "ERROR: PLL init unknown for device %04X\n",
230 @@ -396,12 +417,15 @@ static void ssb_pmu_resources_init(struc
231 u32 min_msk = 0, max_msk = 0;
233 const struct pmu_res_updown_tab_entry *updown_tab = NULL;
234 - unsigned int updown_tab_size;
235 + unsigned int updown_tab_size = 0;
236 const struct pmu_res_depend_tab_entry *depend_tab = NULL;
237 - unsigned int depend_tab_size;
238 + unsigned int depend_tab_size = 0;
240 switch (bus->chip_id) {
245 /* We keep the default settings:
248 @@ -480,9 +504,9 @@ static void ssb_pmu_resources_init(struc
249 chipco_write32(cc, SSB_CHIPCO_PMU_MAXRES_MSK, max_msk);
252 +/* http://bcm-v4.sipsolutions.net/802.11/SSB/PmuInit */
253 void ssb_pmu_init(struct ssb_chipcommon *cc)
255 - struct ssb_bus *bus = cc->dev->bus;
258 if (!(cc->capabilities & SSB_CHIPCO_CAP_PMU))
259 @@ -494,15 +518,91 @@ void ssb_pmu_init(struct ssb_chipcommon
260 ssb_dprintk(KERN_DEBUG PFX "Found rev %u PMU (capabilities 0x%08X)\n",
261 cc->pmu.rev, pmucap);
263 - if (cc->pmu.rev >= 1) {
264 - if ((bus->chip_id == 0x4325) && (bus->chip_rev < 2)) {
265 - chipco_mask32(cc, SSB_CHIPCO_PMU_CTL,
266 - ~SSB_CHIPCO_PMU_CTL_NOILPONW);
268 - chipco_set32(cc, SSB_CHIPCO_PMU_CTL,
269 - SSB_CHIPCO_PMU_CTL_NOILPONW);
272 + if (cc->pmu.rev == 1)
273 + chipco_mask32(cc, SSB_CHIPCO_PMU_CTL,
274 + ~SSB_CHIPCO_PMU_CTL_NOILPONW);
276 + chipco_set32(cc, SSB_CHIPCO_PMU_CTL,
277 + SSB_CHIPCO_PMU_CTL_NOILPONW);
278 ssb_pmu_pll_init(cc);
279 ssb_pmu_resources_init(cc);
282 +void ssb_pmu_set_ldo_voltage(struct ssb_chipcommon *cc,
283 + enum ssb_pmu_ldo_volt_id id, u32 voltage)
285 + struct ssb_bus *bus = cc->dev->bus;
286 + u32 addr, shift, mask;
288 + switch (bus->chip_id) {
318 + if (SSB_WARN_ON(id != LDO_PAREF))
328 + ssb_chipco_regctl_maskset(cc, addr, ~(mask << shift),
329 + (voltage & mask) << shift);
332 +void ssb_pmu_set_ldo_paref(struct ssb_chipcommon *cc, bool on)
334 + struct ssb_bus *bus = cc->dev->bus;
337 + switch (bus->chip_id) {
339 + ldo = SSB_PMURES_4312_PA_REF_LDO;
342 + ldo = SSB_PMURES_4328_PA_REF_LDO;
345 + ldo = SSB_PMURES_5354_PA_REF_LDO;
352 + chipco_set32(cc, SSB_CHIPCO_PMU_MINRES_MSK, 1 << ldo);
354 + chipco_mask32(cc, SSB_CHIPCO_PMU_MINRES_MSK, ~(1 << ldo));
355 + chipco_read32(cc, SSB_CHIPCO_PMU_MINRES_MSK); //SPEC FIXME found via mmiotrace - dummy read?
358 +EXPORT_SYMBOL(ssb_pmu_set_ldo_voltage);
359 +EXPORT_SYMBOL(ssb_pmu_set_ldo_paref);
360 --- a/drivers/ssb/driver_gige.c
361 +++ b/drivers/ssb/driver_gige.c
363 #include <linux/ssb/ssb_driver_gige.h>
364 #include <linux/pci.h>
365 #include <linux/pci_regs.h>
366 +#include <linux/slab.h>
370 @@ -105,8 +106,9 @@ void gige_pcicfg_write32(struct ssb_gige
371 gige_write32(dev, SSB_GIGE_PCICFG + offset, value);
374 -static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn,
375 - int reg, int size, u32 *val)
376 +static int __devinit ssb_gige_pci_read_config(struct pci_bus *bus,
377 + unsigned int devfn, int reg,
378 + int size, u32 *val)
380 struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
382 @@ -135,8 +137,9 @@ static int ssb_gige_pci_read_config(stru
383 return PCIBIOS_SUCCESSFUL;
386 -static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn,
387 - int reg, int size, u32 val)
388 +static int __devinit ssb_gige_pci_write_config(struct pci_bus *bus,
389 + unsigned int devfn, int reg,
392 struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
394 @@ -165,7 +168,8 @@ static int ssb_gige_pci_write_config(str
395 return PCIBIOS_SUCCESSFUL;
398 -static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
399 +static int __devinit ssb_gige_probe(struct ssb_device *sdev,
400 + const struct ssb_device_id *id)
402 struct ssb_gige *dev;
403 u32 base, tmslow, tmshigh;
404 --- a/drivers/ssb/driver_mipscore.c
405 +++ b/drivers/ssb/driver_mipscore.c
406 @@ -270,7 +270,6 @@ void ssb_mipscore_init(struct ssb_mipsco
412 case SSB_DEV_ETHERNET:
413 case SSB_DEV_ETHERNET_GBIT:
414 @@ -281,6 +280,10 @@ void ssb_mipscore_init(struct ssb_mipsco
419 + case SSB_DEV_EXTIF:
424 ssb_dprintk(KERN_INFO PFX "after irq reconfiguration\n");
425 --- a/drivers/ssb/driver_pcicore.c
426 +++ b/drivers/ssb/driver_pcicore.c
429 #include "ssb_private.h"
431 +static u32 ssb_pcie_read(struct ssb_pcicore *pc, u32 address);
432 +static void ssb_pcie_write(struct ssb_pcicore *pc, u32 address, u32 data);
433 +static u16 ssb_pcie_mdio_read(struct ssb_pcicore *pc, u8 device, u8 address);
434 +static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
435 + u8 address, u16 data);
438 u32 pcicore_read32(struct ssb_pcicore *pc, u16 offset)
439 @@ -246,20 +251,12 @@ static struct pci_controller ssb_pcicore
440 .pci_ops = &ssb_pcicore_pciops,
441 .io_resource = &ssb_pcicore_io_resource,
442 .mem_resource = &ssb_pcicore_mem_resource,
443 - .mem_offset = 0x24000000,
446 -static u32 ssb_pcicore_pcibus_iobase = 0x100;
447 -static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
449 /* This function is called when doing a pci_enable_device().
450 * We must first check if the device is a device on the PCI-core bridge. */
451 int ssb_pcicore_plat_dev_init(struct pci_dev *d)
453 - struct resource *res;
457 if (d->bus->ops != &ssb_pcicore_pciops) {
458 /* This is not a device on the PCI-core bridge. */
460 @@ -268,27 +265,6 @@ int ssb_pcicore_plat_dev_init(struct pci
461 ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
464 - /* Fix up resource bases */
465 - for (pos = 0; pos < 6; pos++) {
466 - res = &d->resource[pos];
467 - if (res->flags & IORESOURCE_IO)
468 - base = &ssb_pcicore_pcibus_iobase;
470 - base = &ssb_pcicore_pcibus_membase;
471 - res->flags |= IORESOURCE_PCI_FIXED;
473 - size = res->end - res->start + 1;
474 - if (*base & (size - 1))
475 - *base = (*base + size) & ~(size - 1);
476 - res->start = *base;
477 - res->end = res->start + size - 1;
479 - pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
481 - /* Fix up PCI bridge BAR0 only */
482 - if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
485 /* Fix up interrupt lines */
486 d->irq = ssb_mips_irq(extpci_core->dev) + 2;
487 pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
488 @@ -338,7 +314,7 @@ int ssb_pcicore_pcibios_map_irq(const st
489 return ssb_mips_irq(extpci_core->dev) + 2;
492 -static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
493 +static void __devinit ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
497 @@ -403,7 +379,7 @@ static void ssb_pcicore_init_hostmode(st
498 register_pci_controller(&ssb_pcicore_controller);
501 -static int pcicore_is_in_hostmode(struct ssb_pcicore *pc)
502 +static int __devinit pcicore_is_in_hostmode(struct ssb_pcicore *pc)
504 struct ssb_bus *bus = pc->dev->bus;
506 @@ -432,25 +408,133 @@ static int pcicore_is_in_hostmode(struct
508 #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
510 +/**************************************************
512 + **************************************************/
514 +static void __devinit ssb_pcicore_fix_sprom_core_index(struct ssb_pcicore *pc)
516 + u16 tmp = pcicore_read16(pc, SSB_PCICORE_SPROM(0));
517 + if (((tmp & 0xF000) >> 12) != pc->dev->core_index) {
519 + tmp |= (pc->dev->core_index << 12);
520 + pcicore_write16(pc, SSB_PCICORE_SPROM(0), tmp);
524 +static u8 ssb_pcicore_polarity_workaround(struct ssb_pcicore *pc)
526 + return (ssb_pcie_read(pc, 0x204) & 0x10) ? 0xC0 : 0x80;
529 +static void ssb_pcicore_serdes_workaround(struct ssb_pcicore *pc)
531 + const u8 serdes_pll_device = 0x1D;
532 + const u8 serdes_rx_device = 0x1F;
535 + ssb_pcie_mdio_write(pc, serdes_rx_device, 1 /* Control */,
536 + ssb_pcicore_polarity_workaround(pc));
537 + tmp = ssb_pcie_mdio_read(pc, serdes_pll_device, 1 /* Control */);
539 + ssb_pcie_mdio_write(pc, serdes_pll_device, 1, tmp & ~0x4000);
542 +static void ssb_pcicore_pci_setup_workarounds(struct ssb_pcicore *pc)
544 + struct ssb_device *pdev = pc->dev;
545 + struct ssb_bus *bus = pdev->bus;
548 + tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
549 + tmp |= SSB_PCICORE_SBTOPCI_PREF;
550 + tmp |= SSB_PCICORE_SBTOPCI_BURST;
551 + pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
553 + if (pdev->id.revision < 5) {
554 + tmp = ssb_read32(pdev, SSB_IMCFGLO);
555 + tmp &= ~SSB_IMCFGLO_SERTO;
557 + tmp &= ~SSB_IMCFGLO_REQTO;
558 + tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
559 + ssb_write32(pdev, SSB_IMCFGLO, tmp);
560 + ssb_commit_settings(bus);
561 + } else if (pdev->id.revision >= 11) {
562 + tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
563 + tmp |= SSB_PCICORE_SBTOPCI_MRM;
564 + pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
568 +static void ssb_pcicore_pcie_setup_workarounds(struct ssb_pcicore *pc)
571 + u8 rev = pc->dev->id.revision;
573 + if (rev == 0 || rev == 1) {
574 + /* TLP Workaround register. */
575 + tmp = ssb_pcie_read(pc, 0x4);
577 + ssb_pcie_write(pc, 0x4, tmp);
580 + /* DLLP Link Control register. */
581 + tmp = ssb_pcie_read(pc, 0x100);
583 + ssb_pcie_write(pc, 0x100, tmp);
587 + const u8 serdes_rx_device = 0x1F;
589 + ssb_pcie_mdio_write(pc, serdes_rx_device,
590 + 2 /* Timer */, 0x8128);
591 + ssb_pcie_mdio_write(pc, serdes_rx_device,
592 + 6 /* CDR */, 0x0100);
593 + ssb_pcie_mdio_write(pc, serdes_rx_device,
594 + 7 /* CDR BW */, 0x1466);
595 + } else if (rev == 3 || rev == 4 || rev == 5) {
596 + /* TODO: DLLP Power Management Threshold */
597 + ssb_pcicore_serdes_workaround(pc);
599 + } else if (rev == 7) {
600 + /* TODO: No PLL down */
604 + /* Miscellaneous Configuration Fixup */
605 + tmp = pcicore_read16(pc, SSB_PCICORE_SPROM(5));
606 + if (!(tmp & 0x8000))
607 + pcicore_write16(pc, SSB_PCICORE_SPROM(5),
612 /**************************************************
613 * Generic and Clientmode operation code.
614 **************************************************/
616 -static void ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
617 +static void __devinit ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
619 + ssb_pcicore_fix_sprom_core_index(pc);
621 /* Disable PCI interrupts. */
622 ssb_write32(pc->dev, SSB_INTVEC, 0);
624 + /* Additional PCIe always once-executed workarounds */
625 + if (pc->dev->id.coreid == SSB_DEV_PCIE) {
626 + ssb_pcicore_serdes_workaround(pc);
628 + /* TODO: Clock Request Update */
632 -void ssb_pcicore_init(struct ssb_pcicore *pc)
633 +void __devinit ssb_pcicore_init(struct ssb_pcicore *pc)
635 struct ssb_device *dev = pc->dev;
636 - struct ssb_bus *bus;
641 if (!ssb_device_is_enabled(dev))
642 ssb_device_enable(dev, 0);
644 @@ -475,58 +559,104 @@ static void ssb_pcie_write(struct ssb_pc
645 pcicore_write32(pc, 0x134, data);
648 -static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
649 - u8 address, u16 data)
650 +static void ssb_pcie_mdio_set_phy(struct ssb_pcicore *pc, u8 phy)
652 const u16 mdio_control = 0x128;
653 const u16 mdio_data = 0x12C;
657 + v = (1 << 30); /* Start of Transaction */
658 + v |= (1 << 28); /* Write Transaction */
659 + v |= (1 << 17); /* Turnaround */
662 + pcicore_write32(pc, mdio_data, v);
665 + for (i = 0; i < 200; i++) {
666 + v = pcicore_read32(pc, mdio_control);
667 + if (v & 0x100 /* Trans complete */)
673 +static u16 ssb_pcie_mdio_read(struct ssb_pcicore *pc, u8 device, u8 address)
675 + const u16 mdio_control = 0x128;
676 + const u16 mdio_data = 0x12C;
677 + int max_retries = 10;
682 v = 0x80; /* Enable Preamble Sequence */
683 v |= 0x2; /* MDIO Clock Divisor */
684 pcicore_write32(pc, mdio_control, v);
686 + if (pc->dev->id.revision >= 10) {
688 + ssb_pcie_mdio_set_phy(pc, device);
691 v = (1 << 30); /* Start of Transaction */
692 - v |= (1 << 28); /* Write Transaction */
693 + v |= (1 << 29); /* Read Transaction */
694 v |= (1 << 17); /* Turnaround */
695 - v |= (u32)device << 22;
696 + if (pc->dev->id.revision < 10)
697 + v |= (u32)device << 22;
698 v |= (u32)address << 18;
700 pcicore_write32(pc, mdio_data, v);
701 /* Wait for the device to complete the transaction */
703 - for (i = 0; i < 10; i++) {
704 + for (i = 0; i < max_retries; i++) {
705 v = pcicore_read32(pc, mdio_control);
706 - if (v & 0x100 /* Trans complete */)
707 + if (v & 0x100 /* Trans complete */) {
709 + ret = pcicore_read32(pc, mdio_data);
714 pcicore_write32(pc, mdio_control, 0);
718 -static void ssb_broadcast_value(struct ssb_device *dev,
719 - u32 address, u32 data)
720 +static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
721 + u8 address, u16 data)
723 - /* This is used for both, PCI and ChipCommon core, so be careful. */
724 - BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
725 - BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
726 + const u16 mdio_control = 0x128;
727 + const u16 mdio_data = 0x12C;
728 + int max_retries = 10;
732 - ssb_write32(dev, SSB_PCICORE_BCAST_ADDR, address);
733 - ssb_read32(dev, SSB_PCICORE_BCAST_ADDR); /* flush */
734 - ssb_write32(dev, SSB_PCICORE_BCAST_DATA, data);
735 - ssb_read32(dev, SSB_PCICORE_BCAST_DATA); /* flush */
737 + v = 0x80; /* Enable Preamble Sequence */
738 + v |= 0x2; /* MDIO Clock Divisor */
739 + pcicore_write32(pc, mdio_control, v);
741 -static void ssb_commit_settings(struct ssb_bus *bus)
743 - struct ssb_device *dev;
744 + if (pc->dev->id.revision >= 10) {
746 + ssb_pcie_mdio_set_phy(pc, device);
749 - dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
752 - /* This forces an update of the cached registers. */
753 - ssb_broadcast_value(dev, 0xFD8, 0);
754 + v = (1 << 30); /* Start of Transaction */
755 + v |= (1 << 28); /* Write Transaction */
756 + v |= (1 << 17); /* Turnaround */
757 + if (pc->dev->id.revision < 10)
758 + v |= (u32)device << 22;
759 + v |= (u32)address << 18;
761 + pcicore_write32(pc, mdio_data, v);
762 + /* Wait for the device to complete the transaction */
764 + for (i = 0; i < max_retries; i++) {
765 + v = pcicore_read32(pc, mdio_control);
766 + if (v & 0x100 /* Trans complete */)
770 + pcicore_write32(pc, mdio_control, 0);
773 int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
774 @@ -551,13 +681,13 @@ int ssb_pcicore_dev_irqvecs_enable(struc
775 might_sleep_if(pdev->id.coreid != SSB_DEV_PCI);
777 /* Enable interrupts for this device. */
778 - if (bus->host_pci &&
779 - ((pdev->id.revision >= 6) || (pdev->id.coreid == SSB_DEV_PCIE))) {
780 + if ((pdev->id.revision >= 6) || (pdev->id.coreid == SSB_DEV_PCIE)) {
783 /* Calculate the "coremask" for the device. */
784 coremask = (1 << dev->core_index);
786 + SSB_WARN_ON(bus->bustype != SSB_BUSTYPE_PCI);
787 err = pci_read_config_dword(bus->host_pci, SSB_PCI_IRQMASK, &tmp);
790 @@ -579,48 +709,10 @@ int ssb_pcicore_dev_irqvecs_enable(struc
793 if (pdev->id.coreid == SSB_DEV_PCI) {
794 - tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
795 - tmp |= SSB_PCICORE_SBTOPCI_PREF;
796 - tmp |= SSB_PCICORE_SBTOPCI_BURST;
797 - pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
799 - if (pdev->id.revision < 5) {
800 - tmp = ssb_read32(pdev, SSB_IMCFGLO);
801 - tmp &= ~SSB_IMCFGLO_SERTO;
803 - tmp &= ~SSB_IMCFGLO_REQTO;
804 - tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
805 - ssb_write32(pdev, SSB_IMCFGLO, tmp);
806 - ssb_commit_settings(bus);
807 - } else if (pdev->id.revision >= 11) {
808 - tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
809 - tmp |= SSB_PCICORE_SBTOPCI_MRM;
810 - pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
812 + ssb_pcicore_pci_setup_workarounds(pc);
814 WARN_ON(pdev->id.coreid != SSB_DEV_PCIE);
815 - //TODO: Better make defines for all these magic PCIE values.
816 - if ((pdev->id.revision == 0) || (pdev->id.revision == 1)) {
817 - /* TLP Workaround register. */
818 - tmp = ssb_pcie_read(pc, 0x4);
820 - ssb_pcie_write(pc, 0x4, tmp);
822 - if (pdev->id.revision == 0) {
823 - const u8 serdes_rx_device = 0x1F;
825 - ssb_pcie_mdio_write(pc, serdes_rx_device,
826 - 2 /* Timer */, 0x8128);
827 - ssb_pcie_mdio_write(pc, serdes_rx_device,
828 - 6 /* CDR */, 0x0100);
829 - ssb_pcie_mdio_write(pc, serdes_rx_device,
830 - 7 /* CDR BW */, 0x1466);
831 - } else if (pdev->id.revision == 1) {
832 - /* DLLP Link Control register. */
833 - tmp = ssb_pcie_read(pc, 0x100);
835 - ssb_pcie_write(pc, 0x100, tmp);
837 + ssb_pcicore_pcie_setup_workarounds(pc);
841 --- a/drivers/ssb/main.c
842 +++ b/drivers/ssb/main.c
844 #include <linux/ssb/ssb_driver_gige.h>
845 #include <linux/dma-mapping.h>
846 #include <linux/pci.h>
847 +#include <linux/mmc/sdio_func.h>
848 +#include <linux/slab.h>
850 #include <pcmcia/cs_types.h>
851 #include <pcmcia/cs.h>
852 @@ -88,6 +90,25 @@ found:
854 #endif /* CONFIG_SSB_PCMCIAHOST */
856 +#ifdef CONFIG_SSB_SDIOHOST
857 +struct ssb_bus *ssb_sdio_func_to_bus(struct sdio_func *func)
859 + struct ssb_bus *bus;
862 + list_for_each_entry(bus, &buses, list) {
863 + if (bus->bustype == SSB_BUSTYPE_SDIO &&
864 + bus->host_sdio == func)
869 + ssb_buses_unlock();
873 +#endif /* CONFIG_SSB_SDIOHOST */
875 int ssb_for_each_bus_call(unsigned long data,
876 int (*func)(struct ssb_bus *bus, unsigned long data))
878 @@ -120,6 +141,19 @@ static void ssb_device_put(struct ssb_de
879 put_device(dev->dev);
882 +static inline struct ssb_driver *ssb_driver_get(struct ssb_driver *drv)
885 + get_driver(&drv->drv);
889 +static inline void ssb_driver_put(struct ssb_driver *drv)
892 + put_driver(&drv->drv);
895 static int ssb_device_resume(struct device *dev)
897 struct ssb_device *ssb_dev = dev_to_ssb_dev(dev);
898 @@ -190,90 +224,81 @@ int ssb_bus_suspend(struct ssb_bus *bus)
899 EXPORT_SYMBOL(ssb_bus_suspend);
901 #ifdef CONFIG_SSB_SPROM
902 -int ssb_devices_freeze(struct ssb_bus *bus)
903 +/** ssb_devices_freeze - Freeze all devices on the bus.
905 + * After freezing no device driver will be handling a device
906 + * on this bus anymore. ssb_devices_thaw() must be called after
907 + * a successful freeze to reactivate the devices.
910 + * @ctx: Context structure. Pass this to ssb_devices_thaw().
912 +int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx)
914 - struct ssb_device *dev;
915 - struct ssb_driver *drv;
918 - pm_message_t state = PMSG_FREEZE;
919 + struct ssb_device *sdev;
920 + struct ssb_driver *sdrv;
923 + memset(ctx, 0, sizeof(*ctx));
925 + SSB_WARN_ON(bus->nr_devices > ARRAY_SIZE(ctx->device_frozen));
927 - /* First check that we are capable to freeze all devices. */
928 for (i = 0; i < bus->nr_devices; i++) {
929 - dev = &(bus->devices[i]);
931 - !dev->dev->driver ||
932 - !device_is_registered(dev->dev))
934 - drv = drv_to_ssb_drv(dev->dev->driver);
936 + sdev = ssb_device_get(&bus->devices[i]);
938 + if (!sdev->dev || !sdev->dev->driver ||
939 + !device_is_registered(sdev->dev)) {
940 + ssb_device_put(sdev);
942 - if (!drv->suspend) {
943 - /* Nope, can't suspend this one. */
944 - return -EOPNOTSUPP;
947 - /* Now suspend all devices */
948 - for (i = 0; i < bus->nr_devices; i++) {
949 - dev = &(bus->devices[i]);
951 - !dev->dev->driver ||
952 - !device_is_registered(dev->dev))
954 - drv = drv_to_ssb_drv(dev->dev->driver);
956 + sdrv = ssb_driver_get(drv_to_ssb_drv(sdev->dev->driver));
957 + if (!sdrv || SSB_WARN_ON(!sdrv->remove)) {
958 + ssb_device_put(sdev);
960 - err = drv->suspend(dev, state);
962 - ssb_printk(KERN_ERR PFX "Failed to freeze device %s\n",
963 - dev_name(dev->dev));
966 + sdrv->remove(sdev);
967 + ctx->device_frozen[i] = 1;
972 - for (i--; i >= 0; i--) {
973 - dev = &(bus->devices[i]);
975 - !dev->dev->driver ||
976 - !device_is_registered(dev->dev))
978 - drv = drv_to_ssb_drv(dev->dev->driver);
987 -int ssb_devices_thaw(struct ssb_bus *bus)
988 +/** ssb_devices_thaw - Unfreeze all devices on the bus.
990 + * This will re-attach the device drivers and re-init the devices.
992 + * @ctx: The context structure from ssb_devices_freeze()
994 +int ssb_devices_thaw(struct ssb_freeze_context *ctx)
996 - struct ssb_device *dev;
997 - struct ssb_driver *drv;
1000 + struct ssb_bus *bus = ctx->bus;
1001 + struct ssb_device *sdev;
1002 + struct ssb_driver *sdrv;
1004 + int err, result = 0;
1006 for (i = 0; i < bus->nr_devices; i++) {
1007 - dev = &(bus->devices[i]);
1009 - !dev->dev->driver ||
1010 - !device_is_registered(dev->dev))
1011 + if (!ctx->device_frozen[i])
1013 - drv = drv_to_ssb_drv(dev->dev->driver);
1015 + sdev = &bus->devices[i];
1017 + if (SSB_WARN_ON(!sdev->dev || !sdev->dev->driver))
1019 - if (SSB_WARN_ON(!drv->resume))
1020 + sdrv = drv_to_ssb_drv(sdev->dev->driver);
1021 + if (SSB_WARN_ON(!sdrv || !sdrv->probe))
1023 - err = drv->resume(dev);
1025 + err = sdrv->probe(sdev, &sdev->id);
1027 ssb_printk(KERN_ERR PFX "Failed to thaw device %s\n",
1028 - dev_name(dev->dev));
1029 + dev_name(sdev->dev));
1032 + ssb_driver_put(sdrv);
1033 + ssb_device_put(sdev);
1039 #endif /* CONFIG_SSB_SPROM */
1041 @@ -360,6 +385,35 @@ static int ssb_device_uevent(struct devi
1042 ssb_dev->id.revision);
1045 +#define ssb_config_attr(attrib, field, format_string) \
1047 +attrib##_show(struct device *dev, struct device_attribute *attr, char *buf) \
1049 + return sprintf(buf, format_string, dev_to_ssb_dev(dev)->field); \
1052 +ssb_config_attr(core_num, core_index, "%u\n")
1053 +ssb_config_attr(coreid, id.coreid, "0x%04x\n")
1054 +ssb_config_attr(vendor, id.vendor, "0x%04x\n")
1055 +ssb_config_attr(revision, id.revision, "%u\n")
1056 +ssb_config_attr(irq, irq, "%u\n")
1058 +name_show(struct device *dev, struct device_attribute *attr, char *buf)
1060 + return sprintf(buf, "%s\n",
1061 + ssb_core_name(dev_to_ssb_dev(dev)->id.coreid));
1064 +static struct device_attribute ssb_device_attrs[] = {
1066 + __ATTR_RO(core_num),
1067 + __ATTR_RO(coreid),
1068 + __ATTR_RO(vendor),
1069 + __ATTR_RO(revision),
1074 static struct bus_type ssb_bustype = {
1076 .match = ssb_bus_match,
1077 @@ -369,6 +423,7 @@ static struct bus_type ssb_bustype = {
1078 .suspend = ssb_device_suspend,
1079 .resume = ssb_device_resume,
1080 .uevent = ssb_device_uevent,
1081 + .dev_attrs = ssb_device_attrs,
1084 static void ssb_buses_lock(void)
1085 @@ -461,6 +516,7 @@ static int ssb_devices_register(struct s
1086 #ifdef CONFIG_SSB_PCIHOST
1087 sdev->irq = bus->host_pci->irq;
1088 dev->parent = &bus->host_pci->dev;
1089 + sdev->dma_dev = dev->parent;
1092 case SSB_BUSTYPE_PCMCIA:
1093 @@ -469,8 +525,14 @@ static int ssb_devices_register(struct s
1094 dev->parent = &bus->host_pcmcia->dev;
1097 + case SSB_BUSTYPE_SDIO:
1098 +#ifdef CONFIG_SSB_SDIOHOST
1099 + dev->parent = &bus->host_sdio->dev;
1102 case SSB_BUSTYPE_SSB:
1103 dev->dma_mask = &dev->coherent_dma_mask;
1104 + sdev->dma_dev = dev;
1108 @@ -497,7 +559,7 @@ error:
1111 /* Needs ssb_buses_lock() */
1112 -static int ssb_attach_queued_buses(void)
1113 +static int __devinit ssb_attach_queued_buses(void)
1115 struct ssb_bus *bus, *n;
1117 @@ -708,9 +770,9 @@ out:
1121 -static int ssb_bus_register(struct ssb_bus *bus,
1122 - ssb_invariants_func_t get_invariants,
1123 - unsigned long baseaddr)
1124 +static int __devinit ssb_bus_register(struct ssb_bus *bus,
1125 + ssb_invariants_func_t get_invariants,
1126 + unsigned long baseaddr)
1130 @@ -724,12 +786,18 @@ static int ssb_bus_register(struct ssb_b
1131 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1);
1135 + /* Init SDIO-host device (if any), before the scan */
1136 + err = ssb_sdio_init(bus);
1138 + goto err_disable_xtal;
1141 bus->busnumber = next_busnumber;
1142 /* Scan for devices (cores) */
1143 err = ssb_bus_scan(bus, baseaddr);
1145 - goto err_disable_xtal;
1146 + goto err_sdio_exit;
1148 /* Init PCI-host device (if any) */
1149 err = ssb_pci_init(bus);
1150 @@ -776,6 +844,8 @@ err_pci_exit:
1155 + ssb_sdio_exit(bus);
1158 ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 0);
1159 @@ -783,8 +853,8 @@ err_disable_xtal:
1162 #ifdef CONFIG_SSB_PCIHOST
1163 -int ssb_bus_pcibus_register(struct ssb_bus *bus,
1164 - struct pci_dev *host_pci)
1165 +int __devinit ssb_bus_pcibus_register(struct ssb_bus *bus,
1166 + struct pci_dev *host_pci)
1170 @@ -796,6 +866,9 @@ int ssb_bus_pcibus_register(struct ssb_b
1172 ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane found on "
1173 "PCI device %s\n", dev_name(&host_pci->dev));
1175 + ssb_printk(KERN_ERR PFX "Failed to register PCI version"
1176 + " of SSB with error %d\n", err);
1180 @@ -804,9 +877,9 @@ EXPORT_SYMBOL(ssb_bus_pcibus_register);
1181 #endif /* CONFIG_SSB_PCIHOST */
1183 #ifdef CONFIG_SSB_PCMCIAHOST
1184 -int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
1185 - struct pcmcia_device *pcmcia_dev,
1186 - unsigned long baseaddr)
1187 +int __devinit ssb_bus_pcmciabus_register(struct ssb_bus *bus,
1188 + struct pcmcia_device *pcmcia_dev,
1189 + unsigned long baseaddr)
1193 @@ -825,9 +898,32 @@ int ssb_bus_pcmciabus_register(struct ss
1194 EXPORT_SYMBOL(ssb_bus_pcmciabus_register);
1195 #endif /* CONFIG_SSB_PCMCIAHOST */
1197 -int ssb_bus_ssbbus_register(struct ssb_bus *bus,
1198 - unsigned long baseaddr,
1199 - ssb_invariants_func_t get_invariants)
1200 +#ifdef CONFIG_SSB_SDIOHOST
1201 +int __devinit ssb_bus_sdiobus_register(struct ssb_bus *bus,
1202 + struct sdio_func *func,
1203 + unsigned int quirks)
1207 + bus->bustype = SSB_BUSTYPE_SDIO;
1208 + bus->host_sdio = func;
1209 + bus->ops = &ssb_sdio_ops;
1210 + bus->quirks = quirks;
1212 + err = ssb_bus_register(bus, ssb_sdio_get_invariants, ~0);
1214 + ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane found on "
1215 + "SDIO device %s\n", sdio_func_id(func));
1220 +EXPORT_SYMBOL(ssb_bus_sdiobus_register);
1221 +#endif /* CONFIG_SSB_PCMCIAHOST */
1223 +int __devinit ssb_bus_ssbbus_register(struct ssb_bus *bus,
1224 + unsigned long baseaddr,
1225 + ssb_invariants_func_t get_invariants)
1229 @@ -908,8 +1004,8 @@ u32 ssb_calc_clock_rate(u32 plltype, u32
1231 case SSB_PLLTYPE_6: /* 100/200 or 120/240 only */
1232 if (m & SSB_CHIPCO_CLK_T6_MMASK)
1233 - return SSB_CHIPCO_CLK_T6_M0;
1234 - return SSB_CHIPCO_CLK_T6_M1;
1235 + return SSB_CHIPCO_CLK_T6_M1;
1236 + return SSB_CHIPCO_CLK_T6_M0;
1237 case SSB_PLLTYPE_1: /* 48Mhz base, 3 dividers */
1238 case SSB_PLLTYPE_3: /* 25Mhz, 2 dividers */
1239 case SSB_PLLTYPE_4: /* 48Mhz, 4 dividers */
1240 @@ -1024,23 +1120,22 @@ static u32 ssb_tmslow_reject_bitmask(str
1242 u32 rev = ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_SSBREV;
1244 - /* The REJECT bit changed position in TMSLOW between
1245 - * Backplane revisions. */
1246 + /* The REJECT bit seems to be different for Backplane rev 2.3 */
1248 case SSB_IDLOW_SSBREV_22:
1249 - return SSB_TMSLOW_REJECT_22;
1250 + case SSB_IDLOW_SSBREV_24:
1251 + case SSB_IDLOW_SSBREV_26:
1252 + return SSB_TMSLOW_REJECT;
1253 case SSB_IDLOW_SSBREV_23:
1254 return SSB_TMSLOW_REJECT_23;
1255 - case SSB_IDLOW_SSBREV_24: /* TODO - find the proper REJECT bits */
1256 - case SSB_IDLOW_SSBREV_25: /* same here */
1257 - case SSB_IDLOW_SSBREV_26: /* same here */
1258 + case SSB_IDLOW_SSBREV_25: /* TODO - find the proper REJECT bit */
1259 case SSB_IDLOW_SSBREV_27: /* same here */
1260 - return SSB_TMSLOW_REJECT_23; /* this is a guess */
1261 + return SSB_TMSLOW_REJECT; /* this is a guess */
1263 printk(KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
1266 - return (SSB_TMSLOW_REJECT_22 | SSB_TMSLOW_REJECT_23);
1267 + return (SSB_TMSLOW_REJECT | SSB_TMSLOW_REJECT_23);
1270 int ssb_device_is_enabled(struct ssb_device *dev)
1271 @@ -1099,10 +1194,10 @@ void ssb_device_enable(struct ssb_device
1273 EXPORT_SYMBOL(ssb_device_enable);
1275 -/* Wait for a bit in a register to get set or unset.
1276 +/* Wait for bitmask in a register to get set or cleared.
1277 * timeout is in units of ten-microseconds */
1278 -static int ssb_wait_bit(struct ssb_device *dev, u16 reg, u32 bitmask,
1279 - int timeout, int set)
1280 +static int ssb_wait_bits(struct ssb_device *dev, u16 reg, u32 bitmask,
1281 + int timeout, int set)
1285 @@ -1110,7 +1205,7 @@ static int ssb_wait_bit(struct ssb_devic
1286 for (i = 0; i < timeout; i++) {
1287 val = ssb_read32(dev, reg);
1289 - if (val & bitmask)
1290 + if ((val & bitmask) == bitmask)
1293 if (!(val & bitmask))
1294 @@ -1127,20 +1222,38 @@ static int ssb_wait_bit(struct ssb_devic
1296 void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags)
1301 if (ssb_read32(dev, SSB_TMSLOW) & SSB_TMSLOW_RESET)
1304 reject = ssb_tmslow_reject_bitmask(dev);
1305 - ssb_write32(dev, SSB_TMSLOW, reject | SSB_TMSLOW_CLOCK);
1306 - ssb_wait_bit(dev, SSB_TMSLOW, reject, 1000, 1);
1307 - ssb_wait_bit(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0);
1308 - ssb_write32(dev, SSB_TMSLOW,
1309 - SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
1310 - reject | SSB_TMSLOW_RESET |
1311 - core_specific_flags);
1312 - ssb_flush_tmslow(dev);
1314 + if (ssb_read32(dev, SSB_TMSLOW) & SSB_TMSLOW_CLOCK) {
1315 + ssb_write32(dev, SSB_TMSLOW, reject | SSB_TMSLOW_CLOCK);
1316 + ssb_wait_bits(dev, SSB_TMSLOW, reject, 1000, 1);
1317 + ssb_wait_bits(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0);
1319 + if (ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_INITIATOR) {
1320 + val = ssb_read32(dev, SSB_IMSTATE);
1321 + val |= SSB_IMSTATE_REJECT;
1322 + ssb_write32(dev, SSB_IMSTATE, val);
1323 + ssb_wait_bits(dev, SSB_IMSTATE, SSB_IMSTATE_BUSY, 1000,
1327 + ssb_write32(dev, SSB_TMSLOW,
1328 + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
1329 + reject | SSB_TMSLOW_RESET |
1330 + core_specific_flags);
1331 + ssb_flush_tmslow(dev);
1333 + if (ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_INITIATOR) {
1334 + val = ssb_read32(dev, SSB_IMSTATE);
1335 + val &= ~SSB_IMSTATE_REJECT;
1336 + ssb_write32(dev, SSB_IMSTATE, val);
1340 ssb_write32(dev, SSB_TMSLOW,
1341 reject | SSB_TMSLOW_RESET |
1342 @@ -1155,7 +1268,10 @@ u32 ssb_dma_translation(struct ssb_devic
1343 case SSB_BUSTYPE_SSB:
1345 case SSB_BUSTYPE_PCI:
1346 - return SSB_PCI_DMA;
1347 + if (ssb_read32(dev, SSB_TMSHIGH) & SSB_TMSHIGH_DMA64)
1348 + return SSB_PCIE_DMA_H32;
1350 + return SSB_PCI_DMA;
1352 __ssb_dma_not_implemented(dev);
1354 @@ -1272,20 +1388,20 @@ EXPORT_SYMBOL(ssb_bus_may_powerdown);
1356 int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl)
1358 - struct ssb_chipcommon *cc;
1360 enum ssb_clkmode mode;
1362 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1);
1365 - cc = &bus->chipco;
1366 - mode = dynamic_pctl ? SSB_CLKMODE_DYNAMIC : SSB_CLKMODE_FAST;
1367 - ssb_chipco_set_clockmode(cc, mode);
1369 #ifdef CONFIG_SSB_DEBUG
1370 bus->powered_up = 1;
1373 + mode = dynamic_pctl ? SSB_CLKMODE_DYNAMIC : SSB_CLKMODE_FAST;
1374 + ssb_chipco_set_clockmode(&bus->chipco, mode);
1378 ssb_printk(KERN_ERR PFX "Bus powerup failed\n");
1379 @@ -1293,6 +1409,37 @@ error:
1381 EXPORT_SYMBOL(ssb_bus_powerup);
1383 +static void ssb_broadcast_value(struct ssb_device *dev,
1384 + u32 address, u32 data)
1386 +#ifdef CONFIG_SSB_DRIVER_PCICORE
1387 + /* This is used for both, PCI and ChipCommon core, so be careful. */
1388 + BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
1389 + BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
1392 + ssb_write32(dev, SSB_CHIPCO_BCAST_ADDR, address);
1393 + ssb_read32(dev, SSB_CHIPCO_BCAST_ADDR); /* flush */
1394 + ssb_write32(dev, SSB_CHIPCO_BCAST_DATA, data);
1395 + ssb_read32(dev, SSB_CHIPCO_BCAST_DATA); /* flush */
1398 +void ssb_commit_settings(struct ssb_bus *bus)
1400 + struct ssb_device *dev;
1402 +#ifdef CONFIG_SSB_DRIVER_PCICORE
1403 + dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
1405 + dev = bus->chipco.dev;
1407 + if (WARN_ON(!dev))
1409 + /* This forces an update of the cached registers. */
1410 + ssb_broadcast_value(dev, 0xFD8, 0);
1412 +EXPORT_SYMBOL(ssb_commit_settings);
1414 u32 ssb_admatch_base(u32 adm)
1417 @@ -1358,8 +1505,10 @@ static int __init ssb_modinit(void)
1419 err = ssb_attach_queued_buses();
1423 bus_unregister(&ssb_bustype);
1427 err = b43_pci_ssb_bridge_init();
1429 @@ -1375,7 +1524,7 @@ static int __init ssb_modinit(void)
1430 /* don't fail SSB init because of this */
1437 /* ssb must be initialized after PCI but before the ssb drivers.
1438 --- a/drivers/ssb/pci.c
1439 +++ b/drivers/ssb/pci.c
1442 #include <linux/ssb/ssb.h>
1443 #include <linux/ssb/ssb_regs.h>
1444 +#include <linux/slab.h>
1445 #include <linux/pci.h>
1446 #include <linux/delay.h>
1448 @@ -167,10 +168,16 @@ err_pci:
1451 /* Get the word-offset for a SSB_SPROM_XXX define. */
1452 -#define SPOFF(offset) (((offset) - SSB_SPROM_BASE) / sizeof(u16))
1453 +#define SPOFF(offset) ((offset) / sizeof(u16))
1454 /* Helper to extract some _offset, which is one of the SSB_SPROM_XXX defines. */
1455 -#define SPEX(_outvar, _offset, _mask, _shift) \
1456 +#define SPEX16(_outvar, _offset, _mask, _shift) \
1457 out->_outvar = ((in[SPOFF(_offset)] & (_mask)) >> (_shift))
1458 +#define SPEX32(_outvar, _offset, _mask, _shift) \
1459 + out->_outvar = ((((u32)in[SPOFF((_offset)+2)] << 16 | \
1460 + in[SPOFF(_offset)]) & (_mask)) >> (_shift))
1461 +#define SPEX(_outvar, _offset, _mask, _shift) \
1462 + SPEX16(_outvar, _offset, _mask, _shift)
1465 static inline u8 ssb_crc8(u8 crc, u8 data)
1467 @@ -247,7 +254,7 @@ static int sprom_do_read(struct ssb_bus
1470 for (i = 0; i < bus->sprom_size; i++)
1471 - sprom[i] = ioread16(bus->mmio + SSB_SPROM_BASE + (i * 2));
1472 + sprom[i] = ioread16(bus->mmio + bus->sprom_offset + (i * 2));
1476 @@ -278,7 +285,7 @@ static int sprom_do_write(struct ssb_bus
1480 - writew(sprom[i], bus->mmio + SSB_SPROM_BASE + (i * 2));
1481 + writew(sprom[i], bus->mmio + bus->sprom_offset + (i * 2));
1485 @@ -399,6 +406,46 @@ static void sprom_extract_r123(struct ss
1486 out->antenna_gain.ghz5.a3 = gain;
1489 +/* Revs 4 5 and 8 have partially shared layout */
1490 +static void sprom_extract_r458(struct ssb_sprom *out, const u16 *in)
1492 + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01,
1493 + SSB_SPROM4_TXPID2G0, SSB_SPROM4_TXPID2G0_SHIFT);
1494 + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01,
1495 + SSB_SPROM4_TXPID2G1, SSB_SPROM4_TXPID2G1_SHIFT);
1496 + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23,
1497 + SSB_SPROM4_TXPID2G2, SSB_SPROM4_TXPID2G2_SHIFT);
1498 + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23,
1499 + SSB_SPROM4_TXPID2G3, SSB_SPROM4_TXPID2G3_SHIFT);
1501 + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01,
1502 + SSB_SPROM4_TXPID5GL0, SSB_SPROM4_TXPID5GL0_SHIFT);
1503 + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01,
1504 + SSB_SPROM4_TXPID5GL1, SSB_SPROM4_TXPID5GL1_SHIFT);
1505 + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23,
1506 + SSB_SPROM4_TXPID5GL2, SSB_SPROM4_TXPID5GL2_SHIFT);
1507 + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23,
1508 + SSB_SPROM4_TXPID5GL3, SSB_SPROM4_TXPID5GL3_SHIFT);
1510 + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01,
1511 + SSB_SPROM4_TXPID5G0, SSB_SPROM4_TXPID5G0_SHIFT);
1512 + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01,
1513 + SSB_SPROM4_TXPID5G1, SSB_SPROM4_TXPID5G1_SHIFT);
1514 + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23,
1515 + SSB_SPROM4_TXPID5G2, SSB_SPROM4_TXPID5G2_SHIFT);
1516 + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23,
1517 + SSB_SPROM4_TXPID5G3, SSB_SPROM4_TXPID5G3_SHIFT);
1519 + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01,
1520 + SSB_SPROM4_TXPID5GH0, SSB_SPROM4_TXPID5GH0_SHIFT);
1521 + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01,
1522 + SSB_SPROM4_TXPID5GH1, SSB_SPROM4_TXPID5GH1_SHIFT);
1523 + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23,
1524 + SSB_SPROM4_TXPID5GH2, SSB_SPROM4_TXPID5GH2_SHIFT);
1525 + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23,
1526 + SSB_SPROM4_TXPID5GH3, SSB_SPROM4_TXPID5GH3_SHIFT);
1529 static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
1532 @@ -421,10 +468,14 @@ static void sprom_extract_r45(struct ssb
1533 SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0);
1534 SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
1535 SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0);
1536 + SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0);
1537 + SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0);
1539 SPEX(country_code, SSB_SPROM5_CCODE, 0xFFFF, 0);
1540 SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0);
1541 SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0);
1542 + SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0);
1543 + SPEX(boardflags2_hi, SSB_SPROM5_BFL2HI, 0xFFFF, 0);
1545 SPEX(ant_available_a, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_A,
1546 SSB_SPROM4_ANTAVAIL_A_SHIFT);
1547 @@ -464,6 +515,8 @@ static void sprom_extract_r45(struct ssb
1548 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
1549 sizeof(out->antenna_gain.ghz5));
1551 + sprom_extract_r458(out, in);
1553 /* TODO - get remaining rev 4 stuff needed */
1556 @@ -474,12 +527,14 @@ static void sprom_extract_r8(struct ssb_
1558 /* extract the MAC address */
1559 for (i = 0; i < 3; i++) {
1560 - v = in[SPOFF(SSB_SPROM1_IL0MAC) + i];
1561 + v = in[SPOFF(SSB_SPROM8_IL0MAC) + i];
1562 *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
1564 SPEX(country_code, SSB_SPROM8_CCODE, 0xFFFF, 0);
1565 SPEX(boardflags_lo, SSB_SPROM8_BFLLO, 0xFFFF, 0);
1566 SPEX(boardflags_hi, SSB_SPROM8_BFLHI, 0xFFFF, 0);
1567 + SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, 0xFFFF, 0);
1568 + SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, 0xFFFF, 0);
1569 SPEX(ant_available_a, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_A,
1570 SSB_SPROM8_ANTAVAIL_A_SHIFT);
1571 SPEX(ant_available_bg, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_BG,
1572 @@ -490,12 +545,55 @@ static void sprom_extract_r8(struct ssb_
1573 SPEX(maxpwr_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_MAXP_A_MASK, 0);
1574 SPEX(itssi_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_ITSSI_A,
1575 SSB_SPROM8_ITSSI_A_SHIFT);
1576 + SPEX(maxpwr_ah, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AH_MASK, 0);
1577 + SPEX(maxpwr_al, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AL_MASK,
1578 + SSB_SPROM8_MAXP_AL_SHIFT);
1579 SPEX(gpio0, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P0, 0);
1580 SPEX(gpio1, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P1,
1581 SSB_SPROM8_GPIOA_P1_SHIFT);
1582 SPEX(gpio2, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P2, 0);
1583 SPEX(gpio3, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P3,
1584 SSB_SPROM8_GPIOB_P3_SHIFT);
1585 + SPEX(tri2g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI2G, 0);
1586 + SPEX(tri5g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI5G,
1587 + SSB_SPROM8_TRI5G_SHIFT);
1588 + SPEX(tri5gl, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GL, 0);
1589 + SPEX(tri5gh, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GH,
1590 + SSB_SPROM8_TRI5GH_SHIFT);
1591 + SPEX(rxpo2g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO2G, 0);
1592 + SPEX(rxpo5g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO5G,
1593 + SSB_SPROM8_RXPO5G_SHIFT);
1594 + SPEX(rssismf2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMF2G, 0);
1595 + SPEX(rssismc2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMC2G,
1596 + SSB_SPROM8_RSSISMC2G_SHIFT);
1597 + SPEX(rssisav2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISAV2G,
1598 + SSB_SPROM8_RSSISAV2G_SHIFT);
1599 + SPEX(bxa2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_BXA2G,
1600 + SSB_SPROM8_BXA2G_SHIFT);
1601 + SPEX(rssismf5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMF5G, 0);
1602 + SPEX(rssismc5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMC5G,
1603 + SSB_SPROM8_RSSISMC5G_SHIFT);
1604 + SPEX(rssisav5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISAV5G,
1605 + SSB_SPROM8_RSSISAV5G_SHIFT);
1606 + SPEX(bxa5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_BXA5G,
1607 + SSB_SPROM8_BXA5G_SHIFT);
1608 + SPEX(pa0b0, SSB_SPROM8_PA0B0, 0xFFFF, 0);
1609 + SPEX(pa0b1, SSB_SPROM8_PA0B1, 0xFFFF, 0);
1610 + SPEX(pa0b2, SSB_SPROM8_PA0B2, 0xFFFF, 0);
1611 + SPEX(pa1b0, SSB_SPROM8_PA1B0, 0xFFFF, 0);
1612 + SPEX(pa1b1, SSB_SPROM8_PA1B1, 0xFFFF, 0);
1613 + SPEX(pa1b2, SSB_SPROM8_PA1B2, 0xFFFF, 0);
1614 + SPEX(pa1lob0, SSB_SPROM8_PA1LOB0, 0xFFFF, 0);
1615 + SPEX(pa1lob1, SSB_SPROM8_PA1LOB1, 0xFFFF, 0);
1616 + SPEX(pa1lob2, SSB_SPROM8_PA1LOB2, 0xFFFF, 0);
1617 + SPEX(pa1hib0, SSB_SPROM8_PA1HIB0, 0xFFFF, 0);
1618 + SPEX(pa1hib1, SSB_SPROM8_PA1HIB1, 0xFFFF, 0);
1619 + SPEX(pa1hib2, SSB_SPROM8_PA1HIB2, 0xFFFF, 0);
1620 + SPEX(cck2gpo, SSB_SPROM8_CCK2GPO, 0xFFFF, 0);
1621 + SPEX32(ofdm2gpo, SSB_SPROM8_OFDM2GPO, 0xFFFFFFFF, 0);
1622 + SPEX32(ofdm5glpo, SSB_SPROM8_OFDM5GLPO, 0xFFFFFFFF, 0);
1623 + SPEX32(ofdm5gpo, SSB_SPROM8_OFDM5GPO, 0xFFFFFFFF, 0);
1624 + SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
1626 /* Extract the antenna gain values. */
1627 SPEX(antenna_gain.ghz24.a0, SSB_SPROM8_AGAIN01,
1628 @@ -509,6 +607,8 @@ static void sprom_extract_r8(struct ssb_
1629 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
1630 sizeof(out->antenna_gain.ghz5));
1632 + sprom_extract_r458(out, in);
1634 /* TODO - get remaining rev 8 stuff needed */
1637 @@ -521,36 +621,34 @@ static int sprom_extract(struct ssb_bus
1638 ssb_dprintk(KERN_DEBUG PFX "SPROM revision %d detected.\n", out->revision);
1639 memset(out->et0mac, 0xFF, 6); /* preset et0 and et1 mac */
1640 memset(out->et1mac, 0xFF, 6);
1642 if ((bus->chip_id & 0xFF00) == 0x4400) {
1643 /* Workaround: The BCM44XX chip has a stupid revision
1644 * number stored in the SPROM.
1645 * Always extract r1. */
1647 + ssb_dprintk(KERN_DEBUG PFX "SPROM treated as revision %d\n", out->revision);
1650 + switch (out->revision) {
1654 sprom_extract_r123(out, in);
1655 - } else if (bus->chip_id == 0x4321) {
1656 - /* the BCM4328 has a chipid == 0x4321 and a rev 4 SPROM */
1657 - out->revision = 4;
1661 sprom_extract_r45(out, in);
1663 - switch (out->revision) {
1667 - sprom_extract_r123(out, in);
1671 - sprom_extract_r45(out, in);
1674 - sprom_extract_r8(out, in);
1677 - ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
1678 - " revision %d detected. Will extract"
1679 - " v1\n", out->revision);
1680 - sprom_extract_r123(out, in);
1684 + sprom_extract_r8(out, in);
1687 + ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
1688 + " revision %d detected. Will extract"
1689 + " v1\n", out->revision);
1690 + out->revision = 1;
1691 + sprom_extract_r123(out, in);
1694 if (out->boardflags_lo == 0xFFFF)
1695 @@ -564,13 +662,34 @@ static int sprom_extract(struct ssb_bus
1696 static int ssb_pci_sprom_get(struct ssb_bus *bus,
1697 struct ssb_sprom *sprom)
1699 - const struct ssb_sprom *fallback;
1700 - int err = -ENOMEM;
1704 + if (!ssb_is_sprom_available(bus)) {
1705 + ssb_printk(KERN_ERR PFX "No SPROM available!\n");
1708 + if (bus->chipco.dev) { /* can be unavailable! */
1710 + * get SPROM offset: SSB_SPROM_BASE1 except for
1711 + * chipcommon rev >= 31 or chip ID is 0x4312 and
1712 + * chipcommon status & 3 == 2
1714 + if (bus->chipco.dev->id.revision >= 31)
1715 + bus->sprom_offset = SSB_SPROM_BASE31;
1716 + else if (bus->chip_id == 0x4312 &&
1717 + (bus->chipco.status & 0x03) == 2)
1718 + bus->sprom_offset = SSB_SPROM_BASE31;
1720 + bus->sprom_offset = SSB_SPROM_BASE1;
1722 + bus->sprom_offset = SSB_SPROM_BASE1;
1724 + ssb_dprintk(KERN_INFO PFX "SPROM offset is 0x%x\n", bus->sprom_offset);
1726 buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL);
1730 bus->sprom_size = SSB_SPROMSIZE_WORDS_R123;
1731 sprom_do_read(bus, buf);
1732 err = sprom_check_crc(buf, bus->sprom_size);
1733 @@ -580,17 +699,24 @@ static int ssb_pci_sprom_get(struct ssb_
1734 buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
1739 bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
1740 sprom_do_read(bus, buf);
1741 err = sprom_check_crc(buf, bus->sprom_size);
1743 /* All CRC attempts failed.
1744 * Maybe there is no SPROM on the device?
1745 - * If we have a fallback, use that. */
1746 - fallback = ssb_get_fallback_sprom();
1748 - memcpy(sprom, fallback, sizeof(*sprom));
1749 + * Now we ask the arch code if there is some sprom
1750 + * available for this device in some other storage */
1751 + err = ssb_fill_sprom_with_fallback(bus, sprom);
1753 + ssb_printk(KERN_WARNING PFX "WARNING: Using"
1754 + " fallback SPROM failed (err %d)\n",
1757 + ssb_dprintk(KERN_DEBUG PFX "Using SPROM"
1758 + " revision %d provided by"
1759 + " platform.\n", sprom->revision);
1763 @@ -602,19 +728,15 @@ static int ssb_pci_sprom_get(struct ssb_
1771 static void ssb_pci_get_boardinfo(struct ssb_bus *bus,
1772 struct ssb_boardinfo *bi)
1774 - pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_VENDOR_ID,
1776 - pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_ID,
1778 - pci_read_config_word(bus->host_pci, PCI_REVISION_ID,
1780 + bi->vendor = bus->host_pci->subsystem_vendor;
1781 + bi->type = bus->host_pci->subsystem_device;
1782 + bi->rev = bus->host_pci->revision;
1785 int ssb_pci_get_invariants(struct ssb_bus *bus,
1786 --- a/drivers/ssb/pcihost_wrapper.c
1787 +++ b/drivers/ssb/pcihost_wrapper.c
1791 #include <linux/pci.h>
1792 +#include <linux/slab.h>
1793 #include <linux/ssb/ssb.h>
1796 @@ -52,12 +53,13 @@ static int ssb_pcihost_resume(struct pci
1797 # define ssb_pcihost_resume NULL
1798 #endif /* CONFIG_PM */
1800 -static int ssb_pcihost_probe(struct pci_dev *dev,
1801 - const struct pci_device_id *id)
1802 +static int __devinit ssb_pcihost_probe(struct pci_dev *dev,
1803 + const struct pci_device_id *id)
1805 struct ssb_bus *ssb;
1810 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
1812 @@ -73,6 +75,12 @@ static int ssb_pcihost_probe(struct pci_
1813 goto err_pci_disable;
1814 pci_set_master(dev);
1816 + /* Disable the RETRY_TIMEOUT register (0x41) to keep
1817 + * PCI Tx retries from interfering with C3 CPU state */
1818 + pci_read_config_dword(dev, 0x40, &val);
1819 + if ((val & 0x0000ff00) != 0)
1820 + pci_write_config_dword(dev, 0x40, val & 0xffff00ff);
1822 err = ssb_bus_pcibus_register(ssb, dev);
1824 goto err_pci_release_regions;
1825 @@ -102,7 +110,7 @@ static void ssb_pcihost_remove(struct pc
1826 pci_set_drvdata(dev, NULL);
1829 -int ssb_pcihost_register(struct pci_driver *driver)
1830 +int __devinit ssb_pcihost_register(struct pci_driver *driver)
1832 driver->probe = ssb_pcihost_probe;
1833 driver->remove = ssb_pcihost_remove;
1834 --- a/drivers/ssb/pcmcia.c
1835 +++ b/drivers/ssb/pcmcia.c
1836 @@ -617,136 +617,140 @@ static int ssb_pcmcia_sprom_check_crc(co
1840 -int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
1841 - struct ssb_init_invariants *iv)
1842 +static int ssb_pcmcia_get_mac(struct pcmcia_device *p_dev,
1848 - unsigned char buf[32];
1849 + struct ssb_sprom *sprom = priv;
1851 + if (tuple->TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID)
1853 + if (tuple->TupleDataLen != ETH_ALEN + 2)
1855 + if (tuple->TupleData[1] != ETH_ALEN)
1857 + memcpy(sprom->il0mac, &tuple->TupleData[2], ETH_ALEN);
1861 +static int ssb_pcmcia_do_get_invariants(struct pcmcia_device *p_dev,
1865 + struct ssb_init_invariants *iv = priv;
1866 struct ssb_sprom *sprom = &iv->sprom;
1867 struct ssb_boardinfo *bi = &iv->boardinfo;
1868 const char *error_description;
1870 + GOTO_ERROR_ON(tuple->TupleDataLen < 1, "VEN tpl < 1");
1871 + switch (tuple->TupleData[0]) {
1872 + case SSB_PCMCIA_CIS_ID:
1873 + GOTO_ERROR_ON((tuple->TupleDataLen != 5) &&
1874 + (tuple->TupleDataLen != 7),
1876 + bi->vendor = tuple->TupleData[1] |
1877 + ((u16)tuple->TupleData[2] << 8);
1879 + case SSB_PCMCIA_CIS_BOARDREV:
1880 + GOTO_ERROR_ON(tuple->TupleDataLen != 2,
1881 + "boardrev tpl size");
1882 + sprom->board_rev = tuple->TupleData[1];
1884 + case SSB_PCMCIA_CIS_PA:
1885 + GOTO_ERROR_ON((tuple->TupleDataLen != 9) &&
1886 + (tuple->TupleDataLen != 10),
1888 + sprom->pa0b0 = tuple->TupleData[1] |
1889 + ((u16)tuple->TupleData[2] << 8);
1890 + sprom->pa0b1 = tuple->TupleData[3] |
1891 + ((u16)tuple->TupleData[4] << 8);
1892 + sprom->pa0b2 = tuple->TupleData[5] |
1893 + ((u16)tuple->TupleData[6] << 8);
1894 + sprom->itssi_a = tuple->TupleData[7];
1895 + sprom->itssi_bg = tuple->TupleData[7];
1896 + sprom->maxpwr_a = tuple->TupleData[8];
1897 + sprom->maxpwr_bg = tuple->TupleData[8];
1899 + case SSB_PCMCIA_CIS_OEMNAME:
1900 + /* We ignore this. */
1902 + case SSB_PCMCIA_CIS_CCODE:
1903 + GOTO_ERROR_ON(tuple->TupleDataLen != 2,
1904 + "ccode tpl size");
1905 + sprom->country_code = tuple->TupleData[1];
1907 + case SSB_PCMCIA_CIS_ANTENNA:
1908 + GOTO_ERROR_ON(tuple->TupleDataLen != 2,
1910 + sprom->ant_available_a = tuple->TupleData[1];
1911 + sprom->ant_available_bg = tuple->TupleData[1];
1913 + case SSB_PCMCIA_CIS_ANTGAIN:
1914 + GOTO_ERROR_ON(tuple->TupleDataLen != 2,
1916 + sprom->antenna_gain.ghz24.a0 = tuple->TupleData[1];
1917 + sprom->antenna_gain.ghz24.a1 = tuple->TupleData[1];
1918 + sprom->antenna_gain.ghz24.a2 = tuple->TupleData[1];
1919 + sprom->antenna_gain.ghz24.a3 = tuple->TupleData[1];
1920 + sprom->antenna_gain.ghz5.a0 = tuple->TupleData[1];
1921 + sprom->antenna_gain.ghz5.a1 = tuple->TupleData[1];
1922 + sprom->antenna_gain.ghz5.a2 = tuple->TupleData[1];
1923 + sprom->antenna_gain.ghz5.a3 = tuple->TupleData[1];
1925 + case SSB_PCMCIA_CIS_BFLAGS:
1926 + GOTO_ERROR_ON((tuple->TupleDataLen != 3) &&
1927 + (tuple->TupleDataLen != 5),
1929 + sprom->boardflags_lo = tuple->TupleData[1] |
1930 + ((u16)tuple->TupleData[2] << 8);
1932 + case SSB_PCMCIA_CIS_LEDS:
1933 + GOTO_ERROR_ON(tuple->TupleDataLen != 5,
1935 + sprom->gpio0 = tuple->TupleData[1];
1936 + sprom->gpio1 = tuple->TupleData[2];
1937 + sprom->gpio2 = tuple->TupleData[3];
1938 + sprom->gpio3 = tuple->TupleData[4];
1941 + return -ENOSPC; /* continue with next entry */
1944 + ssb_printk(KERN_ERR PFX
1945 + "PCMCIA: Failed to fetch device invariants: %s\n",
1946 + error_description);
1951 +int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
1952 + struct ssb_init_invariants *iv)
1954 + struct ssb_sprom *sprom = &iv->sprom;
1957 memset(sprom, 0xFF, sizeof(*sprom));
1958 sprom->revision = 1;
1959 sprom->boardflags_lo = 0;
1960 sprom->boardflags_hi = 0;
1962 /* First fetch the MAC address. */
1963 - memset(&tuple, 0, sizeof(tuple));
1964 - tuple.DesiredTuple = CISTPL_FUNCE;
1965 - tuple.TupleData = buf;
1966 - tuple.TupleDataMax = sizeof(buf);
1967 - res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple);
1968 - GOTO_ERROR_ON(res != 0, "MAC first tpl");
1969 - res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple);
1970 - GOTO_ERROR_ON(res != 0, "MAC first tpl data");
1972 - GOTO_ERROR_ON(tuple.TupleDataLen < 1, "MAC tpl < 1");
1973 - if (tuple.TupleData[0] == CISTPL_FUNCE_LAN_NODE_ID)
1975 - res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple);
1976 - GOTO_ERROR_ON(res != 0, "MAC next tpl");
1977 - res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple);
1978 - GOTO_ERROR_ON(res != 0, "MAC next tpl data");
1979 + res = pcmcia_loop_tuple(bus->host_pcmcia, CISTPL_FUNCE,
1980 + ssb_pcmcia_get_mac, sprom);
1982 + ssb_printk(KERN_ERR PFX
1983 + "PCMCIA: Failed to fetch MAC address\n");
1986 - GOTO_ERROR_ON(tuple.TupleDataLen != ETH_ALEN + 2, "MAC tpl size");
1987 - memcpy(sprom->il0mac, &tuple.TupleData[2], ETH_ALEN);
1989 /* Fetch the vendor specific tuples. */
1990 - memset(&tuple, 0, sizeof(tuple));
1991 - tuple.DesiredTuple = SSB_PCMCIA_CIS;
1992 - tuple.TupleData = buf;
1993 - tuple.TupleDataMax = sizeof(buf);
1994 - res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple);
1995 - GOTO_ERROR_ON(res != 0, "VEN first tpl");
1996 - res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple);
1997 - GOTO_ERROR_ON(res != 0, "VEN first tpl data");
1999 - GOTO_ERROR_ON(tuple.TupleDataLen < 1, "VEN tpl < 1");
2000 - switch (tuple.TupleData[0]) {
2001 - case SSB_PCMCIA_CIS_ID:
2002 - GOTO_ERROR_ON((tuple.TupleDataLen != 5) &&
2003 - (tuple.TupleDataLen != 7),
2005 - bi->vendor = tuple.TupleData[1] |
2006 - ((u16)tuple.TupleData[2] << 8);
2008 - case SSB_PCMCIA_CIS_BOARDREV:
2009 - GOTO_ERROR_ON(tuple.TupleDataLen != 2,
2010 - "boardrev tpl size");
2011 - sprom->board_rev = tuple.TupleData[1];
2013 - case SSB_PCMCIA_CIS_PA:
2014 - GOTO_ERROR_ON((tuple.TupleDataLen != 9) &&
2015 - (tuple.TupleDataLen != 10),
2017 - sprom->pa0b0 = tuple.TupleData[1] |
2018 - ((u16)tuple.TupleData[2] << 8);
2019 - sprom->pa0b1 = tuple.TupleData[3] |
2020 - ((u16)tuple.TupleData[4] << 8);
2021 - sprom->pa0b2 = tuple.TupleData[5] |
2022 - ((u16)tuple.TupleData[6] << 8);
2023 - sprom->itssi_a = tuple.TupleData[7];
2024 - sprom->itssi_bg = tuple.TupleData[7];
2025 - sprom->maxpwr_a = tuple.TupleData[8];
2026 - sprom->maxpwr_bg = tuple.TupleData[8];
2028 - case SSB_PCMCIA_CIS_OEMNAME:
2029 - /* We ignore this. */
2031 - case SSB_PCMCIA_CIS_CCODE:
2032 - GOTO_ERROR_ON(tuple.TupleDataLen != 2,
2033 - "ccode tpl size");
2034 - sprom->country_code = tuple.TupleData[1];
2036 - case SSB_PCMCIA_CIS_ANTENNA:
2037 - GOTO_ERROR_ON(tuple.TupleDataLen != 2,
2039 - sprom->ant_available_a = tuple.TupleData[1];
2040 - sprom->ant_available_bg = tuple.TupleData[1];
2042 - case SSB_PCMCIA_CIS_ANTGAIN:
2043 - GOTO_ERROR_ON(tuple.TupleDataLen != 2,
2045 - sprom->antenna_gain.ghz24.a0 = tuple.TupleData[1];
2046 - sprom->antenna_gain.ghz24.a1 = tuple.TupleData[1];
2047 - sprom->antenna_gain.ghz24.a2 = tuple.TupleData[1];
2048 - sprom->antenna_gain.ghz24.a3 = tuple.TupleData[1];
2049 - sprom->antenna_gain.ghz5.a0 = tuple.TupleData[1];
2050 - sprom->antenna_gain.ghz5.a1 = tuple.TupleData[1];
2051 - sprom->antenna_gain.ghz5.a2 = tuple.TupleData[1];
2052 - sprom->antenna_gain.ghz5.a3 = tuple.TupleData[1];
2054 - case SSB_PCMCIA_CIS_BFLAGS:
2055 - GOTO_ERROR_ON((tuple.TupleDataLen != 3) &&
2056 - (tuple.TupleDataLen != 5),
2058 - sprom->boardflags_lo = tuple.TupleData[1] |
2059 - ((u16)tuple.TupleData[2] << 8);
2061 - case SSB_PCMCIA_CIS_LEDS:
2062 - GOTO_ERROR_ON(tuple.TupleDataLen != 5,
2064 - sprom->gpio0 = tuple.TupleData[1];
2065 - sprom->gpio1 = tuple.TupleData[2];
2066 - sprom->gpio2 = tuple.TupleData[3];
2067 - sprom->gpio3 = tuple.TupleData[4];
2070 - res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple);
2071 - if (res == -ENOSPC)
2073 - GOTO_ERROR_ON(res != 0, "VEN next tpl");
2074 - res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple);
2075 - GOTO_ERROR_ON(res != 0, "VEN next tpl data");
2077 + res = pcmcia_loop_tuple(bus->host_pcmcia, SSB_PCMCIA_CIS,
2078 + ssb_pcmcia_do_get_invariants, iv);
2079 + if ((res == 0) || (res == -ENOSPC))
2084 ssb_printk(KERN_ERR PFX
2085 - "PCMCIA: Failed to fetch device invariants: %s\n",
2086 - error_description);
2087 + "PCMCIA: Failed to fetch device invariants\n");
2091 --- a/drivers/ssb/scan.c
2092 +++ b/drivers/ssb/scan.c
2093 @@ -162,6 +162,8 @@ static u8 chipid_to_nrcores(u16 chipid)
2094 static u32 scan_read32(struct ssb_bus *bus, u8 current_coreidx,
2099 switch (bus->bustype) {
2100 case SSB_BUSTYPE_SSB:
2101 offset += current_coreidx * SSB_CORE_SIZE;
2102 @@ -174,7 +176,12 @@ static u32 scan_read32(struct ssb_bus *b
2105 ssb_pcmcia_switch_segment(bus, 0);
2107 + lo = readw(bus->mmio + offset);
2108 + hi = readw(bus->mmio + offset + 2);
2109 + return lo | (hi << 16);
2110 + case SSB_BUSTYPE_SDIO:
2111 + offset += current_coreidx * SSB_CORE_SIZE;
2112 + return ssb_sdio_scan_read32(bus, offset);
2114 return readl(bus->mmio + offset);
2116 @@ -188,6 +195,8 @@ static int scan_switchcore(struct ssb_bu
2117 return ssb_pci_switch_coreidx(bus, coreidx);
2118 case SSB_BUSTYPE_PCMCIA:
2119 return ssb_pcmcia_switch_coreidx(bus, coreidx);
2120 + case SSB_BUSTYPE_SDIO:
2121 + return ssb_sdio_scan_switch_coreidx(bus, coreidx);
2125 @@ -206,6 +215,8 @@ void ssb_iounmap(struct ssb_bus *bus)
2126 SSB_BUG_ON(1); /* Can't reach this code. */
2129 + case SSB_BUSTYPE_SDIO:
2133 bus->mapped_device = NULL;
2134 @@ -230,6 +241,10 @@ static void __iomem *ssb_ioremap(struct
2135 SSB_BUG_ON(1); /* Can't reach this code. */
2138 + case SSB_BUSTYPE_SDIO:
2139 + /* Nothing to ioremap in the SDIO case, just fake it */
2140 + mmio = (void __iomem *)baseaddr;
2145 @@ -245,7 +260,10 @@ static int we_support_multiple_80211_cor
2146 #ifdef CONFIG_SSB_PCIHOST
2147 if (bus->bustype == SSB_BUSTYPE_PCI) {
2148 if (bus->host_pci->vendor == PCI_VENDOR_ID_BROADCOM &&
2149 - bus->host_pci->device == 0x4324)
2150 + ((bus->host_pci->device == 0x4313) ||
2151 + (bus->host_pci->device == 0x431A) ||
2152 + (bus->host_pci->device == 0x4321) ||
2153 + (bus->host_pci->device == 0x4324)))
2156 #endif /* CONFIG_SSB_PCIHOST */
2157 @@ -294,8 +312,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
2159 if (bus->bustype == SSB_BUSTYPE_PCI) {
2160 bus->chip_id = pcidev_to_chipid(bus->host_pci);
2161 - pci_read_config_word(bus->host_pci, PCI_REVISION_ID,
2163 + bus->chip_rev = bus->host_pci->revision;
2164 bus->chip_package = 0;
2166 bus->chip_id = 0x4710;
2167 @@ -339,7 +356,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
2169 dev->ops = bus->ops;
2171 - ssb_dprintk(KERN_INFO PFX
2172 + printk(KERN_DEBUG PFX
2173 "Core %d found: %s "
2174 "(cc 0x%03X, rev 0x%02X, vendor 0x%04X)\n",
2175 i, ssb_core_name(dev->id.coreid),
2176 @@ -407,6 +424,16 @@ int ssb_bus_scan(struct ssb_bus *bus,
2177 bus->pcicore.dev = dev;
2178 #endif /* CONFIG_SSB_DRIVER_PCICORE */
2180 + case SSB_DEV_ETHERNET:
2181 + if (bus->bustype == SSB_BUSTYPE_PCI) {
2182 + if (bus->host_pci->vendor == PCI_VENDOR_ID_BROADCOM &&
2183 + (bus->host_pci->device & 0xFF00) == 0x4300) {
2184 + /* This is a dangling ethernet core on a
2185 + * wireless device. Ignore it. */
2194 +++ b/drivers/ssb/sdio.c
2197 + * Sonics Silicon Backplane
2198 + * SDIO-Hostbus related functions
2200 + * Copyright 2009 Albert Herranz <albert_herranz@yahoo.es>
2202 + * Based on drivers/ssb/pcmcia.c
2203 + * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
2204 + * Copyright 2007-2008 Michael Buesch <mb@bu3sch.de>
2206 + * Licensed under the GNU/GPL. See COPYING for details.
2210 +#include <linux/ssb/ssb.h>
2211 +#include <linux/delay.h>
2212 +#include <linux/io.h>
2213 +#include <linux/etherdevice.h>
2214 +#include <linux/mmc/sdio_func.h>
2216 +#include "ssb_private.h"
2218 +/* Define the following to 1 to enable a printk on each coreswitch. */
2219 +#define SSB_VERBOSE_SDIOCORESWITCH_DEBUG 0
2222 +/* Hardware invariants CIS tuples */
2223 +#define SSB_SDIO_CIS 0x80
2224 +#define SSB_SDIO_CIS_SROMREV 0x00
2225 +#define SSB_SDIO_CIS_ID 0x01
2226 +#define SSB_SDIO_CIS_BOARDREV 0x02
2227 +#define SSB_SDIO_CIS_PA 0x03
2228 +#define SSB_SDIO_CIS_PA_PA0B0_LO 0
2229 +#define SSB_SDIO_CIS_PA_PA0B0_HI 1
2230 +#define SSB_SDIO_CIS_PA_PA0B1_LO 2
2231 +#define SSB_SDIO_CIS_PA_PA0B1_HI 3
2232 +#define SSB_SDIO_CIS_PA_PA0B2_LO 4
2233 +#define SSB_SDIO_CIS_PA_PA0B2_HI 5
2234 +#define SSB_SDIO_CIS_PA_ITSSI 6
2235 +#define SSB_SDIO_CIS_PA_MAXPOW 7
2236 +#define SSB_SDIO_CIS_OEMNAME 0x04
2237 +#define SSB_SDIO_CIS_CCODE 0x05
2238 +#define SSB_SDIO_CIS_ANTENNA 0x06
2239 +#define SSB_SDIO_CIS_ANTGAIN 0x07
2240 +#define SSB_SDIO_CIS_BFLAGS 0x08
2241 +#define SSB_SDIO_CIS_LEDS 0x09
2243 +#define CISTPL_FUNCE_LAN_NODE_ID 0x04 /* same as in PCMCIA */
2247 + * Function 1 miscellaneous registers.
2249 + * Definitions match src/include/sbsdio.h from the
2250 + * Android Open Source Project
2251 + * http://android.git.kernel.org/?p=platform/system/wlan/broadcom.git
2254 +#define SBSDIO_FUNC1_SBADDRLOW 0x1000a /* SB Address window Low (b15) */
2255 +#define SBSDIO_FUNC1_SBADDRMID 0x1000b /* SB Address window Mid (b23-b16) */
2256 +#define SBSDIO_FUNC1_SBADDRHIGH 0x1000c /* SB Address window High (b24-b31) */
2258 +/* valid bits in SBSDIO_FUNC1_SBADDRxxx regs */
2259 +#define SBSDIO_SBADDRLOW_MASK 0x80 /* Valid address bits in SBADDRLOW */
2260 +#define SBSDIO_SBADDRMID_MASK 0xff /* Valid address bits in SBADDRMID */
2261 +#define SBSDIO_SBADDRHIGH_MASK 0xff /* Valid address bits in SBADDRHIGH */
2263 +#define SBSDIO_SB_OFT_ADDR_MASK 0x7FFF /* sb offset addr is <= 15 bits, 32k */
2265 +/* REVISIT: this flag doesn't seem to matter */
2266 +#define SBSDIO_SB_ACCESS_2_4B_FLAG 0x8000 /* forces 32-bit SB access */
2270 + * Address map within the SDIO function address space (128K).
2272 + * Start End Description
2273 + * ------- ------- ------------------------------------------
2274 + * 0x00000 0x0ffff selected backplane address window (64K)
2275 + * 0x10000 0x1ffff backplane control registers (max 64K)
2277 + * The current address window is configured by writing to registers
2278 + * SBADDRLOW, SBADDRMID and SBADDRHIGH.
2280 + * In order to access the contents of a 32-bit Silicon Backplane address
2281 + * the backplane address window must be first loaded with the highest
2282 + * 16 bits of the target address. Then, an access must be done to the
2283 + * SDIO function address space using the lower 15 bits of the address.
2284 + * Bit 15 of the address must be set when doing 32 bit accesses.
2286 + * 10987654321098765432109876543210
2287 + * WWWWWWWWWWWWWWWWW SB Address Window
2288 + * OOOOOOOOOOOOOOOO Offset within SB Address Window
2289 + * a 32-bit access flag
2294 + * SSB I/O via SDIO.
2296 + * NOTE: SDIO address @addr is 17 bits long (SDIO address space is 128K).
2299 +static inline struct device *ssb_sdio_dev(struct ssb_bus *bus)
2301 + return &bus->host_sdio->dev;
2305 +static int ssb_sdio_writeb(struct ssb_bus *bus, unsigned int addr, u8 val)
2309 + sdio_writeb(bus->host_sdio, val, addr, &error);
2310 + if (unlikely(error)) {
2311 + dev_dbg(ssb_sdio_dev(bus), "%08X <- %02x, error %d\n",
2312 + addr, val, error);
2319 +static u8 ssb_sdio_readb(struct ssb_bus *bus, unsigned int addr)
2324 + val = sdio_readb(bus->host_sdio, addr, &error);
2325 + if (unlikely(error)) {
2326 + dev_dbg(ssb_sdio_dev(bus), "%08X -> %02x, error %d\n",
2327 + addr, val, error);
2335 +static int ssb_sdio_set_sbaddr_window(struct ssb_bus *bus, u32 address)
2339 + error = ssb_sdio_writeb(bus, SBSDIO_FUNC1_SBADDRLOW,
2340 + (address >> 8) & SBSDIO_SBADDRLOW_MASK);
2343 + error = ssb_sdio_writeb(bus, SBSDIO_FUNC1_SBADDRMID,
2344 + (address >> 16) & SBSDIO_SBADDRMID_MASK);
2347 + error = ssb_sdio_writeb(bus, SBSDIO_FUNC1_SBADDRHIGH,
2348 + (address >> 24) & SBSDIO_SBADDRHIGH_MASK);
2351 + bus->sdio_sbaddr = address;
2354 + dev_dbg(ssb_sdio_dev(bus), "failed to set address window"
2355 + " to 0x%08x, error %d\n", address, error);
2361 +/* for enumeration use only */
2362 +u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
2367 + sdio_claim_host(bus->host_sdio);
2368 + val = sdio_readl(bus->host_sdio, offset, &error);
2369 + sdio_release_host(bus->host_sdio);
2370 + if (unlikely(error)) {
2371 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %08x, error %d\n",
2372 + bus->sdio_sbaddr >> 16, offset, val, error);
2378 +/* for enumeration use only */
2379 +int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
2384 + sbaddr = (coreidx * SSB_CORE_SIZE) + SSB_ENUM_BASE;
2385 + sdio_claim_host(bus->host_sdio);
2386 + error = ssb_sdio_set_sbaddr_window(bus, sbaddr);
2387 + sdio_release_host(bus->host_sdio);
2389 + dev_err(ssb_sdio_dev(bus), "failed to switch to core %u,"
2390 + " error %d\n", coreidx, error);
2397 +/* host must be already claimed */
2398 +int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev)
2400 + u8 coreidx = dev->core_index;
2404 + sbaddr = (coreidx * SSB_CORE_SIZE) + SSB_ENUM_BASE;
2405 + if (unlikely(bus->sdio_sbaddr != sbaddr)) {
2406 +#if SSB_VERBOSE_SDIOCORESWITCH_DEBUG
2407 + dev_info(ssb_sdio_dev(bus),
2408 + "switching to %s core, index %d\n",
2409 + ssb_core_name(dev->id.coreid), coreidx);
2411 + error = ssb_sdio_set_sbaddr_window(bus, sbaddr);
2413 + dev_dbg(ssb_sdio_dev(bus), "failed to switch to"
2414 + " core %u, error %d\n", coreidx, error);
2417 + bus->mapped_device = dev;
2424 +static u8 ssb_sdio_read8(struct ssb_device *dev, u16 offset)
2426 + struct ssb_bus *bus = dev->bus;
2430 + sdio_claim_host(bus->host_sdio);
2431 + if (unlikely(ssb_sdio_switch_core(bus, dev)))
2433 + offset |= bus->sdio_sbaddr & 0xffff;
2434 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2435 + val = sdio_readb(bus->host_sdio, offset, &error);
2437 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %02x, error %d\n",
2438 + bus->sdio_sbaddr >> 16, offset, val, error);
2441 + sdio_release_host(bus->host_sdio);
2446 +static u16 ssb_sdio_read16(struct ssb_device *dev, u16 offset)
2448 + struct ssb_bus *bus = dev->bus;
2452 + sdio_claim_host(bus->host_sdio);
2453 + if (unlikely(ssb_sdio_switch_core(bus, dev)))
2455 + offset |= bus->sdio_sbaddr & 0xffff;
2456 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2457 + val = sdio_readw(bus->host_sdio, offset, &error);
2459 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %04x, error %d\n",
2460 + bus->sdio_sbaddr >> 16, offset, val, error);
2463 + sdio_release_host(bus->host_sdio);
2468 +static u32 ssb_sdio_read32(struct ssb_device *dev, u16 offset)
2470 + struct ssb_bus *bus = dev->bus;
2471 + u32 val = 0xffffffff;
2474 + sdio_claim_host(bus->host_sdio);
2475 + if (unlikely(ssb_sdio_switch_core(bus, dev)))
2477 + offset |= bus->sdio_sbaddr & 0xffff;
2478 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2479 + offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */
2480 + val = sdio_readl(bus->host_sdio, offset, &error);
2482 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %08x, error %d\n",
2483 + bus->sdio_sbaddr >> 16, offset, val, error);
2486 + sdio_release_host(bus->host_sdio);
2491 +#ifdef CONFIG_SSB_BLOCKIO
2492 +static void ssb_sdio_block_read(struct ssb_device *dev, void *buffer,
2493 + size_t count, u16 offset, u8 reg_width)
2495 + size_t saved_count = count;
2496 + struct ssb_bus *bus = dev->bus;
2499 + sdio_claim_host(bus->host_sdio);
2500 + if (unlikely(ssb_sdio_switch_core(bus, dev))) {
2502 + memset(buffer, 0xff, count);
2505 + offset |= bus->sdio_sbaddr & 0xffff;
2506 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2508 + switch (reg_width) {
2509 + case sizeof(u8): {
2510 + error = sdio_readsb(bus->host_sdio, buffer, offset, count);
2513 + case sizeof(u16): {
2514 + SSB_WARN_ON(count & 1);
2515 + error = sdio_readsb(bus->host_sdio, buffer, offset, count);
2518 + case sizeof(u32): {
2519 + SSB_WARN_ON(count & 3);
2520 + offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */
2521 + error = sdio_readsb(bus->host_sdio, buffer, offset, count);
2531 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%zu), error %d\n",
2532 + bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error);
2534 + sdio_release_host(bus->host_sdio);
2536 +#endif /* CONFIG_SSB_BLOCKIO */
2538 +static void ssb_sdio_write8(struct ssb_device *dev, u16 offset, u8 val)
2540 + struct ssb_bus *bus = dev->bus;
2543 + sdio_claim_host(bus->host_sdio);
2544 + if (unlikely(ssb_sdio_switch_core(bus, dev)))
2546 + offset |= bus->sdio_sbaddr & 0xffff;
2547 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2548 + sdio_writeb(bus->host_sdio, val, offset, &error);
2550 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X < %02x, error %d\n",
2551 + bus->sdio_sbaddr >> 16, offset, val, error);
2554 + sdio_release_host(bus->host_sdio);
2557 +static void ssb_sdio_write16(struct ssb_device *dev, u16 offset, u16 val)
2559 + struct ssb_bus *bus = dev->bus;
2562 + sdio_claim_host(bus->host_sdio);
2563 + if (unlikely(ssb_sdio_switch_core(bus, dev)))
2565 + offset |= bus->sdio_sbaddr & 0xffff;
2566 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2567 + sdio_writew(bus->host_sdio, val, offset, &error);
2569 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X < %04x, error %d\n",
2570 + bus->sdio_sbaddr >> 16, offset, val, error);
2573 + sdio_release_host(bus->host_sdio);
2576 +static void ssb_sdio_write32(struct ssb_device *dev, u16 offset, u32 val)
2578 + struct ssb_bus *bus = dev->bus;
2581 + sdio_claim_host(bus->host_sdio);
2582 + if (unlikely(ssb_sdio_switch_core(bus, dev)))
2584 + offset |= bus->sdio_sbaddr & 0xffff;
2585 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2586 + offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */
2587 + sdio_writel(bus->host_sdio, val, offset, &error);
2589 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X < %08x, error %d\n",
2590 + bus->sdio_sbaddr >> 16, offset, val, error);
2592 + if (bus->quirks & SSB_QUIRK_SDIO_READ_AFTER_WRITE32)
2593 + sdio_readl(bus->host_sdio, 0, &error);
2595 + sdio_release_host(bus->host_sdio);
2598 +#ifdef CONFIG_SSB_BLOCKIO
2599 +static void ssb_sdio_block_write(struct ssb_device *dev, const void *buffer,
2600 + size_t count, u16 offset, u8 reg_width)
2602 + size_t saved_count = count;
2603 + struct ssb_bus *bus = dev->bus;
2606 + sdio_claim_host(bus->host_sdio);
2607 + if (unlikely(ssb_sdio_switch_core(bus, dev))) {
2609 + memset((void *)buffer, 0xff, count);
2612 + offset |= bus->sdio_sbaddr & 0xffff;
2613 + offset &= SBSDIO_SB_OFT_ADDR_MASK;
2615 + switch (reg_width) {
2617 + error = sdio_writesb(bus->host_sdio, offset,
2618 + (void *)buffer, count);
2621 + SSB_WARN_ON(count & 1);
2622 + error = sdio_writesb(bus->host_sdio, offset,
2623 + (void *)buffer, count);
2626 + SSB_WARN_ON(count & 3);
2627 + offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */
2628 + error = sdio_writesb(bus->host_sdio, offset,
2629 + (void *)buffer, count);
2638 + dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%zu), error %d\n",
2639 + bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error);
2641 + sdio_release_host(bus->host_sdio);
2644 +#endif /* CONFIG_SSB_BLOCKIO */
2646 +/* Not "static", as it's used in main.c */
2647 +const struct ssb_bus_ops ssb_sdio_ops = {
2648 + .read8 = ssb_sdio_read8,
2649 + .read16 = ssb_sdio_read16,
2650 + .read32 = ssb_sdio_read32,
2651 + .write8 = ssb_sdio_write8,
2652 + .write16 = ssb_sdio_write16,
2653 + .write32 = ssb_sdio_write32,
2654 +#ifdef CONFIG_SSB_BLOCKIO
2655 + .block_read = ssb_sdio_block_read,
2656 + .block_write = ssb_sdio_block_write,
2660 +#define GOTO_ERROR_ON(condition, description) do { \
2661 + if (unlikely(condition)) { \
2662 + error_description = description; \
2667 +int ssb_sdio_get_invariants(struct ssb_bus *bus,
2668 + struct ssb_init_invariants *iv)
2670 + struct ssb_sprom *sprom = &iv->sprom;
2671 + struct ssb_boardinfo *bi = &iv->boardinfo;
2672 + const char *error_description = "none";
2673 + struct sdio_func_tuple *tuple;
2676 + memset(sprom, 0xFF, sizeof(*sprom));
2677 + sprom->boardflags_lo = 0;
2678 + sprom->boardflags_hi = 0;
2680 + tuple = bus->host_sdio->tuples;
2682 + switch (tuple->code) {
2683 + case 0x22: /* extended function */
2684 + switch (tuple->data[0]) {
2685 + case CISTPL_FUNCE_LAN_NODE_ID:
2686 + GOTO_ERROR_ON((tuple->size != 7) &&
2687 + (tuple->data[1] != 6),
2689 + /* fetch the MAC address. */
2690 + mac = tuple->data + 2;
2691 + memcpy(sprom->il0mac, mac, ETH_ALEN);
2692 + memcpy(sprom->et1mac, mac, ETH_ALEN);
2698 + case 0x80: /* vendor specific tuple */
2699 + switch (tuple->data[0]) {
2700 + case SSB_SDIO_CIS_SROMREV:
2701 + GOTO_ERROR_ON(tuple->size != 2,
2702 + "sromrev tpl size");
2703 + sprom->revision = tuple->data[1];
2705 + case SSB_SDIO_CIS_ID:
2706 + GOTO_ERROR_ON((tuple->size != 5) &&
2707 + (tuple->size != 7),
2709 + bi->vendor = tuple->data[1] |
2710 + (tuple->data[2]<<8);
2712 + case SSB_SDIO_CIS_BOARDREV:
2713 + GOTO_ERROR_ON(tuple->size != 2,
2714 + "boardrev tpl size");
2715 + sprom->board_rev = tuple->data[1];
2717 + case SSB_SDIO_CIS_PA:
2718 + GOTO_ERROR_ON((tuple->size != 9) &&
2719 + (tuple->size != 10),
2721 + sprom->pa0b0 = tuple->data[1] |
2722 + ((u16)tuple->data[2] << 8);
2723 + sprom->pa0b1 = tuple->data[3] |
2724 + ((u16)tuple->data[4] << 8);
2725 + sprom->pa0b2 = tuple->data[5] |
2726 + ((u16)tuple->data[6] << 8);
2727 + sprom->itssi_a = tuple->data[7];
2728 + sprom->itssi_bg = tuple->data[7];
2729 + sprom->maxpwr_a = tuple->data[8];
2730 + sprom->maxpwr_bg = tuple->data[8];
2732 + case SSB_SDIO_CIS_OEMNAME:
2735 + case SSB_SDIO_CIS_CCODE:
2736 + GOTO_ERROR_ON(tuple->size != 2,
2737 + "ccode tpl size");
2738 + sprom->country_code = tuple->data[1];
2740 + case SSB_SDIO_CIS_ANTENNA:
2741 + GOTO_ERROR_ON(tuple->size != 2,
2743 + sprom->ant_available_a = tuple->data[1];
2744 + sprom->ant_available_bg = tuple->data[1];
2746 + case SSB_SDIO_CIS_ANTGAIN:
2747 + GOTO_ERROR_ON(tuple->size != 2,
2749 + sprom->antenna_gain.ghz24.a0 = tuple->data[1];
2750 + sprom->antenna_gain.ghz24.a1 = tuple->data[1];
2751 + sprom->antenna_gain.ghz24.a2 = tuple->data[1];
2752 + sprom->antenna_gain.ghz24.a3 = tuple->data[1];
2753 + sprom->antenna_gain.ghz5.a0 = tuple->data[1];
2754 + sprom->antenna_gain.ghz5.a1 = tuple->data[1];
2755 + sprom->antenna_gain.ghz5.a2 = tuple->data[1];
2756 + sprom->antenna_gain.ghz5.a3 = tuple->data[1];
2758 + case SSB_SDIO_CIS_BFLAGS:
2759 + GOTO_ERROR_ON((tuple->size != 3) &&
2760 + (tuple->size != 5),
2762 + sprom->boardflags_lo = tuple->data[1] |
2763 + ((u16)tuple->data[2] << 8);
2765 + case SSB_SDIO_CIS_LEDS:
2766 + GOTO_ERROR_ON(tuple->size != 5,
2768 + sprom->gpio0 = tuple->data[1];
2769 + sprom->gpio1 = tuple->data[2];
2770 + sprom->gpio2 = tuple->data[3];
2771 + sprom->gpio3 = tuple->data[4];
2780 + tuple = tuple->next;
2785 + dev_err(ssb_sdio_dev(bus), "failed to fetch device invariants: %s\n",
2786 + error_description);
2790 +void ssb_sdio_exit(struct ssb_bus *bus)
2792 + if (bus->bustype != SSB_BUSTYPE_SDIO)
2794 + /* Nothing to do here. */
2797 +int ssb_sdio_init(struct ssb_bus *bus)
2799 + if (bus->bustype != SSB_BUSTYPE_SDIO)
2802 + bus->sdio_sbaddr = ~0;
2806 --- a/drivers/ssb/sprom.c
2807 +++ b/drivers/ssb/sprom.c
2809 #include "ssb_private.h"
2811 #include <linux/ctype.h>
2812 +#include <linux/slab.h>
2815 -static const struct ssb_sprom *fallback_sprom;
2816 +static int(*get_fallback_sprom)(struct ssb_bus *dev, struct ssb_sprom *out);
2819 static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
2820 @@ -102,6 +103,7 @@ ssize_t ssb_attr_sprom_store(struct ssb_
2822 int res = 0, err = -ENOMEM;
2823 size_t sprom_size_words = bus->sprom_size;
2824 + struct ssb_freeze_context freeze;
2826 sprom = kcalloc(bus->sprom_size, sizeof(u16), GFP_KERNEL);
2828 @@ -123,18 +125,13 @@ ssize_t ssb_attr_sprom_store(struct ssb_
2830 if (mutex_lock_interruptible(&bus->sprom_mutex))
2832 - err = ssb_devices_freeze(bus);
2833 - if (err == -EOPNOTSUPP) {
2834 - ssb_printk(KERN_ERR PFX "SPROM write: Could not freeze devices. "
2835 - "No suspend support. Is CONFIG_PM enabled?\n");
2838 + err = ssb_devices_freeze(bus, &freeze);
2840 ssb_printk(KERN_ERR PFX "SPROM write: Could not freeze all devices\n");
2843 res = sprom_write(bus, sprom);
2844 - err = ssb_devices_thaw(bus);
2845 + err = ssb_devices_thaw(&freeze);
2847 ssb_printk(KERN_ERR PFX "SPROM write: Could not thaw all devices\n");
2849 @@ -148,34 +145,56 @@ out:
2853 - * ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found.
2854 + * ssb_arch_register_fallback_sprom - Registers a method providing a
2855 + * fallback SPROM if no SPROM is found.
2857 - * @sprom: The SPROM data structure to register.
2858 + * @sprom_callback: The callback function.
2860 - * With this function the architecture implementation may register a fallback
2861 - * SPROM data structure. The fallback is only used for PCI based SSB devices,
2862 - * where no valid SPROM can be found in the shadow registers.
2863 + * With this function the architecture implementation may register a
2864 + * callback handler which fills the SPROM data structure. The fallback is
2865 + * only used for PCI based SSB devices, where no valid SPROM can be found
2866 + * in the shadow registers.
2868 - * This function is useful for weird architectures that have a half-assed SSB device
2869 - * hardwired to their PCI bus.
2870 + * This function is useful for weird architectures that have a half-assed
2871 + * SSB device hardwired to their PCI bus.
2873 - * Note that it does only work with PCI attached SSB devices. PCMCIA devices currently
2874 - * don't use this fallback.
2875 - * Architectures must provide the SPROM for native SSB devices anyway,
2876 - * so the fallback also isn't used for native devices.
2877 + * Note that it does only work with PCI attached SSB devices. PCMCIA
2878 + * devices currently don't use this fallback.
2879 + * Architectures must provide the SPROM for native SSB devices anyway, so
2880 + * the fallback also isn't used for native devices.
2882 - * This function is available for architecture code, only. So it is not exported.
2883 + * This function is available for architecture code, only. So it is not
2886 -int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom)
2887 +int ssb_arch_register_fallback_sprom(int (*sprom_callback)(struct ssb_bus *bus,
2888 + struct ssb_sprom *out))
2890 - if (fallback_sprom)
2891 + if (get_fallback_sprom)
2893 - fallback_sprom = sprom;
2894 + get_fallback_sprom = sprom_callback;
2899 -const struct ssb_sprom *ssb_get_fallback_sprom(void)
2900 +int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out)
2902 - return fallback_sprom;
2903 + if (!get_fallback_sprom)
2906 + return get_fallback_sprom(bus, out);
2909 +/* http://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */
2910 +bool ssb_is_sprom_available(struct ssb_bus *bus)
2912 + /* status register only exists on chipcomon rev >= 11 and we need check
2914 + /* this routine differs from specs as we do not access SPROM directly
2916 + if (bus->bustype == SSB_BUSTYPE_PCI &&
2917 + bus->chipco.dev && /* can be unavailable! */
2918 + bus->chipco.dev->id.revision >= 31)
2919 + return bus->chipco.capabilities & SSB_CHIPCO_CAP_SPROM;
2923 --- a/drivers/ssb/ssb_private.h
2924 +++ b/drivers/ssb/ssb_private.h
2925 @@ -114,6 +114,46 @@ static inline int ssb_pcmcia_init(struct
2927 #endif /* CONFIG_SSB_PCMCIAHOST */
2930 +#ifdef CONFIG_SSB_SDIOHOST
2931 +extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
2932 + struct ssb_init_invariants *iv);
2934 +extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
2935 +extern int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev);
2936 +extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
2937 +extern int ssb_sdio_hardware_setup(struct ssb_bus *bus);
2938 +extern void ssb_sdio_exit(struct ssb_bus *bus);
2939 +extern int ssb_sdio_init(struct ssb_bus *bus);
2941 +extern const struct ssb_bus_ops ssb_sdio_ops;
2942 +#else /* CONFIG_SSB_SDIOHOST */
2943 +static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
2947 +static inline int ssb_sdio_switch_core(struct ssb_bus *bus,
2948 + struct ssb_device *dev)
2952 +static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
2956 +static inline int ssb_sdio_hardware_setup(struct ssb_bus *bus)
2960 +static inline void ssb_sdio_exit(struct ssb_bus *bus)
2963 +static inline int ssb_sdio_init(struct ssb_bus *bus)
2967 +#endif /* CONFIG_SSB_SDIOHOST */
2971 extern const char *ssb_core_name(u16 coreid);
2972 @@ -131,24 +171,33 @@ ssize_t ssb_attr_sprom_store(struct ssb_
2973 const char *buf, size_t count,
2974 int (*sprom_check_crc)(const u16 *sprom, size_t size),
2975 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
2976 -extern const struct ssb_sprom *ssb_get_fallback_sprom(void);
2977 +extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
2978 + struct ssb_sprom *out);
2982 extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
2983 -extern int ssb_devices_freeze(struct ssb_bus *bus);
2984 -extern int ssb_devices_thaw(struct ssb_bus *bus);
2985 extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
2986 int ssb_for_each_bus_call(unsigned long data,
2987 int (*func)(struct ssb_bus *bus, unsigned long data));
2988 extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
2990 +struct ssb_freeze_context {
2991 + /* Pointer to the bus */
2992 + struct ssb_bus *bus;
2993 + /* Boolean list to indicate whether a device is frozen on this bus. */
2994 + bool device_frozen[SSB_MAX_NR_CORES];
2996 +extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
2997 +extern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
3001 /* b43_pci_bridge.c */
3002 #ifdef CONFIG_SSB_B43_PCI_BRIDGE
3003 extern int __init b43_pci_ssb_bridge_init(void);
3004 extern void __exit b43_pci_ssb_bridge_exit(void);
3005 -#else /* CONFIG_SSB_B43_PCI_BRIDGR */
3006 +#else /* CONFIG_SSB_B43_PCI_BRIDGE */
3007 static inline int b43_pci_ssb_bridge_init(void)
3010 @@ -156,6 +205,6 @@ static inline int b43_pci_ssb_bridge_ini
3011 static inline void b43_pci_ssb_bridge_exit(void)
3014 -#endif /* CONFIG_SSB_PCIHOST */
3015 +#endif /* CONFIG_SSB_B43_PCI_BRIDGE */
3017 #endif /* LINUX_SSB_PRIVATE_H_ */
3018 --- a/include/linux/pci_ids.h
3019 +++ b/include/linux/pci_ids.h
3020 @@ -2017,6 +2017,7 @@
3021 #define PCI_DEVICE_ID_AFAVLAB_P030 0x2182
3022 #define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150
3024 +#define PCI_VENDOR_ID_BCM_GVC 0x14a4
3025 #define PCI_VENDOR_ID_BROADCOM 0x14e4
3026 #define PCI_DEVICE_ID_TIGON3_5752 0x1600
3027 #define PCI_DEVICE_ID_TIGON3_5752M 0x1601
3028 --- a/include/linux/ssb/ssb.h
3029 +++ b/include/linux/ssb/ssb.h
3030 @@ -27,24 +27,60 @@ struct ssb_sprom {
3031 u8 et1mdcport; /* MDIO for enet1 */
3032 u8 board_rev; /* Board revision number from SPROM. */
3033 u8 country_code; /* Country Code */
3034 - u8 ant_available_a; /* A-PHY antenna available bits (up to 4) */
3035 - u8 ant_available_bg; /* B/G-PHY antenna available bits (up to 4) */
3036 + u16 leddc_on_time; /* LED Powersave Duty Cycle On Count */
3037 + u16 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
3038 + u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */
3039 + u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */
3052 u8 gpio0; /* GPIO pin 0 */
3053 u8 gpio1; /* GPIO pin 1 */
3054 u8 gpio2; /* GPIO pin 2 */
3055 u8 gpio3; /* GPIO pin 3 */
3056 - u16 maxpwr_a; /* A-PHY Amplifier Max Power (in dBm Q5.2) */
3057 - u16 maxpwr_bg; /* B/G-PHY Amplifier Max Power (in dBm Q5.2) */
3058 + u16 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
3059 + u16 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
3060 + u16 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
3061 + u16 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
3062 u8 itssi_a; /* Idle TSSI Target for A-PHY */
3063 u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
3064 - u16 boardflags_lo; /* Boardflags (low 16 bits) */
3065 - u16 boardflags_hi; /* Boardflags (high 16 bits) */
3066 + u8 tri2g; /* 2.4GHz TX isolation */
3067 + u8 tri5gl; /* 5.2GHz TX isolation */
3068 + u8 tri5g; /* 5.3GHz TX isolation */
3069 + u8 tri5gh; /* 5.8GHz TX isolation */
3070 + u8 txpid2g[4]; /* 2GHz TX power index */
3071 + u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
3072 + u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
3073 + u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
3074 + u8 rxpo2g; /* 2GHz RX power offset */
3075 + u8 rxpo5g; /* 5GHz RX power offset */
3076 + u8 rssisav2g; /* 2GHz RSSI params */
3079 + u8 bxa2g; /* 2GHz BX arch */
3080 + u8 rssisav5g; /* 5GHz RSSI params */
3083 + u8 bxa5g; /* 5GHz BX arch */
3084 + u16 cck2gpo; /* CCK power offset */
3085 + u32 ofdm2gpo; /* 2.4GHz OFDM power offset */
3086 + u32 ofdm5glpo; /* 5.2GHz OFDM power offset */
3087 + u32 ofdm5gpo; /* 5.3GHz OFDM power offset */
3088 + u32 ofdm5ghpo; /* 5.8GHz OFDM power offset */
3089 + u16 boardflags_lo; /* Board flags (bits 0-15) */
3090 + u16 boardflags_hi; /* Board flags (bits 16-31) */
3091 + u16 boardflags2_lo; /* Board flags (bits 32-47) */
3092 + u16 boardflags2_hi; /* Board flags (bits 48-63) */
3093 + /* TODO store board flags in a single u64 */
3095 /* Antenna gain values for up to 4 antennas
3096 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
3097 @@ -58,14 +94,14 @@ struct ssb_sprom {
3098 } ghz5; /* 5GHz band */
3101 - /* TODO - add any parameters needed from rev 2, 3, or 4 SPROMs */
3102 + /* TODO - add any parameters needed from rev 2, 3, 4, 5 or 8 SPROMs */
3105 /* Information about the PCB the circuitry is soldered on. */
3106 struct ssb_boardinfo {
3114 @@ -137,7 +173,7 @@ struct ssb_device {
3115 * is an optimization. */
3116 const struct ssb_bus_ops *ops;
3118 - struct device *dev;
3119 + struct device *dev, *dma_dev;
3121 struct ssb_bus *bus;
3122 struct ssb_device_id id;
3123 @@ -208,6 +244,7 @@ enum ssb_bustype {
3124 SSB_BUSTYPE_SSB, /* This SSB bus is the system bus */
3125 SSB_BUSTYPE_PCI, /* SSB is connected to PCI bus */
3126 SSB_BUSTYPE_PCMCIA, /* SSB is connected to PCMCIA bus */
3127 + SSB_BUSTYPE_SDIO, /* SSB is connected to SDIO bus */
3131 @@ -238,20 +275,33 @@ struct ssb_bus {
3133 const struct ssb_bus_ops *ops;
3135 - /* The core in the basic address register window. (PCI bus only) */
3136 + /* The core currently mapped into the MMIO window.
3137 + * Not valid on all host-buses. So don't use outside of SSB. */
3138 struct ssb_device *mapped_device;
3139 - /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
3140 - u8 mapped_pcmcia_seg;
3142 + /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
3143 + u8 mapped_pcmcia_seg;
3144 + /* Current SSB base address window for SDIO. */
3147 /* Lock for core and segment switching.
3148 * On PCMCIA-host busses this is used to protect the whole MMIO access. */
3149 spinlock_t bar_lock;
3151 - /* The bus this backplane is running on. */
3152 + /* The host-bus this backplane is running on. */
3153 enum ssb_bustype bustype;
3154 - /* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
3155 - struct pci_dev *host_pci;
3156 - /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
3157 - struct pcmcia_device *host_pcmcia;
3158 + /* Pointers to the host-bus. Check bustype before using any of these pointers. */
3160 + /* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
3161 + struct pci_dev *host_pci;
3162 + /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
3163 + struct pcmcia_device *host_pcmcia;
3164 + /* Pointer to the SDIO device (only if bustype == SSB_BUSTYPE_SDIO). */
3165 + struct sdio_func *host_sdio;
3168 + /* See enum ssb_quirks */
3169 + unsigned int quirks;
3171 #ifdef CONFIG_SSB_SPROM
3172 /* Mutex to protect the SPROM writing. */
3173 @@ -260,7 +310,8 @@ struct ssb_bus {
3175 /* ID information about the Chip. */
3180 u16 sprom_size; /* number of words in sprom */
3183 @@ -306,6 +357,11 @@ struct ssb_bus {
3188 + /* SDIO connected card requires performing a read after writing a 32-bit value */
3189 + SSB_QUIRK_SDIO_READ_AFTER_WRITE32 = (1 << 0),
3192 /* The initialization-invariants. */
3193 struct ssb_init_invariants {
3194 /* Versioning information about the PCB. */
3195 @@ -336,12 +392,23 @@ extern int ssb_bus_pcmciabus_register(st
3196 struct pcmcia_device *pcmcia_dev,
3197 unsigned long baseaddr);
3198 #endif /* CONFIG_SSB_PCMCIAHOST */
3199 +#ifdef CONFIG_SSB_SDIOHOST
3200 +extern int ssb_bus_sdiobus_register(struct ssb_bus *bus,
3201 + struct sdio_func *sdio_func,
3202 + unsigned int quirks);
3203 +#endif /* CONFIG_SSB_SDIOHOST */
3206 extern void ssb_bus_unregister(struct ssb_bus *bus);
3208 +/* Does the device have an SPROM? */
3209 +extern bool ssb_is_sprom_available(struct ssb_bus *bus);
3211 /* Set a fallback SPROM.
3212 * See kdoc at the function definition for complete documentation. */
3213 -extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom);
3214 +extern int ssb_arch_register_fallback_sprom(
3215 + int (*sprom_callback)(struct ssb_bus *bus,
3216 + struct ssb_sprom *out));
3218 /* Suspend a SSB bus.
3219 * Call this from the parent bus suspend routine. */
3220 @@ -612,6 +679,7 @@ extern int ssb_bus_may_powerdown(struct
3221 * Otherwise static always-on powercontrol will be used. */
3222 extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
3224 +extern void ssb_commit_settings(struct ssb_bus *bus);
3226 /* Various helper functions */
3227 extern u32 ssb_admatch_base(u32 adm);
3228 --- a/include/linux/ssb/ssb_driver_chipcommon.h
3229 +++ b/include/linux/ssb/ssb_driver_chipcommon.h
3231 #define SSB_CHIPCO_CAP_64BIT 0x08000000 /* 64-bit Backplane */
3232 #define SSB_CHIPCO_CAP_PMU 0x10000000 /* PMU available (rev >= 20) */
3233 #define SSB_CHIPCO_CAP_ECI 0x20000000 /* ECI available (rev >= 20) */
3234 +#define SSB_CHIPCO_CAP_SPROM 0x40000000 /* SPROM present */
3235 #define SSB_CHIPCO_CORECTL 0x0008
3236 #define SSB_CHIPCO_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */
3237 #define SSB_CHIPCO_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
3239 #define SSB_CHIPCO_FLASHDATA 0x0048
3240 #define SSB_CHIPCO_BCAST_ADDR 0x0050
3241 #define SSB_CHIPCO_BCAST_DATA 0x0054
3242 +#define SSB_CHIPCO_GPIOPULLUP 0x0058 /* Rev >= 20 only */
3243 +#define SSB_CHIPCO_GPIOPULLDOWN 0x005C /* Rev >= 20 only */
3244 #define SSB_CHIPCO_GPIOIN 0x0060
3245 #define SSB_CHIPCO_GPIOOUT 0x0064
3246 #define SSB_CHIPCO_GPIOOUTEN 0x0068
3248 #define SSB_CHIPCO_GPIOIRQ 0x0074
3249 #define SSB_CHIPCO_WATCHDOG 0x0080
3250 #define SSB_CHIPCO_GPIOTIMER 0x0088 /* LED powersave (corerev >= 16) */
3251 +#define SSB_CHIPCO_GPIOTIMER_OFFTIME 0x0000FFFF
3252 +#define SSB_CHIPCO_GPIOTIMER_OFFTIME_SHIFT 0
3253 +#define SSB_CHIPCO_GPIOTIMER_ONTIME 0xFFFF0000
3254 #define SSB_CHIPCO_GPIOTIMER_ONTIME_SHIFT 16
3255 #define SSB_CHIPCO_GPIOTOUTM 0x008C /* LED powersave (corerev >= 16) */
3256 #define SSB_CHIPCO_CLOCK_N 0x0090
3257 @@ -188,8 +194,10 @@
3258 #define SSB_CHIPCO_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
3259 #define SSB_CHIPCO_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
3260 #define SSB_CHIPCO_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
3261 -#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00010000 /* HT available */
3262 -#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00020000 /* APL available */
3263 +#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
3264 +#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00020000 /* HT available */
3265 +#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
3266 +#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
3267 #define SSB_CHIPCO_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
3268 #define SSB_CHIPCO_UART0_DATA 0x0300
3269 #define SSB_CHIPCO_UART0_IMR 0x0304
3273 /** Chip specific Chip-Status register contents. */
3274 +#define SSB_CHIPCO_CHST_4322_SPROM_EXISTS 0x00000040 /* SPROM present */
3275 #define SSB_CHIPCO_CHST_4325_SPROM_OTP_SEL 0x00000003
3276 #define SSB_CHIPCO_CHST_4325_DEFCIS_SEL 0 /* OTP is powered up, use def. CIS, no SPROM */
3277 #define SSB_CHIPCO_CHST_4325_SPROM_SEL 1 /* OTP is powered up, SPROM is present */
3278 @@ -398,6 +407,18 @@
3279 #define SSB_CHIPCO_CHST_4325_RCAL_VALUE_SHIFT 4
3280 #define SSB_CHIPCO_CHST_4325_PMUTOP_2B 0x00000200 /* 1 for 2b, 0 for to 2a */
3282 +/** Macros to determine SPROM presence based on Chip-Status register. */
3283 +#define SSB_CHIPCO_CHST_4312_SPROM_PRESENT(status) \
3284 + ((status & SSB_CHIPCO_CHST_4325_SPROM_OTP_SEL) != \
3285 + SSB_CHIPCO_CHST_4325_OTP_SEL)
3286 +#define SSB_CHIPCO_CHST_4322_SPROM_PRESENT(status) \
3287 + (status & SSB_CHIPCO_CHST_4322_SPROM_EXISTS)
3288 +#define SSB_CHIPCO_CHST_4325_SPROM_PRESENT(status) \
3289 + (((status & SSB_CHIPCO_CHST_4325_SPROM_OTP_SEL) != \
3290 + SSB_CHIPCO_CHST_4325_DEFCIS_SEL) && \
3291 + ((status & SSB_CHIPCO_CHST_4325_SPROM_OTP_SEL) != \
3292 + SSB_CHIPCO_CHST_4325_OTP_SEL))
3296 /** Clockcontrol masks and values **/
3297 @@ -564,6 +585,7 @@ struct ssb_chipcommon_pmu {
3298 struct ssb_chipcommon {
3299 struct ssb_device *dev;
3302 /* Fast Powerup Delay constant */
3303 u16 fast_pwrup_delay;
3304 struct ssb_chipcommon_pmu pmu;
3305 @@ -629,5 +651,15 @@ extern int ssb_chipco_serial_init(struct
3307 extern void ssb_pmu_init(struct ssb_chipcommon *cc);
3309 +enum ssb_pmu_ldo_volt_id {
3316 +void ssb_pmu_set_ldo_voltage(struct ssb_chipcommon *cc,
3317 + enum ssb_pmu_ldo_volt_id id, u32 voltage);
3318 +void ssb_pmu_set_ldo_paref(struct ssb_chipcommon *cc, bool on);
3320 #endif /* LINUX_SSB_CHIPCO_H_ */
3321 --- a/include/linux/ssb/ssb_regs.h
3322 +++ b/include/linux/ssb/ssb_regs.h
3324 #define SSB_IMSTATE_AP_RSV 0x00000030 /* Reserved */
3325 #define SSB_IMSTATE_IBE 0x00020000 /* In Band Error */
3326 #define SSB_IMSTATE_TO 0x00040000 /* Timeout */
3327 +#define SSB_IMSTATE_BUSY 0x01800000 /* Busy (Backplane rev >= 2.3 only) */
3328 +#define SSB_IMSTATE_REJECT 0x02000000 /* Reject (Backplane rev >= 2.3 only) */
3329 #define SSB_INTVEC 0x0F94 /* SB Interrupt Mask */
3330 #define SSB_INTVEC_PCI 0x00000001 /* Enable interrupts for PCI */
3331 #define SSB_INTVEC_ENET0 0x00000002 /* Enable interrupts for enet 0 */
3333 #define SSB_INTVEC_ENET1 0x00000040 /* Enable interrupts for enet 1 */
3334 #define SSB_TMSLOW 0x0F98 /* SB Target State Low */
3335 #define SSB_TMSLOW_RESET 0x00000001 /* Reset */
3336 -#define SSB_TMSLOW_REJECT_22 0x00000002 /* Reject (Backplane rev 2.2) */
3337 +#define SSB_TMSLOW_REJECT 0x00000002 /* Reject (Standard Backplane) */
3338 #define SSB_TMSLOW_REJECT_23 0x00000004 /* Reject (Backplane rev 2.3) */
3339 #define SSB_TMSLOW_CLOCK 0x00010000 /* Clock Enable */
3340 #define SSB_TMSLOW_FGC 0x00020000 /* Force Gated Clocks On */
3343 /* SPROM shadow area. If not otherwise noted, fields are
3344 * two bytes wide. Note that the SPROM can _only_ be read
3345 - * in two-byte quantinies.
3346 + * in two-byte quantities.
3348 #define SSB_SPROMSIZE_WORDS 64
3349 #define SSB_SPROMSIZE_BYTES (SSB_SPROMSIZE_WORDS * sizeof(u16))
3350 @@ -170,26 +172,27 @@
3351 #define SSB_SPROMSIZE_WORDS_R4 220
3352 #define SSB_SPROMSIZE_BYTES_R123 (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
3353 #define SSB_SPROMSIZE_BYTES_R4 (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
3354 -#define SSB_SPROM_BASE 0x1000
3355 -#define SSB_SPROM_REVISION 0x107E
3356 +#define SSB_SPROM_BASE1 0x1000
3357 +#define SSB_SPROM_BASE31 0x0800
3358 +#define SSB_SPROM_REVISION 0x007E
3359 #define SSB_SPROM_REVISION_REV 0x00FF /* SPROM Revision number */
3360 #define SSB_SPROM_REVISION_CRC 0xFF00 /* SPROM CRC8 value */
3361 #define SSB_SPROM_REVISION_CRC_SHIFT 8
3363 /* SPROM Revision 1 */
3364 -#define SSB_SPROM1_SPID 0x1004 /* Subsystem Product ID for PCI */
3365 -#define SSB_SPROM1_SVID 0x1006 /* Subsystem Vendor ID for PCI */
3366 -#define SSB_SPROM1_PID 0x1008 /* Product ID for PCI */
3367 -#define SSB_SPROM1_IL0MAC 0x1048 /* 6 bytes MAC address for 802.11b/g */
3368 -#define SSB_SPROM1_ET0MAC 0x104E /* 6 bytes MAC address for Ethernet */
3369 -#define SSB_SPROM1_ET1MAC 0x1054 /* 6 bytes MAC address for 802.11a */
3370 -#define SSB_SPROM1_ETHPHY 0x105A /* Ethernet PHY settings */
3371 +#define SSB_SPROM1_SPID 0x0004 /* Subsystem Product ID for PCI */
3372 +#define SSB_SPROM1_SVID 0x0006 /* Subsystem Vendor ID for PCI */
3373 +#define SSB_SPROM1_PID 0x0008 /* Product ID for PCI */
3374 +#define SSB_SPROM1_IL0MAC 0x0048 /* 6 bytes MAC address for 802.11b/g */
3375 +#define SSB_SPROM1_ET0MAC 0x004E /* 6 bytes MAC address for Ethernet */
3376 +#define SSB_SPROM1_ET1MAC 0x0054 /* 6 bytes MAC address for 802.11a */
3377 +#define SSB_SPROM1_ETHPHY 0x005A /* Ethernet PHY settings */
3378 #define SSB_SPROM1_ETHPHY_ET0A 0x001F /* MII Address for enet0 */
3379 #define SSB_SPROM1_ETHPHY_ET1A 0x03E0 /* MII Address for enet1 */
3380 #define SSB_SPROM1_ETHPHY_ET1A_SHIFT 5
3381 #define SSB_SPROM1_ETHPHY_ET0M (1<<14) /* MDIO for enet0 */
3382 #define SSB_SPROM1_ETHPHY_ET1M (1<<15) /* MDIO for enet1 */
3383 -#define SSB_SPROM1_BINF 0x105C /* Board info */
3384 +#define SSB_SPROM1_BINF 0x005C /* Board info */
3385 #define SSB_SPROM1_BINF_BREV 0x00FF /* Board Revision */
3386 #define SSB_SPROM1_BINF_CCODE 0x0F00 /* Country Code */
3387 #define SSB_SPROM1_BINF_CCODE_SHIFT 8
3388 @@ -197,63 +200,63 @@
3389 #define SSB_SPROM1_BINF_ANTBG_SHIFT 12
3390 #define SSB_SPROM1_BINF_ANTA 0xC000 /* Available A-PHY antennas */
3391 #define SSB_SPROM1_BINF_ANTA_SHIFT 14
3392 -#define SSB_SPROM1_PA0B0 0x105E
3393 -#define SSB_SPROM1_PA0B1 0x1060
3394 -#define SSB_SPROM1_PA0B2 0x1062
3395 -#define SSB_SPROM1_GPIOA 0x1064 /* General Purpose IO pins 0 and 1 */
3396 +#define SSB_SPROM1_PA0B0 0x005E
3397 +#define SSB_SPROM1_PA0B1 0x0060
3398 +#define SSB_SPROM1_PA0B2 0x0062
3399 +#define SSB_SPROM1_GPIOA 0x0064 /* General Purpose IO pins 0 and 1 */
3400 #define SSB_SPROM1_GPIOA_P0 0x00FF /* Pin 0 */
3401 #define SSB_SPROM1_GPIOA_P1 0xFF00 /* Pin 1 */
3402 #define SSB_SPROM1_GPIOA_P1_SHIFT 8
3403 -#define SSB_SPROM1_GPIOB 0x1066 /* General Purpuse IO pins 2 and 3 */
3404 +#define SSB_SPROM1_GPIOB 0x0066 /* General Purpuse IO pins 2 and 3 */
3405 #define SSB_SPROM1_GPIOB_P2 0x00FF /* Pin 2 */
3406 #define SSB_SPROM1_GPIOB_P3 0xFF00 /* Pin 3 */
3407 #define SSB_SPROM1_GPIOB_P3_SHIFT 8
3408 -#define SSB_SPROM1_MAXPWR 0x1068 /* Power Amplifier Max Power */
3409 +#define SSB_SPROM1_MAXPWR 0x0068 /* Power Amplifier Max Power */
3410 #define SSB_SPROM1_MAXPWR_BG 0x00FF /* B-PHY and G-PHY (in dBm Q5.2) */
3411 #define SSB_SPROM1_MAXPWR_A 0xFF00 /* A-PHY (in dBm Q5.2) */
3412 #define SSB_SPROM1_MAXPWR_A_SHIFT 8
3413 -#define SSB_SPROM1_PA1B0 0x106A
3414 -#define SSB_SPROM1_PA1B1 0x106C
3415 -#define SSB_SPROM1_PA1B2 0x106E
3416 -#define SSB_SPROM1_ITSSI 0x1070 /* Idle TSSI Target */
3417 +#define SSB_SPROM1_PA1B0 0x006A
3418 +#define SSB_SPROM1_PA1B1 0x006C
3419 +#define SSB_SPROM1_PA1B2 0x006E
3420 +#define SSB_SPROM1_ITSSI 0x0070 /* Idle TSSI Target */
3421 #define SSB_SPROM1_ITSSI_BG 0x00FF /* B-PHY and G-PHY*/
3422 #define SSB_SPROM1_ITSSI_A 0xFF00 /* A-PHY */
3423 #define SSB_SPROM1_ITSSI_A_SHIFT 8
3424 -#define SSB_SPROM1_BFLLO 0x1072 /* Boardflags (low 16 bits) */
3425 -#define SSB_SPROM1_AGAIN 0x1074 /* Antenna Gain (in dBm Q5.2) */
3426 +#define SSB_SPROM1_BFLLO 0x0072 /* Boardflags (low 16 bits) */
3427 +#define SSB_SPROM1_AGAIN 0x0074 /* Antenna Gain (in dBm Q5.2) */
3428 #define SSB_SPROM1_AGAIN_BG 0x00FF /* B-PHY and G-PHY */
3429 #define SSB_SPROM1_AGAIN_BG_SHIFT 0
3430 #define SSB_SPROM1_AGAIN_A 0xFF00 /* A-PHY */
3431 #define SSB_SPROM1_AGAIN_A_SHIFT 8
3433 /* SPROM Revision 2 (inherits from rev 1) */
3434 -#define SSB_SPROM2_BFLHI 0x1038 /* Boardflags (high 16 bits) */
3435 -#define SSB_SPROM2_MAXP_A 0x103A /* A-PHY Max Power */
3436 +#define SSB_SPROM2_BFLHI 0x0038 /* Boardflags (high 16 bits) */
3437 +#define SSB_SPROM2_MAXP_A 0x003A /* A-PHY Max Power */
3438 #define SSB_SPROM2_MAXP_A_HI 0x00FF /* Max Power High */
3439 #define SSB_SPROM2_MAXP_A_LO 0xFF00 /* Max Power Low */
3440 #define SSB_SPROM2_MAXP_A_LO_SHIFT 8
3441 -#define SSB_SPROM2_PA1LOB0 0x103C /* A-PHY PowerAmplifier Low Settings */
3442 -#define SSB_SPROM2_PA1LOB1 0x103E /* A-PHY PowerAmplifier Low Settings */
3443 -#define SSB_SPROM2_PA1LOB2 0x1040 /* A-PHY PowerAmplifier Low Settings */
3444 -#define SSB_SPROM2_PA1HIB0 0x1042 /* A-PHY PowerAmplifier High Settings */
3445 -#define SSB_SPROM2_PA1HIB1 0x1044 /* A-PHY PowerAmplifier High Settings */
3446 -#define SSB_SPROM2_PA1HIB2 0x1046 /* A-PHY PowerAmplifier High Settings */
3447 -#define SSB_SPROM2_OPO 0x1078 /* OFDM Power Offset from CCK Level */
3448 +#define SSB_SPROM2_PA1LOB0 0x003C /* A-PHY PowerAmplifier Low Settings */
3449 +#define SSB_SPROM2_PA1LOB1 0x003E /* A-PHY PowerAmplifier Low Settings */
3450 +#define SSB_SPROM2_PA1LOB2 0x0040 /* A-PHY PowerAmplifier Low Settings */
3451 +#define SSB_SPROM2_PA1HIB0 0x0042 /* A-PHY PowerAmplifier High Settings */
3452 +#define SSB_SPROM2_PA1HIB1 0x0044 /* A-PHY PowerAmplifier High Settings */
3453 +#define SSB_SPROM2_PA1HIB2 0x0046 /* A-PHY PowerAmplifier High Settings */
3454 +#define SSB_SPROM2_OPO 0x0078 /* OFDM Power Offset from CCK Level */
3455 #define SSB_SPROM2_OPO_VALUE 0x00FF
3456 #define SSB_SPROM2_OPO_UNUSED 0xFF00
3457 -#define SSB_SPROM2_CCODE 0x107C /* Two char Country Code */
3458 +#define SSB_SPROM2_CCODE 0x007C /* Two char Country Code */
3460 /* SPROM Revision 3 (inherits most data from rev 2) */
3461 -#define SSB_SPROM3_IL0MAC 0x104A /* 6 bytes MAC address for 802.11b/g */
3462 -#define SSB_SPROM3_OFDMAPO 0x102C /* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */
3463 -#define SSB_SPROM3_OFDMALPO 0x1030 /* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */
3464 -#define SSB_SPROM3_OFDMAHPO 0x1034 /* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */
3465 -#define SSB_SPROM3_GPIOLDC 0x1042 /* GPIO LED Powersave Duty Cycle (4 bytes, BigEndian) */
3466 +#define SSB_SPROM3_OFDMAPO 0x002C /* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */
3467 +#define SSB_SPROM3_OFDMALPO 0x0030 /* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */
3468 +#define SSB_SPROM3_OFDMAHPO 0x0034 /* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */
3469 +#define SSB_SPROM3_GPIOLDC 0x0042 /* GPIO LED Powersave Duty Cycle (4 bytes, BigEndian) */
3470 #define SSB_SPROM3_GPIOLDC_OFF 0x0000FF00 /* Off Count */
3471 #define SSB_SPROM3_GPIOLDC_OFF_SHIFT 8
3472 #define SSB_SPROM3_GPIOLDC_ON 0x00FF0000 /* On Count */
3473 #define SSB_SPROM3_GPIOLDC_ON_SHIFT 16
3474 -#define SSB_SPROM3_CCKPO 0x1078 /* CCK Power Offset */
3475 +#define SSB_SPROM3_IL0MAC 0x004A /* 6 bytes MAC address for 802.11b/g */
3476 +#define SSB_SPROM3_CCKPO 0x0078 /* CCK Power Offset */
3477 #define SSB_SPROM3_CCKPO_1M 0x000F /* 1M Rate PO */
3478 #define SSB_SPROM3_CCKPO_2M 0x00F0 /* 2M Rate PO */
3479 #define SSB_SPROM3_CCKPO_2M_SHIFT 4
3480 @@ -264,104 +267,200 @@
3481 #define SSB_SPROM3_OFDMGPO 0x107A /* G-PHY OFDM Power Offset (4 bytes, BigEndian) */
3483 /* SPROM Revision 4 */
3484 -#define SSB_SPROM4_IL0MAC 0x104C /* 6 byte MAC address for a/b/g/n */
3485 -#define SSB_SPROM4_ETHPHY 0x105A /* Ethernet PHY settings ?? */
3486 +#define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */
3487 +#define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */
3488 +#define SSB_SPROM4_BFL2LO 0x0048 /* Board flags 2 (low 16 bits) */
3489 +#define SSB_SPROM4_BFL2HI 0x004A /* Board flags 2 Hi */
3490 +#define SSB_SPROM4_IL0MAC 0x004C /* 6 byte MAC address for a/b/g/n */
3491 +#define SSB_SPROM4_CCODE 0x0052 /* Country Code (2 bytes) */
3492 +#define SSB_SPROM4_GPIOA 0x0056 /* Gen. Purpose IO # 0 and 1 */
3493 +#define SSB_SPROM4_GPIOA_P0 0x00FF /* Pin 0 */
3494 +#define SSB_SPROM4_GPIOA_P1 0xFF00 /* Pin 1 */
3495 +#define SSB_SPROM4_GPIOA_P1_SHIFT 8
3496 +#define SSB_SPROM4_GPIOB 0x0058 /* Gen. Purpose IO # 2 and 3 */
3497 +#define SSB_SPROM4_GPIOB_P2 0x00FF /* Pin 2 */
3498 +#define SSB_SPROM4_GPIOB_P3 0xFF00 /* Pin 3 */
3499 +#define SSB_SPROM4_GPIOB_P3_SHIFT 8
3500 +#define SSB_SPROM4_ETHPHY 0x005A /* Ethernet PHY settings ?? */
3501 #define SSB_SPROM4_ETHPHY_ET0A 0x001F /* MII Address for enet0 */
3502 #define SSB_SPROM4_ETHPHY_ET1A 0x03E0 /* MII Address for enet1 */
3503 #define SSB_SPROM4_ETHPHY_ET1A_SHIFT 5
3504 #define SSB_SPROM4_ETHPHY_ET0M (1<<14) /* MDIO for enet0 */
3505 #define SSB_SPROM4_ETHPHY_ET1M (1<<15) /* MDIO for enet1 */
3506 -#define SSB_SPROM4_CCODE 0x1052 /* Country Code (2 bytes) */
3507 -#define SSB_SPROM4_ANTAVAIL 0x105D /* Antenna available bitfields */
3508 -#define SSB_SPROM4_ANTAVAIL_A 0x00FF /* A-PHY bitfield */
3509 -#define SSB_SPROM4_ANTAVAIL_A_SHIFT 0
3510 -#define SSB_SPROM4_ANTAVAIL_BG 0xFF00 /* B-PHY and G-PHY bitfield */
3511 -#define SSB_SPROM4_ANTAVAIL_BG_SHIFT 8
3512 -#define SSB_SPROM4_BFLLO 0x1044 /* Boardflags (low 16 bits) */
3513 -#define SSB_SPROM4_AGAIN01 0x105E /* Antenna Gain (in dBm Q5.2) */
3514 +#define SSB_SPROM4_ANTAVAIL 0x005D /* Antenna available bitfields */
3515 +#define SSB_SPROM4_ANTAVAIL_A 0x00FF /* A-PHY bitfield */
3516 +#define SSB_SPROM4_ANTAVAIL_A_SHIFT 0
3517 +#define SSB_SPROM4_ANTAVAIL_BG 0xFF00 /* B-PHY and G-PHY bitfield */
3518 +#define SSB_SPROM4_ANTAVAIL_BG_SHIFT 8
3519 +#define SSB_SPROM4_AGAIN01 0x005E /* Antenna Gain (in dBm Q5.2) */
3520 #define SSB_SPROM4_AGAIN0 0x00FF /* Antenna 0 */
3521 #define SSB_SPROM4_AGAIN0_SHIFT 0
3522 #define SSB_SPROM4_AGAIN1 0xFF00 /* Antenna 1 */
3523 #define SSB_SPROM4_AGAIN1_SHIFT 8
3524 -#define SSB_SPROM4_AGAIN23 0x1060
3525 +#define SSB_SPROM4_AGAIN23 0x0060
3526 #define SSB_SPROM4_AGAIN2 0x00FF /* Antenna 2 */
3527 #define SSB_SPROM4_AGAIN2_SHIFT 0
3528 #define SSB_SPROM4_AGAIN3 0xFF00 /* Antenna 3 */
3529 #define SSB_SPROM4_AGAIN3_SHIFT 8
3530 -#define SSB_SPROM4_BFLHI 0x1046 /* Board Flags Hi */
3531 -#define SSB_SPROM4_MAXP_BG 0x1080 /* Max Power BG in path 1 */
3532 +#define SSB_SPROM4_TXPID2G01 0x0062 /* TX Power Index 2GHz */
3533 +#define SSB_SPROM4_TXPID2G0 0x00FF
3534 +#define SSB_SPROM4_TXPID2G0_SHIFT 0
3535 +#define SSB_SPROM4_TXPID2G1 0xFF00
3536 +#define SSB_SPROM4_TXPID2G1_SHIFT 8
3537 +#define SSB_SPROM4_TXPID2G23 0x0064 /* TX Power Index 2GHz */
3538 +#define SSB_SPROM4_TXPID2G2 0x00FF
3539 +#define SSB_SPROM4_TXPID2G2_SHIFT 0
3540 +#define SSB_SPROM4_TXPID2G3 0xFF00
3541 +#define SSB_SPROM4_TXPID2G3_SHIFT 8
3542 +#define SSB_SPROM4_TXPID5G01 0x0066 /* TX Power Index 5GHz middle subband */
3543 +#define SSB_SPROM4_TXPID5G0 0x00FF
3544 +#define SSB_SPROM4_TXPID5G0_SHIFT 0
3545 +#define SSB_SPROM4_TXPID5G1 0xFF00
3546 +#define SSB_SPROM4_TXPID5G1_SHIFT 8
3547 +#define SSB_SPROM4_TXPID5G23 0x0068 /* TX Power Index 5GHz middle subband */
3548 +#define SSB_SPROM4_TXPID5G2 0x00FF
3549 +#define SSB_SPROM4_TXPID5G2_SHIFT 0
3550 +#define SSB_SPROM4_TXPID5G3 0xFF00
3551 +#define SSB_SPROM4_TXPID5G3_SHIFT 8
3552 +#define SSB_SPROM4_TXPID5GL01 0x006A /* TX Power Index 5GHz low subband */
3553 +#define SSB_SPROM4_TXPID5GL0 0x00FF
3554 +#define SSB_SPROM4_TXPID5GL0_SHIFT 0
3555 +#define SSB_SPROM4_TXPID5GL1 0xFF00
3556 +#define SSB_SPROM4_TXPID5GL1_SHIFT 8
3557 +#define SSB_SPROM4_TXPID5GL23 0x006C /* TX Power Index 5GHz low subband */
3558 +#define SSB_SPROM4_TXPID5GL2 0x00FF
3559 +#define SSB_SPROM4_TXPID5GL2_SHIFT 0
3560 +#define SSB_SPROM4_TXPID5GL3 0xFF00
3561 +#define SSB_SPROM4_TXPID5GL3_SHIFT 8
3562 +#define SSB_SPROM4_TXPID5GH01 0x006E /* TX Power Index 5GHz high subband */
3563 +#define SSB_SPROM4_TXPID5GH0 0x00FF
3564 +#define SSB_SPROM4_TXPID5GH0_SHIFT 0
3565 +#define SSB_SPROM4_TXPID5GH1 0xFF00
3566 +#define SSB_SPROM4_TXPID5GH1_SHIFT 8
3567 +#define SSB_SPROM4_TXPID5GH23 0x0070 /* TX Power Index 5GHz high subband */
3568 +#define SSB_SPROM4_TXPID5GH2 0x00FF
3569 +#define SSB_SPROM4_TXPID5GH2_SHIFT 0
3570 +#define SSB_SPROM4_TXPID5GH3 0xFF00
3571 +#define SSB_SPROM4_TXPID5GH3_SHIFT 8
3572 +#define SSB_SPROM4_MAXP_BG 0x0080 /* Max Power BG in path 1 */
3573 #define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */
3574 #define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
3575 #define SSB_SPROM4_ITSSI_BG_SHIFT 8
3576 -#define SSB_SPROM4_MAXP_A 0x108A /* Max Power A in path 1 */
3577 +#define SSB_SPROM4_MAXP_A 0x008A /* Max Power A in path 1 */
3578 #define SSB_SPROM4_MAXP_A_MASK 0x00FF /* Mask for Max Power A */
3579 #define SSB_SPROM4_ITSSI_A 0xFF00 /* Mask for path 1 itssi_a */
3580 #define SSB_SPROM4_ITSSI_A_SHIFT 8
3581 -#define SSB_SPROM4_GPIOA 0x1056 /* Gen. Purpose IO # 0 and 1 */
3582 -#define SSB_SPROM4_GPIOA_P0 0x00FF /* Pin 0 */
3583 -#define SSB_SPROM4_GPIOA_P1 0xFF00 /* Pin 1 */
3584 -#define SSB_SPROM4_GPIOA_P1_SHIFT 8
3585 -#define SSB_SPROM4_GPIOB 0x1058 /* Gen. Purpose IO # 2 and 3 */
3586 -#define SSB_SPROM4_GPIOB_P2 0x00FF /* Pin 2 */
3587 -#define SSB_SPROM4_GPIOB_P3 0xFF00 /* Pin 3 */
3588 -#define SSB_SPROM4_GPIOB_P3_SHIFT 8
3589 -#define SSB_SPROM4_PA0B0 0x1082 /* The paXbY locations are */
3590 -#define SSB_SPROM4_PA0B1 0x1084 /* only guesses */
3591 -#define SSB_SPROM4_PA0B2 0x1086
3592 -#define SSB_SPROM4_PA1B0 0x108E
3593 -#define SSB_SPROM4_PA1B1 0x1090
3594 -#define SSB_SPROM4_PA1B2 0x1092
3595 +#define SSB_SPROM4_PA0B0 0x0082 /* The paXbY locations are */
3596 +#define SSB_SPROM4_PA0B1 0x0084 /* only guesses */
3597 +#define SSB_SPROM4_PA0B2 0x0086
3598 +#define SSB_SPROM4_PA1B0 0x008E
3599 +#define SSB_SPROM4_PA1B1 0x0090
3600 +#define SSB_SPROM4_PA1B2 0x0092
3602 /* SPROM Revision 5 (inherits most data from rev 4) */
3603 -#define SSB_SPROM5_BFLLO 0x104A /* Boardflags (low 16 bits) */
3604 -#define SSB_SPROM5_BFLHI 0x104C /* Board Flags Hi */
3605 -#define SSB_SPROM5_IL0MAC 0x1052 /* 6 byte MAC address for a/b/g/n */
3606 -#define SSB_SPROM5_CCODE 0x1044 /* Country Code (2 bytes) */
3607 -#define SSB_SPROM5_GPIOA 0x1076 /* Gen. Purpose IO # 0 and 1 */
3608 +#define SSB_SPROM5_CCODE 0x0044 /* Country Code (2 bytes) */
3609 +#define SSB_SPROM5_BFLLO 0x004A /* Boardflags (low 16 bits) */
3610 +#define SSB_SPROM5_BFLHI 0x004C /* Board Flags Hi */
3611 +#define SSB_SPROM5_BFL2LO 0x004E /* Board flags 2 (low 16 bits) */
3612 +#define SSB_SPROM5_BFL2HI 0x0050 /* Board flags 2 Hi */
3613 +#define SSB_SPROM5_IL0MAC 0x0052 /* 6 byte MAC address for a/b/g/n */
3614 +#define SSB_SPROM5_GPIOA 0x0076 /* Gen. Purpose IO # 0 and 1 */
3615 #define SSB_SPROM5_GPIOA_P0 0x00FF /* Pin 0 */
3616 #define SSB_SPROM5_GPIOA_P1 0xFF00 /* Pin 1 */
3617 #define SSB_SPROM5_GPIOA_P1_SHIFT 8
3618 -#define SSB_SPROM5_GPIOB 0x1078 /* Gen. Purpose IO # 2 and 3 */
3619 +#define SSB_SPROM5_GPIOB 0x0078 /* Gen. Purpose IO # 2 and 3 */
3620 #define SSB_SPROM5_GPIOB_P2 0x00FF /* Pin 2 */
3621 #define SSB_SPROM5_GPIOB_P3 0xFF00 /* Pin 3 */
3622 #define SSB_SPROM5_GPIOB_P3_SHIFT 8
3624 /* SPROM Revision 8 */
3625 -#define SSB_SPROM8_BFLLO 0x1084 /* Boardflags (low 16 bits) */
3626 -#define SSB_SPROM8_BFLHI 0x1086 /* Boardflags Hi */
3627 -#define SSB_SPROM8_IL0MAC 0x108C /* 6 byte MAC address */
3628 -#define SSB_SPROM8_CCODE 0x1092 /* 2 byte country code */
3629 -#define SSB_SPROM8_ANTAVAIL 0x109C /* Antenna available bitfields*/
3630 -#define SSB_SPROM8_ANTAVAIL_A 0xFF00 /* A-PHY bitfield */
3631 -#define SSB_SPROM8_ANTAVAIL_A_SHIFT 8
3632 -#define SSB_SPROM8_ANTAVAIL_BG 0x00FF /* B-PHY and G-PHY bitfield */
3633 -#define SSB_SPROM8_ANTAVAIL_BG_SHIFT 0
3634 -#define SSB_SPROM8_AGAIN01 0x109E /* Antenna Gain (in dBm Q5.2) */
3635 +#define SSB_SPROM8_BOARDREV 0x0082 /* Board revision */
3636 +#define SSB_SPROM8_BFLLO 0x0084 /* Board flags (bits 0-15) */
3637 +#define SSB_SPROM8_BFLHI 0x0086 /* Board flags (bits 16-31) */
3638 +#define SSB_SPROM8_BFL2LO 0x0088 /* Board flags (bits 32-47) */
3639 +#define SSB_SPROM8_BFL2HI 0x008A /* Board flags (bits 48-63) */
3640 +#define SSB_SPROM8_IL0MAC 0x008C /* 6 byte MAC address */
3641 +#define SSB_SPROM8_CCODE 0x0092 /* 2 byte country code */
3642 +#define SSB_SPROM8_GPIOA 0x0096 /*Gen. Purpose IO # 0 and 1 */
3643 +#define SSB_SPROM8_GPIOA_P0 0x00FF /* Pin 0 */
3644 +#define SSB_SPROM8_GPIOA_P1 0xFF00 /* Pin 1 */
3645 +#define SSB_SPROM8_GPIOA_P1_SHIFT 8
3646 +#define SSB_SPROM8_GPIOB 0x0098 /* Gen. Purpose IO # 2 and 3 */
3647 +#define SSB_SPROM8_GPIOB_P2 0x00FF /* Pin 2 */
3648 +#define SSB_SPROM8_GPIOB_P3 0xFF00 /* Pin 3 */
3649 +#define SSB_SPROM8_GPIOB_P3_SHIFT 8
3650 +#define SSB_SPROM8_ANTAVAIL 0x009C /* Antenna available bitfields*/
3651 +#define SSB_SPROM8_ANTAVAIL_A 0xFF00 /* A-PHY bitfield */
3652 +#define SSB_SPROM8_ANTAVAIL_A_SHIFT 8
3653 +#define SSB_SPROM8_ANTAVAIL_BG 0x00FF /* B-PHY and G-PHY bitfield */
3654 +#define SSB_SPROM8_ANTAVAIL_BG_SHIFT 0
3655 +#define SSB_SPROM8_AGAIN01 0x009E /* Antenna Gain (in dBm Q5.2) */
3656 #define SSB_SPROM8_AGAIN0 0x00FF /* Antenna 0 */
3657 #define SSB_SPROM8_AGAIN0_SHIFT 0
3658 #define SSB_SPROM8_AGAIN1 0xFF00 /* Antenna 1 */
3659 #define SSB_SPROM8_AGAIN1_SHIFT 8
3660 -#define SSB_SPROM8_AGAIN23 0x10A0
3661 +#define SSB_SPROM8_AGAIN23 0x00A0
3662 #define SSB_SPROM8_AGAIN2 0x00FF /* Antenna 2 */
3663 #define SSB_SPROM8_AGAIN2_SHIFT 0
3664 #define SSB_SPROM8_AGAIN3 0xFF00 /* Antenna 3 */
3665 #define SSB_SPROM8_AGAIN3_SHIFT 8
3666 -#define SSB_SPROM8_GPIOA 0x1096 /*Gen. Purpose IO # 0 and 1 */
3667 -#define SSB_SPROM8_GPIOA_P0 0x00FF /* Pin 0 */
3668 -#define SSB_SPROM8_GPIOA_P1 0xFF00 /* Pin 1 */
3669 -#define SSB_SPROM8_GPIOA_P1_SHIFT 8
3670 -#define SSB_SPROM8_GPIOB 0x1098 /* Gen. Purpose IO # 2 and 3 */
3671 -#define SSB_SPROM8_GPIOB_P2 0x00FF /* Pin 2 */
3672 -#define SSB_SPROM8_GPIOB_P3 0xFF00 /* Pin 3 */
3673 -#define SSB_SPROM8_GPIOB_P3_SHIFT 8
3674 -#define SSB_SPROM8_MAXP_BG 0x10C0 /* Max Power BG in path 1 */
3675 -#define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */
3676 +#define SSB_SPROM8_RSSIPARM2G 0x00A4 /* RSSI params for 2GHz */
3677 +#define SSB_SPROM8_RSSISMF2G 0x000F
3678 +#define SSB_SPROM8_RSSISMC2G 0x00F0
3679 +#define SSB_SPROM8_RSSISMC2G_SHIFT 4
3680 +#define SSB_SPROM8_RSSISAV2G 0x0700
3681 +#define SSB_SPROM8_RSSISAV2G_SHIFT 8
3682 +#define SSB_SPROM8_BXA2G 0x1800
3683 +#define SSB_SPROM8_BXA2G_SHIFT 11
3684 +#define SSB_SPROM8_RSSIPARM5G 0x00A6 /* RSSI params for 5GHz */
3685 +#define SSB_SPROM8_RSSISMF5G 0x000F
3686 +#define SSB_SPROM8_RSSISMC5G 0x00F0
3687 +#define SSB_SPROM8_RSSISMC5G_SHIFT 4
3688 +#define SSB_SPROM8_RSSISAV5G 0x0700
3689 +#define SSB_SPROM8_RSSISAV5G_SHIFT 8
3690 +#define SSB_SPROM8_BXA5G 0x1800
3691 +#define SSB_SPROM8_BXA5G_SHIFT 11
3692 +#define SSB_SPROM8_TRI25G 0x00A8 /* TX isolation 2.4&5.3GHz */
3693 +#define SSB_SPROM8_TRI2G 0x00FF /* TX isolation 2.4GHz */
3694 +#define SSB_SPROM8_TRI5G 0xFF00 /* TX isolation 5.3GHz */
3695 +#define SSB_SPROM8_TRI5G_SHIFT 8
3696 +#define SSB_SPROM8_TRI5GHL 0x00AA /* TX isolation 5.2/5.8GHz */
3697 +#define SSB_SPROM8_TRI5GL 0x00FF /* TX isolation 5.2GHz */
3698 +#define SSB_SPROM8_TRI5GH 0xFF00 /* TX isolation 5.8GHz */
3699 +#define SSB_SPROM8_TRI5GH_SHIFT 8
3700 +#define SSB_SPROM8_RXPO 0x00AC /* RX power offsets */
3701 +#define SSB_SPROM8_RXPO2G 0x00FF /* 2GHz RX power offset */
3702 +#define SSB_SPROM8_RXPO5G 0xFF00 /* 5GHz RX power offset */
3703 +#define SSB_SPROM8_RXPO5G_SHIFT 8
3704 +#define SSB_SPROM8_MAXP_BG 0x00C0 /* Max Power 2GHz in path 1 */
3705 +#define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power 2GHz */
3706 #define SSB_SPROM8_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
3707 #define SSB_SPROM8_ITSSI_BG_SHIFT 8
3708 -#define SSB_SPROM8_MAXP_A 0x10C8 /* Max Power A in path 1 */
3709 -#define SSB_SPROM8_MAXP_A_MASK 0x00FF /* Mask for Max Power A */
3710 +#define SSB_SPROM8_PA0B0 0x00C2 /* 2GHz power amp settings */
3711 +#define SSB_SPROM8_PA0B1 0x00C4
3712 +#define SSB_SPROM8_PA0B2 0x00C6
3713 +#define SSB_SPROM8_MAXP_A 0x00C8 /* Max Power 5.3GHz */
3714 +#define SSB_SPROM8_MAXP_A_MASK 0x00FF /* Mask for Max Power 5.3GHz */
3715 #define SSB_SPROM8_ITSSI_A 0xFF00 /* Mask for path 1 itssi_a */
3716 #define SSB_SPROM8_ITSSI_A_SHIFT 8
3717 +#define SSB_SPROM8_MAXP_AHL 0x00CA /* Max Power 5.2/5.8GHz */
3718 +#define SSB_SPROM8_MAXP_AH_MASK 0x00FF /* Mask for Max Power 5.8GHz */
3719 +#define SSB_SPROM8_MAXP_AL_MASK 0xFF00 /* Mask for Max Power 5.2GHz */
3720 +#define SSB_SPROM8_MAXP_AL_SHIFT 8
3721 +#define SSB_SPROM8_PA1B0 0x00CC /* 5.3GHz power amp settings */
3722 +#define SSB_SPROM8_PA1B1 0x00CE
3723 +#define SSB_SPROM8_PA1B2 0x00D0
3724 +#define SSB_SPROM8_PA1LOB0 0x00D2 /* 5.2GHz power amp settings */
3725 +#define SSB_SPROM8_PA1LOB1 0x00D4
3726 +#define SSB_SPROM8_PA1LOB2 0x00D6
3727 +#define SSB_SPROM8_PA1HIB0 0x00D8 /* 5.8GHz power amp settings */
3728 +#define SSB_SPROM8_PA1HIB1 0x00DA
3729 +#define SSB_SPROM8_PA1HIB2 0x00DC
3730 +#define SSB_SPROM8_CCK2GPO 0x0140 /* CCK power offset */
3731 +#define SSB_SPROM8_OFDM2GPO 0x0142 /* 2.4GHz OFDM power offset */
3732 +#define SSB_SPROM8_OFDM5GPO 0x0146 /* 5.3GHz OFDM power offset */
3733 +#define SSB_SPROM8_OFDM5GLPO 0x014A /* 5.2GHz OFDM power offset */
3734 +#define SSB_SPROM8_OFDM5GHPO 0x014E /* 5.8GHz OFDM power offset */
3736 /* Values for SSB_SPROM1_BINF_CCODE */