1 --- a/drivers/ssb/driver_chipcommon.c
2 +++ b/drivers/ssb/driver_chipcommon.c
4 * Broadcom ChipCommon core driver
6 * Copyright 2005, Broadcom Corporation
7 - * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
8 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
10 * Licensed under the GNU/GPL. See COPYING for details.
12 @@ -46,40 +46,66 @@ void ssb_chipco_set_clockmode(struct ssb
17 + /* We support SLOW only on 6..9 */
18 + if (ccdev->id.revision >= 10 && mode == SSB_CLKMODE_SLOW)
19 + mode = SSB_CLKMODE_DYNAMIC;
21 + if (cc->capabilities & SSB_CHIPCO_CAP_PMU)
22 + return; /* PMU controls clockmode, separated function needed */
23 + SSB_WARN_ON(ccdev->id.revision >= 20);
25 /* chipcommon cores prior to rev6 don't support dynamic clock control */
26 if (ccdev->id.revision < 6)
28 - /* chipcommon cores rev10 are a whole new ball game */
30 + /* ChipCommon cores rev10+ need testing */
31 if (ccdev->id.revision >= 10)
34 if (!(cc->capabilities & SSB_CHIPCO_CAP_PCTL))
38 - case SSB_CLKMODE_SLOW:
39 + case SSB_CLKMODE_SLOW: /* For revs 6..9 only */
40 tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
41 tmp |= SSB_CHIPCO_SLOWCLKCTL_FSLOW;
42 chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
44 case SSB_CLKMODE_FAST:
45 - ssb_pci_xtal(bus, SSB_GPIO_XTAL, 1); /* Force crystal on */
46 - tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
47 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
48 - tmp |= SSB_CHIPCO_SLOWCLKCTL_IPLL;
49 - chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
50 + if (ccdev->id.revision < 10) {
51 + ssb_pci_xtal(bus, SSB_GPIO_XTAL, 1); /* Force crystal on */
52 + tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
53 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
54 + tmp |= SSB_CHIPCO_SLOWCLKCTL_IPLL;
55 + chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
57 + chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
58 + (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) |
59 + SSB_CHIPCO_SYSCLKCTL_FORCEHT));
60 + /* udelay(150); TODO: not available in early init */
63 case SSB_CLKMODE_DYNAMIC:
64 - tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
65 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
66 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_IPLL;
67 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
68 - if ((tmp & SSB_CHIPCO_SLOWCLKCTL_SRC) != SSB_CHIPCO_SLOWCLKCTL_SRC_XTAL)
69 - tmp |= SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
70 - chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
72 - /* for dynamic control, we have to release our xtal_pu "force on" */
73 - if (tmp & SSB_CHIPCO_SLOWCLKCTL_ENXTAL)
74 - ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
75 + if (ccdev->id.revision < 10) {
76 + tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
77 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
78 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_IPLL;
79 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
80 + if ((tmp & SSB_CHIPCO_SLOWCLKCTL_SRC) !=
81 + SSB_CHIPCO_SLOWCLKCTL_SRC_XTAL)
82 + tmp |= SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
83 + chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
85 + /* For dynamic control, we have to release our xtal_pu
87 + if (tmp & SSB_CHIPCO_SLOWCLKCTL_ENXTAL)
88 + ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
90 + chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
91 + (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) &
92 + ~SSB_CHIPCO_SYSCLKCTL_FORCEHT));
97 @@ -260,6 +286,12 @@ void ssb_chipcommon_init(struct ssb_chip
98 if (cc->dev->id.revision >= 11)
99 cc->status = chipco_read32(cc, SSB_CHIPCO_CHIPSTAT);
100 ssb_dprintk(KERN_INFO PFX "chipcommon status is 0x%x\n", cc->status);
102 + if (cc->dev->id.revision >= 20) {
103 + chipco_write32(cc, SSB_CHIPCO_GPIOPULLUP, 0);
104 + chipco_write32(cc, SSB_CHIPCO_GPIOPULLDOWN, 0);
108 chipco_powercontrol_init(cc);
109 ssb_chipco_set_clockmode(cc, SSB_CLKMODE_FAST);
110 --- a/drivers/ssb/driver_chipcommon_pmu.c
111 +++ b/drivers/ssb/driver_chipcommon_pmu.c
113 * Sonics Silicon Backplane
114 * Broadcom ChipCommon Power Management Unit driver
116 - * Copyright 2009, Michael Buesch <mb@bu3sch.de>
117 + * Copyright 2009, Michael Buesch <m@bues.ch>
118 * Copyright 2007, Broadcom Corporation
120 * Licensed under the GNU/GPL. See COPYING for details.
122 #include <linux/ssb/ssb_regs.h>
123 #include <linux/ssb/ssb_driver_chipcommon.h>
124 #include <linux/delay.h>
125 +#ifdef CONFIG_BCM47XX
126 +#include <asm/mach-bcm47xx/nvram.h>
129 #include "ssb_private.h"
131 @@ -91,10 +94,6 @@ static void ssb_pmu0_pllinit_r0(struct s
132 u32 pmuctl, tmp, pllctl;
135 - if ((bus->chip_id == 0x5354) && !crystalfreq) {
136 - /* The 5354 crystal freq is 25MHz */
137 - crystalfreq = 25000;
140 e = pmu0_plltab_find_entry(crystalfreq);
142 @@ -320,7 +319,11 @@ static void ssb_pmu_pll_init(struct ssb_
143 u32 crystalfreq = 0; /* in kHz. 0 = keep default freq. */
145 if (bus->bustype == SSB_BUSTYPE_SSB) {
146 - /* TODO: The user may override the crystal frequency. */
147 +#ifdef CONFIG_BCM47XX
149 + if (nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
150 + crystalfreq = simple_strtoul(buf, NULL, 0);
154 switch (bus->chip_id) {
155 @@ -329,7 +332,11 @@ static void ssb_pmu_pll_init(struct ssb_
156 ssb_pmu1_pllinit_r0(cc, crystalfreq);
159 + ssb_pmu0_pllinit_r0(cc, crystalfreq);
162 + if (crystalfreq == 0)
163 + crystalfreq = 25000;
164 ssb_pmu0_pllinit_r0(cc, crystalfreq);
167 @@ -417,12 +424,14 @@ static void ssb_pmu_resources_init(struc
168 u32 min_msk = 0, max_msk = 0;
170 const struct pmu_res_updown_tab_entry *updown_tab = NULL;
171 - unsigned int updown_tab_size;
172 + unsigned int updown_tab_size = 0;
173 const struct pmu_res_depend_tab_entry *depend_tab = NULL;
174 - unsigned int depend_tab_size;
175 + unsigned int depend_tab_size = 0;
177 switch (bus->chip_id) {
182 /* We keep the default settings:
184 @@ -604,3 +613,34 @@ void ssb_pmu_set_ldo_paref(struct ssb_ch
186 EXPORT_SYMBOL(ssb_pmu_set_ldo_voltage);
187 EXPORT_SYMBOL(ssb_pmu_set_ldo_paref);
189 +u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc)
191 + struct ssb_bus *bus = cc->dev->bus;
193 + switch (bus->chip_id) {
195 + /* 5354 chip uses a non programmable PLL of frequency 240MHz */
198 + ssb_printk(KERN_ERR PFX
199 + "ERROR: PMU cpu clock unknown for device %04X\n",
205 +u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc)
207 + struct ssb_bus *bus = cc->dev->bus;
209 + switch (bus->chip_id) {
213 + ssb_printk(KERN_ERR PFX
214 + "ERROR: PMU controlclock unknown for device %04X\n",
219 --- a/drivers/ssb/driver_gige.c
220 +++ b/drivers/ssb/driver_gige.c
222 * Broadcom Gigabit Ethernet core driver
224 * Copyright 2008, Broadcom Corporation
225 - * Copyright 2008, Michael Buesch <mb@bu3sch.de>
226 + * Copyright 2008, Michael Buesch <m@bues.ch>
228 * Licensed under the GNU/GPL. See COPYING for details.
230 @@ -106,8 +106,9 @@ void gige_pcicfg_write32(struct ssb_gige
231 gige_write32(dev, SSB_GIGE_PCICFG + offset, value);
234 -static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn,
235 - int reg, int size, u32 *val)
236 +static int __devinit ssb_gige_pci_read_config(struct pci_bus *bus,
237 + unsigned int devfn, int reg,
238 + int size, u32 *val)
240 struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
242 @@ -136,8 +137,9 @@ static int ssb_gige_pci_read_config(stru
243 return PCIBIOS_SUCCESSFUL;
246 -static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn,
247 - int reg, int size, u32 val)
248 +static int __devinit ssb_gige_pci_write_config(struct pci_bus *bus,
249 + unsigned int devfn, int reg,
252 struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
254 @@ -166,7 +168,8 @@ static int ssb_gige_pci_write_config(str
255 return PCIBIOS_SUCCESSFUL;
258 -static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
259 +static int __devinit ssb_gige_probe(struct ssb_device *sdev,
260 + const struct ssb_device_id *id)
262 struct ssb_gige *dev;
263 u32 base, tmslow, tmshigh;
264 --- a/drivers/ssb/driver_pcicore.c
265 +++ b/drivers/ssb/driver_pcicore.c
267 * Broadcom PCI-core driver
269 * Copyright 2005, Broadcom Corporation
270 - * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
271 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
273 * Licensed under the GNU/GPL. See COPYING for details.
277 #include "ssb_private.h"
279 +static u32 ssb_pcie_read(struct ssb_pcicore *pc, u32 address);
280 +static void ssb_pcie_write(struct ssb_pcicore *pc, u32 address, u32 data);
281 +static u16 ssb_pcie_mdio_read(struct ssb_pcicore *pc, u8 device, u8 address);
282 +static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
283 + u8 address, u16 data);
286 u32 pcicore_read32(struct ssb_pcicore *pc, u16 offset)
287 @@ -69,7 +74,7 @@ static u32 get_cfgspace_addr(struct ssb_
290 /* We do only have one cardbus device behind the bridge. */
291 - if (pc->cardbusmode && (dev >= 1))
292 + if (pc->cardbusmode && (dev > 1))
296 @@ -309,7 +314,7 @@ int ssb_pcicore_pcibios_map_irq(const st
297 return ssb_mips_irq(extpci_core->dev) + 2;
300 -static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
301 +static void __devinit ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
305 @@ -374,7 +379,7 @@ static void ssb_pcicore_init_hostmode(st
306 register_pci_controller(&ssb_pcicore_controller);
309 -static int pcicore_is_in_hostmode(struct ssb_pcicore *pc)
310 +static int __devinit pcicore_is_in_hostmode(struct ssb_pcicore *pc)
312 struct ssb_bus *bus = pc->dev->bus;
314 @@ -403,25 +408,137 @@ static int pcicore_is_in_hostmode(struct
316 #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
318 +/**************************************************
320 + **************************************************/
322 +static void __devinit ssb_pcicore_fix_sprom_core_index(struct ssb_pcicore *pc)
324 + u16 tmp = pcicore_read16(pc, SSB_PCICORE_SPROM(0));
325 + if (((tmp & 0xF000) >> 12) != pc->dev->core_index) {
327 + tmp |= (pc->dev->core_index << 12);
328 + pcicore_write16(pc, SSB_PCICORE_SPROM(0), tmp);
332 +static u8 ssb_pcicore_polarity_workaround(struct ssb_pcicore *pc)
334 + return (ssb_pcie_read(pc, 0x204) & 0x10) ? 0xC0 : 0x80;
337 +static void ssb_pcicore_serdes_workaround(struct ssb_pcicore *pc)
339 + const u8 serdes_pll_device = 0x1D;
340 + const u8 serdes_rx_device = 0x1F;
343 + ssb_pcie_mdio_write(pc, serdes_rx_device, 1 /* Control */,
344 + ssb_pcicore_polarity_workaround(pc));
345 + tmp = ssb_pcie_mdio_read(pc, serdes_pll_device, 1 /* Control */);
347 + ssb_pcie_mdio_write(pc, serdes_pll_device, 1, tmp & ~0x4000);
350 +static void ssb_pcicore_pci_setup_workarounds(struct ssb_pcicore *pc)
352 + struct ssb_device *pdev = pc->dev;
353 + struct ssb_bus *bus = pdev->bus;
356 + tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
357 + tmp |= SSB_PCICORE_SBTOPCI_PREF;
358 + tmp |= SSB_PCICORE_SBTOPCI_BURST;
359 + pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
361 + if (pdev->id.revision < 5) {
362 + tmp = ssb_read32(pdev, SSB_IMCFGLO);
363 + tmp &= ~SSB_IMCFGLO_SERTO;
365 + tmp &= ~SSB_IMCFGLO_REQTO;
366 + tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
367 + ssb_write32(pdev, SSB_IMCFGLO, tmp);
368 + ssb_commit_settings(bus);
369 + } else if (pdev->id.revision >= 11) {
370 + tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
371 + tmp |= SSB_PCICORE_SBTOPCI_MRM;
372 + pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
376 +static void ssb_pcicore_pcie_setup_workarounds(struct ssb_pcicore *pc)
379 + u8 rev = pc->dev->id.revision;
381 + if (rev == 0 || rev == 1) {
382 + /* TLP Workaround register. */
383 + tmp = ssb_pcie_read(pc, 0x4);
385 + ssb_pcie_write(pc, 0x4, tmp);
388 + /* DLLP Link Control register. */
389 + tmp = ssb_pcie_read(pc, 0x100);
391 + ssb_pcie_write(pc, 0x100, tmp);
395 + const u8 serdes_rx_device = 0x1F;
397 + ssb_pcie_mdio_write(pc, serdes_rx_device,
398 + 2 /* Timer */, 0x8128);
399 + ssb_pcie_mdio_write(pc, serdes_rx_device,
400 + 6 /* CDR */, 0x0100);
401 + ssb_pcie_mdio_write(pc, serdes_rx_device,
402 + 7 /* CDR BW */, 0x1466);
403 + } else if (rev == 3 || rev == 4 || rev == 5) {
404 + /* TODO: DLLP Power Management Threshold */
405 + ssb_pcicore_serdes_workaround(pc);
407 + } else if (rev == 7) {
408 + /* TODO: No PLL down */
412 + /* Miscellaneous Configuration Fixup */
413 + tmp = pcicore_read16(pc, SSB_PCICORE_SPROM(5));
414 + if (!(tmp & 0x8000))
415 + pcicore_write16(pc, SSB_PCICORE_SPROM(5),
420 /**************************************************
421 * Generic and Clientmode operation code.
422 **************************************************/
424 -static void ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
425 +static void __devinit ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
427 + struct ssb_device *pdev = pc->dev;
428 + struct ssb_bus *bus = pdev->bus;
430 + if (bus->bustype == SSB_BUSTYPE_PCI)
431 + ssb_pcicore_fix_sprom_core_index(pc);
433 /* Disable PCI interrupts. */
434 - ssb_write32(pc->dev, SSB_INTVEC, 0);
435 + ssb_write32(pdev, SSB_INTVEC, 0);
437 + /* Additional PCIe always once-executed workarounds */
438 + if (pc->dev->id.coreid == SSB_DEV_PCIE) {
439 + ssb_pcicore_serdes_workaround(pc);
441 + /* TODO: Clock Request Update */
445 -void ssb_pcicore_init(struct ssb_pcicore *pc)
446 +void __devinit ssb_pcicore_init(struct ssb_pcicore *pc)
448 struct ssb_device *dev = pc->dev;
449 - struct ssb_bus *bus;
454 if (!ssb_device_is_enabled(dev))
455 ssb_device_enable(dev, 0);
457 @@ -446,11 +563,35 @@ static void ssb_pcie_write(struct ssb_pc
458 pcicore_write32(pc, 0x134, data);
461 -static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
462 - u8 address, u16 data)
463 +static void ssb_pcie_mdio_set_phy(struct ssb_pcicore *pc, u8 phy)
465 + const u16 mdio_control = 0x128;
466 + const u16 mdio_data = 0x12C;
470 + v = (1 << 30); /* Start of Transaction */
471 + v |= (1 << 28); /* Write Transaction */
472 + v |= (1 << 17); /* Turnaround */
475 + pcicore_write32(pc, mdio_data, v);
478 + for (i = 0; i < 200; i++) {
479 + v = pcicore_read32(pc, mdio_control);
480 + if (v & 0x100 /* Trans complete */)
486 +static u16 ssb_pcie_mdio_read(struct ssb_pcicore *pc, u8 device, u8 address)
488 const u16 mdio_control = 0x128;
489 const u16 mdio_data = 0x12C;
490 + int max_retries = 10;
495 @@ -458,46 +599,68 @@ static void ssb_pcie_mdio_write(struct s
496 v |= 0x2; /* MDIO Clock Divisor */
497 pcicore_write32(pc, mdio_control, v);
499 + if (pc->dev->id.revision >= 10) {
501 + ssb_pcie_mdio_set_phy(pc, device);
504 v = (1 << 30); /* Start of Transaction */
505 - v |= (1 << 28); /* Write Transaction */
506 + v |= (1 << 29); /* Read Transaction */
507 v |= (1 << 17); /* Turnaround */
508 - v |= (u32)device << 22;
509 + if (pc->dev->id.revision < 10)
510 + v |= (u32)device << 22;
511 v |= (u32)address << 18;
513 pcicore_write32(pc, mdio_data, v);
514 /* Wait for the device to complete the transaction */
516 - for (i = 0; i < 10; i++) {
517 + for (i = 0; i < max_retries; i++) {
518 v = pcicore_read32(pc, mdio_control);
519 - if (v & 0x100 /* Trans complete */)
520 + if (v & 0x100 /* Trans complete */) {
522 + ret = pcicore_read32(pc, mdio_data);
527 pcicore_write32(pc, mdio_control, 0);
531 -static void ssb_broadcast_value(struct ssb_device *dev,
532 - u32 address, u32 data)
533 +static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
534 + u8 address, u16 data)
536 - /* This is used for both, PCI and ChipCommon core, so be careful. */
537 - BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
538 - BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
539 + const u16 mdio_control = 0x128;
540 + const u16 mdio_data = 0x12C;
541 + int max_retries = 10;
545 - ssb_write32(dev, SSB_PCICORE_BCAST_ADDR, address);
546 - ssb_read32(dev, SSB_PCICORE_BCAST_ADDR); /* flush */
547 - ssb_write32(dev, SSB_PCICORE_BCAST_DATA, data);
548 - ssb_read32(dev, SSB_PCICORE_BCAST_DATA); /* flush */
550 + v = 0x80; /* Enable Preamble Sequence */
551 + v |= 0x2; /* MDIO Clock Divisor */
552 + pcicore_write32(pc, mdio_control, v);
554 -static void ssb_commit_settings(struct ssb_bus *bus)
556 - struct ssb_device *dev;
557 + if (pc->dev->id.revision >= 10) {
559 + ssb_pcie_mdio_set_phy(pc, device);
562 - dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
565 - /* This forces an update of the cached registers. */
566 - ssb_broadcast_value(dev, 0xFD8, 0);
567 + v = (1 << 30); /* Start of Transaction */
568 + v |= (1 << 28); /* Write Transaction */
569 + v |= (1 << 17); /* Turnaround */
570 + if (pc->dev->id.revision < 10)
571 + v |= (u32)device << 22;
572 + v |= (u32)address << 18;
574 + pcicore_write32(pc, mdio_data, v);
575 + /* Wait for the device to complete the transaction */
577 + for (i = 0; i < max_retries; i++) {
578 + v = pcicore_read32(pc, mdio_control);
579 + if (v & 0x100 /* Trans complete */)
583 + pcicore_write32(pc, mdio_control, 0);
586 int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
587 @@ -550,48 +713,10 @@ int ssb_pcicore_dev_irqvecs_enable(struc
590 if (pdev->id.coreid == SSB_DEV_PCI) {
591 - tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
592 - tmp |= SSB_PCICORE_SBTOPCI_PREF;
593 - tmp |= SSB_PCICORE_SBTOPCI_BURST;
594 - pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
596 - if (pdev->id.revision < 5) {
597 - tmp = ssb_read32(pdev, SSB_IMCFGLO);
598 - tmp &= ~SSB_IMCFGLO_SERTO;
600 - tmp &= ~SSB_IMCFGLO_REQTO;
601 - tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
602 - ssb_write32(pdev, SSB_IMCFGLO, tmp);
603 - ssb_commit_settings(bus);
604 - } else if (pdev->id.revision >= 11) {
605 - tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
606 - tmp |= SSB_PCICORE_SBTOPCI_MRM;
607 - pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
609 + ssb_pcicore_pci_setup_workarounds(pc);
611 WARN_ON(pdev->id.coreid != SSB_DEV_PCIE);
612 - //TODO: Better make defines for all these magic PCIE values.
613 - if ((pdev->id.revision == 0) || (pdev->id.revision == 1)) {
614 - /* TLP Workaround register. */
615 - tmp = ssb_pcie_read(pc, 0x4);
617 - ssb_pcie_write(pc, 0x4, tmp);
619 - if (pdev->id.revision == 0) {
620 - const u8 serdes_rx_device = 0x1F;
622 - ssb_pcie_mdio_write(pc, serdes_rx_device,
623 - 2 /* Timer */, 0x8128);
624 - ssb_pcie_mdio_write(pc, serdes_rx_device,
625 - 6 /* CDR */, 0x0100);
626 - ssb_pcie_mdio_write(pc, serdes_rx_device,
627 - 7 /* CDR BW */, 0x1466);
628 - } else if (pdev->id.revision == 1) {
629 - /* DLLP Link Control register. */
630 - tmp = ssb_pcie_read(pc, 0x100);
632 - ssb_pcie_write(pc, 0x100, tmp);
634 + ssb_pcicore_pcie_setup_workarounds(pc);
638 --- a/drivers/ssb/main.c
639 +++ b/drivers/ssb/main.c
643 * Copyright 2005, Broadcom Corporation
644 - * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
645 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
647 * Licensed under the GNU/GPL. See COPYING for details.
651 #include <linux/delay.h>
652 #include <linux/io.h>
653 +#include <linux/module.h>
654 #include <linux/ssb/ssb.h>
655 #include <linux/ssb/ssb_regs.h>
656 #include <linux/ssb/ssb_driver_gige.h>
657 @@ -139,19 +140,6 @@ static void ssb_device_put(struct ssb_de
658 put_device(dev->dev);
661 -static inline struct ssb_driver *ssb_driver_get(struct ssb_driver *drv)
664 - get_driver(&drv->drv);
668 -static inline void ssb_driver_put(struct ssb_driver *drv)
671 - put_driver(&drv->drv);
674 static int ssb_device_resume(struct device *dev)
676 struct ssb_device *ssb_dev = dev_to_ssb_dev(dev);
677 @@ -249,11 +237,9 @@ int ssb_devices_freeze(struct ssb_bus *b
678 ssb_device_put(sdev);
681 - sdrv = ssb_driver_get(drv_to_ssb_drv(sdev->dev->driver));
682 - if (!sdrv || SSB_WARN_ON(!sdrv->remove)) {
683 - ssb_device_put(sdev);
684 + sdrv = drv_to_ssb_drv(sdev->dev->driver);
685 + if (SSB_WARN_ON(!sdrv->remove))
689 ctx->device_frozen[i] = 1;
691 @@ -292,7 +278,6 @@ int ssb_devices_thaw(struct ssb_freeze_c
692 dev_name(sdev->dev));
695 - ssb_driver_put(sdrv);
696 ssb_device_put(sdev);
699 @@ -557,7 +542,7 @@ error:
702 /* Needs ssb_buses_lock() */
703 -static int ssb_attach_queued_buses(void)
704 +static int __devinit ssb_attach_queued_buses(void)
706 struct ssb_bus *bus, *n;
708 @@ -768,9 +753,9 @@ out:
712 -static int ssb_bus_register(struct ssb_bus *bus,
713 - ssb_invariants_func_t get_invariants,
714 - unsigned long baseaddr)
715 +static int __devinit ssb_bus_register(struct ssb_bus *bus,
716 + ssb_invariants_func_t get_invariants,
717 + unsigned long baseaddr)
721 @@ -851,8 +836,8 @@ err_disable_xtal:
724 #ifdef CONFIG_SSB_PCIHOST
725 -int ssb_bus_pcibus_register(struct ssb_bus *bus,
726 - struct pci_dev *host_pci)
727 +int __devinit ssb_bus_pcibus_register(struct ssb_bus *bus,
728 + struct pci_dev *host_pci)
732 @@ -875,9 +860,9 @@ EXPORT_SYMBOL(ssb_bus_pcibus_register);
733 #endif /* CONFIG_SSB_PCIHOST */
735 #ifdef CONFIG_SSB_PCMCIAHOST
736 -int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
737 - struct pcmcia_device *pcmcia_dev,
738 - unsigned long baseaddr)
739 +int __devinit ssb_bus_pcmciabus_register(struct ssb_bus *bus,
740 + struct pcmcia_device *pcmcia_dev,
741 + unsigned long baseaddr)
745 @@ -897,8 +882,9 @@ EXPORT_SYMBOL(ssb_bus_pcmciabus_register
746 #endif /* CONFIG_SSB_PCMCIAHOST */
748 #ifdef CONFIG_SSB_SDIOHOST
749 -int ssb_bus_sdiobus_register(struct ssb_bus *bus, struct sdio_func *func,
750 - unsigned int quirks)
751 +int __devinit ssb_bus_sdiobus_register(struct ssb_bus *bus,
752 + struct sdio_func *func,
753 + unsigned int quirks)
757 @@ -918,9 +904,9 @@ int ssb_bus_sdiobus_register(struct ssb_
758 EXPORT_SYMBOL(ssb_bus_sdiobus_register);
759 #endif /* CONFIG_SSB_PCMCIAHOST */
761 -int ssb_bus_ssbbus_register(struct ssb_bus *bus,
762 - unsigned long baseaddr,
763 - ssb_invariants_func_t get_invariants)
764 +int __devinit ssb_bus_ssbbus_register(struct ssb_bus *bus,
765 + unsigned long baseaddr,
766 + ssb_invariants_func_t get_invariants)
770 @@ -1001,8 +987,8 @@ u32 ssb_calc_clock_rate(u32 plltype, u32
772 case SSB_PLLTYPE_6: /* 100/200 or 120/240 only */
773 if (m & SSB_CHIPCO_CLK_T6_MMASK)
774 - return SSB_CHIPCO_CLK_T6_M0;
775 - return SSB_CHIPCO_CLK_T6_M1;
776 + return SSB_CHIPCO_CLK_T6_M1;
777 + return SSB_CHIPCO_CLK_T6_M0;
778 case SSB_PLLTYPE_1: /* 48Mhz base, 3 dividers */
779 case SSB_PLLTYPE_3: /* 25Mhz, 2 dividers */
780 case SSB_PLLTYPE_4: /* 48Mhz, 4 dividers */
781 @@ -1092,6 +1078,9 @@ u32 ssb_clockspeed(struct ssb_bus *bus)
783 u32 clkctl_n, clkctl_m;
785 + if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
786 + return ssb_pmu_get_controlclock(&bus->chipco);
788 if (ssb_extif_available(&bus->extif))
789 ssb_extif_get_clockcontrol(&bus->extif, &plltype,
790 &clkctl_n, &clkctl_m);
791 @@ -1117,23 +1106,22 @@ static u32 ssb_tmslow_reject_bitmask(str
793 u32 rev = ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_SSBREV;
795 - /* The REJECT bit changed position in TMSLOW between
796 - * Backplane revisions. */
797 + /* The REJECT bit seems to be different for Backplane rev 2.3 */
799 case SSB_IDLOW_SSBREV_22:
800 - return SSB_TMSLOW_REJECT_22;
801 + case SSB_IDLOW_SSBREV_24:
802 + case SSB_IDLOW_SSBREV_26:
803 + return SSB_TMSLOW_REJECT;
804 case SSB_IDLOW_SSBREV_23:
805 return SSB_TMSLOW_REJECT_23;
806 - case SSB_IDLOW_SSBREV_24: /* TODO - find the proper REJECT bits */
807 - case SSB_IDLOW_SSBREV_25: /* same here */
808 - case SSB_IDLOW_SSBREV_26: /* same here */
809 + case SSB_IDLOW_SSBREV_25: /* TODO - find the proper REJECT bit */
810 case SSB_IDLOW_SSBREV_27: /* same here */
811 - return SSB_TMSLOW_REJECT_23; /* this is a guess */
812 + return SSB_TMSLOW_REJECT; /* this is a guess */
814 printk(KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
817 - return (SSB_TMSLOW_REJECT_22 | SSB_TMSLOW_REJECT_23);
818 + return (SSB_TMSLOW_REJECT | SSB_TMSLOW_REJECT_23);
821 int ssb_device_is_enabled(struct ssb_device *dev)
822 @@ -1260,13 +1248,34 @@ void ssb_device_disable(struct ssb_devic
824 EXPORT_SYMBOL(ssb_device_disable);
826 +/* Some chipsets need routing known for PCIe and 64-bit DMA */
827 +static bool ssb_dma_translation_special_bit(struct ssb_device *dev)
829 + u16 chip_id = dev->bus->chip_id;
831 + if (dev->id.coreid == SSB_DEV_80211) {
832 + return (chip_id == 0x4322 || chip_id == 43221 ||
833 + chip_id == 43231 || chip_id == 43222);
839 u32 ssb_dma_translation(struct ssb_device *dev)
841 switch (dev->bus->bustype) {
842 case SSB_BUSTYPE_SSB:
844 case SSB_BUSTYPE_PCI:
845 - return SSB_PCI_DMA;
846 + if (pci_is_pcie(dev->bus->host_pci) &&
847 + ssb_read32(dev, SSB_TMSHIGH) & SSB_TMSHIGH_DMA64) {
848 + return SSB_PCIE_DMA_H32;
850 + if (ssb_dma_translation_special_bit(dev))
851 + return SSB_PCIE_DMA_H32;
853 + return SSB_PCI_DMA;
856 __ssb_dma_not_implemented(dev);
858 @@ -1309,20 +1318,20 @@ EXPORT_SYMBOL(ssb_bus_may_powerdown);
860 int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl)
862 - struct ssb_chipcommon *cc;
864 enum ssb_clkmode mode;
866 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1);
870 - mode = dynamic_pctl ? SSB_CLKMODE_DYNAMIC : SSB_CLKMODE_FAST;
871 - ssb_chipco_set_clockmode(cc, mode);
873 #ifdef CONFIG_SSB_DEBUG
877 + mode = dynamic_pctl ? SSB_CLKMODE_DYNAMIC : SSB_CLKMODE_FAST;
878 + ssb_chipco_set_clockmode(&bus->chipco, mode);
882 ssb_printk(KERN_ERR PFX "Bus powerup failed\n");
883 @@ -1330,6 +1339,37 @@ error:
885 EXPORT_SYMBOL(ssb_bus_powerup);
887 +static void ssb_broadcast_value(struct ssb_device *dev,
888 + u32 address, u32 data)
890 +#ifdef CONFIG_SSB_DRIVER_PCICORE
891 + /* This is used for both, PCI and ChipCommon core, so be careful. */
892 + BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
893 + BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
896 + ssb_write32(dev, SSB_CHIPCO_BCAST_ADDR, address);
897 + ssb_read32(dev, SSB_CHIPCO_BCAST_ADDR); /* flush */
898 + ssb_write32(dev, SSB_CHIPCO_BCAST_DATA, data);
899 + ssb_read32(dev, SSB_CHIPCO_BCAST_DATA); /* flush */
902 +void ssb_commit_settings(struct ssb_bus *bus)
904 + struct ssb_device *dev;
906 +#ifdef CONFIG_SSB_DRIVER_PCICORE
907 + dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
909 + dev = bus->chipco.dev;
913 + /* This forces an update of the cached registers. */
914 + ssb_broadcast_value(dev, 0xFD8, 0);
916 +EXPORT_SYMBOL(ssb_commit_settings);
918 u32 ssb_admatch_base(u32 adm)
921 --- a/drivers/ssb/pci.c
922 +++ b/drivers/ssb/pci.c
925 * Sonics Silicon Backplane PCI-Hostbus related functions.
927 - * Copyright (C) 2005-2006 Michael Buesch <mb@bu3sch.de>
928 + * Copyright (C) 2005-2006 Michael Buesch <m@bues.ch>
929 * Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
930 * Copyright (C) 2005 Stefano Brivio <st3@riseup.net>
931 * Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
932 @@ -331,7 +331,6 @@ static void sprom_extract_r123(struct ss
939 if (out->revision == 3) /* rev 3 moved MAC */
940 @@ -390,20 +389,12 @@ static void sprom_extract_r123(struct ss
941 SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0);
943 /* Extract the antenna gain values. */
944 - gain = r123_extract_antgain(out->revision, in,
945 - SSB_SPROM1_AGAIN_BG,
946 - SSB_SPROM1_AGAIN_BG_SHIFT);
947 - out->antenna_gain.ghz24.a0 = gain;
948 - out->antenna_gain.ghz24.a1 = gain;
949 - out->antenna_gain.ghz24.a2 = gain;
950 - out->antenna_gain.ghz24.a3 = gain;
951 - gain = r123_extract_antgain(out->revision, in,
952 - SSB_SPROM1_AGAIN_A,
953 - SSB_SPROM1_AGAIN_A_SHIFT);
954 - out->antenna_gain.ghz5.a0 = gain;
955 - out->antenna_gain.ghz5.a1 = gain;
956 - out->antenna_gain.ghz5.a2 = gain;
957 - out->antenna_gain.ghz5.a3 = gain;
958 + out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
959 + SSB_SPROM1_AGAIN_BG,
960 + SSB_SPROM1_AGAIN_BG_SHIFT);
961 + out->antenna_gain.a1 = r123_extract_antgain(out->revision, in,
962 + SSB_SPROM1_AGAIN_A,
963 + SSB_SPROM1_AGAIN_A_SHIFT);
966 /* Revs 4 5 and 8 have partially shared layout */
967 @@ -504,16 +495,14 @@ static void sprom_extract_r45(struct ssb
970 /* Extract the antenna gain values. */
971 - SPEX(antenna_gain.ghz24.a0, SSB_SPROM4_AGAIN01,
972 + SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01,
973 SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT);
974 - SPEX(antenna_gain.ghz24.a1, SSB_SPROM4_AGAIN01,
975 + SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01,
976 SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT);
977 - SPEX(antenna_gain.ghz24.a2, SSB_SPROM4_AGAIN23,
978 + SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23,
979 SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT);
980 - SPEX(antenna_gain.ghz24.a3, SSB_SPROM4_AGAIN23,
981 + SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23,
982 SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT);
983 - memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
984 - sizeof(out->antenna_gain.ghz5));
986 sprom_extract_r458(out, in);
988 @@ -523,7 +512,13 @@ static void sprom_extract_r45(struct ssb
989 static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
994 + u16 pwr_info_offset[] = {
995 + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
996 + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
998 + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
999 + ARRAY_SIZE(out->core_pwr_info));
1001 /* extract the MAC address */
1002 for (i = 0; i < 3; i++) {
1003 @@ -596,16 +591,69 @@ static void sprom_extract_r8(struct ssb_
1004 SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
1006 /* Extract the antenna gain values. */
1007 - SPEX(antenna_gain.ghz24.a0, SSB_SPROM8_AGAIN01,
1008 + SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
1009 SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
1010 - SPEX(antenna_gain.ghz24.a1, SSB_SPROM8_AGAIN01,
1011 + SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
1012 SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
1013 - SPEX(antenna_gain.ghz24.a2, SSB_SPROM8_AGAIN23,
1014 + SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
1015 SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
1016 - SPEX(antenna_gain.ghz24.a3, SSB_SPROM8_AGAIN23,
1017 + SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
1018 SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
1019 - memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
1020 - sizeof(out->antenna_gain.ghz5));
1022 + /* Extract cores power info info */
1023 + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
1024 + o = pwr_info_offset[i];
1025 + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
1026 + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
1027 + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
1028 + SSB_SPROM8_2G_MAXP, 0);
1030 + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
1031 + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
1032 + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
1034 + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
1035 + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
1036 + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
1037 + SSB_SPROM8_5G_MAXP, 0);
1038 + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
1039 + SSB_SPROM8_5GH_MAXP, 0);
1040 + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
1041 + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
1043 + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
1044 + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
1045 + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
1046 + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
1047 + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
1048 + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
1049 + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
1050 + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
1051 + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
1054 + /* Extract FEM info */
1055 + SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G,
1056 + SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
1057 + SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G,
1058 + SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
1059 + SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G,
1060 + SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT);
1061 + SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G,
1062 + SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT);
1063 + SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G,
1064 + SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
1066 + SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G,
1067 + SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
1068 + SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G,
1069 + SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
1070 + SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G,
1071 + SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT);
1072 + SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G,
1073 + SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT);
1074 + SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G,
1075 + SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
1077 sprom_extract_r458(out, in);
1079 @@ -662,7 +710,6 @@ static int sprom_extract(struct ssb_bus
1080 static int ssb_pci_sprom_get(struct ssb_bus *bus,
1081 struct ssb_sprom *sprom)
1083 - const struct ssb_sprom *fallback;
1087 @@ -707,10 +754,17 @@ static int ssb_pci_sprom_get(struct ssb_
1089 /* All CRC attempts failed.
1090 * Maybe there is no SPROM on the device?
1091 - * If we have a fallback, use that. */
1092 - fallback = ssb_get_fallback_sprom();
1094 - memcpy(sprom, fallback, sizeof(*sprom));
1095 + * Now we ask the arch code if there is some sprom
1096 + * available for this device in some other storage */
1097 + err = ssb_fill_sprom_with_fallback(bus, sprom);
1099 + ssb_printk(KERN_WARNING PFX "WARNING: Using"
1100 + " fallback SPROM failed (err %d)\n",
1103 + ssb_dprintk(KERN_DEBUG PFX "Using SPROM"
1104 + " revision %d provided by"
1105 + " platform.\n", sprom->revision);
1109 @@ -728,12 +782,9 @@ out_free:
1110 static void ssb_pci_get_boardinfo(struct ssb_bus *bus,
1111 struct ssb_boardinfo *bi)
1113 - pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_VENDOR_ID,
1115 - pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_ID,
1117 - pci_read_config_word(bus->host_pci, PCI_REVISION_ID,
1119 + bi->vendor = bus->host_pci->subsystem_vendor;
1120 + bi->type = bus->host_pci->subsystem_device;
1121 + bi->rev = bus->host_pci->revision;
1124 int ssb_pci_get_invariants(struct ssb_bus *bus,
1125 --- a/drivers/ssb/pcihost_wrapper.c
1126 +++ b/drivers/ssb/pcihost_wrapper.c
1128 * Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
1129 * Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
1130 * Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
1131 - * Copyright (c) 2005-2007 Michael Buesch <mbuesch@freenet.de>
1132 + * Copyright (c) 2005-2007 Michael Buesch <m@bues.ch>
1134 * Licensed under the GNU/GPL. See COPYING for details.
1136 @@ -53,8 +53,8 @@ static int ssb_pcihost_resume(struct pci
1137 # define ssb_pcihost_resume NULL
1138 #endif /* CONFIG_PM */
1140 -static int ssb_pcihost_probe(struct pci_dev *dev,
1141 - const struct pci_device_id *id)
1142 +static int __devinit ssb_pcihost_probe(struct pci_dev *dev,
1143 + const struct pci_device_id *id)
1145 struct ssb_bus *ssb;
1147 @@ -110,7 +110,7 @@ static void ssb_pcihost_remove(struct pc
1148 pci_set_drvdata(dev, NULL);
1151 -int ssb_pcihost_register(struct pci_driver *driver)
1152 +int __devinit ssb_pcihost_register(struct pci_driver *driver)
1154 driver->probe = ssb_pcihost_probe;
1155 driver->remove = ssb_pcihost_remove;
1156 --- a/drivers/ssb/scan.c
1157 +++ b/drivers/ssb/scan.c
1159 * Sonics Silicon Backplane
1162 - * Copyright (C) 2005-2007 Michael Buesch <mb@bu3sch.de>
1163 + * Copyright (C) 2005-2007 Michael Buesch <m@bues.ch>
1164 * Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
1165 * Copyright (C) 2005 Stefano Brivio <st3@riseup.net>
1166 * Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
1167 @@ -258,7 +258,10 @@ static int we_support_multiple_80211_cor
1168 #ifdef CONFIG_SSB_PCIHOST
1169 if (bus->bustype == SSB_BUSTYPE_PCI) {
1170 if (bus->host_pci->vendor == PCI_VENDOR_ID_BROADCOM &&
1171 - bus->host_pci->device == 0x4324)
1172 + ((bus->host_pci->device == 0x4313) ||
1173 + (bus->host_pci->device == 0x431A) ||
1174 + (bus->host_pci->device == 0x4321) ||
1175 + (bus->host_pci->device == 0x4324)))
1178 #endif /* CONFIG_SSB_PCIHOST */
1179 @@ -307,8 +310,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
1181 if (bus->bustype == SSB_BUSTYPE_PCI) {
1182 bus->chip_id = pcidev_to_chipid(bus->host_pci);
1183 - pci_read_config_word(bus->host_pci, PCI_REVISION_ID,
1185 + bus->chip_rev = bus->host_pci->revision;
1186 bus->chip_package = 0;
1188 bus->chip_id = 0x4710;
1189 @@ -316,6 +318,9 @@ int ssb_bus_scan(struct ssb_bus *bus,
1190 bus->chip_package = 0;
1193 + ssb_printk(KERN_INFO PFX "Found chip with id 0x%04X, rev 0x%02X and "
1194 + "package 0x%02X\n", bus->chip_id, bus->chip_rev,
1195 + bus->chip_package);
1196 if (!bus->nr_devices)
1197 bus->nr_devices = chipid_to_nrcores(bus->chip_id);
1198 if (bus->nr_devices > ARRAY_SIZE(bus->devices)) {
1199 --- a/drivers/ssb/sprom.c
1200 +++ b/drivers/ssb/sprom.c
1202 * Sonics Silicon Backplane
1203 * Common SPROM support routines
1205 - * Copyright (C) 2005-2008 Michael Buesch <mb@bu3sch.de>
1206 + * Copyright (C) 2005-2008 Michael Buesch <m@bues.ch>
1207 * Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
1208 * Copyright (C) 2005 Stefano Brivio <st3@riseup.net>
1209 * Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
1211 #include <linux/slab.h>
1214 -static const struct ssb_sprom *fallback_sprom;
1215 +static int(*get_fallback_sprom)(struct ssb_bus *dev, struct ssb_sprom *out);
1218 static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
1219 @@ -145,36 +145,43 @@ out:
1223 - * ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found.
1224 + * ssb_arch_register_fallback_sprom - Registers a method providing a
1225 + * fallback SPROM if no SPROM is found.
1227 - * @sprom: The SPROM data structure to register.
1228 + * @sprom_callback: The callback function.
1230 - * With this function the architecture implementation may register a fallback
1231 - * SPROM data structure. The fallback is only used for PCI based SSB devices,
1232 - * where no valid SPROM can be found in the shadow registers.
1233 + * With this function the architecture implementation may register a
1234 + * callback handler which fills the SPROM data structure. The fallback is
1235 + * only used for PCI based SSB devices, where no valid SPROM can be found
1236 + * in the shadow registers.
1238 + * This function is useful for weird architectures that have a half-assed
1239 + * SSB device hardwired to their PCI bus.
1241 + * Note that it does only work with PCI attached SSB devices. PCMCIA
1242 + * devices currently don't use this fallback.
1243 + * Architectures must provide the SPROM for native SSB devices anyway, so
1244 + * the fallback also isn't used for native devices.
1246 - * This function is useful for weird architectures that have a half-assed SSB device
1247 - * hardwired to their PCI bus.
1249 - * Note that it does only work with PCI attached SSB devices. PCMCIA devices currently
1250 - * don't use this fallback.
1251 - * Architectures must provide the SPROM for native SSB devices anyway,
1252 - * so the fallback also isn't used for native devices.
1254 - * This function is available for architecture code, only. So it is not exported.
1255 + * This function is available for architecture code, only. So it is not
1258 -int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom)
1259 +int ssb_arch_register_fallback_sprom(int (*sprom_callback)(struct ssb_bus *bus,
1260 + struct ssb_sprom *out))
1262 - if (fallback_sprom)
1263 + if (get_fallback_sprom)
1265 - fallback_sprom = sprom;
1266 + get_fallback_sprom = sprom_callback;
1271 -const struct ssb_sprom *ssb_get_fallback_sprom(void)
1272 +int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out)
1274 - return fallback_sprom;
1275 + if (!get_fallback_sprom)
1278 + return get_fallback_sprom(bus, out);
1281 /* http://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */
1282 --- a/drivers/ssb/ssb_private.h
1283 +++ b/drivers/ssb/ssb_private.h
1284 @@ -171,7 +171,8 @@ ssize_t ssb_attr_sprom_store(struct ssb_
1285 const char *buf, size_t count,
1286 int (*sprom_check_crc)(const u16 *sprom, size_t size),
1287 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
1288 -extern const struct ssb_sprom *ssb_get_fallback_sprom(void);
1289 +extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
1290 + struct ssb_sprom *out);
1294 @@ -206,4 +207,8 @@ static inline void b43_pci_ssb_bridge_ex
1296 #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
1298 +/* driver_chipcommon_pmu.c */
1299 +extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
1300 +extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
1302 #endif /* LINUX_SSB_PRIVATE_H_ */
1303 --- a/include/linux/ssb/ssb.h
1304 +++ b/include/linux/ssb/ssb.h
1305 @@ -16,6 +16,12 @@ struct pcmcia_device;
1309 +struct ssb_sprom_core_pwr_info {
1310 + u8 itssi_2g, itssi_5g;
1311 + u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
1312 + u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4];
1317 u8 il0mac[6]; /* MAC address for 802.11b/g */
1318 @@ -25,8 +31,13 @@ struct ssb_sprom {
1319 u8 et1phyaddr; /* MII address for enet1 */
1320 u8 et0mdcport; /* MDIO for enet0 */
1321 u8 et1mdcport; /* MDIO for enet1 */
1322 - u8 board_rev; /* Board revision number from SPROM. */
1323 + u16 board_rev; /* Board revision number from SPROM. */
1324 + u16 board_num; /* Board number from SPROM. */
1325 + u16 board_type; /* Board type from SPROM. */
1326 u8 country_code; /* Country Code */
1327 + char alpha2[2]; /* Country Code as two chars like EU or US */
1328 + u8 leddc_on_time; /* LED Powersave Duty Cycle On Count */
1329 + u8 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
1330 u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */
1331 u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */
1333 @@ -45,10 +56,10 @@ struct ssb_sprom {
1334 u8 gpio1; /* GPIO pin 1 */
1335 u8 gpio2; /* GPIO pin 2 */
1336 u8 gpio3; /* GPIO pin 3 */
1337 - u16 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
1338 - u16 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
1339 - u16 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
1340 - u16 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
1341 + u8 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
1342 + u8 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
1343 + u8 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
1344 + u8 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
1345 u8 itssi_a; /* Idle TSSI Target for A-PHY */
1346 u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
1347 u8 tri2g; /* 2.4GHz TX isolation */
1348 @@ -59,8 +70,8 @@ struct ssb_sprom {
1349 u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
1350 u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
1351 u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
1352 - u8 rxpo2g; /* 2GHz RX power offset */
1353 - u8 rxpo5g; /* 5GHz RX power offset */
1354 + s8 rxpo2g; /* 2GHz RX power offset */
1355 + s8 rxpo5g; /* 5GHz RX power offset */
1356 u8 rssisav2g; /* 2GHz RSSI params */
1359 @@ -80,26 +91,104 @@ struct ssb_sprom {
1360 u16 boardflags2_hi; /* Board flags (bits 48-63) */
1361 /* TODO store board flags in a single u64 */
1363 + struct ssb_sprom_core_pwr_info core_pwr_info[4];
1365 /* Antenna gain values for up to 4 antennas
1366 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
1367 * loss in the connectors is bigger than the gain. */
1370 - s8 a0, a1, a2, a3;
1371 - } ghz24; /* 2.4GHz band */
1373 - s8 a0, a1, a2, a3;
1374 - } ghz5; /* 5GHz band */
1375 + s8 a0, a1, a2, a3;
1378 - /* TODO - add any parameters needed from rev 2, 3, 4, 5 or 8 SPROMs */
1381 + u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
1384 + u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
1394 + u8 rxgainerr2ga[3];
1395 + u8 rxgainerr5gla[3];
1396 + u8 rxgainerr5gma[3];
1397 + u8 rxgainerr5gha[3];
1398 + u8 rxgainerr5gua[3];
1400 + u8 noiselvl2ga[3];
1401 + u8 noiselvl5gla[3];
1402 + u8 noiselvl5gma[3];
1403 + u8 noiselvl5gha[3];
1404 + u8 noiselvl5gua[3];
1419 + u8 tempsense_slope;
1421 + u8 tempsense_option;
1422 + u8 freqoffset_corr;
1427 + u8 phycal_tempdelta;
1429 + u8 temps_hysteresis;
1432 + u8 pcieingress_war;
1434 + /* power per rate from sromrev 9 */
1436 + u16 cckbw20ul2gpo;
1437 + u32 legofdmbw202gpo;
1438 + u32 legofdmbw20ul2gpo;
1439 + u32 legofdmbw205glpo;
1440 + u32 legofdmbw20ul5glpo;
1441 + u32 legofdmbw205gmpo;
1442 + u32 legofdmbw20ul5gmpo;
1443 + u32 legofdmbw205ghpo;
1444 + u32 legofdmbw20ul5ghpo;
1446 + u32 mcsbw20ul2gpo;
1449 + u32 mcsbw20ul5glpo;
1452 + u32 mcsbw20ul5gmpo;
1455 + u32 mcsbw20ul5ghpo;
1458 + u16 legofdm40duppo;
1463 /* Information about the PCB the circuitry is soldered on. */
1464 struct ssb_boardinfo {
1472 @@ -229,10 +318,9 @@ struct ssb_driver {
1473 #define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv)
1475 extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
1476 -static inline int ssb_driver_register(struct ssb_driver *drv)
1478 - return __ssb_driver_register(drv, THIS_MODULE);
1480 +#define ssb_driver_register(drv) \
1481 + __ssb_driver_register(drv, THIS_MODULE)
1483 extern void ssb_driver_unregister(struct ssb_driver *drv);
1486 @@ -308,7 +396,7 @@ struct ssb_bus {
1488 /* ID information about the Chip. */
1493 u16 sprom_size; /* number of words in sprom */
1495 @@ -404,7 +492,9 @@ extern bool ssb_is_sprom_available(struc
1497 /* Set a fallback SPROM.
1498 * See kdoc at the function definition for complete documentation. */
1499 -extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom);
1500 +extern int ssb_arch_register_fallback_sprom(
1501 + int (*sprom_callback)(struct ssb_bus *bus,
1502 + struct ssb_sprom *out));
1504 /* Suspend a SSB bus.
1505 * Call this from the parent bus suspend routine. */
1506 @@ -518,6 +608,7 @@ extern int ssb_bus_may_powerdown(struct
1507 * Otherwise static always-on powercontrol will be used. */
1508 extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
1510 +extern void ssb_commit_settings(struct ssb_bus *bus);
1512 /* Various helper functions */
1513 extern u32 ssb_admatch_base(u32 adm);
1514 --- a/include/linux/ssb/ssb_driver_chipcommon.h
1515 +++ b/include/linux/ssb/ssb_driver_chipcommon.h
1517 * gpio interface, extbus, and support for serial and parallel flashes.
1519 * Copyright 2005, Broadcom Corporation
1520 - * Copyright 2006, Michael Buesch <mb@bu3sch.de>
1521 + * Copyright 2006, Michael Buesch <m@bues.ch>
1523 * Licensed under the GPL version 2. See COPYING for details.
1526 #define SSB_CHIPCO_FLASHDATA 0x0048
1527 #define SSB_CHIPCO_BCAST_ADDR 0x0050
1528 #define SSB_CHIPCO_BCAST_DATA 0x0054
1529 +#define SSB_CHIPCO_GPIOPULLUP 0x0058 /* Rev >= 20 only */
1530 +#define SSB_CHIPCO_GPIOPULLDOWN 0x005C /* Rev >= 20 only */
1531 #define SSB_CHIPCO_GPIOIN 0x0060
1532 #define SSB_CHIPCO_GPIOOUT 0x0064
1533 #define SSB_CHIPCO_GPIOOUTEN 0x0068
1535 #define SSB_CHIPCO_GPIOIRQ 0x0074
1536 #define SSB_CHIPCO_WATCHDOG 0x0080
1537 #define SSB_CHIPCO_GPIOTIMER 0x0088 /* LED powersave (corerev >= 16) */
1538 +#define SSB_CHIPCO_GPIOTIMER_OFFTIME 0x0000FFFF
1539 +#define SSB_CHIPCO_GPIOTIMER_OFFTIME_SHIFT 0
1540 +#define SSB_CHIPCO_GPIOTIMER_ONTIME 0xFFFF0000
1541 #define SSB_CHIPCO_GPIOTIMER_ONTIME_SHIFT 16
1542 #define SSB_CHIPCO_GPIOTOUTM 0x008C /* LED powersave (corerev >= 16) */
1543 #define SSB_CHIPCO_CLOCK_N 0x0090
1544 @@ -189,8 +194,10 @@
1545 #define SSB_CHIPCO_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
1546 #define SSB_CHIPCO_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
1547 #define SSB_CHIPCO_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
1548 -#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00010000 /* HT available */
1549 -#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00020000 /* APL available */
1550 +#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
1551 +#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00020000 /* HT available */
1552 +#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
1553 +#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
1554 #define SSB_CHIPCO_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
1555 #define SSB_CHIPCO_UART0_DATA 0x0300
1556 #define SSB_CHIPCO_UART0_IMR 0x0304
1557 --- a/include/linux/ssb/ssb_regs.h
1558 +++ b/include/linux/ssb/ssb_regs.h
1560 #define SSB_INTVEC_ENET1 0x00000040 /* Enable interrupts for enet 1 */
1561 #define SSB_TMSLOW 0x0F98 /* SB Target State Low */
1562 #define SSB_TMSLOW_RESET 0x00000001 /* Reset */
1563 -#define SSB_TMSLOW_REJECT_22 0x00000002 /* Reject (Backplane rev 2.2) */
1564 +#define SSB_TMSLOW_REJECT 0x00000002 /* Reject (Standard Backplane) */
1565 #define SSB_TMSLOW_REJECT_23 0x00000004 /* Reject (Backplane rev 2.3) */
1566 #define SSB_TMSLOW_CLOCK 0x00010000 /* Clock Enable */
1567 #define SSB_TMSLOW_FGC 0x00020000 /* Force Gated Clocks On */
1568 @@ -432,6 +432,56 @@
1569 #define SSB_SPROM8_RXPO2G 0x00FF /* 2GHz RX power offset */
1570 #define SSB_SPROM8_RXPO5G 0xFF00 /* 5GHz RX power offset */
1571 #define SSB_SPROM8_RXPO5G_SHIFT 8
1572 +#define SSB_SPROM8_FEM2G 0x00AE
1573 +#define SSB_SPROM8_FEM5G 0x00B0
1574 +#define SSB_SROM8_FEM_TSSIPOS 0x0001
1575 +#define SSB_SROM8_FEM_TSSIPOS_SHIFT 0
1576 +#define SSB_SROM8_FEM_EXTPA_GAIN 0x0006
1577 +#define SSB_SROM8_FEM_EXTPA_GAIN_SHIFT 1
1578 +#define SSB_SROM8_FEM_PDET_RANGE 0x00F8
1579 +#define SSB_SROM8_FEM_PDET_RANGE_SHIFT 3
1580 +#define SSB_SROM8_FEM_TR_ISO 0x0700
1581 +#define SSB_SROM8_FEM_TR_ISO_SHIFT 8
1582 +#define SSB_SROM8_FEM_ANTSWLUT 0xF800
1583 +#define SSB_SROM8_FEM_ANTSWLUT_SHIFT 11
1584 +#define SSB_SPROM8_THERMAL 0x00B2
1585 +#define SSB_SPROM8_MPWR_RAWTS 0x00B4
1586 +#define SSB_SPROM8_TS_SLP_OPT_CORRX 0x00B6
1587 +#define SSB_SPROM8_FOC_HWIQ_IQSWP 0x00B8
1588 +#define SSB_SPROM8_PHYCAL_TEMPDELTA 0x00BA
1590 +/* There are 4 blocks with power info sharing the same layout */
1591 +#define SSB_SROM8_PWR_INFO_CORE0 0x00C0
1592 +#define SSB_SROM8_PWR_INFO_CORE1 0x00E0
1593 +#define SSB_SROM8_PWR_INFO_CORE2 0x0100
1594 +#define SSB_SROM8_PWR_INFO_CORE3 0x0120
1596 +#define SSB_SROM8_2G_MAXP_ITSSI 0x00
1597 +#define SSB_SPROM8_2G_MAXP 0x00FF
1598 +#define SSB_SPROM8_2G_ITSSI 0xFF00
1599 +#define SSB_SPROM8_2G_ITSSI_SHIFT 8
1600 +#define SSB_SROM8_2G_PA_0 0x02 /* 2GHz power amp settings */
1601 +#define SSB_SROM8_2G_PA_1 0x04
1602 +#define SSB_SROM8_2G_PA_2 0x06
1603 +#define SSB_SROM8_5G_MAXP_ITSSI 0x08 /* 5GHz ITSSI and 5.3GHz Max Power */
1604 +#define SSB_SPROM8_5G_MAXP 0x00FF
1605 +#define SSB_SPROM8_5G_ITSSI 0xFF00
1606 +#define SSB_SPROM8_5G_ITSSI_SHIFT 8
1607 +#define SSB_SPROM8_5GHL_MAXP 0x0A /* 5.2GHz and 5.8GHz Max Power */
1608 +#define SSB_SPROM8_5GH_MAXP 0x00FF
1609 +#define SSB_SPROM8_5GL_MAXP 0xFF00
1610 +#define SSB_SPROM8_5GL_MAXP_SHIFT 8
1611 +#define SSB_SROM8_5G_PA_0 0x0C /* 5.3GHz power amp settings */
1612 +#define SSB_SROM8_5G_PA_1 0x0E
1613 +#define SSB_SROM8_5G_PA_2 0x10
1614 +#define SSB_SROM8_5GL_PA_0 0x12 /* 5.2GHz power amp settings */
1615 +#define SSB_SROM8_5GL_PA_1 0x14
1616 +#define SSB_SROM8_5GL_PA_2 0x16
1617 +#define SSB_SROM8_5GH_PA_0 0x18 /* 5.8GHz power amp settings */
1618 +#define SSB_SROM8_5GH_PA_1 0x1A
1619 +#define SSB_SROM8_5GH_PA_2 0x1C
1621 +/* TODO: Make it deprecated */
1622 #define SSB_SPROM8_MAXP_BG 0x00C0 /* Max Power 2GHz in path 1 */
1623 #define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power 2GHz */
1624 #define SSB_SPROM8_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
1625 @@ -456,12 +506,53 @@
1626 #define SSB_SPROM8_PA1HIB0 0x00D8 /* 5.8GHz power amp settings */
1627 #define SSB_SPROM8_PA1HIB1 0x00DA
1628 #define SSB_SPROM8_PA1HIB2 0x00DC
1630 #define SSB_SPROM8_CCK2GPO 0x0140 /* CCK power offset */
1631 #define SSB_SPROM8_OFDM2GPO 0x0142 /* 2.4GHz OFDM power offset */
1632 #define SSB_SPROM8_OFDM5GPO 0x0146 /* 5.3GHz OFDM power offset */
1633 #define SSB_SPROM8_OFDM5GLPO 0x014A /* 5.2GHz OFDM power offset */
1634 #define SSB_SPROM8_OFDM5GHPO 0x014E /* 5.8GHz OFDM power offset */
1636 +/* Values for boardflags_lo read from SPROM */
1637 +#define SSB_BFL_BTCOEXIST 0x0001 /* implements Bluetooth coexistance */
1638 +#define SSB_BFL_PACTRL 0x0002 /* GPIO 9 controlling the PA */
1639 +#define SSB_BFL_AIRLINEMODE 0x0004 /* implements GPIO 13 radio disable indication */
1640 +#define SSB_BFL_RSSI 0x0008 /* software calculates nrssi slope. */
1641 +#define SSB_BFL_ENETSPI 0x0010 /* has ephy roboswitch spi */
1642 +#define SSB_BFL_XTAL_NOSLOW 0x0020 /* no slow clock available */
1643 +#define SSB_BFL_CCKHIPWR 0x0040 /* can do high power CCK transmission */
1644 +#define SSB_BFL_ENETADM 0x0080 /* has ADMtek switch */
1645 +#define SSB_BFL_ENETVLAN 0x0100 /* can do vlan */
1646 +#define SSB_BFL_AFTERBURNER 0x0200 /* supports Afterburner mode */
1647 +#define SSB_BFL_NOPCI 0x0400 /* board leaves PCI floating */
1648 +#define SSB_BFL_FEM 0x0800 /* supports the Front End Module */
1649 +#define SSB_BFL_EXTLNA 0x1000 /* has an external LNA */
1650 +#define SSB_BFL_HGPA 0x2000 /* had high gain PA */
1651 +#define SSB_BFL_BTCMOD 0x4000 /* BFL_BTCOEXIST is given in alternate GPIOs */
1652 +#define SSB_BFL_ALTIQ 0x8000 /* alternate I/Q settings */
1654 +/* Values for boardflags_hi read from SPROM */
1655 +#define SSB_BFH_NOPA 0x0001 /* has no PA */
1656 +#define SSB_BFH_RSSIINV 0x0002 /* RSSI uses positive slope (not TSSI) */
1657 +#define SSB_BFH_PAREF 0x0004 /* uses the PARef LDO */
1658 +#define SSB_BFH_3TSWITCH 0x0008 /* uses a triple throw switch shared with bluetooth */
1659 +#define SSB_BFH_PHASESHIFT 0x0010 /* can support phase shifter */
1660 +#define SSB_BFH_BUCKBOOST 0x0020 /* has buck/booster */
1661 +#define SSB_BFH_FEM_BT 0x0040 /* has FEM and switch to share antenna with bluetooth */
1663 +/* Values for boardflags2_lo read from SPROM */
1664 +#define SSB_BFL2_RXBB_INT_REG_DIS 0x0001 /* external RX BB regulator present */
1665 +#define SSB_BFL2_APLL_WAR 0x0002 /* alternative A-band PLL settings implemented */
1666 +#define SSB_BFL2_TXPWRCTRL_EN 0x0004 /* permits enabling TX Power Control */
1667 +#define SSB_BFL2_2X4_DIV 0x0008 /* 2x4 diversity switch */
1668 +#define SSB_BFL2_5G_PWRGAIN 0x0010 /* supports 5G band power gain */
1669 +#define SSB_BFL2_PCIEWAR_OVR 0x0020 /* overrides ASPM and Clkreq settings */
1670 +#define SSB_BFL2_CAESERS_BRD 0x0040 /* is Caesers board (unused) */
1671 +#define SSB_BFL2_BTC3WIRE 0x0080 /* used 3-wire bluetooth coexist */
1672 +#define SSB_BFL2_SKWRKFEM_BRD 0x0100 /* 4321mcm93 uses Skyworks FEM */
1673 +#define SSB_BFL2_SPUR_WAR 0x0200 /* has a workaround for clock-harmonic spurs */
1674 +#define SSB_BFL2_GPLL_WAR 0x0400 /* altenative G-band PLL settings implemented */
1676 /* Values for SSB_SPROM1_BINF_CCODE */
1678 SSB_SPROM1CCODE_WORLD = 0,
1679 --- a/drivers/ssb/b43_pci_bridge.c
1680 +++ b/drivers/ssb/b43_pci_bridge.c
1682 * because of its small size we include it in the SSB core
1683 * instead of creating a standalone module.
1685 - * Copyright 2007 Michael Buesch <mb@bu3sch.de>
1686 + * Copyright 2007 Michael Buesch <m@bues.ch>
1688 * Licensed under the GNU/GPL. See COPYING for details.
1691 #include <linux/pci.h>
1692 +#include <linux/module.h>
1693 #include <linux/ssb/ssb.h>
1695 #include "ssb_private.h"
1696 --- a/drivers/ssb/driver_extif.c
1697 +++ b/drivers/ssb/driver_extif.c
1699 * Broadcom EXTIF core driver
1701 * Copyright 2005, Broadcom Corporation
1702 - * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
1703 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
1704 * Copyright 2006, 2007, Felix Fietkau <nbd@openwrt.org>
1705 * Copyright 2007, Aurelien Jarno <aurelien@aurel32.net>
1707 --- a/drivers/ssb/driver_mipscore.c
1708 +++ b/drivers/ssb/driver_mipscore.c
1710 * Broadcom MIPS core driver
1712 * Copyright 2005, Broadcom Corporation
1713 - * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
1714 + * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
1716 * Licensed under the GNU/GPL. See COPYING for details.
1718 @@ -208,6 +208,9 @@ u32 ssb_cpu_clock(struct ssb_mipscore *m
1719 struct ssb_bus *bus = mcore->dev->bus;
1720 u32 pll_type, n, m, rate = 0;
1722 + if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
1723 + return ssb_pmu_get_cpu_clock(&bus->chipco);
1725 if (bus->extif.dev) {
1726 ssb_extif_get_clockcontrol(&bus->extif, &pll_type, &n, &m);
1727 } else if (bus->chipco.dev) {
1728 --- a/drivers/ssb/embedded.c
1729 +++ b/drivers/ssb/embedded.c
1731 * Embedded systems support code
1733 * Copyright 2005-2008, Broadcom Corporation
1734 - * Copyright 2006-2008, Michael Buesch <mb@bu3sch.de>
1735 + * Copyright 2006-2008, Michael Buesch <m@bues.ch>
1737 * Licensed under the GNU/GPL. See COPYING for details.
1739 --- a/drivers/ssb/pcmcia.c
1740 +++ b/drivers/ssb/pcmcia.c
1742 * PCMCIA-Hostbus related functions
1744 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
1745 - * Copyright 2007-2008 Michael Buesch <mb@bu3sch.de>
1746 + * Copyright 2007-2008 Michael Buesch <m@bues.ch>
1748 * Licensed under the GNU/GPL. See COPYING for details.
1750 @@ -676,14 +676,10 @@ static int ssb_pcmcia_do_get_invariants(
1751 case SSB_PCMCIA_CIS_ANTGAIN:
1752 GOTO_ERROR_ON(tuple->TupleDataLen != 2,
1754 - sprom->antenna_gain.ghz24.a0 = tuple->TupleData[1];
1755 - sprom->antenna_gain.ghz24.a1 = tuple->TupleData[1];
1756 - sprom->antenna_gain.ghz24.a2 = tuple->TupleData[1];
1757 - sprom->antenna_gain.ghz24.a3 = tuple->TupleData[1];
1758 - sprom->antenna_gain.ghz5.a0 = tuple->TupleData[1];
1759 - sprom->antenna_gain.ghz5.a1 = tuple->TupleData[1];
1760 - sprom->antenna_gain.ghz5.a2 = tuple->TupleData[1];
1761 - sprom->antenna_gain.ghz5.a3 = tuple->TupleData[1];
1762 + sprom->antenna_gain.a0 = tuple->TupleData[1];
1763 + sprom->antenna_gain.a1 = tuple->TupleData[1];
1764 + sprom->antenna_gain.a2 = tuple->TupleData[1];
1765 + sprom->antenna_gain.a3 = tuple->TupleData[1];
1767 case SSB_PCMCIA_CIS_BFLAGS:
1768 GOTO_ERROR_ON((tuple->TupleDataLen != 3) &&
1769 --- a/drivers/ssb/sdio.c
1770 +++ b/drivers/ssb/sdio.c
1773 * Based on drivers/ssb/pcmcia.c
1774 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
1775 - * Copyright 2007-2008 Michael Buesch <mb@bu3sch.de>
1776 + * Copyright 2007-2008 Michael Buesch <m@bues.ch>
1778 * Licensed under the GNU/GPL. See COPYING for details.
1780 @@ -551,14 +551,10 @@ int ssb_sdio_get_invariants(struct ssb_b
1781 case SSB_SDIO_CIS_ANTGAIN:
1782 GOTO_ERROR_ON(tuple->size != 2,
1784 - sprom->antenna_gain.ghz24.a0 = tuple->data[1];
1785 - sprom->antenna_gain.ghz24.a1 = tuple->data[1];
1786 - sprom->antenna_gain.ghz24.a2 = tuple->data[1];
1787 - sprom->antenna_gain.ghz24.a3 = tuple->data[1];
1788 - sprom->antenna_gain.ghz5.a0 = tuple->data[1];
1789 - sprom->antenna_gain.ghz5.a1 = tuple->data[1];
1790 - sprom->antenna_gain.ghz5.a2 = tuple->data[1];
1791 - sprom->antenna_gain.ghz5.a3 = tuple->data[1];
1792 + sprom->antenna_gain.a0 = tuple->data[1];
1793 + sprom->antenna_gain.a1 = tuple->data[1];
1794 + sprom->antenna_gain.a2 = tuple->data[1];
1795 + sprom->antenna_gain.a3 = tuple->data[1];
1797 case SSB_SDIO_CIS_BFLAGS:
1798 GOTO_ERROR_ON((tuple->size != 3) &&
1799 --- a/include/linux/ssb/ssb_driver_gige.h
1800 +++ b/include/linux/ssb/ssb_driver_gige.h
1802 #define LINUX_SSB_DRIVER_GIGE_H_
1804 #include <linux/ssb/ssb.h>
1805 +#include <linux/bug.h>
1806 #include <linux/pci.h>
1807 #include <linux/spinlock.h>