aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArend van Spriel <arend@broadcom.com>2011-12-08 18:06:59 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-12-13 15:33:17 -0500
commitb0327ffa8cfe69ce2d380200c2097b86c6b3efd9 (patch)
tree9b8eadd733c0ba2bb891c4cd099c4f1089e03b34 /drivers
parenta8779e4a8e7f0f90ae169393cd72105134ce7c7b (diff)
brcm80211: smac: use bcma core access functions in nicpci.c
Code in nicpci.c now uses the PCI(E) core as provided by the BCMA bus driver to configure that core. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Reviewed-by: Alwin Beukers <alwin@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Franky Lin <frankyl@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/aiutils.c11
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/nicpci.c179
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/nicpci.h11
3 files changed, 90 insertions, 111 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index a68f24a868f9..8d3829a73190 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -633,8 +633,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx)
633 633
634 /* fixup necessary chip/core configurations */ 634 /* fixup necessary chip/core configurations */
635 if (!sii->pch) { 635 if (!sii->pch) {
636 sii->pch = pcicore_init(&sii->pub, sii->pcibus, 636 sii->pch = pcicore_init(&sii->pub, sii->icbus->drv_pci.core);
637 sii->curmap + PCI_16KB0_PCIREGS_OFFSET);
638 if (sii->pch == NULL) 637 if (sii->pch == NULL)
639 return false; 638 return false;
640 } 639 }
@@ -1385,7 +1384,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask)
1385 } 1384 }
1386 1385
1387 if (PCI(sih)) { 1386 if (PCI(sih)) {
1388 pcicore_pci_setup(sii->pch, regs); 1387 pcicore_pci_setup(sii->pch);
1389 1388
1390 /* switch back to previous core */ 1389 /* switch back to previous core */
1391 ai_setcoreidx(sih, idx); 1390 ai_setcoreidx(sih, idx);
@@ -1408,11 +1407,7 @@ int ai_pci_fixcfg(struct si_pub *sih)
1408 1407
1409 /* check 'pi' is correct and fix it if not */ 1408 /* check 'pi' is correct and fix it if not */
1410 regs = ai_setcore(&sii->pub, ai_get_buscoretype(sih), 0); 1409 regs = ai_setcore(&sii->pub, ai_get_buscoretype(sih), 0);
1411 if (ai_get_buscoretype(sih) == PCIE_CORE_ID) 1410 pcicore_fixcfg(sii->pch);
1412 pcicore_fixcfg_pcie(sii->pch,
1413 (struct sbpcieregs __iomem *)regs);
1414 else if (ai_get_buscoretype(sih) == PCI_CORE_ID)
1415 pcicore_fixcfg_pci(sii->pch, (struct sbpciregs __iomem *)regs);
1416 1411
1417 /* restore the original index */ 1412 /* restore the original index */
1418 ai_setcoreidx(&sii->pub, origidx); 1413 ai_setcoreidx(&sii->pub, origidx);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c
index 6c3a9f9d5207..a4330416b43b 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c
@@ -139,6 +139,9 @@
139#define SRSH_PI_MASK 0xf000 /* bit 15:12 */ 139#define SRSH_PI_MASK 0xf000 /* bit 15:12 */
140#define SRSH_PI_SHIFT 12 /* bit 15:12 */ 140#define SRSH_PI_SHIFT 12 /* bit 15:12 */
141 141
142#define PCIREGOFFS(field) offsetof(struct sbpciregs, field)
143#define PCIEREGOFFS(field) offsetof(struct sbpcieregs, field)
144
142/* Sonics side: PCI core and host control registers */ 145/* Sonics side: PCI core and host control registers */
143struct sbpciregs { 146struct sbpciregs {
144 u32 control; /* PCI control */ 147 u32 control; /* PCI control */
@@ -205,11 +208,7 @@ struct sbpcieregs {
205}; 208};
206 209
207struct pcicore_info { 210struct pcicore_info {
208 union { 211 struct bcma_device *core;
209 struct sbpcieregs __iomem *pcieregs;
210 struct sbpciregs __iomem *pciregs;
211 } regs; /* Memory mapped register to the core */
212
213 struct si_pub *sih; /* System interconnect handle */ 212 struct si_pub *sih; /* System interconnect handle */
214 struct pci_dev *dev; 213 struct pci_dev *dev;
215 u8 pciecap_lcreg_offset;/* PCIE capability LCreg offset 214 u8 pciecap_lcreg_offset;/* PCIE capability LCreg offset
@@ -238,8 +237,7 @@ static void pr28829_delay(void)
238/* Initialize the PCI core. 237/* Initialize the PCI core.
239 * It's caller's responsibility to make sure that this is done only once 238 * It's caller's responsibility to make sure that this is done only once
240 */ 239 */
241struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, 240struct pcicore_info *pcicore_init(struct si_pub *sih, struct bcma_device *core)
242 void __iomem *regs)
243{ 241{
244 struct pcicore_info *pi; 242 struct pcicore_info *pi;
245 243
@@ -249,17 +247,15 @@ struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev,
249 return NULL; 247 return NULL;
250 248
251 pi->sih = sih; 249 pi->sih = sih;
252 pi->dev = pdev; 250 pi->dev = core->bus->host_pci;
251 pi->core = core;
253 252
254 if (ai_get_buscoretype(sih) == PCIE_CORE_ID) { 253 if (core->id.id == PCIE_CORE_ID) {
255 u8 cap_ptr; 254 u8 cap_ptr;
256 pi->regs.pcieregs = regs;
257 cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_EXP, 255 cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_EXP,
258 NULL, NULL); 256 NULL, NULL);
259 pi->pciecap_lcreg_offset = cap_ptr + PCIE_CAP_LINKCTRL_OFFSET; 257 pi->pciecap_lcreg_offset = cap_ptr + PCIE_CAP_LINKCTRL_OFFSET;
260 } else 258 }
261 pi->regs.pciregs = regs;
262
263 return pi; 259 return pi;
264} 260}
265 261
@@ -334,37 +330,37 @@ end:
334 330
335/* ***** Register Access API */ 331/* ***** Register Access API */
336static uint 332static uint
337pcie_readreg(struct sbpcieregs __iomem *pcieregs, uint addrtype, uint offset) 333pcie_readreg(struct bcma_device *core, uint addrtype, uint offset)
338{ 334{
339 uint retval = 0xFFFFFFFF; 335 uint retval = 0xFFFFFFFF;
340 336
341 switch (addrtype) { 337 switch (addrtype) {
342 case PCIE_CONFIGREGS: 338 case PCIE_CONFIGREGS:
343 W_REG(&pcieregs->configaddr, offset); 339 bcma_write32(core, PCIEREGOFFS(configaddr), offset);
344 (void)R_REG((&pcieregs->configaddr)); 340 (void)bcma_read32(core, PCIEREGOFFS(configaddr));
345 retval = R_REG(&pcieregs->configdata); 341 retval = bcma_read32(core, PCIEREGOFFS(configdata));
346 break; 342 break;
347 case PCIE_PCIEREGS: 343 case PCIE_PCIEREGS:
348 W_REG(&pcieregs->pcieindaddr, offset); 344 bcma_write32(core, PCIEREGOFFS(pcieindaddr), offset);
349 (void)R_REG(&pcieregs->pcieindaddr); 345 (void)bcma_read32(core, PCIEREGOFFS(pcieindaddr));
350 retval = R_REG(&pcieregs->pcieinddata); 346 retval = bcma_read32(core, PCIEREGOFFS(pcieinddata));
351 break; 347 break;
352 } 348 }
353 349
354 return retval; 350 return retval;
355} 351}
356 352
357static uint pcie_writereg(struct sbpcieregs __iomem *pcieregs, uint addrtype, 353static uint pcie_writereg(struct bcma_device *core, uint addrtype,
358 uint offset, uint val) 354 uint offset, uint val)
359{ 355{
360 switch (addrtype) { 356 switch (addrtype) {
361 case PCIE_CONFIGREGS: 357 case PCIE_CONFIGREGS:
362 W_REG((&pcieregs->configaddr), offset); 358 bcma_write32(core, PCIEREGOFFS(configaddr), offset);
363 W_REG((&pcieregs->configdata), val); 359 bcma_write32(core, PCIEREGOFFS(configdata), val);
364 break; 360 break;
365 case PCIE_PCIEREGS: 361 case PCIE_PCIEREGS:
366 W_REG((&pcieregs->pcieindaddr), offset); 362 bcma_write32(core, PCIEREGOFFS(pcieindaddr), offset);
367 W_REG((&pcieregs->pcieinddata), val); 363 bcma_write32(core, PCIEREGOFFS(pcieinddata), val);
368 break; 364 break;
369 default: 365 default:
370 break; 366 break;
@@ -374,7 +370,6 @@ static uint pcie_writereg(struct sbpcieregs __iomem *pcieregs, uint addrtype,
374 370
375static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) 371static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk)
376{ 372{
377 struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs;
378 uint mdiodata, i = 0; 373 uint mdiodata, i = 0;
379 uint pcie_serdes_spinwait = 200; 374 uint pcie_serdes_spinwait = 200;
380 375
@@ -382,12 +377,13 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk)
382 (MDIODATA_DEV_ADDR << MDIODATA_DEVADDR_SHF) | 377 (MDIODATA_DEV_ADDR << MDIODATA_DEVADDR_SHF) |
383 (MDIODATA_BLK_ADDR << MDIODATA_REGADDR_SHF) | 378 (MDIODATA_BLK_ADDR << MDIODATA_REGADDR_SHF) |
384 (blk << 4)); 379 (blk << 4));
385 W_REG(&pcieregs->mdiodata, mdiodata); 380 bcma_write32(pi->core, PCIEREGOFFS(mdiodata), mdiodata);
386 381
387 pr28829_delay(); 382 pr28829_delay();
388 /* retry till the transaction is complete */ 383 /* retry till the transaction is complete */
389 while (i < pcie_serdes_spinwait) { 384 while (i < pcie_serdes_spinwait) {
390 if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) 385 if (bcma_read32(pi->core, PCIEREGOFFS(mdiocontrol)) &
386 MDIOCTL_ACCESS_DONE)
391 break; 387 break;
392 388
393 udelay(1000); 389 udelay(1000);
@@ -404,13 +400,13 @@ static int
404pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, 400pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
405 uint *val) 401 uint *val)
406{ 402{
407 struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs;
408 uint mdiodata; 403 uint mdiodata;
409 uint i = 0; 404 uint i = 0;
410 uint pcie_serdes_spinwait = 10; 405 uint pcie_serdes_spinwait = 10;
411 406
412 /* enable mdio access to SERDES */ 407 /* enable mdio access to SERDES */
413 W_REG(&pcieregs->mdiocontrol, MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); 408 bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol),
409 MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL);
414 410
415 if (pi->sih->buscorerev >= 10) { 411 if (pi->sih->buscorerev >= 10) {
416 /* new serdes is slower in rw, 412 /* new serdes is slower in rw,
@@ -432,20 +428,22 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
432 mdiodata |= (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA | 428 mdiodata |= (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA |
433 *val); 429 *val);
434 430
435 W_REG(&pcieregs->mdiodata, mdiodata); 431 bcma_write32(pi->core, PCIEREGOFFS(mdiodata), mdiodata);
436 432
437 pr28829_delay(); 433 pr28829_delay();
438 434
439 /* retry till the transaction is complete */ 435 /* retry till the transaction is complete */
440 while (i < pcie_serdes_spinwait) { 436 while (i < pcie_serdes_spinwait) {
441 if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) { 437 if (bcma_read32(pi->core, PCIEREGOFFS(mdiocontrol)) &
438 MDIOCTL_ACCESS_DONE) {
442 if (!write) { 439 if (!write) {
443 pr28829_delay(); 440 pr28829_delay();
444 *val = (R_REG(&pcieregs->mdiodata) & 441 *val = (bcma_read32(pi->core,
442 PCIEREGOFFS(mdiodata)) &
445 MDIODATA_MASK); 443 MDIODATA_MASK);
446 } 444 }
447 /* Disable mdio access to SERDES */ 445 /* Disable mdio access to SERDES */
448 W_REG(&pcieregs->mdiocontrol, 0); 446 bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), 0);
449 return 0; 447 return 0;
450 } 448 }
451 udelay(1000); 449 udelay(1000);
@@ -453,7 +451,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
453 } 451 }
454 452
455 /* Timed out. Disable mdio access to SERDES. */ 453 /* Timed out. Disable mdio access to SERDES. */
456 W_REG(&pcieregs->mdiocontrol, 0); 454 bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), 0);
457 return 1; 455 return 1;
458} 456}
459 457
@@ -502,19 +500,18 @@ static void pcie_extendL1timer(struct pcicore_info *pi, bool extend)
502{ 500{
503 u32 w; 501 u32 w;
504 struct si_pub *sih = pi->sih; 502 struct si_pub *sih = pi->sih;
505 struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs;
506 503
507 if (ai_get_buscoretype(sih) != PCIE_CORE_ID || 504 if (ai_get_buscoretype(sih) != PCIE_CORE_ID ||
508 ai_get_buscorerev(sih) < 7) 505 ai_get_buscorerev(sih) < 7)
509 return; 506 return;
510 507
511 w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); 508 w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG);
512 if (extend) 509 if (extend)
513 w |= PCIE_ASPMTIMER_EXTEND; 510 w |= PCIE_ASPMTIMER_EXTEND;
514 else 511 else
515 w &= ~PCIE_ASPMTIMER_EXTEND; 512 w &= ~PCIE_ASPMTIMER_EXTEND;
516 pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); 513 pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w);
517 w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); 514 w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG);
518} 515}
519 516
520/* centralized clkreq control policy */ 517/* centralized clkreq control policy */
@@ -565,7 +562,7 @@ static void pcie_war_polarity(struct pcicore_info *pi)
565 if (pi->pcie_polarity != 0) 562 if (pi->pcie_polarity != 0)
566 return; 563 return;
567 564
568 w = pcie_readreg(pi->regs.pcieregs, PCIE_PCIEREGS, PCIE_PLP_STATUSREG); 565 w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_PLP_STATUSREG);
569 566
570 /* Detect the current polarity at attach and force that polarity and 567 /* Detect the current polarity at attach and force that polarity and
571 * disable changing the polarity 568 * disable changing the polarity
@@ -584,18 +581,15 @@ static void pcie_war_polarity(struct pcicore_info *pi)
584 */ 581 */
585static void pcie_war_aspm_clkreq(struct pcicore_info *pi) 582static void pcie_war_aspm_clkreq(struct pcicore_info *pi)
586{ 583{
587 struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs;
588 struct si_pub *sih = pi->sih; 584 struct si_pub *sih = pi->sih;
589 u16 val16; 585 u16 val16;
590 u16 __iomem *reg16;
591 u32 w; 586 u32 w;
592 587
593 if (!PCIE_ASPM(sih)) 588 if (!PCIE_ASPM(sih))
594 return; 589 return;
595 590
596 /* bypass this on QT or VSIM */ 591 /* bypass this on QT or VSIM */
597 reg16 = &pcieregs->sprom[SRSH_ASPM_OFFSET]; 592 val16 = bcma_read16(pi->core, PCIEREGOFFS(sprom[SRSH_ASPM_OFFSET]));
598 val16 = R_REG(reg16);
599 593
600 val16 &= ~SRSH_ASPM_ENB; 594 val16 &= ~SRSH_ASPM_ENB;
601 if (pi->pcie_war_aspm_ovr == PCIE_ASPM_ENAB) 595 if (pi->pcie_war_aspm_ovr == PCIE_ASPM_ENAB)
@@ -605,15 +599,15 @@ static void pcie_war_aspm_clkreq(struct pcicore_info *pi)
605 else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L0s_ENAB) 599 else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L0s_ENAB)
606 val16 |= SRSH_ASPM_L0s_ENB; 600 val16 |= SRSH_ASPM_L0s_ENB;
607 601
608 W_REG(reg16, val16); 602 bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_ASPM_OFFSET]), val16);
609 603
610 pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w); 604 pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w);
611 w &= ~PCIE_ASPM_ENAB; 605 w &= ~PCIE_ASPM_ENAB;
612 w |= pi->pcie_war_aspm_ovr; 606 w |= pi->pcie_war_aspm_ovr;
613 pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w); 607 pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w);
614 608
615 reg16 = &pcieregs->sprom[SRSH_CLKREQ_OFFSET_REV5]; 609 val16 = bcma_read16(pi->core,
616 val16 = R_REG(reg16); 610 PCIEREGOFFS(sprom[SRSH_CLKREQ_OFFSET_REV5]));
617 611
618 if (pi->pcie_war_aspm_ovr != PCIE_ASPM_DISAB) { 612 if (pi->pcie_war_aspm_ovr != PCIE_ASPM_DISAB) {
619 val16 |= SRSH_CLKREQ_ENB; 613 val16 |= SRSH_CLKREQ_ENB;
@@ -621,7 +615,8 @@ static void pcie_war_aspm_clkreq(struct pcicore_info *pi)
621 } else 615 } else
622 val16 &= ~SRSH_CLKREQ_ENB; 616 val16 &= ~SRSH_CLKREQ_ENB;
623 617
624 W_REG(reg16, val16); 618 bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_CLKREQ_OFFSET_REV5]),
619 val16);
625} 620}
626 621
627/* Apply the polarity determined at the start */ 622/* Apply the polarity determined at the start */
@@ -645,16 +640,15 @@ static void pcie_war_serdes(struct pcicore_info *pi)
645/* Needs to happen when coming out of 'standby'/'hibernate' */ 640/* Needs to happen when coming out of 'standby'/'hibernate' */
646static void pcie_misc_config_fixup(struct pcicore_info *pi) 641static void pcie_misc_config_fixup(struct pcicore_info *pi)
647{ 642{
648 struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs;
649 u16 val16; 643 u16 val16;
650 u16 __iomem *reg16;
651 644
652 reg16 = &pcieregs->sprom[SRSH_PCIE_MISC_CONFIG]; 645 val16 = bcma_read16(pi->core,
653 val16 = R_REG(reg16); 646 PCIEREGOFFS(sprom[SRSH_PCIE_MISC_CONFIG]));
654 647
655 if ((val16 & SRSH_L23READY_EXIT_NOPERST) == 0) { 648 if ((val16 & SRSH_L23READY_EXIT_NOPERST) == 0) {
656 val16 |= SRSH_L23READY_EXIT_NOPERST; 649 val16 |= SRSH_L23READY_EXIT_NOPERST;
657 W_REG(reg16, val16); 650 bcma_write16(pi->core,
651 PCIEREGOFFS(sprom[SRSH_PCIE_MISC_CONFIG]), val16);
658 } 652 }
659} 653}
660 654
@@ -662,37 +656,32 @@ static void pcie_misc_config_fixup(struct pcicore_info *pi)
662/* Needs to happen when coming out of 'standby'/'hibernate' */ 656/* Needs to happen when coming out of 'standby'/'hibernate' */
663static void pcie_war_noplldown(struct pcicore_info *pi) 657static void pcie_war_noplldown(struct pcicore_info *pi)
664{ 658{
665 struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs;
666 u16 __iomem *reg16;
667
668 /* turn off serdes PLL down */ 659 /* turn off serdes PLL down */
669 ai_cc_reg(pi->sih, offsetof(struct chipcregs, chipcontrol), 660 ai_cc_reg(pi->sih, offsetof(struct chipcregs, chipcontrol),
670 CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN); 661 CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN);
671 662
672 /* clear srom shadow backdoor */ 663 /* clear srom shadow backdoor */
673 reg16 = &pcieregs->sprom[SRSH_BD_OFFSET]; 664 bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_BD_OFFSET]), 0);
674 W_REG(reg16, 0);
675} 665}
676 666
677/* Needs to happen when coming out of 'standby'/'hibernate' */ 667/* Needs to happen when coming out of 'standby'/'hibernate' */
678static void pcie_war_pci_setup(struct pcicore_info *pi) 668static void pcie_war_pci_setup(struct pcicore_info *pi)
679{ 669{
680 struct si_pub *sih = pi->sih; 670 struct si_pub *sih = pi->sih;
681 struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs;
682 u32 w; 671 u32 w;
683 672
684 if (ai_get_buscorerev(sih) == 0 || ai_get_buscorerev(sih) == 1) { 673 if (ai_get_buscorerev(sih) == 0 || ai_get_buscorerev(sih) == 1) {
685 w = pcie_readreg(pcieregs, PCIE_PCIEREGS, 674 w = pcie_readreg(pi->core, PCIE_PCIEREGS,
686 PCIE_TLP_WORKAROUNDSREG); 675 PCIE_TLP_WORKAROUNDSREG);
687 w |= 0x8; 676 w |= 0x8;
688 pcie_writereg(pcieregs, PCIE_PCIEREGS, 677 pcie_writereg(pi->core, PCIE_PCIEREGS,
689 PCIE_TLP_WORKAROUNDSREG, w); 678 PCIE_TLP_WORKAROUNDSREG, w);
690 } 679 }
691 680
692 if (ai_get_buscorerev(sih) == 1) { 681 if (ai_get_buscorerev(sih) == 1) {
693 w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG); 682 w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_LCREG);
694 w |= 0x40; 683 w |= 0x40;
695 pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w); 684 pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w);
696 } 685 }
697 686
698 if (ai_get_buscorerev(sih) == 0) { 687 if (ai_get_buscorerev(sih) == 0) {
@@ -701,11 +690,11 @@ static void pcie_war_pci_setup(struct pcicore_info *pi)
701 pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466); 690 pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466);
702 } else if (PCIE_ASPM(sih)) { 691 } else if (PCIE_ASPM(sih)) {
703 /* Change the L1 threshold for better performance */ 692 /* Change the L1 threshold for better performance */
704 w = pcie_readreg(pcieregs, PCIE_PCIEREGS, 693 w = pcie_readreg(pi->core, PCIE_PCIEREGS,
705 PCIE_DLLP_PMTHRESHREG); 694 PCIE_DLLP_PMTHRESHREG);
706 w &= ~PCIE_L1THRESHOLDTIME_MASK; 695 w &= ~PCIE_L1THRESHOLDTIME_MASK;
707 w |= PCIE_L1THRESHOLD_WARVAL << PCIE_L1THRESHOLDTIME_SHIFT; 696 w |= PCIE_L1THRESHOLD_WARVAL << PCIE_L1THRESHOLDTIME_SHIFT;
708 pcie_writereg(pcieregs, PCIE_PCIEREGS, 697 pcie_writereg(pi->core, PCIE_PCIEREGS,
709 PCIE_DLLP_PMTHRESHREG, w); 698 PCIE_DLLP_PMTHRESHREG, w);
710 699
711 pcie_war_serdes(pi); 700 pcie_war_serdes(pi);
@@ -794,45 +783,45 @@ void pcicore_down(struct pcicore_info *pi, int state)
794} 783}
795 784
796/* precondition: current core is sii->buscoretype */ 785/* precondition: current core is sii->buscoretype */
797static void pcicore_fixcfg(struct pcicore_info *pi, u16 __iomem *reg16) 786void pcicore_fixcfg(struct pcicore_info *pi)
798{ 787{
799 struct si_info *sii = (struct si_info *)(pi->sih); 788 struct bcma_device *core = pi->core;
800 u16 val16; 789 u16 val16;
801 uint pciidx; 790 uint regoff;
802 791
803 pciidx = ai_coreidx(&sii->pub); 792 switch (pi->core->id.id) {
804 val16 = R_REG(reg16); 793 case BCMA_CORE_PCI:
805 if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16)pciidx) { 794 regoff = PCIREGOFFS(sprom[SRSH_PI_OFFSET]);
806 val16 = (u16)(pciidx << SRSH_PI_SHIFT) | 795 break;
807 (val16 & ~SRSH_PI_MASK);
808 W_REG(reg16, val16);
809 }
810}
811 796
812void 797 case BCMA_CORE_PCIE:
813pcicore_fixcfg_pci(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) 798 regoff = PCIEREGOFFS(sprom[SRSH_PI_OFFSET]);
814{ 799 break;
815 pcicore_fixcfg(pi, &pciregs->sprom[SRSH_PI_OFFSET]);
816}
817 800
818void pcicore_fixcfg_pcie(struct pcicore_info *pi, 801 default:
819 struct sbpcieregs __iomem *pcieregs) 802 return;
820{ 803 }
821 pcicore_fixcfg(pi, &pcieregs->sprom[SRSH_PI_OFFSET]); 804
805 val16 = bcma_read16(pi->core, regoff);
806 if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) !=
807 (u16)core->core_index) {
808 val16 = ((u16)core->core_index << SRSH_PI_SHIFT) |
809 (val16 & ~SRSH_PI_MASK);
810 bcma_write16(pi->core, regoff, val16);
811 }
822} 812}
823 813
824/* precondition: current core is pci core */ 814/* precondition: current core is pci core */
825void 815void
826pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) 816pcicore_pci_setup(struct pcicore_info *pi)
827{ 817{
828 u32 w; 818 bcma_set32(pi->core, PCIREGOFFS(sbtopci2),
829 819 SBTOPCI_PREF | SBTOPCI_BURST);
830 OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST); 820
831 821 if (pi->core->id.rev >= 11) {
832 if (ai_get_buscorerev(pi->sih) >= 11) { 822 bcma_set32(pi->core, PCIREGOFFS(sbtopci2),
833 OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI); 823 SBTOPCI_RC_READMULTI);
834 w = R_REG(&pciregs->clkrun); 824 bcma_set32(pi->core, PCIREGOFFS(clkrun), PCI_CLKRUN_DSBL);
835 W_REG(&pciregs->clkrun, w | PCI_CLKRUN_DSBL); 825 (void)bcma_read32(pi->core, PCIREGOFFS(clkrun));
836 w = R_REG(&pciregs->clkrun);
837 } 826 }
838} 827}
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h
index 58aa80dc3329..9fc3ead540a8 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h
@@ -62,8 +62,7 @@ struct sbpciregs;
62struct sbpcieregs; 62struct sbpcieregs;
63 63
64extern struct pcicore_info *pcicore_init(struct si_pub *sih, 64extern struct pcicore_info *pcicore_init(struct si_pub *sih,
65 struct pci_dev *pdev, 65 struct bcma_device *core);
66 void __iomem *regs);
67extern void pcicore_deinit(struct pcicore_info *pch); 66extern void pcicore_deinit(struct pcicore_info *pch);
68extern void pcicore_attach(struct pcicore_info *pch, int state); 67extern void pcicore_attach(struct pcicore_info *pch, int state);
69extern void pcicore_hwup(struct pcicore_info *pch); 68extern void pcicore_hwup(struct pcicore_info *pch);
@@ -72,11 +71,7 @@ extern void pcicore_sleep(struct pcicore_info *pch);
72extern void pcicore_down(struct pcicore_info *pch, int state); 71extern void pcicore_down(struct pcicore_info *pch, int state);
73extern u8 pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, 72extern u8 pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id,
74 unsigned char *buf, u32 *buflen); 73 unsigned char *buf, u32 *buflen);
75extern void pcicore_fixcfg_pci(struct pcicore_info *pch, 74extern void pcicore_fixcfg(struct pcicore_info *pch);
76 struct sbpciregs __iomem *pciregs); 75extern void pcicore_pci_setup(struct pcicore_info *pch);
77extern void pcicore_fixcfg_pcie(struct pcicore_info *pch,
78 struct sbpcieregs __iomem *pciregs);
79extern void pcicore_pci_setup(struct pcicore_info *pch,
80 struct sbpciregs __iomem *pciregs);
81 76
82#endif /* _BRCM_NICPCI_H_ */ 77#endif /* _BRCM_NICPCI_H_ */