Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

brcm80211: smac: use bcma core register access functions for 802.11 core

The driver now uses the bcma register access functions to read and
write the registers on the 802.11 core. The dma and phy code need
to be modified next and access to the other cores. That will be done
in coming patches.

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>

authored by

Arend van Spriel and committed by
John W. Linville
16d2812e 5204563a

+274 -267
+26 -22
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
··· 504 504 } 505 505 } 506 506 507 + static struct bcma_device *ai_find_bcma_core(struct si_pub *sih, uint coreidx) 508 + { 509 + struct si_info *sii = (struct si_info *)sih; 510 + struct bcma_device *core; 511 + 512 + list_for_each_entry(core, &sii->icbus->cores, list) { 513 + if (core->core_index == coreidx) 514 + return core; 515 + } 516 + return NULL; 517 + } 507 518 /* 508 519 * This function changes the logical "focus" to the indicated core. 509 520 * Return the current core's virtual address. Since each core starts with the ··· 525 514 void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx) 526 515 { 527 516 struct si_info *sii = (struct si_info *)sih; 528 - u32 addr = sii->coresba[coreidx]; 529 - u32 wrap = sii->wrapba[coreidx]; 517 + struct bcma_device *core; 530 518 531 - if (coreidx >= sii->numcores) 532 - return NULL; 519 + if (sii->curidx != coreidx) { 520 + core = ai_find_bcma_core(sih, coreidx); 521 + if (core == NULL) 522 + return NULL; 533 523 534 - /* point bar0 window */ 535 - pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, addr); 536 - /* point bar0 2nd 4KB window */ 537 - pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN2, wrap); 538 - sii->curidx = coreidx; 539 - 524 + (void)bcma_aread32(core, BCMA_IOST); 525 + sii->curidx = coreidx; 526 + } 540 527 return sii->curmap; 541 528 } 542 529 ··· 820 811 uint socitype; 821 812 uint origidx; 822 813 823 - /* assume the window is looking at chipcommon */ 824 - WARN_ON(pbus->mapped_core->id.id != BCMA_CORE_CHIPCOMMON); 825 814 memset((unsigned char *) sii, 0, sizeof(struct si_info)); 826 815 827 816 savewin = 0; ··· 830 823 sii->curmap = regs; 831 824 sii->curwrap = sii->curmap + SI_CORE_SIZE; 832 825 833 - /* find Chipcommon address */ 834 - pci_read_config_dword(sii->pcibus, PCI_BAR0_WIN, &savewin); 835 - if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) 836 - savewin = SI_ENUM_BASE; 826 + /* switch to Chipcommon core */ 827 + bcma_read32(pbus->drv_cc.core, 0); 828 + savewin = SI_ENUM_BASE; 837 829 838 - pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, 839 - SI_ENUM_BASE); 840 830 cc = (struct chipcregs __iomem *) regs; 841 831 842 832 /* bus/core/clk setup for register access */ ··· 1040 1036 /* return index of coreid or BADIDX if not found */ 1041 1037 uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) 1042 1038 { 1039 + struct bcma_device *core; 1043 1040 struct si_info *sii; 1044 1041 uint found; 1045 - uint i; 1046 1042 1047 1043 sii = (struct si_info *)sih; 1048 1044 1049 1045 found = 0; 1050 1046 1051 - for (i = 0; i < sii->numcores; i++) 1052 - if (sii->coreid[i] == coreid) { 1047 + list_for_each_entry(core, &sii->icbus->cores, list) 1048 + if (core->id.id == coreid) { 1053 1049 if (found == coreunit) 1054 - return i; 1050 + return core->core_index; 1055 1051 found++; 1056 1052 } 1057 1053
+5 -2
drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
··· 1118 1118 u8 status_delay = 0; 1119 1119 1120 1120 /* wait till the next 8 bytes of txstatus is available */ 1121 - while (((s1 = R_REG(&wlc->regs->frmtxstatus)) & TXS_V) == 0) { 1121 + s1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(frmtxstatus)); 1122 + while ((s1 & TXS_V) == 0) { 1122 1123 udelay(1); 1123 1124 status_delay++; 1124 1125 if (status_delay > 10) 1125 1126 return; /* error condition */ 1127 + s1 = bcma_read32(wlc->hw->d11core, 1128 + D11REGOFFS(frmtxstatus)); 1126 1129 } 1127 1130 1128 - s2 = R_REG(&wlc->regs->frmtxstatus2); 1131 + s2 = bcma_read32(wlc->hw->d11core, D11REGOFFS(frmtxstatus2)); 1129 1132 } 1130 1133 1131 1134 if (scb) {
+3
drivers/net/wireless/brcm80211/brcmsmac/d11.h
··· 430 430 u16 PAD[0x380]; /* 0x800 - 0xEFE */ 431 431 }; 432 432 433 + /* d11 register field offset */ 434 + #define D11REGOFFS(field) offsetof(struct d11regs, field) 435 + 433 436 #define PIHR_BASE 0x0400 /* byte address of packed IHR region */ 434 437 435 438 /* biststatus */
+239 -240
drivers/net/wireless/brcm80211/brcmsmac/main.c
··· 388 388 */ 389 389 static bool brcms_deviceremoved(struct brcms_c_info *wlc) 390 390 { 391 + u32 macctrl; 392 + 391 393 if (!wlc->hw->clk) 392 394 return ai_deviceremoved(wlc->hw->sih); 393 - return (R_REG(&wlc->hw->regs->maccontrol) & 394 - (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN; 395 + macctrl = bcma_read32(wlc->hw->d11core, 396 + D11REGOFFS(maccontrol)); 397 + return (macctrl & (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN; 395 398 } 396 399 397 400 /* sum the individual fifo tx pending packet counts */ ··· 585 582 static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, 586 583 bool shortslot) 587 584 { 588 - struct d11regs __iomem *regs; 589 - 590 - regs = wlc_hw->regs; 585 + struct bcma_device *core = wlc_hw->d11core; 591 586 592 587 if (shortslot) { 593 588 /* 11g short slot: 11a timing */ 594 - W_REG(&regs->ifs_slot, 0x0207); /* APHY_SLOT_TIME */ 589 + bcma_write16(core, D11REGOFFS(ifs_slot), 0x0207); 595 590 brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, APHY_SLOT_TIME); 596 591 } else { 597 592 /* 11g long slot: 11b timing */ 598 - W_REG(&regs->ifs_slot, 0x0212); /* BPHY_SLOT_TIME */ 593 + bcma_write16(core, D11REGOFFS(ifs_slot), 0x0212); 599 594 brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, BPHY_SLOT_TIME); 600 595 } 601 596 } ··· 673 672 static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, 674 673 const struct d11init *inits) 675 674 { 675 + struct bcma_device *core = wlc_hw->d11core; 676 676 int i; 677 - u8 __iomem *base; 678 - u8 __iomem *addr; 677 + uint offset; 679 678 u16 size; 680 679 u32 value; 681 680 682 681 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 683 682 684 - base = (u8 __iomem *)wlc_hw->regs; 685 - 686 683 for (i = 0; inits[i].addr != cpu_to_le16(0xffff); i++) { 687 684 size = le16_to_cpu(inits[i].size); 688 - addr = base + le16_to_cpu(inits[i].addr); 685 + offset = le16_to_cpu(inits[i].addr); 689 686 value = le32_to_cpu(inits[i].value); 690 687 if (size == 2) 691 - W_REG((u16 __iomem *)addr, value); 688 + bcma_write16(core, offset, value); 692 689 else if (size == 4) 693 - W_REG((u32 __iomem *)addr, value); 690 + bcma_write32(core, offset, value); 694 691 else 695 692 break; 696 693 } ··· 787 788 { 788 789 struct brcms_hardware *wlc_hw = wlc->hw; 789 790 u32 macintmask; 791 + u32 macctrl; 790 792 791 793 BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); 792 - 793 - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); 794 + macctrl = bcma_read32(wlc_hw->d11core, 795 + D11REGOFFS(maccontrol)); 796 + WARN_ON((macctrl & MCTL_EN_MAC) != 0); 794 797 795 798 /* disable interrupts */ 796 799 macintmask = brcms_intrsoff(wlc->wl); ··· 983 982 { 984 983 bool morepending = false; 985 984 struct brcms_c_info *wlc = wlc_hw->wlc; 986 - struct d11regs __iomem *regs; 985 + struct bcma_device *core; 987 986 struct tx_status txstatus, *txs; 988 987 u32 s1, s2; 989 988 uint n = 0; ··· 996 995 BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); 997 996 998 997 txs = &txstatus; 999 - regs = wlc_hw->regs; 998 + core = wlc_hw->d11core; 1000 999 *fatal = false; 1000 + s1 = bcma_read32(core, D11REGOFFS(frmtxstatus)); 1001 1001 while (!(*fatal) 1002 - && (s1 = R_REG(&regs->frmtxstatus)) & TXS_V) { 1002 + && (s1 & TXS_V)) { 1003 1003 1004 1004 if (s1 == 0xffffffff) { 1005 1005 wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", 1006 1006 wlc_hw->unit, __func__); 1007 1007 return morepending; 1008 1008 } 1009 - 1010 - s2 = R_REG(&regs->frmtxstatus2); 1009 + s2 = bcma_read32(core, D11REGOFFS(frmtxstatus2)); 1011 1010 1012 1011 txs->status = s1 & TXS_STATUS_MASK; 1013 1012 txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; ··· 1020 1019 /* !give others some time to run! */ 1021 1020 if (++n >= max_tx_num) 1022 1021 break; 1022 + s1 = bcma_read32(core, D11REGOFFS(frmtxstatus)); 1023 1023 } 1024 1024 1025 1025 if (*fatal) ··· 1068 1066 static struct dma64regs __iomem * 1069 1067 dmareg(struct brcms_hardware *hw, uint direction, uint fifonum) 1070 1068 { 1069 + struct d11regs __iomem *regs = hw->d11core->bus->mmio; 1070 + 1071 1071 if (direction == DMA_TX) 1072 - return &(hw->regs->fifo64regs[fifonum].dmaxmt); 1073 - return &(hw->regs->fifo64regs[fifonum].dmarcv); 1072 + return &(regs->fifo64regs[fifonum].dmaxmt); 1073 + return &(regs->fifo64regs[fifonum].dmarcv); 1074 1074 } 1075 1075 1076 1076 static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) ··· 1218 1214 1219 1215 if (wlc_hw->clk) { 1220 1216 if (mode == CLK_FAST) { 1221 - OR_REG(&wlc_hw->regs->clk_ctl_st, 1222 - CCS_FORCEHT); 1217 + bcma_set32(wlc_hw->d11core, 1218 + D11REGOFFS(clk_ctl_st), 1219 + CCS_FORCEHT); 1223 1220 1224 1221 udelay(64); 1225 1222 1226 - SPINWAIT(((R_REG 1227 - (&wlc_hw->regs-> 1228 - clk_ctl_st) & CCS_HTAVAIL) == 0), 1229 - PMU_MAX_TRANSITION_DLY); 1230 - WARN_ON(!(R_REG 1231 - (&wlc_hw->regs-> 1232 - clk_ctl_st) & CCS_HTAVAIL)); 1223 + SPINWAIT( 1224 + ((bcma_read32(wlc_hw->d11core, 1225 + D11REGOFFS(clk_ctl_st)) & 1226 + CCS_HTAVAIL) == 0), 1227 + PMU_MAX_TRANSITION_DLY); 1228 + WARN_ON(!(bcma_read32(wlc_hw->d11core, 1229 + D11REGOFFS(clk_ctl_st)) & 1230 + CCS_HTAVAIL)); 1233 1231 } else { 1234 1232 if ((ai_get_pmurev(wlc_hw->sih) == 0) && 1235 - (R_REG 1236 - (&wlc_hw->regs-> 1237 - clk_ctl_st) & (CCS_FORCEHT | CCS_HTAREQ))) 1238 - SPINWAIT(((R_REG 1239 - (&wlc_hw->regs-> 1240 - clk_ctl_st) & CCS_HTAVAIL) 1241 - == 0), 1242 - PMU_MAX_TRANSITION_DLY); 1243 - AND_REG(&wlc_hw->regs->clk_ctl_st, 1233 + (bcma_read32(wlc_hw->d11core, 1234 + D11REGOFFS(clk_ctl_st)) & 1235 + (CCS_FORCEHT | CCS_HTAREQ))) 1236 + SPINWAIT( 1237 + ((bcma_read32(wlc_hw->d11core, 1238 + offsetof(struct d11regs, 1239 + clk_ctl_st)) & 1240 + CCS_HTAVAIL) == 0), 1241 + PMU_MAX_TRANSITION_DLY); 1242 + bcma_mask32(wlc_hw->d11core, 1243 + D11REGOFFS(clk_ctl_st), 1244 1244 ~CCS_FORCEHT); 1245 1245 } 1246 1246 } ··· 1376 1368 maccontrol |= MCTL_INFRA; 1377 1369 } 1378 1370 1379 - W_REG(&wlc_hw->regs->maccontrol, maccontrol); 1371 + bcma_write32(wlc_hw->d11core, D11REGOFFS(maccontrol), 1372 + maccontrol); 1380 1373 } 1381 1374 1382 1375 /* set or clear maccontrol bits */ ··· 1471 1462 brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, 1472 1463 const u8 *addr) 1473 1464 { 1474 - struct d11regs __iomem *regs; 1465 + struct bcma_device *core = wlc_hw->d11core; 1475 1466 u16 mac_l; 1476 1467 u16 mac_m; 1477 1468 u16 mac_h; ··· 1479 1470 BCMMSG(wlc_hw->wlc->wiphy, "wl%d: brcms_b_set_addrmatch\n", 1480 1471 wlc_hw->unit); 1481 1472 1482 - regs = wlc_hw->regs; 1483 1473 mac_l = addr[0] | (addr[1] << 8); 1484 1474 mac_m = addr[2] | (addr[3] << 8); 1485 1475 mac_h = addr[4] | (addr[5] << 8); 1486 1476 1487 1477 /* enter the MAC addr into the RXE match registers */ 1488 - W_REG(&regs->rcm_ctl, RCM_INC_DATA | match_reg_offset); 1489 - W_REG(&regs->rcm_mat_data, mac_l); 1490 - W_REG(&regs->rcm_mat_data, mac_m); 1491 - W_REG(&regs->rcm_mat_data, mac_h); 1492 - 1478 + bcma_write16(core, D11REGOFFS(rcm_ctl), 1479 + RCM_INC_DATA | match_reg_offset); 1480 + bcma_write16(core, D11REGOFFS(rcm_mat_data), mac_l); 1481 + bcma_write16(core, D11REGOFFS(rcm_mat_data), mac_m); 1482 + bcma_write16(core, D11REGOFFS(rcm_mat_data), mac_h); 1493 1483 } 1494 1484 1495 1485 void 1496 1486 brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, 1497 1487 void *buf) 1498 1488 { 1499 - struct d11regs __iomem *regs; 1489 + struct bcma_device *core = wlc_hw->d11core; 1500 1490 u32 word; 1501 1491 __le32 word_le; 1502 1492 __be32 word_be; 1503 1493 bool be_bit; 1504 1494 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 1505 1495 1506 - regs = wlc_hw->regs; 1507 - W_REG(&regs->tplatewrptr, offset); 1496 + bcma_write32(core, D11REGOFFS(tplatewrptr), offset); 1508 1497 1509 1498 /* if MCTL_BIGEND bit set in mac control register, 1510 1499 * the chip swaps data in fifo, as well as data in 1511 1500 * template ram 1512 1501 */ 1513 - be_bit = (R_REG(&regs->maccontrol) & MCTL_BIGEND) != 0; 1502 + be_bit = (bcma_read32(core, D11REGOFFS(maccontrol)) & MCTL_BIGEND) != 0; 1514 1503 1515 1504 while (len > 0) { 1516 1505 memcpy(&word, buf, sizeof(u32)); ··· 1521 1514 word = *(u32 *)&word_le; 1522 1515 } 1523 1516 1524 - W_REG(&regs->tplatewrdata, word); 1517 + bcma_write32(core, D11REGOFFS(tplatewrdata), word); 1525 1518 1526 1519 buf = (u8 *) buf + sizeof(u32); 1527 1520 len -= sizeof(u32); ··· 1532 1525 { 1533 1526 wlc_hw->band->CWmin = newmin; 1534 1527 1535 - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMIN); 1536 - (void)R_REG(&wlc_hw->regs->objaddr); 1537 - W_REG(&wlc_hw->regs->objdata, newmin); 1528 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), 1529 + OBJADDR_SCR_SEL | S_DOT11_CWMIN); 1530 + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); 1531 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmin); 1538 1532 } 1539 1533 1540 1534 static void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) 1541 1535 { 1542 1536 wlc_hw->band->CWmax = newmax; 1543 1537 1544 - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMAX); 1545 - (void)R_REG(&wlc_hw->regs->objaddr); 1546 - W_REG(&wlc_hw->regs->objdata, newmax); 1538 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), 1539 + OBJADDR_SCR_SEL | S_DOT11_CWMAX); 1540 + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); 1541 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmax); 1547 1542 } 1548 1543 1549 1544 void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) ··· 1824 1815 brcms_intrsrestore(wlc->wl, macintmask); 1825 1816 1826 1817 /* ucode should still be suspended.. */ 1827 - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); 1818 + WARN_ON((bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & 1819 + MCTL_EN_MAC) != 0); 1828 1820 } 1829 1821 1830 1822 static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) ··· 1947 1937 */ 1948 1938 if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || 1949 1939 (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) 1950 - wlc_hw->regs = (struct d11regs __iomem *) 1951 - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); 1940 + (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); 1941 + 1952 1942 ai_core_reset(wlc_hw->sih, flags, resetbits); 1953 1943 brcms_c_mctrl_reset(wlc_hw); 1954 1944 } 1955 1945 1956 - v = ((R_REG(&wlc_hw->regs->phydebug) & PDBG_RFD) != 0); 1946 + v = ((bcma_read32(wlc_hw->d11core, 1947 + D11REGOFFS(phydebug)) & PDBG_RFD) != 0); 1957 1948 1958 1949 /* put core back into reset */ 1959 1950 if (!clk) ··· 1982 1971 */ 1983 1972 void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) 1984 1973 { 1985 - struct d11regs __iomem *regs; 1986 1974 uint i; 1987 1975 bool fastclk; 1988 1976 u32 resetbits = 0; ··· 1990 1980 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); 1991 1981 1992 1982 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 1993 - 1994 - regs = wlc_hw->regs; 1995 1983 1996 1984 /* request FAST clock if not on */ 1997 1985 fastclk = wlc_hw->forcefastclk; ··· 2063 2055 */ 2064 2056 static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) 2065 2057 { 2066 - struct d11regs __iomem *regs = wlc_hw->regs; 2058 + struct bcma_device *core = wlc_hw->d11core; 2067 2059 u16 fifo_nu; 2068 2060 u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; 2069 2061 u16 txfifo_def, txfifo_def1; ··· 2084 2076 txfifo_cmd = 2085 2077 TXFIFOCMD_RESET_MASK | (fifo_nu << TXFIFOCMD_FIFOSEL_SHIFT); 2086 2078 2087 - W_REG(&regs->xmtfifocmd, txfifo_cmd); 2088 - W_REG(&regs->xmtfifodef, txfifo_def); 2089 - W_REG(&regs->xmtfifodef1, txfifo_def1); 2079 + bcma_write16(core, D11REGOFFS(xmtfifocmd), txfifo_cmd); 2080 + bcma_write16(core, D11REGOFFS(xmtfifodef), txfifo_def); 2081 + bcma_write16(core, D11REGOFFS(xmtfifodef1), txfifo_def1); 2090 2082 2091 - W_REG(&regs->xmtfifocmd, txfifo_cmd); 2083 + bcma_write16(core, D11REGOFFS(xmtfifocmd), txfifo_cmd); 2092 2084 2093 2085 txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; 2094 2086 } ··· 2123 2115 2124 2116 void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) 2125 2117 { 2126 - struct d11regs __iomem *regs = wlc_hw->regs; 2118 + struct bcma_device *core = wlc_hw->d11core; 2127 2119 2128 2120 if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || 2129 2121 (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) { 2130 2122 if (spurmode == WL_SPURAVOID_ON2) { /* 126Mhz */ 2131 - W_REG(&regs->tsf_clk_frac_l, 0x2082); 2132 - W_REG(&regs->tsf_clk_frac_h, 0x8); 2123 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x2082); 2124 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0x8); 2133 2125 } else if (spurmode == WL_SPURAVOID_ON1) { /* 123Mhz */ 2134 - W_REG(&regs->tsf_clk_frac_l, 0x5341); 2135 - W_REG(&regs->tsf_clk_frac_h, 0x8); 2126 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x5341); 2127 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0x8); 2136 2128 } else { /* 120Mhz */ 2137 - W_REG(&regs->tsf_clk_frac_l, 0x8889); 2138 - W_REG(&regs->tsf_clk_frac_h, 0x8); 2129 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x8889); 2130 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0x8); 2139 2131 } 2140 2132 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { 2141 2133 if (spurmode == WL_SPURAVOID_ON1) { /* 82Mhz */ 2142 - W_REG(&regs->tsf_clk_frac_l, 0x7CE0); 2143 - W_REG(&regs->tsf_clk_frac_h, 0xC); 2134 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x7CE0); 2135 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0xC); 2144 2136 } else { /* 80Mhz */ 2145 - W_REG(&regs->tsf_clk_frac_l, 0xCCCD); 2146 - W_REG(&regs->tsf_clk_frac_h, 0xC); 2137 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0xCCCD); 2138 + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0xC); 2147 2139 } 2148 2140 } 2149 2141 } ··· 2152 2144 static void brcms_c_gpio_init(struct brcms_c_info *wlc) 2153 2145 { 2154 2146 struct brcms_hardware *wlc_hw = wlc->hw; 2155 - struct d11regs __iomem *regs; 2156 2147 u32 gc, gm; 2157 - 2158 - regs = wlc_hw->regs; 2159 2148 2160 2149 /* use GPIO select 0 to get all gpio signals from the gpio out reg */ 2161 2150 brcms_b_mctrl(wlc_hw, MCTL_GPOUT_SEL_MASK, 0); ··· 2184 2179 * The board itself is powered by these GPIOs 2185 2180 * (when not sending pattern) so set them high 2186 2181 */ 2187 - OR_REG(&regs->psm_gpio_oe, 2188 - (BOARD_GPIO_12 | BOARD_GPIO_13)); 2189 - OR_REG(&regs->psm_gpio_out, 2190 - (BOARD_GPIO_12 | BOARD_GPIO_13)); 2182 + bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_oe), 2183 + (BOARD_GPIO_12 | BOARD_GPIO_13)); 2184 + bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_out), 2185 + (BOARD_GPIO_12 | BOARD_GPIO_13)); 2191 2186 2192 2187 /* Enable antenna diversity, use 2x4 mode */ 2193 2188 brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, ··· 2214 2209 static void brcms_ucode_write(struct brcms_hardware *wlc_hw, 2215 2210 const __le32 ucode[], const size_t nbytes) 2216 2211 { 2217 - struct d11regs __iomem *regs = wlc_hw->regs; 2212 + struct bcma_device *core = wlc_hw->d11core; 2218 2213 uint i; 2219 2214 uint count; 2220 2215 ··· 2222 2217 2223 2218 count = (nbytes / sizeof(u32)); 2224 2219 2225 - W_REG(&regs->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); 2226 - (void)R_REG(&regs->objaddr); 2220 + bcma_write32(core, D11REGOFFS(objaddr), 2221 + OBJADDR_AUTO_INC | OBJADDR_UCM_SEL); 2222 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2227 2223 for (i = 0; i < count; i++) 2228 - W_REG(&regs->objdata, le32_to_cpu(ucode[i])); 2224 + bcma_write32(core, D11REGOFFS(objdata), le32_to_cpu(ucode[i])); 2229 2225 2230 2226 } 2231 2227 ··· 2292 2286 bool fatal = false; 2293 2287 uint unit; 2294 2288 uint intstatus, idx; 2295 - struct d11regs __iomem *regs = wlc_hw->regs; 2289 + struct bcma_device *core = wlc_hw->d11core; 2296 2290 struct wiphy *wiphy = wlc_hw->wlc->wiphy; 2297 2291 2298 2292 unit = wlc_hw->unit; ··· 2300 2294 for (idx = 0; idx < NFIFO; idx++) { 2301 2295 /* read intstatus register and ignore any non-error bits */ 2302 2296 intstatus = 2303 - R_REG(&regs->intctrlregs[idx].intstatus) & I_ERRORS; 2297 + bcma_read32(core, 2298 + D11REGOFFS(intctrlregs[idx].intstatus)) & 2299 + I_ERRORS; 2304 2300 if (!intstatus) 2305 2301 continue; 2306 2302 ··· 2347 2339 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ 2348 2340 break; 2349 2341 } else 2350 - W_REG(&regs->intctrlregs[idx].intstatus, 2351 - intstatus); 2342 + bcma_write32(core, 2343 + D11REGOFFS(intctrlregs[idx].intstatus), 2344 + intstatus); 2352 2345 } 2353 2346 } 2354 2347 ··· 2357 2348 { 2358 2349 struct brcms_hardware *wlc_hw = wlc->hw; 2359 2350 wlc->macintmask = wlc->defmacintmask; 2360 - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); 2351 + bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); 2361 2352 } 2362 2353 2363 2354 /* ··· 2391 2382 2392 2383 macintmask = wlc->macintmask; /* isr can still happen */ 2393 2384 2394 - W_REG(&wlc_hw->regs->macintmask, 0); 2395 - (void)R_REG(&wlc_hw->regs->macintmask); /* sync readback */ 2385 + bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), 0); 2386 + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(macintmask)); 2396 2387 udelay(1); /* ensure int line is no longer driven */ 2397 2388 wlc->macintmask = 0; 2398 2389 ··· 2407 2398 return; 2408 2399 2409 2400 wlc->macintmask = macintmask; 2410 - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); 2401 + bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); 2411 2402 } 2412 2403 2413 2404 /* assumes that the d11 MAC is enabled */ ··· 2519 2510 static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) 2520 2511 { 2521 2512 struct brcms_hardware *wlc_hw = wlc->hw; 2522 - struct d11regs __iomem *regs = wlc_hw->regs; 2513 + struct bcma_device *core = wlc_hw->d11core; 2523 2514 u32 macintstatus; 2524 2515 2525 2516 /* macintstatus includes a DMA interrupt summary bit */ 2526 - macintstatus = R_REG(&regs->macintstatus); 2517 + macintstatus = bcma_read32(core, D11REGOFFS(macintstatus)); 2527 2518 2528 2519 BCMMSG(wlc->wiphy, "wl%d: macintstatus: 0x%x\n", wlc_hw->unit, 2529 2520 macintstatus); ··· 2550 2541 * consequences 2551 2542 */ 2552 2543 /* turn off the interrupts */ 2553 - W_REG(&regs->macintmask, 0); 2554 - (void)R_REG(&regs->macintmask); /* sync readback */ 2544 + bcma_write32(core, D11REGOFFS(macintmask), 0); 2545 + (void)bcma_read32(core, D11REGOFFS(macintmask)); 2555 2546 wlc->macintmask = 0; 2556 2547 2557 2548 /* clear device interrupts */ 2558 - W_REG(&regs->macintstatus, macintstatus); 2549 + bcma_write32(core, D11REGOFFS(macintstatus), macintstatus); 2559 2550 2560 2551 /* MI_DMAINT is indication of non-zero intstatus */ 2561 2552 if (macintstatus & MI_DMAINT) ··· 2564 2555 * RX_FIFO. If MI_DMAINT is set, assume it 2565 2556 * is set and clear the interrupt. 2566 2557 */ 2567 - W_REG(&regs->intctrlregs[RX_FIFO].intstatus, 2568 - DEF_RXINTMASK); 2558 + bcma_write32(core, D11REGOFFS(intctrlregs[RX_FIFO].intstatus), 2559 + DEF_RXINTMASK); 2569 2560 2570 2561 return macintstatus; 2571 2562 } ··· 2628 2619 void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) 2629 2620 { 2630 2621 struct brcms_hardware *wlc_hw = wlc->hw; 2631 - struct d11regs __iomem *regs = wlc_hw->regs; 2622 + struct bcma_device *core = wlc_hw->d11core; 2632 2623 u32 mc, mi; 2633 2624 struct wiphy *wiphy = wlc->wiphy; 2634 2625 ··· 2645 2636 /* force the core awake */ 2646 2637 brcms_c_ucode_wake_override_set(wlc_hw, BRCMS_WAKE_OVERRIDE_MACSUSPEND); 2647 2638 2648 - mc = R_REG(&regs->maccontrol); 2639 + mc = bcma_read32(core, D11REGOFFS(maccontrol)); 2649 2640 2650 2641 if (mc == 0xffffffff) { 2651 2642 wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, ··· 2657 2648 WARN_ON(!(mc & MCTL_PSM_RUN)); 2658 2649 WARN_ON(!(mc & MCTL_EN_MAC)); 2659 2650 2660 - mi = R_REG(&regs->macintstatus); 2651 + mi = bcma_read32(core, D11REGOFFS(macintstatus)); 2661 2652 if (mi == 0xffffffff) { 2662 2653 wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, 2663 2654 __func__); ··· 2668 2659 2669 2660 brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, 0); 2670 2661 2671 - SPINWAIT(!(R_REG(&regs->macintstatus) & MI_MACSSPNDD), 2662 + SPINWAIT(!(bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD), 2672 2663 BRCMS_MAX_MAC_SUSPEND); 2673 2664 2674 - if (!(R_REG(&regs->macintstatus) & MI_MACSSPNDD)) { 2665 + if (!(bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD)) { 2675 2666 wiphy_err(wiphy, "wl%d: wlc_suspend_mac_and_wait: waited %d uS" 2676 2667 " and MI_MACSSPNDD is still not on.\n", 2677 2668 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); 2678 2669 wiphy_err(wiphy, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, " 2679 2670 "psm_brc 0x%04x\n", wlc_hw->unit, 2680 - R_REG(&regs->psmdebug), 2681 - R_REG(&regs->phydebug), 2682 - R_REG(&regs->psm_brc)); 2671 + bcma_read32(core, D11REGOFFS(psmdebug)), 2672 + bcma_read32(core, D11REGOFFS(phydebug)), 2673 + bcma_read16(core, D11REGOFFS(psm_brc))); 2683 2674 } 2684 2675 2685 - mc = R_REG(&regs->maccontrol); 2676 + mc = bcma_read32(core, D11REGOFFS(maccontrol)); 2686 2677 if (mc == 0xffffffff) { 2687 2678 wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, 2688 2679 __func__); ··· 2697 2688 void brcms_c_enable_mac(struct brcms_c_info *wlc) 2698 2689 { 2699 2690 struct brcms_hardware *wlc_hw = wlc->hw; 2700 - struct d11regs __iomem *regs = wlc_hw->regs; 2691 + struct bcma_device *core = wlc_hw->d11core; 2701 2692 u32 mc, mi; 2702 2693 2703 2694 BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, ··· 2710 2701 if (wlc_hw->mac_suspend_depth > 0) 2711 2702 return; 2712 2703 2713 - mc = R_REG(&regs->maccontrol); 2704 + mc = bcma_read32(core, D11REGOFFS(maccontrol)); 2714 2705 WARN_ON(mc & MCTL_PSM_JMP_0); 2715 2706 WARN_ON(mc & MCTL_EN_MAC); 2716 2707 WARN_ON(!(mc & MCTL_PSM_RUN)); 2717 2708 2718 2709 brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC); 2719 - W_REG(&regs->macintstatus, MI_MACSSPNDD); 2710 + bcma_write32(core, D11REGOFFS(macintstatus), MI_MACSSPNDD); 2720 2711 2721 - mc = R_REG(&regs->maccontrol); 2712 + mc = bcma_read32(core, D11REGOFFS(maccontrol)); 2722 2713 WARN_ON(mc & MCTL_PSM_JMP_0); 2723 2714 WARN_ON(!(mc & MCTL_EN_MAC)); 2724 2715 WARN_ON(!(mc & MCTL_PSM_RUN)); 2725 2716 2726 - mi = R_REG(&regs->macintstatus); 2717 + mi = bcma_read32(core, D11REGOFFS(macintstatus)); 2727 2718 WARN_ON(mi & MI_MACSSPNDD); 2728 2719 2729 2720 brcms_c_ucode_wake_override_clear(wlc_hw, ··· 2740 2731 2741 2732 static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) 2742 2733 { 2743 - struct d11regs __iomem *regs; 2734 + struct bcma_device *core = wlc_hw->d11core; 2744 2735 u32 w, val; 2745 2736 struct wiphy *wiphy = wlc_hw->wlc->wiphy; 2746 2737 2747 2738 BCMMSG(wiphy, "wl%d\n", wlc_hw->unit); 2748 2739 2749 - regs = wlc_hw->regs; 2750 - 2751 2740 /* Validate dchip register access */ 2752 2741 2753 - W_REG(&regs->objaddr, OBJADDR_SHM_SEL | 0); 2754 - (void)R_REG(&regs->objaddr); 2755 - w = R_REG(&regs->objdata); 2742 + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); 2743 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2744 + w = bcma_read32(core, D11REGOFFS(objdata)); 2756 2745 2757 2746 /* Can we write and read back a 32bit register? */ 2758 - W_REG(&regs->objaddr, OBJADDR_SHM_SEL | 0); 2759 - (void)R_REG(&regs->objaddr); 2760 - W_REG(&regs->objdata, (u32) 0xaa5555aa); 2747 + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); 2748 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2749 + bcma_write32(core, D11REGOFFS(objdata), (u32) 0xaa5555aa); 2761 2750 2762 - W_REG(&regs->objaddr, OBJADDR_SHM_SEL | 0); 2763 - (void)R_REG(&regs->objaddr); 2764 - val = R_REG(&regs->objdata); 2751 + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); 2752 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2753 + val = bcma_read32(core, D11REGOFFS(objdata)); 2765 2754 if (val != (u32) 0xaa5555aa) { 2766 2755 wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " 2767 2756 "expected 0xaa5555aa\n", wlc_hw->unit, val); 2768 2757 return false; 2769 2758 } 2770 2759 2771 - W_REG(&regs->objaddr, OBJADDR_SHM_SEL | 0); 2772 - (void)R_REG(&regs->objaddr); 2773 - W_REG(&regs->objdata, (u32) 0x55aaaa55); 2760 + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); 2761 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2762 + bcma_write32(core, D11REGOFFS(objdata), (u32) 0x55aaaa55); 2774 2763 2775 - W_REG(&regs->objaddr, OBJADDR_SHM_SEL | 0); 2776 - (void)R_REG(&regs->objaddr); 2777 - val = R_REG(&regs->objdata); 2764 + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); 2765 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2766 + val = bcma_read32(core, D11REGOFFS(objdata)); 2778 2767 if (val != (u32) 0x55aaaa55) { 2779 2768 wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " 2780 2769 "expected 0x55aaaa55\n", wlc_hw->unit, val); 2781 2770 return false; 2782 2771 } 2783 2772 2784 - W_REG(&regs->objaddr, OBJADDR_SHM_SEL | 0); 2785 - (void)R_REG(&regs->objaddr); 2786 - W_REG(&regs->objdata, w); 2773 + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); 2774 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2775 + bcma_write32(core, D11REGOFFS(objdata), w); 2787 2776 2788 2777 /* clear CFPStart */ 2789 - W_REG(&regs->tsf_cfpstart, 0); 2778 + bcma_write32(core, D11REGOFFS(tsf_cfpstart), 0); 2790 2779 2791 - w = R_REG(&regs->maccontrol); 2780 + w = bcma_read32(core, D11REGOFFS(maccontrol)); 2792 2781 if ((w != (MCTL_IHR_EN | MCTL_WAKE)) && 2793 2782 (w != (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE))) { 2794 2783 wiphy_err(wiphy, "wl%d: validate_chip_access: maccontrol = " ··· 2803 2796 2804 2797 void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) 2805 2798 { 2806 - struct d11regs __iomem *regs; 2799 + struct bcma_device *core = wlc_hw->d11core; 2807 2800 u32 tmp; 2808 2801 2809 2802 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 2810 2803 2811 2804 tmp = 0; 2812 - regs = wlc_hw->regs; 2813 2805 2814 2806 if (on) { 2815 2807 if ((ai_get_chip_id(wlc_hw->sih) == BCM4313_CHIP_ID)) { 2816 - OR_REG(&regs->clk_ctl_st, 2817 - (CCS_ERSRC_REQ_HT | CCS_ERSRC_REQ_D11PLL | 2818 - CCS_ERSRC_REQ_PHYPLL)); 2819 - SPINWAIT((R_REG(&regs->clk_ctl_st) & 2820 - (CCS_ERSRC_AVAIL_HT)) != (CCS_ERSRC_AVAIL_HT), 2808 + bcma_set32(core, D11REGOFFS(clk_ctl_st), 2809 + CCS_ERSRC_REQ_HT | 2810 + CCS_ERSRC_REQ_D11PLL | 2811 + CCS_ERSRC_REQ_PHYPLL); 2812 + SPINWAIT((bcma_read32(core, D11REGOFFS(clk_ctl_st)) & 2813 + CCS_ERSRC_AVAIL_HT) != CCS_ERSRC_AVAIL_HT, 2821 2814 PHYPLL_WAIT_US); 2822 2815 2823 - tmp = R_REG(&regs->clk_ctl_st); 2824 - if ((tmp & (CCS_ERSRC_AVAIL_HT)) != 2825 - (CCS_ERSRC_AVAIL_HT)) 2816 + tmp = bcma_read32(core, D11REGOFFS(clk_ctl_st)); 2817 + if ((tmp & CCS_ERSRC_AVAIL_HT) != CCS_ERSRC_AVAIL_HT) 2826 2818 wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY" 2827 2819 " PLL failed\n", __func__); 2828 2820 } else { 2829 - OR_REG(&regs->clk_ctl_st, 2830 - (CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); 2831 - SPINWAIT((R_REG(&regs->clk_ctl_st) & 2821 + bcma_set32(core, D11REGOFFS(clk_ctl_st), 2822 + tmp | CCS_ERSRC_REQ_D11PLL | 2823 + CCS_ERSRC_REQ_PHYPLL); 2824 + SPINWAIT((bcma_read32(core, D11REGOFFS(clk_ctl_st)) & 2832 2825 (CCS_ERSRC_AVAIL_D11PLL | 2833 2826 CCS_ERSRC_AVAIL_PHYPLL)) != 2834 2827 (CCS_ERSRC_AVAIL_D11PLL | 2835 2828 CCS_ERSRC_AVAIL_PHYPLL), PHYPLL_WAIT_US); 2836 2829 2837 - tmp = R_REG(&regs->clk_ctl_st); 2830 + tmp = bcma_read32(core, D11REGOFFS(clk_ctl_st)); 2838 2831 if ((tmp & 2839 2832 (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) 2840 2833 != ··· 2848 2841 * be requesting it; so we'll deassert the request but 2849 2842 * not wait for status to comply. 2850 2843 */ 2851 - AND_REG(&regs->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); 2852 - tmp = R_REG(&regs->clk_ctl_st); 2844 + bcma_mask32(core, D11REGOFFS(clk_ctl_st), 2845 + ~CCS_ERSRC_REQ_PHYPLL); 2846 + (void)bcma_read32(core, D11REGOFFS(clk_ctl_st)); 2853 2847 } 2854 2848 } 2855 2849 ··· 2902 2894 static u16 2903 2895 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) 2904 2896 { 2905 - struct d11regs __iomem *regs = wlc_hw->regs; 2906 - u16 __iomem *objdata_lo = (u16 __iomem *)&regs->objdata; 2907 - u16 __iomem *objdata_hi = objdata_lo + 1; 2908 - u16 v; 2897 + struct bcma_device *core = wlc_hw->d11core; 2898 + u16 objoff = D11REGOFFS(objdata); 2909 2899 2910 - W_REG(&regs->objaddr, sel | (offset >> 2)); 2911 - (void)R_REG(&regs->objaddr); 2900 + bcma_write32(core, D11REGOFFS(objaddr), sel | (offset >> 2)); 2901 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2912 2902 if (offset & 2) 2913 - v = R_REG(objdata_hi); 2914 - else 2915 - v = R_REG(objdata_lo); 2903 + objoff += 2; 2916 2904 2917 - return v; 2905 + return bcma_read16(core, objoff); 2906 + ; 2918 2907 } 2919 2908 2920 2909 static void 2921 2910 brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, 2922 2911 u32 sel) 2923 2912 { 2924 - struct d11regs __iomem *regs = wlc_hw->regs; 2925 - u16 __iomem *objdata_lo = (u16 __iomem *)&regs->objdata; 2926 - u16 __iomem *objdata_hi = objdata_lo + 1; 2913 + struct bcma_device *core = wlc_hw->d11core; 2914 + u16 objoff = D11REGOFFS(objdata); 2927 2915 2928 - W_REG(&regs->objaddr, sel | (offset >> 2)); 2929 - (void)R_REG(&regs->objaddr); 2916 + bcma_write32(core, D11REGOFFS(objaddr), sel | (offset >> 2)); 2917 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 2930 2918 if (offset & 2) 2931 - W_REG(objdata_hi, v); 2932 - else 2933 - W_REG(objdata_lo, v); 2919 + objoff += 2; 2920 + 2921 + bcma_write16(core, objoff, v); 2934 2922 } 2935 2923 2936 2924 /* ··· 3012 3008 3013 3009 /* write retry limit to SCR, shouldn't need to suspend */ 3014 3010 if (wlc_hw->up) { 3015 - W_REG(&wlc_hw->regs->objaddr, 3016 - OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); 3017 - (void)R_REG(&wlc_hw->regs->objaddr); 3018 - W_REG(&wlc_hw->regs->objdata, wlc_hw->SRL); 3019 - W_REG(&wlc_hw->regs->objaddr, 3020 - OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); 3021 - (void)R_REG(&wlc_hw->regs->objaddr); 3022 - W_REG(&wlc_hw->regs->objdata, wlc_hw->LRL); 3011 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), 3012 + OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); 3013 + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); 3014 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->SRL); 3015 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), 3016 + OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); 3017 + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); 3018 + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->LRL); 3023 3019 } 3024 3020 } 3025 3021 ··· 3201 3197 static void brcms_b_coreinit(struct brcms_c_info *wlc) 3202 3198 { 3203 3199 struct brcms_hardware *wlc_hw = wlc->hw; 3204 - struct d11regs __iomem *regs; 3200 + struct bcma_device *core = wlc_hw->d11core; 3205 3201 u32 sflags; 3206 - uint bcnint_us; 3202 + u32 bcnint_us; 3207 3203 uint i = 0; 3208 3204 bool fifosz_fixup = false; 3209 3205 int err = 0; 3210 3206 u16 buf[NFIFO]; 3211 3207 struct wiphy *wiphy = wlc->wiphy; 3212 3208 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; 3213 - 3214 - regs = wlc_hw->regs; 3215 3209 3216 3210 BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); 3217 3211 ··· 3223 3221 fifosz_fixup = true; 3224 3222 3225 3223 /* let the PSM run to the suspended state, set mode to BSS STA */ 3226 - W_REG(&regs->macintstatus, -1); 3224 + bcma_write32(core, D11REGOFFS(macintstatus), -1); 3227 3225 brcms_b_mctrl(wlc_hw, ~0, 3228 3226 (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); 3229 3227 3230 3228 /* wait for ucode to self-suspend after auto-init */ 3231 - SPINWAIT(((R_REG(&regs->macintstatus) & MI_MACSSPNDD) == 0), 3232 - 1000 * 1000); 3233 - if ((R_REG(&regs->macintstatus) & MI_MACSSPNDD) == 0) 3229 + SPINWAIT(((bcma_read32(core, D11REGOFFS(macintstatus)) & 3230 + MI_MACSSPNDD) == 0), 1000 * 1000); 3231 + if ((bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD) == 0) 3234 3232 wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" 3235 3233 "suspend!\n", wlc_hw->unit); 3236 3234 ··· 3300 3298 wlc_hw->xmtfifo_sz[i], i); 3301 3299 3302 3300 /* make sure we can still talk to the mac */ 3303 - WARN_ON(R_REG(&regs->maccontrol) == 0xffffffff); 3301 + WARN_ON(bcma_read32(core, D11REGOFFS(maccontrol)) == 0xffffffff); 3304 3302 3305 3303 /* band-specific inits done by wlc_bsinit() */ 3306 3304 ··· 3309 3307 brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); 3310 3308 3311 3309 /* enable one rx interrupt per received frame */ 3312 - W_REG(&regs->intrcvlazy[0], (1 << IRL_FC_SHIFT)); 3310 + bcma_write32(core, D11REGOFFS(intrcvlazy[0]), (1 << IRL_FC_SHIFT)); 3313 3311 3314 3312 /* set the station mode (BSS STA) */ 3315 3313 brcms_b_mctrl(wlc_hw, ··· 3318 3316 3319 3317 /* set up Beacon interval */ 3320 3318 bcnint_us = 0x8000 << 10; 3321 - W_REG(&regs->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); 3322 - W_REG(&regs->tsf_cfpstart, bcnint_us); 3323 - W_REG(&regs->macintstatus, MI_GP1); 3319 + bcma_write32(core, D11REGOFFS(tsf_cfprep), 3320 + (bcnint_us << CFPREP_CBI_SHIFT)); 3321 + bcma_write32(core, D11REGOFFS(tsf_cfpstart), bcnint_us); 3322 + bcma_write32(core, D11REGOFFS(macintstatus), MI_GP1); 3324 3323 3325 3324 /* write interrupt mask */ 3326 - W_REG(&regs->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); 3325 + bcma_write32(core, D11REGOFFS(intctrlregs[RX_FIFO].intmask), 3326 + DEF_RXINTMASK); 3327 3327 3328 3328 /* allow the MAC to control the PHY clock (dynamic on/off) */ 3329 3329 brcms_b_macphyclk_set(wlc_hw, ON); 3330 3330 3331 3331 /* program dynamic clock control fast powerup delay register */ 3332 3332 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); 3333 - W_REG(&regs->scc_fastpwrup_dly, wlc->fastpwrup_dly); 3333 + bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); 3334 3334 3335 3335 /* tell the ucode the corerev */ 3336 3336 brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); ··· 3345 3341 machwcap >> 16) & 0xffff)); 3346 3342 3347 3343 /* write retry limits to SCR, this done after PSM init */ 3348 - W_REG(&regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); 3349 - (void)R_REG(&regs->objaddr); 3350 - W_REG(&regs->objdata, wlc_hw->SRL); 3351 - W_REG(&regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); 3352 - (void)R_REG(&regs->objaddr); 3353 - W_REG(&regs->objdata, wlc_hw->LRL); 3344 + bcma_write32(core, D11REGOFFS(objaddr), 3345 + OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); 3346 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 3347 + bcma_write32(core, D11REGOFFS(objdata), wlc_hw->SRL); 3348 + bcma_write32(core, D11REGOFFS(objaddr), 3349 + OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); 3350 + (void)bcma_read32(core, D11REGOFFS(objaddr)); 3351 + bcma_write32(core, D11REGOFFS(objdata), wlc_hw->LRL); 3354 3352 3355 3353 /* write rate fallback retry limits */ 3356 3354 brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); 3357 3355 brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); 3358 3356 3359 - AND_REG(&regs->ifs_ctl, 0x0FFF); 3360 - W_REG(&regs->ifs_aifsn, EDCF_AIFSN_MIN); 3357 + bcma_mask16(core, D11REGOFFS(ifs_ctl), 0x0FFF); 3358 + bcma_write16(core, D11REGOFFS(ifs_aifsn), EDCF_AIFSN_MIN); 3361 3359 3362 3360 /* init the tx dma engines */ 3363 3361 for (i = 0; i < NFIFO; i++) { ··· 3816 3810 3817 3811 BCMMSG(wlc->wiphy, "wl%d: hps %d\n", wlc->pub->unit, hps); 3818 3812 3819 - v1 = R_REG(&wlc->regs->maccontrol); 3813 + v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); 3820 3814 v2 = MCTL_WAKE; 3821 3815 if (hps) 3822 3816 v2 |= MCTL_HPS; ··· 4135 4129 acp_shm.cwmax = params->cw_max; 4136 4130 acp_shm.cwcur = acp_shm.cwmin; 4137 4131 acp_shm.bslots = 4138 - R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur; 4132 + bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & 4133 + acp_shm.cwcur; 4139 4134 acp_shm.reggap = acp_shm.bslots + acp_shm.aifs; 4140 4135 /* Indicate the new params to the ucode */ 4141 4136 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + ··· 4448 4441 uint unit, bool piomode) 4449 4442 { 4450 4443 struct brcms_hardware *wlc_hw; 4451 - struct d11regs __iomem *regs; 4452 4444 char *macaddr = NULL; 4453 4445 uint err = 0; 4454 4446 uint j; ··· 4496 4490 wlc_hw->deviceid = pcidev->device; 4497 4491 4498 4492 /* set bar0 window to point at D11 core */ 4499 - wlc_hw->regs = (struct d11regs __iomem *) 4500 - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); 4501 - wlc_hw->corerev = ai_corerev(wlc_hw->sih); 4502 - 4503 - regs = wlc_hw->regs; 4504 - 4505 - wlc->regs = wlc_hw->regs; 4493 + (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); 4494 + wlc_hw->d11core = core; 4495 + wlc_hw->corerev = core->id.rev; 4506 4496 4507 4497 /* validate chip, chiprev and corerev */ 4508 4498 if (!brcms_c_isgoodchip(wlc_hw)) { ··· 4619 4617 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; 4620 4618 wlc->core->coreidx = ai_coreidx(wlc_hw->sih); 4621 4619 4622 - wlc_hw->machwcap = R_REG(&regs->machwcap); 4620 + wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); 4623 4621 wlc_hw->machwcap_backup = wlc_hw->machwcap; 4624 4622 4625 4623 /* init tx fifo size */ ··· 4628 4626 4629 4627 /* Get a phy for this band */ 4630 4628 wlc_hw->band->pi = 4631 - wlc_phy_attach(wlc_hw->phy_sh, regs, 4629 + wlc_phy_attach(wlc_hw->phy_sh, core->bus->mmio, 4632 4630 wlc_hw->band->bandtype, 4633 4631 wlc->wiphy); 4634 4632 if (wlc_hw->band->pi == NULL) { ··· 5076 5074 */ 5077 5075 if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || 5078 5076 (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) 5079 - wlc_hw->regs = (struct d11regs __iomem *) 5080 - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); 5077 + (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); 5081 5078 5082 5079 /* 5083 5080 * Inform phy that a POR reset has occurred so ··· 5321 5320 5322 5321 /* Reset and disable the core */ 5323 5322 if (ai_iscoreup(wlc_hw->sih)) { 5324 - if (R_REG(&wlc_hw->regs->maccontrol) & 5325 - MCTL_EN_MAC) 5323 + if (bcma_read32(wlc_hw->d11core, 5324 + D11REGOFFS(maccontrol)) & MCTL_EN_MAC) 5326 5325 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); 5327 5326 callbacks += brcms_reset(wlc_hw->wlc->wl); 5328 5327 brcms_c_coredisable(wlc_hw); ··· 7479 7478 brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, 7480 7479 u32 *tsf_h_ptr) 7481 7480 { 7482 - struct d11regs __iomem *regs = wlc_hw->regs; 7481 + struct bcma_device *core = wlc_hw->d11core; 7483 7482 7484 7483 /* read the tsf timer low, then high to get an atomic read */ 7485 - *tsf_l_ptr = R_REG(&regs->tsf_timerlow); 7486 - *tsf_h_ptr = R_REG(&regs->tsf_timerhigh); 7484 + *tsf_l_ptr = bcma_read32(core, D11REGOFFS(tsf_timerlow)); 7485 + *tsf_h_ptr = bcma_read32(core, D11REGOFFS(tsf_timerhigh)); 7487 7486 } 7488 7487 7489 7488 /* ··· 8156 8155 { 8157 8156 u32 macintstatus; 8158 8157 struct brcms_hardware *wlc_hw = wlc->hw; 8159 - struct d11regs __iomem *regs = wlc_hw->regs; 8158 + struct bcma_device *core = wlc_hw->d11core; 8160 8159 struct wiphy *wiphy = wlc->wiphy; 8161 8160 8162 8161 if (brcms_deviceremoved(wlc)) { ··· 8192 8191 /* ATIM window end */ 8193 8192 if (macintstatus & MI_ATIMWINEND) { 8194 8193 BCMMSG(wlc->wiphy, "end of ATIM window\n"); 8195 - OR_REG(&regs->maccommand, wlc->qvalid); 8194 + bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); 8196 8195 wlc->qvalid = 0; 8197 8196 } 8198 8197 ··· 8220 8219 8221 8220 /* gptimer timeout */ 8222 8221 if (macintstatus & MI_TO) 8223 - W_REG(&regs->gptimer, 0); 8222 + bcma_write32(core, D11REGOFFS(gptimer), 0); 8224 8223 8225 8224 if (macintstatus & MI_RFDISABLE) { 8226 8225 BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the" ··· 8242 8241 8243 8242 void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) 8244 8243 { 8245 - struct d11regs __iomem *regs; 8244 + struct bcma_device *core = wlc->hw->d11core; 8246 8245 u16 chanspec; 8247 8246 8248 8247 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); 8249 - 8250 - regs = wlc->regs; 8251 8248 8252 8249 /* 8253 8250 * This will happen if a big-hammer was executed. In ··· 8276 8277 * update since init path would reset 8277 8278 * to default value 8278 8279 */ 8279 - W_REG(&regs->tsf_cfprep, 8280 - (bi << CFPREP_CBI_SHIFT)); 8280 + bcma_write32(core, D11REGOFFS(tsf_cfprep), 8281 + bi << CFPREP_CBI_SHIFT); 8281 8282 8282 8283 /* Update maccontrol PM related bits */ 8283 8284 brcms_c_set_ps_ctrl(wlc); ··· 8307 8308 brcms_c_bsinit(wlc); 8308 8309 8309 8310 /* Enable EDCF mode (while the MAC is suspended) */ 8310 - OR_REG(&regs->ifs_ctl, IFS_USEEDCF); 8311 + bcma_set16(core, D11REGOFFS(ifs_ctl), IFS_USEEDCF); 8311 8312 brcms_c_edcf_setparams(wlc, false); 8312 8313 8313 8314 /* Init precedence maps for empty FIFOs */ ··· 8331 8332 brcms_c_txflowcontrol_reset(wlc); 8332 8333 8333 8334 /* enable the RF Disable Delay timer */ 8334 - W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); 8335 + bcma_write32(core, D11REGOFFS(rfdisabledly), RFDISABLE_DEFAULT); 8335 8336 8336 8337 /* 8337 8338 * Initialize WME parameters; if they haven't been set by some other
+1 -3
drivers/net/wireless/brcm80211/brcmsmac/main.h
··· 334 334 u32 machwcap_backup; /* backup of machwcap */ 335 335 336 336 struct si_pub *sih; /* SI handle (cookie for siutils calls) */ 337 - struct d11regs __iomem *regs; /* pointer to device registers */ 337 + struct bcma_device *d11core; /* pointer to 802.11 core */ 338 338 struct phy_shim_info *physhim; /* phy shim layer handler */ 339 339 struct shared_phy *phy_sh; /* pointer to shared phy state */ 340 340 struct brcms_hw_band *band;/* pointer to active per-band state */ ··· 400 400 * 401 401 * pub: pointer to driver public state. 402 402 * wl: pointer to specific private state. 403 - * regs: pointer to device registers. 404 403 * hw: HW related state. 405 404 * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1. 406 405 * fastpwrup_dly: time in us needed to bring up d11 fast clock. ··· 476 477 struct brcms_c_info { 477 478 struct brcms_pub *pub; 478 479 struct brcms_info *wl; 479 - struct d11regs __iomem *regs; 480 480 struct brcms_hardware *hw; 481 481 482 482 /* clock */