Lines Matching +full:in +full:- +full:band
3 * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
7 * copyright notice and this permission notice appear in all copies.
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
42 /* watchdog timer, in unit of ms */
44 /* radio monitor timer, in unit of ms */
47 /* beacon interval, in unit of 1024TU */
50 /* n-mode support capability */
82 #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1)
125 /* synthpu_dly times in us */
133 /* Per-AC retry limit register definitions; uses defs.h bitfield macros */
167 #define BRCMS_PLCP_AUTO -1
172 #define BRCMS_PROTECTION_AUTO -1
189 /* values for band specific 40MHz capabilities */
199 /* MSC in use,indicates b0-6 holds an mcs */
211 #define NRATE_LDPC_CODING 0x00400000 /* adv coding in use */
221 /* # of entries in Tx FIFO */
223 /* Max # of entries in Rx FIFO based on 4kb page size */
226 /* Amount of headroom to leave in Tx FIFO */
232 /* max # frames to process in brcms_c_recv() */
234 /* max # tx status to process in wlc_txstatus() */
244 * The following table lists the buffer memory allocated to xmt fifos in HW.
245 * the size is in units of 256bytes(one block), total size is HW dependent
248 * This is documented in twiki under the topic UcodeTxFifo. Please ensure
361 return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] in brcms_basic_rate()
363 return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; in brcms_basic_rate()
373 /* currently the best mechanism for determining SIFS is the band in use */
374 static u16 get_sifs(struct brcms_band *band) in get_sifs() argument
376 return band->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : in get_sifs()
383 * is in reset it breaks CF address mechanism. Accessing gphy phyversion will
384 * cause SB error if aphy is in reset on 4306B0-DB. Need a simple accessible
393 if (!wlc->hw->clk) in brcms_deviceremoved()
394 return ai_deviceremoved(wlc->hw->sih); in brcms_deviceremoved()
395 macctrl = bcma_read32(wlc->hw->d11core, in brcms_deviceremoved()
406 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_txpktpendtot()
407 if (wlc->hw->di[i]) in brcms_txpktpendtot()
408 pending += dma_txpending(wlc->hw->di[i]); in brcms_txpktpendtot()
414 return wlc->pub->_nbands > 1 && !wlc->bandlocked; in brcms_is_mband_unlocked()
432 kfree(cfg->current_bss); in brcms_c_bsscfg_mfree()
441 brcms_c_bsscfg_mfree(wlc->bsscfg); in brcms_c_detach_mfree()
442 kfree(wlc->pub); in brcms_c_detach_mfree()
443 kfree(wlc->modulecb); in brcms_c_detach_mfree()
444 kfree(wlc->default_bss); in brcms_c_detach_mfree()
445 kfree(wlc->protection); in brcms_c_detach_mfree()
446 kfree(wlc->stf); in brcms_c_detach_mfree()
447 kfree(wlc->bandstate[0]); in brcms_c_detach_mfree()
448 if (wlc->corestate) in brcms_c_detach_mfree()
449 kfree(wlc->corestate->macstat_snapshot); in brcms_c_detach_mfree()
450 kfree(wlc->corestate); in brcms_c_detach_mfree()
451 if (wlc->hw) in brcms_c_detach_mfree()
452 kfree(wlc->hw->bandstate[0]); in brcms_c_detach_mfree()
453 kfree(wlc->hw); in brcms_c_detach_mfree()
454 if (wlc->beacon) in brcms_c_detach_mfree()
455 dev_kfree_skb_any(wlc->beacon); in brcms_c_detach_mfree()
456 if (wlc->probe_resp) in brcms_c_detach_mfree()
457 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_detach_mfree()
470 cfg->current_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); in brcms_c_bsscfg_malloc()
471 if (cfg->current_bss == NULL) in brcms_c_bsscfg_malloc()
493 wlc->pub = kzalloc(sizeof(struct brcms_pub), GFP_ATOMIC); in brcms_c_attach_malloc()
494 if (wlc->pub == NULL) { in brcms_c_attach_malloc()
498 wlc->pub->wlc = wlc; in brcms_c_attach_malloc()
502 wlc->hw = kzalloc(sizeof(struct brcms_hardware), GFP_ATOMIC); in brcms_c_attach_malloc()
503 if (wlc->hw == NULL) { in brcms_c_attach_malloc()
507 wlc->hw->wlc = wlc; in brcms_c_attach_malloc()
509 wlc->hw->bandstate[0] = in brcms_c_attach_malloc()
511 if (wlc->hw->bandstate[0] == NULL) { in brcms_c_attach_malloc()
518 wlc->hw->bandstate[i] = (struct brcms_hw_band *) in brcms_c_attach_malloc()
519 ((unsigned long)wlc->hw->bandstate[0] + in brcms_c_attach_malloc()
523 wlc->modulecb = in brcms_c_attach_malloc()
526 if (wlc->modulecb == NULL) { in brcms_c_attach_malloc()
531 wlc->default_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); in brcms_c_attach_malloc()
532 if (wlc->default_bss == NULL) { in brcms_c_attach_malloc()
537 wlc->bsscfg = brcms_c_bsscfg_malloc(unit); in brcms_c_attach_malloc()
538 if (wlc->bsscfg == NULL) { in brcms_c_attach_malloc()
543 wlc->protection = kzalloc(sizeof(struct brcms_protection), in brcms_c_attach_malloc()
545 if (wlc->protection == NULL) { in brcms_c_attach_malloc()
550 wlc->stf = kzalloc(sizeof(struct brcms_stf), GFP_ATOMIC); in brcms_c_attach_malloc()
551 if (wlc->stf == NULL) { in brcms_c_attach_malloc()
556 wlc->bandstate[0] = in brcms_c_attach_malloc()
558 if (wlc->bandstate[0] == NULL) { in brcms_c_attach_malloc()
565 wlc->bandstate[i] = (struct brcms_band *) in brcms_c_attach_malloc()
566 ((unsigned long)wlc->bandstate[0] in brcms_c_attach_malloc()
570 wlc->corestate = kzalloc(sizeof(struct brcms_core), GFP_ATOMIC); in brcms_c_attach_malloc()
571 if (wlc->corestate == NULL) { in brcms_c_attach_malloc()
576 wlc->corestate->macstat_snapshot = in brcms_c_attach_malloc()
578 if (wlc->corestate->macstat_snapshot == NULL) { in brcms_c_attach_malloc()
598 struct bcma_device *core = wlc_hw->d11core; in brcms_b_update_slot_timing()
613 * time in usec unit
622 brcms_err(wlc->hw->d11core, "wl%d: WAR: using rate of 1 mbps\n", in brcms_c_calc_frame_time()
623 wlc->pub->unit); in brcms_c_calc_frame_time()
650 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
662 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
666 * calc # bits * 2 so factor of 2 in rate (1/2 mbps) in brcms_c_calc_frame_time()
671 dur = (mac_len + rate - 1) / rate; in brcms_c_calc_frame_time()
683 struct bcma_device *core = wlc_hw->d11core; in brcms_c_write_inits()
689 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_write_inits()
718 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_c_ucode_bsinit()
721 brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); in brcms_c_ucode_bsinit()
723 /* do band-specific ucode IHR, SHM, and SCR inits */ in brcms_c_ucode_bsinit()
724 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_c_ucode_bsinit()
725 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
726 brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16); in brcms_c_ucode_bsinit()
728 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
729 "%s: wl%d: unsupported phy in corerev %d\n", in brcms_c_ucode_bsinit()
730 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
731 wlc_hw->corerev); in brcms_c_ucode_bsinit()
733 if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_c_ucode_bsinit()
734 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
736 ucode->d11lcn0bsinitvals24); in brcms_c_ucode_bsinit()
738 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
739 "%s: wl%d: unsupported phy in core rev %d\n", in brcms_c_ucode_bsinit()
740 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
741 wlc_hw->corerev); in brcms_c_ucode_bsinit()
743 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
745 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_c_ucode_bsinit()
752 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_ioctl()
760 brcms_dbg_info(wlc_hw->d11core, "wl%d: clk %d\n", wlc_hw->unit, clk); in brcms_b_core_phy_clk()
762 wlc_hw->phyclk = clk; in brcms_b_core_phy_clk()
782 /* low-level band switch utility routine */
785 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_setxband()
788 wlc_hw->band = wlc_hw->bandstate[bandunit]; in brcms_c_setxband()
792 * until we eliminate need for wlc->band refs in low level code in brcms_c_setxband()
794 wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; in brcms_c_setxband()
797 if (wlc_hw->sbclk && !wlc_hw->noreset) { in brcms_c_setxband()
807 /* switch to new band but leave it inactive */
810 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_setband_inact()
814 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_setband_inact()
815 macctrl = bcma_read32(wlc_hw->d11core, in brcms_c_setband_inact()
820 macintmask = brcms_intrsoff(wlc->wl); in brcms_c_setband_inact()
823 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_setband_inact()
850 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen, in brcms_c_dotxstatus()
851 txs->frameid, txs->status, txs->lasttxtime, in brcms_c_dotxstatus()
852 txs->sequence, txs->phyerr, txs->ackphyrxsh); in brcms_c_dotxstatus()
859 if (!(txs->status & TX_STATUS_AMPDU) in brcms_c_dotxstatus()
860 && (txs->status & TX_STATUS_INTERMEDIATE)) { in brcms_c_dotxstatus()
861 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n"); in brcms_c_dotxstatus()
866 queue = txs->frameid & TXFID_QUEUE_MASK; in brcms_c_dotxstatus()
868 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue); in brcms_c_dotxstatus()
872 dma = wlc->hw->di[queue]; in brcms_c_dotxstatus()
874 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); in brcms_c_dotxstatus()
876 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n"); in brcms_c_dotxstatus()
880 txh = (struct d11txh *) (p->data); in brcms_c_dotxstatus()
882 if (txs->phyerr) in brcms_c_dotxstatus()
883 brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", in brcms_c_dotxstatus()
884 txs->phyerr, txh->MainRates); in brcms_c_dotxstatus()
886 if (txs->frameid != le16_to_cpu(txh->TxFrameID)) { in brcms_c_dotxstatus()
887 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); in brcms_c_dotxstatus()
893 if (tx_info->rate_driver_data[0]) in brcms_c_dotxstatus()
894 scb = &wlc->pri_scb; in brcms_c_dotxstatus()
896 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { in brcms_c_dotxstatus()
897 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); in brcms_c_dotxstatus()
906 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh)); in brcms_c_dotxstatus()
908 supr_status = txs->status & TX_STATUS_SUPR_MASK; in brcms_c_dotxstatus()
910 unsigned xfts = le16_to_cpu(txh->XtraFrameTypes); in brcms_c_dotxstatus()
911 brcms_dbg_tx(wlc->hw->d11core, in brcms_c_dotxstatus()
914 CHSPEC_CHANNEL(wlc->default_bss->chanspec)); in brcms_c_dotxstatus()
918 (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; in brcms_c_dotxstatus()
920 lastframe = !ieee80211_has_morefrags(h->frame_control); in brcms_c_dotxstatus()
923 brcms_err(wlc->hw->d11core, "Not last frame!\n"); in brcms_c_dotxstatus()
938 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
940 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
943 sfbl = wlc->SFBL; in brcms_c_dotxstatus()
944 lfbl = wlc->LFBL; in brcms_c_dotxstatus()
947 txrate = tx_info->status.rates; in brcms_c_dotxstatus()
961 txrate[1].count = tx_frame_count - fbl; in brcms_c_dotxstatus()
970 * unused rates to be marked with idx = -1 in brcms_c_dotxstatus()
972 txrate[1].idx = -1; in brcms_c_dotxstatus()
978 txrate[i].idx = -1; in brcms_c_dotxstatus()
982 if (txs->status & TX_STATUS_ACK_RCV) in brcms_c_dotxstatus()
983 tx_info->flags |= IEEE80211_TX_STAT_ACK; in brcms_c_dotxstatus()
990 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_dotxstatus()
992 brcms_err(wlc->hw->d11core, in brcms_c_dotxstatus()
1002 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, in brcms_c_dotxstatus()
1009 if (dma->txavail > TX_HEADROOM && queue < TX_BCMC_FIFO && in brcms_c_dotxstatus()
1010 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue)) in brcms_c_dotxstatus()
1011 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue); in brcms_c_dotxstatus()
1018 /* process tx completion events in BMAC
1032 uint max_tx_num = bound ? TXSBND : -1; in brcms_b_txstatus()
1035 core = wlc_hw->d11core; in brcms_b_txstatus()
1041 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_b_txstatus()
1051 txs->status = s1 & TXS_STATUS_MASK; in brcms_b_txstatus()
1052 txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; in brcms_b_txstatus()
1053 txs->sequence = s2 & TXS_SEQ_MASK; in brcms_b_txstatus()
1054 txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; in brcms_b_txstatus()
1055 txs->lasttxtime = 0; in brcms_b_txstatus()
1057 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1068 if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_tbtt()
1073 wlc->qvalid |= MCMD_DIRFRMQVAL; in brcms_c_tbtt()
1080 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef()
1087 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_c_mhfdef()
1090 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { in brcms_c_mhfdef()
1109 * ucode host flag 2 needed for pio mode, independent of band and fifo in brcms_b_attach_dmapio()
1112 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio()
1113 uint unit = wlc_hw->unit; in brcms_b_attach_dmapio()
1118 if (wlc_hw->di[0] == NULL) { /* Init FIFOs */ in brcms_b_attach_dmapio()
1126 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1130 RXBUFSZ, -1, NRXBUFPOST, in brcms_b_attach_dmapio()
1132 dma_attach_err |= (NULL == wlc_hw->di[0]); in brcms_b_attach_dmapio()
1136 * TX: TX_AC_BE_FIFO (TX AC Best-Effort data packets) in brcms_b_attach_dmapio()
1140 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1142 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1143 dma_attach_err |= (NULL == wlc_hw->di[1]); in brcms_b_attach_dmapio()
1150 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1152 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1153 dma_attach_err |= (NULL == wlc_hw->di[2]); in brcms_b_attach_dmapio()
1159 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1161 0, NTXD, 0, 0, -1, in brcms_b_attach_dmapio()
1163 dma_attach_err |= (NULL == wlc_hw->di[3]); in brcms_b_attach_dmapio()
1167 brcms_err(wlc_hw->d11core, in brcms_b_attach_dmapio()
1175 if (wlc_hw->di[i]) in brcms_b_attach_dmapio()
1176 wlc_hw->txavail[i] = in brcms_b_attach_dmapio()
1177 (uint *) dma_getvar(wlc_hw->di[i], in brcms_b_attach_dmapio()
1182 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1192 if (wlc_hw->di[j]) { in brcms_b_detach_dmapio()
1193 dma_detach(wlc_hw->di[j]); in brcms_b_detach_dmapio()
1194 wlc_hw->di[j] = NULL; in brcms_b_detach_dmapio()
1201 * may get overrides later in this function
1206 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init()
1209 wlc->defmacintmask = DEF_MACINTMASK; in brcms_b_info_init()
1212 wlc_hw->shortslot = false; in brcms_b_info_init()
1214 wlc_hw->SFBL = RETRY_SHORT_FB; in brcms_b_info_init()
1215 wlc_hw->LFBL = RETRY_LONG_FB; in brcms_b_info_init()
1218 wlc_hw->SRL = RETRY_SHORT_DEF; in brcms_b_info_init()
1219 wlc_hw->LRL = RETRY_LONG_DEF; in brcms_b_info_init()
1220 wlc_hw->chanspec = ch20mhz_chspec(1); in brcms_b_info_init()
1230 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1236 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) { in brcms_b_clkctl_clk()
1243 if (wlc_hw->clk) { in brcms_b_clkctl_clk()
1245 bcma_set32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1252 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1256 WARN_ON(!(bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1260 if ((ai_get_pmurev(wlc_hw->sih) == 0) && in brcms_b_clkctl_clk()
1261 (bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1265 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1270 bcma_mask32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1275 wlc_hw->forcefastclk = (mode == BCMA_CLKMODE_FAST); in brcms_b_clkctl_clk()
1282 wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); in brcms_b_clkctl_clk()
1284 /* check fast clock is available (if core is not in reset) */ in brcms_b_clkctl_clk()
1285 if (wlc_hw->forcefastclk && wlc_hw->clk) in brcms_b_clkctl_clk()
1286 WARN_ON(!(bcma_aread32(wlc_hw->d11core, BCMA_IOST) & in brcms_b_clkctl_clk()
1293 * current forcefastclk state. Only setting bit in wake_override in brcms_b_clkctl_clk()
1295 * behavior. Older code set wlc->forcefastclk but only had the in brcms_b_clkctl_clk()
1299 if (wlc_hw->forcefastclk) in brcms_b_clkctl_clk()
1300 mboolset(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1303 mboolclr(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1309 * it has an optimization for no-change write
1311 * pre-CLK changes should use wlc_write_mhf to get around the optimization
1314 * bands values are: BRCM_BAND_AUTO <--- Current band only
1315 * BRCM_BAND_5G <--- 5G band only
1316 * BRCM_BAND_2G <--- 2G band only
1317 * BRCM_BAND_ALL <--- All bands
1328 struct brcms_hw_band *band; in brcms_b_mhf() local
1334 /* Current band only or all bands, in brcms_b_mhf()
1335 * then set the band to current band in brcms_b_mhf()
1339 band = wlc_hw->band; in brcms_b_mhf()
1342 band = wlc_hw->bandstate[BAND_5G_INDEX]; in brcms_b_mhf()
1345 band = wlc_hw->bandstate[BAND_2G_INDEX]; in brcms_b_mhf()
1348 band = NULL; /* error condition */ in brcms_b_mhf()
1351 if (band) { in brcms_b_mhf()
1352 save = band->mhfs[idx]; in brcms_b_mhf()
1353 band->mhfs[idx] = (band->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1356 * changed band is the current band in brcms_b_mhf()
1358 if (wlc_hw->clk && (band->mhfs[idx] != save) in brcms_b_mhf()
1359 && (band == wlc_hw->band)) in brcms_b_mhf()
1361 (u16) band->mhfs[idx]); in brcms_b_mhf()
1365 wlc_hw->bandstate[0]->mhfs[idx] = in brcms_b_mhf()
1366 (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1367 wlc_hw->bandstate[1]->mhfs[idx] = in brcms_b_mhf()
1368 (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1378 wlc_hw->maccontrol = 0; in brcms_c_mctrl_reset()
1379 wlc_hw->suspended_fifos = 0; in brcms_c_mctrl_reset()
1380 wlc_hw->wake_override = 0; in brcms_c_mctrl_reset()
1381 wlc_hw->mute_override = 0; in brcms_c_mctrl_reset()
1391 u32 maccontrol = wlc_hw->maccontrol; in brcms_c_mctrl_write()
1393 /* OR in the wake bit if overridden */ in brcms_c_mctrl_write()
1394 if (wlc_hw->wake_override) in brcms_c_mctrl_write()
1398 if (wlc_hw->mute_override) { in brcms_c_mctrl_write()
1403 bcma_write32(wlc_hw->d11core, D11REGOFFS(maccontrol), in brcms_c_mctrl_write()
1415 maccontrol = wlc_hw->maccontrol; in brcms_b_mctrl()
1423 wlc_hw->maccontrol = new_maccontrol; in brcms_b_mctrl()
1432 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { in brcms_c_ucode_wake_override_set()
1433 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1437 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1446 mboolclr(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_clear()
1448 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) in brcms_c_ucode_wake_override_clear()
1458 * STA 0 1 <--- This will ensure no beacons
1463 wlc_hw->mute_override = 1; in brcms_c_ucode_mute_override_set()
1468 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_set()
1477 if (wlc_hw->mute_override == 0) in brcms_c_ucode_mute_override_clear()
1480 wlc_hw->mute_override = 0; in brcms_c_ucode_mute_override_clear()
1485 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_clear()
1492 * Write a MAC address to the given match reg offset in the RXE match engine.
1498 struct bcma_device *core = wlc_hw->d11core; in brcms_b_set_addrmatch()
1503 brcms_dbg_rx(core, "wl%d: brcms_b_set_addrmatch\n", wlc_hw->unit); in brcms_b_set_addrmatch()
1521 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_template_ram()
1526 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_write_template_ram()
1530 /* if MCTL_BIGEND bit set in mac control register, in brcms_b_write_template_ram()
1531 * the chip swaps data in fifo, as well as data in in brcms_b_write_template_ram()
1550 len -= sizeof(u32); in brcms_b_write_template_ram()
1556 wlc_hw->band->CWmin = newmin; in brcms_b_set_cwmin()
1558 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmin()
1560 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmin()
1561 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmin); in brcms_b_set_cwmin()
1566 wlc_hw->band->CWmax = newmax; in brcms_b_set_cwmax()
1568 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmax()
1570 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmax()
1571 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmax); in brcms_b_set_cwmax()
1579 fastclk = wlc_hw->forcefastclk; in brcms_b_bw_set()
1583 wlc_phy_bw_state_set(wlc_hw->band->pi, bw); in brcms_b_bw_set()
1586 wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); in brcms_b_bw_set()
1596 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu()
1599 if (BRCMS_ISLCNPHY(wlc->band)) in brcms_b_upd_synthpu()
1601 else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) in brcms_b_upd_synthpu()
1612 u16 phytxant = wlc_hw->bmac_phytxant; in brcms_c_ucode_txant_set()
1635 /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ in brcms_b_ofdm_ratetable_offset()
1654 /* Find the SHM pointer to the rate table entry by looking in the in brcms_b_ofdm_ratetable_offset()
1655 * Direct-map Table in brcms_b_ofdm_ratetable_offset()
1671 if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_upd_ofdm_pctl1_table()
1686 pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); in brcms_upd_ofdm_pctl1_table()
1694 /* band-specific init */
1697 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit()
1699 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_b_bsinit()
1700 wlc_hw->band->bandunit); in brcms_b_bsinit()
1704 wlc_phy_init(wlc_hw->band->pi, chanspec); in brcms_b_bsinit()
1709 * cwmin is band-specific, update hardware in brcms_b_bsinit()
1710 * with value for current band in brcms_b_bsinit()
1712 brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); in brcms_b_bsinit()
1713 brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); in brcms_b_bsinit()
1716 wlc_hw->band->bandtype == BRCM_BAND_5G ? in brcms_b_bsinit()
1717 true : wlc_hw->shortslot); in brcms_b_bsinit()
1720 brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); in brcms_b_bsinit()
1721 brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); in brcms_b_bsinit()
1735 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr), in brcms_b_core_phypll_reset()
1738 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1741 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1744 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1755 if (!BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_phyclk_fgc()
1775 struct brcms_phy_pub *pih = wlc_hw->band->pi; in brcms_b_phy_reset()
1778 brcms_dbg_info(wlc_hw->d11core, "wl%d: reset phy\n", wlc_hw->unit); in brcms_b_phy_reset()
1783 phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); in brcms_b_phy_reset()
1786 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && in brcms_b_phy_reset()
1787 NREV_LE(wlc_hw->band->phyrev, 4)) { in brcms_b_phy_reset()
1811 /* switch to and initialize new band */
1814 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband()
1818 if (!bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_setband()
1819 bcma_core_enable(wlc_hw->d11core, 0); in brcms_b_setband()
1825 if (!wlc_hw->up) in brcms_b_setband()
1830 /* band-specific initializations */ in brcms_b_setband()
1836 * so brcms_c_dpc() will re-enable interrupts when done. in brcms_b_setband()
1838 if (wlc->macintstatus) in brcms_b_setband()
1839 wlc->macintstatus = MI_DMAINT; in brcms_b_setband()
1842 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_setband()
1845 WARN_ON((bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & in brcms_b_setband()
1853 if (!CONF_HAS(D11CONF, wlc_hw->corerev)) { in brcms_c_isgoodchip()
1854 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
1855 wlc_hw->corerev); in brcms_c_isgoodchip()
1865 uint boardrev = wlc_hw->boardrev; in brcms_c_validboardtype()
1874 if (ai_get_boardvendor(wlc_hw->sih) != PCI_VENDOR_ID_BROADCOM) in brcms_c_validboardtype()
1893 struct ssb_sprom *sprom = &wlc_hw->d11core->bus->sprom; in brcms_c_get_macaddr()
1896 if (!is_zero_ether_addr(sprom->il0mac)) { in brcms_c_get_macaddr()
1897 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1901 if (wlc_hw->_nbands > 1) in brcms_c_get_macaddr()
1902 memcpy(etheraddr, sprom->et1mac, ETH_ALEN); in brcms_c_get_macaddr()
1904 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1910 brcms_dbg_info(wlc_hw->d11core, "wl%d: want %d\n", wlc_hw->unit, want); in brcms_b_xtal()
1916 if (!want && wlc_hw->pllreq) in brcms_b_xtal()
1919 wlc_hw->sbclk = want; in brcms_b_xtal()
1920 if (!wlc_hw->sbclk) { in brcms_b_xtal()
1921 wlc_hw->clk = false; in brcms_b_xtal()
1922 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_xtal()
1923 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_xtal()
1938 xtal = wlc_hw->sbclk; in brcms_b_radio_read_hwdisabled()
1943 clk = wlc_hw->clk; in brcms_b_radio_read_hwdisabled()
1950 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_radio_read_hwdisabled()
1960 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_radio_read_hwdisabled()
1964 v = ((bcma_read32(wlc_hw->d11core, in brcms_b_radio_read_hwdisabled()
1969 bcma_core_disable(wlc_hw->d11core, 0); in brcms_b_radio_read_hwdisabled()
1979 struct dma_pub *di = wlc_hw->di[fifo]; in wlc_dma_rxreset()
1989 * one testing hack wlc_hw->noreset will bypass the d11/phy reset
1997 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); in brcms_b_corereset()
1999 brcms_dbg_info(wlc_hw->d11core, "wl%d: core reset\n", wlc_hw->unit); in brcms_b_corereset()
2002 fastclk = wlc_hw->forcefastclk; in brcms_b_corereset()
2007 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_corereset()
2009 if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) in brcms_b_corereset()
2010 brcms_err(wlc_hw->d11core, "wl%d: %s: " in brcms_b_corereset()
2012 wlc_hw->unit, __func__, i); in brcms_b_corereset()
2014 if ((wlc_hw->di[RX_FIFO]) in brcms_b_corereset()
2016 brcms_err(wlc_hw->d11core, "wl%d: %s: dma_rxreset" in brcms_b_corereset()
2018 wlc_hw->unit, __func__, RX_FIFO); in brcms_b_corereset()
2021 if (wlc_hw->noreset) { in brcms_b_corereset()
2022 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2030 * band->pi is invalid. need to enable PHY CLK in brcms_b_corereset()
2032 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_corereset()
2037 * In chips with PMU, the fastclk request goes through d11 core in brcms_b_corereset()
2038 * reg 0x1e0, which is cleared by the core_reset. have to re-request it. in brcms_b_corereset()
2045 wlc_hw->clk = false; in brcms_b_corereset()
2046 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_corereset()
2047 wlc_hw->clk = true; in brcms_b_corereset()
2048 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_corereset()
2049 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); in brcms_b_corereset()
2053 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) in brcms_b_corereset()
2062 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2074 struct bcma_device *core = wlc_hw->d11core; in brcms_b_corerev_fifofixup()
2086 txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2088 (((txfifo_endblk - 1) & 0xff) << TXFIFO_FIFOTOP_SHIFT); in brcms_b_corerev_fifofixup()
2090 ((((txfifo_endblk - in brcms_b_corerev_fifofixup()
2101 txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2104 * need to propagate to shm location to be in sync since ucode/hw won't in brcms_b_corerev_fifofixup()
2108 wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); in brcms_b_corerev_fifofixup()
2110 wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); in brcms_b_corerev_fifofixup()
2112 ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2115 ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2124 * For spuron2 - 126MHz -> 2^26/126 = 532610.0
2125 * - 532610 = 0x82082 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x2082
2126 * For spuron: 123MHz -> 2^26/123 = 545600.5
2127 * - 545601 = 0x85341 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x5341
2128 * For spur off: 120MHz -> 2^26/120 = 559240.5
2129 * - 559241 = 0x88889 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x8889
2134 struct bcma_device *core = wlc_hw->d11core; in brcms_b_switch_macfreq()
2136 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43224) || in brcms_b_switch_macfreq()
2137 (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) { in brcms_b_switch_macfreq()
2148 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_switch_macfreq()
2161 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_station()
2162 wlc->bsscfg->type = BRCMS_TYPE_STATION; in brcms_c_start_station()
2170 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_ap()
2171 memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID)); in brcms_c_start_ap()
2172 wlc->bsscfg->type = BRCMS_TYPE_AP; in brcms_c_start_ap()
2174 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA); in brcms_c_start_ap()
2179 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_adhoc()
2180 wlc->bsscfg->type = BRCMS_TYPE_ADHOC; in brcms_c_start_adhoc()
2182 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0); in brcms_c_start_adhoc()
2188 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init()
2205 if (wlc_hw->antsel_type == ANTSEL_2x3) { in brcms_c_gpio_init()
2213 wlc_phy_antsel_init(wlc_hw->band->pi, false); in brcms_c_gpio_init()
2215 } else if (wlc_hw->antsel_type == ANTSEL_2x4) { in brcms_c_gpio_init()
2221 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_oe), in brcms_c_gpio_init()
2223 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_out), in brcms_c_gpio_init()
2241 if (wlc_hw->boardflags & BFL_PACTRL) in brcms_c_gpio_init()
2245 bcma_chipco_gpio_control(&wlc_hw->d11core->bus->drv_cc, gm, gc); in brcms_c_gpio_init()
2251 struct bcma_device *core = wlc_hw->d11core; in brcms_ucode_write()
2255 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_ucode_write()
2269 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2271 if (wlc_hw->ucode_loaded) in brcms_ucode_download()
2274 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_ucode_download()
2275 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_ucode_download()
2276 brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, in brcms_ucode_download()
2277 ucode->bcm43xx_16_mimosz); in brcms_ucode_download()
2278 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2280 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2281 "%s: wl%d: unsupported phy in corerev %d\n", in brcms_ucode_download()
2282 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2283 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_ucode_download()
2284 if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_ucode_download()
2285 brcms_ucode_write(wlc_hw, ucode->bcm43xx_24_lcn, in brcms_ucode_download()
2286 ucode->bcm43xx_24_lcnsz); in brcms_ucode_download()
2287 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2289 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2290 "%s: wl%d: unsupported phy in corerev %d\n", in brcms_ucode_download()
2291 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2299 wlc_hw->bmac_phytxant = phytxant; in brcms_b_txant_set()
2302 if (!wlc_hw->up) in brcms_b_txant_set()
2310 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2315 wlc_hw->antsel_type = antsel_type; in brcms_b_antsel_type_set()
2318 wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); in brcms_b_antsel_type_set()
2326 struct bcma_device *core = wlc_hw->d11core; in brcms_b_fifoerrors()
2328 unit = wlc_hw->unit; in brcms_b_fifoerrors()
2331 /* read intstatus register and ignore any non-error bits */ in brcms_b_fifoerrors()
2377 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2388 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson()
2389 wlc->macintmask = wlc->defmacintmask; in brcms_c_intrson()
2390 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2395 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff()
2398 if (!wlc_hw->clk) in brcms_c_intrsoff()
2401 macintmask = wlc->macintmask; /* isr can still happen */ in brcms_c_intrsoff()
2403 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), 0); in brcms_c_intrsoff()
2404 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(macintmask)); in brcms_c_intrsoff()
2406 wlc->macintmask = 0; in brcms_c_intrsoff()
2409 return wlc->macintstatus ? 0 : macintmask; in brcms_c_intrsoff()
2414 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore()
2415 if (!wlc_hw->clk) in brcms_c_intrsrestore()
2418 wlc->macintmask = macintmask; in brcms_c_intrsrestore()
2419 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2431 if ((wlc_hw->suspended_fifos & fifo) == fifo) in brcms_b_tx_fifo_suspend()
2435 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_suspend()
2439 wlc_hw->suspended_fifos |= fifo; in brcms_b_tx_fifo_suspend()
2441 if (wlc_hw->di[tx_fifo]) { in brcms_b_tx_fifo_suspend()
2443 * Suspending AMPDU transmissions in the middle can cause in brcms_b_tx_fifo_suspend()
2444 * underflow which may result in mismatch between ucode and in brcms_b_tx_fifo_suspend()
2447 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2448 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2450 dma_txsuspend(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_suspend()
2452 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2453 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2460 /* BMAC_NOTE: BRCMS_TX_FIFO_ENAB is done in brcms_c_dpc() for DMA case in brcms_b_tx_fifo_resume()
2465 if (wlc_hw->di[tx_fifo]) in brcms_b_tx_fifo_resume()
2466 dma_txresume(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_resume()
2469 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2472 wlc_hw->suspended_fifos &= ~(1 << tx_fifo); in brcms_b_tx_fifo_resume()
2473 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2483 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2505 wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); in brcms_b_mute()
2516 brcms_b_mute(wlc->hw, mute_tx); in brcms_c_mute()
2523 * -1 if brcms_deviceremoved(wlc) evaluates to true;
2524 * 0 if the interrupt is not for us, or we are in some special cases;
2529 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus()
2530 struct bcma_device *core = wlc_hw->d11core; in wlc_intstatus()
2535 mask = in_isr ? wlc->macintmask : wlc->defmacintmask; in wlc_intstatus()
2537 trace_brcms_macintstatus(&core->dev, in_isr, macintstatus, mask); in wlc_intstatus()
2539 /* detect cardbus removed, in power down(suspend) and in reset */ in wlc_intstatus()
2541 return -1; in wlc_intstatus()
2559 wlc->macintmask = 0; in wlc_intstatus()
2564 /* MI_DMAINT is indication of non-zero intstatus */ in wlc_intstatus()
2567 * only fifo interrupt enabled is I_RI in in wlc_intstatus()
2577 /* Update wlc->macintstatus and wlc->intstatus[]. */
2590 /* update interrupt status in software */ in brcms_c_intrsupd()
2591 wlc->macintstatus |= macintstatus; in brcms_c_intrsupd()
2597 * First-level interrupt processing.
2604 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr()
2607 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2614 brcms_err(wlc_hw->d11core, in brcms_c_isr()
2615 "DEVICEREMOVED detected in the ISR code path\n"); in brcms_c_isr()
2624 wlc->macintstatus = macintstatus; in brcms_c_isr()
2632 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait()
2633 struct bcma_device *core = wlc_hw->d11core; in brcms_c_suspend_mac_and_wait()
2636 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2637 wlc_hw->band->bandunit); in brcms_c_suspend_mac_and_wait()
2642 wlc_hw->mac_suspend_depth++; in brcms_c_suspend_mac_and_wait()
2643 if (wlc_hw->mac_suspend_depth > 1) in brcms_c_suspend_mac_and_wait()
2652 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2654 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2663 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2665 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2678 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); in brcms_c_suspend_mac_and_wait()
2680 "psm_brc 0x%04x\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2688 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2690 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2700 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac()
2701 struct bcma_device *core = wlc_hw->d11core; in brcms_c_enable_mac()
2704 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_enable_mac()
2705 wlc->band->bandunit); in brcms_c_enable_mac()
2710 wlc_hw->mac_suspend_depth--; in brcms_c_enable_mac()
2711 if (wlc_hw->mac_suspend_depth > 0) in brcms_c_enable_mac()
2736 wlc_hw->hw_stf_ss_opmode = stf_mode; in brcms_b_band_stf_ss_set()
2738 if (wlc_hw->clk) in brcms_b_band_stf_ss_set()
2744 struct bcma_device *core = wlc_hw->d11core; in brcms_b_validate_chip_access()
2746 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2764 "expected 0xaa5555aa\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2777 "expected 0x55aaaa55\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2792 "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, in brcms_b_validate_chip_access()
2805 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_phypll_ctl()
2808 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_core_phypll_ctl()
2813 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_core_phypll_ctl()
2860 brcms_dbg_info(wlc_hw->d11core, "wl%d: disable core\n", wlc_hw->unit); in brcms_c_coredisable()
2862 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2867 if (wlc_hw->noreset) in brcms_c_coredisable()
2871 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2874 wlc_phy_anacore(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2879 wlc_hw->clk = false; in brcms_c_coredisable()
2880 bcma_core_disable(wlc_hw->d11core, 0); in brcms_c_coredisable()
2881 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_c_coredisable()
2886 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues()
2891 if (wlc_hw->di[i]) { in brcms_c_flushqueues()
2892 dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); in brcms_c_flushqueues()
2894 ieee80211_wake_queue(wlc->pub->ieee_hw, in brcms_c_flushqueues()
2900 dma_rxreclaim(wlc_hw->di[RX_FIFO]); in brcms_c_flushqueues()
2906 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_objmem()
2921 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_objmem()
3004 brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); in brcms_c_copyto_shm()
3010 wlc_hw->SRL = SRL; in brcms_b_retrylimit_upd()
3011 wlc_hw->LRL = LRL; in brcms_b_retrylimit_upd()
3014 if (wlc_hw->up) { in brcms_b_retrylimit_upd()
3015 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3017 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3018 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_retrylimit_upd()
3019 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3021 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3022 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_retrylimit_upd()
3029 if (mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3032 mboolset(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3034 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3035 if (!wlc_hw->sbclk) in brcms_b_pllreq()
3039 if (!mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3042 mboolclr(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3044 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3045 if (wlc_hw->sbclk) in brcms_b_pllreq()
3053 wlc_hw->antsel_avail = antsel_avail; in brcms_b_antsel_set()
3057 * conditions under which the PM bit should be set in outgoing frames
3077 if (!wlc->pub->up) in brcms_c_statsupd()
3080 macstats = wlc->core->macstat_snapshot; in brcms_c_statsupd()
3084 rxf0ovfl = macstats->rxf0ovfl; in brcms_c_statsupd()
3088 txfunfl[i] = macstats->txfunfl[i]; in brcms_c_statsupd()
3092 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, macstats, in brcms_c_statsupd()
3097 delta = (u16)(macstats->rxf0ovfl - rxf0ovfl); in brcms_c_statsupd()
3099 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n", in brcms_c_statsupd()
3100 wlc->pub->unit, delta); in brcms_c_statsupd()
3104 delta = macstats->txfunfl[i] - txfunfl[i]; in brcms_c_statsupd()
3106 brcms_err(wlc->hw->d11core, in brcms_c_statsupd()
3108 wlc->pub->unit, delta, i); in brcms_c_statsupd()
3114 if (wlc->hw->di[i]) in brcms_c_statsupd()
3115 dma_counterreset(wlc->hw->di[i]); in brcms_c_statsupd()
3122 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3126 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3131 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_reset()
3137 memset(wlc->core->macstat_snapshot, 0, sizeof(struct macstat)); in brcms_c_reset()
3139 brcms_b_reset(wlc->hw); in brcms_c_reset()
3147 scb->flags = SCB_WMECAP | SCB_HTCAP; in brcms_c_init_scb()
3149 scb->seqnum[i] = 0; in brcms_c_init_scb()
3152 scb->magic = SCB_MAGIC; in brcms_c_init_scb()
3165 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit()
3166 struct bcma_device *core = wlc_hw->d11core; in brcms_b_coreinit()
3172 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3174 brcms_dbg_info(core, "wl%d: core init\n", wlc_hw->unit); in brcms_b_coreinit()
3186 bcma_write32(core, D11REGOFFS(macintstatus), -1); in brcms_b_coreinit()
3190 /* wait for ucode to self-suspend after auto-init */ in brcms_b_coreinit()
3194 brcms_err(core, "wl%d: wlc_coreinit: ucode did not self-" in brcms_b_coreinit()
3195 "suspend!\n", wlc_hw->unit); in brcms_b_coreinit()
3201 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_b_coreinit()
3202 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_coreinit()
3203 brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); in brcms_b_coreinit()
3205 brcms_err(core, "%s: wl%d: unsupported phy in corerev" in brcms_b_coreinit()
3206 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3207 wlc_hw->corerev); in brcms_b_coreinit()
3208 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_b_coreinit()
3209 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_b_coreinit()
3210 brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); in brcms_b_coreinit()
3212 brcms_err(core, "%s: wl%d: unsupported phy in corerev" in brcms_b_coreinit()
3213 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3214 wlc_hw->corerev); in brcms_b_coreinit()
3217 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_b_coreinit()
3226 if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { in brcms_b_coreinit()
3228 err = -1; in brcms_b_coreinit()
3231 if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { in brcms_b_coreinit()
3233 err = -1; in brcms_b_coreinit()
3238 if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { in brcms_b_coreinit()
3240 err = -1; in brcms_b_coreinit()
3242 if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { in brcms_b_coreinit()
3244 err = -1; in brcms_b_coreinit()
3249 if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { in brcms_b_coreinit()
3251 err = -1; in brcms_b_coreinit()
3253 if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { in brcms_b_coreinit()
3255 err = -1; in brcms_b_coreinit()
3260 wlc_hw->xmtfifo_sz[i], i); in brcms_b_coreinit()
3265 /* band-specific inits done by wlc_bsinit() */ in brcms_b_coreinit()
3294 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3295 bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); in brcms_b_coreinit()
3298 brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); in brcms_b_coreinit()
3302 (u16) (wlc_hw->machwcap & 0xffff)); in brcms_b_coreinit()
3304 (u16) ((wlc_hw-> in brcms_b_coreinit()
3311 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_coreinit()
3315 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_coreinit()
3318 brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); in brcms_b_coreinit()
3319 brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); in brcms_b_coreinit()
3326 if (wlc_hw->di[i]) in brcms_b_coreinit()
3327 dma_txinit(wlc_hw->di[i]); in brcms_b_coreinit()
3331 dma_rxinit(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3332 dma_rxfill(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3339 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init()
3342 fastclk = wlc_hw->forcefastclk; in brcms_b_init()
3347 macintmask = brcms_intrsoff(wlc->wl); in brcms_b_init()
3349 /* set up the specified band and chanspec */ in brcms_b_init()
3351 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_init()
3353 /* do one-time phy inits and calibration */ in brcms_b_init()
3354 wlc_phy_cal_init(wlc_hw->band->pi); in brcms_b_init()
3356 /* core-specific initialization */ in brcms_b_init()
3359 /* band-specific inits */ in brcms_b_init()
3363 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_init()
3368 mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); in brcms_b_init()
3374 wlc_hw->mac_suspend_depth = 1; in brcms_b_init()
3385 wlc->chanspec = chanspec; in brcms_c_set_phy_chanspec()
3388 brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); in brcms_c_set_phy_chanspec()
3390 if (wlc->stf->ss_algosel_auto) in brcms_c_set_phy_chanspec()
3391 brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, in brcms_c_set_phy_chanspec()
3394 brcms_c_stf_ss_update(wlc, wlc->band); in brcms_c_set_phy_chanspec()
3400 brcms_c_rateset_default(rs, NULL, wlc->band->phytype, in brcms_default_rateset()
3401 wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_default_rateset()
3402 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_default_rateset()
3403 brcms_chspec_bw(wlc->default_bss->chanspec), in brcms_default_rateset()
3404 wlc->stf->txstreams); in brcms_default_rateset()
3407 /* derive wlc->band->basic_rate[] table from 'rateset' */
3415 u8 *br = wlc->band->basic_rate; in brcms_c_rate_lookup_init()
3418 /* incoming rates are in 500kbps units as in 802.11 Supported Rates */ in brcms_c_rate_lookup_init()
3421 /* For each basic rate in the rates list, make an entry in the in brcms_c_rate_lookup_init()
3424 for (i = 0; i < rateset->count; i++) { in brcms_c_rate_lookup_init()
3426 if (!(rateset->rates[i] & BRCMS_RATE_FLAG)) in brcms_c_rate_lookup_init()
3430 rate = (rateset->rates[i] & BRCMS_RATE_MASK); in brcms_c_rate_lookup_init()
3433 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: " in brcms_c_rate_lookup_init()
3434 "invalid rate 0x%X in rate set\n", in brcms_c_rate_lookup_init()
3435 rateset->rates[i]); in brcms_c_rate_lookup_init()
3442 /* The rate lookup table now has non-zero entries for each in brcms_c_rate_lookup_init()
3449 * basic_rate = wlc->band->basic_rate[tx_rate] in brcms_c_rate_lookup_init()
3453 * to high, filling in holes in the lookup table in brcms_c_rate_lookup_init()
3456 for (i = 0; i < wlc->band->hw_rateset.count; i++) { in brcms_c_rate_lookup_init()
3457 rate = wlc->band->hw_rateset.rates[i]; in brcms_c_rate_lookup_init()
3473 * best basic rate less than this rate and fill in in brcms_c_rate_lookup_init()
3474 * the hole in the table in brcms_c_rate_lookup_init()
3484 * In 11g and 11a, the OFDM mandatory rates in brcms_c_rate_lookup_init()
3494 /* In 11b, all CCK rates are mandatory 1 - 11 Mbps */ in brcms_c_rate_lookup_init()
3511 * power-cycled (hibernate). Figure out the right band to park on in brcms_c_bandinit_ordered()
3513 if (wlc->bandlocked || wlc->pub->_nbands == 1) { in brcms_c_bandinit_ordered()
3514 /* updated in brcms_c_bandlock() */ in brcms_c_bandinit_ordered()
3515 parkband = wlc->band->bandunit; in brcms_c_bandinit_ordered()
3518 /* park on the band of the specified chanspec */ in brcms_c_bandinit_ordered()
3526 /* make each band operational, software state init */ in brcms_c_bandinit_ordered()
3527 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_bandinit_ordered()
3530 wlc->band = wlc->bandstate[j]; in brcms_c_bandinit_ordered()
3534 /* fill in hw_rate */ in brcms_c_bandinit_ordered()
3535 brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, in brcms_c_bandinit_ordered()
3537 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_bandinit_ordered()
3555 wlc->filter_flags = filter_flags; in brcms_c_mac_promisc()
3569 brcms_b_mctrl(wlc->hw, in brcms_c_mac_promisc()
3584 if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { in brcms_c_ucode_mac_upd()
3585 if (wlc->pub->associated) { in brcms_c_ucode_mac_upd()
3588 * in ucode inits. I think that the ucode inits set in brcms_c_ucode_mac_upd()
3590 * beacon. This should not be done in the inits. If in brcms_c_ucode_mac_upd()
3595 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_ucode_mac_upd()
3596 brcms_b_write_shm(wlc->hw, in brcms_c_ucode_mac_upd()
3619 * for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_c_write_rate_shm()
3627 /* Find the SHM pointer to the ACK rate entry by looking in the in brcms_c_write_rate_shm()
3628 * Direct-map Table in brcms_c_write_rate_shm()
3630 basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); in brcms_c_write_rate_shm()
3632 /* Update the SHM BSS-basic-rate-set mapping table with the pointer in brcms_c_write_rate_shm()
3635 brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); in brcms_c_write_rate_shm()
3643 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rateset_get_hwrs()
3644 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_rateset_get_hwrs()
3648 } else if (wlc->band->gmode) in brcms_c_rateset_get_hwrs()
3666 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_set_ratetable()
3686 /* band-specific init */
3689 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n", in brcms_c_bsinit()
3690 wlc->pub->unit, wlc->band->bandunit); in brcms_c_bsinit()
3695 /* update some band specific mac configuration */ in brcms_c_bsinit()
3699 brcms_c_antsel_init(wlc->asi); in brcms_c_bsinit()
3703 /* formula: IDLE_BUSY_RATIO_X_16 = (100-duty_cycle)/duty_cycle*16 */
3713 brcms_err(wlc->hw->d11core, in brcms_c_duty_cycle_set()
3715 wlc->pub->unit); in brcms_c_duty_cycle_set()
3716 return -EINVAL; in brcms_c_duty_cycle_set()
3719 idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; in brcms_c_duty_cycle_set()
3722 brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); in brcms_c_duty_cycle_set()
3725 wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3727 wlc->tx_duty_cycle_cck = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3741 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit, in brcms_c_set_ps_ctrl()
3744 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_set_ps_ctrl()
3749 brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); in brcms_c_set_ps_ctrl()
3754 brcms_b_wait_for_wake(wlc->hw); in brcms_c_set_ps_ctrl()
3763 struct brcms_c_info *wlc = bsscfg->wlc; in brcms_c_set_mac()
3766 brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr); in brcms_c_set_mac()
3771 /* Write the BSS config's BSSID address to core (set_bssid in d11procs.tcl).
3776 /* we need to update BSSID in RXE match registers */ in brcms_c_set_bssid()
3777 brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); in brcms_c_set_bssid()
3782 u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len); in brcms_c_set_ssid()
3783 memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID)); in brcms_c_set_ssid()
3785 memcpy(wlc->bsscfg->SSID, ssid, len); in brcms_c_set_ssid()
3786 wlc->bsscfg->SSID_len = len; in brcms_c_set_ssid()
3791 wlc_hw->shortslot = shortslot; in brcms_b_set_shortslot()
3793 if (wlc_hw->band->bandtype == BRCM_BAND_2G && wlc_hw->up) { in brcms_b_set_shortslot()
3794 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3796 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3807 if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) in brcms_c_switch_shortslot()
3808 shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); in brcms_c_switch_shortslot()
3810 if (wlc->shortslot == shortslot) in brcms_c_switch_shortslot()
3813 wlc->shortslot = shortslot; in brcms_c_switch_shortslot()
3815 brcms_b_set_shortslot(wlc->hw, shortslot); in brcms_c_switch_shortslot()
3820 if (wlc->home_chanspec != chanspec) { in brcms_c_set_home_chanspec()
3821 wlc->home_chanspec = chanspec; in brcms_c_set_home_chanspec()
3823 if (wlc->pub->associated) in brcms_c_set_home_chanspec()
3824 wlc->bsscfg->current_bss->chanspec = chanspec; in brcms_c_set_home_chanspec()
3834 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: 0x%x\n", wlc_hw->unit, in brcms_b_set_chanspec()
3837 wlc_hw->chanspec = chanspec; in brcms_b_set_chanspec()
3840 if (wlc_hw->_nbands > 1) { in brcms_b_set_chanspec()
3842 if (wlc_hw->band->bandunit != bandunit) { in brcms_b_set_chanspec()
3844 * use light band switch if not up yet in brcms_b_set_chanspec()
3846 if (wlc_hw->up) { in brcms_b_set_chanspec()
3847 wlc_phy_chanspec_radio_set(wlc_hw-> in brcms_b_set_chanspec()
3848 bandstate[bandunit]-> in brcms_b_set_chanspec()
3857 wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); in brcms_b_set_chanspec()
3859 if (!wlc_hw->up) { in brcms_b_set_chanspec()
3860 if (wlc_hw->clk) in brcms_b_set_chanspec()
3861 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, in brcms_b_set_chanspec()
3863 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3865 wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3866 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); in brcms_b_set_chanspec()
3873 /* switch to and initialize new band */
3877 wlc->band = wlc->bandstate[bandunit]; in brcms_c_setband()
3879 if (!wlc->pub->up) in brcms_c_setband()
3885 /* band-specific initializations */ in brcms_c_setband()
3892 u16 old_chanspec = wlc->chanspec; in brcms_c_set_chanspec()
3894 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { in brcms_c_set_chanspec()
3895 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n", in brcms_c_set_chanspec()
3896 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); in brcms_c_set_chanspec()
3901 if (wlc->pub->_nbands > 1) { in brcms_c_set_chanspec()
3903 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { in brcms_c_set_chanspec()
3904 if (wlc->bandlocked) { in brcms_c_set_chanspec()
3905 brcms_err(wlc->hw->d11core, in brcms_c_set_chanspec()
3906 "wl%d: %s: chspec %d band is locked!\n", in brcms_c_set_chanspec()
3907 wlc->pub->unit, __func__, in brcms_c_set_chanspec()
3916 * band, or the following brcms_b_set_chanspec() may in brcms_c_set_chanspec()
3928 brcms_c_antsel_init(wlc->asi); in brcms_c_set_chanspec()
3933 brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, in brcms_c_set_chanspec()
3934 wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); in brcms_c_set_chanspec()
3944 * ratespec CCK ant = wlc->stf->txant
3951 u16 phytxant = wlc->stf->phytxant; in brcms_c_beacon_phytxctl_txant_upd()
3954 /* for non-siso rates or default setting, use the available chains */ in brcms_c_beacon_phytxctl_txant_upd()
3955 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_beacon_phytxctl_txant_upd()
3958 phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); in brcms_c_beacon_phytxctl_txant_upd()
3960 brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); in brcms_c_beacon_phytxctl_txant_upd()
3966 * in periodic function
3974 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); in brcms_c_protection_upd()
3978 wlc->protection->_g = (bool) val; in brcms_c_protection_upd()
3981 wlc->protection->g_override = (s8) val; in brcms_c_protection_upd()
3984 wlc->protection->gmode_user = (u8) val; in brcms_c_protection_upd()
3987 wlc->protection->overlap = (s8) val; in brcms_c_protection_upd()
3990 wlc->protection->nmode_user = (s8) val; in brcms_c_protection_upd()
3993 wlc->protection->n_cfg = (s8) val; in brcms_c_protection_upd()
3996 wlc->protection->n_cfg_override = (s8) val; in brcms_c_protection_upd()
3999 wlc->protection->nongf = (bool) val; in brcms_c_protection_upd()
4002 wlc->protection->nongf_override = (s8) val; in brcms_c_protection_upd()
4005 wlc->protection->n_pam_override = (s8) val; in brcms_c_protection_upd()
4008 wlc->protection->n_obss = (bool) val; in brcms_c_protection_upd()
4019 if (wlc->pub->up) { in brcms_c_ht_update_sgi_rx()
4027 wlc->stf->ldpc = val; in brcms_c_ht_update_ldpc()
4029 if (wlc->pub->up) { in brcms_c_ht_update_ldpc()
4032 wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); in brcms_c_ht_update_ldpc()
4045 if (!wlc->clk) { in brcms_c_wme_setparams()
4046 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n", in brcms_c_wme_setparams()
4047 wlc->pub->unit, __func__); in brcms_c_wme_setparams()
4052 /* fill in shm ac params struct */ in brcms_c_wme_setparams()
4053 acp_shm.txop = params->txop; in brcms_c_wme_setparams()
4055 wlc->edcf_txop[aci & 0x3] = acp_shm.txop = in brcms_c_wme_setparams()
4057 acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); in brcms_c_wme_setparams()
4065 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad " in brcms_c_wme_setparams()
4066 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); in brcms_c_wme_setparams()
4068 acp_shm.cwmin = params->cw_min; in brcms_c_wme_setparams()
4069 acp_shm.cwmax = params->cw_max; in brcms_c_wme_setparams()
4072 bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & in brcms_c_wme_setparams()
4076 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + in brcms_c_wme_setparams()
4082 /* Fill in shm acparam table */ in brcms_c_wme_setparams()
4085 brcms_b_write_shm(wlc->hw, in brcms_c_wme_setparams()
4116 aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; in brcms_c_edcf_setparams()
4118 /* fill in shm ac params struct */ in brcms_c_edcf_setparams()
4119 txq_pars.txop = edcf_acp->TXOP; in brcms_c_edcf_setparams()
4120 txq_pars.aifs = edcf_acp->ACI; in brcms_c_edcf_setparams()
4122 /* CWmin = 2^(ECWmin) - 1 */ in brcms_c_edcf_setparams()
4123 txq_pars.cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK); in brcms_c_edcf_setparams()
4124 /* CWmax = 2^(ECWmax) - 1 */ in brcms_c_edcf_setparams()
4125 txq_pars.cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK) in brcms_c_edcf_setparams()
4139 if (wlc->radio_monitor) in brcms_c_radio_monitor_start()
4142 wlc->radio_monitor = true; in brcms_c_radio_monitor_start()
4143 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_start()
4144 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); in brcms_c_radio_monitor_start()
4149 if (!wlc->radio_monitor) in brcms_c_radio_monitor_stop()
4152 wlc->radio_monitor = false; in brcms_c_radio_monitor_stop()
4153 brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_stop()
4154 return brcms_del_timer(wlc->radio_timer); in brcms_c_radio_monitor_stop()
4160 if (wlc->pub->hw_off) in brcms_c_radio_hwdisable_upd()
4163 if (brcms_b_radio_read_hwdisabled(wlc->hw)) in brcms_c_radio_hwdisable_upd()
4164 mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4166 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4174 return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? in brcms_c_check_radio_disabled()
4184 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_radio_timer()
4185 wlc->pub->unit, __func__); in brcms_c_radio_timer()
4186 brcms_down(wlc->wl); in brcms_c_radio_timer()
4193 /* common low-level watchdog code */
4196 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog()
4198 if (!wlc_hw->up) in brcms_b_watchdog()
4202 wlc_hw->now++; in brcms_b_watchdog()
4208 dma_rxfill(wlc->hw->di[RX_FIFO]); in brcms_b_watchdog()
4210 wlc_phy_watchdog(wlc_hw->band->pi); in brcms_b_watchdog()
4216 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_watchdog()
4218 if (!wlc->pub->up) in brcms_c_watchdog()
4222 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_watchdog()
4223 wlc->pub->unit, __func__); in brcms_c_watchdog()
4224 brcms_down(wlc->wl); in brcms_c_watchdog()
4229 wlc->pub->now++; in brcms_c_watchdog()
4233 if (wlc->pub->radio_disabled) in brcms_c_watchdog()
4240 * detect 16-bit counter wrap in brcms_c_watchdog()
4242 if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) in brcms_c_watchdog()
4245 if (BRCMS_ISNPHY(wlc->band) && in brcms_c_watchdog()
4246 ((wlc->pub->now - wlc->tempsense_lasttime) >= in brcms_c_watchdog()
4248 wlc->tempsense_lasttime = wlc->pub->now; in brcms_c_watchdog()
4262 wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, in brcms_c_timers_init()
4264 if (!wlc->wdtimer) { in brcms_c_timers_init()
4265 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " in brcms_c_timers_init()
4270 wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, in brcms_c_timers_init()
4272 if (!wlc->radio_timer) { in brcms_c_timers_init()
4273 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " in brcms_c_timers_init()
4286 * may get overrides later in this function
4293 wlc->chanspec = ch20mhz_chspec(1); in brcms_c_info_init()
4296 wlc->shortslot = false; in brcms_c_info_init()
4297 wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; in brcms_c_info_init()
4314 wlc->include_legacy_erp = true; in brcms_c_info_init()
4316 wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; in brcms_c_info_init()
4317 wlc->stf->txant = ANT_TX_DEF; in brcms_c_info_init()
4319 wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; in brcms_c_info_init()
4321 wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4323 wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4324 wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; in brcms_c_info_init()
4327 wlc->SFBL = RETRY_SHORT_FB; in brcms_c_info_init()
4328 wlc->LFBL = RETRY_LONG_FB; in brcms_c_info_init()
4331 wlc->SRL = RETRY_SHORT_DEF; in brcms_c_info_init()
4332 wlc->LRL = RETRY_LONG_DEF; in brcms_c_info_init()
4335 wlc->pub->_ampdu = AMPDU_AGG_HOST; in brcms_c_info_init()
4342 unit = wlc->pub->unit; in brcms_c_attach_module()
4344 wlc->asi = brcms_c_antsel_attach(wlc); in brcms_c_attach_module()
4345 if (wlc->asi == NULL) { in brcms_c_attach_module()
4346 wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " in brcms_c_attach_module()
4352 wlc->ampdu = brcms_c_ampdu_attach(wlc); in brcms_c_attach_module()
4353 if (wlc->ampdu == NULL) { in brcms_c_attach_module()
4354 wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " in brcms_c_attach_module()
4361 wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " in brcms_c_attach_module()
4372 return wlc->pub; in brcms_c_pub()
4378 * initialize software state for each core and band
4379 * put the whole chip in reset(driver down state), no clock
4389 struct wiphy *wiphy = wlc->wiphy; in brcms_b_attach()
4390 struct pci_dev *pcidev = core->bus->host_pci; in brcms_b_attach()
4391 struct ssb_sprom *sprom = &core->bus->sprom; in brcms_b_attach()
4393 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) in brcms_b_attach()
4395 pcidev->vendor, in brcms_b_attach()
4396 pcidev->device); in brcms_b_attach()
4399 core->bus->boardinfo.vendor, in brcms_b_attach()
4400 core->bus->boardinfo.type); in brcms_b_attach()
4404 wlc_hw = wlc->hw; in brcms_b_attach()
4405 wlc_hw->wlc = wlc; in brcms_b_attach()
4406 wlc_hw->unit = unit; in brcms_b_attach()
4407 wlc_hw->band = wlc_hw->bandstate[0]; in brcms_b_attach()
4408 wlc_hw->_piomode = piomode; in brcms_b_attach()
4417 wlc_hw->sih = ai_attach(core->bus); in brcms_b_attach()
4418 if (wlc_hw->sih == NULL) { in brcms_b_attach()
4433 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) { in brcms_b_attach()
4434 wlc_hw->vendorid = pcidev->vendor; in brcms_b_attach()
4435 wlc_hw->deviceid = pcidev->device; in brcms_b_attach()
4437 wlc_hw->vendorid = core->bus->boardinfo.vendor; in brcms_b_attach()
4438 wlc_hw->deviceid = core->bus->boardinfo.type; in brcms_b_attach()
4441 wlc_hw->d11core = core; in brcms_b_attach()
4442 wlc_hw->corerev = core->id.rev; in brcms_b_attach()
4451 ai_clkctl_init(wlc_hw->sih); in brcms_b_attach()
4455 * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk in brcms_b_attach()
4470 j = sprom->board_rev; in brcms_b_attach()
4474 wlc_hw->boardrev = (u16) j; in brcms_b_attach()
4478 unit, ai_get_boardtype(wlc_hw->sih), in brcms_b_attach()
4479 wlc_hw->boardrev); in brcms_b_attach()
4483 wlc_hw->sromrev = sprom->revision; in brcms_b_attach()
4484 wlc_hw->boardflags = sprom->boardflags_lo + (sprom->boardflags_hi << 16); in brcms_b_attach()
4485 wlc_hw->boardflags2 = sprom->boardflags2_lo + (sprom->boardflags2_hi << 16); in brcms_b_attach()
4487 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_b_attach()
4491 if (wlc_hw->deviceid == BCM43224_D11N_ID || in brcms_b_attach()
4492 wlc_hw->deviceid == BCM43224_D11N_ID_VEN1 || in brcms_b_attach()
4493 wlc_hw->deviceid == BCM43224_CHIP_ID) in brcms_b_attach()
4495 wlc_hw->_nbands = 2; in brcms_b_attach()
4497 wlc_hw->_nbands = 1; in brcms_b_attach()
4499 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) in brcms_b_attach()
4500 wlc_hw->_nbands = 1; in brcms_b_attach()
4505 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4506 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4507 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4508 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4509 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4510 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4511 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4512 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4513 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4515 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4517 if (wlc_hw->physhim == NULL) { in brcms_b_attach()
4524 /* pass all the parameters to wlc_phy_shared_attach in one struct */ in brcms_b_attach()
4525 sha_params.sih = wlc_hw->sih; in brcms_b_attach()
4526 sha_params.physhim = wlc_hw->physhim; in brcms_b_attach()
4528 sha_params.corerev = wlc_hw->corerev; in brcms_b_attach()
4529 sha_params.vid = wlc_hw->vendorid; in brcms_b_attach()
4530 sha_params.did = wlc_hw->deviceid; in brcms_b_attach()
4531 sha_params.chip = ai_get_chip_id(wlc_hw->sih); in brcms_b_attach()
4532 sha_params.chiprev = ai_get_chiprev(wlc_hw->sih); in brcms_b_attach()
4533 sha_params.chippkg = ai_get_chippkg(wlc_hw->sih); in brcms_b_attach()
4534 sha_params.sromrev = wlc_hw->sromrev; in brcms_b_attach()
4535 sha_params.boardtype = ai_get_boardtype(wlc_hw->sih); in brcms_b_attach()
4536 sha_params.boardrev = wlc_hw->boardrev; in brcms_b_attach()
4537 sha_params.boardflags = wlc_hw->boardflags; in brcms_b_attach()
4538 sha_params.boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4541 wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); in brcms_b_attach()
4542 if (!wlc_hw->phy_sh) { in brcms_b_attach()
4547 /* initialize software state for each core and band */ in brcms_b_attach()
4548 for (j = 0; j < wlc_hw->_nbands; j++) { in brcms_b_attach()
4556 wlc_hw->band->bandunit = j; in brcms_b_attach()
4557 wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4558 wlc->band->bandunit = j; in brcms_b_attach()
4559 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4560 wlc->core->coreidx = core->core_index; in brcms_b_attach()
4562 wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); in brcms_b_attach()
4563 wlc_hw->machwcap_backup = wlc_hw->machwcap; in brcms_b_attach()
4566 WARN_ON(wlc_hw->corerev < XMTFIFOTBL_STARTREV || in brcms_b_attach()
4567 (wlc_hw->corerev - XMTFIFOTBL_STARTREV) > in brcms_b_attach()
4569 wlc_hw->xmtfifo_sz = in brcms_b_attach()
4570 xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; in brcms_b_attach()
4571 WARN_ON(!wlc_hw->xmtfifo_sz[0]); in brcms_b_attach()
4573 /* Get a phy for this band */ in brcms_b_attach()
4574 wlc_hw->band->pi = in brcms_b_attach()
4575 wlc_phy_attach(wlc_hw->phy_sh, core, in brcms_b_attach()
4576 wlc_hw->band->bandtype, in brcms_b_attach()
4577 wlc->wiphy); in brcms_b_attach()
4578 if (wlc_hw->band->pi == NULL) { in brcms_b_attach()
4585 wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); in brcms_b_attach()
4587 wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, in brcms_b_attach()
4588 &wlc_hw->band->phyrev, in brcms_b_attach()
4589 &wlc_hw->band->radioid, in brcms_b_attach()
4590 &wlc_hw->band->radiorev); in brcms_b_attach()
4591 wlc_hw->band->abgphy_encore = in brcms_b_attach()
4592 wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4593 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4594 wlc_hw->band->core_flags = in brcms_b_attach()
4595 wlc_phy_get_coreflags(wlc_hw->band->pi); in brcms_b_attach()
4598 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_b_attach()
4599 if (NCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4603 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_attach()
4604 if (LCNCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4612 wlc_hw->band->phytype, wlc_hw->band->phyrev); in brcms_b_attach()
4619 * BMAC_NOTE: wlc->band->pi should not be set below and should in brcms_b_attach()
4620 * be done in the high level attach. However we can not make in brcms_b_attach()
4622 * wlc_hw->band->pi. Instead do the wlc->band->pi init below, in brcms_b_attach()
4623 * keeping wlc_hw->band->pi as well for incremental update of in brcms_b_attach()
4627 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4628 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4629 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4630 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4631 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4633 wlc->band->phytype, wlc->band->phyrev, in brcms_b_attach()
4634 wlc->band->radioid, wlc->band->radiorev); in brcms_b_attach()
4636 wlc_hw->band->CWmin = APHY_CWMIN; in brcms_b_attach()
4637 wlc_hw->band->CWmax = PHY_CWMAX; in brcms_b_attach()
4649 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_attach()
4655 * The hardware is in the DOWN state at this point. D11 core in brcms_b_attach()
4656 * or cores are in reset with clocks off, and the board PLLs in brcms_b_attach()
4659 * Beyond this point, wlc->sbclk == false and chip registers in brcms_b_attach()
4665 brcms_c_get_macaddr(wlc_hw, wlc_hw->etheraddr); in brcms_b_attach()
4667 if (is_broadcast_ether_addr(wlc_hw->etheraddr) || in brcms_b_attach()
4668 is_zero_ether_addr(wlc_hw->etheraddr)) { in brcms_b_attach()
4675 brcms_dbg_info(wlc_hw->d11core, "deviceid 0x%x nbands %d board 0x%x\n", in brcms_b_attach()
4676 wlc_hw->deviceid, wlc_hw->_nbands, in brcms_b_attach()
4677 ai_get_boardtype(wlc_hw->sih)); in brcms_b_attach()
4692 struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom; in brcms_c_attach_stf_ant_init()
4694 unit = wlc->pub->unit; in brcms_c_attach_stf_ant_init()
4695 bandtype = wlc->band->bandtype; in brcms_c_attach_stf_ant_init()
4699 aa = sprom->ant_available_a; in brcms_c_attach_stf_ant_init()
4701 aa = sprom->ant_available_bg; in brcms_c_attach_stf_ant_init()
4704 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" in brcms_c_attach_stf_ant_init()
4711 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; in brcms_c_attach_stf_ant_init()
4712 wlc->stf->txant = ANT_TX_FORCE_0; in brcms_c_attach_stf_ant_init()
4714 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; in brcms_c_attach_stf_ant_init()
4715 wlc->stf->txant = ANT_TX_FORCE_1; in brcms_c_attach_stf_ant_init()
4721 wlc->band->antgain = sprom->antenna_gain.a1; in brcms_c_attach_stf_ant_init()
4723 wlc->band->antgain = sprom->antenna_gain.a0; in brcms_c_attach_stf_ant_init()
4731 struct brcms_band *band; in brcms_c_bss_default_init() local
4732 struct brcms_bss_info *bi = wlc->default_bss; in brcms_c_bss_default_init()
4736 bi->beacon_period = BEACON_INTERVAL_DEFAULT; in brcms_c_bss_default_init()
4742 wlc->home_chanspec = bi->chanspec = chanspec; in brcms_c_bss_default_init()
4744 /* find the band of our default channel */ in brcms_c_bss_default_init()
4745 band = wlc->band; in brcms_c_bss_default_init()
4746 if (wlc->pub->_nbands > 1 && in brcms_c_bss_default_init()
4747 band->bandunit != chspec_bandunit(chanspec)) in brcms_c_bss_default_init()
4748 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_bss_default_init()
4750 /* init bss rates to the band specific default rate set */ in brcms_c_bss_default_init()
4751 brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, in brcms_c_bss_default_init()
4752 band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_c_bss_default_init()
4753 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_c_bss_default_init()
4754 brcms_chspec_bw(chanspec), wlc->stf->txstreams); in brcms_c_bss_default_init()
4756 if (wlc->pub->_n_enab & SUPPORT_11N) in brcms_c_bss_default_init()
4757 bi->flags |= BRCMS_BSS_HT; in brcms_c_bss_default_init()
4763 struct brcms_band *band; in brcms_c_update_mimo_band_bwcap() local
4765 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_update_mimo_band_bwcap()
4766 band = wlc->bandstate[i]; in brcms_c_update_mimo_band_bwcap()
4767 if (band->bandtype == BRCM_BAND_5G) { in brcms_c_update_mimo_band_bwcap()
4770 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4772 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4775 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4777 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4785 if (wlc->wdtimer) { in brcms_c_timers_deinit()
4786 brcms_free_timer(wlc->wdtimer); in brcms_c_timers_deinit()
4787 wlc->wdtimer = NULL; in brcms_c_timers_deinit()
4789 if (wlc->radio_timer) { in brcms_c_timers_deinit()
4790 brcms_free_timer(wlc->radio_timer); in brcms_c_timers_deinit()
4791 wlc->radio_timer = NULL; in brcms_c_timers_deinit()
4797 if (wlc->asi) { in brcms_c_detach_module()
4798 brcms_c_antsel_detach(wlc->asi); in brcms_c_detach_module()
4799 wlc->asi = NULL; in brcms_c_detach_module()
4802 if (wlc->ampdu) { in brcms_c_detach_module()
4803 brcms_c_ampdu_detach(wlc->ampdu); in brcms_c_detach_module()
4804 wlc->ampdu = NULL; in brcms_c_detach_module()
4816 struct brcms_hw_band *band; in brcms_b_detach() local
4817 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach()
4821 band = wlc_hw->band; in brcms_b_detach()
4822 for (i = 0; i < wlc_hw->_nbands; i++) { in brcms_b_detach()
4823 if (band->pi) { in brcms_b_detach()
4824 /* Detach this band's phy */ in brcms_b_detach()
4825 wlc_phy_detach(band->pi); in brcms_b_detach()
4826 band->pi = NULL; in brcms_b_detach()
4828 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4832 kfree(wlc_hw->phy_sh); in brcms_b_detach()
4834 wlc_phy_shim_detach(wlc_hw->physhim); in brcms_b_detach()
4836 if (wlc_hw->sih) { in brcms_b_detach()
4837 ai_detach(wlc_hw->sih); in brcms_b_detach()
4838 wlc_hw->sih = NULL; in brcms_b_detach()
4846 * It can NOT touch hardware registers since the d11core may be in reset and
4866 brcms_c_channel_mgr_detach(wlc->cmi); in brcms_c_detach()
4879 /* STA-BSS; short capable */ in brcms_c_ap_upd()
4880 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; in brcms_c_ap_upd()
4886 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4889 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_hw_up()
4896 ai_clkctl_init(wlc_hw->sih); in brcms_b_hw_up()
4910 wlc_phy_por_inform(wlc_hw->band->pi); in brcms_b_hw_up()
4912 wlc_hw->ucode_loaded = false; in brcms_b_hw_up()
4913 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4915 if ((wlc_hw->boardflags & BFL_FEM) in brcms_b_hw_up()
4916 && (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_hw_up()
4918 (wlc_hw->boardrev >= 0x1250 in brcms_b_hw_up()
4919 && (wlc_hw->boardflags & BFL_FEM_BT))) in brcms_b_hw_up()
4920 ai_epa_4313war(wlc_hw->sih); in brcms_b_hw_up()
4926 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_up_prep()
4933 ai_clkctl_init(wlc_hw->sih); in brcms_b_up_prep()
4937 * Configure pci/pcmcia here instead of in brcms_c_attach() in brcms_b_up_prep()
4940 bcma_host_pci_irq_ctl(wlc_hw->d11core->bus, wlc_hw->d11core, in brcms_b_up_prep()
4946 * bring the driver up in this case. in brcms_b_up_prep()
4949 /* put SB PCI in down state again */ in brcms_b_up_prep()
4950 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_up_prep()
4952 return -ENOMEDIUM; in brcms_b_up_prep()
4955 bcma_host_pci_up(wlc_hw->d11core->bus); in brcms_b_up_prep()
4965 wlc_hw->up = true; in brcms_b_up_finish()
4966 wlc_phy_hw_state_upd(wlc_hw->band->pi, true); in brcms_b_up_finish()
4970 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
4983 if (!wlc->clk) in brcms_c_wme_retries_write()
4987 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), in brcms_c_wme_retries_write()
4988 wlc->wme_retries[ac]); in brcms_c_wme_retries_write()
4996 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_up()
4999 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) in brcms_c_up()
5000 return -ENOMEDIUM; in brcms_c_up()
5002 if (!wlc->pub->hw_up) { in brcms_c_up()
5003 brcms_b_hw_up(wlc->hw); in brcms_c_up()
5004 wlc->pub->hw_up = true; in brcms_c_up()
5007 if ((wlc->pub->boardflags & BFL_FEM) in brcms_c_up()
5008 && (ai_get_chip_id(wlc->hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_c_up()
5009 if (wlc->pub->boardrev >= 0x1250 in brcms_c_up()
5010 && (wlc->pub->boardflags & BFL_FEM_BT)) in brcms_c_up()
5011 brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, in brcms_c_up()
5014 brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, in brcms_c_up()
5021 * the driver up in this case. If radio is disabled, abort up, lower in brcms_c_up()
5025 * brcms_b_up_prep() returns either 0 or -BCME_RADIOOFF only in brcms_c_up()
5027 if (!wlc->pub->radio_disabled) { in brcms_c_up()
5028 int status = brcms_b_up_prep(wlc->hw); in brcms_c_up()
5029 if (status == -ENOMEDIUM) { in brcms_c_up()
5031 (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { in brcms_c_up()
5032 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_up()
5033 mboolset(wlc->pub->radio_disabled, in brcms_c_up()
5035 if (bsscfg->type == BRCMS_TYPE_STATION || in brcms_c_up()
5036 bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_up()
5037 brcms_err(wlc->hw->d11core, in brcms_c_up()
5038 "wl%d: up: rfdisable -> " in brcms_c_up()
5040 wlc->pub->unit); in brcms_c_up()
5045 if (wlc->pub->radio_disabled) { in brcms_c_up()
5051 wlc->clk = true; in brcms_c_up()
5056 brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); in brcms_c_up()
5058 brcms_init(wlc->wl); in brcms_c_up()
5059 wlc->pub->up = true; in brcms_c_up()
5061 if (wlc->bandinit_pending) { in brcms_c_up()
5062 ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_up()
5064 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->hw_value)); in brcms_c_up()
5065 wlc->bandinit_pending = false; in brcms_c_up()
5069 brcms_b_up_finish(wlc->hw); in brcms_c_up()
5075 brcms_add_timer(wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); in brcms_c_up()
5076 wlc->WDarmed = true; in brcms_c_up()
5080 /* ensure LDPC config is in sync */ in brcms_c_up()
5081 brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); in brcms_c_up()
5091 if (!wlc_hw->up) in brcms_b_bmac_down_prep()
5094 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5098 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5101 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5107 callbacks += wlc_phy_down(wlc_hw->band->pi); in brcms_b_bmac_down_prep()
5117 if (!wlc_hw->up) in brcms_b_down_finish()
5120 wlc_hw->up = false; in brcms_b_down_finish()
5121 wlc_phy_hw_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5123 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5126 wlc_hw->sbclk = false; in brcms_b_down_finish()
5127 wlc_hw->clk = false; in brcms_b_down_finish()
5128 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5131 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5135 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_down_finish()
5136 if (bcma_read32(wlc_hw->d11core, in brcms_b_down_finish()
5138 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5139 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5144 if (!wlc_hw->noreset) { in brcms_b_down_finish()
5145 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_down_finish()
5164 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_down()
5166 /* check if we are already in the going down path */ in brcms_c_down()
5167 if (wlc->going_down) { in brcms_c_down()
5168 brcms_err(wlc->hw->d11core, in brcms_c_down()
5170 wlc->pub->unit, __func__); in brcms_c_down()
5173 if (!wlc->pub->up) in brcms_c_down()
5176 wlc->going_down = true; in brcms_c_down()
5178 callbacks += brcms_b_bmac_down_prep(wlc->hw); in brcms_c_down()
5184 if (wlc->modulecb[i].down_fn) in brcms_c_down()
5186 wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); in brcms_c_down()
5190 if (wlc->WDarmed) { in brcms_c_down()
5191 if (!brcms_del_timer(wlc->wdtimer)) in brcms_c_down()
5193 wlc->WDarmed = false; in brcms_c_down()
5196 wlc->pub->up = false; in brcms_c_down()
5198 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); in brcms_c_down()
5200 callbacks += brcms_b_down_finish(wlc->hw); in brcms_c_down()
5203 wlc->clk = false; in brcms_c_down()
5205 wlc->going_down = false; in brcms_c_down()
5216 /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */ in brcms_c_set_gmode()
5219 struct brcms_band *band; in brcms_c_set_gmode() local
5221 /* if N-support is enabled, allow Gmode set as long as requested in brcms_c_set_gmode()
5224 if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) in brcms_c_set_gmode()
5225 return -ENOTSUPP; in brcms_c_set_gmode()
5227 /* verify that we are dealing with 2G band and grab the band pointer */ in brcms_c_set_gmode()
5228 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_set_gmode()
5229 band = wlc->band; in brcms_c_set_gmode()
5230 else if ((wlc->pub->_nbands > 1) && in brcms_c_set_gmode()
5231 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) in brcms_c_set_gmode()
5232 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_set_gmode()
5234 return -EINVAL; in brcms_c_set_gmode()
5268 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n", in brcms_c_set_gmode()
5269 wlc->pub->unit, __func__, gmode); in brcms_c_set_gmode()
5270 return -ENOTSUPP; in brcms_c_set_gmode()
5273 band->gmode = gmode; in brcms_c_set_gmode()
5275 wlc->shortslot_override = shortslot; in brcms_c_set_gmode()
5291 wlc->default_bss->rateset.count = rs.count; in brcms_c_set_gmode()
5292 memcpy(wlc->default_bss->rateset.rates, rs.rates, in brcms_c_set_gmode()
5293 sizeof(wlc->default_bss->rateset.rates)); in brcms_c_set_gmode()
5303 if (wlc->stf->txstreams == WL_11N_3x3) in brcms_c_set_nmode()
5311 wlc->pub->_n_enab = SUPPORT_HT; in brcms_c_set_nmode()
5313 wlc->pub->_n_enab = SUPPORT_11N; in brcms_c_set_nmode()
5314 wlc->default_bss->flags |= BRCMS_BSS_HT; in brcms_c_set_nmode()
5316 brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, in brcms_c_set_nmode()
5317 wlc->stf->txstreams); in brcms_c_set_nmode()
5318 for (i = 0; i < wlc->pub->_nbands; i++) in brcms_c_set_nmode()
5319 memcpy(wlc->bandstate[i]->hw_rateset.mcs, in brcms_c_set_nmode()
5320 wlc->default_bss->rateset.mcs, MCSSET_LEN); in brcms_c_set_nmode()
5336 return -EINVAL; in brcms_c_set_internal_rateset()
5338 /* try the current band */ in brcms_c_set_internal_rateset()
5339 bandunit = wlc->band->bandunit; in brcms_c_set_internal_rateset()
5342 (&new, &wlc->bandstate[bandunit]->hw_rateset, true, in brcms_c_set_internal_rateset()
5343 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5346 /* try the other band */ in brcms_c_set_internal_rateset()
5351 &wlc-> in brcms_c_set_internal_rateset()
5352 bandstate[bandunit]-> in brcms_c_set_internal_rateset()
5354 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5358 return -EBADE; in brcms_c_set_internal_rateset()
5362 memcpy(&wlc->default_bss->rateset, &new, in brcms_c_set_internal_rateset()
5364 memcpy(&wlc->bandstate[bandunit]->defrateset, &new, in brcms_c_set_internal_rateset()
5371 wlc_phy_ofdm_rateset_war(wlc->band->pi, false); in brcms_c_ofdm_rateset_war()
5379 return -EINVAL; in brcms_c_set_channel()
5381 if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) in brcms_c_set_channel()
5382 return -EINVAL; in brcms_c_set_channel()
5385 if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { in brcms_c_set_channel()
5386 if (wlc->band->bandunit != chspec_bandunit(chspec)) in brcms_c_set_channel()
5387 wlc->bandinit_pending = true; in brcms_c_set_channel()
5389 wlc->bandinit_pending = false; in brcms_c_set_channel()
5392 wlc->default_bss->chanspec = chspec; in brcms_c_set_channel()
5395 if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { in brcms_c_set_channel()
5410 return -EINVAL; in brcms_c_set_rate_limit()
5412 wlc->SRL = srl; in brcms_c_set_rate_limit()
5413 wlc->LRL = lrl; in brcms_c_set_rate_limit()
5415 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); in brcms_c_set_rate_limit()
5418 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5419 EDCF_SHORT, wlc->SRL); in brcms_c_set_rate_limit()
5420 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5421 EDCF_LONG, wlc->LRL); in brcms_c_set_rate_limit()
5433 if (wlc->pub->associated) in brcms_c_get_current_rateset()
5434 rs = &wlc->bsscfg->current_bss->rateset; in brcms_c_get_current_rateset()
5436 rs = &wlc->default_bss->rateset; in brcms_c_get_current_rateset()
5439 currs->count = rs->count; in brcms_c_get_current_rateset()
5440 memcpy(&currs->rates, &rs->rates, rs->count); in brcms_c_get_current_rateset()
5448 if (rs->count > BRCMS_NUMRATES) in brcms_c_set_rateset()
5449 return -ENOBUFS; in brcms_c_set_rateset()
5454 internal_rs.count = rs->count; in brcms_c_set_rateset()
5455 memcpy(&internal_rs.rates, &rs->rates, internal_rs.count); in brcms_c_set_rateset()
5457 /* merge rateset coming in with the current mcsset */ in brcms_c_set_rateset()
5458 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_set_rateset()
5460 if (wlc->pub->associated) in brcms_c_set_rateset()
5461 mcsset_bss = wlc->bsscfg->current_bss; in brcms_c_set_rateset()
5463 mcsset_bss = wlc->default_bss; in brcms_c_set_rateset()
5464 memcpy(internal_rs.mcs, &mcsset_bss->rateset.mcs[0], in brcms_c_set_rateset()
5477 bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD); in brcms_c_time_lock()
5479 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_lock()
5484 bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD); in brcms_c_time_unlock()
5486 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_unlock()
5494 return -EINVAL; in brcms_c_set_beacon_period()
5496 wlc->default_bss->beacon_period = period; in brcms_c_set_beacon_period()
5500 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep), in brcms_c_set_beacon_period()
5502 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us); in brcms_c_set_beacon_period()
5510 return wlc->band->phytype; in brcms_c_get_phy_type()
5515 wlc->shortslot_override = sslot_override; in brcms_c_set_shortslot_override()
5519 * currently on the 5G band in brcms_c_set_shortslot_override()
5521 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_set_shortslot_override()
5524 if (wlc->pub->up && wlc->pub->associated) { in brcms_c_set_shortslot_override()
5526 } else if (wlc->pub->up) { in brcms_c_set_shortslot_override()
5532 if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) in brcms_c_set_shortslot_override()
5533 wlc->shortslot = false; in brcms_c_set_shortslot_override()
5535 wlc->shortslot = in brcms_c_set_shortslot_override()
5536 (wlc->shortslot_override == in brcms_c_set_shortslot_override()
5548 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_register()
5553 if (wlc->modulecb[i].name[0] == '\0') { in brcms_c_module_register()
5554 strncpy(wlc->modulecb[i].name, name, in brcms_c_module_register()
5555 sizeof(wlc->modulecb[i].name) - 1); in brcms_c_module_register()
5556 wlc->modulecb[i].hdl = hdl; in brcms_c_module_register()
5557 wlc->modulecb[i].down_fn = d_fn; in brcms_c_module_register()
5562 return -ENOSR; in brcms_c_module_register()
5569 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_unregister()
5573 return -ENODATA; in brcms_c_module_unregister()
5576 if (!strcmp(wlc->modulecb[i].name, name) && in brcms_c_module_unregister()
5577 (wlc->modulecb[i].hdl == hdl)) { in brcms_c_module_unregister()
5578 memset(&wlc->modulecb[i], 0, sizeof(wlc->modulecb[i])); in brcms_c_module_unregister()
5584 return -ENODATA; in brcms_c_module_unregister()
5589 struct pci_dev *pcidev = core->bus->host_pci; in brcms_c_chipmatch_pci()
5590 u16 vendor = pcidev->vendor; in brcms_c_chipmatch_pci()
5591 u16 device = pcidev->device; in brcms_c_chipmatch_pci()
5613 struct bcma_chipinfo *chipinfo = &core->bus->chipinfo; in brcms_c_chipmatch_soc()
5615 if (chipinfo->id == BCMA_CHIP_ID_BCM4716) in brcms_c_chipmatch_soc()
5618 pr_err("unknown chip id %04x\n", chipinfo->id); in brcms_c_chipmatch_soc()
5624 switch (core->bus->hosttype) { in brcms_c_chipmatch()
5630 pr_err("unknown host type: %i\n", core->bus->hosttype); in brcms_c_chipmatch()
5646 /* for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_b_rate_shm_offset()
5652 /* Find the SHM pointer to the rate table entry by looking in the in brcms_b_rate_shm_offset()
5653 * Direct-map Table in brcms_b_rate_shm_offset()
5669 frameid = le16_to_cpu(txh->TxFrameID) & ~(TXFID_SEQ_MASK | in bcmc_fid_generate()
5672 (((wlc-> in bcmc_fid_generate()
5686 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that in brcms_c_calc_ack_time()
5688 * frame in the FES in brcms_c_calc_ack_time()
5710 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that in brcms_c_calc_ba_time()
5712 * frame in the FES in brcms_c_calc_ba_time()
5727 * rate MPDU rate in unit of 500kbps
5728 * next_frag_len next MPDU length in bytes
5737 sifs = get_sifs(wlc->band); in brcms_c_compute_frame_dur()
5765 dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); in brcms_c_calc_frame_len()
5767 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_len()
5768 dur -= DOT11_OFDM_SIGNAL_EXTENSION; in brcms_c_calc_frame_len()
5774 ((nsyms * kNdps) - in brcms_c_calc_frame_len()
5777 dur -= APHY_PREAMBLE_TIME; in brcms_c_calc_frame_len()
5778 dur -= APHY_SIGNAL_TIME; in brcms_c_calc_frame_len()
5783 ((nsyms * Ndps) - in brcms_c_calc_frame_len()
5787 dur -= BPHY_PLCP_SHORT_TIME; in brcms_c_calc_frame_len()
5789 dur -= BPHY_PLCP_TIME; in brcms_c_calc_frame_len()
5791 /* divide out factor of 2 in rate (1/2 mbps) */ in brcms_c_calc_frame_len()
5798 * Return true if the specified rate is supported by the specified band.
5799 * BRCM_BAND_AUTO indicates the current band.
5801 static bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, in brcms_c_valid_rate() argument
5807 if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) in brcms_c_valid_rate()
5808 hw_rateset = &wlc->band->hw_rateset; in brcms_c_valid_rate()
5809 else if (wlc->pub->_nbands > 1) in brcms_c_valid_rate()
5810 hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; in brcms_c_valid_rate()
5812 /* other band specified and we are a single band device */ in brcms_c_valid_rate()
5820 return isset(hw_rateset->mcs, (rspec & RSPEC_RATE_MASK)); in brcms_c_valid_rate()
5823 for (i = 0; i < hw_rateset->count; i++) in brcms_c_valid_rate()
5824 if (hw_rateset->rates[i] == rspec2rate(rspec)) in brcms_c_valid_rate()
5828 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x " in brcms_c_valid_rate()
5829 "not in hw_rateset\n", wlc->pub->unit, rspec); in brcms_c_valid_rate()
5838 struct bcma_device *core = wlc->hw->d11core; in mac80211_wlc_set_nrate()
5851 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { in mac80211_wlc_set_nrate()
5855 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5861 if (!CHSPEC_IS40(wlc->home_chanspec) || in mac80211_wlc_set_nrate()
5865 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5874 wlc->pub->unit, rate); in mac80211_wlc_set_nrate()
5879 * MCS 0-7 may use SISO, CDD, and for in mac80211_wlc_set_nrate()
5886 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5893 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5897 if ((cur_band->bandtype != BRCM_BAND_2G) in mac80211_wlc_set_nrate()
5900 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5905 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5908 /* make sure multiple antennae are available for non-siso rates */ in mac80211_wlc_set_nrate()
5909 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { in mac80211_wlc_set_nrate()
5911 "request\n", wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5935 && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) in mac80211_wlc_set_nrate()
5945 * Rate is given in the driver standard multiple of 500 kbps.
5965 if ((length << 4) - (usec * 11) > 0) in brcms_c_cck_plcp_set()
5970 if ((length << 3) - (usec * 11) > 0) { in brcms_c_cck_plcp_set()
5972 if ((usec * 11) - (length << 3) >= 8) in brcms_c_cck_plcp_set()
5978 brcms_err(wlc->hw->d11core, in brcms_c_cck_plcp_set()
5997 /* Rate: 802.11 rate code, length: PSDU length in octets */
6011 /* Rate: 802.11 rate code, length: PSDU length in octets */
6020 * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb in brcms_c_compute_ofdm_plcp()
6033 /* Rate: 802.11 rate code, length: PSDU length in octets */
6058 * DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK
6060 * cts cts-to-self or rts/cts
6061 * rts_rate rts or cts rate in unit of 500kbps
6062 * rate next MPDU rate in unit of 500kbps
6063 * frame_len next MPDU frame length in bytes
6073 sifs = get_sifs(wlc->band); in brcms_c_compute_rtscts_dur()
6082 /* CTS-TO-SELF */ in brcms_c_compute_rtscts_dur()
6105 if (BRCMS_ISLCNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6111 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is " in brcms_c_phytxctl1_calc()
6120 /* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ in brcms_c_phytxctl1_calc()
6124 } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) in brcms_c_phytxctl1_calc()
6125 && !BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6127 * In CCK mode LPPHY overloads OFDM Modulation bits with CCK in brcms_c_phytxctl1_calc()
6137 if (phycfg == -1) { in brcms_c_phytxctl1_calc()
6138 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong " in brcms_c_phytxctl1_calc()
6196 h = (struct ieee80211_hdr *)(p->data); in brcms_c_d11hdrs_mac80211()
6197 qos = ieee80211_is_data_qos(h->frame_control); in brcms_c_d11hdrs_mac80211()
6199 /* compute length of frame in bytes for use in PLCP computations */ in brcms_c_d11hdrs_mac80211()
6200 len = p->len; in brcms_c_d11hdrs_mac80211()
6214 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { in brcms_c_d11hdrs_mac80211()
6215 /* non-AP STA should never use BCMC queue */ in brcms_c_d11hdrs_mac80211()
6217 brcms_err(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6219 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6223 if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) in brcms_c_d11hdrs_mac80211()
6224 scb->seqnum[p->priority]++; in brcms_c_d11hdrs_mac80211()
6227 seq = le16_to_cpu(h->seq_ctrl) & FRAGNUM_MASK; in brcms_c_d11hdrs_mac80211()
6228 seq |= (scb->seqnum[p->priority] << SEQNUM_SHIFT); in brcms_c_d11hdrs_mac80211()
6229 h->seq_ctrl = cpu_to_le16(seq); in brcms_c_d11hdrs_mac80211()
6237 /* set the ignpmq bit for all pkts tx'd in PS mode and for beacons */ in brcms_c_d11hdrs_mac80211()
6238 if (ieee80211_is_beacon(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6241 txrate[0] = tx_info->control.rates; in brcms_c_d11hdrs_mac80211()
6248 if (txrate[1]->idx < 0) in brcms_c_d11hdrs_mac80211()
6251 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6252 is_mcs = txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false; in brcms_c_d11hdrs_mac80211()
6254 if ((txrate[k]->idx >= 0) in brcms_c_d11hdrs_mac80211()
6255 && (txrate[k]->idx < in brcms_c_d11hdrs_mac80211()
6256 hw->wiphy->bands[tx_info->band]->n_bitrates)) { in brcms_c_d11hdrs_mac80211()
6258 hw->wiphy->bands[tx_info->band]-> in brcms_c_d11hdrs_mac80211()
6259 bitrates[txrate[k]->idx].hw_value; in brcms_c_d11hdrs_mac80211()
6264 rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, in brcms_c_d11hdrs_mac80211()
6265 NRATE_MCS_INUSE | txrate[k]->idx); in brcms_c_d11hdrs_mac80211()
6274 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6277 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6289 if (!is_multicast_ether_addr(h->addr1)) { in brcms_c_d11hdrs_mac80211()
6291 brcms_c_antsel_antcfg_get(wlc->asi, false, in brcms_c_d11hdrs_mac80211()
6297 phyctl1_stf = wlc->stf->ss_opmode; in brcms_c_d11hdrs_mac80211()
6299 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_d11hdrs_mac80211()
6300 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6331 if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { in brcms_c_d11hdrs_mac80211()
6335 wlc->band->pi)) in brcms_c_d11hdrs_mac80211()
6345 } else if (wlc->mimo_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6346 mimo_txbw = wlc->mimo_40txbw; in brcms_c_d11hdrs_mac80211()
6348 else if (scb->flags & SCB_IS40) in brcms_c_d11hdrs_mac80211()
6351 if (wlc->ofdm_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6352 mimo_txbw = wlc->ofdm_40txbw; in brcms_c_d11hdrs_mac80211()
6353 } else if (wlc->cck_40txbw != AUTO) { in brcms_c_d11hdrs_mac80211()
6354 mimo_txbw = wlc->cck_40txbw; in brcms_c_d11hdrs_mac80211()
6380 if (txrate[k]->flags & IEEE80211_TX_RC_GREEN_FIELD) in brcms_c_d11hdrs_mac80211()
6383 if ((txrate[k]->flags & IEEE80211_TX_RC_MCS) in brcms_c_d11hdrs_mac80211()
6385 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6387 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6405 && (tx_info->control.rates[0]. in brcms_c_d11hdrs_mac80211()
6410 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6416 if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { in brcms_c_d11hdrs_mac80211()
6424 txrate[0]->count = 0; in brcms_c_d11hdrs_mac80211()
6425 txrate[1]->count = 0; in brcms_c_d11hdrs_mac80211()
6428 if ((ieee80211_is_data(h->frame_control) || in brcms_c_d11hdrs_mac80211()
6429 ieee80211_is_mgmt(h->frame_control)) && in brcms_c_d11hdrs_mac80211()
6430 (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6437 memcpy(&txh->FragPLCPFallback, in brcms_c_d11hdrs_mac80211()
6438 plcp_fallback, sizeof(txh->FragPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6440 /* Length field now put in CCK FBR CRC field */ in brcms_c_d11hdrs_mac80211()
6442 txh->FragPLCPFallback[4] = phylen & 0xff; in brcms_c_d11hdrs_mac80211()
6443 txh->FragPLCPFallback[5] = (phylen & 0xff00) >> 8; in brcms_c_d11hdrs_mac80211()
6446 /* MIMO-RATE: need validation ?? */ in brcms_c_d11hdrs_mac80211()
6452 if (!ieee80211_is_pspoll(h->frame_control) && in brcms_c_d11hdrs_mac80211()
6453 !is_multicast_ether_addr(h->addr1) && !use_rifs) { in brcms_c_d11hdrs_mac80211()
6457 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6465 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6469 if (ieee80211_is_pspoll(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6470 txh->FragDurFallback = h->duration_id; in brcms_c_d11hdrs_mac80211()
6471 else if (is_multicast_ether_addr(h->addr1) || use_rifs) in brcms_c_d11hdrs_mac80211()
6472 txh->FragDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6476 txh->FragDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6479 /* (4) MAC-HDR: MacTxControlLow */ in brcms_c_d11hdrs_mac80211()
6483 if (!is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6486 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_d11hdrs_mac80211()
6489 if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) in brcms_c_d11hdrs_mac80211()
6496 txh->MacTxControlLow = cpu_to_le16(mcl); in brcms_c_d11hdrs_mac80211()
6509 memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16)); in brcms_c_d11hdrs_mac80211()
6510 txh->TxFesTimeNormal = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6512 txh->TxFesTimeFallback = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6515 memcpy(&txh->TxFrameRA, &h->addr1, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6518 txh->TxFrameID = cpu_to_le16(frameid); in brcms_c_d11hdrs_mac80211()
6524 txh->TxStatus = cpu_to_le16(status); in brcms_c_d11hdrs_mac80211()
6528 * the END of previous structure so that it's compatible in driver. in brcms_c_d11hdrs_mac80211()
6530 txh->MaxNMpdus = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6531 txh->MaxABytes_MRT = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6532 txh->MaxABytes_FBR = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6533 txh->MinMBytes = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6550 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6557 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6564 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDCTS); in brcms_c_d11hdrs_mac80211()
6566 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDRTS); in brcms_c_d11hdrs_mac80211()
6567 txh->MacTxControlLow |= cpu_to_le16(TXC_LONGFRAME); in brcms_c_d11hdrs_mac80211()
6571 rts_plcp = txh->RTSPhyHeader; in brcms_c_d11hdrs_mac80211()
6582 memcpy(&txh->RTSPLCPFallback, rts_plcp_fallback, in brcms_c_d11hdrs_mac80211()
6583 sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6586 rts = (struct ieee80211_rts *)&txh->rts_frame; in brcms_c_d11hdrs_mac80211()
6591 rts->duration = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6597 txh->RTSDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6600 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6603 memcpy(&rts->ra, &h->addr2, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6605 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6608 memcpy(&rts->ra, &h->addr1, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6609 memcpy(&rts->ta, &h->addr2, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6621 memset(txh->RTSPhyHeader, 0, D11_PHY_HDR_LEN); in brcms_c_d11hdrs_mac80211()
6622 memset(&txh->rts_frame, 0, sizeof(struct ieee80211_rts)); in brcms_c_d11hdrs_mac80211()
6623 memset(txh->RTSPLCPFallback, 0, sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6624 txh->RTSDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6629 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && is_mcs_rate(rspec)) in brcms_c_d11hdrs_mac80211()
6630 txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = in brcms_c_d11hdrs_mac80211()
6631 brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); in brcms_c_d11hdrs_mac80211()
6639 txh->MacTxControlHigh = cpu_to_le16(mch); in brcms_c_d11hdrs_mac80211()
6645 txh->MainRates = cpu_to_le16(mainrates); in brcms_c_d11hdrs_mac80211()
6648 xfts = frametype(rspec[1], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6649 xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6650 xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6651 xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << in brcms_c_d11hdrs_mac80211()
6653 txh->XtraFrameTypes = cpu_to_le16(xfts); in brcms_c_d11hdrs_mac80211()
6656 phyctl = frametype(rspec[0], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6665 txh->PhyTxControlWord = cpu_to_le16(phyctl); in brcms_c_d11hdrs_mac80211()
6668 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_d11hdrs_mac80211()
6672 txh->PhyTxControlWord_1 = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6674 txh->PhyTxControlWord_1_Fbr = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6678 txh->PhyTxControlWord_1_Rts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6680 txh->PhyTxControlWord_1_FbrRts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6685 * is going to be set, fill in non-zero MModeLen and/or in brcms_c_d11hdrs_mac80211()
6692 txh->MModeLen = cpu_to_le16(mmodelen); in brcms_c_d11hdrs_mac80211()
6699 txh->MModeFbrLen = cpu_to_le16(mmodefbrlen); in brcms_c_d11hdrs_mac80211()
6704 if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { in brcms_c_d11hdrs_mac80211()
6708 if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU) && frag == 0) { in brcms_c_d11hdrs_mac80211()
6714 /* 1 RTS or CTS-to-self frame */ in brcms_c_d11hdrs_mac80211()
6722 dur += le16_to_cpu(rts->duration); in brcms_c_d11hdrs_mac80211()
6724 le16_to_cpu(txh->RTSDurFallback); in brcms_c_d11hdrs_mac80211()
6744 txh->TxFesTimeNormal = cpu_to_le16((u16) dur); in brcms_c_d11hdrs_mac80211()
6749 txh->TxFesTimeFallback = in brcms_c_d11hdrs_mac80211()
6756 if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { in brcms_c_d11hdrs_mac80211()
6762 (wlc->edcf_txop[ac] - in brcms_c_d11hdrs_mac80211()
6763 (dur - frag_dur))); in brcms_c_d11hdrs_mac80211()
6769 wlc->usr_fragthresh) in brcms_c_d11hdrs_mac80211()
6771 wlc->usr_fragthresh; in brcms_c_d11hdrs_mac80211()
6773 if (wlc->fragthresh[queue] != in brcms_c_d11hdrs_mac80211()
6775 wlc->fragthresh[queue] = in brcms_c_d11hdrs_mac80211()
6778 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6780 wlc->pub->unit, fifo_names[queue], in brcms_c_d11hdrs_mac80211()
6784 if (dur > wlc->edcf_txop[ac]) in brcms_c_d11hdrs_mac80211()
6785 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6787 wlc->pub->unit, __func__, in brcms_c_d11hdrs_mac80211()
6789 phylen, wlc->fragthresh[queue], in brcms_c_d11hdrs_mac80211()
6790 dur, wlc->edcf_txop[ac]); in brcms_c_d11hdrs_mac80211()
6800 int fifo, ret = -ENOSPC; in brcms_c_tx()
6805 dma = wlc->hw->di[fifo]; in brcms_c_tx()
6806 txh = (struct d11txh *)(skb->data); in brcms_c_tx()
6808 if (dma->txavail == 0) { in brcms_c_tx()
6815 * in the tx ring and the tx queue isn't stopped then in brcms_c_tx()
6818 brcms_warn(wlc->hw->d11core, in brcms_c_tx()
6819 "Received frame for tx with no space in DMA ring\n"); in brcms_c_tx()
6820 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw, in brcms_c_tx()
6822 return -ENOSPC; in brcms_c_tx()
6829 frameid = le16_to_cpu(txh->TxFrameID); in brcms_c_tx()
6831 /* Commit BCMC sequence number in the SHM frame ID location */ in brcms_c_tx()
6837 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); in brcms_c_tx()
6855 struct scb *scb = &wlc->pri_scb; in brcms_c_sendpkt_mac80211()
6870 struct dma_pub *dma = wlc->hw->di[fifo]; in brcms_c_txfifo()
6876 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); in brcms_c_txfifo()
6884 if (dma->txavail <= TX_HEADROOM && fifo < TX_BCMC_FIFO && in brcms_c_txfifo()
6885 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue)) in brcms_c_txfifo()
6886 ieee80211_stop_queue(wlc->pub->ieee_hw, queue); in brcms_c_txfifo()
6900 else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) in brcms_c_rspec_to_rts_rspec()
6903 * under the target in case 11 Mbps is not Basic. in brcms_c_rspec_to_rts_rspec()
6916 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rspec_to_rts_rspec()
6917 /* set rts txbw to correct side band */ in brcms_c_rspec_to_rts_rspec()
6932 rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); in brcms_c_rspec_to_rts_rspec()
6938 /* Update beacon listen interval in shared memory */
6942 if (wlc->bcn_li_dtim == 1) in brcms_c_bcn_li_upd()
6943 brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); in brcms_c_bcn_li_upd()
6945 brcms_b_write_shm(wlc->hw, M_BCN_LI, in brcms_c_bcn_li_upd()
6946 (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); in brcms_c_bcn_li_upd()
6953 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_tsf()
6961 * recover 64bit TSF value from the 16bit TSF value in the rx header
6962 * given the assumption that the TSF passed in header is within 65ms
6967 * |<---------- tsf_h ----------->||<--- tsf_l -->||<-RxTSFTime ->|
6970 * tsf_l is filled in by brcms_b_recv, which is done earlier in the
6980 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_recover_tsf64()
6983 rx_tsf_0_15 = rxh->RxTSFTime; in brcms_c_recover_tsf64()
6990 rx_tsf_16_31 -= 1; in brcms_c_recover_tsf64()
6992 tsf_h -= 1; in brcms_c_recover_tsf64()
7007 /* fill in TSF and flag its presence */ in prep_mac80211_status()
7008 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); in prep_mac80211_status()
7009 rx_status->flag |= RX_FLAG_MACTIME_START; in prep_mac80211_status()
7011 channel = BRCMS_CHAN_CHANNEL(rxh->RxChan); in prep_mac80211_status()
7013 rx_status->band = in prep_mac80211_status()
7015 rx_status->freq = in prep_mac80211_status()
7016 ieee80211_channel_to_frequency(channel, rx_status->band); in prep_mac80211_status()
7018 rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); in prep_mac80211_status()
7022 rx_status->antenna = in prep_mac80211_status()
7023 (rxh->PhyRxStatus_0 & PRXS0_RXANT_UPSUBBAND) ? 1 : 0; in prep_mac80211_status()
7025 plcp = p->data; in prep_mac80211_status()
7029 rx_status->rate_idx = rspec & RSPEC_RATE_MASK; in prep_mac80211_status()
7030 rx_status->encoding = RX_ENC_HT; in prep_mac80211_status()
7032 rx_status->bw = RATE_INFO_BW_40; in prep_mac80211_status()
7036 rx_status->rate_idx = 0; in prep_mac80211_status()
7039 rx_status->rate_idx = 1; in prep_mac80211_status()
7042 rx_status->rate_idx = 2; in prep_mac80211_status()
7045 rx_status->rate_idx = 3; in prep_mac80211_status()
7048 rx_status->rate_idx = 4; in prep_mac80211_status()
7051 rx_status->rate_idx = 5; in prep_mac80211_status()
7054 rx_status->rate_idx = 6; in prep_mac80211_status()
7057 rx_status->rate_idx = 7; in prep_mac80211_status()
7060 rx_status->rate_idx = 8; in prep_mac80211_status()
7063 rx_status->rate_idx = 9; in prep_mac80211_status()
7066 rx_status->rate_idx = 10; in prep_mac80211_status()
7069 rx_status->rate_idx = 11; in prep_mac80211_status()
7072 brcms_err(wlc->hw->d11core, in prep_mac80211_status()
7079 * of brcms_band_5GHz_nphy (in mac80211_if.c). in prep_mac80211_status()
7081 if (rx_status->band == NL80211_BAND_5GHZ) in prep_mac80211_status()
7082 rx_status->rate_idx -= BRCMS_LEGACY_5G_RATE_OFFSET; in prep_mac80211_status()
7086 if (rxh->PhyRxStatus_0 & PRXS0_SHORTH) in prep_mac80211_status()
7087 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7089 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7091 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n", in prep_mac80211_status()
7097 rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in prep_mac80211_status()
7099 if (rxh->RxStatus1 & RXS_DECERR) { in prep_mac80211_status()
7100 rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; in prep_mac80211_status()
7101 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n", in prep_mac80211_status()
7104 if (rxh->RxStatus1 & RXS_FCSERR) { in prep_mac80211_status()
7105 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; in prep_mac80211_status()
7106 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n", in prep_mac80211_status()
7123 len_mpdu = p->len - D11_PHY_HDR_LEN - FCS_LEN; in brcms_c_recvctl()
7128 if (wlc->hw->suspended_fifos) { in brcms_c_recvctl()
7129 hdr = (struct ieee80211_hdr *)p->data; in brcms_c_recvctl()
7130 if (ieee80211_is_beacon(hdr->frame_control)) in brcms_c_recvctl()
7131 brcms_b_mute(wlc->hw, false); in brcms_c_recvctl()
7135 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_recvctl()
7138 /* calculate frame duration for Mixed-mode L-SIG spoofing, return
7139 * number of bytes goes in the length field
7142 * len = 3(nsyms + nstream + 3) - 3
7174 /* (+3) account for HT-SIG(2) and HT-STF(1) */ in brcms_c_calc_lsig_len()
7178 * (-3) excluding service bits and tail bits in brcms_c_calc_lsig_len()
7180 len = (3 * nsyms) - 3; in brcms_c_calc_lsig_len()
7197 sifs = get_sifs(wlc->band); in brcms_c_mod_prb_rsp_rate_table()
7202 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_mod_prb_rsp_rate_table()
7211 entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); in brcms_c_mod_prb_rsp_rate_table()
7225 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, in brcms_c_mod_prb_rsp_rate_table()
7227 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, in brcms_c_mod_prb_rsp_rate_table()
7229 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); in brcms_c_mod_prb_rsp_rate_table()
7244 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write()
7245 struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw; in brcms_c_beacon_write()
7250 len = min_t(size_t, beacon->len, BCN_TMPL_LEN); in brcms_c_beacon_write()
7251 wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value; in brcms_c_beacon_write()
7253 brcms_c_compute_plcp(wlc, wlc->bcn_rspec, in brcms_c_beacon_write()
7254 len + FCS_LEN - D11_PHY_HDR_LEN, beacon->data); in brcms_c_beacon_write()
7258 brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); in brcms_c_beacon_write()
7263 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7271 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7292 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw()
7293 struct bcma_device *core = wlc_hw->d11core; in brcms_c_update_beacon_hw()
7298 /* Check if both templates are in use, if so sched. an interrupt in brcms_c_update_beacon_hw()
7305 if (wlc->beacon_template_virgin) { in brcms_c_update_beacon_hw()
7306 wlc->beacon_template_virgin = false; in brcms_c_update_beacon_hw()
7318 wlc->defmacintmask |= MI_BCNTPL; in brcms_c_update_beacon_hw()
7342 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_beacon()
7344 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_beacon()
7345 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_beacon()
7347 wlc->defmacintmask &= ~MI_BCNTPL; in brcms_c_update_beacon()
7348 if (!wlc->beacon) in brcms_c_update_beacon()
7350 brcms_c_update_beacon_hw(wlc, wlc->beacon, in brcms_c_update_beacon()
7351 wlc->beacon_tim_offset, in brcms_c_update_beacon()
7352 wlc->beacon_dtim_period); in brcms_c_update_beacon()
7361 if (wlc->beacon) in brcms_c_set_new_beacon()
7362 dev_kfree_skb_any(wlc->beacon); in brcms_c_set_new_beacon()
7363 wlc->beacon = beacon; in brcms_c_set_new_beacon()
7366 skb_push(wlc->beacon, D11_PHY_HDR_LEN); in brcms_c_set_new_beacon()
7367 wlc->beacon_tim_offset = tim_offset; in brcms_c_set_new_beacon()
7368 wlc->beacon_dtim_period = dtim_period; in brcms_c_set_new_beacon()
7377 if (wlc->probe_resp) in brcms_c_set_new_probe_resp()
7378 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_set_new_probe_resp()
7379 wlc->probe_resp = probe_resp; in brcms_c_set_new_probe_resp()
7382 skb_push(wlc->probe_resp, D11_PHY_HDR_LEN); in brcms_c_set_new_probe_resp()
7390 * to 1, it can not send it in that time frame. in brcms_c_enable_probe_resp()
7392 wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1; in brcms_c_enable_probe_resp()
7393 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_enable_probe_resp()
7401 u8 *ssidptr = cfg->SSID; in brcms_c_shm_ssid_upd()
7407 memcpy(ssidbuf, ssidptr, cfg->SSID_len); in brcms_c_shm_ssid_upd()
7410 brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); in brcms_c_shm_ssid_upd()
7421 len = min_t(size_t, probe_resp->len, BCN_TMPL_LEN); in brcms_c_bss_update_probe_resp()
7427 brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, in brcms_c_bss_update_probe_resp()
7428 (len + 3) & ~3, probe_resp->data); in brcms_c_bss_update_probe_resp()
7430 /* write the length of the probe response frame (+PLCP/-FCS) */ in brcms_c_bss_update_probe_resp()
7431 brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); in brcms_c_bss_update_probe_resp()
7443 (u16)len + FCS_LEN - D11_PHY_HDR_LEN); in brcms_c_bss_update_probe_resp()
7451 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_probe_resp()
7454 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_probe_resp()
7455 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_probe_resp()
7456 if (!wlc->probe_resp) in brcms_c_update_probe_resp()
7458 brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp, in brcms_c_update_probe_resp()
7467 return -EINVAL; in brcms_b_xmtfifo_sz_get()
7469 *blocks = wlc_hw->xmtfifo_sz[fifo]; in brcms_b_xmtfifo_sz_get()
7478 brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); in brcms_c_set_addrmatch()
7480 memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); in brcms_c_set_addrmatch()
7484 * Flag 'scan in progress' to withhold dynamic phy calibration
7488 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); in brcms_c_scan_start()
7493 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); in brcms_c_scan_stop()
7498 wlc->pub->associated = state; in brcms_c_associate_upd()
7503 * AMPDU traffic, packets pending in hardware have to be invalidated so that
7513 dmah = hw->di[i]; in brcms_c_inval_dma_pkts()
7521 return wlc->band->bandunit; in brcms_c_get_curband()
7529 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_c_tx_flush_completed()
7530 if (wlc->hw->di[i]) in brcms_c_tx_flush_completed()
7531 dma_kick_tx(wlc->hw->di[i]); in brcms_c_tx_flush_completed()
7538 wlc->bcn_li_bcn = interval; in brcms_c_set_beacon_listen_interval()
7539 if (wlc->pub->up) in brcms_c_set_beacon_listen_interval()
7548 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_tsf_get()
7567 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l); in brcms_c_tsf_set()
7568 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h); in brcms_c_tsf_set()
7579 return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); in brcms_c_set_tx_power()
7587 wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); in brcms_c_get_tx_power()
7606 rxh = (struct d11rxhdr *) (p->data); in brcms_c_recv()
7611 /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ in brcms_c_recv()
7612 if (rxh->RxStatus1 & RXS_PBPRES) { in brcms_c_recv()
7613 if (p->len < 2) { in brcms_c_recv()
7614 brcms_err(wlc->hw->d11core, in brcms_c_recv()
7616 wlc->pub->unit, p->len); in brcms_c_recv()
7622 h = (struct ieee80211_hdr *)(p->data + D11_PHY_HDR_LEN); in brcms_c_recv()
7623 len = p->len; in brcms_c_recv()
7625 if (rxh->RxStatus1 & RXS_FCSERR) { in brcms_c_recv()
7626 if (!(wlc->filter_flags & FIF_FCSFAIL)) in brcms_c_recv()
7631 if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) in brcms_c_recv()
7634 /* not supporting A-MSDU */ in brcms_c_recv()
7635 is_amsdu = rxh->RxStatus2 & RXS_AMSDU_MASK; in brcms_c_recv()
7659 uint bound_limit = bound ? RXBND : -1; in brcms_b_recv()
7670 morepending = dma_rx(wlc_hw->di[fifo], &recv_frames); in brcms_b_recv()
7675 dma_rxfill(wlc_hw->di[fifo]); in brcms_b_recv()
7683 rxh_le = (struct d11rxhdr_le *)p->data; in brcms_b_recv()
7684 rxh = (struct d11rxhdr *)p->data; in brcms_b_recv()
7687 rxh->RxFrameSize = le16_to_cpu(rxh_le->RxFrameSize); in brcms_b_recv()
7688 rxh->PhyRxStatus_0 = le16_to_cpu(rxh_le->PhyRxStatus_0); in brcms_b_recv()
7689 rxh->PhyRxStatus_1 = le16_to_cpu(rxh_le->PhyRxStatus_1); in brcms_b_recv()
7690 rxh->PhyRxStatus_2 = le16_to_cpu(rxh_le->PhyRxStatus_2); in brcms_b_recv()
7691 rxh->PhyRxStatus_3 = le16_to_cpu(rxh_le->PhyRxStatus_3); in brcms_b_recv()
7692 rxh->PhyRxStatus_4 = le16_to_cpu(rxh_le->PhyRxStatus_4); in brcms_b_recv()
7693 rxh->PhyRxStatus_5 = le16_to_cpu(rxh_le->PhyRxStatus_5); in brcms_b_recv()
7694 rxh->RxStatus1 = le16_to_cpu(rxh_le->RxStatus1); in brcms_b_recv()
7695 rxh->RxStatus2 = le16_to_cpu(rxh_le->RxStatus2); in brcms_b_recv()
7696 rxh->RxTSFTime = le16_to_cpu(rxh_le->RxTSFTime); in brcms_b_recv()
7697 rxh->RxChan = le16_to_cpu(rxh_le->RxChan); in brcms_b_recv()
7699 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7705 /* second-level interrupt processing
7706 * Return true if another dpc needs to be re-scheduled. false otherwise.
7712 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc()
7713 struct bcma_device *core = wlc_hw->d11core; in brcms_c_dpc()
7716 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_dpc()
7718 brcms_down(wlc->wl); in brcms_c_dpc()
7723 macintstatus = wlc->macintstatus; in brcms_c_dpc()
7724 wlc->macintstatus = 0; in brcms_c_dpc()
7727 wlc_hw->unit, macintstatus); in brcms_c_dpc()
7729 WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ in brcms_c_dpc()
7734 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) in brcms_c_dpc()
7735 wlc->macintstatus |= MI_TFS; in brcms_c_dpc()
7748 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); in brcms_c_dpc()
7749 wlc->qvalid = 0; in brcms_c_dpc()
7758 wlc->macintstatus |= MI_DMAINT; in brcms_c_dpc()
7762 wlc_phy_noise_sample_intr(wlc_hw->band->pi); in brcms_c_dpc()
7766 "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); in brcms_c_dpc()
7769 __func__, ai_get_chip_id(wlc_hw->sih), in brcms_c_dpc()
7770 ai_get_chiprev(wlc_hw->sih)); in brcms_c_dpc()
7771 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7780 " RF Disable Input\n", wlc_hw->unit); in brcms_c_dpc()
7781 brcms_rfkill_set_hw_state(wlc->wl); in brcms_c_dpc()
7788 /* it isn't done and needs to be resched if macintstatus is non-zero */ in brcms_c_dpc()
7789 return wlc->macintstatus != 0; in brcms_c_dpc()
7792 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7793 return wlc->macintstatus != 0; in brcms_c_dpc()
7798 struct bcma_device *core = wlc->hw->d11core; in brcms_c_init()
7799 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_init()
7802 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit); in brcms_c_init()
7804 chanspec = ch20mhz_chspec(ch->hw_value); in brcms_c_init()
7806 brcms_b_init(wlc->hw, chanspec); in brcms_c_init()
7812 brcms_c_set_mac(wlc->bsscfg); in brcms_c_init()
7813 brcms_c_set_bssid(wlc->bsscfg); in brcms_c_init()
7816 if (wlc->pub->associated && wlc->pub->up) { in brcms_c_init()
7820 bi = wlc->bsscfg->current_bss->beacon_period << 10; in brcms_c_init()
7835 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_init()
7838 brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, in brcms_c_init()
7839 (wlc-> in brcms_c_init()
7843 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); in brcms_c_init()
7844 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); in brcms_c_init()
7850 brcms_c_ampdu_shm_upd(wlc->ampdu); in brcms_c_init()
7852 /* band-specific inits */ in brcms_c_init()
7860 if (wlc->ucode_rev == 0) { in brcms_c_init()
7864 rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR); in brcms_c_init()
7865 patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); in brcms_c_init()
7866 wlc->ucode_rev = (rev << NBITS(u16)) | patch; in brcms_c_init()
7867 snprintf(wlc->wiphy->fw_version, in brcms_c_init()
7868 sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch); in brcms_c_init()
7876 brcms_b_mute(wlc->hw, true); in brcms_c_init()
7885 if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { in brcms_c_init()
7890 wlc->wme_retries[ac] = in brcms_c_init()
7891 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); in brcms_c_init()
7911 wlc->wiphy = wl->wiphy; in brcms_c_attach()
7912 pub = wlc->pub; in brcms_c_attach()
7918 wlc->band = wlc->bandstate[0]; in brcms_c_attach()
7919 wlc->core = wlc->corestate; in brcms_c_attach()
7920 wlc->wl = wl; in brcms_c_attach()
7921 pub->unit = unit; in brcms_c_attach()
7922 pub->_piomode = piomode; in brcms_c_attach()
7923 wlc->bandinit_pending = false; in brcms_c_attach()
7924 wlc->beacon_template_virgin = true; in brcms_c_attach()
7934 * inside, no more in rest of the attach) in brcms_c_attach()
7942 pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); in brcms_c_attach()
7945 wlc->tx_duty_cycle_ofdm = 0; in brcms_c_attach()
7946 wlc->tx_duty_cycle_cck = 0; in brcms_c_attach()
7951 if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) in brcms_c_attach()
7952 wlc->stf->txant = wlc->stf->hw_txchain - 1; in brcms_c_attach()
7955 wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, in brcms_c_attach()
7956 wlc->stf->hw_rxchain); in brcms_c_attach()
7960 wlc->core->txavail[i] = wlc->hw->txavail[i]; in brcms_c_attach()
7962 memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7963 memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7965 for (j = 0; j < wlc->pub->_nbands; j++) { in brcms_c_attach()
7966 wlc->band = wlc->bandstate[j]; in brcms_c_attach()
7974 wlc->band->CWmin = APHY_CWMIN; in brcms_c_attach()
7975 wlc->band->CWmax = PHY_CWMAX; in brcms_c_attach()
7978 if (wlc->band->bandtype == BRCM_BAND_2G) { in brcms_c_attach()
7979 wlc->band->gmode = GMODE_AUTO; in brcms_c_attach()
7981 wlc->band->gmode); in brcms_c_attach()
7985 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_attach()
7986 pub->_n_enab = SUPPORT_11N; in brcms_c_attach()
7988 ((pub->_n_enab == in brcms_c_attach()
7993 /* init per-band default rateset, depend on band->gmode */ in brcms_c_attach()
7994 brcms_default_rateset(wlc, &wlc->band->defrateset); in brcms_c_attach()
7996 /* fill in hw_rateset */ in brcms_c_attach()
7997 brcms_c_rateset_filter(&wlc->band->defrateset, in brcms_c_attach()
7998 &wlc->band->hw_rateset, false, in brcms_c_attach()
8000 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_attach()
8005 * wlc->stf->txant/txchain/ant_rx_ovr change in brcms_c_attach()
8015 wiphy_err(wl->wiphy, "wl%d: %s: init_timer failed\n", unit, in brcms_c_attach()
8022 wlc->cmi = brcms_c_channel_mgr_attach(wlc); in brcms_c_attach()
8023 if (!wlc->cmi) { in brcms_c_attach()
8024 wiphy_err(wl->wiphy, "wl%d: %s: channel_mgr_attach failed" in brcms_c_attach()
8030 /* init default when all parameters are ready, i.e. ->rateset */ in brcms_c_attach()
8037 wlc->bsscfg->wlc = wlc; in brcms_c_attach()
8039 wlc->mimoft = FT_HT; in brcms_c_attach()
8040 wlc->mimo_40txbw = AUTO; in brcms_c_attach()
8041 wlc->ofdm_40txbw = AUTO; in brcms_c_attach()
8042 wlc->cck_40txbw = AUTO; in brcms_c_attach()
8049 } else if (BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_attach()
8056 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); in brcms_c_attach()
8064 wiphy_err(wl->wiphy, "wl%d: %s: failed with err %d\n", in brcms_c_attach()