1 --- a/drivers/ssb/main.c
2 +++ b/drivers/ssb/main.c
3 @@ -384,6 +384,35 @@ static int ssb_device_uevent(struct devi
7 +#define ssb_config_attr(attrib, field, format_string) \
9 +attrib##_show(struct device *dev, struct device_attribute *attr, char *buf) \
11 + return sprintf(buf, format_string, dev_to_ssb_dev(dev)->field); \
14 +ssb_config_attr(core_num, core_index, "%u\n")
15 +ssb_config_attr(coreid, id.coreid, "0x%04x\n")
16 +ssb_config_attr(vendor, id.vendor, "0x%04x\n")
17 +ssb_config_attr(revision, id.revision, "%u\n")
18 +ssb_config_attr(irq, irq, "%u\n")
20 +name_show(struct device *dev, struct device_attribute *attr, char *buf)
22 + return sprintf(buf, "%s\n",
23 + ssb_core_name(dev_to_ssb_dev(dev)->id.coreid));
26 +static struct device_attribute ssb_device_attrs[] = {
28 + __ATTR_RO(core_num),
31 + __ATTR_RO(revision),
36 static struct bus_type ssb_bustype = {
38 .match = ssb_bus_match,
39 @@ -393,6 +422,7 @@ static struct bus_type ssb_bustype = {
40 .suspend = ssb_device_suspend,
41 .resume = ssb_device_resume,
42 .uevent = ssb_device_uevent,
43 + .dev_attrs = ssb_device_attrs,
46 static void ssb_buses_lock(void)
47 @@ -528,7 +558,7 @@ error:
50 /* Needs ssb_buses_lock() */
51 -static int ssb_attach_queued_buses(void)
52 +static int __devinit ssb_attach_queued_buses(void)
54 struct ssb_bus *bus, *n;
56 @@ -739,9 +769,9 @@ out:
60 -static int ssb_bus_register(struct ssb_bus *bus,
61 - ssb_invariants_func_t get_invariants,
62 - unsigned long baseaddr)
63 +static int __devinit ssb_bus_register(struct ssb_bus *bus,
64 + ssb_invariants_func_t get_invariants,
65 + unsigned long baseaddr)
69 @@ -822,8 +852,8 @@ err_disable_xtal:
72 #ifdef CONFIG_SSB_PCIHOST
73 -int ssb_bus_pcibus_register(struct ssb_bus *bus,
74 - struct pci_dev *host_pci)
75 +int __devinit ssb_bus_pcibus_register(struct ssb_bus *bus,
76 + struct pci_dev *host_pci)
80 @@ -846,9 +876,9 @@ EXPORT_SYMBOL(ssb_bus_pcibus_register);
81 #endif /* CONFIG_SSB_PCIHOST */
83 #ifdef CONFIG_SSB_PCMCIAHOST
84 -int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
85 - struct pcmcia_device *pcmcia_dev,
86 - unsigned long baseaddr)
87 +int __devinit ssb_bus_pcmciabus_register(struct ssb_bus *bus,
88 + struct pcmcia_device *pcmcia_dev,
89 + unsigned long baseaddr)
93 @@ -868,8 +898,9 @@ EXPORT_SYMBOL(ssb_bus_pcmciabus_register
94 #endif /* CONFIG_SSB_PCMCIAHOST */
96 #ifdef CONFIG_SSB_SDIOHOST
97 -int ssb_bus_sdiobus_register(struct ssb_bus *bus, struct sdio_func *func,
98 - unsigned int quirks)
99 +int __devinit ssb_bus_sdiobus_register(struct ssb_bus *bus,
100 + struct sdio_func *func,
101 + unsigned int quirks)
105 @@ -889,9 +920,9 @@ int ssb_bus_sdiobus_register(struct ssb_
106 EXPORT_SYMBOL(ssb_bus_sdiobus_register);
107 #endif /* CONFIG_SSB_PCMCIAHOST */
109 -int ssb_bus_ssbbus_register(struct ssb_bus *bus,
110 - unsigned long baseaddr,
111 - ssb_invariants_func_t get_invariants)
112 +int __devinit ssb_bus_ssbbus_register(struct ssb_bus *bus,
113 + unsigned long baseaddr,
114 + ssb_invariants_func_t get_invariants)
118 @@ -972,8 +1003,8 @@ u32 ssb_calc_clock_rate(u32 plltype, u32
120 case SSB_PLLTYPE_6: /* 100/200 or 120/240 only */
121 if (m & SSB_CHIPCO_CLK_T6_MMASK)
122 - return SSB_CHIPCO_CLK_T6_M0;
123 - return SSB_CHIPCO_CLK_T6_M1;
124 + return SSB_CHIPCO_CLK_T6_M1;
125 + return SSB_CHIPCO_CLK_T6_M0;
126 case SSB_PLLTYPE_1: /* 48Mhz base, 3 dividers */
127 case SSB_PLLTYPE_3: /* 25Mhz, 2 dividers */
128 case SSB_PLLTYPE_4: /* 48Mhz, 4 dividers */
129 @@ -1088,23 +1119,22 @@ static u32 ssb_tmslow_reject_bitmask(str
131 u32 rev = ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_SSBREV;
133 - /* The REJECT bit changed position in TMSLOW between
134 - * Backplane revisions. */
135 + /* The REJECT bit seems to be different for Backplane rev 2.3 */
137 case SSB_IDLOW_SSBREV_22:
138 - return SSB_TMSLOW_REJECT_22;
139 + case SSB_IDLOW_SSBREV_24:
140 + case SSB_IDLOW_SSBREV_26:
141 + return SSB_TMSLOW_REJECT;
142 case SSB_IDLOW_SSBREV_23:
143 return SSB_TMSLOW_REJECT_23;
144 - case SSB_IDLOW_SSBREV_24: /* TODO - find the proper REJECT bits */
145 - case SSB_IDLOW_SSBREV_25: /* same here */
146 - case SSB_IDLOW_SSBREV_26: /* same here */
147 + case SSB_IDLOW_SSBREV_25: /* TODO - find the proper REJECT bit */
148 case SSB_IDLOW_SSBREV_27: /* same here */
149 - return SSB_TMSLOW_REJECT_23; /* this is a guess */
150 + return SSB_TMSLOW_REJECT; /* this is a guess */
152 printk(KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
155 - return (SSB_TMSLOW_REJECT_22 | SSB_TMSLOW_REJECT_23);
156 + return (SSB_TMSLOW_REJECT | SSB_TMSLOW_REJECT_23);
159 int ssb_device_is_enabled(struct ssb_device *dev)
160 @@ -1163,10 +1193,10 @@ void ssb_device_enable(struct ssb_device
162 EXPORT_SYMBOL(ssb_device_enable);
164 -/* Wait for a bit in a register to get set or unset.
165 +/* Wait for bitmask in a register to get set or cleared.
166 * timeout is in units of ten-microseconds */
167 -static int ssb_wait_bit(struct ssb_device *dev, u16 reg, u32 bitmask,
168 - int timeout, int set)
169 +static int ssb_wait_bits(struct ssb_device *dev, u16 reg, u32 bitmask,
170 + int timeout, int set)
174 @@ -1174,7 +1204,7 @@ static int ssb_wait_bit(struct ssb_devic
175 for (i = 0; i < timeout; i++) {
176 val = ssb_read32(dev, reg);
179 + if ((val & bitmask) == bitmask)
182 if (!(val & bitmask))
183 @@ -1191,20 +1221,38 @@ static int ssb_wait_bit(struct ssb_devic
185 void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags)
190 if (ssb_read32(dev, SSB_TMSLOW) & SSB_TMSLOW_RESET)
193 reject = ssb_tmslow_reject_bitmask(dev);
194 - ssb_write32(dev, SSB_TMSLOW, reject | SSB_TMSLOW_CLOCK);
195 - ssb_wait_bit(dev, SSB_TMSLOW, reject, 1000, 1);
196 - ssb_wait_bit(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0);
197 - ssb_write32(dev, SSB_TMSLOW,
198 - SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
199 - reject | SSB_TMSLOW_RESET |
200 - core_specific_flags);
201 - ssb_flush_tmslow(dev);
203 + if (ssb_read32(dev, SSB_TMSLOW) & SSB_TMSLOW_CLOCK) {
204 + ssb_write32(dev, SSB_TMSLOW, reject | SSB_TMSLOW_CLOCK);
205 + ssb_wait_bits(dev, SSB_TMSLOW, reject, 1000, 1);
206 + ssb_wait_bits(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0);
208 + if (ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_INITIATOR) {
209 + val = ssb_read32(dev, SSB_IMSTATE);
210 + val |= SSB_IMSTATE_REJECT;
211 + ssb_write32(dev, SSB_IMSTATE, val);
212 + ssb_wait_bits(dev, SSB_IMSTATE, SSB_IMSTATE_BUSY, 1000,
216 + ssb_write32(dev, SSB_TMSLOW,
217 + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
218 + reject | SSB_TMSLOW_RESET |
219 + core_specific_flags);
220 + ssb_flush_tmslow(dev);
222 + if (ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_INITIATOR) {
223 + val = ssb_read32(dev, SSB_IMSTATE);
224 + val &= ~SSB_IMSTATE_REJECT;
225 + ssb_write32(dev, SSB_IMSTATE, val);
229 ssb_write32(dev, SSB_TMSLOW,
230 reject | SSB_TMSLOW_RESET |
231 @@ -1219,7 +1267,10 @@ u32 ssb_dma_translation(struct ssb_devic
232 case SSB_BUSTYPE_SSB:
234 case SSB_BUSTYPE_PCI:
235 - return SSB_PCI_DMA;
236 + if (ssb_read32(dev, SSB_TMSHIGH) & SSB_TMSHIGH_DMA64)
237 + return SSB_PCIE_DMA_H32;
239 + return SSB_PCI_DMA;
241 __ssb_dma_not_implemented(dev);
243 @@ -1262,20 +1313,20 @@ EXPORT_SYMBOL(ssb_bus_may_powerdown);
245 int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl)
247 - struct ssb_chipcommon *cc;
249 enum ssb_clkmode mode;
251 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1);
255 - mode = dynamic_pctl ? SSB_CLKMODE_DYNAMIC : SSB_CLKMODE_FAST;
256 - ssb_chipco_set_clockmode(cc, mode);
258 #ifdef CONFIG_SSB_DEBUG
262 + mode = dynamic_pctl ? SSB_CLKMODE_DYNAMIC : SSB_CLKMODE_FAST;
263 + ssb_chipco_set_clockmode(&bus->chipco, mode);
267 ssb_printk(KERN_ERR PFX "Bus powerup failed\n");
268 @@ -1283,6 +1334,37 @@ error:
270 EXPORT_SYMBOL(ssb_bus_powerup);
272 +static void ssb_broadcast_value(struct ssb_device *dev,
273 + u32 address, u32 data)
275 +#ifdef CONFIG_SSB_DRIVER_PCICORE
276 + /* This is used for both, PCI and ChipCommon core, so be careful. */
277 + BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
278 + BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
281 + ssb_write32(dev, SSB_CHIPCO_BCAST_ADDR, address);
282 + ssb_read32(dev, SSB_CHIPCO_BCAST_ADDR); /* flush */
283 + ssb_write32(dev, SSB_CHIPCO_BCAST_DATA, data);
284 + ssb_read32(dev, SSB_CHIPCO_BCAST_DATA); /* flush */
287 +void ssb_commit_settings(struct ssb_bus *bus)
289 + struct ssb_device *dev;
291 +#ifdef CONFIG_SSB_DRIVER_PCICORE
292 + dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
294 + dev = bus->chipco.dev;
298 + /* This forces an update of the cached registers. */
299 + ssb_broadcast_value(dev, 0xFD8, 0);
301 +EXPORT_SYMBOL(ssb_commit_settings);
303 u32 ssb_admatch_base(u32 adm)
306 --- a/drivers/ssb/pci.c
307 +++ b/drivers/ssb/pci.c
308 @@ -406,6 +406,46 @@ static void sprom_extract_r123(struct ss
309 out->antenna_gain.ghz5.a3 = gain;
312 +/* Revs 4 5 and 8 have partially shared layout */
313 +static void sprom_extract_r458(struct ssb_sprom *out, const u16 *in)
315 + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01,
316 + SSB_SPROM4_TXPID2G0, SSB_SPROM4_TXPID2G0_SHIFT);
317 + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01,
318 + SSB_SPROM4_TXPID2G1, SSB_SPROM4_TXPID2G1_SHIFT);
319 + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23,
320 + SSB_SPROM4_TXPID2G2, SSB_SPROM4_TXPID2G2_SHIFT);
321 + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23,
322 + SSB_SPROM4_TXPID2G3, SSB_SPROM4_TXPID2G3_SHIFT);
324 + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01,
325 + SSB_SPROM4_TXPID5GL0, SSB_SPROM4_TXPID5GL0_SHIFT);
326 + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01,
327 + SSB_SPROM4_TXPID5GL1, SSB_SPROM4_TXPID5GL1_SHIFT);
328 + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23,
329 + SSB_SPROM4_TXPID5GL2, SSB_SPROM4_TXPID5GL2_SHIFT);
330 + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23,
331 + SSB_SPROM4_TXPID5GL3, SSB_SPROM4_TXPID5GL3_SHIFT);
333 + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01,
334 + SSB_SPROM4_TXPID5G0, SSB_SPROM4_TXPID5G0_SHIFT);
335 + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01,
336 + SSB_SPROM4_TXPID5G1, SSB_SPROM4_TXPID5G1_SHIFT);
337 + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23,
338 + SSB_SPROM4_TXPID5G2, SSB_SPROM4_TXPID5G2_SHIFT);
339 + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23,
340 + SSB_SPROM4_TXPID5G3, SSB_SPROM4_TXPID5G3_SHIFT);
342 + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01,
343 + SSB_SPROM4_TXPID5GH0, SSB_SPROM4_TXPID5GH0_SHIFT);
344 + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01,
345 + SSB_SPROM4_TXPID5GH1, SSB_SPROM4_TXPID5GH1_SHIFT);
346 + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23,
347 + SSB_SPROM4_TXPID5GH2, SSB_SPROM4_TXPID5GH2_SHIFT);
348 + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23,
349 + SSB_SPROM4_TXPID5GH3, SSB_SPROM4_TXPID5GH3_SHIFT);
352 static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
355 @@ -428,10 +468,14 @@ static void sprom_extract_r45(struct ssb
356 SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0);
357 SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
358 SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0);
359 + SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0);
360 + SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0);
362 SPEX(country_code, SSB_SPROM5_CCODE, 0xFFFF, 0);
363 SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0);
364 SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0);
365 + SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0);
366 + SPEX(boardflags2_hi, SSB_SPROM5_BFL2HI, 0xFFFF, 0);
368 SPEX(ant_available_a, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_A,
369 SSB_SPROM4_ANTAVAIL_A_SHIFT);
370 @@ -471,6 +515,8 @@ static void sprom_extract_r45(struct ssb
371 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
372 sizeof(out->antenna_gain.ghz5));
374 + sprom_extract_r458(out, in);
376 /* TODO - get remaining rev 4 stuff needed */
379 @@ -561,6 +607,8 @@ static void sprom_extract_r8(struct ssb_
380 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
381 sizeof(out->antenna_gain.ghz5));
383 + sprom_extract_r458(out, in);
385 /* TODO - get remaining rev 8 stuff needed */
388 @@ -573,37 +621,34 @@ static int sprom_extract(struct ssb_bus
389 ssb_dprintk(KERN_DEBUG PFX "SPROM revision %d detected.\n", out->revision);
390 memset(out->et0mac, 0xFF, 6); /* preset et0 and et1 mac */
391 memset(out->et1mac, 0xFF, 6);
393 if ((bus->chip_id & 0xFF00) == 0x4400) {
394 /* Workaround: The BCM44XX chip has a stupid revision
395 * number stored in the SPROM.
396 * Always extract r1. */
398 + ssb_dprintk(KERN_DEBUG PFX "SPROM treated as revision %d\n", out->revision);
401 + switch (out->revision) {
405 sprom_extract_r123(out, in);
406 - } else if (bus->chip_id == 0x4321) {
407 - /* the BCM4328 has a chipid == 0x4321 and a rev 4 SPROM */
412 sprom_extract_r45(out, in);
414 - switch (out->revision) {
418 - sprom_extract_r123(out, in);
422 - sprom_extract_r45(out, in);
425 - sprom_extract_r8(out, in);
428 - ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
429 - " revision %d detected. Will extract"
430 - " v1\n", out->revision);
432 - sprom_extract_r123(out, in);
436 + sprom_extract_r8(out, in);
439 + ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
440 + " revision %d detected. Will extract"
441 + " v1\n", out->revision);
443 + sprom_extract_r123(out, in);
446 if (out->boardflags_lo == 0xFFFF)
447 @@ -617,15 +662,14 @@ static int sprom_extract(struct ssb_bus
448 static int ssb_pci_sprom_get(struct ssb_bus *bus,
449 struct ssb_sprom *sprom)
451 - const struct ssb_sprom *fallback;
456 if (!ssb_is_sprom_available(bus)) {
457 ssb_printk(KERN_ERR PFX "No SPROM available!\n");
460 - if (bus->chipco.dev) { /* can be unavailible! */
461 + if (bus->chipco.dev) { /* can be unavailable! */
463 * get SPROM offset: SSB_SPROM_BASE1 except for
464 * chipcommon rev >= 31 or chip ID is 0x4312 and
465 @@ -645,7 +689,7 @@ static int ssb_pci_sprom_get(struct ssb_
467 buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL);
471 bus->sprom_size = SSB_SPROMSIZE_WORDS_R123;
472 sprom_do_read(bus, buf);
473 err = sprom_check_crc(buf, bus->sprom_size);
474 @@ -655,17 +699,24 @@ static int ssb_pci_sprom_get(struct ssb_
475 buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
480 bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
481 sprom_do_read(bus, buf);
482 err = sprom_check_crc(buf, bus->sprom_size);
484 /* All CRC attempts failed.
485 * Maybe there is no SPROM on the device?
486 - * If we have a fallback, use that. */
487 - fallback = ssb_get_fallback_sprom();
489 - memcpy(sprom, fallback, sizeof(*sprom));
490 + * Now we ask the arch code if there is some sprom
491 + * available for this device in some other storage */
492 + err = ssb_fill_sprom_with_fallback(bus, sprom);
494 + ssb_printk(KERN_WARNING PFX "WARNING: Using"
495 + " fallback SPROM failed (err %d)\n",
498 + ssb_dprintk(KERN_DEBUG PFX "Using SPROM"
499 + " revision %d provided by"
500 + " platform.\n", sprom->revision);
504 @@ -677,19 +728,15 @@ static int ssb_pci_sprom_get(struct ssb_
512 static void ssb_pci_get_boardinfo(struct ssb_bus *bus,
513 struct ssb_boardinfo *bi)
515 - pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_VENDOR_ID,
517 - pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_ID,
519 - pci_read_config_word(bus->host_pci, PCI_REVISION_ID,
521 + bi->vendor = bus->host_pci->subsystem_vendor;
522 + bi->type = bus->host_pci->subsystem_device;
523 + bi->rev = bus->host_pci->revision;
526 int ssb_pci_get_invariants(struct ssb_bus *bus,
527 --- a/drivers/ssb/pcihost_wrapper.c
528 +++ b/drivers/ssb/pcihost_wrapper.c
529 @@ -53,12 +53,13 @@ static int ssb_pcihost_resume(struct pci
530 # define ssb_pcihost_resume NULL
531 #endif /* CONFIG_PM */
533 -static int ssb_pcihost_probe(struct pci_dev *dev,
534 - const struct pci_device_id *id)
535 +static int __devinit ssb_pcihost_probe(struct pci_dev *dev,
536 + const struct pci_device_id *id)
543 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
545 @@ -74,6 +75,12 @@ static int ssb_pcihost_probe(struct pci_
546 goto err_pci_disable;
549 + /* Disable the RETRY_TIMEOUT register (0x41) to keep
550 + * PCI Tx retries from interfering with C3 CPU state */
551 + pci_read_config_dword(dev, 0x40, &val);
552 + if ((val & 0x0000ff00) != 0)
553 + pci_write_config_dword(dev, 0x40, val & 0xffff00ff);
555 err = ssb_bus_pcibus_register(ssb, dev);
557 goto err_pci_release_regions;
558 @@ -103,7 +110,7 @@ static void ssb_pcihost_remove(struct pc
559 pci_set_drvdata(dev, NULL);
562 -int ssb_pcihost_register(struct pci_driver *driver)
563 +int __devinit ssb_pcihost_register(struct pci_driver *driver)
565 driver->probe = ssb_pcihost_probe;
566 driver->remove = ssb_pcihost_remove;
567 --- a/drivers/ssb/scan.c
568 +++ b/drivers/ssb/scan.c
569 @@ -259,7 +259,10 @@ static int we_support_multiple_80211_cor
570 #ifdef CONFIG_SSB_PCIHOST
571 if (bus->bustype == SSB_BUSTYPE_PCI) {
572 if (bus->host_pci->vendor == PCI_VENDOR_ID_BROADCOM &&
573 - bus->host_pci->device == 0x4324)
574 + ((bus->host_pci->device == 0x4313) ||
575 + (bus->host_pci->device == 0x431A) ||
576 + (bus->host_pci->device == 0x4321) ||
577 + (bus->host_pci->device == 0x4324)))
580 #endif /* CONFIG_SSB_PCIHOST */
581 @@ -308,8 +311,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
583 if (bus->bustype == SSB_BUSTYPE_PCI) {
584 bus->chip_id = pcidev_to_chipid(bus->host_pci);
585 - pci_read_config_word(bus->host_pci, PCI_REVISION_ID,
587 + bus->chip_rev = bus->host_pci->revision;
588 bus->chip_package = 0;
590 bus->chip_id = 0x4710;
591 @@ -406,10 +408,10 @@ int ssb_bus_scan(struct ssb_bus *bus,
592 /* Ignore PCI cores on PCI-E cards.
593 * Ignore PCI-E cores on PCI cards. */
594 if (dev->id.coreid == SSB_DEV_PCI) {
595 - if (bus->host_pci->is_pcie)
596 + if (pci_is_pcie(bus->host_pci))
599 - if (!bus->host_pci->is_pcie)
600 + if (!pci_is_pcie(bus->host_pci))
604 @@ -421,6 +423,16 @@ int ssb_bus_scan(struct ssb_bus *bus,
605 bus->pcicore.dev = dev;
606 #endif /* CONFIG_SSB_DRIVER_PCICORE */
608 + case SSB_DEV_ETHERNET:
609 + if (bus->bustype == SSB_BUSTYPE_PCI) {
610 + if (bus->host_pci->vendor == PCI_VENDOR_ID_BROADCOM &&
611 + (bus->host_pci->device & 0xFF00) == 0x4300) {
612 + /* This is a dangling ethernet core on a
613 + * wireless device. Ignore it. */
621 --- a/include/linux/ssb/ssb.h
622 +++ b/include/linux/ssb/ssb.h
623 @@ -27,6 +27,8 @@ struct ssb_sprom {
624 u8 et1mdcport; /* MDIO for enet1 */
625 u8 board_rev; /* Board revision number from SPROM. */
626 u8 country_code; /* Country Code */
627 + u16 leddc_on_time; /* LED Powersave Duty Cycle On Count */
628 + u16 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
629 u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */
630 u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */
632 @@ -55,6 +57,10 @@ struct ssb_sprom {
633 u8 tri5gl; /* 5.2GHz TX isolation */
634 u8 tri5g; /* 5.3GHz TX isolation */
635 u8 tri5gh; /* 5.8GHz TX isolation */
636 + u8 txpid2g[4]; /* 2GHz TX power index */
637 + u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
638 + u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
639 + u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
640 u8 rxpo2g; /* 2GHz RX power offset */
641 u8 rxpo5g; /* 5GHz RX power offset */
642 u8 rssisav2g; /* 2GHz RSSI params */
643 @@ -95,7 +101,7 @@ struct ssb_sprom {
644 struct ssb_boardinfo {
652 @@ -304,7 +310,7 @@ struct ssb_bus {
654 /* ID information about the Chip. */
659 u16 sprom_size; /* number of words in sprom */
661 @@ -400,7 +406,9 @@ extern bool ssb_is_sprom_available(struc
663 /* Set a fallback SPROM.
664 * See kdoc at the function definition for complete documentation. */
665 -extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom);
666 +extern int ssb_arch_register_fallback_sprom(
667 + int (*sprom_callback)(struct ssb_bus *bus,
668 + struct ssb_sprom *out));
670 /* Suspend a SSB bus.
671 * Call this from the parent bus suspend routine. */
672 @@ -514,6 +522,7 @@ extern int ssb_bus_may_powerdown(struct
673 * Otherwise static always-on powercontrol will be used. */
674 extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
676 +extern void ssb_commit_settings(struct ssb_bus *bus);
678 /* Various helper functions */
679 extern u32 ssb_admatch_base(u32 adm);
680 --- a/include/linux/ssb/ssb_driver_gige.h
681 +++ b/include/linux/ssb/ssb_driver_gige.h
682 @@ -96,16 +96,21 @@ static inline bool ssb_gige_must_flush_p
686 -extern char * nvram_get(const char *name);
687 +#ifdef CONFIG_BCM47XX
688 +#include <asm/mach-bcm47xx/nvram.h>
689 /* Get the device MAC address */
690 static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
692 -#ifdef CONFIG_BCM47XX
693 - char *res = nvram_get("et0macaddr");
695 - memcpy(macaddr, res, 6);
698 + if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
700 + nvram_parse_macaddr(buf, macaddr);
703 +static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
708 extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
709 struct pci_dev *pdev);
710 --- a/include/linux/ssb/ssb_regs.h
711 +++ b/include/linux/ssb/ssb_regs.h
713 #define SSB_IMSTATE_AP_RSV 0x00000030 /* Reserved */
714 #define SSB_IMSTATE_IBE 0x00020000 /* In Band Error */
715 #define SSB_IMSTATE_TO 0x00040000 /* Timeout */
716 +#define SSB_IMSTATE_BUSY 0x01800000 /* Busy (Backplane rev >= 2.3 only) */
717 +#define SSB_IMSTATE_REJECT 0x02000000 /* Reject (Backplane rev >= 2.3 only) */
718 #define SSB_INTVEC 0x0F94 /* SB Interrupt Mask */
719 #define SSB_INTVEC_PCI 0x00000001 /* Enable interrupts for PCI */
720 #define SSB_INTVEC_ENET0 0x00000002 /* Enable interrupts for enet 0 */
722 #define SSB_INTVEC_ENET1 0x00000040 /* Enable interrupts for enet 1 */
723 #define SSB_TMSLOW 0x0F98 /* SB Target State Low */
724 #define SSB_TMSLOW_RESET 0x00000001 /* Reset */
725 -#define SSB_TMSLOW_REJECT_22 0x00000002 /* Reject (Backplane rev 2.2) */
726 +#define SSB_TMSLOW_REJECT 0x00000002 /* Reject (Standard Backplane) */
727 #define SSB_TMSLOW_REJECT_23 0x00000004 /* Reject (Backplane rev 2.3) */
728 #define SSB_TMSLOW_CLOCK 0x00010000 /* Clock Enable */
729 #define SSB_TMSLOW_FGC 0x00020000 /* Force Gated Clocks On */
731 /* SPROM Revision 4 */
732 #define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */
733 #define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */
734 +#define SSB_SPROM4_BFL2LO 0x0048 /* Board flags 2 (low 16 bits) */
735 +#define SSB_SPROM4_BFL2HI 0x004A /* Board flags 2 Hi */
736 #define SSB_SPROM4_IL0MAC 0x004C /* 6 byte MAC address for a/b/g/n */
737 #define SSB_SPROM4_CCODE 0x0052 /* Country Code (2 bytes) */
738 #define SSB_SPROM4_GPIOA 0x0056 /* Gen. Purpose IO # 0 and 1 */
740 #define SSB_SPROM4_AGAIN2_SHIFT 0
741 #define SSB_SPROM4_AGAIN3 0xFF00 /* Antenna 3 */
742 #define SSB_SPROM4_AGAIN3_SHIFT 8
743 +#define SSB_SPROM4_TXPID2G01 0x0062 /* TX Power Index 2GHz */
744 +#define SSB_SPROM4_TXPID2G0 0x00FF
745 +#define SSB_SPROM4_TXPID2G0_SHIFT 0
746 +#define SSB_SPROM4_TXPID2G1 0xFF00
747 +#define SSB_SPROM4_TXPID2G1_SHIFT 8
748 +#define SSB_SPROM4_TXPID2G23 0x0064 /* TX Power Index 2GHz */
749 +#define SSB_SPROM4_TXPID2G2 0x00FF
750 +#define SSB_SPROM4_TXPID2G2_SHIFT 0
751 +#define SSB_SPROM4_TXPID2G3 0xFF00
752 +#define SSB_SPROM4_TXPID2G3_SHIFT 8
753 +#define SSB_SPROM4_TXPID5G01 0x0066 /* TX Power Index 5GHz middle subband */
754 +#define SSB_SPROM4_TXPID5G0 0x00FF
755 +#define SSB_SPROM4_TXPID5G0_SHIFT 0
756 +#define SSB_SPROM4_TXPID5G1 0xFF00
757 +#define SSB_SPROM4_TXPID5G1_SHIFT 8
758 +#define SSB_SPROM4_TXPID5G23 0x0068 /* TX Power Index 5GHz middle subband */
759 +#define SSB_SPROM4_TXPID5G2 0x00FF
760 +#define SSB_SPROM4_TXPID5G2_SHIFT 0
761 +#define SSB_SPROM4_TXPID5G3 0xFF00
762 +#define SSB_SPROM4_TXPID5G3_SHIFT 8
763 +#define SSB_SPROM4_TXPID5GL01 0x006A /* TX Power Index 5GHz low subband */
764 +#define SSB_SPROM4_TXPID5GL0 0x00FF
765 +#define SSB_SPROM4_TXPID5GL0_SHIFT 0
766 +#define SSB_SPROM4_TXPID5GL1 0xFF00
767 +#define SSB_SPROM4_TXPID5GL1_SHIFT 8
768 +#define SSB_SPROM4_TXPID5GL23 0x006C /* TX Power Index 5GHz low subband */
769 +#define SSB_SPROM4_TXPID5GL2 0x00FF
770 +#define SSB_SPROM4_TXPID5GL2_SHIFT 0
771 +#define SSB_SPROM4_TXPID5GL3 0xFF00
772 +#define SSB_SPROM4_TXPID5GL3_SHIFT 8
773 +#define SSB_SPROM4_TXPID5GH01 0x006E /* TX Power Index 5GHz high subband */
774 +#define SSB_SPROM4_TXPID5GH0 0x00FF
775 +#define SSB_SPROM4_TXPID5GH0_SHIFT 0
776 +#define SSB_SPROM4_TXPID5GH1 0xFF00
777 +#define SSB_SPROM4_TXPID5GH1_SHIFT 8
778 +#define SSB_SPROM4_TXPID5GH23 0x0070 /* TX Power Index 5GHz high subband */
779 +#define SSB_SPROM4_TXPID5GH2 0x00FF
780 +#define SSB_SPROM4_TXPID5GH2_SHIFT 0
781 +#define SSB_SPROM4_TXPID5GH3 0xFF00
782 +#define SSB_SPROM4_TXPID5GH3_SHIFT 8
783 #define SSB_SPROM4_MAXP_BG 0x0080 /* Max Power BG in path 1 */
784 #define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */
785 #define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
787 #define SSB_SPROM5_CCODE 0x0044 /* Country Code (2 bytes) */
788 #define SSB_SPROM5_BFLLO 0x004A /* Boardflags (low 16 bits) */
789 #define SSB_SPROM5_BFLHI 0x004C /* Board Flags Hi */
790 +#define SSB_SPROM5_BFL2LO 0x004E /* Board flags 2 (low 16 bits) */
791 +#define SSB_SPROM5_BFL2HI 0x0050 /* Board flags 2 Hi */
792 #define SSB_SPROM5_IL0MAC 0x0052 /* 6 byte MAC address for a/b/g/n */
793 #define SSB_SPROM5_GPIOA 0x0076 /* Gen. Purpose IO # 0 and 1 */
794 #define SSB_SPROM5_GPIOA_P0 0x00FF /* Pin 0 */
795 --- a/drivers/ssb/driver_chipcommon.c
796 +++ b/drivers/ssb/driver_chipcommon.c
797 @@ -46,40 +46,66 @@ void ssb_chipco_set_clockmode(struct ssb
802 + /* We support SLOW only on 6..9 */
803 + if (ccdev->id.revision >= 10 && mode == SSB_CLKMODE_SLOW)
804 + mode = SSB_CLKMODE_DYNAMIC;
806 + if (cc->capabilities & SSB_CHIPCO_CAP_PMU)
807 + return; /* PMU controls clockmode, separated function needed */
808 + SSB_WARN_ON(ccdev->id.revision >= 20);
810 /* chipcommon cores prior to rev6 don't support dynamic clock control */
811 if (ccdev->id.revision < 6)
813 - /* chipcommon cores rev10 are a whole new ball game */
815 + /* ChipCommon cores rev10+ need testing */
816 if (ccdev->id.revision >= 10)
819 if (!(cc->capabilities & SSB_CHIPCO_CAP_PCTL))
823 - case SSB_CLKMODE_SLOW:
824 + case SSB_CLKMODE_SLOW: /* For revs 6..9 only */
825 tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
826 tmp |= SSB_CHIPCO_SLOWCLKCTL_FSLOW;
827 chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
829 case SSB_CLKMODE_FAST:
830 - ssb_pci_xtal(bus, SSB_GPIO_XTAL, 1); /* Force crystal on */
831 - tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
832 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
833 - tmp |= SSB_CHIPCO_SLOWCLKCTL_IPLL;
834 - chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
835 + if (ccdev->id.revision < 10) {
836 + ssb_pci_xtal(bus, SSB_GPIO_XTAL, 1); /* Force crystal on */
837 + tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
838 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
839 + tmp |= SSB_CHIPCO_SLOWCLKCTL_IPLL;
840 + chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
842 + chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
843 + (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) |
844 + SSB_CHIPCO_SYSCLKCTL_FORCEHT));
845 + /* udelay(150); TODO: not available in early init */
848 case SSB_CLKMODE_DYNAMIC:
849 - tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
850 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
851 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_IPLL;
852 - tmp &= ~SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
853 - if ((tmp & SSB_CHIPCO_SLOWCLKCTL_SRC) != SSB_CHIPCO_SLOWCLKCTL_SRC_XTAL)
854 - tmp |= SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
855 - chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
857 - /* for dynamic control, we have to release our xtal_pu "force on" */
858 - if (tmp & SSB_CHIPCO_SLOWCLKCTL_ENXTAL)
859 - ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
860 + if (ccdev->id.revision < 10) {
861 + tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
862 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
863 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_IPLL;
864 + tmp &= ~SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
865 + if ((tmp & SSB_CHIPCO_SLOWCLKCTL_SRC) !=
866 + SSB_CHIPCO_SLOWCLKCTL_SRC_XTAL)
867 + tmp |= SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
868 + chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
870 + /* For dynamic control, we have to release our xtal_pu
872 + if (tmp & SSB_CHIPCO_SLOWCLKCTL_ENXTAL)
873 + ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
875 + chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
876 + (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) &
877 + ~SSB_CHIPCO_SYSCLKCTL_FORCEHT));
882 @@ -260,6 +286,12 @@ void ssb_chipcommon_init(struct ssb_chip
883 if (cc->dev->id.revision >= 11)
884 cc->status = chipco_read32(cc, SSB_CHIPCO_CHIPSTAT);
885 ssb_dprintk(KERN_INFO PFX "chipcommon status is 0x%x\n", cc->status);
887 + if (cc->dev->id.revision >= 20) {
888 + chipco_write32(cc, SSB_CHIPCO_GPIOPULLUP, 0);
889 + chipco_write32(cc, SSB_CHIPCO_GPIOPULLDOWN, 0);
893 chipco_powercontrol_init(cc);
894 ssb_chipco_set_clockmode(cc, SSB_CLKMODE_FAST);
895 --- a/drivers/ssb/driver_chipcommon_pmu.c
896 +++ b/drivers/ssb/driver_chipcommon_pmu.c
897 @@ -417,12 +417,14 @@ static void ssb_pmu_resources_init(struc
898 u32 min_msk = 0, max_msk = 0;
900 const struct pmu_res_updown_tab_entry *updown_tab = NULL;
901 - unsigned int updown_tab_size;
902 + unsigned int updown_tab_size = 0;
903 const struct pmu_res_depend_tab_entry *depend_tab = NULL;
904 - unsigned int depend_tab_size;
905 + unsigned int depend_tab_size = 0;
907 switch (bus->chip_id) {
912 /* We keep the default settings:
914 --- a/drivers/ssb/driver_gige.c
915 +++ b/drivers/ssb/driver_gige.c
916 @@ -106,8 +106,9 @@ void gige_pcicfg_write32(struct ssb_gige
917 gige_write32(dev, SSB_GIGE_PCICFG + offset, value);
920 -static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn,
921 - int reg, int size, u32 *val)
922 +static int __devinit ssb_gige_pci_read_config(struct pci_bus *bus,
923 + unsigned int devfn, int reg,
924 + int size, u32 *val)
926 struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
928 @@ -136,8 +137,9 @@ static int ssb_gige_pci_read_config(stru
929 return PCIBIOS_SUCCESSFUL;
932 -static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn,
933 - int reg, int size, u32 val)
934 +static int __devinit ssb_gige_pci_write_config(struct pci_bus *bus,
935 + unsigned int devfn, int reg,
938 struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops);
940 @@ -166,7 +168,8 @@ static int ssb_gige_pci_write_config(str
941 return PCIBIOS_SUCCESSFUL;
944 -static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
945 +static int __devinit ssb_gige_probe(struct ssb_device *sdev,
946 + const struct ssb_device_id *id)
948 struct ssb_gige *dev;
949 u32 base, tmslow, tmshigh;
950 --- a/drivers/ssb/driver_pcicore.c
951 +++ b/drivers/ssb/driver_pcicore.c
954 #include "ssb_private.h"
956 +static u32 ssb_pcie_read(struct ssb_pcicore *pc, u32 address);
957 +static void ssb_pcie_write(struct ssb_pcicore *pc, u32 address, u32 data);
958 +static u16 ssb_pcie_mdio_read(struct ssb_pcicore *pc, u8 device, u8 address);
959 +static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
960 + u8 address, u16 data);
963 u32 pcicore_read32(struct ssb_pcicore *pc, u16 offset)
964 @@ -309,7 +314,7 @@ int ssb_pcicore_pcibios_map_irq(const st
965 return ssb_mips_irq(extpci_core->dev) + 2;
968 -static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
969 +static void __devinit ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
973 @@ -374,7 +379,7 @@ static void ssb_pcicore_init_hostmode(st
974 register_pci_controller(&ssb_pcicore_controller);
977 -static int pcicore_is_in_hostmode(struct ssb_pcicore *pc)
978 +static int __devinit pcicore_is_in_hostmode(struct ssb_pcicore *pc)
980 struct ssb_bus *bus = pc->dev->bus;
982 @@ -403,25 +408,133 @@ static int pcicore_is_in_hostmode(struct
984 #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
986 +/**************************************************
988 + **************************************************/
990 +static void __devinit ssb_pcicore_fix_sprom_core_index(struct ssb_pcicore *pc)
992 + u16 tmp = pcicore_read16(pc, SSB_PCICORE_SPROM(0));
993 + if (((tmp & 0xF000) >> 12) != pc->dev->core_index) {
995 + tmp |= (pc->dev->core_index << 12);
996 + pcicore_write16(pc, SSB_PCICORE_SPROM(0), tmp);
1000 +static u8 ssb_pcicore_polarity_workaround(struct ssb_pcicore *pc)
1002 + return (ssb_pcie_read(pc, 0x204) & 0x10) ? 0xC0 : 0x80;
1005 +static void ssb_pcicore_serdes_workaround(struct ssb_pcicore *pc)
1007 + const u8 serdes_pll_device = 0x1D;
1008 + const u8 serdes_rx_device = 0x1F;
1011 + ssb_pcie_mdio_write(pc, serdes_rx_device, 1 /* Control */,
1012 + ssb_pcicore_polarity_workaround(pc));
1013 + tmp = ssb_pcie_mdio_read(pc, serdes_pll_device, 1 /* Control */);
1015 + ssb_pcie_mdio_write(pc, serdes_pll_device, 1, tmp & ~0x4000);
1018 +static void ssb_pcicore_pci_setup_workarounds(struct ssb_pcicore *pc)
1020 + struct ssb_device *pdev = pc->dev;
1021 + struct ssb_bus *bus = pdev->bus;
1024 + tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
1025 + tmp |= SSB_PCICORE_SBTOPCI_PREF;
1026 + tmp |= SSB_PCICORE_SBTOPCI_BURST;
1027 + pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
1029 + if (pdev->id.revision < 5) {
1030 + tmp = ssb_read32(pdev, SSB_IMCFGLO);
1031 + tmp &= ~SSB_IMCFGLO_SERTO;
1033 + tmp &= ~SSB_IMCFGLO_REQTO;
1034 + tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
1035 + ssb_write32(pdev, SSB_IMCFGLO, tmp);
1036 + ssb_commit_settings(bus);
1037 + } else if (pdev->id.revision >= 11) {
1038 + tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
1039 + tmp |= SSB_PCICORE_SBTOPCI_MRM;
1040 + pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
1044 +static void ssb_pcicore_pcie_setup_workarounds(struct ssb_pcicore *pc)
1047 + u8 rev = pc->dev->id.revision;
1049 + if (rev == 0 || rev == 1) {
1050 + /* TLP Workaround register. */
1051 + tmp = ssb_pcie_read(pc, 0x4);
1053 + ssb_pcie_write(pc, 0x4, tmp);
1056 + /* DLLP Link Control register. */
1057 + tmp = ssb_pcie_read(pc, 0x100);
1059 + ssb_pcie_write(pc, 0x100, tmp);
1063 + const u8 serdes_rx_device = 0x1F;
1065 + ssb_pcie_mdio_write(pc, serdes_rx_device,
1066 + 2 /* Timer */, 0x8128);
1067 + ssb_pcie_mdio_write(pc, serdes_rx_device,
1068 + 6 /* CDR */, 0x0100);
1069 + ssb_pcie_mdio_write(pc, serdes_rx_device,
1070 + 7 /* CDR BW */, 0x1466);
1071 + } else if (rev == 3 || rev == 4 || rev == 5) {
1072 + /* TODO: DLLP Power Management Threshold */
1073 + ssb_pcicore_serdes_workaround(pc);
1075 + } else if (rev == 7) {
1076 + /* TODO: No PLL down */
1080 + /* Miscellaneous Configuration Fixup */
1081 + tmp = pcicore_read16(pc, SSB_PCICORE_SPROM(5));
1082 + if (!(tmp & 0x8000))
1083 + pcicore_write16(pc, SSB_PCICORE_SPROM(5),
1088 /**************************************************
1089 * Generic and Clientmode operation code.
1090 **************************************************/
1092 -static void ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
1093 +static void __devinit ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
1095 + ssb_pcicore_fix_sprom_core_index(pc);
1097 /* Disable PCI interrupts. */
1098 ssb_write32(pc->dev, SSB_INTVEC, 0);
1100 + /* Additional PCIe always once-executed workarounds */
1101 + if (pc->dev->id.coreid == SSB_DEV_PCIE) {
1102 + ssb_pcicore_serdes_workaround(pc);
1104 + /* TODO: Clock Request Update */
1108 -void ssb_pcicore_init(struct ssb_pcicore *pc)
1109 +void __devinit ssb_pcicore_init(struct ssb_pcicore *pc)
1111 struct ssb_device *dev = pc->dev;
1112 - struct ssb_bus *bus;
1117 if (!ssb_device_is_enabled(dev))
1118 ssb_device_enable(dev, 0);
1120 @@ -446,11 +559,35 @@ static void ssb_pcie_write(struct ssb_pc
1121 pcicore_write32(pc, 0x134, data);
1124 -static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
1125 - u8 address, u16 data)
1126 +static void ssb_pcie_mdio_set_phy(struct ssb_pcicore *pc, u8 phy)
1128 + const u16 mdio_control = 0x128;
1129 + const u16 mdio_data = 0x12C;
1133 + v = (1 << 30); /* Start of Transaction */
1134 + v |= (1 << 28); /* Write Transaction */
1135 + v |= (1 << 17); /* Turnaround */
1136 + v |= (0x1F << 18);
1138 + pcicore_write32(pc, mdio_data, v);
1141 + for (i = 0; i < 200; i++) {
1142 + v = pcicore_read32(pc, mdio_control);
1143 + if (v & 0x100 /* Trans complete */)
1149 +static u16 ssb_pcie_mdio_read(struct ssb_pcicore *pc, u8 device, u8 address)
1151 const u16 mdio_control = 0x128;
1152 const u16 mdio_data = 0x12C;
1153 + int max_retries = 10;
1158 @@ -458,46 +595,68 @@ static void ssb_pcie_mdio_write(struct s
1159 v |= 0x2; /* MDIO Clock Divisor */
1160 pcicore_write32(pc, mdio_control, v);
1162 + if (pc->dev->id.revision >= 10) {
1163 + max_retries = 200;
1164 + ssb_pcie_mdio_set_phy(pc, device);
1167 v = (1 << 30); /* Start of Transaction */
1168 - v |= (1 << 28); /* Write Transaction */
1169 + v |= (1 << 29); /* Read Transaction */
1170 v |= (1 << 17); /* Turnaround */
1171 - v |= (u32)device << 22;
1172 + if (pc->dev->id.revision < 10)
1173 + v |= (u32)device << 22;
1174 v |= (u32)address << 18;
1176 pcicore_write32(pc, mdio_data, v);
1177 /* Wait for the device to complete the transaction */
1179 - for (i = 0; i < 10; i++) {
1180 + for (i = 0; i < max_retries; i++) {
1181 v = pcicore_read32(pc, mdio_control);
1182 - if (v & 0x100 /* Trans complete */)
1183 + if (v & 0x100 /* Trans complete */) {
1185 + ret = pcicore_read32(pc, mdio_data);
1190 pcicore_write32(pc, mdio_control, 0);
1194 -static void ssb_broadcast_value(struct ssb_device *dev,
1195 - u32 address, u32 data)
1196 +static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
1197 + u8 address, u16 data)
1199 - /* This is used for both, PCI and ChipCommon core, so be careful. */
1200 - BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
1201 - BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
1202 + const u16 mdio_control = 0x128;
1203 + const u16 mdio_data = 0x12C;
1204 + int max_retries = 10;
1208 - ssb_write32(dev, SSB_PCICORE_BCAST_ADDR, address);
1209 - ssb_read32(dev, SSB_PCICORE_BCAST_ADDR); /* flush */
1210 - ssb_write32(dev, SSB_PCICORE_BCAST_DATA, data);
1211 - ssb_read32(dev, SSB_PCICORE_BCAST_DATA); /* flush */
1213 + v = 0x80; /* Enable Preamble Sequence */
1214 + v |= 0x2; /* MDIO Clock Divisor */
1215 + pcicore_write32(pc, mdio_control, v);
1217 -static void ssb_commit_settings(struct ssb_bus *bus)
1219 - struct ssb_device *dev;
1220 + if (pc->dev->id.revision >= 10) {
1221 + max_retries = 200;
1222 + ssb_pcie_mdio_set_phy(pc, device);
1225 - dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
1226 - if (WARN_ON(!dev))
1228 - /* This forces an update of the cached registers. */
1229 - ssb_broadcast_value(dev, 0xFD8, 0);
1230 + v = (1 << 30); /* Start of Transaction */
1231 + v |= (1 << 28); /* Write Transaction */
1232 + v |= (1 << 17); /* Turnaround */
1233 + if (pc->dev->id.revision < 10)
1234 + v |= (u32)device << 22;
1235 + v |= (u32)address << 18;
1237 + pcicore_write32(pc, mdio_data, v);
1238 + /* Wait for the device to complete the transaction */
1240 + for (i = 0; i < max_retries; i++) {
1241 + v = pcicore_read32(pc, mdio_control);
1242 + if (v & 0x100 /* Trans complete */)
1246 + pcicore_write32(pc, mdio_control, 0);
1249 int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
1250 @@ -550,48 +709,10 @@ int ssb_pcicore_dev_irqvecs_enable(struc
1253 if (pdev->id.coreid == SSB_DEV_PCI) {
1254 - tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
1255 - tmp |= SSB_PCICORE_SBTOPCI_PREF;
1256 - tmp |= SSB_PCICORE_SBTOPCI_BURST;
1257 - pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
1259 - if (pdev->id.revision < 5) {
1260 - tmp = ssb_read32(pdev, SSB_IMCFGLO);
1261 - tmp &= ~SSB_IMCFGLO_SERTO;
1263 - tmp &= ~SSB_IMCFGLO_REQTO;
1264 - tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
1265 - ssb_write32(pdev, SSB_IMCFGLO, tmp);
1266 - ssb_commit_settings(bus);
1267 - } else if (pdev->id.revision >= 11) {
1268 - tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
1269 - tmp |= SSB_PCICORE_SBTOPCI_MRM;
1270 - pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
1272 + ssb_pcicore_pci_setup_workarounds(pc);
1274 WARN_ON(pdev->id.coreid != SSB_DEV_PCIE);
1275 - //TODO: Better make defines for all these magic PCIE values.
1276 - if ((pdev->id.revision == 0) || (pdev->id.revision == 1)) {
1277 - /* TLP Workaround register. */
1278 - tmp = ssb_pcie_read(pc, 0x4);
1280 - ssb_pcie_write(pc, 0x4, tmp);
1282 - if (pdev->id.revision == 0) {
1283 - const u8 serdes_rx_device = 0x1F;
1285 - ssb_pcie_mdio_write(pc, serdes_rx_device,
1286 - 2 /* Timer */, 0x8128);
1287 - ssb_pcie_mdio_write(pc, serdes_rx_device,
1288 - 6 /* CDR */, 0x0100);
1289 - ssb_pcie_mdio_write(pc, serdes_rx_device,
1290 - 7 /* CDR BW */, 0x1466);
1291 - } else if (pdev->id.revision == 1) {
1292 - /* DLLP Link Control register. */
1293 - tmp = ssb_pcie_read(pc, 0x100);
1295 - ssb_pcie_write(pc, 0x100, tmp);
1297 + ssb_pcicore_pcie_setup_workarounds(pc);
1301 --- a/drivers/ssb/sprom.c
1302 +++ b/drivers/ssb/sprom.c
1304 #include <linux/slab.h>
1307 -static const struct ssb_sprom *fallback_sprom;
1308 +static int(*get_fallback_sprom)(struct ssb_bus *dev, struct ssb_sprom *out);
1311 static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
1312 @@ -145,36 +145,43 @@ out:
1316 - * ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found.
1317 + * ssb_arch_register_fallback_sprom - Registers a method providing a
1318 + * fallback SPROM if no SPROM is found.
1320 - * @sprom: The SPROM data structure to register.
1321 + * @sprom_callback: The callback function.
1323 - * With this function the architecture implementation may register a fallback
1324 - * SPROM data structure. The fallback is only used for PCI based SSB devices,
1325 - * where no valid SPROM can be found in the shadow registers.
1326 + * With this function the architecture implementation may register a
1327 + * callback handler which fills the SPROM data structure. The fallback is
1328 + * only used for PCI based SSB devices, where no valid SPROM can be found
1329 + * in the shadow registers.
1331 - * This function is useful for weird architectures that have a half-assed SSB device
1332 - * hardwired to their PCI bus.
1333 + * This function is useful for weird architectures that have a half-assed
1334 + * SSB device hardwired to their PCI bus.
1336 - * Note that it does only work with PCI attached SSB devices. PCMCIA devices currently
1337 - * don't use this fallback.
1338 - * Architectures must provide the SPROM for native SSB devices anyway,
1339 - * so the fallback also isn't used for native devices.
1340 + * Note that it does only work with PCI attached SSB devices. PCMCIA
1341 + * devices currently don't use this fallback.
1342 + * Architectures must provide the SPROM for native SSB devices anyway, so
1343 + * the fallback also isn't used for native devices.
1345 - * This function is available for architecture code, only. So it is not exported.
1346 + * This function is available for architecture code, only. So it is not
1349 -int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom)
1350 +int ssb_arch_register_fallback_sprom(int (*sprom_callback)(struct ssb_bus *bus,
1351 + struct ssb_sprom *out))
1353 - if (fallback_sprom)
1354 + if (get_fallback_sprom)
1356 - fallback_sprom = sprom;
1357 + get_fallback_sprom = sprom_callback;
1362 -const struct ssb_sprom *ssb_get_fallback_sprom(void)
1363 +int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out)
1365 - return fallback_sprom;
1366 + if (!get_fallback_sprom)
1369 + return get_fallback_sprom(bus, out);
1372 /* http://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */
1373 @@ -185,7 +192,7 @@ bool ssb_is_sprom_available(struct ssb_b
1374 /* this routine differs from specs as we do not access SPROM directly
1376 if (bus->bustype == SSB_BUSTYPE_PCI &&
1377 - bus->chipco.dev && /* can be unavailible! */
1378 + bus->chipco.dev && /* can be unavailable! */
1379 bus->chipco.dev->id.revision >= 31)
1380 return bus->chipco.capabilities & SSB_CHIPCO_CAP_SPROM;
1382 --- a/drivers/ssb/ssb_private.h
1383 +++ b/drivers/ssb/ssb_private.h
1384 @@ -171,7 +171,8 @@ ssize_t ssb_attr_sprom_store(struct ssb_
1385 const char *buf, size_t count,
1386 int (*sprom_check_crc)(const u16 *sprom, size_t size),
1387 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
1388 -extern const struct ssb_sprom *ssb_get_fallback_sprom(void);
1389 +extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
1390 + struct ssb_sprom *out);
1394 --- a/include/linux/ssb/ssb_driver_chipcommon.h
1395 +++ b/include/linux/ssb/ssb_driver_chipcommon.h
1397 #define SSB_CHIPCO_FLASHDATA 0x0048
1398 #define SSB_CHIPCO_BCAST_ADDR 0x0050
1399 #define SSB_CHIPCO_BCAST_DATA 0x0054
1400 +#define SSB_CHIPCO_GPIOPULLUP 0x0058 /* Rev >= 20 only */
1401 +#define SSB_CHIPCO_GPIOPULLDOWN 0x005C /* Rev >= 20 only */
1402 #define SSB_CHIPCO_GPIOIN 0x0060
1403 #define SSB_CHIPCO_GPIOOUT 0x0064
1404 #define SSB_CHIPCO_GPIOOUTEN 0x0068
1406 #define SSB_CHIPCO_GPIOIRQ 0x0074
1407 #define SSB_CHIPCO_WATCHDOG 0x0080
1408 #define SSB_CHIPCO_GPIOTIMER 0x0088 /* LED powersave (corerev >= 16) */
1409 +#define SSB_CHIPCO_GPIOTIMER_OFFTIME 0x0000FFFF
1410 +#define SSB_CHIPCO_GPIOTIMER_OFFTIME_SHIFT 0
1411 +#define SSB_CHIPCO_GPIOTIMER_ONTIME 0xFFFF0000
1412 #define SSB_CHIPCO_GPIOTIMER_ONTIME_SHIFT 16
1413 #define SSB_CHIPCO_GPIOTOUTM 0x008C /* LED powersave (corerev >= 16) */
1414 #define SSB_CHIPCO_CLOCK_N 0x0090
1415 @@ -189,8 +194,10 @@
1416 #define SSB_CHIPCO_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
1417 #define SSB_CHIPCO_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
1418 #define SSB_CHIPCO_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
1419 -#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00010000 /* HT available */
1420 -#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00020000 /* APL available */
1421 +#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
1422 +#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00020000 /* HT available */
1423 +#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
1424 +#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
1425 #define SSB_CHIPCO_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
1426 #define SSB_CHIPCO_UART0_DATA 0x0300
1427 #define SSB_CHIPCO_UART0_IMR 0x0304