kernel: backport get_cycles() fix
[openwrt/staging/wigyori.git] / target / linux / generic / patches-3.10 / 025-bcma_backport.patch
1 --- a/drivers/bcma/Kconfig
2 +++ b/drivers/bcma/Kconfig
3 @@ -26,6 +26,7 @@ config BCMA_HOST_PCI_POSSIBLE
4 config BCMA_HOST_PCI
5 bool "Support for BCMA on PCI-host bus"
6 depends on BCMA_HOST_PCI_POSSIBLE
7 + default y
8
9 config BCMA_DRIVER_PCI_HOSTMODE
10 bool "Driver for PCI core working in hostmode"
11 @@ -34,8 +35,14 @@ config BCMA_DRIVER_PCI_HOSTMODE
12 PCI core hostmode operation (external PCI bus).
13
14 config BCMA_HOST_SOC
15 - bool
16 - depends on BCMA_DRIVER_MIPS
17 + bool "Support for BCMA in a SoC"
18 + depends on BCMA
19 + help
20 + Host interface for a Broadcom AIX bus directly mapped into
21 + the memory. This only works with the Broadcom SoCs from the
22 + BCM47XX line.
23 +
24 + If unsure, say N
25
26 config BCMA_DRIVER_MIPS
27 bool "BCMA Broadcom MIPS core driver"
28 --- a/drivers/bcma/bcma_private.h
29 +++ b/drivers/bcma/bcma_private.h
30 @@ -22,6 +22,8 @@
31 struct bcma_bus;
32
33 /* main.c */
34 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
35 + int timeout);
36 int bcma_bus_register(struct bcma_bus *bus);
37 void bcma_bus_unregister(struct bcma_bus *bus);
38 int __init bcma_bus_early_register(struct bcma_bus *bus,
39 --- a/drivers/bcma/core.c
40 +++ b/drivers/bcma/core.c
41 @@ -9,6 +9,25 @@
42 #include <linux/export.h>
43 #include <linux/bcma/bcma.h>
44
45 +static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask,
46 + u32 value, int timeout)
47 +{
48 + unsigned long deadline = jiffies + timeout;
49 + u32 val;
50 +
51 + do {
52 + val = bcma_aread32(core, reg);
53 + if ((val & mask) == value)
54 + return true;
55 + cpu_relax();
56 + udelay(10);
57 + } while (!time_after_eq(jiffies, deadline));
58 +
59 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
60 +
61 + return false;
62 +}
63 +
64 bool bcma_core_is_enabled(struct bcma_device *core)
65 {
66 if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC))
67 @@ -25,13 +44,15 @@ void bcma_core_disable(struct bcma_devic
68 if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
69 return;
70
71 - bcma_awrite32(core, BCMA_IOCTL, flags);
72 - bcma_aread32(core, BCMA_IOCTL);
73 - udelay(10);
74 + bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300);
75
76 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
77 bcma_aread32(core, BCMA_RESET_CTL);
78 udelay(1);
79 +
80 + bcma_awrite32(core, BCMA_IOCTL, flags);
81 + bcma_aread32(core, BCMA_IOCTL);
82 + udelay(10);
83 }
84 EXPORT_SYMBOL_GPL(bcma_core_disable);
85
86 @@ -43,6 +64,7 @@ int bcma_core_enable(struct bcma_device
87 bcma_aread32(core, BCMA_IOCTL);
88
89 bcma_awrite32(core, BCMA_RESET_CTL, 0);
90 + bcma_aread32(core, BCMA_RESET_CTL);
91 udelay(1);
92
93 bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
94 --- a/drivers/bcma/driver_chipcommon.c
95 +++ b/drivers/bcma/driver_chipcommon.c
96 @@ -140,8 +140,15 @@ void bcma_core_chipcommon_init(struct bc
97 bcma_core_chipcommon_early_init(cc);
98
99 if (cc->core->id.rev >= 20) {
100 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
101 - bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
102 + u32 pullup = 0, pulldown = 0;
103 +
104 + if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) {
105 + pullup = 0x402e0;
106 + pulldown = 0x20500;
107 + }
108 +
109 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup);
110 + bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown);
111 }
112
113 if (cc->capabilities & BCMA_CC_CAP_PMU)
114 --- a/drivers/bcma/driver_chipcommon_pmu.c
115 +++ b/drivers/bcma/driver_chipcommon_pmu.c
116 @@ -56,6 +56,109 @@ void bcma_chipco_regctl_maskset(struct b
117 }
118 EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
119
120 +static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc)
121 +{
122 + u32 ilp_ctl, alp_hz;
123 +
124 + if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) &
125 + BCMA_CC_PMU_STAT_EXT_LPO_AVAIL))
126 + return 0;
127 +
128 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
129 + BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
130 + usleep_range(1000, 2000);
131 +
132 + ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
133 + ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK;
134 +
135 + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
136 +
137 + alp_hz = ilp_ctl * 32768 / 4;
138 + return (alp_hz + 50000) / 100000 * 100;
139 +}
140 +
141 +static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq)
142 +{
143 + struct bcma_bus *bus = cc->core->bus;
144 + u32 freq_tgt_target = 0, freq_tgt_current;
145 + u32 pll0, mask;
146 +
147 + switch (bus->chipinfo.id) {
148 + case BCMA_CHIP_ID_BCM43142:
149 + /* pmu2_xtaltab0_adfll_485 */
150 + switch (xtalfreq) {
151 + case 12000:
152 + freq_tgt_target = 0x50D52;
153 + break;
154 + case 20000:
155 + freq_tgt_target = 0x307FE;
156 + break;
157 + case 26000:
158 + freq_tgt_target = 0x254EA;
159 + break;
160 + case 37400:
161 + freq_tgt_target = 0x19EF8;
162 + break;
163 + case 52000:
164 + freq_tgt_target = 0x12A75;
165 + break;
166 + }
167 + break;
168 + }
169 +
170 + if (!freq_tgt_target) {
171 + bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n",
172 + xtalfreq);
173 + return;
174 + }
175 +
176 + pll0 = bcma_chipco_pll_read(cc, BCMA_CC_PMU15_PLL_PLLCTL0);
177 + freq_tgt_current = (pll0 & BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK) >>
178 + BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
179 +
180 + if (freq_tgt_current == freq_tgt_target) {
181 + bcma_debug(bus, "Target TGT frequency already set\n");
182 + return;
183 + }
184 +
185 + /* Turn off PLL */
186 + switch (bus->chipinfo.id) {
187 + case BCMA_CHIP_ID_BCM43142:
188 + mask = (u32)~(BCMA_RES_4314_HT_AVAIL |
189 + BCMA_RES_4314_MACPHY_CLK_AVAIL);
190 +
191 + bcma_cc_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask);
192 + bcma_cc_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask);
193 + bcma_wait_value(cc->core, BCMA_CLKCTLST,
194 + BCMA_CLKCTLST_HAVEHT, 0, 20000);
195 + break;
196 + }
197 +
198 + pll0 &= ~BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK;
199 + pll0 |= freq_tgt_target << BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
200 + bcma_chipco_pll_write(cc, BCMA_CC_PMU15_PLL_PLLCTL0, pll0);
201 +
202 + /* Flush */
203 + if (cc->pmu.rev >= 2)
204 + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
205 +
206 + /* TODO: Do we need to update OTP? */
207 +}
208 +
209 +static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
210 +{
211 + struct bcma_bus *bus = cc->core->bus;
212 + u32 xtalfreq = bcma_pmu_xtalfreq(cc);
213 +
214 + switch (bus->chipinfo.id) {
215 + case BCMA_CHIP_ID_BCM43142:
216 + if (xtalfreq == 0)
217 + xtalfreq = 20000;
218 + bcma_pmu2_pll_init0(cc, xtalfreq);
219 + break;
220 + }
221 +}
222 +
223 static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
224 {
225 struct bcma_bus *bus = cc->core->bus;
226 @@ -66,6 +169,25 @@ static void bcma_pmu_resources_init(stru
227 min_msk = 0x200D;
228 max_msk = 0xFFFF;
229 break;
230 + case BCMA_CHIP_ID_BCM43142:
231 + min_msk = BCMA_RES_4314_LPLDO_PU |
232 + BCMA_RES_4314_PMU_SLEEP_DIS |
233 + BCMA_RES_4314_PMU_BG_PU |
234 + BCMA_RES_4314_CBUCK_LPOM_PU |
235 + BCMA_RES_4314_CBUCK_PFM_PU |
236 + BCMA_RES_4314_CLDO_PU |
237 + BCMA_RES_4314_LPLDO2_LVM |
238 + BCMA_RES_4314_WL_PMU_PU |
239 + BCMA_RES_4314_LDO3P3_PU |
240 + BCMA_RES_4314_OTP_PU |
241 + BCMA_RES_4314_WL_PWRSW_PU |
242 + BCMA_RES_4314_LQ_AVAIL |
243 + BCMA_RES_4314_LOGIC_RET |
244 + BCMA_RES_4314_MEM_SLEEP |
245 + BCMA_RES_4314_MACPHY_RET |
246 + BCMA_RES_4314_WL_CORE_READY;
247 + max_msk = 0x3FFFFFFF;
248 + break;
249 default:
250 bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
251 bus->chipinfo.id);
252 @@ -165,6 +287,7 @@ void bcma_pmu_init(struct bcma_drv_cc *c
253 bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
254 BCMA_CC_PMU_CTL_NOILPONW);
255
256 + bcma_pmu_pll_init(cc);
257 bcma_pmu_resources_init(cc);
258 bcma_pmu_workarounds(cc);
259 }
260 --- a/drivers/bcma/driver_chipcommon_sflash.c
261 +++ b/drivers/bcma/driver_chipcommon_sflash.c
262 @@ -30,7 +30,7 @@ struct bcma_sflash_tbl_e {
263 u16 numblocks;
264 };
265
266 -static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
267 +static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
268 { "M25P20", 0x11, 0x10000, 4, },
269 { "M25P40", 0x12, 0x10000, 8, },
270
271 @@ -41,7 +41,7 @@ static struct bcma_sflash_tbl_e bcma_sfl
272 { 0 },
273 };
274
275 -static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
276 +static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
277 { "SST25WF512", 1, 0x1000, 16, },
278 { "SST25VF512", 0x48, 0x1000, 16, },
279 { "SST25WF010", 2, 0x1000, 32, },
280 @@ -59,7 +59,7 @@ static struct bcma_sflash_tbl_e bcma_sfl
281 { 0 },
282 };
283
284 -static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
285 +static const struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
286 { "AT45DB011", 0xc, 256, 512, },
287 { "AT45DB021", 0x14, 256, 1024, },
288 { "AT45DB041", 0x1c, 256, 2048, },
289 @@ -89,7 +89,7 @@ int bcma_sflash_init(struct bcma_drv_cc
290 {
291 struct bcma_bus *bus = cc->core->bus;
292 struct bcma_sflash *sflash = &cc->sflash;
293 - struct bcma_sflash_tbl_e *e;
294 + const struct bcma_sflash_tbl_e *e;
295 u32 id, id2;
296
297 switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
298 --- a/drivers/bcma/host_pci.c
299 +++ b/drivers/bcma/host_pci.c
300 @@ -188,8 +188,11 @@ static int bcma_host_pci_probe(struct pc
301 pci_write_config_dword(dev, 0x40, val & 0xffff00ff);
302
303 /* SSB needed additional powering up, do we have any AMBA PCI cards? */
304 - if (!pci_is_pcie(dev))
305 - bcma_err(bus, "PCI card detected, report problems.\n");
306 + if (!pci_is_pcie(dev)) {
307 + bcma_err(bus, "PCI card detected, they are not supported.\n");
308 + err = -ENXIO;
309 + goto err_pci_release_regions;
310 + }
311
312 /* Map MMIO */
313 err = -ENOMEM;
314 @@ -269,12 +272,14 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
315
316 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
317 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
318 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) },
319 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) },
320 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
321 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
322 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
323 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
324 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
325 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
326 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
327 { 0, },
328 };
329 --- a/drivers/bcma/main.c
330 +++ b/drivers/bcma/main.c
331 @@ -93,6 +93,25 @@ struct bcma_device *bcma_find_core_unit(
332 return NULL;
333 }
334
335 +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
336 + int timeout)
337 +{
338 + unsigned long deadline = jiffies + timeout;
339 + u32 val;
340 +
341 + do {
342 + val = bcma_read32(core, reg);
343 + if ((val & mask) == value)
344 + return true;
345 + cpu_relax();
346 + udelay(10);
347 + } while (!time_after_eq(jiffies, deadline));
348 +
349 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
350 +
351 + return false;
352 +}
353 +
354 static void bcma_release_core_dev(struct device *dev)
355 {
356 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
357 @@ -218,7 +237,7 @@ int bcma_bus_register(struct bcma_bus *b
358 err = bcma_bus_scan(bus);
359 if (err) {
360 bcma_err(bus, "Failed to scan: %d\n", err);
361 - return -1;
362 + return err;
363 }
364
365 /* Early init CC core */
366 --- a/drivers/bcma/sprom.c
367 +++ b/drivers/bcma/sprom.c
368 @@ -72,12 +72,12 @@ fail:
369 * R/W ops.
370 **************************************************/
371
372 -static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
373 +static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom,
374 + size_t words)
375 {
376 int i;
377 - for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
378 - sprom[i] = bcma_read16(bus->drv_cc.core,
379 - offset + (i * 2));
380 + for (i = 0; i < words; i++)
381 + sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2));
382 }
383
384 /**************************************************
385 @@ -124,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da
386 return t[crc ^ data];
387 }
388
389 -static u8 bcma_sprom_crc(const u16 *sprom)
390 +static u8 bcma_sprom_crc(const u16 *sprom, size_t words)
391 {
392 int word;
393 u8 crc = 0xFF;
394
395 - for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
396 + for (word = 0; word < words - 1; word++) {
397 crc = bcma_crc8(crc, sprom[word] & 0x00FF);
398 crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
399 }
400 - crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
401 + crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF);
402 crc ^= 0xFF;
403
404 return crc;
405 }
406
407 -static int bcma_sprom_check_crc(const u16 *sprom)
408 +static int bcma_sprom_check_crc(const u16 *sprom, size_t words)
409 {
410 u8 crc;
411 u8 expected_crc;
412 u16 tmp;
413
414 - crc = bcma_sprom_crc(sprom);
415 - tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
416 + crc = bcma_sprom_crc(sprom, words);
417 + tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC;
418 expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
419 if (crc != expected_crc)
420 return -EPROTO;
421 @@ -154,21 +154,25 @@ static int bcma_sprom_check_crc(const u1
422 return 0;
423 }
424
425 -static int bcma_sprom_valid(const u16 *sprom)
426 +static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom,
427 + size_t words)
428 {
429 u16 revision;
430 int err;
431
432 - err = bcma_sprom_check_crc(sprom);
433 + err = bcma_sprom_check_crc(sprom, words);
434 if (err)
435 return err;
436
437 - revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
438 - if (revision != 8 && revision != 9) {
439 + revision = sprom[words - 1] & SSB_SPROM_REVISION_REV;
440 + if (revision != 8 && revision != 9 && revision != 10) {
441 pr_err("Unsupported SPROM revision: %d\n", revision);
442 return -ENOENT;
443 }
444
445 + bus->sprom.revision = revision;
446 + bcma_debug(bus, "Found SPROM revision %d\n", revision);
447 +
448 return 0;
449 }
450
451 @@ -208,9 +212,6 @@ static void bcma_sprom_extract_r8(struct
452 BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
453 ARRAY_SIZE(bus->sprom.core_pwr_info));
454
455 - bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
456 - SSB_SPROM_REVISION_REV;
457 -
458 for (i = 0; i < 3; i++) {
459 v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
460 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
461 @@ -502,7 +503,7 @@ static bool bcma_sprom_onchip_available(
462 case BCMA_CHIP_ID_BCM4331:
463 present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
464 break;
465 -
466 + case BCMA_CHIP_ID_BCM43142:
467 case BCMA_CHIP_ID_BCM43224:
468 case BCMA_CHIP_ID_BCM43225:
469 /* for these chips OTP is always available */
470 @@ -550,7 +551,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
471 {
472 u16 offset = BCMA_CC_SPROM;
473 u16 *sprom;
474 - int err = 0;
475 + size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
476 + SSB_SPROMSIZE_WORDS_R10, };
477 + int i, err = 0;
478
479 if (!bus->drv_cc.core)
480 return -EOPNOTSUPP;
481 @@ -579,32 +582,37 @@ int bcma_sprom_get(struct bcma_bus *bus)
482 }
483 }
484
485 - sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
486 - GFP_KERNEL);
487 - if (!sprom)
488 - return -ENOMEM;
489 -
490 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
491 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
492 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
493
494 bcma_debug(bus, "SPROM offset 0x%x\n", offset);
495 - bcma_sprom_read(bus, offset, sprom);
496 + for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
497 + size_t words = sprom_sizes[i];
498 +
499 + sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
500 + if (!sprom)
501 + return -ENOMEM;
502 +
503 + bcma_sprom_read(bus, offset, sprom, words);
504 + err = bcma_sprom_valid(bus, sprom, words);
505 + if (!err)
506 + break;
507 +
508 + kfree(sprom);
509 + }
510
511 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
512 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
513 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
514
515 - err = bcma_sprom_valid(sprom);
516 if (err) {
517 - bcma_warn(bus, "invalid sprom read from the PCIe card, try to use fallback sprom\n");
518 + bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n");
519 err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
520 - goto out;
521 + } else {
522 + bcma_sprom_extract_r8(bus, sprom);
523 + kfree(sprom);
524 }
525
526 - bcma_sprom_extract_r8(bus, sprom);
527 -
528 -out:
529 - kfree(sprom);
530 return err;
531 }
532 --- a/include/linux/bcma/bcma.h
533 +++ b/include/linux/bcma/bcma.h
534 @@ -72,7 +72,19 @@ struct bcma_host_ops {
535 /* Core-ID values. */
536 #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
537 #define BCMA_CORE_4706_CHIPCOMMON 0x500
538 +#define BCMA_CORE_PCIEG2 0x501
539 +#define BCMA_CORE_DMA 0x502
540 +#define BCMA_CORE_SDIO3 0x503
541 +#define BCMA_CORE_USB20 0x504
542 +#define BCMA_CORE_USB30 0x505
543 +#define BCMA_CORE_A9JTAG 0x506
544 +#define BCMA_CORE_DDR23 0x507
545 +#define BCMA_CORE_ROM 0x508
546 +#define BCMA_CORE_NAND 0x509
547 +#define BCMA_CORE_QSPI 0x50A
548 +#define BCMA_CORE_CHIPCOMMON_B 0x50B
549 #define BCMA_CORE_4706_SOC_RAM 0x50E
550 +#define BCMA_CORE_ARMCA9 0x510
551 #define BCMA_CORE_4706_MAC_GBIT 0x52D
552 #define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */
553 #define BCMA_CORE_ALTA 0x534 /* I2S core */
554 @@ -144,6 +156,7 @@ struct bcma_host_ops {
555
556 /* Chip IDs of PCIe devices */
557 #define BCMA_CHIP_ID_BCM4313 0x4313
558 +#define BCMA_CHIP_ID_BCM43142 43142
559 #define BCMA_CHIP_ID_BCM43224 43224
560 #define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
561 #define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
562 @@ -176,6 +189,11 @@ struct bcma_host_ops {
563 #define BCMA_PKG_ID_BCM5357 11
564 #define BCMA_CHIP_ID_BCM53572 53572
565 #define BCMA_PKG_ID_BCM47188 9
566 +#define BCMA_CHIP_ID_BCM4707 53010
567 +#define BCMA_PKG_ID_BCM4707 1
568 +#define BCMA_PKG_ID_BCM4708 2
569 +#define BCMA_PKG_ID_BCM4709 0
570 +#define BCMA_CHIP_ID_BCM53018 53018
571
572 /* Board types (on PCI usually equals to the subsystem dev id) */
573 /* BCM4313 */
574 --- a/include/linux/bcma/bcma_driver_chipcommon.h
575 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
576 @@ -330,6 +330,8 @@
577 #define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
578 #define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
579 #define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
580 +#define BCMA_CC_PMU_STAT_EXT_LPO_AVAIL 0x00000100
581 +#define BCMA_CC_PMU_STAT_WDRESET 0x00000080
582 #define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
583 #define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
584 #define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
585 @@ -355,6 +357,11 @@
586 #define BCMA_CC_REGCTL_DATA 0x065C
587 #define BCMA_CC_PLLCTL_ADDR 0x0660
588 #define BCMA_CC_PLLCTL_DATA 0x0664
589 +#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */
590 +#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */
591 +#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF
592 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_MASK 0x80000000
593 +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT 31
594 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
595 /* NAND flash MLC controller registers (corerev >= 38) */
596 #define BCMA_CC_NAND_REVISION 0x0C00
597 @@ -435,6 +442,23 @@
598 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007
599 #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0
600
601 +/* PMU rev 15 */
602 +#define BCMA_CC_PMU15_PLL_PLLCTL0 0
603 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_MASK 0x00000003
604 +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_SHIFT 0
605 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK 0x003FFFFC
606 +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT 2
607 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_MASK 0x00C00000
608 +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_SHIFT 22
609 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_MASK 0x07000000
610 +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_SHIFT 24
611 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_MASK 0x38000000
612 +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_SHIFT 27
613 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_MASK 0x40000000
614 +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_SHIFT 30
615 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_MASK 0x80000000
616 +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_SHIFT 31
617 +
618 /* ALP clock on pre-PMU chips */
619 #define BCMA_CC_PMU_ALP_CLOCK 20000000
620 /* HT clock for systems with PMU-enabled chipcommon */
621 @@ -507,6 +531,37 @@
622 #define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
623 #define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
624
625 +#define BCMA_RES_4314_LPLDO_PU BIT(0)
626 +#define BCMA_RES_4314_PMU_SLEEP_DIS BIT(1)
627 +#define BCMA_RES_4314_PMU_BG_PU BIT(2)
628 +#define BCMA_RES_4314_CBUCK_LPOM_PU BIT(3)
629 +#define BCMA_RES_4314_CBUCK_PFM_PU BIT(4)
630 +#define BCMA_RES_4314_CLDO_PU BIT(5)
631 +#define BCMA_RES_4314_LPLDO2_LVM BIT(6)
632 +#define BCMA_RES_4314_WL_PMU_PU BIT(7)
633 +#define BCMA_RES_4314_LNLDO_PU BIT(8)
634 +#define BCMA_RES_4314_LDO3P3_PU BIT(9)
635 +#define BCMA_RES_4314_OTP_PU BIT(10)
636 +#define BCMA_RES_4314_XTAL_PU BIT(11)
637 +#define BCMA_RES_4314_WL_PWRSW_PU BIT(12)
638 +#define BCMA_RES_4314_LQ_AVAIL BIT(13)
639 +#define BCMA_RES_4314_LOGIC_RET BIT(14)
640 +#define BCMA_RES_4314_MEM_SLEEP BIT(15)
641 +#define BCMA_RES_4314_MACPHY_RET BIT(16)
642 +#define BCMA_RES_4314_WL_CORE_READY BIT(17)
643 +#define BCMA_RES_4314_ILP_REQ BIT(18)
644 +#define BCMA_RES_4314_ALP_AVAIL BIT(19)
645 +#define BCMA_RES_4314_MISC_PWRSW_PU BIT(20)
646 +#define BCMA_RES_4314_SYNTH_PWRSW_PU BIT(21)
647 +#define BCMA_RES_4314_RX_PWRSW_PU BIT(22)
648 +#define BCMA_RES_4314_RADIO_PU BIT(23)
649 +#define BCMA_RES_4314_VCO_LDO_PU BIT(24)
650 +#define BCMA_RES_4314_AFE_LDO_PU BIT(25)
651 +#define BCMA_RES_4314_RX_LDO_PU BIT(26)
652 +#define BCMA_RES_4314_TX_LDO_PU BIT(27)
653 +#define BCMA_RES_4314_HT_AVAIL BIT(28)
654 +#define BCMA_RES_4314_MACPHY_CLK_AVAIL BIT(29)
655 +
656 /* Data for the PMU, if available.
657 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
658 */
659 --- a/drivers/bcma/driver_pci.c
660 +++ b/drivers/bcma/driver_pci.c
661 @@ -31,7 +31,7 @@ static void bcma_pcie_write(struct bcma_
662 pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
663 }
664
665 -static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
666 +static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u16 phy)
667 {
668 u32 v;
669 int i;
670 @@ -55,7 +55,7 @@ static void bcma_pcie_mdio_set_phy(struc
671 }
672 }
673
674 -static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
675 +static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address)
676 {
677 int max_retries = 10;
678 u16 ret = 0;
679 @@ -98,7 +98,7 @@ static u16 bcma_pcie_mdio_read(struct bc
680 return ret;
681 }
682
683 -static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
684 +static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device,
685 u8 address, u16 data)
686 {
687 int max_retries = 10;
688 @@ -137,6 +137,13 @@ static void bcma_pcie_mdio_write(struct
689 pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
690 }
691
692 +static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device,
693 + u8 address, u16 data)
694 +{
695 + bcma_pcie_mdio_write(pc, device, address, data);
696 + return bcma_pcie_mdio_read(pc, device, address);
697 +}
698 +
699 /**************************************************
700 * Workarounds.
701 **************************************************/
702 @@ -229,6 +236,32 @@ void bcma_core_pci_init(struct bcma_drv_
703 bcma_core_pci_clientmode_init(pc);
704 }
705
706 +void bcma_core_pci_power_save(struct bcma_bus *bus, bool up)
707 +{
708 + struct bcma_drv_pci *pc;
709 + u16 data;
710 +
711 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
712 + return;
713 +
714 + pc = &bus->drv_pci[0];
715 +
716 + if (pc->core->id.rev >= 15 && pc->core->id.rev <= 20) {
717 + data = up ? 0x74 : 0x7C;
718 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
719 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7F64);
720 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
721 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
722 + } else if (pc->core->id.rev >= 21 && pc->core->id.rev <= 22) {
723 + data = up ? 0x75 : 0x7D;
724 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
725 + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7E65);
726 + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
727 + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
728 + }
729 +}
730 +EXPORT_SYMBOL_GPL(bcma_core_pci_power_save);
731 +
732 int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
733 bool enable)
734 {
735 @@ -262,7 +295,7 @@ out:
736 }
737 EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
738
739 -void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
740 +static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
741 {
742 u32 w;
743
744 @@ -274,4 +307,29 @@ void bcma_core_pci_extend_L1timer(struct
745 bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
746 bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
747 }
748 -EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
749 +
750 +void bcma_core_pci_up(struct bcma_bus *bus)
751 +{
752 + struct bcma_drv_pci *pc;
753 +
754 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
755 + return;
756 +
757 + pc = &bus->drv_pci[0];
758 +
759 + bcma_core_pci_extend_L1timer(pc, true);
760 +}
761 +EXPORT_SYMBOL_GPL(bcma_core_pci_up);
762 +
763 +void bcma_core_pci_down(struct bcma_bus *bus)
764 +{
765 + struct bcma_drv_pci *pc;
766 +
767 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
768 + return;
769 +
770 + pc = &bus->drv_pci[0];
771 +
772 + bcma_core_pci_extend_L1timer(pc, false);
773 +}
774 +EXPORT_SYMBOL_GPL(bcma_core_pci_down);
775 --- a/drivers/bcma/driver_pci_host.c
776 +++ b/drivers/bcma/driver_pci_host.c
777 @@ -581,6 +581,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI
778 int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
779 {
780 struct bcma_drv_pci_host *pc_host;
781 + int readrq;
782
783 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
784 /* This is not a device on the PCI-core bridge. */
785 @@ -595,6 +596,11 @@ int bcma_core_pci_plat_dev_init(struct p
786 dev->irq = bcma_core_irq(pc_host->pdev->core);
787 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
788
789 + readrq = pcie_get_readrq(dev);
790 + if (readrq > 128) {
791 + pr_info("change PCIe max read request size from %i to 128\n", readrq);
792 + pcie_set_readrq(dev, 128);
793 + }
794 return 0;
795 }
796 EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
797 --- a/drivers/bcma/scan.c
798 +++ b/drivers/bcma/scan.c
799 @@ -32,6 +32,18 @@ static const struct bcma_device_id_name
800 { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
801 { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
802 { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
803 + { BCMA_CORE_PCIEG2, "PCIe Gen 2" },
804 + { BCMA_CORE_DMA, "DMA" },
805 + { BCMA_CORE_SDIO3, "SDIO3" },
806 + { BCMA_CORE_USB20, "USB 2.0" },
807 + { BCMA_CORE_USB30, "USB 3.0" },
808 + { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" },
809 + { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" },
810 + { BCMA_CORE_ROM, "ROM" },
811 + { BCMA_CORE_NAND, "NAND flash controller" },
812 + { BCMA_CORE_QSPI, "SPI flash controller" },
813 + { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" },
814 + { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" },
815 { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
816 { BCMA_CORE_ALTA, "ALTA (I2S)" },
817 { BCMA_CORE_INVALID, "Invalid" },
818 @@ -201,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct
819 return ent;
820 }
821
822 -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
823 +static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
824 u32 type, u8 port)
825 {
826 u32 addrl, addrh, sizel, sizeh = 0;
827 @@ -213,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc
828 ((ent & SCAN_ADDR_TYPE) != type) ||
829 (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
830 bcma_erom_push_ent(eromptr);
831 - return -EINVAL;
832 + return (u32)-EINVAL;
833 }
834
835 addrl = ent & SCAN_ADDR_ADDR;
836 @@ -257,11 +269,13 @@ static struct bcma_device *bcma_find_cor
837 return NULL;
838 }
839
840 +#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
841 +
842 static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
843 struct bcma_device_id *match, int core_num,
844 struct bcma_device *core)
845 {
846 - s32 tmp;
847 + u32 tmp;
848 u8 i, j;
849 s32 cia, cib;
850 u8 ports[2], wrappers[2];
851 @@ -339,11 +353,11 @@ static int bcma_get_next_core(struct bcm
852 * the main register space for the core
853 */
854 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
855 - if (tmp <= 0) {
856 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
857 /* Try again to see if it is a bridge */
858 tmp = bcma_erom_get_addr_desc(bus, eromptr,
859 SCAN_ADDR_TYPE_BRIDGE, 0);
860 - if (tmp <= 0) {
861 + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
862 return -EILSEQ;
863 } else {
864 bcma_info(bus, "Bridge found\n");
865 @@ -357,7 +371,7 @@ static int bcma_get_next_core(struct bcm
866 for (j = 0; ; j++) {
867 tmp = bcma_erom_get_addr_desc(bus, eromptr,
868 SCAN_ADDR_TYPE_SLAVE, i);
869 - if (tmp < 0) {
870 + if (IS_ERR_VALUE_U32(tmp)) {
871 /* no more entries for port _i_ */
872 /* pr_debug("erom: slave port %d "
873 * "has %d descriptors\n", i, j); */
874 @@ -374,7 +388,7 @@ static int bcma_get_next_core(struct bcm
875 for (j = 0; ; j++) {
876 tmp = bcma_erom_get_addr_desc(bus, eromptr,
877 SCAN_ADDR_TYPE_MWRAP, i);
878 - if (tmp < 0) {
879 + if (IS_ERR_VALUE_U32(tmp)) {
880 /* no more entries for port _i_ */
881 /* pr_debug("erom: master wrapper %d "
882 * "has %d descriptors\n", i, j); */
883 @@ -392,7 +406,7 @@ static int bcma_get_next_core(struct bcm
884 for (j = 0; ; j++) {
885 tmp = bcma_erom_get_addr_desc(bus, eromptr,
886 SCAN_ADDR_TYPE_SWRAP, i + hack);
887 - if (tmp < 0) {
888 + if (IS_ERR_VALUE_U32(tmp)) {
889 /* no more entries for port _i_ */
890 /* pr_debug("erom: master wrapper %d "
891 * has %d descriptors\n", i, j); */
892 --- a/include/linux/bcma/bcma_driver_pci.h
893 +++ b/include/linux/bcma/bcma_driver_pci.h
894 @@ -181,10 +181,31 @@ struct pci_dev;
895
896 #define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8
897
898 +#define BCMA_CORE_PCI_
899 +
900 +/* MDIO devices (SERDES modules) */
901 +#define BCMA_CORE_PCI_MDIO_IEEE0 0x000
902 +#define BCMA_CORE_PCI_MDIO_IEEE1 0x001
903 +#define BCMA_CORE_PCI_MDIO_BLK0 0x800
904 +#define BCMA_CORE_PCI_MDIO_BLK1 0x801
905 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT0 0x16
906 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT1 0x17
907 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT2 0x18
908 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT3 0x19
909 +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT4 0x1A
910 +#define BCMA_CORE_PCI_MDIO_BLK2 0x802
911 +#define BCMA_CORE_PCI_MDIO_BLK3 0x803
912 +#define BCMA_CORE_PCI_MDIO_BLK4 0x804
913 +#define BCMA_CORE_PCI_MDIO_TXPLL 0x808 /* TXPLL register block idx */
914 +#define BCMA_CORE_PCI_MDIO_TXCTRL0 0x820
915 +#define BCMA_CORE_PCI_MDIO_SERDESID 0x831
916 +#define BCMA_CORE_PCI_MDIO_RXCTRL0 0x840
917 +
918 /* PCIE Root Capability Register bits (Host mode only) */
919 #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
920
921 struct bcma_drv_pci;
922 +struct bcma_bus;
923
924 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
925 struct bcma_drv_pci_host {
926 @@ -219,7 +240,9 @@ struct bcma_drv_pci {
927 extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
928 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
929 struct bcma_device *core, bool enable);
930 -extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend);
931 +extern void bcma_core_pci_up(struct bcma_bus *bus);
932 +extern void bcma_core_pci_down(struct bcma_bus *bus);
933 +extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up);
934
935 extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
936 extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
937 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
938 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
939 @@ -679,27 +679,6 @@ bool ai_clkctl_cc(struct si_pub *sih, en
940 return mode == BCMA_CLKMODE_FAST;
941 }
942
943 -void ai_pci_up(struct si_pub *sih)
944 -{
945 - struct si_info *sii;
946 -
947 - sii = container_of(sih, struct si_info, pub);
948 -
949 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
950 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], true);
951 -}
952 -
953 -/* Unconfigure and/or apply various WARs when going down */
954 -void ai_pci_down(struct si_pub *sih)
955 -{
956 - struct si_info *sii;
957 -
958 - sii = container_of(sih, struct si_info, pub);
959 -
960 - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
961 - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], false);
962 -}
963 -
964 /* Enable BT-COEX & Ex-PA for 4313 */
965 void ai_epa_4313war(struct si_pub *sih)
966 {
967 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
968 +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
969 @@ -183,9 +183,6 @@ extern u16 ai_clkctl_fast_pwrup_delay(st
970 extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode);
971 extern bool ai_deviceremoved(struct si_pub *sih);
972
973 -extern void ai_pci_down(struct si_pub *sih);
974 -extern void ai_pci_up(struct si_pub *sih);
975 -
976 /* Enable Ex-PA for 4313 */
977 extern void ai_epa_4313war(struct si_pub *sih);
978
979 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
980 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
981 @@ -4667,7 +4667,7 @@ static int brcms_b_attach(struct brcms_c
982 brcms_c_coredisable(wlc_hw);
983
984 /* Match driver "down" state */
985 - ai_pci_down(wlc_hw->sih);
986 + bcma_core_pci_down(wlc_hw->d11core->bus);
987
988 /* turn off pll and xtal to match driver "down" state */
989 brcms_b_xtal(wlc_hw, OFF);
990 @@ -5010,12 +5010,12 @@ static int brcms_b_up_prep(struct brcms_
991 */
992 if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
993 /* put SB PCI in down state again */
994 - ai_pci_down(wlc_hw->sih);
995 + bcma_core_pci_down(wlc_hw->d11core->bus);
996 brcms_b_xtal(wlc_hw, OFF);
997 return -ENOMEDIUM;
998 }
999
1000 - ai_pci_up(wlc_hw->sih);
1001 + bcma_core_pci_up(wlc_hw->d11core->bus);
1002
1003 /* reset the d11 core */
1004 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
1005 @@ -5212,7 +5212,7 @@ static int brcms_b_down_finish(struct br
1006
1007 /* turn off primary xtal and pll */
1008 if (!wlc_hw->noreset) {
1009 - ai_pci_down(wlc_hw->sih);
1010 + bcma_core_pci_down(wlc_hw->d11core->bus);
1011 brcms_b_xtal(wlc_hw, OFF);
1012 }
1013 }