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 @@ -1163,10 +1193,10 @@ void ssb_device_enable(struct ssb_device
49 EXPORT_SYMBOL(ssb_device_enable);
51 -/* Wait for a bit in a register to get set or unset.
52 +/* Wait for bitmask in a register to get set or cleared.
53 * timeout is in units of ten-microseconds */
54 -static int ssb_wait_bit(struct ssb_device *dev, u16 reg, u32 bitmask,
55 - int timeout, int set)
56 +static int ssb_wait_bits(struct ssb_device *dev, u16 reg, u32 bitmask,
57 + int timeout, int set)
61 @@ -1174,7 +1204,7 @@ static int ssb_wait_bit(struct ssb_devic
62 for (i = 0; i < timeout; i++) {
63 val = ssb_read32(dev, reg);
66 + if ((val & bitmask) == bitmask)
70 @@ -1191,20 +1221,38 @@ static int ssb_wait_bit(struct ssb_devic
72 void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags)
77 if (ssb_read32(dev, SSB_TMSLOW) & SSB_TMSLOW_RESET)
80 reject = ssb_tmslow_reject_bitmask(dev);
81 - ssb_write32(dev, SSB_TMSLOW, reject | SSB_TMSLOW_CLOCK);
82 - ssb_wait_bit(dev, SSB_TMSLOW, reject, 1000, 1);
83 - ssb_wait_bit(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0);
84 - ssb_write32(dev, SSB_TMSLOW,
85 - SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
86 - reject | SSB_TMSLOW_RESET |
87 - core_specific_flags);
88 - ssb_flush_tmslow(dev);
90 + if (ssb_read32(dev, SSB_TMSLOW) & SSB_TMSLOW_CLOCK) {
91 + ssb_write32(dev, SSB_TMSLOW, reject | SSB_TMSLOW_CLOCK);
92 + ssb_wait_bits(dev, SSB_TMSLOW, reject, 1000, 1);
93 + ssb_wait_bits(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0);
95 + if (ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_INITIATOR) {
96 + val = ssb_read32(dev, SSB_IMSTATE);
97 + val |= SSB_IMSTATE_REJECT;
98 + ssb_write32(dev, SSB_IMSTATE, val);
99 + ssb_wait_bits(dev, SSB_IMSTATE, SSB_IMSTATE_BUSY, 1000,
103 + ssb_write32(dev, SSB_TMSLOW,
104 + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
105 + reject | SSB_TMSLOW_RESET |
106 + core_specific_flags);
107 + ssb_flush_tmslow(dev);
109 + if (ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_INITIATOR) {
110 + val = ssb_read32(dev, SSB_IMSTATE);
111 + val &= ~SSB_IMSTATE_REJECT;
112 + ssb_write32(dev, SSB_IMSTATE, val);
116 ssb_write32(dev, SSB_TMSLOW,
117 reject | SSB_TMSLOW_RESET |
118 --- a/drivers/ssb/pci.c
119 +++ b/drivers/ssb/pci.c
120 @@ -406,6 +406,46 @@ static void sprom_extract_r123(struct ss
121 out->antenna_gain.ghz5.a3 = gain;
124 +/* Revs 4 5 and 8 have partially shared layout */
125 +static void sprom_extract_r458(struct ssb_sprom *out, const u16 *in)
127 + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01,
128 + SSB_SPROM4_TXPID2G0, SSB_SPROM4_TXPID2G0_SHIFT);
129 + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01,
130 + SSB_SPROM4_TXPID2G1, SSB_SPROM4_TXPID2G1_SHIFT);
131 + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23,
132 + SSB_SPROM4_TXPID2G2, SSB_SPROM4_TXPID2G2_SHIFT);
133 + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23,
134 + SSB_SPROM4_TXPID2G3, SSB_SPROM4_TXPID2G3_SHIFT);
136 + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01,
137 + SSB_SPROM4_TXPID5GL0, SSB_SPROM4_TXPID5GL0_SHIFT);
138 + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01,
139 + SSB_SPROM4_TXPID5GL1, SSB_SPROM4_TXPID5GL1_SHIFT);
140 + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23,
141 + SSB_SPROM4_TXPID5GL2, SSB_SPROM4_TXPID5GL2_SHIFT);
142 + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23,
143 + SSB_SPROM4_TXPID5GL3, SSB_SPROM4_TXPID5GL3_SHIFT);
145 + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01,
146 + SSB_SPROM4_TXPID5G0, SSB_SPROM4_TXPID5G0_SHIFT);
147 + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01,
148 + SSB_SPROM4_TXPID5G1, SSB_SPROM4_TXPID5G1_SHIFT);
149 + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23,
150 + SSB_SPROM4_TXPID5G2, SSB_SPROM4_TXPID5G2_SHIFT);
151 + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23,
152 + SSB_SPROM4_TXPID5G3, SSB_SPROM4_TXPID5G3_SHIFT);
154 + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01,
155 + SSB_SPROM4_TXPID5GH0, SSB_SPROM4_TXPID5GH0_SHIFT);
156 + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01,
157 + SSB_SPROM4_TXPID5GH1, SSB_SPROM4_TXPID5GH1_SHIFT);
158 + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23,
159 + SSB_SPROM4_TXPID5GH2, SSB_SPROM4_TXPID5GH2_SHIFT);
160 + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23,
161 + SSB_SPROM4_TXPID5GH3, SSB_SPROM4_TXPID5GH3_SHIFT);
164 static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
167 @@ -428,10 +468,14 @@ static void sprom_extract_r45(struct ssb
168 SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0);
169 SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
170 SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0);
171 + SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0);
172 + SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0);
174 SPEX(country_code, SSB_SPROM5_CCODE, 0xFFFF, 0);
175 SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0);
176 SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0);
177 + SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0);
178 + SPEX(boardflags2_hi, SSB_SPROM5_BFL2HI, 0xFFFF, 0);
180 SPEX(ant_available_a, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_A,
181 SSB_SPROM4_ANTAVAIL_A_SHIFT);
182 @@ -471,6 +515,8 @@ static void sprom_extract_r45(struct ssb
183 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
184 sizeof(out->antenna_gain.ghz5));
186 + sprom_extract_r458(out, in);
188 /* TODO - get remaining rev 4 stuff needed */
191 @@ -561,6 +607,8 @@ static void sprom_extract_r8(struct ssb_
192 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
193 sizeof(out->antenna_gain.ghz5));
195 + sprom_extract_r458(out, in);
197 /* TODO - get remaining rev 8 stuff needed */
200 @@ -573,37 +621,34 @@ static int sprom_extract(struct ssb_bus
201 ssb_dprintk(KERN_DEBUG PFX "SPROM revision %d detected.\n", out->revision);
202 memset(out->et0mac, 0xFF, 6); /* preset et0 and et1 mac */
203 memset(out->et1mac, 0xFF, 6);
205 if ((bus->chip_id & 0xFF00) == 0x4400) {
206 /* Workaround: The BCM44XX chip has a stupid revision
207 * number stored in the SPROM.
208 * Always extract r1. */
210 + ssb_dprintk(KERN_DEBUG PFX "SPROM treated as revision %d\n", out->revision);
213 + switch (out->revision) {
217 sprom_extract_r123(out, in);
218 - } else if (bus->chip_id == 0x4321) {
219 - /* the BCM4328 has a chipid == 0x4321 and a rev 4 SPROM */
224 sprom_extract_r45(out, in);
226 - switch (out->revision) {
230 - sprom_extract_r123(out, in);
234 - sprom_extract_r45(out, in);
237 - sprom_extract_r8(out, in);
240 - ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
241 - " revision %d detected. Will extract"
242 - " v1\n", out->revision);
244 - sprom_extract_r123(out, in);
248 + sprom_extract_r8(out, in);
251 + ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
252 + " revision %d detected. Will extract"
253 + " v1\n", out->revision);
255 + sprom_extract_r123(out, in);
258 if (out->boardflags_lo == 0xFFFF)
259 @@ -618,7 +663,7 @@ static int ssb_pci_sprom_get(struct ssb_
260 struct ssb_sprom *sprom)
262 const struct ssb_sprom *fallback;
267 if (!ssb_is_sprom_available(bus)) {
268 @@ -645,7 +690,7 @@ static int ssb_pci_sprom_get(struct ssb_
270 buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL);
274 bus->sprom_size = SSB_SPROMSIZE_WORDS_R123;
275 sprom_do_read(bus, buf);
276 err = sprom_check_crc(buf, bus->sprom_size);
277 @@ -655,7 +700,7 @@ static int ssb_pci_sprom_get(struct ssb_
278 buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
283 bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
284 sprom_do_read(bus, buf);
285 err = sprom_check_crc(buf, bus->sprom_size);
286 @@ -677,7 +722,6 @@ static int ssb_pci_sprom_get(struct ssb_
294 --- a/drivers/ssb/pcihost_wrapper.c
295 +++ b/drivers/ssb/pcihost_wrapper.c
296 @@ -59,6 +59,7 @@ static int ssb_pcihost_probe(struct pci_
302 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
304 @@ -74,6 +75,12 @@ static int ssb_pcihost_probe(struct pci_
305 goto err_pci_disable;
308 + /* Disable the RETRY_TIMEOUT register (0x41) to keep
309 + * PCI Tx retries from interfering with C3 CPU state */
310 + pci_read_config_dword(dev, 0x40, &val);
311 + if ((val & 0x0000ff00) != 0)
312 + pci_write_config_dword(dev, 0x40, val & 0xffff00ff);
314 err = ssb_bus_pcibus_register(ssb, dev);
316 goto err_pci_release_regions;
317 --- a/drivers/ssb/scan.c
318 +++ b/drivers/ssb/scan.c
319 @@ -406,10 +406,10 @@ int ssb_bus_scan(struct ssb_bus *bus,
320 /* Ignore PCI cores on PCI-E cards.
321 * Ignore PCI-E cores on PCI cards. */
322 if (dev->id.coreid == SSB_DEV_PCI) {
323 - if (bus->host_pci->is_pcie)
324 + if (pci_is_pcie(bus->host_pci))
327 - if (!bus->host_pci->is_pcie)
328 + if (!pci_is_pcie(bus->host_pci))
332 @@ -421,6 +421,16 @@ int ssb_bus_scan(struct ssb_bus *bus,
333 bus->pcicore.dev = dev;
334 #endif /* CONFIG_SSB_DRIVER_PCICORE */
336 + case SSB_DEV_ETHERNET:
337 + if (bus->bustype == SSB_BUSTYPE_PCI) {
338 + if (bus->host_pci->vendor == PCI_VENDOR_ID_BROADCOM &&
339 + (bus->host_pci->device & 0xFF00) == 0x4300) {
340 + /* This is a dangling ethernet core on a
341 + * wireless device. Ignore it. */
349 --- a/include/linux/ssb/ssb.h
350 +++ b/include/linux/ssb/ssb.h
351 @@ -55,6 +55,10 @@ struct ssb_sprom {
352 u8 tri5gl; /* 5.2GHz TX isolation */
353 u8 tri5g; /* 5.3GHz TX isolation */
354 u8 tri5gh; /* 5.8GHz TX isolation */
355 + u8 txpid2g[4]; /* 2GHz TX power index */
356 + u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
357 + u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
358 + u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
359 u8 rxpo2g; /* 2GHz RX power offset */
360 u8 rxpo5g; /* 5GHz RX power offset */
361 u8 rssisav2g; /* 2GHz RSSI params */
362 --- a/include/linux/ssb/ssb_driver_gige.h
363 +++ b/include/linux/ssb/ssb_driver_gige.h
364 @@ -96,16 +96,21 @@ static inline bool ssb_gige_must_flush_p
368 -extern char * nvram_get(const char *name);
369 +#ifdef CONFIG_BCM47XX
370 +#include <asm/mach-bcm47xx/nvram.h>
371 /* Get the device MAC address */
372 static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
374 -#ifdef CONFIG_BCM47XX
375 - char *res = nvram_get("et0macaddr");
377 - memcpy(macaddr, res, 6);
380 + if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
382 + nvram_parse_macaddr(buf, macaddr);
385 +static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
390 extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
391 struct pci_dev *pdev);
392 --- a/include/linux/ssb/ssb_regs.h
393 +++ b/include/linux/ssb/ssb_regs.h
395 #define SSB_IMSTATE_AP_RSV 0x00000030 /* Reserved */
396 #define SSB_IMSTATE_IBE 0x00020000 /* In Band Error */
397 #define SSB_IMSTATE_TO 0x00040000 /* Timeout */
398 +#define SSB_IMSTATE_BUSY 0x01800000 /* Busy (Backplane rev >= 2.3 only) */
399 +#define SSB_IMSTATE_REJECT 0x02000000 /* Reject (Backplane rev >= 2.3 only) */
400 #define SSB_INTVEC 0x0F94 /* SB Interrupt Mask */
401 #define SSB_INTVEC_PCI 0x00000001 /* Enable interrupts for PCI */
402 #define SSB_INTVEC_ENET0 0x00000002 /* Enable interrupts for enet 0 */
404 /* SPROM Revision 4 */
405 #define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */
406 #define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */
407 +#define SSB_SPROM4_BFL2LO 0x0048 /* Board flags 2 (low 16 bits) */
408 +#define SSB_SPROM4_BFL2HI 0x004A /* Board flags 2 Hi */
409 #define SSB_SPROM4_IL0MAC 0x004C /* 6 byte MAC address for a/b/g/n */
410 #define SSB_SPROM4_CCODE 0x0052 /* Country Code (2 bytes) */
411 #define SSB_SPROM4_GPIOA 0x0056 /* Gen. Purpose IO # 0 and 1 */
413 #define SSB_SPROM4_AGAIN2_SHIFT 0
414 #define SSB_SPROM4_AGAIN3 0xFF00 /* Antenna 3 */
415 #define SSB_SPROM4_AGAIN3_SHIFT 8
416 +#define SSB_SPROM4_TXPID2G01 0x0062 /* TX Power Index 2GHz */
417 +#define SSB_SPROM4_TXPID2G0 0x00FF
418 +#define SSB_SPROM4_TXPID2G0_SHIFT 0
419 +#define SSB_SPROM4_TXPID2G1 0xFF00
420 +#define SSB_SPROM4_TXPID2G1_SHIFT 8
421 +#define SSB_SPROM4_TXPID2G23 0x0064 /* TX Power Index 2GHz */
422 +#define SSB_SPROM4_TXPID2G2 0x00FF
423 +#define SSB_SPROM4_TXPID2G2_SHIFT 0
424 +#define SSB_SPROM4_TXPID2G3 0xFF00
425 +#define SSB_SPROM4_TXPID2G3_SHIFT 8
426 +#define SSB_SPROM4_TXPID5G01 0x0066 /* TX Power Index 5GHz middle subband */
427 +#define SSB_SPROM4_TXPID5G0 0x00FF
428 +#define SSB_SPROM4_TXPID5G0_SHIFT 0
429 +#define SSB_SPROM4_TXPID5G1 0xFF00
430 +#define SSB_SPROM4_TXPID5G1_SHIFT 8
431 +#define SSB_SPROM4_TXPID5G23 0x0068 /* TX Power Index 5GHz middle subband */
432 +#define SSB_SPROM4_TXPID5G2 0x00FF
433 +#define SSB_SPROM4_TXPID5G2_SHIFT 0
434 +#define SSB_SPROM4_TXPID5G3 0xFF00
435 +#define SSB_SPROM4_TXPID5G3_SHIFT 8
436 +#define SSB_SPROM4_TXPID5GL01 0x006A /* TX Power Index 5GHz low subband */
437 +#define SSB_SPROM4_TXPID5GL0 0x00FF
438 +#define SSB_SPROM4_TXPID5GL0_SHIFT 0
439 +#define SSB_SPROM4_TXPID5GL1 0xFF00
440 +#define SSB_SPROM4_TXPID5GL1_SHIFT 8
441 +#define SSB_SPROM4_TXPID5GL23 0x006C /* TX Power Index 5GHz low subband */
442 +#define SSB_SPROM4_TXPID5GL2 0x00FF
443 +#define SSB_SPROM4_TXPID5GL2_SHIFT 0
444 +#define SSB_SPROM4_TXPID5GL3 0xFF00
445 +#define SSB_SPROM4_TXPID5GL3_SHIFT 8
446 +#define SSB_SPROM4_TXPID5GH01 0x006E /* TX Power Index 5GHz high subband */
447 +#define SSB_SPROM4_TXPID5GH0 0x00FF
448 +#define SSB_SPROM4_TXPID5GH0_SHIFT 0
449 +#define SSB_SPROM4_TXPID5GH1 0xFF00
450 +#define SSB_SPROM4_TXPID5GH1_SHIFT 8
451 +#define SSB_SPROM4_TXPID5GH23 0x0070 /* TX Power Index 5GHz high subband */
452 +#define SSB_SPROM4_TXPID5GH2 0x00FF
453 +#define SSB_SPROM4_TXPID5GH2_SHIFT 0
454 +#define SSB_SPROM4_TXPID5GH3 0xFF00
455 +#define SSB_SPROM4_TXPID5GH3_SHIFT 8
456 #define SSB_SPROM4_MAXP_BG 0x0080 /* Max Power BG in path 1 */
457 #define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */
458 #define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
460 #define SSB_SPROM5_CCODE 0x0044 /* Country Code (2 bytes) */
461 #define SSB_SPROM5_BFLLO 0x004A /* Boardflags (low 16 bits) */
462 #define SSB_SPROM5_BFLHI 0x004C /* Board Flags Hi */
463 +#define SSB_SPROM5_BFL2LO 0x004E /* Board flags 2 (low 16 bits) */
464 +#define SSB_SPROM5_BFL2HI 0x0050 /* Board flags 2 Hi */
465 #define SSB_SPROM5_IL0MAC 0x0052 /* 6 byte MAC address for a/b/g/n */
466 #define SSB_SPROM5_GPIOA 0x0076 /* Gen. Purpose IO # 0 and 1 */
467 #define SSB_SPROM5_GPIOA_P0 0x00FF /* Pin 0 */