Lines Matching refs:wlc_hw

594 static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw,  in brcms_b_update_slot_timing()  argument
597 struct bcma_device *core = wlc_hw->d11core; in brcms_b_update_slot_timing()
602 brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, APHY_SLOT_TIME); in brcms_b_update_slot_timing()
606 brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, BPHY_SLOT_TIME); in brcms_b_update_slot_timing()
679 static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, in brcms_c_write_inits() argument
682 struct bcma_device *core = wlc_hw->d11core; in brcms_c_write_inits()
688 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_write_inits()
703 static void brcms_c_write_mhf(struct brcms_hardware *wlc_hw, u16 *mhfs) in brcms_c_write_mhf() argument
712 brcms_b_write_shm(wlc_hw, addr[idx], mhfs[idx]); in brcms_c_write_mhf()
715 static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) in brcms_c_ucode_bsinit() argument
717 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_c_ucode_bsinit()
720 brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); in brcms_c_ucode_bsinit()
723 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_c_ucode_bsinit()
724 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
725 brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16); in brcms_c_ucode_bsinit()
727 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
729 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
730 wlc_hw->corerev); in brcms_c_ucode_bsinit()
732 if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_c_ucode_bsinit()
733 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
734 brcms_c_write_inits(wlc_hw, in brcms_c_ucode_bsinit()
737 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
739 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
740 wlc_hw->corerev); in brcms_c_ucode_bsinit()
742 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
744 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_c_ucode_bsinit()
749 static void brcms_b_core_ioctl(struct brcms_hardware *wlc_hw, u32 m, u32 v) in brcms_b_core_ioctl() argument
751 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_ioctl()
757 static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) in brcms_b_core_phy_clk() argument
759 brcms_dbg_info(wlc_hw->d11core, "wl%d: clk %d\n", wlc_hw->unit, clk); in brcms_b_core_phy_clk()
761 wlc_hw->phyclk = clk; in brcms_b_core_phy_clk()
765 brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_FGC | SICF_GMODE), in brcms_b_core_phy_clk()
768 brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_FGC), SICF_PRST); in brcms_b_core_phy_clk()
773 brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_FGC), SICF_FGC); in brcms_b_core_phy_clk()
775 brcms_b_core_ioctl(wlc_hw, SICF_FGC, 0); in brcms_b_core_phy_clk()
782 static void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit) in brcms_c_setxband() argument
784 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_setxband()
787 wlc_hw->band = wlc_hw->bandstate[bandunit]; in brcms_c_setxband()
793 wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; in brcms_c_setxband()
796 if (wlc_hw->sbclk && !wlc_hw->noreset) { in brcms_c_setxband()
802 brcms_b_core_ioctl(wlc_hw, SICF_GMODE, gmode); in brcms_c_setxband()
809 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_setband_inact() local
813 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_setband_inact()
814 macctrl = bcma_read32(wlc_hw->d11core, in brcms_c_setband_inact()
822 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_setband_inact()
824 brcms_b_core_phy_clk(wlc_hw, OFF); in brcms_c_setband_inact()
826 brcms_c_setxband(wlc_hw, bandunit); in brcms_c_setband_inact()
1030 brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) in brcms_b_txstatus() argument
1043 core = wlc_hw->d11core; in brcms_b_txstatus()
1049 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_b_txstatus()
1065 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1088 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef() local
1095 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_c_mhfdef()
1098 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { in brcms_c_mhfdef()
1120 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio() local
1121 uint unit = wlc_hw->unit; in brcms_b_attach_dmapio()
1126 if (wlc_hw->di[0] == NULL) { /* Init FIFOs */ in brcms_b_attach_dmapio()
1134 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1140 dma_attach_err |= (NULL == wlc_hw->di[0]); in brcms_b_attach_dmapio()
1148 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1151 dma_attach_err |= (NULL == wlc_hw->di[1]); in brcms_b_attach_dmapio()
1158 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1161 dma_attach_err |= (NULL == wlc_hw->di[2]); in brcms_b_attach_dmapio()
1167 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1171 dma_attach_err |= (NULL == wlc_hw->di[3]); in brcms_b_attach_dmapio()
1175 brcms_err(wlc_hw->d11core, in brcms_b_attach_dmapio()
1183 if (wlc_hw->di[i]) in brcms_b_attach_dmapio()
1184 wlc_hw->txavail[i] = in brcms_b_attach_dmapio()
1185 (uint *) dma_getvar(wlc_hw->di[i], in brcms_b_attach_dmapio()
1190 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1195 static void brcms_b_detach_dmapio(struct brcms_hardware *wlc_hw) in brcms_b_detach_dmapio() argument
1200 if (wlc_hw->di[j]) { in brcms_b_detach_dmapio()
1201 dma_detach(wlc_hw->di[j]); in brcms_b_detach_dmapio()
1202 wlc_hw->di[j] = NULL; in brcms_b_detach_dmapio()
1212 static void brcms_b_info_init(struct brcms_hardware *wlc_hw) in brcms_b_info_init() argument
1214 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init()
1220 wlc_hw->shortslot = false; in brcms_b_info_init()
1222 wlc_hw->SFBL = RETRY_SHORT_FB; in brcms_b_info_init()
1223 wlc_hw->LFBL = RETRY_LONG_FB; in brcms_b_info_init()
1226 wlc_hw->SRL = RETRY_SHORT_DEF; in brcms_b_info_init()
1227 wlc_hw->LRL = RETRY_LONG_DEF; in brcms_b_info_init()
1228 wlc_hw->chanspec = ch20mhz_chspec(1); in brcms_b_info_init()
1231 static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) in brcms_b_wait_for_wake() argument
1237 SPINWAIT((brcms_b_read_shm(wlc_hw, M_UCODE_DBGST) == in brcms_b_wait_for_wake()
1238 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1242 static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, enum bcma_clkmode mode) in brcms_b_clkctl_clk() argument
1244 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) { in brcms_b_clkctl_clk()
1251 if (wlc_hw->clk) { in brcms_b_clkctl_clk()
1253 bcma_set32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1260 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1264 WARN_ON(!(bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1268 if ((ai_get_pmurev(wlc_hw->sih) == 0) && in brcms_b_clkctl_clk()
1269 (bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1273 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1278 bcma_mask32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1283 wlc_hw->forcefastclk = (mode == BCMA_CLKMODE_FAST); in brcms_b_clkctl_clk()
1290 wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); in brcms_b_clkctl_clk()
1293 if (wlc_hw->forcefastclk && wlc_hw->clk) in brcms_b_clkctl_clk()
1294 WARN_ON(!(bcma_aread32(wlc_hw->d11core, BCMA_IOST) & in brcms_b_clkctl_clk()
1307 if (wlc_hw->forcefastclk) in brcms_b_clkctl_clk()
1308 mboolset(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1311 mboolclr(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1328 brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val, in brcms_b_mhf() argument
1347 band = wlc_hw->band; in brcms_b_mhf()
1350 band = wlc_hw->bandstate[BAND_5G_INDEX]; in brcms_b_mhf()
1353 band = wlc_hw->bandstate[BAND_2G_INDEX]; in brcms_b_mhf()
1366 if (wlc_hw->clk && (band->mhfs[idx] != save) in brcms_b_mhf()
1367 && (band == wlc_hw->band)) in brcms_b_mhf()
1368 brcms_b_write_shm(wlc_hw, addr[idx], in brcms_b_mhf()
1373 wlc_hw->bandstate[0]->mhfs[idx] = in brcms_b_mhf()
1374 (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1375 wlc_hw->bandstate[1]->mhfs[idx] = in brcms_b_mhf()
1376 (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1383 static void brcms_c_mctrl_reset(struct brcms_hardware *wlc_hw) in brcms_c_mctrl_reset() argument
1386 wlc_hw->maccontrol = 0; in brcms_c_mctrl_reset()
1387 wlc_hw->suspended_fifos = 0; in brcms_c_mctrl_reset()
1388 wlc_hw->wake_override = 0; in brcms_c_mctrl_reset()
1389 wlc_hw->mute_override = 0; in brcms_c_mctrl_reset()
1390 brcms_b_mctrl(wlc_hw, ~0, MCTL_IHR_EN | MCTL_WAKE); in brcms_c_mctrl_reset()
1397 static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) in brcms_c_mctrl_write() argument
1399 u32 maccontrol = wlc_hw->maccontrol; in brcms_c_mctrl_write()
1402 if (wlc_hw->wake_override) in brcms_c_mctrl_write()
1406 if (wlc_hw->mute_override) { in brcms_c_mctrl_write()
1411 bcma_write32(wlc_hw->d11core, D11REGOFFS(maccontrol), in brcms_c_mctrl_write()
1416 void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val) in brcms_b_mctrl() argument
1423 maccontrol = wlc_hw->maccontrol; in brcms_b_mctrl()
1431 wlc_hw->maccontrol = new_maccontrol; in brcms_b_mctrl()
1434 brcms_c_mctrl_write(wlc_hw); in brcms_b_mctrl()
1437 void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw, in brcms_c_ucode_wake_override_set() argument
1440 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { in brcms_c_ucode_wake_override_set()
1441 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1445 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1447 brcms_c_mctrl_write(wlc_hw); in brcms_c_ucode_wake_override_set()
1448 brcms_b_wait_for_wake(wlc_hw); in brcms_c_ucode_wake_override_set()
1451 void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw, in brcms_c_ucode_wake_override_clear() argument
1454 mboolclr(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_clear()
1456 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) in brcms_c_ucode_wake_override_clear()
1459 brcms_c_mctrl_write(wlc_hw); in brcms_c_ucode_wake_override_clear()
1469 static void brcms_c_ucode_mute_override_set(struct brcms_hardware *wlc_hw) in brcms_c_ucode_mute_override_set() argument
1471 wlc_hw->mute_override = 1; in brcms_c_ucode_mute_override_set()
1476 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_set()
1479 brcms_c_mctrl_write(wlc_hw); in brcms_c_ucode_mute_override_set()
1483 static void brcms_c_ucode_mute_override_clear(struct brcms_hardware *wlc_hw) in brcms_c_ucode_mute_override_clear() argument
1485 if (wlc_hw->mute_override == 0) in brcms_c_ucode_mute_override_clear()
1488 wlc_hw->mute_override = 0; in brcms_c_ucode_mute_override_clear()
1493 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_clear()
1496 brcms_c_mctrl_write(wlc_hw); in brcms_c_ucode_mute_override_clear()
1503 brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, in brcms_b_set_addrmatch() argument
1506 struct bcma_device *core = wlc_hw->d11core; in brcms_b_set_addrmatch()
1511 brcms_dbg_rx(core, "wl%d: brcms_b_set_addrmatch\n", wlc_hw->unit); in brcms_b_set_addrmatch()
1526 brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, in brcms_b_write_template_ram() argument
1529 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_template_ram()
1534 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_write_template_ram()
1562 static void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) in brcms_b_set_cwmin() argument
1564 wlc_hw->band->CWmin = newmin; in brcms_b_set_cwmin()
1566 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmin()
1568 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmin()
1569 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmin); in brcms_b_set_cwmin()
1572 static void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) in brcms_b_set_cwmax() argument
1574 wlc_hw->band->CWmax = newmax; in brcms_b_set_cwmax()
1576 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmax()
1578 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmax()
1579 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmax); in brcms_b_set_cwmax()
1582 void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) in brcms_b_bw_set() argument
1587 fastclk = wlc_hw->forcefastclk; in brcms_b_bw_set()
1589 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_bw_set()
1591 wlc_phy_bw_state_set(wlc_hw->band->pi, bw); in brcms_b_bw_set()
1593 brcms_b_phy_reset(wlc_hw); in brcms_b_bw_set()
1594 wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); in brcms_b_bw_set()
1598 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC); in brcms_b_bw_set()
1601 static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw) in brcms_b_upd_synthpu() argument
1604 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu()
1614 brcms_b_write_shm(wlc_hw, M_SYNTHPU_DLY, v); in brcms_b_upd_synthpu()
1617 static void brcms_c_ucode_txant_set(struct brcms_hardware *wlc_hw) in brcms_c_ucode_txant_set() argument
1620 u16 phytxant = wlc_hw->bmac_phytxant; in brcms_c_ucode_txant_set()
1624 phyctl = brcms_b_read_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS); in brcms_c_ucode_txant_set()
1626 brcms_b_write_shm(wlc_hw, M_CTXPRS_BLK + C_CTX_PCTLWD_POS, phyctl); in brcms_c_ucode_txant_set()
1629 phyctl = brcms_b_read_shm(wlc_hw, M_RSP_PCTLWD); in brcms_c_ucode_txant_set()
1631 brcms_b_write_shm(wlc_hw, M_RSP_PCTLWD, phyctl); in brcms_c_ucode_txant_set()
1634 static u16 brcms_b_ofdm_ratetable_offset(struct brcms_hardware *wlc_hw, in brcms_b_ofdm_ratetable_offset() argument
1665 return 2 * brcms_b_read_shm(wlc_hw, M_RT_DIRMAP_A + (plcp_rate * 2)); in brcms_b_ofdm_ratetable_offset()
1668 static void brcms_upd_ofdm_pctl1_table(struct brcms_hardware *wlc_hw) in brcms_upd_ofdm_pctl1_table() argument
1679 if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_upd_ofdm_pctl1_table()
1686 entry_ptr = brcms_b_ofdm_ratetable_offset(wlc_hw, rate); in brcms_upd_ofdm_pctl1_table()
1690 brcms_b_read_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS); in brcms_upd_ofdm_pctl1_table()
1694 pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); in brcms_upd_ofdm_pctl1_table()
1697 brcms_b_write_shm(wlc_hw, entry_ptr + M_RT_OFDM_PCTL1_POS, in brcms_upd_ofdm_pctl1_table()
1705 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit() local
1707 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_b_bsinit()
1708 wlc_hw->band->bandunit); in brcms_b_bsinit()
1710 brcms_c_ucode_bsinit(wlc_hw); in brcms_b_bsinit()
1712 wlc_phy_init(wlc_hw->band->pi, chanspec); in brcms_b_bsinit()
1714 brcms_c_ucode_txant_set(wlc_hw); in brcms_b_bsinit()
1720 brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); in brcms_b_bsinit()
1721 brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); in brcms_b_bsinit()
1723 brcms_b_update_slot_timing(wlc_hw, in brcms_b_bsinit()
1724 wlc_hw->band->bandtype == BRCM_BAND_5G ? in brcms_b_bsinit()
1725 true : wlc_hw->shortslot); in brcms_b_bsinit()
1728 brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); in brcms_b_bsinit()
1729 brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); in brcms_b_bsinit()
1735 brcms_upd_ofdm_pctl1_table(wlc_hw); in brcms_b_bsinit()
1737 brcms_b_upd_synthpu(wlc_hw); in brcms_b_bsinit()
1741 void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) in brcms_b_core_phypll_reset() argument
1743 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr), in brcms_b_core_phypll_reset()
1746 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1749 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1752 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1760 void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk) in brcms_b_phyclk_fgc() argument
1763 if (!BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_phyclk_fgc()
1767 brcms_b_core_ioctl(wlc_hw, SICF_FGC, SICF_FGC); in brcms_b_phyclk_fgc()
1769 brcms_b_core_ioctl(wlc_hw, SICF_FGC, 0); in brcms_b_phyclk_fgc()
1773 void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk) in brcms_b_macphyclk_set() argument
1776 brcms_b_core_ioctl(wlc_hw, SICF_MPCLKE, SICF_MPCLKE); in brcms_b_macphyclk_set()
1778 brcms_b_core_ioctl(wlc_hw, SICF_MPCLKE, 0); in brcms_b_macphyclk_set()
1781 void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) in brcms_b_phy_reset() argument
1783 struct brcms_phy_pub *pih = wlc_hw->band->pi; in brcms_b_phy_reset()
1787 brcms_dbg_info(wlc_hw->d11core, "wl%d: reset phy\n", wlc_hw->unit); in brcms_b_phy_reset()
1792 phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); in brcms_b_phy_reset()
1795 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && in brcms_b_phy_reset()
1796 NREV_LE(wlc_hw->band->phyrev, 4)) { in brcms_b_phy_reset()
1798 brcms_b_core_ioctl(wlc_hw, SICF_BWMASK, phy_bw_clkbits); in brcms_b_phy_reset()
1803 brcms_b_core_phypll_reset(wlc_hw); in brcms_b_phy_reset()
1806 brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_PCLKE), in brcms_b_phy_reset()
1810 brcms_b_core_ioctl(wlc_hw, in brcms_b_phy_reset()
1816 brcms_b_core_phy_clk(wlc_hw, ON); in brcms_b_phy_reset()
1823 static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, in brcms_b_setband() argument
1825 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband()
1829 if (!bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_setband()
1830 bcma_core_enable(wlc_hw->d11core, 0); in brcms_b_setband()
1831 brcms_c_mctrl_reset(wlc_hw); in brcms_b_setband()
1836 if (!wlc_hw->up) in brcms_b_setband()
1839 brcms_b_core_phy_clk(wlc_hw, ON); in brcms_b_setband()
1856 WARN_ON((bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & in brcms_b_setband()
1860 static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) in brcms_c_isgoodchip() argument
1864 if (!CONF_HAS(D11CONF, wlc_hw->corerev)) { in brcms_c_isgoodchip()
1865 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
1866 wlc_hw->corerev); in brcms_c_isgoodchip()
1874 static bool brcms_c_validboardtype(struct brcms_hardware *wlc_hw) in brcms_c_validboardtype() argument
1876 uint boardrev = wlc_hw->boardrev; in brcms_c_validboardtype()
1885 if (ai_get_boardvendor(wlc_hw->sih) != PCI_VENDOR_ID_BROADCOM) in brcms_c_validboardtype()
1902 static void brcms_c_get_macaddr(struct brcms_hardware *wlc_hw, u8 etheraddr[ETH_ALEN]) in brcms_c_get_macaddr() argument
1904 struct ssb_sprom *sprom = &wlc_hw->d11core->bus->sprom; in brcms_c_get_macaddr()
1912 if (wlc_hw->_nbands > 1) in brcms_c_get_macaddr()
1919 static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) in brcms_b_xtal() argument
1921 brcms_dbg_info(wlc_hw->d11core, "wl%d: want %d\n", wlc_hw->unit, want); in brcms_b_xtal()
1927 if (!want && wlc_hw->pllreq) in brcms_b_xtal()
1930 wlc_hw->sbclk = want; in brcms_b_xtal()
1931 if (!wlc_hw->sbclk) { in brcms_b_xtal()
1932 wlc_hw->clk = false; in brcms_b_xtal()
1933 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_xtal()
1934 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_xtal()
1944 static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) in brcms_b_radio_read_hwdisabled() argument
1949 xtal = wlc_hw->sbclk; in brcms_b_radio_read_hwdisabled()
1951 brcms_b_xtal(wlc_hw, ON); in brcms_b_radio_read_hwdisabled()
1954 clk = wlc_hw->clk; in brcms_b_radio_read_hwdisabled()
1961 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_radio_read_hwdisabled()
1971 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_radio_read_hwdisabled()
1972 brcms_c_mctrl_reset(wlc_hw); in brcms_b_radio_read_hwdisabled()
1975 v = ((bcma_read32(wlc_hw->d11core, in brcms_b_radio_read_hwdisabled()
1980 bcma_core_disable(wlc_hw->d11core, 0); in brcms_b_radio_read_hwdisabled()
1983 brcms_b_xtal(wlc_hw, OFF); in brcms_b_radio_read_hwdisabled()
1988 static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) in wlc_dma_rxreset() argument
1990 struct dma_pub *di = wlc_hw->di[fifo]; in wlc_dma_rxreset()
2002 void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) in brcms_b_corereset() argument
2008 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); in brcms_b_corereset()
2010 brcms_dbg_info(wlc_hw->d11core, "wl%d: core reset\n", wlc_hw->unit); in brcms_b_corereset()
2013 fastclk = wlc_hw->forcefastclk; in brcms_b_corereset()
2015 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_corereset()
2018 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_corereset()
2020 if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) in brcms_b_corereset()
2021 brcms_err(wlc_hw->d11core, "wl%d: %s: " in brcms_b_corereset()
2023 wlc_hw->unit, __func__, i); in brcms_b_corereset()
2025 if ((wlc_hw->di[RX_FIFO]) in brcms_b_corereset()
2026 && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) in brcms_b_corereset()
2027 brcms_err(wlc_hw->d11core, "wl%d: %s: dma_rxreset" in brcms_b_corereset()
2029 wlc_hw->unit, __func__, RX_FIFO); in brcms_b_corereset()
2032 if (wlc_hw->noreset) { in brcms_b_corereset()
2033 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2034 brcms_b_mctrl(wlc_hw, MCTL_PSM_RUN | MCTL_EN_MAC, 0); in brcms_b_corereset()
2043 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_corereset()
2056 wlc_hw->clk = false; in brcms_b_corereset()
2057 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_corereset()
2058 wlc_hw->clk = true; in brcms_b_corereset()
2059 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_corereset()
2060 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); in brcms_b_corereset()
2062 brcms_c_mctrl_reset(wlc_hw); in brcms_b_corereset()
2064 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) in brcms_b_corereset()
2065 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_corereset()
2067 brcms_b_phy_reset(wlc_hw); in brcms_b_corereset()
2070 brcms_b_core_phypll_ctl(wlc_hw, true); in brcms_b_corereset()
2073 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2077 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC); in brcms_b_corereset()
2083 static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) in brcms_b_corerev_fifofixup() argument
2085 struct bcma_device *core = wlc_hw->d11core; in brcms_b_corerev_fifofixup()
2097 txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2112 txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2118 brcms_b_write_shm(wlc_hw, M_FIFOSIZE0, in brcms_b_corerev_fifofixup()
2119 wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); in brcms_b_corerev_fifofixup()
2120 brcms_b_write_shm(wlc_hw, M_FIFOSIZE1, in brcms_b_corerev_fifofixup()
2121 wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); in brcms_b_corerev_fifofixup()
2122 brcms_b_write_shm(wlc_hw, M_FIFOSIZE2, in brcms_b_corerev_fifofixup()
2123 ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2125 brcms_b_write_shm(wlc_hw, M_FIFOSIZE3, in brcms_b_corerev_fifofixup()
2126 ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2143 void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) in brcms_b_switch_macfreq() argument
2145 struct bcma_device *core = wlc_hw->d11core; in brcms_b_switch_macfreq()
2147 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43224) || in brcms_b_switch_macfreq()
2148 (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) { in brcms_b_switch_macfreq()
2159 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_switch_macfreq()
2199 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init() local
2203 brcms_b_mctrl(wlc_hw, MCTL_GPOUT_SEL_MASK, 0); in brcms_c_gpio_init()
2216 if (wlc_hw->antsel_type == ANTSEL_2x3) { in brcms_c_gpio_init()
2218 brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, in brcms_c_gpio_init()
2220 brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, in brcms_c_gpio_init()
2224 wlc_phy_antsel_init(wlc_hw->band->pi, false); in brcms_c_gpio_init()
2226 } else if (wlc_hw->antsel_type == ANTSEL_2x4) { in brcms_c_gpio_init()
2232 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_oe), in brcms_c_gpio_init()
2234 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_out), in brcms_c_gpio_init()
2238 brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, in brcms_c_gpio_init()
2240 brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, 0, in brcms_c_gpio_init()
2244 brcms_b_write_shm(wlc_hw, M_ANTSEL_CLKDIV, in brcms_c_gpio_init()
2252 if (wlc_hw->boardflags & BFL_PACTRL) in brcms_c_gpio_init()
2256 bcma_chipco_gpio_control(&wlc_hw->d11core->bus->drv_cc, gm, gc); in brcms_c_gpio_init()
2259 static void brcms_ucode_write(struct brcms_hardware *wlc_hw, in brcms_ucode_write() argument
2262 struct bcma_device *core = wlc_hw->d11core; in brcms_ucode_write()
2266 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_ucode_write()
2278 static void brcms_ucode_download(struct brcms_hardware *wlc_hw) in brcms_ucode_download() argument
2281 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2283 wlc = wlc_hw->wlc; in brcms_ucode_download()
2285 if (wlc_hw->ucode_loaded) in brcms_ucode_download()
2288 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_ucode_download()
2289 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_ucode_download()
2290 brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, in brcms_ucode_download()
2292 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2294 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2296 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2297 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_ucode_download()
2298 if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_ucode_download()
2299 brcms_ucode_write(wlc_hw, ucode->bcm43xx_24_lcn, in brcms_ucode_download()
2301 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2303 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2305 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2310 void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant) in brcms_b_txant_set() argument
2313 wlc_hw->bmac_phytxant = phytxant; in brcms_b_txant_set()
2316 if (!wlc_hw->up) in brcms_b_txant_set()
2318 brcms_c_ucode_txant_set(wlc_hw); in brcms_b_txant_set()
2322 u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw) in brcms_b_get_txant() argument
2324 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2327 void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type) in brcms_b_antsel_type_set() argument
2329 wlc_hw->antsel_type = antsel_type; in brcms_b_antsel_type_set()
2332 wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); in brcms_b_antsel_type_set()
2335 static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) in brcms_b_fifoerrors() argument
2340 struct bcma_device *core = wlc_hw->d11core; in brcms_b_fifoerrors()
2342 unit = wlc_hw->unit; in brcms_b_fifoerrors()
2391 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2402 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson() local
2404 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2409 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff() local
2412 if (!wlc_hw->clk) in brcms_c_intrsoff()
2417 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), 0); in brcms_c_intrsoff()
2418 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(macintmask)); in brcms_c_intrsoff()
2428 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore() local
2429 if (!wlc_hw->clk) in brcms_c_intrsrestore()
2433 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2437 static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, in brcms_b_tx_fifo_suspend() argument
2445 if ((wlc_hw->suspended_fifos & fifo) == fifo) in brcms_b_tx_fifo_suspend()
2449 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_suspend()
2450 brcms_c_ucode_wake_override_set(wlc_hw, in brcms_b_tx_fifo_suspend()
2453 wlc_hw->suspended_fifos |= fifo; in brcms_b_tx_fifo_suspend()
2455 if (wlc_hw->di[tx_fifo]) { in brcms_b_tx_fifo_suspend()
2461 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2462 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2464 dma_txsuspend(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_suspend()
2466 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2467 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2471 static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, in brcms_b_tx_fifo_resume() argument
2479 if (wlc_hw->di[tx_fifo]) in brcms_b_tx_fifo_resume()
2480 dma_txresume(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_resume()
2483 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2486 wlc_hw->suspended_fifos &= ~(1 << tx_fifo); in brcms_b_tx_fifo_resume()
2487 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2488 brcms_c_ucode_wake_override_clear(wlc_hw, in brcms_b_tx_fifo_resume()
2494 static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool mute_tx) in brcms_b_mute() argument
2497 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2501 brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); in brcms_b_mute()
2502 brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); in brcms_b_mute()
2503 brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_BK_FIFO); in brcms_b_mute()
2504 brcms_b_tx_fifo_suspend(wlc_hw, TX_AC_VI_FIFO); in brcms_b_mute()
2507 brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, null_ether_addr); in brcms_b_mute()
2510 brcms_b_tx_fifo_resume(wlc_hw, TX_DATA_FIFO); in brcms_b_mute()
2511 brcms_b_tx_fifo_resume(wlc_hw, TX_CTL_FIFO); in brcms_b_mute()
2512 brcms_b_tx_fifo_resume(wlc_hw, TX_AC_BK_FIFO); in brcms_b_mute()
2513 brcms_b_tx_fifo_resume(wlc_hw, TX_AC_VI_FIFO); in brcms_b_mute()
2516 brcms_b_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, ethaddr); in brcms_b_mute()
2519 wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); in brcms_b_mute()
2522 brcms_c_ucode_mute_override_set(wlc_hw); in brcms_b_mute()
2524 brcms_c_ucode_mute_override_clear(wlc_hw); in brcms_b_mute()
2543 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus() local
2544 struct bcma_device *core = wlc_hw->d11core; in wlc_intstatus()
2618 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr() local
2621 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2628 brcms_err(wlc_hw->d11core, in brcms_c_isr()
2646 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait() local
2647 struct bcma_device *core = wlc_hw->d11core; in brcms_c_suspend_mac_and_wait()
2650 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2651 wlc_hw->band->bandunit); in brcms_c_suspend_mac_and_wait()
2656 wlc_hw->mac_suspend_depth++; in brcms_c_suspend_mac_and_wait()
2657 if (wlc_hw->mac_suspend_depth > 1) in brcms_c_suspend_mac_and_wait()
2661 brcms_c_ucode_wake_override_set(wlc_hw, BRCMS_WAKE_OVERRIDE_MACSUSPEND); in brcms_c_suspend_mac_and_wait()
2666 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2677 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2684 brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, 0); in brcms_c_suspend_mac_and_wait()
2692 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); in brcms_c_suspend_mac_and_wait()
2694 "psm_brc 0x%04x\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2702 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2714 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac() local
2715 struct bcma_device *core = wlc_hw->d11core; in brcms_c_enable_mac()
2718 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_enable_mac()
2724 wlc_hw->mac_suspend_depth--; in brcms_c_enable_mac()
2725 if (wlc_hw->mac_suspend_depth > 0) in brcms_c_enable_mac()
2733 brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC); in brcms_c_enable_mac()
2744 brcms_c_ucode_wake_override_clear(wlc_hw, in brcms_c_enable_mac()
2748 void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) in brcms_b_band_stf_ss_set() argument
2750 wlc_hw->hw_stf_ss_opmode = stf_mode; in brcms_b_band_stf_ss_set()
2752 if (wlc_hw->clk) in brcms_b_band_stf_ss_set()
2753 brcms_upd_ofdm_pctl1_table(wlc_hw); in brcms_b_band_stf_ss_set()
2756 static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) in brcms_b_validate_chip_access() argument
2758 struct bcma_device *core = wlc_hw->d11core; in brcms_b_validate_chip_access()
2760 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2778 "expected 0xaa5555aa\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2791 "expected 0x55aaaa55\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2806 "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, in brcms_b_validate_chip_access()
2817 void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) in brcms_b_core_phypll_ctl() argument
2819 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_phypll_ctl()
2822 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_core_phypll_ctl()
2827 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_core_phypll_ctl()
2870 static void brcms_c_coredisable(struct brcms_hardware *wlc_hw) in brcms_c_coredisable() argument
2874 brcms_dbg_info(wlc_hw->d11core, "wl%d: disable core\n", wlc_hw->unit); in brcms_c_coredisable()
2876 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2881 if (wlc_hw->noreset) in brcms_c_coredisable()
2885 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2888 wlc_phy_anacore(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2891 brcms_b_core_phypll_ctl(wlc_hw, false); in brcms_c_coredisable()
2893 wlc_hw->clk = false; in brcms_c_coredisable()
2894 bcma_core_disable(wlc_hw->d11core, 0); in brcms_c_coredisable()
2895 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_c_coredisable()
2900 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues() local
2905 if (wlc_hw->di[i]) { in brcms_c_flushqueues()
2906 dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); in brcms_c_flushqueues()
2914 dma_rxreclaim(wlc_hw->di[RX_FIFO]); in brcms_c_flushqueues()
2918 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) in brcms_b_read_objmem() argument
2920 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_objmem()
2932 brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, in brcms_b_write_objmem() argument
2935 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_objmem()
2950 u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset) in brcms_b_read_shm() argument
2952 return brcms_b_read_objmem(wlc_hw, offset, OBJADDR_SHM_SEL); in brcms_b_read_shm()
2959 void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v) in brcms_b_write_shm() argument
2961 brcms_b_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL); in brcms_b_write_shm()
2971 brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset, in brcms_b_copyto_objmem() argument
2983 brcms_b_write_objmem(wlc_hw, offset + i, v, sel); in brcms_b_copyto_objmem()
2994 brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset, void *buf, in brcms_b_copyfrom_objmem() argument
3005 v = brcms_b_read_objmem(wlc_hw, offset + i, sel); in brcms_b_copyfrom_objmem()
3021 static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, in brcms_b_retrylimit_upd() argument
3024 wlc_hw->SRL = SRL; in brcms_b_retrylimit_upd()
3025 wlc_hw->LRL = LRL; in brcms_b_retrylimit_upd()
3028 if (wlc_hw->up) { in brcms_b_retrylimit_upd()
3029 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3031 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3032 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_retrylimit_upd()
3033 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3035 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3036 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_retrylimit_upd()
3040 static void brcms_b_pllreq(struct brcms_hardware *wlc_hw, bool set, u32 req_bit) in brcms_b_pllreq() argument
3043 if (mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3046 mboolset(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3048 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3049 if (!wlc_hw->sbclk) in brcms_b_pllreq()
3050 brcms_b_xtal(wlc_hw, ON); in brcms_b_pllreq()
3053 if (!mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3056 mboolclr(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3058 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3059 if (wlc_hw->sbclk) in brcms_b_pllreq()
3060 brcms_b_xtal(wlc_hw, OFF); in brcms_b_pllreq()
3065 static void brcms_b_antsel_set(struct brcms_hardware *wlc_hw, u32 antsel_avail) in brcms_b_antsel_set() argument
3067 wlc_hw->antsel_avail = antsel_avail; in brcms_b_antsel_set()
3133 static void brcms_b_reset(struct brcms_hardware *wlc_hw) in brcms_b_reset() argument
3136 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3137 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); in brcms_b_reset()
3140 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3181 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit() local
3182 struct bcma_device *core = wlc_hw->d11core; in brcms_b_coreinit()
3189 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3191 brcms_dbg_info(core, "wl%d: core init\n", wlc_hw->unit); in brcms_b_coreinit()
3194 brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE)); in brcms_b_coreinit()
3196 brcms_ucode_download(wlc_hw); in brcms_b_coreinit()
3204 brcms_b_mctrl(wlc_hw, ~0, in brcms_b_coreinit()
3212 "suspend!\n", wlc_hw->unit); in brcms_b_coreinit()
3218 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_b_coreinit()
3219 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_coreinit()
3220 brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); in brcms_b_coreinit()
3223 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3224 wlc_hw->corerev); in brcms_b_coreinit()
3225 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_b_coreinit()
3226 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_b_coreinit()
3227 brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); in brcms_b_coreinit()
3230 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3231 wlc_hw->corerev); in brcms_b_coreinit()
3234 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_b_coreinit()
3239 brcms_b_corerev_fifofixup(wlc_hw); in brcms_b_coreinit()
3242 buf[TX_AC_BE_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE0); in brcms_b_coreinit()
3243 if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { in brcms_b_coreinit()
3247 buf[TX_AC_VI_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE1); in brcms_b_coreinit()
3248 if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { in brcms_b_coreinit()
3252 buf[TX_AC_BK_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE2); in brcms_b_coreinit()
3255 if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { in brcms_b_coreinit()
3259 if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { in brcms_b_coreinit()
3263 buf[TX_BCMC_FIFO] = brcms_b_read_shm(wlc_hw, M_FIFOSIZE3); in brcms_b_coreinit()
3266 if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { in brcms_b_coreinit()
3270 if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { in brcms_b_coreinit()
3277 wlc_hw->xmtfifo_sz[i], i); in brcms_b_coreinit()
3285 brcms_b_write_shm(wlc_hw, M_MBURST_SIZE, MAXTXFRAMEBURST); in brcms_b_coreinit()
3286 brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); in brcms_b_coreinit()
3292 brcms_b_mctrl(wlc_hw, in brcms_b_coreinit()
3308 brcms_b_macphyclk_set(wlc_hw, ON); in brcms_b_coreinit()
3311 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3315 brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); in brcms_b_coreinit()
3318 brcms_b_write_shm(wlc_hw, M_MACHW_CAP_L, in brcms_b_coreinit()
3319 (u16) (wlc_hw->machwcap & 0xffff)); in brcms_b_coreinit()
3320 brcms_b_write_shm(wlc_hw, M_MACHW_CAP_H, in brcms_b_coreinit()
3321 (u16) ((wlc_hw-> in brcms_b_coreinit()
3328 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_coreinit()
3332 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_coreinit()
3335 brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); in brcms_b_coreinit()
3336 brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); in brcms_b_coreinit()
3343 if (wlc_hw->di[i]) in brcms_b_coreinit()
3344 dma_txinit(wlc_hw->di[i]); in brcms_b_coreinit()
3348 dma_rxinit(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3349 dma_rxfill(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3353 static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec) { in brcms_b_init() argument
3356 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init()
3359 fastclk = wlc_hw->forcefastclk; in brcms_b_init()
3361 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_init()
3367 brcms_c_setxband(wlc_hw, chspec_bandunit(chanspec)); in brcms_b_init()
3368 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_init()
3371 wlc_phy_cal_init(wlc_hw->band->pi); in brcms_b_init()
3385 mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); in brcms_b_init()
3391 wlc_hw->mac_suspend_depth = 1; in brcms_b_init()
3395 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC); in brcms_b_init()
3809 static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot) in brcms_b_set_shortslot() argument
3811 wlc_hw->shortslot = shortslot; in brcms_b_set_shortslot()
3813 if (wlc_hw->band->bandtype == BRCM_BAND_2G && wlc_hw->up) { in brcms_b_set_shortslot()
3814 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3815 brcms_b_update_slot_timing(wlc_hw, shortslot); in brcms_b_set_shortslot()
3816 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3849 brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, in brcms_b_set_chanspec() argument
3854 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: 0x%x\n", wlc_hw->unit, in brcms_b_set_chanspec()
3857 wlc_hw->chanspec = chanspec; in brcms_b_set_chanspec()
3860 if (wlc_hw->_nbands > 1) { in brcms_b_set_chanspec()
3862 if (wlc_hw->band->bandunit != bandunit) { in brcms_b_set_chanspec()
3866 if (wlc_hw->up) { in brcms_b_set_chanspec()
3867 wlc_phy_chanspec_radio_set(wlc_hw-> in brcms_b_set_chanspec()
3870 brcms_b_setband(wlc_hw, bandunit, chanspec); in brcms_b_set_chanspec()
3872 brcms_c_setxband(wlc_hw, bandunit); in brcms_b_set_chanspec()
3877 wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); in brcms_b_set_chanspec()
3879 if (!wlc_hw->up) { in brcms_b_set_chanspec()
3880 if (wlc_hw->clk) in brcms_b_set_chanspec()
3881 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, in brcms_b_set_chanspec()
3883 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3885 wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3886 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); in brcms_b_set_chanspec()
3889 brcms_b_mute(wlc_hw, mute_tx); in brcms_b_set_chanspec()
4218 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog() local
4220 if (!wlc_hw->up) in brcms_b_watchdog()
4224 wlc_hw->now++; in brcms_b_watchdog()
4227 brcms_b_fifoerrors(wlc_hw); in brcms_b_watchdog()
4232 wlc_phy_watchdog(wlc_hw->band->pi); in brcms_b_watchdog()
4406 struct brcms_hardware *wlc_hw; in brcms_b_attach() local
4426 wlc_hw = wlc->hw; in brcms_b_attach()
4427 wlc_hw->wlc = wlc; in brcms_b_attach()
4428 wlc_hw->unit = unit; in brcms_b_attach()
4429 wlc_hw->band = wlc_hw->bandstate[0]; in brcms_b_attach()
4430 wlc_hw->_piomode = piomode; in brcms_b_attach()
4433 brcms_b_info_init(wlc_hw); in brcms_b_attach()
4439 wlc_hw->sih = ai_attach(core->bus); in brcms_b_attach()
4440 if (wlc_hw->sih == NULL) { in brcms_b_attach()
4456 wlc_hw->vendorid = pcidev->vendor; in brcms_b_attach()
4457 wlc_hw->deviceid = pcidev->device; in brcms_b_attach()
4459 wlc_hw->vendorid = core->bus->boardinfo.vendor; in brcms_b_attach()
4460 wlc_hw->deviceid = core->bus->boardinfo.type; in brcms_b_attach()
4463 wlc_hw->d11core = core; in brcms_b_attach()
4464 wlc_hw->corerev = core->id.rev; in brcms_b_attach()
4467 if (!brcms_c_isgoodchip(wlc_hw)) { in brcms_b_attach()
4473 ai_clkctl_init(wlc_hw->sih); in brcms_b_attach()
4481 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_attach()
4482 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); in brcms_b_attach()
4484 if (!brcms_b_validate_chip_access(wlc_hw)) { in brcms_b_attach()
4496 wlc_hw->boardrev = (u16) j; in brcms_b_attach()
4497 if (!brcms_c_validboardtype(wlc_hw)) { in brcms_b_attach()
4500 unit, ai_get_boardtype(wlc_hw->sih), in brcms_b_attach()
4501 wlc_hw->boardrev); in brcms_b_attach()
4505 wlc_hw->sromrev = sprom->revision; in brcms_b_attach()
4506 wlc_hw->boardflags = sprom->boardflags_lo + (sprom->boardflags_hi << 16); in brcms_b_attach()
4507 wlc_hw->boardflags2 = sprom->boardflags2_lo + (sprom->boardflags2_hi << 16); in brcms_b_attach()
4509 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_b_attach()
4510 brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED); in brcms_b_attach()
4513 if (wlc_hw->deviceid == BCM43224_D11N_ID || in brcms_b_attach()
4514 wlc_hw->deviceid == BCM43224_D11N_ID_VEN1 || in brcms_b_attach()
4515 wlc_hw->deviceid == BCM43224_CHIP_ID) in brcms_b_attach()
4517 wlc_hw->_nbands = 2; in brcms_b_attach()
4519 wlc_hw->_nbands = 1; in brcms_b_attach()
4521 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) in brcms_b_attach()
4522 wlc_hw->_nbands = 1; in brcms_b_attach()
4527 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4528 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4529 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4530 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4531 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4532 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4533 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4534 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4535 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4537 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4539 if (wlc_hw->physhim == NULL) { in brcms_b_attach()
4547 sha_params.sih = wlc_hw->sih; in brcms_b_attach()
4548 sha_params.physhim = wlc_hw->physhim; in brcms_b_attach()
4550 sha_params.corerev = wlc_hw->corerev; in brcms_b_attach()
4551 sha_params.vid = wlc_hw->vendorid; in brcms_b_attach()
4552 sha_params.did = wlc_hw->deviceid; in brcms_b_attach()
4553 sha_params.chip = ai_get_chip_id(wlc_hw->sih); in brcms_b_attach()
4554 sha_params.chiprev = ai_get_chiprev(wlc_hw->sih); in brcms_b_attach()
4555 sha_params.chippkg = ai_get_chippkg(wlc_hw->sih); in brcms_b_attach()
4556 sha_params.sromrev = wlc_hw->sromrev; in brcms_b_attach()
4557 sha_params.boardtype = ai_get_boardtype(wlc_hw->sih); in brcms_b_attach()
4558 sha_params.boardrev = wlc_hw->boardrev; in brcms_b_attach()
4559 sha_params.boardflags = wlc_hw->boardflags; in brcms_b_attach()
4560 sha_params.boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4563 wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); in brcms_b_attach()
4564 if (!wlc_hw->phy_sh) { in brcms_b_attach()
4570 for (j = 0; j < wlc_hw->_nbands; j++) { in brcms_b_attach()
4576 brcms_c_setxband(wlc_hw, j); in brcms_b_attach()
4578 wlc_hw->band->bandunit = j; in brcms_b_attach()
4579 wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4584 wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); in brcms_b_attach()
4585 wlc_hw->machwcap_backup = wlc_hw->machwcap; in brcms_b_attach()
4588 WARN_ON(wlc_hw->corerev < XMTFIFOTBL_STARTREV || in brcms_b_attach()
4589 (wlc_hw->corerev - XMTFIFOTBL_STARTREV) > in brcms_b_attach()
4591 wlc_hw->xmtfifo_sz = in brcms_b_attach()
4592 xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; in brcms_b_attach()
4593 WARN_ON(!wlc_hw->xmtfifo_sz[0]); in brcms_b_attach()
4596 wlc_hw->band->pi = in brcms_b_attach()
4597 wlc_phy_attach(wlc_hw->phy_sh, core, in brcms_b_attach()
4598 wlc_hw->band->bandtype, in brcms_b_attach()
4600 if (wlc_hw->band->pi == NULL) { in brcms_b_attach()
4607 wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); in brcms_b_attach()
4609 wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, in brcms_b_attach()
4610 &wlc_hw->band->phyrev, in brcms_b_attach()
4611 &wlc_hw->band->radioid, in brcms_b_attach()
4612 &wlc_hw->band->radiorev); in brcms_b_attach()
4613 wlc_hw->band->abgphy_encore = in brcms_b_attach()
4614 wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4615 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4616 wlc_hw->band->core_flags = in brcms_b_attach()
4617 wlc_phy_get_coreflags(wlc_hw->band->pi); in brcms_b_attach()
4620 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_b_attach()
4621 if (NCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4625 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_attach()
4626 if (LCNCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4634 wlc_hw->band->phytype, wlc_hw->band->phyrev); in brcms_b_attach()
4649 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4650 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4651 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4652 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4653 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4658 wlc_hw->band->CWmin = APHY_CWMIN; in brcms_b_attach()
4659 wlc_hw->band->CWmax = PHY_CWMAX; in brcms_b_attach()
4668 brcms_c_coredisable(wlc_hw); in brcms_b_attach()
4671 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_attach()
4674 brcms_b_xtal(wlc_hw, OFF); in brcms_b_attach()
4687 brcms_c_get_macaddr(wlc_hw, wlc_hw->etheraddr); in brcms_b_attach()
4689 if (is_broadcast_ether_addr(wlc_hw->etheraddr) || in brcms_b_attach()
4690 is_zero_ether_addr(wlc_hw->etheraddr)) { in brcms_b_attach()
4697 brcms_dbg_info(wlc_hw->d11core, "deviceid 0x%x nbands %d board 0x%x\n", in brcms_b_attach()
4698 wlc_hw->deviceid, wlc_hw->_nbands, in brcms_b_attach()
4699 ai_get_boardtype(wlc_hw->sih)); in brcms_b_attach()
4839 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach() local
4841 brcms_b_detach_dmapio(wlc_hw); in brcms_b_detach()
4843 band = wlc_hw->band; in brcms_b_detach()
4844 for (i = 0; i < wlc_hw->_nbands; i++) { in brcms_b_detach()
4850 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4854 kfree(wlc_hw->phy_sh); in brcms_b_detach()
4856 wlc_phy_shim_detach(wlc_hw->physhim); in brcms_b_detach()
4858 if (wlc_hw->sih) { in brcms_b_detach()
4859 ai_detach(wlc_hw->sih); in brcms_b_detach()
4860 wlc_hw->sih = NULL; in brcms_b_detach()
4906 static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) in brcms_b_hw_up() argument
4908 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4911 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_hw_up()
4917 brcms_b_xtal(wlc_hw, ON); in brcms_b_hw_up()
4918 ai_clkctl_init(wlc_hw->sih); in brcms_b_hw_up()
4919 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_hw_up()
4932 wlc_phy_por_inform(wlc_hw->band->pi); in brcms_b_hw_up()
4934 wlc_hw->ucode_loaded = false; in brcms_b_hw_up()
4935 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4937 if ((wlc_hw->boardflags & BFL_FEM) in brcms_b_hw_up()
4938 && (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_hw_up()
4940 (wlc_hw->boardrev >= 0x1250 in brcms_b_hw_up()
4941 && (wlc_hw->boardflags & BFL_FEM_BT))) in brcms_b_hw_up()
4942 ai_epa_4313war(wlc_hw->sih); in brcms_b_hw_up()
4946 static int brcms_b_up_prep(struct brcms_hardware *wlc_hw) in brcms_b_up_prep() argument
4948 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_up_prep()
4954 brcms_b_xtal(wlc_hw, ON); in brcms_b_up_prep()
4955 ai_clkctl_init(wlc_hw->sih); in brcms_b_up_prep()
4956 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_up_prep()
4962 bcma_host_pci_irq_ctl(wlc_hw->d11core->bus, wlc_hw->d11core, in brcms_b_up_prep()
4970 if (brcms_b_radio_read_hwdisabled(wlc_hw)) { in brcms_b_up_prep()
4972 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_up_prep()
4973 brcms_b_xtal(wlc_hw, OFF); in brcms_b_up_prep()
4977 bcma_host_pci_up(wlc_hw->d11core->bus); in brcms_b_up_prep()
4980 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); in brcms_b_up_prep()
4985 static int brcms_b_up_finish(struct brcms_hardware *wlc_hw) in brcms_b_up_finish() argument
4987 wlc_hw->up = true; in brcms_b_up_finish()
4988 wlc_phy_hw_state_upd(wlc_hw->band->pi, true); in brcms_b_up_finish()
4991 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC); in brcms_b_up_finish()
4992 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
5115 static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) in brcms_b_bmac_down_prep() argument
5120 if (!wlc_hw->up) in brcms_b_bmac_down_prep()
5123 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5127 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5130 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5133 brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST); in brcms_b_bmac_down_prep()
5136 callbacks += wlc_phy_down(wlc_hw->band->pi); in brcms_b_bmac_down_prep()
5141 static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) in brcms_b_down_finish() argument
5146 if (!wlc_hw->up) in brcms_b_down_finish()
5149 wlc_hw->up = false; in brcms_b_down_finish()
5150 wlc_phy_hw_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5152 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5155 wlc_hw->sbclk = false; in brcms_b_down_finish()
5156 wlc_hw->clk = false; in brcms_b_down_finish()
5157 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5160 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5164 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_down_finish()
5165 if (bcma_read32(wlc_hw->d11core, in brcms_b_down_finish()
5167 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5168 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5169 brcms_c_coredisable(wlc_hw); in brcms_b_down_finish()
5173 if (!wlc_hw->noreset) { in brcms_b_down_finish()
5174 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_down_finish()
5175 brcms_b_xtal(wlc_hw, OFF); in brcms_b_down_finish()
5688 u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) in brcms_b_rate_shm_offset() argument
5708 return 2 * brcms_b_read_shm(wlc_hw, table_ptr + (index * 2)); in brcms_b_rate_shm_offset()
7015 brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, in brcms_b_read_tsf() argument
7018 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_tsf()
7309 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write() local
7327 brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE, in brcms_c_beacon_write()
7331 brcms_b_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len); in brcms_c_beacon_write()
7335 brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE, in brcms_c_beacon_write()
7339 brcms_b_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len); in brcms_c_beacon_write()
7343 brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON, in brcms_c_beacon_write()
7345 brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, dtim_period); in brcms_c_beacon_write()
7347 brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON, in brcms_c_beacon_write()
7349 brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, 0); in brcms_c_beacon_write()
7357 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw() local
7358 struct bcma_device *core = wlc_hw->d11core; in brcms_c_update_beacon_hw()
7530 int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, in brcms_b_xmtfifo_sz_get() argument
7536 *blocks = wlc_hw->xmtfifo_sz[fifo]; in brcms_b_xmtfifo_sz_get()
7719 brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) in brcms_b_recv() argument
7737 morepending = dma_rx(wlc_hw->di[fifo], &recv_frames); in brcms_b_recv()
7742 dma_rxfill(wlc_hw->di[fifo]); in brcms_b_recv()
7766 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7779 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc() local
7780 struct bcma_device *core = wlc_hw->d11core; in brcms_c_dpc()
7783 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_dpc()
7794 wlc_hw->unit, macintstatus); in brcms_c_dpc()
7824 if (brcms_b_recv(wlc_hw, RX_FIFO, bounded)) in brcms_c_dpc()
7829 wlc_phy_noise_sample_intr(wlc_hw->band->pi); in brcms_c_dpc()
7833 "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); in brcms_c_dpc()
7836 __func__, ai_get_chip_id(wlc_hw->sih), in brcms_c_dpc()
7837 ai_get_chiprev(wlc_hw->sih)); in brcms_c_dpc()
7838 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7847 " RF Disable Input\n", wlc_hw->unit); in brcms_c_dpc()
7859 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()