17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/if_ether.h>
45 #define TIMER_INTERVAL_WATCHDOG 1000
47 #define TIMER_INTERVAL_RADIOCHK 800
50 #define BEACON_INTERVAL_DEFAULT 100
61 #define EDCF_ACI_MASK 0x60
62 #define EDCF_ACI_SHIFT 5
63 #define EDCF_ECWMIN_MASK 0x0f
64 #define EDCF_ECWMAX_SHIFT 4
65 #define EDCF_AIFSN_MASK 0x0f
66 #define EDCF_AIFSN_MAX 15
67 #define EDCF_ECWMAX_MASK 0xf0
69 #define EDCF_AC_BE_TXOP_STA 0x0000
70 #define EDCF_AC_BK_TXOP_STA 0x0000
71 #define EDCF_AC_VO_ACI_STA 0x62
72 #define EDCF_AC_VO_ECW_STA 0x32
73 #define EDCF_AC_VI_ACI_STA 0x42
74 #define EDCF_AC_VI_ECW_STA 0x43
75 #define EDCF_AC_BK_ECW_STA 0xA4
76 #define EDCF_AC_VI_TXOP_STA 0x005e
77 #define EDCF_AC_VO_TXOP_STA 0x002f
78 #define EDCF_AC_BE_ACI_STA 0x03
79 #define EDCF_AC_BE_ECW_STA 0xA4
80 #define EDCF_AC_BK_ACI_STA 0x27
81 #define EDCF_AC_VO_TXOP_AP 0x002f
83 #define EDCF_TXOP2USEC(txop) ((txop) << 5)
84 #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1)
86 #define APHY_SYMBOL_TIME 4
87 #define APHY_PREAMBLE_TIME 16
88 #define APHY_SIGNAL_TIME 4
89 #define APHY_SIFS_TIME 16
90 #define APHY_SERVICE_NBITS 16
91 #define APHY_TAIL_NBITS 6
92 #define BPHY_SIFS_TIME 10
93 #define BPHY_PLCP_SHORT_TIME 96
95 #define PREN_PREAMBLE 24
96 #define PREN_MM_EXT 12
97 #define PREN_PREAMBLE_EXT 4
99 #define DOT11_MAC_HDR_LEN 24
100 #define DOT11_ACK_LEN 10
101 #define DOT11_BA_LEN 4
102 #define DOT11_OFDM_SIGNAL_EXTENSION 6
103 #define DOT11_MIN_FRAG_LEN 256
104 #define DOT11_RTS_LEN 16
105 #define DOT11_CTS_LEN 10
106 #define DOT11_BA_BITMAP_LEN 128
107 #define DOT11_MIN_BEACON_PERIOD 1
108 #define DOT11_MAX_BEACON_PERIOD 0xFFFF
109 #define DOT11_MAXNUMFRAGS 16
110 #define DOT11_MAX_FRAG_LEN 2346
112 #define BPHY_PLCP_TIME 192
113 #define RIFS_11N_TIME 2
116 #define BCN_TMPL_LEN 512
119 #define BRCMS_BSS_HT 0x0020
122 #define BRCMS_HWRXOFF 38
125 #define RFDISABLE_DEFAULT 10000000
127 #define BRCMS_TEMPSENSE_PERIOD 10
135 #define _BRCMS_PREC_NONE 0
136 #define _BRCMS_PREC_BK 2
137 #define _BRCMS_PREC_BE 4
138 #define _BRCMS_PREC_EE 6
139 #define _BRCMS_PREC_CL 8
140 #define _BRCMS_PREC_VI 10
141 #define _BRCMS_PREC_VO 12
142 #define _BRCMS_PREC_NC 14
145 #define SYNTHPU_DLY_APHY_US 3700
146 #define SYNTHPU_DLY_BPHY_US 1050
147 #define SYNTHPU_DLY_NPHY_US 2048
148 #define SYNTHPU_DLY_LPPHY_US 300
153 #define EDCF_SHORT_S 0
155 #define EDCF_LONG_S 8
156 #define EDCF_LFB_S 12
157 #define EDCF_SHORT_M BITFIELD_MASK(4)
158 #define EDCF_SFB_M BITFIELD_MASK(4)
159 #define EDCF_LONG_M BITFIELD_MASK(4)
160 #define EDCF_LFB_M BITFIELD_MASK(4)
162 #define RETRY_SHORT_DEF 7
163 #define RETRY_SHORT_MAX 255
164 #define RETRY_LONG_DEF 4
165 #define RETRY_SHORT_FB 3
166 #define RETRY_LONG_FB 2
168 #define APHY_CWMIN 15
169 #define PHY_CWMAX 1023
171 #define EDCF_AIFSN_MIN 1
173 #define FRAGNUM_MASK 0xF
175 #define APHY_SLOT_TIME 9
176 #define BPHY_SLOT_TIME 20
178 #define WL_SPURAVOID_OFF 0
179 #define WL_SPURAVOID_ON1 1
180 #define WL_SPURAVOID_ON2 2
183 #define BRCMS_USE_COREFLAGS 0xffffffff
186 #define BRCMS_PLCP_AUTO -1
187 #define BRCMS_PLCP_SHORT 0
188 #define BRCMS_PLCP_LONG 1
191 #define BRCMS_PROTECTION_AUTO -1
192 #define BRCMS_PROTECTION_OFF 0
193 #define BRCMS_PROTECTION_ON 1
194 #define BRCMS_PROTECTION_MMHDR_ONLY 2
195 #define BRCMS_PROTECTION_CTS_ONLY 3
198 #define BRCMS_PROTECTION_CTL_OFF 0
199 #define BRCMS_PROTECTION_CTL_LOCAL 1
200 #define BRCMS_PROTECTION_CTL_OVERLAP 2
203 #define BRCMS_N_PROTECTION_OFF 0
204 #define BRCMS_N_PROTECTION_OPTIONAL 1
205 #define BRCMS_N_PROTECTION_20IN40 2
206 #define BRCMS_N_PROTECTION_MIXEDMODE 3
209 #define BRCMS_N_BW_20ALL 0
210 #define BRCMS_N_BW_40ALL 1
211 #define BRCMS_N_BW_20IN2G_40IN5G 2
214 #define BRCMS_N_SGI_20 0x01
215 #define BRCMS_N_SGI_40 0x02
219 #define NRATE_MCS_INUSE 0x00000080
221 #define NRATE_RATE_MASK 0x0000007f
223 #define NRATE_STF_MASK 0x0000ff00
225 #define NRATE_STF_SHIFT 8
227 #define NRATE_OVERRIDE_MCS_ONLY 0x40000000
228 #define NRATE_SGI_MASK 0x00800000
229 #define NRATE_SGI_SHIFT 23
230 #define NRATE_LDPC_CODING 0x00400000
231 #define NRATE_LDPC_SHIFT 22
233 #define NRATE_STF_SISO 0
234 #define NRATE_STF_CDD 1
235 #define NRATE_STF_STBC 2
236 #define NRATE_STF_SDM 3
238 #define MAX_DMA_SEGS 4
246 #define NRXBUFPOST 32
249 #define BRCMS_DATAHIWAT 50
272 #define XMTFIFOTBL_STARTREV 17
306 static const u8 wme_fifo2ac[] = {
316 static const u8 wme_ac2fifo[] = {
335 static const u16 xmtfifo_sz[][
NFIFO] = {
337 {20, 192, 192, 21, 17, 5},
343 {20, 192, 192, 21, 17, 5},
345 {9, 58, 22, 14, 14, 5},
347 {20, 192, 192, 21, 17, 5},
349 {20, 192, 192, 21, 17, 5},
351 {9, 58, 22, 14, 14, 5},
359 {9, 58, 22, 14, 14, 5},
363 static const char *
const fifo_names[] = {
364 "AC_BK",
"AC_BE",
"AC_VI",
"AC_VO",
"BCMC",
"ATIM" };
366 static const char fifo_names[6][0];
377 if (is_mcs_rate(rspec))
383 static u16 frametype(
u32 rspec,
u8 mimoframe)
385 if (is_mcs_rate(rspec))
406 static bool brcms_deviceremoved(
struct brcms_c_info *wlc)
412 macctrl = bcma_read32(wlc->
hw->d11core,
420 return wlc->
core->txpktpend[0] + wlc->
core->txpktpend[1] +
421 wlc->
core->txpktpend[2] + wlc->
core->txpktpend[3];
424 static bool brcms_is_mband_unlocked(
struct brcms_c_info *wlc)
448 static void brcms_c_detach_mfree(
struct brcms_c_info *wlc)
453 brcms_c_bsscfg_mfree(wlc->
bsscfg);
485 brcms_c_bsscfg_mfree(cfg);
517 wlc->
hw->bandstate[0] =
519 if (wlc->
hw->bandstate[0] ==
NULL) {
527 ((
unsigned long)wlc->
hw->bandstate[0] +
544 wlc->
bsscfg = brcms_c_bsscfg_malloc(unit);
593 brcms_c_detach_mfree(wlc);
602 static void brcms_b_update_slot_timing(
struct brcms_hardware *wlc_hw,
609 bcma_write16(core,
D11REGOFFS(ifs_slot), 0x0207);
613 bcma_write16(core,
D11REGOFFS(ifs_slot), 0x0212);
623 u8 preamble_type,
uint mac_len)
625 uint nsyms, dur = 0, Ndps, kNdps;
634 BCMMSG(wlc->
wiphy,
"wl%d: rspec 0x%x, preamble_type %d, len%d\n",
635 wlc->
pub->unit, ratespec, preamble_type, mac_len);
637 if (is_mcs_rate(ratespec)) {
639 int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec);
645 kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec),
646 rspec_issgi(ratespec)) * 4;
648 if (rspec_stc(ratespec) == 0)
662 }
else if (is_ofdm_rate(rate)) {
679 mac_len = mac_len * 8 * 2;
681 dur = (mac_len + rate - 1) / rate;
706 bcma_write16(core, offset, value);
708 bcma_write32(core, offset, value);
722 for (idx = 0; idx <
MHFMAX; idx++)
732 brcms_c_write_mhf(wlc_hw, wlc_hw->
band->mhfs);
739 wiphy_err(wiphy,
"%s: wl%d: unsupported phy in corerev"
740 " %d\n", __func__, wlc_hw->
unit,
745 brcms_c_write_inits(wlc_hw,
748 wiphy_err(wiphy,
"%s: wl%d: unsupported phy in"
749 " core rev %d\n", __func__,
752 wiphy_err(wiphy,
"%s: wl%d: unsupported corerev %d\n",
768 BCMMSG(wlc_hw->
wlc->wiphy,
"wl%d: clk %d\n", wlc_hw->
unit, clk);
784 brcms_b_core_ioctl(wlc_hw,
SICF_FGC, 0);
793 BCMMSG(wlc_hw->
wlc->wiphy,
"wl%d: bandunit %d\n", wlc_hw->
unit,
802 wlc_hw->
wlc->band = wlc_hw->
wlc->bandstate[bandunit];
811 brcms_b_core_ioctl(wlc_hw,
SICF_GMODE, gmode);
823 macctrl = bcma_read32(wlc_hw->
d11core,
833 brcms_b_core_phy_clk(wlc_hw,
OFF);
835 brcms_c_setxband(wlc_hw, bandunit);
849 int tx_rts, tx_frame_count, tx_rts_count;
865 BCMMSG(wlc->
wiphy,
"INTERMEDIATE but not AMPDU\n");
870 if (queue >=
NFIFO) {
886 brcms_c_print_txdesc(txh);
893 tx_info = IEEE80211_SKB_CB(p);
907 "%s: Pkt tx suppressed, possibly channel %d\n",
943 txrate = tx_info->
status.rates;
949 ieee80211_tx_info_clear_status(tx_info);
951 if ((tx_frame_count > fbl) && (txrate[1].idx >= 0)) {
956 txrate[0].
count = fbl;
957 txrate[1].
count = tx_frame_count - fbl;
963 txrate[0].
count = tx_frame_count;
994 "tx_status\n", __func__);
1013 bool morepending =
false;
1030 s1 = bcma_read32(core,
D11REGOFFS(frmtxstatus));
1034 if (s1 == 0xffffffff) {
1036 wlc_hw->
unit, __func__);
1039 s2 = bcma_read32(core,
D11REGOFFS(frmtxstatus2));
1047 *fatal = brcms_c_dotxstatus(wlc_hw->
wlc, txs);
1050 if (++n >= max_tx_num)
1052 s1 = bcma_read32(core,
D11REGOFFS(frmtxstatus));
1058 if (n >= max_tx_num)
1085 mhfs[
MHF2] |= mhf2_init;
1115 struct wiphy *wiphy = wlc->
wiphy;
1118 snprintf(name,
sizeof(name),
"wl%d", unit);
1120 if (wlc_hw->
di[0] ==
NULL) {
1121 int dma_attach_err = 0;
1134 dma_attach_err |= (
NULL == wlc_hw->
di[0]);
1144 NTXD, 0, 0, -1, 0, 0,
1146 dma_attach_err |= (
NULL == wlc_hw->
di[1]);
1155 NTXD, 0, 0, -1, 0, 0,
1157 dma_attach_err |= (
NULL == wlc_hw->
di[2]);
1167 dma_attach_err |= (
NULL == wlc_hw->
di[3]);
1170 if (dma_attach_err) {
1171 wiphy_err(wiphy,
"wl%d: wlc_attach: dma_attach failed"
1177 for (i = 0; i <
NFIFO; i++)
1185 brcms_c_mhfdef(wlc, wlc_hw->
band->mhfs, pio_mhf2);
1194 for (j = 0; j <
NFIFO; j++) {
1195 if (wlc_hw->
di[j]) {
1223 wlc_hw->
chanspec = ch20mhz_chspec(1);
1255 ((bcma_read32(wlc_hw->
d11core,
1263 if ((ai_get_pmurev(wlc_hw->
sih) == 0) &&
1268 ((bcma_read32(wlc_hw->
d11core,
1333 if ((val & ~mask) || idx >= MHFMAX)
1342 band = wlc_hw->
band;
1361 if (wlc_hw->
clk && (band->
mhfs[idx] != save)
1362 && (band == wlc_hw->
band))
1419 new_maccontrol = (maccontrol & ~mask) | val;
1422 if (new_maccontrol == maccontrol)
1429 brcms_c_mctrl_write(wlc_hw);
1442 brcms_c_mctrl_write(wlc_hw);
1443 brcms_b_wait_for_wake(wlc_hw);
1454 brcms_c_mctrl_write(wlc_hw);
1464 static void brcms_c_ucode_mute_override_set(
struct brcms_hardware *wlc_hw)
1474 brcms_c_mctrl_write(wlc_hw);
1478 static void brcms_c_ucode_mute_override_clear(
struct brcms_hardware *wlc_hw)
1491 brcms_c_mctrl_write(wlc_hw);
1498 brcms_b_set_addrmatch(
struct brcms_hardware *wlc_hw,
int match_reg_offset,
1506 BCMMSG(wlc_hw->
wlc->wiphy,
"wl%d: brcms_b_set_addrmatch\n",
1509 mac_l = addr[0] | (addr[1] << 8);
1510 mac_m = addr[2] | (addr[3] << 8);
1511 mac_h = addr[4] | (addr[5] << 8);
1516 bcma_write16(core,
D11REGOFFS(rcm_mat_data), mac_l);
1517 bcma_write16(core,
D11REGOFFS(rcm_mat_data), mac_m);
1518 bcma_write16(core,
D11REGOFFS(rcm_mat_data), mac_h);
1532 bcma_write32(core,
D11REGOFFS(tplatewrptr), offset);
1545 word = *(
u32 *)&word_be;
1548 word = *(
u32 *)&word_le;
1551 bcma_write32(core,
D11REGOFFS(tplatewrdata), word);
1553 buf = (
u8 *) buf +
sizeof(
u32);
1560 wlc_hw->
band->CWmin = newmin;
1570 wlc_hw->
band->CWmax = newmax;
1613 static void brcms_c_ucode_txant_set(
struct brcms_hardware *wlc_hw)
1621 phyctl = (phyctl & ~mask) | phytxant;
1626 phyctl = (phyctl & ~mask) | phytxant;
1635 struct plcp_signal_rate_lookup {
1640 const struct plcp_signal_rate_lookup rate_lookup[] = {
1651 for (i = 0; i <
ARRAY_SIZE(rate_lookup); i++) {
1652 if (rate == rate_lookup[i].rate) {
1653 plcp_rate = rate_lookup[
i].signal_rate;
1664 static void brcms_upd_ofdm_pctl1_table(
struct brcms_hardware *wlc_hw)
1682 entry_ptr = brcms_b_ofdm_ratetable_offset(wlc_hw, rate);
1704 wlc_hw->
band->bandunit);
1706 brcms_c_ucode_bsinit(wlc_hw);
1710 brcms_c_ucode_txant_set(wlc_hw);
1716 brcms_b_set_cwmin(wlc_hw, wlc_hw->
band->CWmin);
1717 brcms_b_set_cwmax(wlc_hw, wlc_hw->
band->CWmax);
1719 brcms_b_update_slot_timing(wlc_hw,
1731 brcms_upd_ofdm_pctl1_table(wlc_hw);
1733 brcms_b_upd_synthpu(wlc_hw);
1767 brcms_b_core_ioctl(wlc_hw,
SICF_FGC, 0);
1783 bool phy_in_reset =
false;
1796 brcms_b_core_ioctl(wlc_hw,
SICF_BWMASK, phy_bw_clkbits);
1806 phy_in_reset =
true;
1808 brcms_b_core_ioctl(wlc_hw,
1814 brcms_b_core_phy_clk(wlc_hw,
ON);
1829 brcms_c_mctrl_reset(wlc_hw);
1832 macintmask = brcms_c_setband_inact(wlc, bandunit);
1837 brcms_b_core_phy_clk(wlc_hw,
ON);
1840 brcms_b_bsinit(wlc, chanspec);
1863 wiphy_err(wlc_hw->
wlc->wiphy,
"unsupported core rev %d\n",
1872 static bool brcms_c_validboardtype(
struct brcms_hardware *wlc_hw)
1877 uint brt = (boardrev & 0xf000) >> 12;
1878 uint b0 = (boardrev & 0xf00) >> 8;
1879 uint b1 = (boardrev & 0xf0) >> 4;
1880 uint b2 = boardrev & 0xf;
1890 if (boardrev <= 0xff)
1893 if ((brt > 2) || (brt == 0) || (b0 > 9) || (b0 == 0) || (b1 > 9)
1905 if (!is_zero_ether_addr(sprom->
il0mac)) {
1917 static void brcms_b_xtal(
struct brcms_hardware *wlc_hw,
bool want)
1919 BCMMSG(wlc_hw->
wlc->wiphy,
"wl%d: want %d\n", wlc_hw->
unit, want);
1925 if (!want && wlc_hw->
pllreq)
1928 wlc_hw->
sbclk = want;
1929 if (!wlc_hw->
sbclk) {
1930 wlc_hw->
clk =
false;
1931 if (wlc_hw->
band && wlc_hw->
band->pi)
1942 static bool brcms_b_radio_read_hwdisabled(
struct brcms_hardware *wlc_hw)
1947 xtal = wlc_hw->
sbclk;
1949 brcms_b_xtal(wlc_hw,
ON);
1970 brcms_c_mctrl_reset(wlc_hw);
1973 v = ((bcma_read32(wlc_hw->
d11core,
1981 brcms_b_xtal(wlc_hw,
OFF);
2006 flags = (wlc_hw->
band->pi ? wlc_hw->
band->core_flags : 0);
2017 for (i = 0; i <
NFIFO; i++)
2020 "dma_txreset[%d]: cannot stop dma\n",
2021 wlc_hw->
unit, __func__, i);
2024 && (!wlc_dma_rxreset(wlc_hw,
RX_FIFO)))
2026 "[%d]: cannot stop dma\n",
2031 wlc_hw->
wlc->macintstatus = 0;
2054 wlc_hw->
clk =
false;
2057 if (wlc_hw->
band && wlc_hw->
band->pi)
2060 brcms_c_mctrl_reset(wlc_hw);
2071 wlc_hw->
wlc->macintstatus = 0;
2081 static void brcms_b_corerev_fifofixup(
struct brcms_hardware *wlc_hw)
2086 u16 txfifo_def, txfifo_def1;
2093 for (fifo_nu = 0; fifo_nu <
NFIFO; fifo_nu++) {
2095 txfifo_endblk = txfifo_startblk + wlc_hw->
xmtfifo_sz[fifo_nu];
2096 txfifo_def = (txfifo_startblk & 0xff) |
2098 txfifo_def1 = ((txfifo_startblk >> 8) & 0x1) |
2104 bcma_write16(core,
D11REGOFFS(xmtfifocmd), txfifo_cmd);
2105 bcma_write16(core,
D11REGOFFS(xmtfifodef), txfifo_def);
2106 bcma_write16(core,
D11REGOFFS(xmtfifodef1), txfifo_def1);
2108 bcma_write16(core,
D11REGOFFS(xmtfifocmd), txfifo_cmd);
2110 txfifo_startblk += wlc_hw->
xmtfifo_sz[fifo_nu];
2148 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_l), 0x2082);
2149 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_h), 0x8);
2151 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_l), 0x5341);
2152 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_h), 0x8);
2154 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_l), 0x8889);
2155 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_h), 0x8);
2159 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_l), 0x7CE0);
2160 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_h), 0xC);
2162 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_l), 0xCCCD);
2163 bcma_write16(core,
D11REGOFFS(tsf_clk_frac_h), 0xC);
2169 static void brcms_c_gpio_init(
struct brcms_c_info *wlc)
2240 count = (nbytes /
sizeof(
u32));
2245 for (i = 0; i <
count; i++)
2290 brcms_c_ucode_txant_set(wlc_hw);
2296 return (
u16) wlc_hw->
wlc->stf->txant;
2313 struct wiphy *wiphy = wlc_hw->
wlc->wiphy;
2315 unit = wlc_hw->
unit;
2317 for (idx = 0; idx <
NFIFO; idx++) {
2326 BCMMSG(wlc_hw->
wlc->wiphy,
"wl%d: intstatus%d 0x%x\n",
2327 unit, idx, intstatus);
2329 if (intstatus &
I_RO) {
2330 wiphy_err(wiphy,
"wl%d: fifo %d: receive fifo "
2331 "overflow\n", unit, idx);
2335 if (intstatus &
I_PC) {
2336 wiphy_err(wiphy,
"wl%d: fifo %d: descriptor error\n",
2341 if (intstatus &
I_PD) {
2342 wiphy_err(wiphy,
"wl%d: fifo %d: data error\n", unit,
2347 if (intstatus &
I_DE) {
2348 wiphy_err(wiphy,
"wl%d: fifo %d: descriptor protocol "
2349 "error\n", unit, idx);
2353 if (intstatus &
I_RU)
2354 wiphy_err(wiphy,
"wl%d: fifo %d: receive descriptor "
2355 "underflow\n", idx, unit);
2357 if (intstatus &
I_XU) {
2358 wiphy_err(wiphy,
"wl%d: fifo %d: transmit fifo "
2359 "underflow\n", idx, unit);
2410 static void brcms_b_tx_fifo_suspend(
struct brcms_hardware *wlc_hw,
2428 if (wlc_hw->
di[tx_fifo]) {
2444 static void brcms_b_tx_fifo_resume(
struct brcms_hardware *wlc_hw,
2452 if (wlc_hw->
di[tx_fifo])
2467 static void brcms_b_mute(
struct brcms_hardware *wlc_hw,
bool mute_tx)
2469 static const u8 null_ether_addr[
ETH_ALEN] = {0, 0, 0, 0, 0, 0};
2496 brcms_c_ucode_mute_override_set(wlc_hw);
2498 brcms_c_ucode_mute_override_clear(wlc_hw);
2504 brcms_b_mute(wlc->
hw, mute_tx);
2515 static inline u32 wlc_intstatus(
struct brcms_c_info *wlc,
bool in_isr)
2522 macintstatus = bcma_read32(core,
D11REGOFFS(macintstatus));
2528 if (brcms_deviceremoved(wlc))
2534 if (macintstatus == 0xffffffff)
2541 if (macintstatus == 0)
2549 bcma_write32(core,
D11REGOFFS(macintmask), 0);
2554 bcma_write32(core,
D11REGOFFS(macintstatus), macintstatus);
2566 return macintstatus;
2576 macintstatus = wlc_intstatus(wlc,
false);
2579 if (macintstatus == 0xffffffff)
2605 macintstatus = wlc_intstatus(wlc,
true);
2607 if (macintstatus == 0xffffffff)
2612 if (macintstatus == 0)
2629 struct wiphy *wiphy = wlc->
wiphy;
2632 wlc_hw->
band->bandunit);
2644 mc = bcma_read32(core,
D11REGOFFS(maccontrol));
2646 if (mc == 0xffffffff) {
2656 mi = bcma_read32(core,
D11REGOFFS(macintstatus));
2657 if (mi == 0xffffffff) {
2670 if (!(bcma_read32(core,
D11REGOFFS(macintstatus)) & MI_MACSSPNDD)) {
2671 wiphy_err(wiphy,
"wl%d: wlc_suspend_mac_and_wait: waited %d uS"
2672 " and MI_MACSSPNDD is still not on.\n",
2674 wiphy_err(wiphy,
"wl%d: psmdebug 0x%08x, phydebug 0x%08x, "
2675 "psm_brc 0x%04x\n", wlc_hw->
unit,
2681 mc = bcma_read32(core,
D11REGOFFS(maccontrol));
2682 if (mc == 0xffffffff) {
2689 WARN_ON(!(mc & MCTL_PSM_RUN));
2700 wlc->
band->bandunit);
2709 mc = bcma_read32(core,
D11REGOFFS(maccontrol));
2717 mc = bcma_read32(core,
D11REGOFFS(maccontrol));
2720 WARN_ON(!(mc & MCTL_PSM_RUN));
2722 mi = bcma_read32(core,
D11REGOFFS(macintstatus));
2734 brcms_upd_ofdm_pctl1_table(wlc_hw);
2737 static bool brcms_b_validate_chip_access(
struct brcms_hardware *wlc_hw)
2741 struct wiphy *wiphy = wlc_hw->
wlc->wiphy;
2758 val = bcma_read32(core,
D11REGOFFS(objdata));
2759 if (val != (
u32) 0xaa5555aa) {
2760 wiphy_err(wiphy,
"wl%d: validate_chip_access: SHM = 0x%x, "
2761 "expected 0xaa5555aa\n", wlc_hw->
unit, val);
2771 val = bcma_read32(core,
D11REGOFFS(objdata));
2772 if (val != (
u32) 0x55aaaa55) {
2773 wiphy_err(wiphy,
"wl%d: validate_chip_access: SHM = 0x%x, "
2774 "expected 0x55aaaa55\n", wlc_hw->
unit, val);
2783 bcma_write32(core,
D11REGOFFS(tsf_cfpstart), 0);
2785 w = bcma_read32(core,
D11REGOFFS(maccontrol));
2788 wiphy_err(wiphy,
"wl%d: validate_chip_access: maccontrol = "
2789 "0x%x, expected 0x%x or 0x%x\n", wlc_hw->
unit, w,
2798 #define PHYPLL_WAIT_US 100000
2819 tmp = bcma_read32(core,
D11REGOFFS(clk_ctl_st));
2820 if ((tmp & CCS_ERSRC_AVAIL_HT) != CCS_ERSRC_AVAIL_HT)
2822 " PLL failed\n", __func__);
2833 tmp = bcma_read32(core,
D11REGOFFS(clk_ctl_st));
2839 "PHY PLL failed\n", __func__);
2859 dev_gone = brcms_deviceremoved(wlc_hw->
wlc);
2876 wlc_hw->
clk =
false;
2881 static void brcms_c_flushqueues(
struct brcms_c_info *wlc)
2887 for (i = 0; i <
NFIFO; i++)
2888 if (wlc_hw->
di[i]) {
2890 wlc->
core->txpktpend[
i] = 0;
2904 bcma_write32(core,
D11REGOFFS(objaddr), sel | (offset >> 2));
2909 return bcma_read16(core, objoff);
2919 bcma_write32(core,
D11REGOFFS(objaddr), sel | (offset >> 2));
2924 bcma_write16(core, objoff, v);
2953 const void *
buf,
int len,
u32 sel)
2956 const u8 *p = (
const u8 *)buf;
2959 if (len <= 0 || (offset & 1) || (len & 1))
2962 for (i = 0; i < len; i += 2) {
2963 v = p[
i] | (p[i + 1] << 8);
2964 brcms_b_write_objmem(wlc_hw, offset + i, v, sel);
2982 if (len <= 0 || (offset & 1) || (len & 1))
2985 for (i = 0; i < len; i += 2) {
2986 v = brcms_b_read_objmem(wlc_hw, offset + i, sel);
2988 p[i + 1] = (v >> 8) & 0xFF;
2997 const void *
buf,
int len)
3002 static void brcms_b_retrylimit_upd(
struct brcms_hardware *wlc_hw,
3021 static void brcms_b_pllreq(
struct brcms_hardware *wlc_hw,
bool set,
u32 req_bit)
3031 brcms_b_xtal(wlc_hw,
ON);
3041 brcms_b_xtal(wlc_hw,
OFF);
3055 static bool brcms_c_ps_allowed(
struct brcms_c_info *wlc)
3060 if (!wlc->
pub->associated)
3097 rxf0ovfl = wlc->
core->macstat_snapshot->rxf0ovfl;
3100 for (i = 0; i <
NFIFO; i++)
3101 txfunfl[i] = wlc->
core->macstat_snapshot->txfunfl[i];
3110 delta = (
u16) (wlc->
core->macstat_snapshot->rxf0ovfl - rxf0ovfl);
3113 wlc->
pub->unit, delta);
3116 for (i = 0; i <
NFIFO; i++) {
3118 (
u16) (wlc->
core->macstat_snapshot->txfunfl[i] -
3122 "\n", wlc->
pub->unit, delta, i);
3127 for (i = 0; i <
NFIFO; i++) {
3138 if (!brcms_deviceremoved(wlc_hw->
wlc))
3142 brcms_c_flushqueues(wlc_hw->
wlc);
3150 brcms_c_statsupd(wlc);
3153 memset((
char *)wlc->
core->macstat_snapshot, 0,
3156 brcms_b_reset(wlc->
hw);
3163 memset(scb, 0,
sizeof(
struct scb));
3165 for (i = 0; i <
NUMPRIO; i++) {
3189 bool fifosz_fixup =
false;
3192 struct wiphy *wiphy = wlc->
wiphy;
3200 brcms_ucode_download(wlc_hw);
3204 fifosz_fixup =
true;
3207 bcma_write32(core,
D11REGOFFS(macintstatus), -1);
3215 wiphy_err(wiphy,
"wl%d: wlc_coreinit: ucode did not self-"
3216 "suspend!\n", wlc_hw->
unit);
3218 brcms_c_gpio_init(wlc);
3226 wiphy_err(wiphy,
"%s: wl%d: unsupported phy in corerev"
3227 " %d\n", __func__, wlc_hw->
unit,
3233 wiphy_err(wiphy,
"%s: wl%d: unsupported phy in corerev"
3234 " %d\n", __func__, wlc_hw->
unit,
3237 wiphy_err(wiphy,
"%s: wl%d: unsupported corerev %d\n",
3243 brcms_b_corerev_fifofixup(wlc_hw);
3279 wiphy_err(wiphy,
"wlc_coreinit: txfifo mismatch: ucode size %d"
3280 " driver size %d index %d\n", buf[i],
3301 bcnint_us = 0x8000 << 10;
3304 bcma_write32(core,
D11REGOFFS(tsf_cfpstart), bcnint_us);
3326 machwcap >> 16) & 0xffff));
3342 bcma_mask16(core,
D11REGOFFS(ifs_ctl), 0x0FFF);
3346 for (i = 0; i <
NFIFO; i++) {
3373 brcms_c_setxband(wlc_hw, chspec_bandunit(chanspec));
3380 brcms_b_coreinit(wlc);
3383 brcms_b_bsinit(wlc, chanspec);
3404 static void brcms_c_set_phy_chanspec(
struct brcms_c_info *wlc,
3413 if (wlc->
stf->ss_algosel_auto)
3427 wlc->
stf->txstreams);
3431 static void brcms_c_rate_lookup_init(
struct brcms_c_info *wlc,
3438 u8 *br = wlc->
band->basic_rate;
3447 for (i = 0; i < rateset->
count; i++) {
3457 "invalid rate 0x%X in rate set\n",
3479 for (i = 0; i < wlc->
band->hw_rateset.count; i++) {
3480 rate = wlc->
band->hw_rateset.rates[
i];
3482 if (br[rate] != 0) {
3487 if (is_ofdm_rate(rate))
3500 br[
rate] = is_ofdm_rate(rate) ? ofdm_basic : cck_basic;
3505 if (is_ofdm_rate(rate)) {
3521 br[
rate] = mandatory;
3525 static void brcms_c_bandinit_ordered(
struct brcms_c_info *wlc,
3530 uint i, band_order[2];
3539 parkband = wlc->
band->bandunit;
3540 band_order[0] = band_order[1] = parkband;
3543 parkband = chspec_bandunit(chanspec);
3546 band_order[0] = parkband ^ 1;
3547 band_order[1] = parkband;
3551 for (i = 0; i < wlc->
pub->_nbands; i++) {
3552 uint j = band_order[
i];
3556 brcms_default_rateset(wlc, &default_rateset);
3564 brcms_c_rate_lookup_init(wlc, &default_rateset);
3568 brcms_c_set_phy_chanspec(wlc, chanspec);
3577 u32 promisc_bits = 0;
3603 static void brcms_c_ucode_mac_upd(
struct brcms_c_info *wlc)
3609 if (wlc->
pub->associated) {
3628 static void brcms_c_write_rate_shm(
struct brcms_c_info *wlc,
u8 rate,
3632 u8 basic_phy_rate, basic_index;
3633 u16 dir_table, basic_table;
3648 index = phy_rate & 0xf;
3649 basic_index = basic_phy_rate & 0xf;
3672 }
else if (wlc->
band->gmode)
3680 static void brcms_c_set_ratetable(
struct brcms_c_info *wlc)
3687 rs_dflt = brcms_c_rateset_get_hwrs(wlc);
3693 for (i = 0; i < rs.
count; i++) {
3699 basic_rate = brcms_basic_rate(wlc, rate);
3700 if (basic_rate == 0)
3706 brcms_c_write_rate_shm(wlc, rate, basic_rate);
3714 wlc->
pub->unit, wlc->
band->bandunit);
3717 brcms_c_set_ratetable(wlc);
3720 brcms_c_ucode_mac_upd(wlc);
3729 brcms_c_duty_cycle_set(
struct brcms_c_info *wlc,
int duty_cycle,
bool isOFDM,
3732 int idle_busy_ratio_x_16 = 0;
3736 if (duty_cycle > 100 || duty_cycle < 0) {
3742 idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle;
3759 static void brcms_c_tx_prec_map_init(
struct brcms_c_info *wlc)
3777 static void brcms_c_txflowcontrol_reset(
struct brcms_c_info *wlc)
3783 brcms_c_txflowcontrol_signal(wlc, qi,
OFF,
ALLPRIO);
3790 static void brcms_c_set_ps_ctrl(
struct brcms_c_info *wlc)
3796 hps = brcms_c_ps_allowed(wlc);
3800 v1 = bcma_read32(wlc->
hw->d11core,
D11REGOFFS(maccontrol));
3810 brcms_b_wait_for_wake(wlc->
hw);
3839 static void brcms_b_set_shortslot(
struct brcms_hardware *wlc_hw,
bool shortslot)
3845 brcms_b_update_slot_timing(wlc_hw, shortslot);
3854 static void brcms_c_switch_shortslot(
struct brcms_c_info *wlc,
bool shortslot)
3865 brcms_b_set_shortslot(wlc->
hw, shortslot);
3868 static void brcms_c_set_home_chanspec(
struct brcms_c_info *wlc,
u16 chanspec)
3873 if (wlc->
bsscfg->associated)
3884 BCMMSG(wlc_hw->
wlc->wiphy,
"wl%d: 0x%x\n", wlc_hw->
unit, chanspec);
3890 bandunit = chspec_bandunit(chanspec);
3891 if (wlc_hw->
band->bandunit != bandunit) {
3899 brcms_b_setband(wlc_hw, bandunit, chanspec);
3901 brcms_c_setxband(wlc_hw, bandunit);
3918 brcms_b_mute(wlc_hw, mute_tx);
3932 brcms_c_set_ps_ctrl(wlc);
3935 brcms_c_bsinit(wlc);
3938 static void brcms_c_set_chanspec(
struct brcms_c_info *wlc,
u16 chanspec)
3941 bool switchband =
false;
3951 if (wlc->
pub->_nbands > 1) {
3952 bandunit = chspec_bandunit(chanspec);
3957 "band is locked!\n",
3958 wlc->
pub->unit, __func__,
3970 brcms_c_setband(wlc, bandunit);
3975 brcms_c_set_phy_chanspec(wlc, chanspec);
3978 if (brcms_chspec_bw(old_chanspec) != brcms_chspec_bw(chanspec)) {
3985 wlc->
band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0);
3989 brcms_c_ucode_mac_upd(wlc);
4002 u16 phytxant = wlc->
stf->phytxant;
4010 phyctl = (phyctl & ~mask) | phytxant;
4064 static void brcms_c_ht_update_sgi_rx(
struct brcms_c_info *wlc,
int val)
4072 static void brcms_c_ht_update_ldpc(
struct brcms_c_info *wlc,
s8 val)
4113 "aifs %d\n", wlc->
pub->unit, acp_shm.
aifs);
4119 bcma_read16(wlc->
hw->d11core,
D11REGOFFS(tsf_random)) &
4130 shm_entry = (
u16 *) &acp_shm;
4149 static const struct edcf_acparam default_edcf_acparams[] = {
4155 const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0];
4162 txq_pars.txop = edcf_acp->
TXOP;
4163 txq_pars.aifs = edcf_acp->
ACI;
4179 static void brcms_c_radio_monitor_start(
struct brcms_c_info *wlc)
4190 static bool brcms_c_radio_monitor_stop(
struct brcms_c_info *wlc)
4201 static void brcms_c_radio_hwdisable_upd(
struct brcms_c_info *wlc)
4203 if (wlc->
pub->hw_off)
4206 if (brcms_b_radio_read_hwdisabled(wlc->
hw))
4215 brcms_c_radio_hwdisable_upd(wlc);
4222 static void brcms_c_radio_timer(
void *
arg)
4226 if (brcms_deviceremoved(wlc)) {
4233 brcms_c_radio_hwdisable_upd(wlc);
4250 brcms_b_fifoerrors(wlc_hw);
4266 if (brcms_deviceremoved(wlc)) {
4276 brcms_c_radio_hwdisable_upd(wlc);
4278 if (wlc->
pub->radio_disabled)
4281 brcms_b_watchdog(wlc);
4288 brcms_c_statsupd(wlc);
4298 static void brcms_c_watchdog_by_timer(
void *arg)
4302 brcms_c_watchdog(wlc);
4305 static bool brcms_c_timers_init(
struct brcms_c_info *wlc,
int unit)
4333 static void brcms_c_info_init(
struct brcms_c_info *wlc,
int unit)
4367 for (i = 0; i <
NFIFO; i++)
4381 wlc->
pub->bcmerror = 0;
4388 unit = wlc->
pub->unit;
4428 uint unit,
bool piomode)
4435 struct wiphy *wiphy = wlc->
wiphy;
4440 BCMMSG(wlc->
wiphy,
"wl%d: vendor 0x%x device 0x%x\n", unit,
4444 BCMMSG(wlc->
wiphy,
"wl%d: vendor 0x%x device 0x%x\n", unit,
4445 core->
bus->boardinfo.vendor,
4446 core->
bus->boardinfo.type);
4457 brcms_b_info_init(wlc_hw);
4465 wiphy_err(wiphy,
"wl%d: brcms_b_attach: si_attach failed\n",
4473 wiphy_err(wiphy,
"wl%d: brcms_b_attach: Unsupported device\n",
4491 if (!brcms_c_isgoodchip(wlc_hw)) {
4508 if (!brcms_b_validate_chip_access(wlc_hw)) {
4509 wiphy_err(wiphy,
"wl%d: brcms_b_attach: validate_chip_access "
4521 if (!brcms_c_validboardtype(wlc_hw)) {
4522 wiphy_err(wiphy,
"wl%d: brcms_b_attach: Unsupported Broadcom "
4523 "board type (0x%x)" " or revision level (0x%x)\n",
4524 unit, ai_get_boardtype(wlc_hw->
sih),
4552 wlc->
pub->sih = wlc_hw->
sih;
4563 wiphy_err(wiphy,
"wl%d: brcms_b_attach: wlc_phy_shim_attach "
4570 sha_params.sih = wlc_hw->
sih;
4571 sha_params.physhim = wlc_hw->
physhim;
4572 sha_params.unit =
unit;
4573 sha_params.corerev = wlc_hw->
corerev;
4576 sha_params.chip = ai_get_chip_id(wlc_hw->
sih);
4577 sha_params.chiprev = ai_get_chiprev(wlc_hw->
sih);
4578 sha_params.chippkg = ai_get_chippkg(wlc_hw->
sih);
4579 sha_params.sromrev = wlc_hw->
sromrev;
4580 sha_params.boardtype = ai_get_boardtype(wlc_hw->
sih);
4581 sha_params.boardrev = wlc_hw->
boardrev;
4593 for (j = 0; j < wlc_hw->
_nbands; j++) {
4599 brcms_c_setxband(wlc_hw, j);
4601 wlc_hw->
band->bandunit =
j;
4603 wlc->
band->bandunit =
j;
4621 wlc_hw->
band->bandtype,
4624 wiphy_err(wiphy,
"wl%d: brcms_b_attach: wlc_phy_"
4625 "attach failed\n", unit);
4633 &wlc_hw->
band->phyrev,
4634 &wlc_hw->
band->radioid,
4635 &wlc_hw->
band->radiorev);
4636 wlc_hw->
band->abgphy_encore =
4639 wlc_hw->
band->core_flags =
4655 wiphy_err(wiphy,
"wl%d: brcms_b_attach: unsupported "
4656 "phy type/rev (%d/%d)\n", unit,
4657 wlc_hw->
band->phytype, wlc_hw->
band->phyrev);
4673 wlc->
band->phytype = wlc_hw->
band->phytype;
4674 wlc->
band->phyrev = wlc_hw->
band->phyrev;
4675 wlc->
band->radioid = wlc_hw->
band->radioid;
4676 wlc->
band->radiorev = wlc_hw->
band->radiorev;
4682 if (!brcms_b_attach_dmapio(wlc, j, wme)) {
4689 brcms_c_coredisable(wlc_hw);
4695 brcms_b_xtal(wlc_hw,
OFF);
4708 brcms_c_get_macaddr(wlc_hw, wlc_hw->
etheraddr);
4710 if (is_broadcast_ether_addr(wlc_hw->
etheraddr) ||
4711 is_zero_ether_addr(wlc_hw->
etheraddr)) {
4712 wiphy_err(wiphy,
"wl%d: brcms_b_attach: bad macaddr\n",
4718 BCMMSG(wlc->
wiphy,
"deviceid 0x%x nbands %d board 0x%x\n",
4724 wiphy_err(wiphy,
"wl%d: brcms_b_attach: failed with err %d\n", unit,
4729 static void brcms_c_attach_antgain_init(
struct brcms_c_info *wlc)
4732 unit = wlc->
pub->unit;
4734 if ((wlc->
band->antgain == -1) && (wlc->
pub->sromrev == 1)) {
4736 wlc->
band->antgain = 8;
4737 }
else if (wlc->
band->antgain == -1) {
4739 " srom, using 2dB\n", unit, __func__);
4740 wlc->
band->antgain = 8;
4756 gain = wlc->
band->antgain & 0x3f;
4759 fract = (wlc->
band->antgain & 0xc0) >> 6;
4760 wlc->
band->antgain = 4 * gain + fract;
4764 static bool brcms_c_attach_stf_ant_init(
struct brcms_c_info *wlc)
4769 struct ssb_sprom *sprom = &wlc->
hw->d11core->bus->sprom;
4771 unit = wlc->
pub->unit;
4772 bandtype = wlc->
band->bandtype;
4780 if ((aa < 1) || (aa > 15)) {
4782 " srom (0x%x), using 3\n", unit, __func__, aa);
4790 }
else if (aa == 2) {
4802 brcms_c_attach_antgain_init(wlc);
4807 static void brcms_c_bss_default_init(
struct brcms_c_info *wlc)
4820 chanspec = ch20mhz_chspec(1);
4825 if (wlc->
pub->_nbands > 1 &&
4826 band->
bandunit != chspec_bandunit(chanspec))
4833 brcms_chspec_bw(chanspec), wlc->
stf->txstreams);
4889 static void brcms_c_update_mimo_band_bwcap(
struct brcms_c_info *wlc,
u8 bwcap)
4894 for (i = 0; i < wlc->
pub->_nbands; i++) {
4911 static void brcms_c_timers_deinit(
struct brcms_c_info *wlc)
4924 static void brcms_c_detach_module(
struct brcms_c_info *wlc)
4951 brcms_b_detach_dmapio(wlc_hw);
4953 band = wlc_hw->
band;
4954 for (i = 0; i < wlc_hw->
_nbands; i++) {
4996 callbacks += brcms_b_detach(wlc);
4999 if (!brcms_c_radio_monitor_stop(wlc))
5004 brcms_c_timers_deinit(wlc);
5006 brcms_c_detach_module(wlc);
5012 brcms_c_detach_mfree(wlc);
5026 if (wlc_hw->
wlc->pub->hw_up)
5035 brcms_b_xtal(wlc_hw,
ON);
5053 wlc_hw->
wlc->pub->hw_up =
true;
5072 brcms_b_xtal(wlc_hw,
ON);
5088 if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
5091 brcms_b_xtal(wlc_hw,
OFF);
5120 static void brcms_c_wme_retries_write(
struct brcms_c_info *wlc)
5141 if (wlc->
pub->hw_off || brcms_deviceremoved(wlc))
5144 if (!wlc->
pub->hw_up) {
5145 brcms_b_hw_up(wlc->
hw);
5146 wlc->
pub->hw_up =
true;
5151 if (wlc->
pub->boardrev >= 0x1250
5169 if (!wlc->
pub->radio_disabled) {
5170 int status = brcms_b_up_prep(wlc->
hw);
5181 "bsscfg_disable()\n",
5187 if (wlc->
pub->radio_disabled) {
5188 brcms_c_radio_monitor_start(wlc);
5195 brcms_c_radio_monitor_stop(wlc);
5201 wlc->
pub->up =
true;
5204 ch = wlc->
pub->ieee_hw->conf.channel;
5206 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->
hw_value));
5211 brcms_b_up_finish(wlc->
hw);
5214 brcms_c_wme_retries_write(wlc);
5223 brcms_c_ht_update_ldpc(wlc, wlc->
stf->ldpc);
5245 dev_gone = brcms_deviceremoved(wlc_hw->
wlc);
5249 wlc_hw->
wlc->macintmask = 0;
5276 dev_gone = brcms_deviceremoved(wlc_hw->
wlc);
5279 wlc_hw->
sbclk =
false;
5280 wlc_hw->
clk =
false;
5284 brcms_c_flushqueues(wlc_hw->
wlc);
5289 if (bcma_read32(wlc_hw->
d11core,
5293 brcms_c_coredisable(wlc_hw);
5299 brcms_b_xtal(wlc_hw,
OFF);
5316 bool dev_gone =
false;
5324 "\n", wlc->
pub->unit, __func__);
5332 callbacks += brcms_b_bmac_down_prep(wlc->
hw);
5334 dev_gone = brcms_deviceremoved(wlc);
5350 callbacks += brcms_c_down_del_timer(wlc);
5352 wlc->
pub->up =
false;
5357 brcms_c_txflowcontrol_reset(wlc);
5363 callbacks += brcms_b_down_finish(wlc->
hw);
5381 bool shortslot_restrict =
false;
5384 bool ofdm_basic =
false;
5387 bool preamble_restrict =
false;
5401 else if ((wlc->
pub->_nbands > 1) &&
5431 preamble_restrict =
true;
5436 shortslot_restrict =
true;
5439 preamble_restrict =
true;
5445 wlc->
pub->unit, __func__, gmode);
5458 for (i = 0; i < rs.
count; i++) {
5493 wlc->
stf->txstreams);
5494 for (i = 0; i < wlc->
pub->_nbands; i++)
5515 bandunit = wlc->
band->bandunit;
5518 (&
new, &wlc->
bandstate[bandunit]->hw_rateset,
true,
5519 wlc->
stf->txstreams))
5523 if (brcms_is_mband_unlocked(wlc)) {
5528 bandstate[bandunit]->
5530 wlc->
stf->txstreams))
5545 static void brcms_c_ofdm_rateset_war(
struct brcms_c_info *wlc)
5550 if (wlc->
bsscfg->associated)
5551 r = wlc->
bsscfg->current_bss->rateset.rates[0];
5560 u16 chspec = ch20mhz_chspec(channel);
5569 if (!wlc->
pub->up && brcms_is_mband_unlocked(wlc)) {
5570 if (wlc->
band->bandunit != chspec_bandunit(chspec))
5580 brcms_c_set_home_chanspec(wlc, chspec);
5582 brcms_c_set_chanspec(wlc, chspec);
5599 brcms_b_retrylimit_upd(wlc->
hw, wlc->
SRL, wlc->
LRL);
5603 EDCF_SHORT, wlc->
SRL);
5605 EDCF_LONG, wlc->
LRL);
5607 brcms_c_wme_retries_write(wlc);
5617 if (wlc->
pub->associated)
5618 rs = &wlc->
bsscfg->current_bss->rateset;
5644 if (wlc->
bsscfg->associated)
5645 mcsset_bss = wlc->
bsscfg->current_bss;
5652 bcmerror = brcms_c_set_internal_rateset(wlc, &internal_rs);
5654 brcms_c_ofdm_rateset_war(wlc);
5671 return wlc->
band->phytype;
5685 if (wlc->
pub->up && wlc->
pub->associated) {
5687 }
else if (wlc->
pub->up) {
5689 brcms_c_switch_shortslot(wlc,
false);
5707 int (*d_fn)(
void *
handle))
5714 if (wlc->
modulecb[i].name[0] ==
'\0') {
5716 sizeof(wlc->
modulecb[i].name) - 1);
5750 pr_debug(
"\ntxpkt (MPDU) Complete\n");
5754 pr_debug(
"[15:12] %d frame attempts\n",
5757 pr_debug(
" [11:8] %d rts attempts\n",
5760 pr_debug(
" [7] %d PM mode indicated\n",
5762 pr_debug(
" [6] %d intermediate status\n",
5766 pr_debug(
" [4:2] %d Frame Suppressed Reason (%s)\n",
5772 "Previous frag failure",
5781 pr_debug(
"LastTxTime: %04x Seq: %04x PHYTxStatus: %04x RxAckRSSI: %04x RxAckSQ: %04x\n",
5787 static bool brcms_c_chipmatch_pci(
struct bcma_device *core)
5789 struct pci_dev *pcidev = core->
bus->host_pci;
5794 pr_err(
"unknown vendor id %04x\n", vendor);
5807 pr_err(
"unknown device id %04x\n", device);
5811 static bool brcms_c_chipmatch_soc(
struct bcma_device *core)
5818 pr_err(
"unknown chip id %04x\n", chipinfo->
id);
5824 switch (core->
bus->hosttype) {
5826 return brcms_c_chipmatch_pci(core);
5828 return brcms_c_chipmatch_soc(core);
5830 pr_err(
"unknown host type: %i\n", core->
bus->hosttype);
5836 void brcms_c_print_txdesc(
struct d11txh *txh)
5869 brcmu_dbg_hex_dump(txh,
sizeof(
struct d11txh) + 48,
5870 "Raw TxDesc + plcp header:\n");
5873 pr_debug(
"TxCtlHigh: %04x ", mtch);
5875 pr_debug(
"FES Time: %04x\n", tfest);
5878 pr_debug(
"PhyCtl_1: %04x ", ptcw_1);
5879 pr_debug(
"PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr);
5880 pr_debug(
"PhyCtl_1_Rts: %04x ", ptcw_1_Rts);
5881 pr_debug(
"PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts);
5882 pr_debug(
"MainRates: %04x ", mainrates);
5883 pr_debug(
"XtraFrameTypes: %04x ", xtraft);
5890 pr_debug(
"Fb FES Time: %04x ", tfestfb);
5893 pr_debug(
"RTS DUR: %04x ", rtsdfb);
5899 pr_debug(
"MModeLen: %04x ", mmodelen);
5900 pr_debug(
"MModeFbrLen: %04x\n", mmodefbrlen);
5905 pr_debug(
"MaxNumMpdu: %04x\n", mnmpdu);
5906 pr_debug(
"MaxAggbyte: %04x\n", mabyte);
5907 pr_debug(
"MaxAggbyte_fb: %04x\n", mabyte_f);
5908 pr_debug(
"MinByte: %04x\n", mmbyte);
5926 int slen = 0, nlen = 0;
5930 if (len < 2 || !buf)
5935 for (i = 0; flags != 0; i++) {
5938 if (bit == 0 && flags != 0) {
5940 snprintf(hexstr, 16,
"0x%X", flags);
5943 }
else if ((flags & bit) == 0)
5970 return (
int)(p -
buf);
5975 void brcms_c_print_rxh(
struct d11rxhdr *rxh)
5996 brcmu_dbg_hex_dump(rxh,
sizeof(
struct d11rxhdr),
"Raw RxDesc:\n");
5998 brcms_c_format_flags(macstat_flags, macstatus1, flagstr, 64);
6000 snprintf(lenbuf,
sizeof(lenbuf),
"0x%x", len);
6002 pr_debug(
"RxFrameSize: %6s (%d)%s\n", lenbuf, len,
6004 pr_debug(
"RxPHYStatus: %04x %04x %04x %04x\n",
6005 phystatus_0, phystatus_1, phystatus_2, phystatus_3);
6006 pr_debug(
"RxMACStatus: %x %s\n", macstatus1, flagstr);
6019 if (is_ofdm_rate(rate))
6028 index = phy_rate & 0xf;
6044 if (pktq_pfull(q, prec))
6046 else if (pktq_full(q)) {
6050 "\n", __func__, eprec, prec);
6057 bool discard_oldest;
6059 discard_oldest = ac_bitmap_tst(0, eprec);
6062 if (eprec == prec && !discard_oldest) {
6064 "\n", __func__, prec);
6093 struct sk_buff *pkt,
int prec)
6095 return brcms_c_prec_enq_head(wlc, q, pkt, prec,
false);
6102 struct pktq *q = &qi->
q;
6107 if (!brcms_c_prec_enq(wlc, q, sdu, prec)) {
6143 BCMMSG(wlc->
wiphy,
"wl%d: rspec 0x%x, preamble_type %d\n",
6144 wlc->
pub->unit, rspec, preamble_type);
6150 rspec = brcms_basic_rate(wlc, rspec);
6153 brcms_c_calc_frame_time(wlc, rspec, preamble_type,
6162 BCMMSG(wlc->
wiphy,
"wl%d: ratespec 0x%x, preamble_type %d\n",
6163 wlc->
pub->unit, rspec, preamble_type);
6164 return brcms_c_calc_ack_time(wlc, rspec, preamble_type);
6172 "preamble_type %d\n", wlc->
pub->unit, rspec, preamble_type);
6178 rspec = brcms_basic_rate(wlc, rspec);
6180 return brcms_c_calc_frame_time(wlc, rspec, preamble_type,
6197 u8 preamble_type,
uint next_frag_len)
6201 sifs = get_sifs(wlc->
band);
6204 dur += (
u16) brcms_c_calc_ack_time(wlc, rate, preamble_type);
6206 if (next_frag_len) {
6212 (
u16) brcms_c_calc_frame_time(wlc, rate, preamble_type,
6221 u8 preamble_type,
uint dur)
6223 uint nsyms, mac_len, Ndps, kNdps;
6224 uint rate = rspec2rate(ratespec);
6226 BCMMSG(wlc->
wiphy,
"wl%d: rspec 0x%x, preamble_type %d, dur %d\n",
6227 wlc->
pub->unit, ratespec, preamble_type, dur);
6229 if (is_mcs_rate(ratespec)) {
6231 int tot_streams = mcs_2_txstreams(mcs) + rspec_stc(ratespec);
6237 kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec),
6238 rspec_issgi(ratespec)) * 4;
6243 }
else if (is_ofdm_rate(ratespec)) {
6257 mac_len = dur *
rate;
6259 mac_len = mac_len / 8 / 2;
6268 static bool brcms_c_valid_rate(
struct brcms_c_info *wlc,
u32 rspec,
int band,
6275 hw_rateset = &wlc->
band->hw_rateset;
6276 else if (wlc->
pub->_nbands > 1)
6283 if (is_mcs_rate(rspec)) {
6287 return isset(hw_rateset->
mcs, (rspec & RSPEC_RATE_MASK));
6290 for (i = 0; i < hw_rateset->
count; i++)
6291 if (hw_rateset->
rates[i] == rspec2rate(rspec))
6296 "not in hw_rateset\n", wlc->
pub->unit, rspec);
6322 wlc->
pub->unit, __func__);
6333 "32\n", wlc->
pub->unit, __func__);
6342 "SDM mode for mcs %d\n",
6343 wlc->
pub->unit, rate);
6355 "\n", wlc->
pub->unit, __func__);
6360 }
else if (is_ofdm_rate(rate)) {
6363 wlc->
pub->unit, __func__);
6367 }
else if (is_cck_rate(rate)) {
6371 wlc->
pub->unit, __func__);
6377 wlc->
pub->unit, __func__);
6384 "request\n", wlc->
pub->unit, __func__);
6402 if (override_mcs_only)
6409 && !brcms_c_valid_rate(wlc, rspec, cur_band->
bandtype,
true))
6424 static void brcms_c_cck_plcp_set(
struct brcms_c_info *wlc,
int rate_500,
6438 usec = (length << 4) / 11;
6439 if ((length << 4) - (usec * 11) > 0)
6443 usec = (length << 3) / 11;
6444 if ((length << 3) - (usec * 11) > 0) {
6446 if ((usec * 11) - (length << 3) >= 8)
6453 "brcms_c_cck_plcp_set: unsupported rate %d\n",
6460 plcp[0] = rate_500 * 5;
6464 plcp[2] = usec & 0xff;
6465 plcp[3] = (usec >> 8) & 0xff;
6472 static void brcms_c_compute_mimo_plcp(
u32 rspec,
uint length,
u8 *plcp)
6474 u8 mcs = (
u8) (rspec & RSPEC_RATE_MASK);
6476 if (rspec_is40mhz(rspec) || (mcs == 32))
6479 plcp[3] = rspec_mimoplcp3(rspec);
6487 brcms_c_compute_ofdm_plcp(
u32 rspec,
u32 length,
u8 *plcp)
6491 int rate = rspec2rate(rspec);
6501 tmp = (length & 0xfff) << 5;
6502 plcp[2] |= (tmp >> 16) & 0xff;
6503 plcp[1] |= (tmp >> 8) & 0xff;
6504 plcp[0] |= tmp & 0xff;
6508 static void brcms_c_compute_cck_plcp(
struct brcms_c_info *wlc,
u32 rspec,
6511 int rate = rspec2rate(rspec);
6513 brcms_c_cck_plcp_set(wlc, rate, length, plcp);
6520 if (is_mcs_rate(rspec))
6521 brcms_c_compute_mimo_plcp(rspec, length, plcp);
6522 else if (is_ofdm_rate(rspec))
6523 brcms_c_compute_ofdm_plcp(rspec, length, plcp);
6525 brcms_c_compute_cck_plcp(wlc, rspec, length, plcp);
6542 u32 frame_rate,
u8 rts_preamble_type,
6543 u8 frame_preamble_type,
uint frame_len,
bool ba)
6547 sifs = get_sifs(wlc->
band);
6553 (
u16) brcms_c_calc_cts_time(wlc, rts_rate,
6561 (
u16) brcms_c_calc_frame_time(wlc, frame_rate, frame_preamble_type,
6565 (
u16) brcms_c_calc_ba_time(wlc, frame_rate,
6569 (
u16) brcms_c_calc_ack_time(wlc, frame_rate,
6570 frame_preamble_type);
6582 bw = rspec_get_bw(rspec);
6586 "not supported yet, set to 20L\n", bw);
6591 if (is_mcs_rate(rspec)) {
6595 phyctl1 = rspec_phytxbyte2(rspec);
6613 "legacy OFDM/CCK rate\n");
6618 (bw | (phycfg << 8) |
6641 int len, phylen, rts_phylen;
6642 u16 mch, phyctl, xfts, mainrates;
6646 bool use_rts =
false;
6647 bool use_cts =
false;
6648 bool use_rifs =
false;
6649 bool short_preamble[2] = {
false,
false };
6656 bool hwtkmic =
false;
6658 #define ANTCFG_NONE 0xFF
6661 uint phyctl1_stf = 0;
6668 u8 mimo_preamble_type;
6679 tx_info = IEEE80211_SKB_CB(p);
6693 "TX_BCMC!\n", wlc->
pub->unit, __func__);
6694 frameid = bcmc_fid_generate(wlc,
NULL, txh);
6715 txrate[0] = tx_info->
control.rates;
6716 txrate[1] = txrate[0] + 1;
6722 if (txrate[1]->idx < 0)
6723 txrate[1] = txrate[0];
6728 if ((txrate[k]->idx >= 0)
6729 && (txrate[
k]->
idx <
6730 hw->
wiphy->bands[tx_info->
band]->n_bitrates)) {
6733 bitrates[txrate[
k]->
idx].hw_value;
6742 rspec[
k] = mac80211_wlc_set_nrate(wlc, wlc->
band,
6753 flags & IEEE80211_TX_RC_USE_RTS_CTS ?
true :
false;
6764 if (!rspec_active(rspec[k])) {
6767 if (!is_multicast_ether_addr(h->
addr1)) {
6770 false, 0, 0, &antcfg, &fbantcfg);
6775 phyctl1_stf = wlc->
stf->ss_opmode;
6783 if (((is_mcs_rate(rspec[k]) &&
6784 is_single_stream(rspec[k] & RSPEC_RATE_MASK)) ||
6785 is_ofdm_rate(rspec[k]))
6791 if (is_mcs_rate(rspec[k])
6811 mimo_ctlchbw = mimo_txbw =
6816 if (is_mcs_rate(rspec[k])) {
6818 if ((rspec[k] & RSPEC_RATE_MASK)
6828 }
else if (is_ofdm_rate(rspec[k])) {
6840 if ((rspec[k] & RSPEC_RATE_MASK) == 32)
6849 if ((k == 0) || ((k > 0) && is_mcs_rate(rspec[k])))
6862 && (!is_mcs_rate(rspec[k]))) {
6864 "RC_MCS != is_mcs_rate(rspec)\n",
6865 wlc->
pub->unit, __func__);
6868 if (is_mcs_rate(rspec[k])) {
6869 preamble_type[
k] = mimo_preamble_type;
6876 && is_single_stream(rspec[k] &
6882 if (!is_mcs_rate(rspec[0])
6883 && (tx_info->
control.rates[0].
6902 txrate[0]->
count = 0;
6903 txrate[1]->
count = 0;
6913 brcms_c_compute_plcp(wlc, rspec[0], phylen, plcp);
6914 brcms_c_compute_plcp(wlc, rspec[1], phylen, plcp_fallback);
6919 if (is_cck_rate(rspec[1])) {
6925 mainrates = is_ofdm_rate(rspec[0]) ?
6931 !is_multicast_ether_addr(h->
addr1) && !use_rifs) {
6933 brcms_c_compute_frame_dur(wlc, rspec[0], preamble_type[0],
6936 }
else if (use_rifs) {
6939 (
u16) brcms_c_calc_frame_time(wlc, rspec[0],
6949 else if (is_multicast_ether_addr(h->
addr1) || use_rifs)
6952 durid = brcms_c_compute_frame_dur(wlc, rspec[1],
6953 preamble_type[1], next_frag_len);
6961 if (!is_multicast_ether_addr(h->
addr1))
7016 if (use_rts || use_cts) {
7017 if (use_rts && use_cts)
7020 for (k = 0; k < 2; k++) {
7026 if (!is_ofdm_rate(rts_rspec[0]) &&
7033 if (!is_ofdm_rate(rts_rspec[1]) &&
7055 brcms_c_compute_plcp(wlc, rts_rspec[0], rts_phylen, rts_plcp);
7058 brcms_c_compute_plcp(wlc, rts_rspec[1], rts_phylen,
7067 rspec[0], rts_preamble_type[0],
7068 preamble_type[0], phylen,
false);
7072 rts_rspec[1], rspec[1],
7073 rts_preamble_type[1],
7074 preamble_type[1], phylen,
false);
7093 mainrates |= (is_ofdm_rate(rts_rspec[0]) ?
7106 #ifdef SUPPORT_40MHZ
7110 brcm_c_ampdu_null_delim_cnt(wlc->
ampdu, scb, rspec, phylen);
7127 xfts = frametype(rspec[1], wlc->
mimoft);
7135 phyctl = frametype(rspec[0], wlc->
mimoft);
7150 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[0]);
7152 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[1]);
7155 if (use_rts || use_cts) {
7156 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[0]);
7158 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[1]);
7167 if (is_mcs_rate(rspec[0]) &&
7174 if (is_mcs_rate(rspec[1]) &&
7182 ac = skb_get_queue_mapping(p);
7184 uint frag_dur, dur, dur_fallback;
7189 brcms_c_calc_frame_time(wlc, rspec[0],
7190 preamble_type[0], phylen);
7195 brcms_c_calc_cts_time(wlc, rts_rspec[0],
7196 rts_preamble_type[0]);
7198 brcms_c_calc_cts_time(wlc, rts_rspec[1],
7199 rts_preamble_type[1]);
7204 }
else if (use_rifs) {
7211 brcms_c_compute_frame_dur(wlc, rspec[0],
7212 preamble_type[0], 0);
7215 brcms_c_calc_frame_time(wlc, rspec[1],
7219 brcms_c_compute_frame_dur(wlc, rspec[1],
7220 preamble_type[1], 0);
7235 if (wlc->
edcf_txop[ac] >= (dur - frag_dur)) {
7239 brcms_c_calc_frame_len(wlc,
7240 rspec[0], preamble_type[0],
7247 else if (newfragthresh >
7253 (
u16) newfragthresh)
7255 (
u16) newfragthresh;
7259 wlc->
pub->unit, fifo_names[queue],
7260 rspec2rate(rspec[0]));
7265 "exceeded phylen %d/%d dur %d/%d\n",
7266 wlc->
pub->unit, __func__,
7281 struct scb *scb = &wlc->
pri_scb;
7291 if (brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0))
7305 struct pktq *q = &qi->
q;
7314 tx_info = IEEE80211_SKB_CB(pkt[0]);
7321 for (i = 0; i <
count; i++)
7327 if (err == -
EBUSY) {
7361 wlc->
core->txpktpend[fifo] += txpktpend;
7363 txpktpend, wlc->
core->txpktpend[fifo]);
7381 bool use_rspec,
u16 mimo_ctlchbw)
7388 else if (wlc->
band->gmode && wlc->
protection->_g && !is_cck_rate(rspec))
7402 rts_rspec = brcms_basic_rate(wlc, rspec);
7412 if (rspec_is40mhz(rspec) && !is_cck_rate(rts_rspec))
7418 if (is_ofdm_rate(rts_rspec)) {
7429 wlc->
core->txpktpend[fifo] -= txpktpend;
7430 BCMMSG(wlc->
wiphy,
"pktpend dec %d to %d\n", txpktpend,
7431 wlc->
core->txpktpend[fifo]);
7440 static void brcms_c_bcn_li_upd(
struct brcms_c_info *wlc)
7457 *tsf_l_ptr = bcma_read32(core,
D11REGOFFS(tsf_timerlow));
7458 *tsf_h_ptr = bcma_read32(core,
D11REGOFFS(tsf_timerhigh));
7479 u16 rx_tsf_0_15, rx_tsf_16_31;
7481 brcms_b_read_tsf(wlc->
hw, &tsf_l, &tsf_h);
7483 rx_tsf_16_31 = (
u16)(tsf_l >> 16);
7490 if ((
u16)tsf_l < rx_tsf_0_15) {
7492 if (rx_tsf_16_31 == 0xffff)
7496 return ((
u64)tsf_h << 32) | (((
u32)rx_tsf_16_31 << 16) + rx_tsf_0_15);
7507 unsigned char *plcp;
7510 rx_status->
mactime = brcms_c_recover_tsf64(wlc, rxh);
7530 if (is_mcs_rate(rspec)) {
7533 if (rspec_is40mhz(rspec))
7536 switch (rspec2rate(rspec)) {
7587 if (is_cck_rate(rspec)) {
7590 }
else if (is_ofdm_rate(rspec)) {
7598 if (plcp3_issgi(plcp[3]))
7621 memset(&rx_status, 0,
sizeof(rx_status));
7622 prep_mac80211_status(wlc, rxh, p, &rx_status);
7627 __skb_trim(p, len_mpdu);
7630 if (wlc->
hw->suspended_fifos) {
7633 brcms_b_mute(wlc->
hw,
false);
7636 memcpy(IEEE80211_SKB_RXCB(p), &rx_status,
sizeof(rx_status));
7650 uint nsyms, len = 0, kNdps;
7653 wlc->
pub->unit, rspec2rate(ratespec), mac_len);
7655 if (is_mcs_rate(ratespec)) {
7657 int tot_streams = (mcs_2_txstreams(mcs) + 1) +
7658 rspec_stc(ratespec);
7665 kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec),
7666 rspec_issgi(ratespec)) * 4;
7668 if (rspec_stc(ratespec) == 0)
7680 nsyms += (tot_streams + 3);
7685 len = (3 * nsyms) - 3;
7702 sifs = get_sifs(wlc->
band);
7704 rs_dflt = brcms_c_rateset_get_hwrs(wlc);
7713 for (i = 0; i < rs.
count; i++) {
7719 brcms_c_compute_plcp(wlc, rate, frame_len, plcp);
7725 dur = (
u16) brcms_c_calc_frame_time(wlc, rate,
7731 (
u16) (plcp[0] + (plcp[1] << 8)));
7733 (
u16) (plcp[2] + (plcp[3] << 8)));
7755 static const u8 ether_bcast[
ETH_ALEN] = {255, 255, 255, 255, 255, 255};
7765 *len = hdr_len + body_len;
7768 memset((
char *)buf, 0, hdr_len);
7778 brcms_c_compute_plcp(wlc, bcn_rspec,
7779 (DOT11_MAC_HDR_LEN + body_len + FCS_LEN),
7794 memcpy(&h->
da, ðer_bcast, ETH_ALEN);
7813 if (bsscfg->
up && !bsscfg->
BSS)
7835 brcms_c_bss_update_probe_resp(
struct brcms_c_info *wlc,
7849 cfg, prb_resp, &len);
7856 (len + 3) & ~3, prb_resp);
7862 brcms_c_shm_ssid_upd(wlc, cfg);
7871 brcms_c_mod_prb_rsp_rate_table(wlc, (
u16) len);
7882 if (bsscfg->
up && !bsscfg->
BSS)
7883 brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
7930 brcms_b_set_addrmatch(wlc->
hw, match_reg_offset, addr);
7961 void (*dma_callback_fn))
7965 for (i = 0; i <
NFIFO; i++) {
7974 return wlc->
band->bandunit;
7986 while (!pktq_empty(&wlc->
pkt_queue->q) || brcms_txpktpendtot(wlc) > 0) {
8000 brcms_c_bcn_li_upd(wlc);
8047 "len %d\n", wlc->
pub->unit, p->
len);
8070 brcms_c_recvctl(wlc, rxh, p);
8093 skb_queue_head_init(&recv_frames);
8096 while (
dma_rx(wlc_hw->
di[fifo], &recv_frames)) {
8099 if (++n >= bound_limit)
8107 skb_queue_walk_safe(&recv_frames, p, next) {
8128 brcms_c_recv(wlc_hw->
wlc, p);
8131 return n >= bound_limit;
8143 struct wiphy *wiphy = wlc->
wiphy;
8145 if (brcms_deviceremoved(wlc)) {
8157 wlc_hw->
unit, macintstatus);
8162 if (macintstatus &
MI_TFS) {
8164 if (brcms_b_txstatus(wlc->
hw, bounded, &fatal))
8186 if (macintstatus & MI_DMAINT)
8187 if (brcms_b_recv(wlc_hw,
RX_FIFO, bounded))
8194 if (macintstatus &
MI_GP0) {
8195 wiphy_err(wiphy,
"wl%d: PSM microcode watchdog fired at %d "
8196 "(seconds). Resetting.\n", wlc_hw->
unit, wlc_hw->
now);
8198 printk_once(
"%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n",
8199 __func__, ai_get_chip_id(wlc_hw->
sih),
8200 ai_get_chiprev(wlc_hw->
sih));
8205 if (macintstatus &
MI_TO)
8209 BCMMSG(wlc->
wiphy,
"wl%d: BMAC Detected a change on the"
8210 " RF Disable Input\n", wlc_hw->
unit);
8234 chanspec = ch20mhz_chspec(ch->
hw_value);
8236 brcms_b_init(wlc->
hw, chanspec);
8239 brcms_c_bcn_li_upd(wlc);
8242 brcms_c_set_mac(wlc->
bsscfg);
8243 brcms_c_set_bssid(wlc->
bsscfg);
8246 if (wlc->
pub->associated && wlc->
bsscfg->up) {
8250 bi = wlc->
bsscfg->current_bss->beacon_period << 10;
8259 brcms_c_set_ps_ctrl(wlc);
8262 brcms_c_bandinit_ordered(wlc, chanspec);
8283 brcms_c_bsinit(wlc);
8287 brcms_c_edcf_setparams(wlc,
false);
8290 brcms_c_tx_prec_map_init(wlc);
8304 brcms_b_mute(wlc->
hw,
true);
8307 brcms_c_txflowcontrol_reset(wlc);
8331 bool piomode,
uint *perr)
8339 wlc = brcms_c_attach_malloc(unit, &err, 0);
8357 brcms_c_info_init(wlc, unit);
8360 brcms_c_ap_upd(wlc);
8366 err = brcms_b_attach(wlc, core, unit, piomode);
8382 wlc->
stf->txant = wlc->
stf->hw_txchain - 1;
8386 wlc->
stf->hw_rxchain);
8389 for (i = 0; i <
NFIFO; i++)
8390 wlc->
core->txavail[i] = wlc->
hw->txavail[i];
8395 for (j = 0; j < wlc->
pub->_nbands; j++) {
8398 if (!brcms_c_attach_stf_ant_init(wlc)) {
8424 brcms_default_rateset(wlc, &wlc->
band->defrateset);
8428 &wlc->
band->hw_rateset,
false,
8440 err = brcms_c_attach_module(wlc);
8444 if (!brcms_c_timers_init(wlc, unit)) {
8455 "\n", unit, __func__);
8461 brcms_c_bss_default_init(wlc);
8468 wlc->
pkt_queue = brcms_c_txq_alloc(wlc);
8492 brcms_c_ht_update_sgi_rx(wlc, 0);
8495 brcms_b_antsel_set(wlc->
hw, wlc->
asi->antsel_avail);
8504 unit, __func__, err);