1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
7 #include <osdep_service.h>
12 #include <rtl8188e_hal.h>
16 void dump_chip_info(struct HAL_VERSION chip_vers)
21 cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_");
22 cnt += sprintf((buf+cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ?
23 "Normal_Chip" : "Test_Chip");
24 cnt += sprintf((buf+cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ?
26 if (chip_vers.CUTVersion == A_CUT_VERSION)
27 cnt += sprintf((buf+cnt), "A_CUT_");
28 else if (chip_vers.CUTVersion == B_CUT_VERSION)
29 cnt += sprintf((buf+cnt), "B_CUT_");
30 else if (chip_vers.CUTVersion == C_CUT_VERSION)
31 cnt += sprintf((buf+cnt), "C_CUT_");
32 else if (chip_vers.CUTVersion == D_CUT_VERSION)
33 cnt += sprintf((buf+cnt), "D_CUT_");
34 else if (chip_vers.CUTVersion == E_CUT_VERSION)
35 cnt += sprintf((buf+cnt), "E_CUT_");
37 cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_",
38 chip_vers.CUTVersion);
39 cnt += sprintf((buf+cnt), "1T1R_");
40 cnt += sprintf((buf+cnt), "RomVer(0)\n");
45 #define CHAN_PLAN_HW 0x80
47 /* return the final channel plan decision */
48 u8 hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan,
49 u8 sw_channel_plan, u8 def_channel_plan,
57 if (!rtw_is_channel_plan_valid(sw_channel_plan))
59 if (hw_channel_plan & CHAN_PLAN_HW)
64 chnlplan = sw_channel_plan;
66 chnlplan = hw_channel_plan & (~CHAN_PLAN_HW);
68 if (!rtw_is_channel_plan_valid(chnlplan))
69 chnlplan = def_channel_plan;
74 u8 MRateToHwRate(u8 rate)
79 /* CCK and OFDM non-HT rates */
80 case IEEE80211_CCK_RATE_1MB:
83 case IEEE80211_CCK_RATE_2MB:
86 case IEEE80211_CCK_RATE_5MB:
89 case IEEE80211_CCK_RATE_11MB:
92 case IEEE80211_OFDM_RATE_6MB:
95 case IEEE80211_OFDM_RATE_9MB:
98 case IEEE80211_OFDM_RATE_12MB:
101 case IEEE80211_OFDM_RATE_18MB:
104 case IEEE80211_OFDM_RATE_24MB:
107 case IEEE80211_OFDM_RATE_36MB:
110 case IEEE80211_OFDM_RATE_48MB:
113 case IEEE80211_OFDM_RATE_54MB:
122 void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg)
124 u8 i, is_brate, brate;
126 for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
127 is_brate = brates[i] & IEEE80211_BASIC_RATE_MASK;
128 brate = brates[i] & 0x7f;
132 case IEEE80211_CCK_RATE_1MB:
133 *rate_cfg |= RATE_1M;
135 case IEEE80211_CCK_RATE_2MB:
136 *rate_cfg |= RATE_2M;
138 case IEEE80211_CCK_RATE_5MB:
139 *rate_cfg |= RATE_5_5M;
141 case IEEE80211_CCK_RATE_11MB:
142 *rate_cfg |= RATE_11M;
144 case IEEE80211_OFDM_RATE_6MB:
145 *rate_cfg |= RATE_6M;
147 case IEEE80211_OFDM_RATE_9MB:
148 *rate_cfg |= RATE_9M;
150 case IEEE80211_OFDM_RATE_12MB:
151 *rate_cfg |= RATE_12M;
153 case IEEE80211_OFDM_RATE_18MB:
154 *rate_cfg |= RATE_18M;
156 case IEEE80211_OFDM_RATE_24MB:
157 *rate_cfg |= RATE_24M;
159 case IEEE80211_OFDM_RATE_36MB:
160 *rate_cfg |= RATE_36M;
162 case IEEE80211_OFDM_RATE_48MB:
163 *rate_cfg |= RATE_48M;
165 case IEEE80211_OFDM_RATE_54MB:
166 *rate_cfg |= RATE_54M;
173 static void one_out_pipe(struct adapter *adapter)
175 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
177 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
178 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
179 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */
180 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
182 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
183 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
184 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
185 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
188 static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
190 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
195 * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA
196 * 0, 1, 0, 1, 0, 0, 0, 0, 0
199 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */
200 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
201 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
202 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
204 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
205 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
206 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
207 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
211 * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA
212 * 1, 1, 0, 0, 0, 0, 0, 0, 0
215 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
216 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
217 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
218 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
220 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
221 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
222 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
223 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
227 static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
229 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
234 * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA
235 * 1, 2, 1, 0, 0, 0, 0, 0, 0
238 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
239 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
240 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
241 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
243 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
244 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
245 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
246 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
250 * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA
251 * 2, 2, 1, 0, 0, 0, 0, 0, 0
254 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
255 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
256 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
257 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */
259 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
260 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
261 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
262 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
266 bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
268 struct registry_priv *pregistrypriv = &adapter->registrypriv;
269 bool wifi_cfg = (pregistrypriv->wifi_spec) ? true : false;
272 switch (numoutpipe) {
274 one_out_pipe(adapter);
277 two_out_pipe(adapter, wifi_cfg);
280 three_out_pipe(adapter, wifi_cfg);
288 void hal_init_macaddr(struct adapter *adapter)
290 rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR,
291 adapter->eeprompriv.mac_addr);