Lines Matching +full:mixed +full:- +full:signals
3 * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
50 /* n-mode support capability */
82 #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1)
133 /* Per-AC retry limit register definitions; uses defs.h bitfield macros */
167 #define BRCMS_PLCP_AUTO -1
172 #define BRCMS_PROTECTION_AUTO -1
199 /* MSC in use,indicates b0-6 holds an mcs */
355 return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] in brcms_basic_rate()
357 return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; in brcms_basic_rate()
370 return band->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : in get_sifs()
378 * cause SB error if aphy is in reset on 4306B0-DB. Need a simple accessible
387 if (!wlc->hw->clk) in brcms_deviceremoved()
388 return ai_deviceremoved(wlc->hw->sih); in brcms_deviceremoved()
389 macctrl = bcma_read32(wlc->hw->d11core, in brcms_deviceremoved()
400 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_txpktpendtot()
401 if (wlc->hw->di[i]) in brcms_txpktpendtot()
402 pending += dma_txpending(wlc->hw->di[i]); in brcms_txpktpendtot()
408 return wlc->pub->_nbands > 1 && !wlc->bandlocked; in brcms_is_mband_unlocked()
426 kfree(cfg->current_bss); in brcms_c_bsscfg_mfree()
435 brcms_c_bsscfg_mfree(wlc->bsscfg); in brcms_c_detach_mfree()
436 kfree(wlc->pub); in brcms_c_detach_mfree()
437 kfree(wlc->modulecb); in brcms_c_detach_mfree()
438 kfree(wlc->default_bss); in brcms_c_detach_mfree()
439 kfree(wlc->protection); in brcms_c_detach_mfree()
440 kfree(wlc->stf); in brcms_c_detach_mfree()
441 kfree(wlc->bandstate[0]); in brcms_c_detach_mfree()
442 if (wlc->corestate) in brcms_c_detach_mfree()
443 kfree(wlc->corestate->macstat_snapshot); in brcms_c_detach_mfree()
444 kfree(wlc->corestate); in brcms_c_detach_mfree()
445 if (wlc->hw) in brcms_c_detach_mfree()
446 kfree(wlc->hw->bandstate[0]); in brcms_c_detach_mfree()
447 kfree(wlc->hw); in brcms_c_detach_mfree()
448 if (wlc->beacon) in brcms_c_detach_mfree()
449 dev_kfree_skb_any(wlc->beacon); in brcms_c_detach_mfree()
450 if (wlc->probe_resp) in brcms_c_detach_mfree()
451 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_detach_mfree()
464 cfg->current_bss = kzalloc(sizeof(*cfg->current_bss), GFP_ATOMIC); in brcms_c_bsscfg_malloc()
465 if (cfg->current_bss == NULL) in brcms_c_bsscfg_malloc()
487 wlc->pub = kzalloc(sizeof(*wlc->pub), GFP_ATOMIC); in brcms_c_attach_malloc()
488 if (wlc->pub == NULL) { in brcms_c_attach_malloc()
492 wlc->pub->wlc = wlc; in brcms_c_attach_malloc()
496 wlc->hw = kzalloc(sizeof(*wlc->hw), GFP_ATOMIC); in brcms_c_attach_malloc()
497 if (wlc->hw == NULL) { in brcms_c_attach_malloc()
501 wlc->hw->wlc = wlc; in brcms_c_attach_malloc()
503 wlc->hw->bandstate[0] = in brcms_c_attach_malloc()
505 if (wlc->hw->bandstate[0] == NULL) { in brcms_c_attach_malloc()
512 wlc->hw->bandstate[i] = (struct brcms_hw_band *) in brcms_c_attach_malloc()
513 ((unsigned long)wlc->hw->bandstate[0] + in brcms_c_attach_malloc()
517 wlc->modulecb = in brcms_c_attach_malloc()
520 if (wlc->modulecb == NULL) { in brcms_c_attach_malloc()
525 wlc->default_bss = kzalloc(sizeof(*wlc->default_bss), GFP_ATOMIC); in brcms_c_attach_malloc()
526 if (wlc->default_bss == NULL) { in brcms_c_attach_malloc()
531 wlc->bsscfg = brcms_c_bsscfg_malloc(unit); in brcms_c_attach_malloc()
532 if (wlc->bsscfg == NULL) { in brcms_c_attach_malloc()
537 wlc->protection = kzalloc(sizeof(*wlc->protection), GFP_ATOMIC); in brcms_c_attach_malloc()
538 if (wlc->protection == NULL) { in brcms_c_attach_malloc()
543 wlc->stf = kzalloc(sizeof(*wlc->stf), GFP_ATOMIC); in brcms_c_attach_malloc()
544 if (wlc->stf == NULL) { in brcms_c_attach_malloc()
549 wlc->bandstate[0] = in brcms_c_attach_malloc()
550 kcalloc(MAXBANDS, sizeof(*wlc->bandstate[0]), GFP_ATOMIC); in brcms_c_attach_malloc()
551 if (wlc->bandstate[0] == NULL) { in brcms_c_attach_malloc()
558 wlc->bandstate[i] = (struct brcms_band *) in brcms_c_attach_malloc()
559 ((unsigned long)wlc->bandstate[0] in brcms_c_attach_malloc()
563 wlc->corestate = kzalloc(sizeof(*wlc->corestate), GFP_ATOMIC); in brcms_c_attach_malloc()
564 if (wlc->corestate == NULL) { in brcms_c_attach_malloc()
569 wlc->corestate->macstat_snapshot = in brcms_c_attach_malloc()
570 kzalloc(sizeof(*wlc->corestate->macstat_snapshot), GFP_ATOMIC); in brcms_c_attach_malloc()
571 if (wlc->corestate->macstat_snapshot == NULL) { in brcms_c_attach_malloc()
591 struct bcma_device *core = wlc_hw->d11core; in brcms_b_update_slot_timing()
615 brcms_err(wlc->hw->d11core, "wl%d: WAR: using rate of 1 mbps\n", in brcms_c_calc_frame_time()
616 wlc->pub->unit); in brcms_c_calc_frame_time()
643 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
655 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
664 dur = (mac_len + rate - 1) / rate; in brcms_c_calc_frame_time()
676 struct bcma_device *core = wlc_hw->d11core; in brcms_c_write_inits()
682 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_write_inits()
711 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_c_ucode_bsinit()
714 brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); in brcms_c_ucode_bsinit()
716 /* do band-specific ucode IHR, SHM, and SCR inits */ in brcms_c_ucode_bsinit()
717 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_c_ucode_bsinit()
718 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
719 brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16); in brcms_c_ucode_bsinit()
721 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
723 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
724 wlc_hw->corerev); in brcms_c_ucode_bsinit()
726 if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_c_ucode_bsinit()
727 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
729 ucode->d11lcn0bsinitvals24); in brcms_c_ucode_bsinit()
731 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
733 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
734 wlc_hw->corerev); in brcms_c_ucode_bsinit()
736 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
738 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_c_ucode_bsinit()
745 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_ioctl()
753 brcms_dbg_info(wlc_hw->d11core, "wl%d: clk %d\n", wlc_hw->unit, clk); in brcms_b_core_phy_clk()
755 wlc_hw->phyclk = clk; in brcms_b_core_phy_clk()
775 /* low-level band switch utility routine */
778 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_setxband()
781 wlc_hw->band = wlc_hw->bandstate[bandunit]; in brcms_c_setxband()
785 * until we eliminate need for wlc->band refs in low level code in brcms_c_setxband()
787 wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; in brcms_c_setxband()
790 if (wlc_hw->sbclk && !wlc_hw->noreset) { in brcms_c_setxband()
803 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_setband_inact()
807 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_setband_inact()
808 macctrl = bcma_read32(wlc_hw->d11core, in brcms_c_setband_inact()
813 macintmask = brcms_intrsoff(wlc->wl); in brcms_c_setband_inact()
816 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_setband_inact()
843 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen, in brcms_c_dotxstatus()
844 txs->frameid, txs->status, txs->lasttxtime, in brcms_c_dotxstatus()
845 txs->sequence, txs->phyerr, txs->ackphyrxsh); in brcms_c_dotxstatus()
852 if (!(txs->status & TX_STATUS_AMPDU) in brcms_c_dotxstatus()
853 && (txs->status & TX_STATUS_INTERMEDIATE)) { in brcms_c_dotxstatus()
854 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n"); in brcms_c_dotxstatus()
859 queue = txs->frameid & TXFID_QUEUE_MASK; in brcms_c_dotxstatus()
861 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue); in brcms_c_dotxstatus()
865 dma = wlc->hw->di[queue]; in brcms_c_dotxstatus()
867 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); in brcms_c_dotxstatus()
869 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n"); in brcms_c_dotxstatus()
873 txh = (struct d11txh *) (p->data); in brcms_c_dotxstatus()
875 if (txs->phyerr) in brcms_c_dotxstatus()
876 brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", in brcms_c_dotxstatus()
877 txs->phyerr, txh->MainRates); in brcms_c_dotxstatus()
879 if (txs->frameid != le16_to_cpu(txh->TxFrameID)) { in brcms_c_dotxstatus()
880 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); in brcms_c_dotxstatus()
886 if (tx_info->rate_driver_data[0]) in brcms_c_dotxstatus()
887 scb = &wlc->pri_scb; in brcms_c_dotxstatus()
889 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { in brcms_c_dotxstatus()
890 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); in brcms_c_dotxstatus()
899 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh)); in brcms_c_dotxstatus()
901 supr_status = txs->status & TX_STATUS_SUPR_MASK; in brcms_c_dotxstatus()
903 unsigned xfts = le16_to_cpu(txh->XtraFrameTypes); in brcms_c_dotxstatus()
904 brcms_dbg_tx(wlc->hw->d11core, in brcms_c_dotxstatus()
907 CHSPEC_CHANNEL(wlc->default_bss->chanspec)); in brcms_c_dotxstatus()
911 (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; in brcms_c_dotxstatus()
913 lastframe = !ieee80211_has_morefrags(h->frame_control); in brcms_c_dotxstatus()
916 brcms_err(wlc->hw->d11core, "Not last frame!\n"); in brcms_c_dotxstatus()
931 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
933 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
936 sfbl = wlc->SFBL; in brcms_c_dotxstatus()
937 lfbl = wlc->LFBL; in brcms_c_dotxstatus()
940 txrate = tx_info->status.rates; in brcms_c_dotxstatus()
954 txrate[1].count = tx_frame_count - fbl; in brcms_c_dotxstatus()
963 * unused rates to be marked with idx = -1 in brcms_c_dotxstatus()
965 txrate[1].idx = -1; in brcms_c_dotxstatus()
971 txrate[i].idx = -1; in brcms_c_dotxstatus()
975 if (txs->status & TX_STATUS_ACK_RCV) in brcms_c_dotxstatus()
976 tx_info->flags |= IEEE80211_TX_STAT_ACK; in brcms_c_dotxstatus()
983 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_dotxstatus()
985 brcms_err(wlc->hw->d11core, in brcms_c_dotxstatus()
995 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, in brcms_c_dotxstatus()
1002 if (dma->txavail > TX_HEADROOM && queue < TX_BCMC_FIFO && in brcms_c_dotxstatus()
1003 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue)) in brcms_c_dotxstatus()
1004 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue); in brcms_c_dotxstatus()
1025 uint max_tx_num = bound ? TXSBND : -1; in brcms_b_txstatus()
1028 core = wlc_hw->d11core; in brcms_b_txstatus()
1034 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_b_txstatus()
1044 txs->status = s1 & TXS_STATUS_MASK; in brcms_b_txstatus()
1045 txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; in brcms_b_txstatus()
1046 txs->sequence = s2 & TXS_SEQ_MASK; in brcms_b_txstatus()
1047 txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; in brcms_b_txstatus()
1048 txs->lasttxtime = 0; in brcms_b_txstatus()
1050 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1061 if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_tbtt()
1066 wlc->qvalid |= MCMD_DIRFRMQVAL; in brcms_c_tbtt()
1073 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef()
1080 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_c_mhfdef()
1083 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { in brcms_c_mhfdef()
1105 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio()
1106 uint unit = wlc_hw->unit; in brcms_b_attach_dmapio()
1111 if (wlc_hw->di[0] == NULL) { /* Init FIFOs */ in brcms_b_attach_dmapio()
1119 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1123 RXBUFSZ, -1, NRXBUFPOST, in brcms_b_attach_dmapio()
1125 dma_attach_err |= (NULL == wlc_hw->di[0]); in brcms_b_attach_dmapio()
1129 * TX: TX_AC_BE_FIFO (TX AC Best-Effort data packets) in brcms_b_attach_dmapio()
1133 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1135 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1136 dma_attach_err |= (NULL == wlc_hw->di[1]); in brcms_b_attach_dmapio()
1143 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1145 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1146 dma_attach_err |= (NULL == wlc_hw->di[2]); in brcms_b_attach_dmapio()
1152 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1154 0, NTXD, 0, 0, -1, in brcms_b_attach_dmapio()
1156 dma_attach_err |= (NULL == wlc_hw->di[3]); in brcms_b_attach_dmapio()
1160 brcms_err(wlc_hw->d11core, in brcms_b_attach_dmapio()
1168 if (wlc_hw->di[i]) in brcms_b_attach_dmapio()
1169 wlc_hw->txavail[i] = in brcms_b_attach_dmapio()
1170 (uint *) dma_getvar(wlc_hw->di[i], in brcms_b_attach_dmapio()
1175 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1185 if (wlc_hw->di[j]) { in brcms_b_detach_dmapio()
1186 dma_detach(wlc_hw->di[j]); in brcms_b_detach_dmapio()
1187 wlc_hw->di[j] = NULL; in brcms_b_detach_dmapio()
1199 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init()
1202 wlc->defmacintmask = DEF_MACINTMASK; in brcms_b_info_init()
1205 wlc_hw->shortslot = false; in brcms_b_info_init()
1207 wlc_hw->SFBL = RETRY_SHORT_FB; in brcms_b_info_init()
1208 wlc_hw->LFBL = RETRY_LONG_FB; in brcms_b_info_init()
1211 wlc_hw->SRL = RETRY_SHORT_DEF; in brcms_b_info_init()
1212 wlc_hw->LRL = RETRY_LONG_DEF; in brcms_b_info_init()
1213 wlc_hw->chanspec = ch20mhz_chspec(1); in brcms_b_info_init()
1223 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1229 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) { in brcms_b_clkctl_clk()
1236 if (wlc_hw->clk) { in brcms_b_clkctl_clk()
1238 bcma_set32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1245 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1249 WARN_ON(!(bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1253 if ((ai_get_pmurev(wlc_hw->sih) == 0) && in brcms_b_clkctl_clk()
1254 (bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1258 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1263 bcma_mask32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1268 wlc_hw->forcefastclk = (mode == BCMA_CLKMODE_FAST); in brcms_b_clkctl_clk()
1275 wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); in brcms_b_clkctl_clk()
1278 if (wlc_hw->forcefastclk && wlc_hw->clk) in brcms_b_clkctl_clk()
1279 WARN_ON(!(bcma_aread32(wlc_hw->d11core, BCMA_IOST) & in brcms_b_clkctl_clk()
1288 * behavior. Older code set wlc->forcefastclk but only had the in brcms_b_clkctl_clk()
1292 if (wlc_hw->forcefastclk) in brcms_b_clkctl_clk()
1293 mboolset(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1296 mboolclr(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1302 * it has an optimization for no-change write
1304 * pre-CLK changes should use wlc_write_mhf to get around the optimization
1307 * bands values are: BRCM_BAND_AUTO <--- Current band only
1308 * BRCM_BAND_5G <--- 5G band only
1309 * BRCM_BAND_2G <--- 2G band only
1310 * BRCM_BAND_ALL <--- All bands
1332 band = wlc_hw->band; in brcms_b_mhf()
1335 band = wlc_hw->bandstate[BAND_5G_INDEX]; in brcms_b_mhf()
1338 band = wlc_hw->bandstate[BAND_2G_INDEX]; in brcms_b_mhf()
1345 save = band->mhfs[idx]; in brcms_b_mhf()
1346 band->mhfs[idx] = (band->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1351 if (wlc_hw->clk && (band->mhfs[idx] != save) in brcms_b_mhf()
1352 && (band == wlc_hw->band)) in brcms_b_mhf()
1354 (u16) band->mhfs[idx]); in brcms_b_mhf()
1358 wlc_hw->bandstate[0]->mhfs[idx] = in brcms_b_mhf()
1359 (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1360 wlc_hw->bandstate[1]->mhfs[idx] = in brcms_b_mhf()
1361 (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1371 wlc_hw->maccontrol = 0; in brcms_c_mctrl_reset()
1372 wlc_hw->suspended_fifos = 0; in brcms_c_mctrl_reset()
1373 wlc_hw->wake_override = 0; in brcms_c_mctrl_reset()
1374 wlc_hw->mute_override = 0; in brcms_c_mctrl_reset()
1384 u32 maccontrol = wlc_hw->maccontrol; in brcms_c_mctrl_write()
1387 if (wlc_hw->wake_override) in brcms_c_mctrl_write()
1391 if (wlc_hw->mute_override) { in brcms_c_mctrl_write()
1396 bcma_write32(wlc_hw->d11core, D11REGOFFS(maccontrol), in brcms_c_mctrl_write()
1408 maccontrol = wlc_hw->maccontrol; in brcms_b_mctrl()
1416 wlc_hw->maccontrol = new_maccontrol; in brcms_b_mctrl()
1425 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { in brcms_c_ucode_wake_override_set()
1426 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1430 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1439 mboolclr(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_clear()
1441 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) in brcms_c_ucode_wake_override_clear()
1451 * STA 0 1 <--- This will ensure no beacons
1456 wlc_hw->mute_override = 1; in brcms_c_ucode_mute_override_set()
1461 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_set()
1470 if (wlc_hw->mute_override == 0) in brcms_c_ucode_mute_override_clear()
1473 wlc_hw->mute_override = 0; in brcms_c_ucode_mute_override_clear()
1478 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_clear()
1491 struct bcma_device *core = wlc_hw->d11core; in brcms_b_set_addrmatch()
1496 brcms_dbg_rx(core, "wl%d: brcms_b_set_addrmatch\n", wlc_hw->unit); in brcms_b_set_addrmatch()
1514 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_template_ram()
1519 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_write_template_ram()
1543 len -= sizeof(u32); in brcms_b_write_template_ram()
1549 wlc_hw->band->CWmin = newmin; in brcms_b_set_cwmin()
1551 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmin()
1553 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmin()
1554 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmin); in brcms_b_set_cwmin()
1559 wlc_hw->band->CWmax = newmax; in brcms_b_set_cwmax()
1561 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmax()
1563 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmax()
1564 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmax); in brcms_b_set_cwmax()
1572 fastclk = wlc_hw->forcefastclk; in brcms_b_bw_set()
1576 wlc_phy_bw_state_set(wlc_hw->band->pi, bw); in brcms_b_bw_set()
1579 wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); in brcms_b_bw_set()
1589 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu()
1592 if (BRCMS_ISLCNPHY(wlc->band)) in brcms_b_upd_synthpu()
1594 else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) in brcms_b_upd_synthpu()
1605 u16 phytxant = wlc_hw->bmac_phytxant; in brcms_c_ucode_txant_set()
1628 /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ in brcms_b_ofdm_ratetable_offset()
1648 * Direct-map Table in brcms_b_ofdm_ratetable_offset()
1664 if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_upd_ofdm_pctl1_table()
1679 pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); in brcms_upd_ofdm_pctl1_table()
1687 /* band-specific init */
1690 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit()
1692 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_b_bsinit()
1693 wlc_hw->band->bandunit); in brcms_b_bsinit()
1697 wlc_phy_init(wlc_hw->band->pi, chanspec); in brcms_b_bsinit()
1702 * cwmin is band-specific, update hardware in brcms_b_bsinit()
1705 brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); in brcms_b_bsinit()
1706 brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); in brcms_b_bsinit()
1709 wlc_hw->band->bandtype == BRCM_BAND_5G ? in brcms_b_bsinit()
1710 true : wlc_hw->shortslot); in brcms_b_bsinit()
1713 brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); in brcms_b_bsinit()
1714 brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); in brcms_b_bsinit()
1728 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr), in brcms_b_core_phypll_reset()
1731 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1734 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1737 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1748 if (!BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_phyclk_fgc()
1768 struct brcms_phy_pub *pih = wlc_hw->band->pi; in brcms_b_phy_reset()
1771 brcms_dbg_info(wlc_hw->d11core, "wl%d: reset phy\n", wlc_hw->unit); in brcms_b_phy_reset()
1776 phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); in brcms_b_phy_reset()
1779 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && in brcms_b_phy_reset()
1780 NREV_LE(wlc_hw->band->phyrev, 4)) { in brcms_b_phy_reset()
1807 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband()
1811 if (!bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_setband()
1812 bcma_core_enable(wlc_hw->d11core, 0); in brcms_b_setband()
1818 if (!wlc_hw->up) in brcms_b_setband()
1823 /* band-specific initializations */ in brcms_b_setband()
1829 * so brcms_c_dpc() will re-enable interrupts when done. in brcms_b_setband()
1831 if (wlc->macintstatus) in brcms_b_setband()
1832 wlc->macintstatus = MI_DMAINT; in brcms_b_setband()
1835 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_setband()
1838 WARN_ON((bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & in brcms_b_setband()
1846 if (!CONF_HAS(D11CONF, wlc_hw->corerev)) { in brcms_c_isgoodchip()
1847 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
1848 wlc_hw->corerev); in brcms_c_isgoodchip()
1858 uint boardrev = wlc_hw->boardrev; in brcms_c_validboardtype()
1867 if (ai_get_boardvendor(wlc_hw->sih) != PCI_VENDOR_ID_BROADCOM) in brcms_c_validboardtype()
1886 struct ssb_sprom *sprom = &wlc_hw->d11core->bus->sprom; in brcms_c_get_macaddr()
1889 if (!is_zero_ether_addr(sprom->il0mac)) { in brcms_c_get_macaddr()
1890 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1894 if (wlc_hw->_nbands > 1) in brcms_c_get_macaddr()
1895 memcpy(etheraddr, sprom->et1mac, ETH_ALEN); in brcms_c_get_macaddr()
1897 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1903 brcms_dbg_info(wlc_hw->d11core, "wl%d: want %d\n", wlc_hw->unit, want); in brcms_b_xtal()
1909 if (!want && wlc_hw->pllreq) in brcms_b_xtal()
1912 wlc_hw->sbclk = want; in brcms_b_xtal()
1913 if (!wlc_hw->sbclk) { in brcms_b_xtal()
1914 wlc_hw->clk = false; in brcms_b_xtal()
1915 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_xtal()
1916 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_xtal()
1931 xtal = wlc_hw->sbclk; in brcms_b_radio_read_hwdisabled()
1936 clk = wlc_hw->clk; in brcms_b_radio_read_hwdisabled()
1943 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_radio_read_hwdisabled()
1953 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_radio_read_hwdisabled()
1957 v = ((bcma_read32(wlc_hw->d11core, in brcms_b_radio_read_hwdisabled()
1962 bcma_core_disable(wlc_hw->d11core, 0); in brcms_b_radio_read_hwdisabled()
1972 struct dma_pub *di = wlc_hw->di[fifo]; in wlc_dma_rxreset()
1982 * one testing hack wlc_hw->noreset will bypass the d11/phy reset
1990 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); in brcms_b_corereset()
1992 brcms_dbg_info(wlc_hw->d11core, "wl%d: core reset\n", wlc_hw->unit); in brcms_b_corereset()
1995 fastclk = wlc_hw->forcefastclk; in brcms_b_corereset()
2000 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_corereset()
2002 if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) in brcms_b_corereset()
2003 brcms_err(wlc_hw->d11core, "wl%d: %s: " in brcms_b_corereset()
2005 wlc_hw->unit, __func__, i); in brcms_b_corereset()
2007 if ((wlc_hw->di[RX_FIFO]) in brcms_b_corereset()
2009 brcms_err(wlc_hw->d11core, "wl%d: %s: dma_rxreset" in brcms_b_corereset()
2011 wlc_hw->unit, __func__, RX_FIFO); in brcms_b_corereset()
2014 if (wlc_hw->noreset) { in brcms_b_corereset()
2015 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2023 * band->pi is invalid. need to enable PHY CLK in brcms_b_corereset()
2025 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_corereset()
2031 * reg 0x1e0, which is cleared by the core_reset. have to re-request it. in brcms_b_corereset()
2038 wlc_hw->clk = false; in brcms_b_corereset()
2039 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_corereset()
2040 wlc_hw->clk = true; in brcms_b_corereset()
2041 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_corereset()
2042 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); in brcms_b_corereset()
2046 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) in brcms_b_corereset()
2055 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2067 struct bcma_device *core = wlc_hw->d11core; in brcms_b_corerev_fifofixup()
2079 txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2081 (((txfifo_endblk - 1) & 0xff) << TXFIFO_FIFOTOP_SHIFT); in brcms_b_corerev_fifofixup()
2083 ((((txfifo_endblk - in brcms_b_corerev_fifofixup()
2094 txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2101 wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); in brcms_b_corerev_fifofixup()
2103 wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); in brcms_b_corerev_fifofixup()
2105 ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2108 ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2117 * For spuron2 - 126MHz -> 2^26/126 = 532610.0
2118 * - 532610 = 0x82082 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x2082
2119 * For spuron: 123MHz -> 2^26/123 = 545600.5
2120 * - 545601 = 0x85341 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x5341
2121 * For spur off: 120MHz -> 2^26/120 = 559240.5
2122 * - 559241 = 0x88889 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x8889
2127 struct bcma_device *core = wlc_hw->d11core; in brcms_b_switch_macfreq()
2129 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43224) || in brcms_b_switch_macfreq()
2130 (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) { in brcms_b_switch_macfreq()
2141 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_switch_macfreq()
2154 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_station()
2155 wlc->bsscfg->type = BRCMS_TYPE_STATION; in brcms_c_start_station()
2163 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_ap()
2164 memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID)); in brcms_c_start_ap()
2165 wlc->bsscfg->type = BRCMS_TYPE_AP; in brcms_c_start_ap()
2167 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA); in brcms_c_start_ap()
2172 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_adhoc()
2173 wlc->bsscfg->type = BRCMS_TYPE_ADHOC; in brcms_c_start_adhoc()
2175 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0); in brcms_c_start_adhoc()
2181 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init()
2184 /* use GPIO select 0 to get all gpio signals from the gpio out reg */ in brcms_c_gpio_init()
2198 if (wlc_hw->antsel_type == ANTSEL_2x3) { in brcms_c_gpio_init()
2206 wlc_phy_antsel_init(wlc_hw->band->pi, false); in brcms_c_gpio_init()
2208 } else if (wlc_hw->antsel_type == ANTSEL_2x4) { in brcms_c_gpio_init()
2214 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_oe), in brcms_c_gpio_init()
2216 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_out), in brcms_c_gpio_init()
2234 if (wlc_hw->boardflags & BFL_PACTRL) in brcms_c_gpio_init()
2238 bcma_chipco_gpio_control(&wlc_hw->d11core->bus->drv_cc, gm, gc); in brcms_c_gpio_init()
2244 struct bcma_device *core = wlc_hw->d11core; in brcms_ucode_write()
2248 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_ucode_write()
2262 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2264 if (wlc_hw->ucode_loaded) in brcms_ucode_download()
2267 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_ucode_download()
2268 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_ucode_download()
2269 brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, in brcms_ucode_download()
2270 ucode->bcm43xx_16_mimosz); in brcms_ucode_download()
2271 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2273 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2275 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2276 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_ucode_download()
2277 if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_ucode_download()
2278 brcms_ucode_write(wlc_hw, ucode->bcm43xx_24_lcn, in brcms_ucode_download()
2279 ucode->bcm43xx_24_lcnsz); in brcms_ucode_download()
2280 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2282 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2284 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2292 wlc_hw->bmac_phytxant = phytxant; in brcms_b_txant_set()
2295 if (!wlc_hw->up) in brcms_b_txant_set()
2303 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2308 wlc_hw->antsel_type = antsel_type; in brcms_b_antsel_type_set()
2311 wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); in brcms_b_antsel_type_set()
2319 struct bcma_device *core = wlc_hw->d11core; in brcms_b_fifoerrors()
2321 unit = wlc_hw->unit; in brcms_b_fifoerrors()
2324 /* read intstatus register and ignore any non-error bits */ in brcms_b_fifoerrors()
2370 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2381 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson()
2382 wlc->macintmask = wlc->defmacintmask; in brcms_c_intrson()
2383 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2388 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff()
2391 if (!wlc_hw->clk) in brcms_c_intrsoff()
2394 macintmask = wlc->macintmask; /* isr can still happen */ in brcms_c_intrsoff()
2396 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), 0); in brcms_c_intrsoff()
2397 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(macintmask)); in brcms_c_intrsoff()
2399 wlc->macintmask = 0; in brcms_c_intrsoff()
2402 return wlc->macintstatus ? 0 : macintmask; in brcms_c_intrsoff()
2407 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore()
2408 if (!wlc_hw->clk) in brcms_c_intrsrestore()
2411 wlc->macintmask = macintmask; in brcms_c_intrsrestore()
2412 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2424 if ((wlc_hw->suspended_fifos & fifo) == fifo) in brcms_b_tx_fifo_suspend()
2428 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_suspend()
2432 wlc_hw->suspended_fifos |= fifo; in brcms_b_tx_fifo_suspend()
2434 if (wlc_hw->di[tx_fifo]) { in brcms_b_tx_fifo_suspend()
2440 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2441 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2443 dma_txsuspend(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_suspend()
2445 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2446 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2458 if (wlc_hw->di[tx_fifo]) in brcms_b_tx_fifo_resume()
2459 dma_txresume(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_resume()
2462 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2465 wlc_hw->suspended_fifos &= ~(1 << tx_fifo); in brcms_b_tx_fifo_resume()
2466 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2476 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2498 wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); in brcms_b_mute()
2509 brcms_b_mute(wlc->hw, mute_tx); in brcms_c_mute()
2516 * -1 if brcms_deviceremoved(wlc) evaluates to true;
2522 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus()
2523 struct bcma_device *core = wlc_hw->d11core; in wlc_intstatus()
2528 mask = in_isr ? wlc->macintmask : wlc->defmacintmask; in wlc_intstatus()
2530 trace_brcms_macintstatus(&core->dev, in_isr, macintstatus, mask); in wlc_intstatus()
2534 return -1; in wlc_intstatus()
2552 wlc->macintmask = 0; in wlc_intstatus()
2557 /* MI_DMAINT is indication of non-zero intstatus */ in wlc_intstatus()
2570 /* Update wlc->macintstatus and wlc->intstatus[]. */
2584 wlc->macintstatus |= macintstatus; in brcms_c_intrsupd()
2590 * First-level interrupt processing.
2597 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr()
2600 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2607 brcms_err(wlc_hw->d11core, in brcms_c_isr()
2617 wlc->macintstatus = macintstatus; in brcms_c_isr()
2625 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait()
2626 struct bcma_device *core = wlc_hw->d11core; in brcms_c_suspend_mac_and_wait()
2629 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2630 wlc_hw->band->bandunit); in brcms_c_suspend_mac_and_wait()
2635 wlc_hw->mac_suspend_depth++; in brcms_c_suspend_mac_and_wait()
2636 if (wlc_hw->mac_suspend_depth > 1) in brcms_c_suspend_mac_and_wait()
2645 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2647 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2656 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2658 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2671 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); in brcms_c_suspend_mac_and_wait()
2673 "psm_brc 0x%04x\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2681 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2683 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2693 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac()
2694 struct bcma_device *core = wlc_hw->d11core; in brcms_c_enable_mac()
2697 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_enable_mac()
2698 wlc->band->bandunit); in brcms_c_enable_mac()
2703 wlc_hw->mac_suspend_depth--; in brcms_c_enable_mac()
2704 if (wlc_hw->mac_suspend_depth > 0) in brcms_c_enable_mac()
2729 wlc_hw->hw_stf_ss_opmode = stf_mode; in brcms_b_band_stf_ss_set()
2731 if (wlc_hw->clk) in brcms_b_band_stf_ss_set()
2737 struct bcma_device *core = wlc_hw->d11core; in brcms_b_validate_chip_access()
2739 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2757 "expected 0xaa5555aa\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2770 "expected 0x55aaaa55\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2785 "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, in brcms_b_validate_chip_access()
2798 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_phypll_ctl()
2801 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_core_phypll_ctl()
2806 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_core_phypll_ctl()
2853 brcms_dbg_info(wlc_hw->d11core, "wl%d: disable core\n", wlc_hw->unit); in brcms_c_coredisable()
2855 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2860 if (wlc_hw->noreset) in brcms_c_coredisable()
2864 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2867 wlc_phy_anacore(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2872 wlc_hw->clk = false; in brcms_c_coredisable()
2873 bcma_core_disable(wlc_hw->d11core, 0); in brcms_c_coredisable()
2874 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_c_coredisable()
2879 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues()
2884 if (wlc_hw->di[i]) { in brcms_c_flushqueues()
2885 dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); in brcms_c_flushqueues()
2887 ieee80211_wake_queue(wlc->pub->ieee_hw, in brcms_c_flushqueues()
2893 dma_rxreclaim(wlc_hw->di[RX_FIFO]); in brcms_c_flushqueues()
2899 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_objmem()
2914 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_objmem()
2997 brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); in brcms_c_copyto_shm()
3003 wlc_hw->SRL = SRL; in brcms_b_retrylimit_upd()
3004 wlc_hw->LRL = LRL; in brcms_b_retrylimit_upd()
3007 if (wlc_hw->up) { in brcms_b_retrylimit_upd()
3008 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3010 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3011 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_retrylimit_upd()
3012 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3014 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3015 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_retrylimit_upd()
3022 if (mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3025 mboolset(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3027 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3028 if (!wlc_hw->sbclk) in brcms_b_pllreq()
3032 if (!mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3035 mboolclr(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3037 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3038 if (wlc_hw->sbclk) in brcms_b_pllreq()
3046 wlc_hw->antsel_avail = antsel_avail; in brcms_b_antsel_set()
3070 if (!wlc->pub->up) in brcms_c_statsupd()
3073 macstats = wlc->core->macstat_snapshot; in brcms_c_statsupd()
3077 rxf0ovfl = macstats->rxf0ovfl; in brcms_c_statsupd()
3081 txfunfl[i] = macstats->txfunfl[i]; in brcms_c_statsupd()
3085 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, macstats, in brcms_c_statsupd()
3090 delta = (u16)(macstats->rxf0ovfl - rxf0ovfl); in brcms_c_statsupd()
3092 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n", in brcms_c_statsupd()
3093 wlc->pub->unit, delta); in brcms_c_statsupd()
3097 delta = macstats->txfunfl[i] - txfunfl[i]; in brcms_c_statsupd()
3099 brcms_err(wlc->hw->d11core, in brcms_c_statsupd()
3101 wlc->pub->unit, delta, i); in brcms_c_statsupd()
3107 if (wlc->hw->di[i]) in brcms_c_statsupd()
3108 dma_counterreset(wlc->hw->di[i]); in brcms_c_statsupd()
3115 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3119 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3124 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_reset()
3130 memset(wlc->core->macstat_snapshot, 0, sizeof(struct macstat)); in brcms_c_reset()
3132 brcms_b_reset(wlc->hw); in brcms_c_reset()
3140 scb->flags = SCB_WMECAP | SCB_HTCAP; in brcms_c_init_scb()
3142 scb->seqnum[i] = 0; in brcms_c_init_scb()
3145 scb->magic = SCB_MAGIC; in brcms_c_init_scb()
3158 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit()
3159 struct bcma_device *core = wlc_hw->d11core; in brcms_b_coreinit()
3165 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3167 brcms_dbg_info(core, "wl%d: core init\n", wlc_hw->unit); in brcms_b_coreinit()
3179 bcma_write32(core, D11REGOFFS(macintstatus), -1); in brcms_b_coreinit()
3183 /* wait for ucode to self-suspend after auto-init */ in brcms_b_coreinit()
3187 brcms_err(core, "wl%d: wlc_coreinit: ucode did not self-" in brcms_b_coreinit()
3188 "suspend!\n", wlc_hw->unit); in brcms_b_coreinit()
3194 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_b_coreinit()
3195 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_coreinit()
3196 brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); in brcms_b_coreinit()
3199 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3200 wlc_hw->corerev); in brcms_b_coreinit()
3201 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_b_coreinit()
3202 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_b_coreinit()
3203 brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); in brcms_b_coreinit()
3206 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3207 wlc_hw->corerev); in brcms_b_coreinit()
3210 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_b_coreinit()
3219 if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { in brcms_b_coreinit()
3221 err = -1; in brcms_b_coreinit()
3224 if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { in brcms_b_coreinit()
3226 err = -1; in brcms_b_coreinit()
3231 if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { in brcms_b_coreinit()
3233 err = -1; in brcms_b_coreinit()
3235 if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { in brcms_b_coreinit()
3237 err = -1; in brcms_b_coreinit()
3242 if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { in brcms_b_coreinit()
3244 err = -1; in brcms_b_coreinit()
3246 if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { in brcms_b_coreinit()
3248 err = -1; in brcms_b_coreinit()
3253 wlc_hw->xmtfifo_sz[i], i); in brcms_b_coreinit()
3258 /* band-specific inits done by wlc_bsinit() */ in brcms_b_coreinit()
3287 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3288 bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); in brcms_b_coreinit()
3291 brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); in brcms_b_coreinit()
3295 (u16) (wlc_hw->machwcap & 0xffff)); in brcms_b_coreinit()
3297 (u16) ((wlc_hw-> in brcms_b_coreinit()
3304 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_coreinit()
3308 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_coreinit()
3311 brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); in brcms_b_coreinit()
3312 brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); in brcms_b_coreinit()
3319 if (wlc_hw->di[i]) in brcms_b_coreinit()
3320 dma_txinit(wlc_hw->di[i]); in brcms_b_coreinit()
3324 dma_rxinit(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3325 dma_rxfill(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3332 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init()
3335 fastclk = wlc_hw->forcefastclk; in brcms_b_init()
3340 macintmask = brcms_intrsoff(wlc->wl); in brcms_b_init()
3344 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_init()
3346 /* do one-time phy inits and calibration */ in brcms_b_init()
3347 wlc_phy_cal_init(wlc_hw->band->pi); in brcms_b_init()
3349 /* core-specific initialization */ in brcms_b_init()
3352 /* band-specific inits */ in brcms_b_init()
3356 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_init()
3361 mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); in brcms_b_init()
3367 wlc_hw->mac_suspend_depth = 1; in brcms_b_init()
3378 wlc->chanspec = chanspec; in brcms_c_set_phy_chanspec()
3381 brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); in brcms_c_set_phy_chanspec()
3383 if (wlc->stf->ss_algosel_auto) in brcms_c_set_phy_chanspec()
3384 brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, in brcms_c_set_phy_chanspec()
3387 brcms_c_stf_ss_update(wlc, wlc->band); in brcms_c_set_phy_chanspec()
3393 brcms_c_rateset_default(rs, NULL, wlc->band->phytype, in brcms_default_rateset()
3394 wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_default_rateset()
3395 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_default_rateset()
3396 brcms_chspec_bw(wlc->default_bss->chanspec), in brcms_default_rateset()
3397 wlc->stf->txstreams); in brcms_default_rateset()
3400 /* derive wlc->band->basic_rate[] table from 'rateset' */
3408 u8 *br = wlc->band->basic_rate; in brcms_c_rate_lookup_init()
3417 for (i = 0; i < rateset->count; i++) { in brcms_c_rate_lookup_init()
3419 if (!(rateset->rates[i] & BRCMS_RATE_FLAG)) in brcms_c_rate_lookup_init()
3423 rate = (rateset->rates[i] & BRCMS_RATE_MASK); in brcms_c_rate_lookup_init()
3426 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: " in brcms_c_rate_lookup_init()
3428 rateset->rates[i]); in brcms_c_rate_lookup_init()
3435 /* The rate lookup table now has non-zero entries for each in brcms_c_rate_lookup_init()
3442 * basic_rate = wlc->band->basic_rate[tx_rate] in brcms_c_rate_lookup_init()
3449 for (i = 0; i < wlc->band->hw_rateset.count; i++) { in brcms_c_rate_lookup_init()
3450 rate = wlc->band->hw_rateset.rates[i]; in brcms_c_rate_lookup_init()
3487 /* In 11b, all CCK rates are mandatory 1 - 11 Mbps */ in brcms_c_rate_lookup_init()
3504 * power-cycled (hibernate). Figure out the right band to park on in brcms_c_bandinit_ordered()
3506 if (wlc->bandlocked || wlc->pub->_nbands == 1) { in brcms_c_bandinit_ordered()
3508 parkband = wlc->band->bandunit; in brcms_c_bandinit_ordered()
3520 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_bandinit_ordered()
3523 wlc->band = wlc->bandstate[j]; in brcms_c_bandinit_ordered()
3528 brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, in brcms_c_bandinit_ordered()
3530 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_bandinit_ordered()
3548 wlc->filter_flags = filter_flags; in brcms_c_mac_promisc()
3562 brcms_b_mctrl(wlc->hw, in brcms_c_mac_promisc()
3577 if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { in brcms_c_ucode_mac_upd()
3578 if (wlc->pub->associated) { in brcms_c_ucode_mac_upd()
3588 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_ucode_mac_upd()
3589 brcms_b_write_shm(wlc->hw, in brcms_c_ucode_mac_upd()
3612 * for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_c_write_rate_shm()
3621 * Direct-map Table in brcms_c_write_rate_shm()
3623 basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); in brcms_c_write_rate_shm()
3625 /* Update the SHM BSS-basic-rate-set mapping table with the pointer in brcms_c_write_rate_shm()
3628 brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); in brcms_c_write_rate_shm()
3636 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rateset_get_hwrs()
3637 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_rateset_get_hwrs()
3641 } else if (wlc->band->gmode) in brcms_c_rateset_get_hwrs()
3659 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_set_ratetable()
3679 /* band-specific init */
3682 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n", in brcms_c_bsinit()
3683 wlc->pub->unit, wlc->band->bandunit); in brcms_c_bsinit()
3692 brcms_c_antsel_init(wlc->asi); in brcms_c_bsinit()
3696 /* formula: IDLE_BUSY_RATIO_X_16 = (100-duty_cycle)/duty_cycle*16 */
3706 brcms_err(wlc->hw->d11core, in brcms_c_duty_cycle_set()
3708 wlc->pub->unit); in brcms_c_duty_cycle_set()
3709 return -EINVAL; in brcms_c_duty_cycle_set()
3712 idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; in brcms_c_duty_cycle_set()
3715 brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); in brcms_c_duty_cycle_set()
3718 wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3720 wlc->tx_duty_cycle_cck = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3734 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit, in brcms_c_set_ps_ctrl()
3737 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_set_ps_ctrl()
3742 brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); in brcms_c_set_ps_ctrl()
3747 brcms_b_wait_for_wake(wlc->hw); in brcms_c_set_ps_ctrl()
3756 struct brcms_c_info *wlc = bsscfg->wlc; in brcms_c_set_mac()
3759 brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr); in brcms_c_set_mac()
3770 brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); in brcms_c_set_bssid()
3775 u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len); in brcms_c_set_ssid()
3776 memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID)); in brcms_c_set_ssid()
3778 memcpy(wlc->bsscfg->SSID, ssid, len); in brcms_c_set_ssid()
3779 wlc->bsscfg->SSID_len = len; in brcms_c_set_ssid()
3784 wlc_hw->shortslot = shortslot; in brcms_b_set_shortslot()
3786 if (wlc_hw->band->bandtype == BRCM_BAND_2G && wlc_hw->up) { in brcms_b_set_shortslot()
3787 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3789 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3800 if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) in brcms_c_switch_shortslot()
3801 shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); in brcms_c_switch_shortslot()
3803 if (wlc->shortslot == shortslot) in brcms_c_switch_shortslot()
3806 wlc->shortslot = shortslot; in brcms_c_switch_shortslot()
3808 brcms_b_set_shortslot(wlc->hw, shortslot); in brcms_c_switch_shortslot()
3813 if (wlc->home_chanspec != chanspec) { in brcms_c_set_home_chanspec()
3814 wlc->home_chanspec = chanspec; in brcms_c_set_home_chanspec()
3816 if (wlc->pub->associated) in brcms_c_set_home_chanspec()
3817 wlc->bsscfg->current_bss->chanspec = chanspec; in brcms_c_set_home_chanspec()
3827 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: 0x%x\n", wlc_hw->unit, in brcms_b_set_chanspec()
3830 wlc_hw->chanspec = chanspec; in brcms_b_set_chanspec()
3833 if (wlc_hw->_nbands > 1) { in brcms_b_set_chanspec()
3835 if (wlc_hw->band->bandunit != bandunit) { in brcms_b_set_chanspec()
3839 if (wlc_hw->up) { in brcms_b_set_chanspec()
3840 wlc_phy_chanspec_radio_set(wlc_hw-> in brcms_b_set_chanspec()
3841 bandstate[bandunit]-> in brcms_b_set_chanspec()
3850 wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); in brcms_b_set_chanspec()
3852 if (!wlc_hw->up) { in brcms_b_set_chanspec()
3853 if (wlc_hw->clk) in brcms_b_set_chanspec()
3854 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, in brcms_b_set_chanspec()
3856 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3858 wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3859 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); in brcms_b_set_chanspec()
3870 wlc->band = wlc->bandstate[bandunit]; in brcms_c_setband()
3872 if (!wlc->pub->up) in brcms_c_setband()
3878 /* band-specific initializations */ in brcms_c_setband()
3885 u16 old_chanspec = wlc->chanspec; in brcms_c_set_chanspec()
3887 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { in brcms_c_set_chanspec()
3888 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n", in brcms_c_set_chanspec()
3889 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); in brcms_c_set_chanspec()
3894 if (wlc->pub->_nbands > 1) { in brcms_c_set_chanspec()
3896 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { in brcms_c_set_chanspec()
3897 if (wlc->bandlocked) { in brcms_c_set_chanspec()
3898 brcms_err(wlc->hw->d11core, in brcms_c_set_chanspec()
3900 wlc->pub->unit, __func__, in brcms_c_set_chanspec()
3921 brcms_c_antsel_init(wlc->asi); in brcms_c_set_chanspec()
3926 brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, in brcms_c_set_chanspec()
3927 wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); in brcms_c_set_chanspec()
3937 * ratespec CCK ant = wlc->stf->txant
3944 u16 phytxant = wlc->stf->phytxant; in brcms_c_beacon_phytxctl_txant_upd()
3947 /* for non-siso rates or default setting, use the available chains */ in brcms_c_beacon_phytxctl_txant_upd()
3948 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_beacon_phytxctl_txant_upd()
3951 phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); in brcms_c_beacon_phytxctl_txant_upd()
3953 brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); in brcms_c_beacon_phytxctl_txant_upd()
3967 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); in brcms_c_protection_upd()
3971 wlc->protection->_g = (bool) val; in brcms_c_protection_upd()
3974 wlc->protection->g_override = (s8) val; in brcms_c_protection_upd()
3977 wlc->protection->gmode_user = (u8) val; in brcms_c_protection_upd()
3980 wlc->protection->overlap = (s8) val; in brcms_c_protection_upd()
3983 wlc->protection->nmode_user = (s8) val; in brcms_c_protection_upd()
3986 wlc->protection->n_cfg = (s8) val; in brcms_c_protection_upd()
3989 wlc->protection->n_cfg_override = (s8) val; in brcms_c_protection_upd()
3992 wlc->protection->nongf = (bool) val; in brcms_c_protection_upd()
3995 wlc->protection->nongf_override = (s8) val; in brcms_c_protection_upd()
3998 wlc->protection->n_pam_override = (s8) val; in brcms_c_protection_upd()
4001 wlc->protection->n_obss = (bool) val; in brcms_c_protection_upd()
4012 if (wlc->pub->up) { in brcms_c_ht_update_sgi_rx()
4020 wlc->stf->ldpc = val; in brcms_c_ht_update_ldpc()
4022 if (wlc->pub->up) { in brcms_c_ht_update_ldpc()
4025 wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); in brcms_c_ht_update_ldpc()
4038 if (!wlc->clk) { in brcms_c_wme_setparams()
4039 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n", in brcms_c_wme_setparams()
4040 wlc->pub->unit, __func__); in brcms_c_wme_setparams()
4046 acp_shm.txop = params->txop; in brcms_c_wme_setparams()
4048 wlc->edcf_txop[aci & 0x3] = acp_shm.txop = in brcms_c_wme_setparams()
4050 acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); in brcms_c_wme_setparams()
4058 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad " in brcms_c_wme_setparams()
4059 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); in brcms_c_wme_setparams()
4061 acp_shm.cwmin = params->cw_min; in brcms_c_wme_setparams()
4062 acp_shm.cwmax = params->cw_max; in brcms_c_wme_setparams()
4065 bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & in brcms_c_wme_setparams()
4069 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + in brcms_c_wme_setparams()
4078 brcms_b_write_shm(wlc->hw, in brcms_c_wme_setparams()
4109 aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; in brcms_c_edcf_setparams()
4112 txq_pars.txop = edcf_acp->TXOP; in brcms_c_edcf_setparams()
4113 txq_pars.aifs = edcf_acp->ACI; in brcms_c_edcf_setparams()
4115 /* CWmin = 2^(ECWmin) - 1 */ in brcms_c_edcf_setparams()
4116 txq_pars.cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK); in brcms_c_edcf_setparams()
4117 /* CWmax = 2^(ECWmax) - 1 */ in brcms_c_edcf_setparams()
4118 txq_pars.cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK) in brcms_c_edcf_setparams()
4132 if (wlc->radio_monitor) in brcms_c_radio_monitor_start()
4135 wlc->radio_monitor = true; in brcms_c_radio_monitor_start()
4136 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_start()
4137 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); in brcms_c_radio_monitor_start()
4142 if (!wlc->radio_monitor) in brcms_c_radio_monitor_stop()
4145 wlc->radio_monitor = false; in brcms_c_radio_monitor_stop()
4146 brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_stop()
4147 return brcms_del_timer(wlc->radio_timer); in brcms_c_radio_monitor_stop()
4153 if (wlc->pub->hw_off) in brcms_c_radio_hwdisable_upd()
4156 if (brcms_b_radio_read_hwdisabled(wlc->hw)) in brcms_c_radio_hwdisable_upd()
4157 mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4159 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4167 return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? in brcms_c_check_radio_disabled()
4177 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_radio_timer()
4178 wlc->pub->unit, __func__); in brcms_c_radio_timer()
4179 brcms_down(wlc->wl); in brcms_c_radio_timer()
4186 /* common low-level watchdog code */
4189 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog()
4191 if (!wlc_hw->up) in brcms_b_watchdog()
4195 wlc_hw->now++; in brcms_b_watchdog()
4201 dma_rxfill(wlc->hw->di[RX_FIFO]); in brcms_b_watchdog()
4203 wlc_phy_watchdog(wlc_hw->band->pi); in brcms_b_watchdog()
4209 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_watchdog()
4211 if (!wlc->pub->up) in brcms_c_watchdog()
4215 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_watchdog()
4216 wlc->pub->unit, __func__); in brcms_c_watchdog()
4217 brcms_down(wlc->wl); in brcms_c_watchdog()
4222 wlc->pub->now++; in brcms_c_watchdog()
4226 if (wlc->pub->radio_disabled) in brcms_c_watchdog()
4233 * detect 16-bit counter wrap in brcms_c_watchdog()
4235 if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) in brcms_c_watchdog()
4238 if (BRCMS_ISNPHY(wlc->band) && in brcms_c_watchdog()
4239 ((wlc->pub->now - wlc->tempsense_lasttime) >= in brcms_c_watchdog()
4241 wlc->tempsense_lasttime = wlc->pub->now; in brcms_c_watchdog()
4255 wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, in brcms_c_timers_init()
4257 if (!wlc->wdtimer) { in brcms_c_timers_init()
4258 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " in brcms_c_timers_init()
4263 wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, in brcms_c_timers_init()
4265 if (!wlc->radio_timer) { in brcms_c_timers_init()
4266 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " in brcms_c_timers_init()
4286 wlc->chanspec = ch20mhz_chspec(1); in brcms_c_info_init()
4289 wlc->shortslot = false; in brcms_c_info_init()
4290 wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; in brcms_c_info_init()
4307 wlc->include_legacy_erp = true; in brcms_c_info_init()
4309 wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; in brcms_c_info_init()
4310 wlc->stf->txant = ANT_TX_DEF; in brcms_c_info_init()
4312 wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; in brcms_c_info_init()
4314 wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4316 wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4317 wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; in brcms_c_info_init()
4320 wlc->SFBL = RETRY_SHORT_FB; in brcms_c_info_init()
4321 wlc->LFBL = RETRY_LONG_FB; in brcms_c_info_init()
4324 wlc->SRL = RETRY_SHORT_DEF; in brcms_c_info_init()
4325 wlc->LRL = RETRY_LONG_DEF; in brcms_c_info_init()
4328 wlc->pub->_ampdu = AMPDU_AGG_HOST; in brcms_c_info_init()
4335 unit = wlc->pub->unit; in brcms_c_attach_module()
4337 wlc->asi = brcms_c_antsel_attach(wlc); in brcms_c_attach_module()
4338 if (wlc->asi == NULL) { in brcms_c_attach_module()
4339 wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " in brcms_c_attach_module()
4345 wlc->ampdu = brcms_c_ampdu_attach(wlc); in brcms_c_attach_module()
4346 if (wlc->ampdu == NULL) { in brcms_c_attach_module()
4347 wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " in brcms_c_attach_module()
4354 wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " in brcms_c_attach_module()
4365 return wlc->pub; in brcms_c_pub()
4382 struct wiphy *wiphy = wlc->wiphy; in brcms_b_attach()
4383 struct pci_dev *pcidev = core->bus->host_pci; in brcms_b_attach()
4384 struct ssb_sprom *sprom = &core->bus->sprom; in brcms_b_attach()
4386 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) in brcms_b_attach()
4388 pcidev->vendor, in brcms_b_attach()
4389 pcidev->device); in brcms_b_attach()
4392 core->bus->boardinfo.vendor, in brcms_b_attach()
4393 core->bus->boardinfo.type); in brcms_b_attach()
4397 wlc_hw = wlc->hw; in brcms_b_attach()
4398 wlc_hw->wlc = wlc; in brcms_b_attach()
4399 wlc_hw->unit = unit; in brcms_b_attach()
4400 wlc_hw->band = wlc_hw->bandstate[0]; in brcms_b_attach()
4401 wlc_hw->_piomode = piomode; in brcms_b_attach()
4410 wlc_hw->sih = ai_attach(core->bus); in brcms_b_attach()
4411 if (wlc_hw->sih == NULL) { in brcms_b_attach()
4426 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) { in brcms_b_attach()
4427 wlc_hw->vendorid = pcidev->vendor; in brcms_b_attach()
4428 wlc_hw->deviceid = pcidev->device; in brcms_b_attach()
4430 wlc_hw->vendorid = core->bus->boardinfo.vendor; in brcms_b_attach()
4431 wlc_hw->deviceid = core->bus->boardinfo.type; in brcms_b_attach()
4434 wlc_hw->d11core = core; in brcms_b_attach()
4435 wlc_hw->corerev = core->id.rev; in brcms_b_attach()
4444 ai_clkctl_init(wlc_hw->sih); in brcms_b_attach()
4448 * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk in brcms_b_attach()
4463 j = sprom->board_rev; in brcms_b_attach()
4467 wlc_hw->boardrev = (u16) j; in brcms_b_attach()
4471 unit, ai_get_boardtype(wlc_hw->sih), in brcms_b_attach()
4472 wlc_hw->boardrev); in brcms_b_attach()
4476 wlc_hw->sromrev = sprom->revision; in brcms_b_attach()
4477 wlc_hw->boardflags = sprom->boardflags_lo + (sprom->boardflags_hi << 16); in brcms_b_attach()
4478 wlc_hw->boardflags2 = sprom->boardflags2_lo + (sprom->boardflags2_hi << 16); in brcms_b_attach()
4480 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_b_attach()
4484 if (wlc_hw->deviceid == BCM43224_D11N_ID || in brcms_b_attach()
4485 wlc_hw->deviceid == BCM43224_D11N_ID_VEN1 || in brcms_b_attach()
4486 wlc_hw->deviceid == BCM43224_CHIP_ID) in brcms_b_attach()
4488 wlc_hw->_nbands = 2; in brcms_b_attach()
4490 wlc_hw->_nbands = 1; in brcms_b_attach()
4492 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) in brcms_b_attach()
4493 wlc_hw->_nbands = 1; in brcms_b_attach()
4498 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4499 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4500 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4501 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4502 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4503 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4504 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4505 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4506 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4508 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4510 if (wlc_hw->physhim == NULL) { in brcms_b_attach()
4518 sha_params.sih = wlc_hw->sih; in brcms_b_attach()
4519 sha_params.physhim = wlc_hw->physhim; in brcms_b_attach()
4521 sha_params.corerev = wlc_hw->corerev; in brcms_b_attach()
4522 sha_params.vid = wlc_hw->vendorid; in brcms_b_attach()
4523 sha_params.did = wlc_hw->deviceid; in brcms_b_attach()
4524 sha_params.chip = ai_get_chip_id(wlc_hw->sih); in brcms_b_attach()
4525 sha_params.chiprev = ai_get_chiprev(wlc_hw->sih); in brcms_b_attach()
4526 sha_params.chippkg = ai_get_chippkg(wlc_hw->sih); in brcms_b_attach()
4527 sha_params.sromrev = wlc_hw->sromrev; in brcms_b_attach()
4528 sha_params.boardtype = ai_get_boardtype(wlc_hw->sih); in brcms_b_attach()
4529 sha_params.boardrev = wlc_hw->boardrev; in brcms_b_attach()
4530 sha_params.boardflags = wlc_hw->boardflags; in brcms_b_attach()
4531 sha_params.boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4534 wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); in brcms_b_attach()
4535 if (!wlc_hw->phy_sh) { in brcms_b_attach()
4541 for (j = 0; j < wlc_hw->_nbands; j++) { in brcms_b_attach()
4549 wlc_hw->band->bandunit = j; in brcms_b_attach()
4550 wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4551 wlc->band->bandunit = j; in brcms_b_attach()
4552 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4553 wlc->core->coreidx = core->core_index; in brcms_b_attach()
4555 wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); in brcms_b_attach()
4556 wlc_hw->machwcap_backup = wlc_hw->machwcap; in brcms_b_attach()
4559 WARN_ON(wlc_hw->corerev < XMTFIFOTBL_STARTREV || in brcms_b_attach()
4560 (wlc_hw->corerev - XMTFIFOTBL_STARTREV) > in brcms_b_attach()
4562 wlc_hw->xmtfifo_sz = in brcms_b_attach()
4563 xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; in brcms_b_attach()
4564 WARN_ON(!wlc_hw->xmtfifo_sz[0]); in brcms_b_attach()
4567 wlc_hw->band->pi = in brcms_b_attach()
4568 wlc_phy_attach(wlc_hw->phy_sh, core, in brcms_b_attach()
4569 wlc_hw->band->bandtype, in brcms_b_attach()
4570 wlc->wiphy); in brcms_b_attach()
4571 if (wlc_hw->band->pi == NULL) { in brcms_b_attach()
4578 wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); in brcms_b_attach()
4580 wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, in brcms_b_attach()
4581 &wlc_hw->band->phyrev, in brcms_b_attach()
4582 &wlc_hw->band->radioid, in brcms_b_attach()
4583 &wlc_hw->band->radiorev); in brcms_b_attach()
4584 wlc_hw->band->abgphy_encore = in brcms_b_attach()
4585 wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4586 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4587 wlc_hw->band->core_flags = in brcms_b_attach()
4588 wlc_phy_get_coreflags(wlc_hw->band->pi); in brcms_b_attach()
4591 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_b_attach()
4592 if (NCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4596 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_attach()
4597 if (LCNCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4605 wlc_hw->band->phytype, wlc_hw->band->phyrev); in brcms_b_attach()
4612 * BMAC_NOTE: wlc->band->pi should not be set below and should in brcms_b_attach()
4615 * wlc_hw->band->pi. Instead do the wlc->band->pi init below, in brcms_b_attach()
4616 * keeping wlc_hw->band->pi as well for incremental update of in brcms_b_attach()
4620 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4621 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4622 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4623 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4624 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4626 wlc->band->phytype, wlc->band->phyrev, in brcms_b_attach()
4627 wlc->band->radioid, wlc->band->radiorev); in brcms_b_attach()
4629 wlc_hw->band->CWmin = APHY_CWMIN; in brcms_b_attach()
4630 wlc_hw->band->CWmax = PHY_CWMAX; in brcms_b_attach()
4642 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_attach()
4652 * Beyond this point, wlc->sbclk == false and chip registers in brcms_b_attach()
4658 brcms_c_get_macaddr(wlc_hw, wlc_hw->etheraddr); in brcms_b_attach()
4660 if (is_broadcast_ether_addr(wlc_hw->etheraddr) || in brcms_b_attach()
4661 is_zero_ether_addr(wlc_hw->etheraddr)) { in brcms_b_attach()
4668 brcms_dbg_info(wlc_hw->d11core, "deviceid 0x%x nbands %d board 0x%x\n", in brcms_b_attach()
4669 wlc_hw->deviceid, wlc_hw->_nbands, in brcms_b_attach()
4670 ai_get_boardtype(wlc_hw->sih)); in brcms_b_attach()
4685 struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom; in brcms_c_attach_stf_ant_init()
4687 unit = wlc->pub->unit; in brcms_c_attach_stf_ant_init()
4688 bandtype = wlc->band->bandtype; in brcms_c_attach_stf_ant_init()
4692 aa = sprom->ant_available_a; in brcms_c_attach_stf_ant_init()
4694 aa = sprom->ant_available_bg; in brcms_c_attach_stf_ant_init()
4697 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" in brcms_c_attach_stf_ant_init()
4704 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; in brcms_c_attach_stf_ant_init()
4705 wlc->stf->txant = ANT_TX_FORCE_0; in brcms_c_attach_stf_ant_init()
4707 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; in brcms_c_attach_stf_ant_init()
4708 wlc->stf->txant = ANT_TX_FORCE_1; in brcms_c_attach_stf_ant_init()
4714 wlc->band->antgain = sprom->antenna_gain.a1; in brcms_c_attach_stf_ant_init()
4716 wlc->band->antgain = sprom->antenna_gain.a0; in brcms_c_attach_stf_ant_init()
4725 struct brcms_bss_info *bi = wlc->default_bss; in brcms_c_bss_default_init()
4729 bi->beacon_period = BEACON_INTERVAL_DEFAULT; in brcms_c_bss_default_init()
4735 wlc->home_chanspec = bi->chanspec = chanspec; in brcms_c_bss_default_init()
4738 band = wlc->band; in brcms_c_bss_default_init()
4739 if (wlc->pub->_nbands > 1 && in brcms_c_bss_default_init()
4740 band->bandunit != chspec_bandunit(chanspec)) in brcms_c_bss_default_init()
4741 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_bss_default_init()
4744 brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, in brcms_c_bss_default_init()
4745 band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_c_bss_default_init()
4746 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_c_bss_default_init()
4747 brcms_chspec_bw(chanspec), wlc->stf->txstreams); in brcms_c_bss_default_init()
4749 if (wlc->pub->_n_enab & SUPPORT_11N) in brcms_c_bss_default_init()
4750 bi->flags |= BRCMS_BSS_HT; in brcms_c_bss_default_init()
4758 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_update_mimo_band_bwcap()
4759 band = wlc->bandstate[i]; in brcms_c_update_mimo_band_bwcap()
4760 if (band->bandtype == BRCM_BAND_5G) { in brcms_c_update_mimo_band_bwcap()
4763 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4765 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4768 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4770 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4778 if (wlc->wdtimer) { in brcms_c_timers_deinit()
4779 brcms_free_timer(wlc->wdtimer); in brcms_c_timers_deinit()
4780 wlc->wdtimer = NULL; in brcms_c_timers_deinit()
4782 if (wlc->radio_timer) { in brcms_c_timers_deinit()
4783 brcms_free_timer(wlc->radio_timer); in brcms_c_timers_deinit()
4784 wlc->radio_timer = NULL; in brcms_c_timers_deinit()
4790 if (wlc->asi) { in brcms_c_detach_module()
4791 brcms_c_antsel_detach(wlc->asi); in brcms_c_detach_module()
4792 wlc->asi = NULL; in brcms_c_detach_module()
4795 if (wlc->ampdu) { in brcms_c_detach_module()
4796 brcms_c_ampdu_detach(wlc->ampdu); in brcms_c_detach_module()
4797 wlc->ampdu = NULL; in brcms_c_detach_module()
4810 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach()
4814 band = wlc_hw->band; in brcms_b_detach()
4815 for (i = 0; i < wlc_hw->_nbands; i++) { in brcms_b_detach()
4816 if (band->pi) { in brcms_b_detach()
4818 wlc_phy_detach(band->pi); in brcms_b_detach()
4819 band->pi = NULL; in brcms_b_detach()
4821 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4825 kfree(wlc_hw->phy_sh); in brcms_b_detach()
4827 wlc_phy_shim_detach(wlc_hw->physhim); in brcms_b_detach()
4829 if (wlc_hw->sih) { in brcms_b_detach()
4830 ai_detach(wlc_hw->sih); in brcms_b_detach()
4831 wlc_hw->sih = NULL; in brcms_b_detach()
4859 brcms_c_channel_mgr_detach(wlc->cmi); in brcms_c_detach()
4872 /* STA-BSS; short capable */ in brcms_c_ap_upd()
4873 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; in brcms_c_ap_upd()
4879 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4882 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_hw_up()
4889 ai_clkctl_init(wlc_hw->sih); in brcms_b_hw_up()
4903 wlc_phy_por_inform(wlc_hw->band->pi); in brcms_b_hw_up()
4905 wlc_hw->ucode_loaded = false; in brcms_b_hw_up()
4906 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4908 if ((wlc_hw->boardflags & BFL_FEM) in brcms_b_hw_up()
4909 && (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_hw_up()
4911 (wlc_hw->boardrev >= 0x1250 in brcms_b_hw_up()
4912 && (wlc_hw->boardflags & BFL_FEM_BT))) in brcms_b_hw_up()
4913 ai_epa_4313war(wlc_hw->sih); in brcms_b_hw_up()
4919 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_up_prep()
4926 ai_clkctl_init(wlc_hw->sih); in brcms_b_up_prep()
4933 bcma_host_pci_irq_ctl(wlc_hw->d11core->bus, wlc_hw->d11core, in brcms_b_up_prep()
4943 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_up_prep()
4945 return -ENOMEDIUM; in brcms_b_up_prep()
4948 bcma_host_pci_up(wlc_hw->d11core->bus); in brcms_b_up_prep()
4958 wlc_hw->up = true; in brcms_b_up_finish()
4959 wlc_phy_hw_state_upd(wlc_hw->band->pi, true); in brcms_b_up_finish()
4963 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
4976 if (!wlc->clk) in brcms_c_wme_retries_write()
4980 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), in brcms_c_wme_retries_write()
4981 wlc->wme_retries[ac]); in brcms_c_wme_retries_write()
4989 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_up()
4992 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) in brcms_c_up()
4993 return -ENOMEDIUM; in brcms_c_up()
4995 if (!wlc->pub->hw_up) { in brcms_c_up()
4996 brcms_b_hw_up(wlc->hw); in brcms_c_up()
4997 wlc->pub->hw_up = true; in brcms_c_up()
5000 if ((wlc->pub->boardflags & BFL_FEM) in brcms_c_up()
5001 && (ai_get_chip_id(wlc->hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_c_up()
5002 if (wlc->pub->boardrev >= 0x1250 in brcms_c_up()
5003 && (wlc->pub->boardflags & BFL_FEM_BT)) in brcms_c_up()
5004 brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, in brcms_c_up()
5007 brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, in brcms_c_up()
5018 * brcms_b_up_prep() returns either 0 or -BCME_RADIOOFF only in brcms_c_up()
5020 if (!wlc->pub->radio_disabled) { in brcms_c_up()
5021 int status = brcms_b_up_prep(wlc->hw); in brcms_c_up()
5022 if (status == -ENOMEDIUM) { in brcms_c_up()
5024 (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { in brcms_c_up()
5025 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_up()
5026 mboolset(wlc->pub->radio_disabled, in brcms_c_up()
5028 if (bsscfg->type == BRCMS_TYPE_STATION || in brcms_c_up()
5029 bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_up()
5030 brcms_err(wlc->hw->d11core, in brcms_c_up()
5031 "wl%d: up: rfdisable -> " in brcms_c_up()
5033 wlc->pub->unit); in brcms_c_up()
5038 if (wlc->pub->radio_disabled) { in brcms_c_up()
5044 wlc->clk = true; in brcms_c_up()
5049 brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); in brcms_c_up()
5051 brcms_init(wlc->wl); in brcms_c_up()
5052 wlc->pub->up = true; in brcms_c_up()
5054 if (wlc->bandinit_pending) { in brcms_c_up()
5055 ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_up()
5057 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->hw_value)); in brcms_c_up()
5058 wlc->bandinit_pending = false; in brcms_c_up()
5062 brcms_b_up_finish(wlc->hw); in brcms_c_up()
5068 brcms_add_timer(wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); in brcms_c_up()
5069 wlc->WDarmed = true; in brcms_c_up()
5074 brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); in brcms_c_up()
5084 if (!wlc_hw->up) in brcms_b_bmac_down_prep()
5087 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5091 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5094 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5100 callbacks += wlc_phy_down(wlc_hw->band->pi); in brcms_b_bmac_down_prep()
5110 if (!wlc_hw->up) in brcms_b_down_finish()
5113 wlc_hw->up = false; in brcms_b_down_finish()
5114 wlc_phy_hw_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5116 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5119 wlc_hw->sbclk = false; in brcms_b_down_finish()
5120 wlc_hw->clk = false; in brcms_b_down_finish()
5121 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5124 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5128 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_down_finish()
5129 if (bcma_read32(wlc_hw->d11core, in brcms_b_down_finish()
5131 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5132 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5137 if (!wlc_hw->noreset) { in brcms_b_down_finish()
5138 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_down_finish()
5157 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_down()
5160 if (wlc->going_down) { in brcms_c_down()
5161 brcms_err(wlc->hw->d11core, in brcms_c_down()
5163 wlc->pub->unit, __func__); in brcms_c_down()
5166 if (!wlc->pub->up) in brcms_c_down()
5169 wlc->going_down = true; in brcms_c_down()
5171 callbacks += brcms_b_bmac_down_prep(wlc->hw); in brcms_c_down()
5177 if (wlc->modulecb[i].down_fn) in brcms_c_down()
5179 wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); in brcms_c_down()
5183 if (wlc->WDarmed) { in brcms_c_down()
5184 if (!brcms_del_timer(wlc->wdtimer)) in brcms_c_down()
5186 wlc->WDarmed = false; in brcms_c_down()
5189 wlc->pub->up = false; in brcms_c_down()
5191 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); in brcms_c_down()
5193 callbacks += brcms_b_down_finish(wlc->hw); in brcms_c_down()
5196 wlc->clk = false; in brcms_c_down()
5198 wlc->going_down = false; in brcms_c_down()
5209 /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */ in brcms_c_set_gmode()
5214 /* if N-support is enabled, allow Gmode set as long as requested in brcms_c_set_gmode()
5217 if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) in brcms_c_set_gmode()
5218 return -ENOTSUPP; in brcms_c_set_gmode()
5221 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_set_gmode()
5222 band = wlc->band; in brcms_c_set_gmode()
5223 else if ((wlc->pub->_nbands > 1) && in brcms_c_set_gmode()
5224 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) in brcms_c_set_gmode()
5225 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_set_gmode()
5227 return -EINVAL; in brcms_c_set_gmode()
5261 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n", in brcms_c_set_gmode()
5262 wlc->pub->unit, __func__, gmode); in brcms_c_set_gmode()
5263 return -ENOTSUPP; in brcms_c_set_gmode()
5266 band->gmode = gmode; in brcms_c_set_gmode()
5268 wlc->shortslot_override = shortslot; in brcms_c_set_gmode()
5284 wlc->default_bss->rateset.count = rs.count; in brcms_c_set_gmode()
5285 memcpy(wlc->default_bss->rateset.rates, rs.rates, in brcms_c_set_gmode()
5286 sizeof(wlc->default_bss->rateset.rates)); in brcms_c_set_gmode()
5296 if (wlc->stf->txstreams == WL_11N_3x3) in brcms_c_set_nmode()
5304 wlc->pub->_n_enab = SUPPORT_HT; in brcms_c_set_nmode()
5306 wlc->pub->_n_enab = SUPPORT_11N; in brcms_c_set_nmode()
5307 wlc->default_bss->flags |= BRCMS_BSS_HT; in brcms_c_set_nmode()
5309 brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, in brcms_c_set_nmode()
5310 wlc->stf->txstreams); in brcms_c_set_nmode()
5311 for (i = 0; i < wlc->pub->_nbands; i++) in brcms_c_set_nmode()
5312 memcpy(wlc->bandstate[i]->hw_rateset.mcs, in brcms_c_set_nmode()
5313 wlc->default_bss->rateset.mcs, MCSSET_LEN); in brcms_c_set_nmode()
5329 return -EINVAL; in brcms_c_set_internal_rateset()
5332 bandunit = wlc->band->bandunit; in brcms_c_set_internal_rateset()
5335 (&new, &wlc->bandstate[bandunit]->hw_rateset, true, in brcms_c_set_internal_rateset()
5336 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5344 &wlc-> in brcms_c_set_internal_rateset()
5345 bandstate[bandunit]-> in brcms_c_set_internal_rateset()
5347 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5351 return -EBADE; in brcms_c_set_internal_rateset()
5355 memcpy(&wlc->default_bss->rateset, &new, in brcms_c_set_internal_rateset()
5357 memcpy(&wlc->bandstate[bandunit]->defrateset, &new, in brcms_c_set_internal_rateset()
5364 wlc_phy_ofdm_rateset_war(wlc->band->pi, false); in brcms_c_ofdm_rateset_war()
5372 return -EINVAL; in brcms_c_set_channel()
5374 if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) in brcms_c_set_channel()
5375 return -EINVAL; in brcms_c_set_channel()
5378 if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { in brcms_c_set_channel()
5379 if (wlc->band->bandunit != chspec_bandunit(chspec)) in brcms_c_set_channel()
5380 wlc->bandinit_pending = true; in brcms_c_set_channel()
5382 wlc->bandinit_pending = false; in brcms_c_set_channel()
5385 wlc->default_bss->chanspec = chspec; in brcms_c_set_channel()
5388 if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { in brcms_c_set_channel()
5403 return -EINVAL; in brcms_c_set_rate_limit()
5405 wlc->SRL = srl; in brcms_c_set_rate_limit()
5406 wlc->LRL = lrl; in brcms_c_set_rate_limit()
5408 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); in brcms_c_set_rate_limit()
5411 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5412 EDCF_SHORT, wlc->SRL); in brcms_c_set_rate_limit()
5413 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5414 EDCF_LONG, wlc->LRL); in brcms_c_set_rate_limit()
5426 if (wlc->pub->associated) in brcms_c_get_current_rateset()
5427 rs = &wlc->bsscfg->current_bss->rateset; in brcms_c_get_current_rateset()
5429 rs = &wlc->default_bss->rateset; in brcms_c_get_current_rateset()
5432 currs->count = rs->count; in brcms_c_get_current_rateset()
5433 memcpy(&currs->rates, &rs->rates, rs->count); in brcms_c_get_current_rateset()
5441 if (rs->count > BRCMS_NUMRATES) in brcms_c_set_rateset()
5442 return -ENOBUFS; in brcms_c_set_rateset()
5447 internal_rs.count = rs->count; in brcms_c_set_rateset()
5448 memcpy(&internal_rs.rates, &rs->rates, internal_rs.count); in brcms_c_set_rateset()
5451 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_set_rateset()
5453 if (wlc->pub->associated) in brcms_c_set_rateset()
5454 mcsset_bss = wlc->bsscfg->current_bss; in brcms_c_set_rateset()
5456 mcsset_bss = wlc->default_bss; in brcms_c_set_rateset()
5457 memcpy(internal_rs.mcs, &mcsset_bss->rateset.mcs[0], in brcms_c_set_rateset()
5470 bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD); in brcms_c_time_lock()
5472 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_lock()
5477 bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD); in brcms_c_time_unlock()
5479 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_unlock()
5487 return -EINVAL; in brcms_c_set_beacon_period()
5489 wlc->default_bss->beacon_period = period; in brcms_c_set_beacon_period()
5493 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep), in brcms_c_set_beacon_period()
5495 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us); in brcms_c_set_beacon_period()
5503 return wlc->band->phytype; in brcms_c_get_phy_type()
5508 wlc->shortslot_override = sslot_override; in brcms_c_set_shortslot_override()
5514 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_set_shortslot_override()
5517 if (wlc->pub->up && wlc->pub->associated) { in brcms_c_set_shortslot_override()
5519 } else if (wlc->pub->up) { in brcms_c_set_shortslot_override()
5525 if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) in brcms_c_set_shortslot_override()
5526 wlc->shortslot = false; in brcms_c_set_shortslot_override()
5528 wlc->shortslot = in brcms_c_set_shortslot_override()
5529 (wlc->shortslot_override == in brcms_c_set_shortslot_override()
5541 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_register()
5546 if (wlc->modulecb[i].name[0] == '\0') { in brcms_c_module_register()
5547 strscpy(wlc->modulecb[i].name, name, in brcms_c_module_register()
5548 sizeof(wlc->modulecb[i].name)); in brcms_c_module_register()
5549 wlc->modulecb[i].hdl = hdl; in brcms_c_module_register()
5550 wlc->modulecb[i].down_fn = d_fn; in brcms_c_module_register()
5555 return -ENOSR; in brcms_c_module_register()
5562 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_unregister()
5566 return -ENODATA; in brcms_c_module_unregister()
5569 if (!strcmp(wlc->modulecb[i].name, name) && in brcms_c_module_unregister()
5570 (wlc->modulecb[i].hdl == hdl)) { in brcms_c_module_unregister()
5571 memset(&wlc->modulecb[i], 0, sizeof(wlc->modulecb[i])); in brcms_c_module_unregister()
5577 return -ENODATA; in brcms_c_module_unregister()
5582 struct pci_dev *pcidev = core->bus->host_pci; in brcms_c_chipmatch_pci()
5583 u16 vendor = pcidev->vendor; in brcms_c_chipmatch_pci()
5584 u16 device = pcidev->device; in brcms_c_chipmatch_pci()
5606 struct bcma_chipinfo *chipinfo = &core->bus->chipinfo; in brcms_c_chipmatch_soc()
5608 if (chipinfo->id == BCMA_CHIP_ID_BCM4716) in brcms_c_chipmatch_soc()
5611 pr_err("unknown chip id %04x\n", chipinfo->id); in brcms_c_chipmatch_soc()
5617 switch (core->bus->hosttype) { in brcms_c_chipmatch()
5623 pr_err("unknown host type: %i\n", core->bus->hosttype); in brcms_c_chipmatch()
5639 /* for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_b_rate_shm_offset()
5646 * Direct-map Table in brcms_b_rate_shm_offset()
5662 frameid = le16_to_cpu(txh->TxFrameID) & ~(TXFID_SEQ_MASK | in bcmc_fid_generate()
5665 (((wlc-> in bcmc_fid_generate()
5730 sifs = get_sifs(wlc->band); in brcms_c_compute_frame_dur()
5758 dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); in brcms_c_calc_frame_len()
5760 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_len()
5761 dur -= DOT11_OFDM_SIGNAL_EXTENSION; in brcms_c_calc_frame_len()
5767 ((nsyms * kNdps) - in brcms_c_calc_frame_len()
5770 dur -= APHY_PREAMBLE_TIME; in brcms_c_calc_frame_len()
5771 dur -= APHY_SIGNAL_TIME; in brcms_c_calc_frame_len()
5776 ((nsyms * Ndps) - in brcms_c_calc_frame_len()
5780 dur -= BPHY_PLCP_SHORT_TIME; in brcms_c_calc_frame_len()
5782 dur -= BPHY_PLCP_TIME; in brcms_c_calc_frame_len()
5800 if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) in brcms_c_valid_rate()
5801 hw_rateset = &wlc->band->hw_rateset; in brcms_c_valid_rate()
5802 else if (wlc->pub->_nbands > 1) in brcms_c_valid_rate()
5803 hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; in brcms_c_valid_rate()
5813 return isset(hw_rateset->mcs, (rspec & RSPEC_RATE_MASK)); in brcms_c_valid_rate()
5816 for (i = 0; i < hw_rateset->count; i++) in brcms_c_valid_rate()
5817 if (hw_rateset->rates[i] == rspec2rate(rspec)) in brcms_c_valid_rate()
5821 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x " in brcms_c_valid_rate()
5822 "not in hw_rateset\n", wlc->pub->unit, rspec); in brcms_c_valid_rate()
5831 struct bcma_device *core = wlc->hw->d11core; in mac80211_wlc_set_nrate()
5844 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { in mac80211_wlc_set_nrate()
5848 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5854 if (!CHSPEC_IS40(wlc->home_chanspec) || in mac80211_wlc_set_nrate()
5858 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5867 wlc->pub->unit, rate); in mac80211_wlc_set_nrate()
5872 * MCS 0-7 may use SISO, CDD, and for in mac80211_wlc_set_nrate()
5879 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5886 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5890 if ((cur_band->bandtype != BRCM_BAND_2G) in mac80211_wlc_set_nrate()
5893 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5898 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5901 /* make sure multiple antennae are available for non-siso rates */ in mac80211_wlc_set_nrate()
5902 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { in mac80211_wlc_set_nrate()
5904 "request\n", wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5928 && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) in mac80211_wlc_set_nrate()
5958 if ((length << 4) - (usec * 11) > 0) in brcms_c_cck_plcp_set()
5963 if ((length << 3) - (usec * 11) > 0) { in brcms_c_cck_plcp_set()
5965 if ((usec * 11) - (length << 3) >= 8) in brcms_c_cck_plcp_set()
5971 brcms_err(wlc->hw->d11core, in brcms_c_cck_plcp_set()
6013 * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb in brcms_c_compute_ofdm_plcp()
6051 * DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK
6053 * cts cts-to-self or rts/cts
6066 sifs = get_sifs(wlc->band); in brcms_c_compute_rtscts_dur()
6075 /* CTS-TO-SELF */ in brcms_c_compute_rtscts_dur()
6098 if (BRCMS_ISLCNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6104 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is " in brcms_c_phytxctl1_calc()
6113 /* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ in brcms_c_phytxctl1_calc()
6117 } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) in brcms_c_phytxctl1_calc()
6118 && !BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6130 if (phycfg == -1) { in brcms_c_phytxctl1_calc()
6131 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong " in brcms_c_phytxctl1_calc()
6189 h = (struct ieee80211_hdr *)(p->data); in brcms_c_d11hdrs_mac80211()
6190 qos = ieee80211_is_data_qos(h->frame_control); in brcms_c_d11hdrs_mac80211()
6193 len = p->len; in brcms_c_d11hdrs_mac80211()
6207 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { in brcms_c_d11hdrs_mac80211()
6208 /* non-AP STA should never use BCMC queue */ in brcms_c_d11hdrs_mac80211()
6210 brcms_err(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6212 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6216 if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) in brcms_c_d11hdrs_mac80211()
6217 scb->seqnum[p->priority]++; in brcms_c_d11hdrs_mac80211()
6220 seq = le16_to_cpu(h->seq_ctrl) & FRAGNUM_MASK; in brcms_c_d11hdrs_mac80211()
6221 seq |= (scb->seqnum[p->priority] << SEQNUM_SHIFT); in brcms_c_d11hdrs_mac80211()
6222 h->seq_ctrl = cpu_to_le16(seq); in brcms_c_d11hdrs_mac80211()
6231 if (ieee80211_is_beacon(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6234 txrate[0] = tx_info->control.rates; in brcms_c_d11hdrs_mac80211()
6241 if (txrate[1]->idx < 0) in brcms_c_d11hdrs_mac80211()
6244 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6245 is_mcs = txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false; in brcms_c_d11hdrs_mac80211()
6247 if ((txrate[k]->idx >= 0) in brcms_c_d11hdrs_mac80211()
6248 && (txrate[k]->idx < in brcms_c_d11hdrs_mac80211()
6249 hw->wiphy->bands[tx_info->band]->n_bitrates)) { in brcms_c_d11hdrs_mac80211()
6251 hw->wiphy->bands[tx_info->band]-> in brcms_c_d11hdrs_mac80211()
6252 bitrates[txrate[k]->idx].hw_value; in brcms_c_d11hdrs_mac80211()
6257 rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, in brcms_c_d11hdrs_mac80211()
6258 NRATE_MCS_INUSE | txrate[k]->idx); in brcms_c_d11hdrs_mac80211()
6267 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6270 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6282 if (!is_multicast_ether_addr(h->addr1)) { in brcms_c_d11hdrs_mac80211()
6284 brcms_c_antsel_antcfg_get(wlc->asi, false, in brcms_c_d11hdrs_mac80211()
6290 phyctl1_stf = wlc->stf->ss_opmode; in brcms_c_d11hdrs_mac80211()
6292 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_d11hdrs_mac80211()
6293 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6324 if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { in brcms_c_d11hdrs_mac80211()
6328 wlc->band->pi)) in brcms_c_d11hdrs_mac80211()
6338 } else if (wlc->mimo_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6339 mimo_txbw = wlc->mimo_40txbw; in brcms_c_d11hdrs_mac80211()
6341 else if (scb->flags & SCB_IS40) in brcms_c_d11hdrs_mac80211()
6344 if (wlc->ofdm_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6345 mimo_txbw = wlc->ofdm_40txbw; in brcms_c_d11hdrs_mac80211()
6346 } else if (wlc->cck_40txbw != AUTO) { in brcms_c_d11hdrs_mac80211()
6347 mimo_txbw = wlc->cck_40txbw; in brcms_c_d11hdrs_mac80211()
6373 if (txrate[k]->flags & IEEE80211_TX_RC_GREEN_FIELD) in brcms_c_d11hdrs_mac80211()
6376 if ((txrate[k]->flags & IEEE80211_TX_RC_MCS) in brcms_c_d11hdrs_mac80211()
6378 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6380 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6398 && (tx_info->control.rates[0]. in brcms_c_d11hdrs_mac80211()
6403 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6409 if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { in brcms_c_d11hdrs_mac80211()
6417 txrate[0]->count = 0; in brcms_c_d11hdrs_mac80211()
6418 txrate[1]->count = 0; in brcms_c_d11hdrs_mac80211()
6421 if ((ieee80211_is_data(h->frame_control) || in brcms_c_d11hdrs_mac80211()
6422 ieee80211_is_mgmt(h->frame_control)) && in brcms_c_d11hdrs_mac80211()
6423 (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6430 memcpy(&txh->FragPLCPFallback, in brcms_c_d11hdrs_mac80211()
6431 plcp_fallback, sizeof(txh->FragPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6435 txh->FragPLCPFallback[4] = phylen & 0xff; in brcms_c_d11hdrs_mac80211()
6436 txh->FragPLCPFallback[5] = (phylen & 0xff00) >> 8; in brcms_c_d11hdrs_mac80211()
6439 /* MIMO-RATE: need validation ?? */ in brcms_c_d11hdrs_mac80211()
6445 if (!ieee80211_is_pspoll(h->frame_control) && in brcms_c_d11hdrs_mac80211()
6446 !is_multicast_ether_addr(h->addr1) && !use_rifs) { in brcms_c_d11hdrs_mac80211()
6450 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6458 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6462 if (ieee80211_is_pspoll(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6463 txh->FragDurFallback = h->duration_id; in brcms_c_d11hdrs_mac80211()
6464 else if (is_multicast_ether_addr(h->addr1) || use_rifs) in brcms_c_d11hdrs_mac80211()
6465 txh->FragDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6469 txh->FragDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6472 /* (4) MAC-HDR: MacTxControlLow */ in brcms_c_d11hdrs_mac80211()
6476 if (!is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6479 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_d11hdrs_mac80211()
6482 if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) in brcms_c_d11hdrs_mac80211()
6489 txh->MacTxControlLow = cpu_to_le16(mcl); in brcms_c_d11hdrs_mac80211()
6502 memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16)); in brcms_c_d11hdrs_mac80211()
6503 txh->TxFesTimeNormal = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6505 txh->TxFesTimeFallback = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6508 memcpy(&txh->TxFrameRA, &h->addr1, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6511 txh->TxFrameID = cpu_to_le16(frameid); in brcms_c_d11hdrs_mac80211()
6517 txh->TxStatus = cpu_to_le16(status); in brcms_c_d11hdrs_mac80211()
6523 txh->MaxNMpdus = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6524 txh->MaxABytes_MRT = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6525 txh->MaxABytes_FBR = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6526 txh->MinMBytes = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6543 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6550 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6557 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDCTS); in brcms_c_d11hdrs_mac80211()
6559 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDRTS); in brcms_c_d11hdrs_mac80211()
6560 txh->MacTxControlLow |= cpu_to_le16(TXC_LONGFRAME); in brcms_c_d11hdrs_mac80211()
6564 rts_plcp = txh->RTSPhyHeader; in brcms_c_d11hdrs_mac80211()
6575 memcpy(&txh->RTSPLCPFallback, rts_plcp_fallback, in brcms_c_d11hdrs_mac80211()
6576 sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6579 rts = (struct ieee80211_rts *)&txh->rts_frame; in brcms_c_d11hdrs_mac80211()
6584 rts->duration = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6590 txh->RTSDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6593 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6596 memcpy(&rts->ra, &h->addr2, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6598 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6601 memcpy(&rts->ra, &h->addr1, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6602 memcpy(&rts->ta, &h->addr2, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6614 memset(txh->RTSPhyHeader, 0, D11_PHY_HDR_LEN); in brcms_c_d11hdrs_mac80211()
6615 memset(&txh->rts_frame, 0, sizeof(struct ieee80211_rts)); in brcms_c_d11hdrs_mac80211()
6616 memset(txh->RTSPLCPFallback, 0, sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6617 txh->RTSDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6622 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && is_mcs_rate(rspec)) in brcms_c_d11hdrs_mac80211()
6623 txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = in brcms_c_d11hdrs_mac80211()
6624 brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); in brcms_c_d11hdrs_mac80211()
6632 txh->MacTxControlHigh = cpu_to_le16(mch); in brcms_c_d11hdrs_mac80211()
6638 txh->MainRates = cpu_to_le16(mainrates); in brcms_c_d11hdrs_mac80211()
6641 xfts = frametype(rspec[1], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6642 xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6643 xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6644 xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << in brcms_c_d11hdrs_mac80211()
6646 txh->XtraFrameTypes = cpu_to_le16(xfts); in brcms_c_d11hdrs_mac80211()
6649 phyctl = frametype(rspec[0], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6658 txh->PhyTxControlWord = cpu_to_le16(phyctl); in brcms_c_d11hdrs_mac80211()
6661 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_d11hdrs_mac80211()
6665 txh->PhyTxControlWord_1 = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6667 txh->PhyTxControlWord_1_Fbr = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6671 txh->PhyTxControlWord_1_Rts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6673 txh->PhyTxControlWord_1_FbrRts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6678 * is going to be set, fill in non-zero MModeLen and/or in brcms_c_d11hdrs_mac80211()
6685 txh->MModeLen = cpu_to_le16(mmodelen); in brcms_c_d11hdrs_mac80211()
6692 txh->MModeFbrLen = cpu_to_le16(mmodefbrlen); in brcms_c_d11hdrs_mac80211()
6697 if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { in brcms_c_d11hdrs_mac80211()
6701 if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU) && frag == 0) { in brcms_c_d11hdrs_mac80211()
6707 /* 1 RTS or CTS-to-self frame */ in brcms_c_d11hdrs_mac80211()
6715 dur += le16_to_cpu(rts->duration); in brcms_c_d11hdrs_mac80211()
6717 le16_to_cpu(txh->RTSDurFallback); in brcms_c_d11hdrs_mac80211()
6737 txh->TxFesTimeNormal = cpu_to_le16((u16) dur); in brcms_c_d11hdrs_mac80211()
6742 txh->TxFesTimeFallback = in brcms_c_d11hdrs_mac80211()
6749 if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { in brcms_c_d11hdrs_mac80211()
6755 (wlc->edcf_txop[ac] - in brcms_c_d11hdrs_mac80211()
6756 (dur - frag_dur))); in brcms_c_d11hdrs_mac80211()
6762 wlc->usr_fragthresh) in brcms_c_d11hdrs_mac80211()
6764 wlc->usr_fragthresh; in brcms_c_d11hdrs_mac80211()
6766 if (wlc->fragthresh[queue] != in brcms_c_d11hdrs_mac80211()
6768 wlc->fragthresh[queue] = in brcms_c_d11hdrs_mac80211()
6771 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6773 wlc->pub->unit, fifo_names[queue], in brcms_c_d11hdrs_mac80211()
6777 if (dur > wlc->edcf_txop[ac]) in brcms_c_d11hdrs_mac80211()
6778 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6780 wlc->pub->unit, __func__, in brcms_c_d11hdrs_mac80211()
6782 phylen, wlc->fragthresh[queue], in brcms_c_d11hdrs_mac80211()
6783 dur, wlc->edcf_txop[ac]); in brcms_c_d11hdrs_mac80211()
6793 int fifo, ret = -ENOSPC; in brcms_c_tx()
6798 dma = wlc->hw->di[fifo]; in brcms_c_tx()
6799 txh = (struct d11txh *)(skb->data); in brcms_c_tx()
6801 if (dma->txavail == 0) { in brcms_c_tx()
6811 brcms_warn(wlc->hw->d11core, in brcms_c_tx()
6813 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw, in brcms_c_tx()
6815 return -ENOSPC; in brcms_c_tx()
6822 frameid = le16_to_cpu(txh->TxFrameID); in brcms_c_tx()
6830 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); in brcms_c_tx()
6848 struct scb *scb = &wlc->pri_scb; in brcms_c_sendpkt_mac80211()
6863 struct dma_pub *dma = wlc->hw->di[fifo]; in brcms_c_txfifo()
6869 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); in brcms_c_txfifo()
6877 if (dma->txavail <= TX_HEADROOM && fifo < TX_BCMC_FIFO && in brcms_c_txfifo()
6878 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue)) in brcms_c_txfifo()
6879 ieee80211_stop_queue(wlc->pub->ieee_hw, queue); in brcms_c_txfifo()
6893 else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) in brcms_c_rspec_to_rts_rspec()
6909 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rspec_to_rts_rspec()
6925 rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); in brcms_c_rspec_to_rts_rspec()
6935 if (wlc->bcn_li_dtim == 1) in brcms_c_bcn_li_upd()
6936 brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); in brcms_c_bcn_li_upd()
6938 brcms_b_write_shm(wlc->hw, M_BCN_LI, in brcms_c_bcn_li_upd()
6939 (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); in brcms_c_bcn_li_upd()
6946 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_tsf()
6960 * |<---------- tsf_h ----------->||<--- tsf_l -->||<-RxTSFTime ->|
6973 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_recover_tsf64()
6976 rx_tsf_0_15 = rxh->RxTSFTime; in brcms_c_recover_tsf64()
6983 rx_tsf_16_31 -= 1; in brcms_c_recover_tsf64()
6985 tsf_h -= 1; in brcms_c_recover_tsf64()
7001 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); in prep_mac80211_status()
7002 rx_status->flag |= RX_FLAG_MACTIME_START; in prep_mac80211_status()
7004 channel = BRCMS_CHAN_CHANNEL(rxh->RxChan); in prep_mac80211_status()
7006 rx_status->band = in prep_mac80211_status()
7008 rx_status->freq = in prep_mac80211_status()
7009 ieee80211_channel_to_frequency(channel, rx_status->band); in prep_mac80211_status()
7011 rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); in prep_mac80211_status()
7015 rx_status->antenna = in prep_mac80211_status()
7016 (rxh->PhyRxStatus_0 & PRXS0_RXANT_UPSUBBAND) ? 1 : 0; in prep_mac80211_status()
7018 plcp = p->data; in prep_mac80211_status()
7022 rx_status->rate_idx = rspec & RSPEC_RATE_MASK; in prep_mac80211_status()
7023 rx_status->encoding = RX_ENC_HT; in prep_mac80211_status()
7025 rx_status->bw = RATE_INFO_BW_40; in prep_mac80211_status()
7029 rx_status->rate_idx = 0; in prep_mac80211_status()
7032 rx_status->rate_idx = 1; in prep_mac80211_status()
7035 rx_status->rate_idx = 2; in prep_mac80211_status()
7038 rx_status->rate_idx = 3; in prep_mac80211_status()
7041 rx_status->rate_idx = 4; in prep_mac80211_status()
7044 rx_status->rate_idx = 5; in prep_mac80211_status()
7047 rx_status->rate_idx = 6; in prep_mac80211_status()
7050 rx_status->rate_idx = 7; in prep_mac80211_status()
7053 rx_status->rate_idx = 8; in prep_mac80211_status()
7056 rx_status->rate_idx = 9; in prep_mac80211_status()
7059 rx_status->rate_idx = 10; in prep_mac80211_status()
7062 rx_status->rate_idx = 11; in prep_mac80211_status()
7065 brcms_err(wlc->hw->d11core, in prep_mac80211_status()
7074 if (rx_status->band == NL80211_BAND_5GHZ) in prep_mac80211_status()
7075 rx_status->rate_idx -= BRCMS_LEGACY_5G_RATE_OFFSET; in prep_mac80211_status()
7079 if (rxh->PhyRxStatus_0 & PRXS0_SHORTH) in prep_mac80211_status()
7080 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7082 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7084 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n", in prep_mac80211_status()
7090 rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in prep_mac80211_status()
7092 if (rxh->RxStatus1 & RXS_DECERR) { in prep_mac80211_status()
7093 rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; in prep_mac80211_status()
7094 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n", in prep_mac80211_status()
7097 if (rxh->RxStatus1 & RXS_FCSERR) { in prep_mac80211_status()
7098 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; in prep_mac80211_status()
7099 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n", in prep_mac80211_status()
7116 len_mpdu = p->len - D11_PHY_HDR_LEN - FCS_LEN; in brcms_c_recvctl()
7121 if (wlc->hw->suspended_fifos) { in brcms_c_recvctl()
7122 hdr = (struct ieee80211_hdr *)p->data; in brcms_c_recvctl()
7123 if (ieee80211_is_beacon(hdr->frame_control)) in brcms_c_recvctl()
7124 brcms_b_mute(wlc->hw, false); in brcms_c_recvctl()
7128 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_recvctl()
7131 /* calculate frame duration for Mixed-mode L-SIG spoofing, return
7135 * len = 3(nsyms + nstream + 3) - 3
7167 /* (+3) account for HT-SIG(2) and HT-STF(1) */ in brcms_c_calc_lsig_len()
7171 * (-3) excluding service bits and tail bits in brcms_c_calc_lsig_len()
7173 len = (3 * nsyms) - 3; in brcms_c_calc_lsig_len()
7190 sifs = get_sifs(wlc->band); in brcms_c_mod_prb_rsp_rate_table()
7195 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_mod_prb_rsp_rate_table()
7204 entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); in brcms_c_mod_prb_rsp_rate_table()
7218 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, in brcms_c_mod_prb_rsp_rate_table()
7220 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, in brcms_c_mod_prb_rsp_rate_table()
7222 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); in brcms_c_mod_prb_rsp_rate_table()
7237 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write()
7238 struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw; in brcms_c_beacon_write()
7243 len = min_t(size_t, beacon->len, BCN_TMPL_LEN); in brcms_c_beacon_write()
7244 wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value; in brcms_c_beacon_write()
7246 brcms_c_compute_plcp(wlc, wlc->bcn_rspec, in brcms_c_beacon_write()
7247 len + FCS_LEN - D11_PHY_HDR_LEN, beacon->data); in brcms_c_beacon_write()
7251 brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); in brcms_c_beacon_write()
7256 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7264 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7285 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw()
7286 struct bcma_device *core = wlc_hw->d11core; in brcms_c_update_beacon_hw()
7298 if (wlc->beacon_template_virgin) { in brcms_c_update_beacon_hw()
7299 wlc->beacon_template_virgin = false; in brcms_c_update_beacon_hw()
7311 wlc->defmacintmask |= MI_BCNTPL; in brcms_c_update_beacon_hw()
7335 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_beacon()
7337 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_beacon()
7338 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_beacon()
7340 wlc->defmacintmask &= ~MI_BCNTPL; in brcms_c_update_beacon()
7341 if (!wlc->beacon) in brcms_c_update_beacon()
7343 brcms_c_update_beacon_hw(wlc, wlc->beacon, in brcms_c_update_beacon()
7344 wlc->beacon_tim_offset, in brcms_c_update_beacon()
7345 wlc->beacon_dtim_period); in brcms_c_update_beacon()
7354 if (wlc->beacon) in brcms_c_set_new_beacon()
7355 dev_kfree_skb_any(wlc->beacon); in brcms_c_set_new_beacon()
7356 wlc->beacon = beacon; in brcms_c_set_new_beacon()
7359 skb_push(wlc->beacon, D11_PHY_HDR_LEN); in brcms_c_set_new_beacon()
7360 wlc->beacon_tim_offset = tim_offset; in brcms_c_set_new_beacon()
7361 wlc->beacon_dtim_period = dtim_period; in brcms_c_set_new_beacon()
7370 if (wlc->probe_resp) in brcms_c_set_new_probe_resp()
7371 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_set_new_probe_resp()
7372 wlc->probe_resp = probe_resp; in brcms_c_set_new_probe_resp()
7375 skb_push(wlc->probe_resp, D11_PHY_HDR_LEN); in brcms_c_set_new_probe_resp()
7385 wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1; in brcms_c_enable_probe_resp()
7386 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_enable_probe_resp()
7394 u8 *ssidptr = cfg->SSID; in brcms_c_shm_ssid_upd()
7400 memcpy(ssidbuf, ssidptr, cfg->SSID_len); in brcms_c_shm_ssid_upd()
7403 brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); in brcms_c_shm_ssid_upd()
7414 len = min_t(size_t, probe_resp->len, BCN_TMPL_LEN); in brcms_c_bss_update_probe_resp()
7420 brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, in brcms_c_bss_update_probe_resp()
7421 (len + 3) & ~3, probe_resp->data); in brcms_c_bss_update_probe_resp()
7423 /* write the length of the probe response frame (+PLCP/-FCS) */ in brcms_c_bss_update_probe_resp()
7424 brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); in brcms_c_bss_update_probe_resp()
7436 (u16)len + FCS_LEN - D11_PHY_HDR_LEN); in brcms_c_bss_update_probe_resp()
7444 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_probe_resp()
7447 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_probe_resp()
7448 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_probe_resp()
7449 if (!wlc->probe_resp) in brcms_c_update_probe_resp()
7451 brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp, in brcms_c_update_probe_resp()
7460 return -EINVAL; in brcms_b_xmtfifo_sz_get()
7462 *blocks = wlc_hw->xmtfifo_sz[fifo]; in brcms_b_xmtfifo_sz_get()
7471 brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); in brcms_c_set_addrmatch()
7473 memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); in brcms_c_set_addrmatch()
7481 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); in brcms_c_scan_start()
7486 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); in brcms_c_scan_stop()
7491 wlc->pub->associated = state; in brcms_c_associate_upd()
7506 dmah = hw->di[i]; in brcms_c_inval_dma_pkts()
7514 return wlc->band->bandunit; in brcms_c_get_curband()
7522 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_c_tx_flush_completed()
7523 if (wlc->hw->di[i]) in brcms_c_tx_flush_completed()
7524 dma_kick_tx(wlc->hw->di[i]); in brcms_c_tx_flush_completed()
7531 wlc->bcn_li_bcn = interval; in brcms_c_set_beacon_listen_interval()
7532 if (wlc->pub->up) in brcms_c_set_beacon_listen_interval()
7541 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_tsf_get()
7560 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l); in brcms_c_tsf_set()
7561 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h); in brcms_c_tsf_set()
7572 return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); in brcms_c_set_tx_power()
7580 wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); in brcms_c_get_tx_power()
7599 rxh = (struct d11rxhdr *) (p->data); in brcms_c_recv()
7604 /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ in brcms_c_recv()
7605 if (rxh->RxStatus1 & RXS_PBPRES) { in brcms_c_recv()
7606 if (p->len < 2) { in brcms_c_recv()
7607 brcms_err(wlc->hw->d11core, in brcms_c_recv()
7609 wlc->pub->unit, p->len); in brcms_c_recv()
7615 h = (struct ieee80211_hdr *)(p->data + D11_PHY_HDR_LEN); in brcms_c_recv()
7616 len = p->len; in brcms_c_recv()
7618 if (rxh->RxStatus1 & RXS_FCSERR) { in brcms_c_recv()
7619 if (!(wlc->filter_flags & FIF_FCSFAIL)) in brcms_c_recv()
7624 if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) in brcms_c_recv()
7627 /* not supporting A-MSDU */ in brcms_c_recv()
7628 is_amsdu = rxh->RxStatus2 & RXS_AMSDU_MASK; in brcms_c_recv()
7652 uint bound_limit = bound ? RXBND : -1; in brcms_b_recv()
7663 morepending = dma_rx(wlc_hw->di[fifo], &recv_frames); in brcms_b_recv()
7668 dma_rxfill(wlc_hw->di[fifo]); in brcms_b_recv()
7676 rxh_le = (struct d11rxhdr_le *)p->data; in brcms_b_recv()
7677 rxh = (struct d11rxhdr *)p->data; in brcms_b_recv()
7680 rxh->RxFrameSize = le16_to_cpu(rxh_le->RxFrameSize); in brcms_b_recv()
7681 rxh->PhyRxStatus_0 = le16_to_cpu(rxh_le->PhyRxStatus_0); in brcms_b_recv()
7682 rxh->PhyRxStatus_1 = le16_to_cpu(rxh_le->PhyRxStatus_1); in brcms_b_recv()
7683 rxh->PhyRxStatus_2 = le16_to_cpu(rxh_le->PhyRxStatus_2); in brcms_b_recv()
7684 rxh->PhyRxStatus_3 = le16_to_cpu(rxh_le->PhyRxStatus_3); in brcms_b_recv()
7685 rxh->PhyRxStatus_4 = le16_to_cpu(rxh_le->PhyRxStatus_4); in brcms_b_recv()
7686 rxh->PhyRxStatus_5 = le16_to_cpu(rxh_le->PhyRxStatus_5); in brcms_b_recv()
7687 rxh->RxStatus1 = le16_to_cpu(rxh_le->RxStatus1); in brcms_b_recv()
7688 rxh->RxStatus2 = le16_to_cpu(rxh_le->RxStatus2); in brcms_b_recv()
7689 rxh->RxTSFTime = le16_to_cpu(rxh_le->RxTSFTime); in brcms_b_recv()
7690 rxh->RxChan = le16_to_cpu(rxh_le->RxChan); in brcms_b_recv()
7692 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7698 /* second-level interrupt processing
7699 * Return true if another dpc needs to be re-scheduled. false otherwise.
7705 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc()
7706 struct bcma_device *core = wlc_hw->d11core; in brcms_c_dpc()
7709 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_dpc()
7711 brcms_down(wlc->wl); in brcms_c_dpc()
7716 macintstatus = wlc->macintstatus; in brcms_c_dpc()
7717 wlc->macintstatus = 0; in brcms_c_dpc()
7720 wlc_hw->unit, macintstatus); in brcms_c_dpc()
7722 WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ in brcms_c_dpc()
7727 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) in brcms_c_dpc()
7728 wlc->macintstatus |= MI_TFS; in brcms_c_dpc()
7741 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); in brcms_c_dpc()
7742 wlc->qvalid = 0; in brcms_c_dpc()
7751 wlc->macintstatus |= MI_DMAINT; in brcms_c_dpc()
7755 wlc_phy_noise_sample_intr(wlc_hw->band->pi); in brcms_c_dpc()
7759 "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); in brcms_c_dpc()
7762 __func__, ai_get_chip_id(wlc_hw->sih), in brcms_c_dpc()
7763 ai_get_chiprev(wlc_hw->sih)); in brcms_c_dpc()
7764 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7773 " RF Disable Input\n", wlc_hw->unit); in brcms_c_dpc()
7774 brcms_rfkill_set_hw_state(wlc->wl); in brcms_c_dpc()
7781 /* it isn't done and needs to be resched if macintstatus is non-zero */ in brcms_c_dpc()
7782 return wlc->macintstatus != 0; in brcms_c_dpc()
7785 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7786 return wlc->macintstatus != 0; in brcms_c_dpc()
7791 struct bcma_device *core = wlc->hw->d11core; in brcms_c_init()
7792 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_init()
7795 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit); in brcms_c_init()
7797 chanspec = ch20mhz_chspec(ch->hw_value); in brcms_c_init()
7799 brcms_b_init(wlc->hw, chanspec); in brcms_c_init()
7805 brcms_c_set_mac(wlc->bsscfg); in brcms_c_init()
7806 brcms_c_set_bssid(wlc->bsscfg); in brcms_c_init()
7809 if (wlc->pub->associated && wlc->pub->up) { in brcms_c_init()
7813 bi = wlc->bsscfg->current_bss->beacon_period << 10; in brcms_c_init()
7828 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_init()
7831 brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, in brcms_c_init()
7832 (wlc-> in brcms_c_init()
7836 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); in brcms_c_init()
7837 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); in brcms_c_init()
7843 brcms_c_ampdu_shm_upd(wlc->ampdu); in brcms_c_init()
7845 /* band-specific inits */ in brcms_c_init()
7853 if (wlc->ucode_rev == 0) { in brcms_c_init()
7857 rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR); in brcms_c_init()
7858 patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); in brcms_c_init()
7859 wlc->ucode_rev = (rev << NBITS(u16)) | patch; in brcms_c_init()
7860 snprintf(wlc->wiphy->fw_version, in brcms_c_init()
7861 sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch); in brcms_c_init()
7869 brcms_b_mute(wlc->hw, true); in brcms_c_init()
7878 if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { in brcms_c_init()
7883 wlc->wme_retries[ac] = in brcms_c_init()
7884 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); in brcms_c_init()
7904 wlc->wiphy = wl->wiphy; in brcms_c_attach()
7905 pub = wlc->pub; in brcms_c_attach()
7911 wlc->band = wlc->bandstate[0]; in brcms_c_attach()
7912 wlc->core = wlc->corestate; in brcms_c_attach()
7913 wlc->wl = wl; in brcms_c_attach()
7914 pub->unit = unit; in brcms_c_attach()
7915 pub->_piomode = piomode; in brcms_c_attach()
7916 wlc->bandinit_pending = false; in brcms_c_attach()
7917 wlc->beacon_template_virgin = true; in brcms_c_attach()
7935 pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); in brcms_c_attach()
7938 wlc->tx_duty_cycle_ofdm = 0; in brcms_c_attach()
7939 wlc->tx_duty_cycle_cck = 0; in brcms_c_attach()
7944 if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) in brcms_c_attach()
7945 wlc->stf->txant = wlc->stf->hw_txchain - 1; in brcms_c_attach()
7948 wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, in brcms_c_attach()
7949 wlc->stf->hw_rxchain); in brcms_c_attach()
7953 wlc->core->txavail[i] = wlc->hw->txavail[i]; in brcms_c_attach()
7955 memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7956 memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7958 for (j = 0; j < wlc->pub->_nbands; j++) { in brcms_c_attach()
7959 wlc->band = wlc->bandstate[j]; in brcms_c_attach()
7967 wlc->band->CWmin = APHY_CWMIN; in brcms_c_attach()
7968 wlc->band->CWmax = PHY_CWMAX; in brcms_c_attach()
7971 if (wlc->band->bandtype == BRCM_BAND_2G) { in brcms_c_attach()
7972 wlc->band->gmode = GMODE_AUTO; in brcms_c_attach()
7974 wlc->band->gmode); in brcms_c_attach()
7978 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_attach()
7979 pub->_n_enab = SUPPORT_11N; in brcms_c_attach()
7981 ((pub->_n_enab == in brcms_c_attach()
7986 /* init per-band default rateset, depend on band->gmode */ in brcms_c_attach()
7987 brcms_default_rateset(wlc, &wlc->band->defrateset); in brcms_c_attach()
7990 brcms_c_rateset_filter(&wlc->band->defrateset, in brcms_c_attach()
7991 &wlc->band->hw_rateset, false, in brcms_c_attach()
7993 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_attach()
7998 * wlc->stf->txant/txchain/ant_rx_ovr change in brcms_c_attach()
8008 wiphy_err(wl->wiphy, "wl%d: %s: init_timer failed\n", unit, in brcms_c_attach()
8015 wlc->cmi = brcms_c_channel_mgr_attach(wlc); in brcms_c_attach()
8016 if (!wlc->cmi) { in brcms_c_attach()
8017 wiphy_err(wl->wiphy, "wl%d: %s: channel_mgr_attach failed" in brcms_c_attach()
8023 /* init default when all parameters are ready, i.e. ->rateset */ in brcms_c_attach()
8030 wlc->bsscfg->wlc = wlc; in brcms_c_attach()
8032 wlc->mimoft = FT_HT; in brcms_c_attach()
8033 wlc->mimo_40txbw = AUTO; in brcms_c_attach()
8034 wlc->ofdm_40txbw = AUTO; in brcms_c_attach()
8035 wlc->cck_40txbw = AUTO; in brcms_c_attach()
8042 } else if (BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_attach()
8049 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); in brcms_c_attach()
8057 wiphy_err(wl->wiphy, "wl%d: %s: failed with err %d\n", in brcms_c_attach()