1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
15 #include <osdep_service.h>
16 #include <drv_types.h>
20 #include <rtl8188e_hal.h>
24 void dump_chip_info(struct HAL_VERSION chip_vers)
29 cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_");
30 cnt += sprintf((buf+cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ?
31 "Normal_Chip" : "Test_Chip");
32 cnt += sprintf((buf+cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ?
34 if (chip_vers.CUTVersion == A_CUT_VERSION)
35 cnt += sprintf((buf+cnt), "A_CUT_");
36 else if (chip_vers.CUTVersion == B_CUT_VERSION)
37 cnt += sprintf((buf+cnt), "B_CUT_");
38 else if (chip_vers.CUTVersion == C_CUT_VERSION)
39 cnt += sprintf((buf+cnt), "C_CUT_");
40 else if (chip_vers.CUTVersion == D_CUT_VERSION)
41 cnt += sprintf((buf+cnt), "D_CUT_");
42 else if (chip_vers.CUTVersion == E_CUT_VERSION)
43 cnt += sprintf((buf+cnt), "E_CUT_");
45 cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_",
46 chip_vers.CUTVersion);
47 cnt += sprintf((buf+cnt), "1T1R_");
48 cnt += sprintf((buf+cnt), "RomVer(0)\n");
53 #define CHAN_PLAN_HW 0x80
55 u8 /* return the final channel plan decision */
56 hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan,
57 u8 sw_channel_plan, u8 def_channel_plan,
65 if (!rtw_is_channel_plan_valid(sw_channel_plan))
67 if (hw_channel_plan & CHAN_PLAN_HW)
72 chnlplan = sw_channel_plan;
74 chnlplan = hw_channel_plan & (~CHAN_PLAN_HW);
76 if (!rtw_is_channel_plan_valid(chnlplan))
77 chnlplan = def_channel_plan;
82 u8 MRateToHwRate(u8 rate)
87 /* CCK and OFDM non-HT rates */
88 case IEEE80211_CCK_RATE_1MB:
91 case IEEE80211_CCK_RATE_2MB:
94 case IEEE80211_CCK_RATE_5MB:
97 case IEEE80211_CCK_RATE_11MB:
100 case IEEE80211_OFDM_RATE_6MB:
103 case IEEE80211_OFDM_RATE_9MB:
106 case IEEE80211_OFDM_RATE_12MB:
109 case IEEE80211_OFDM_RATE_18MB:
112 case IEEE80211_OFDM_RATE_24MB:
115 case IEEE80211_OFDM_RATE_36MB:
118 case IEEE80211_OFDM_RATE_48MB:
121 case IEEE80211_OFDM_RATE_54MB:
130 void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg)
132 u8 i, is_brate, brate;
134 for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
135 is_brate = brates[i] & IEEE80211_BASIC_RATE_MASK;
136 brate = brates[i] & 0x7f;
140 case IEEE80211_CCK_RATE_1MB:
141 *rate_cfg |= RATE_1M;
143 case IEEE80211_CCK_RATE_2MB:
144 *rate_cfg |= RATE_2M;
146 case IEEE80211_CCK_RATE_5MB:
147 *rate_cfg |= RATE_5_5M;
149 case IEEE80211_CCK_RATE_11MB:
150 *rate_cfg |= RATE_11M;
152 case IEEE80211_OFDM_RATE_6MB:
153 *rate_cfg |= RATE_6M;
155 case IEEE80211_OFDM_RATE_9MB:
156 *rate_cfg |= RATE_9M;
158 case IEEE80211_OFDM_RATE_12MB:
159 *rate_cfg |= RATE_12M;
161 case IEEE80211_OFDM_RATE_18MB:
162 *rate_cfg |= RATE_18M;
164 case IEEE80211_OFDM_RATE_24MB:
165 *rate_cfg |= RATE_24M;
167 case IEEE80211_OFDM_RATE_36MB:
168 *rate_cfg |= RATE_36M;
170 case IEEE80211_OFDM_RATE_48MB:
171 *rate_cfg |= RATE_48M;
173 case IEEE80211_OFDM_RATE_54MB:
174 *rate_cfg |= RATE_54M;
181 static void one_out_pipe(struct adapter *adapter)
183 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
185 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
186 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
187 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */
188 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
190 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
191 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
192 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
193 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
196 static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
198 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
200 if (wifi_cfg) { /* WMM */
201 /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
202 /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */
205 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */
206 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
207 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
208 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
210 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
211 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
212 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
213 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
215 } else {/* typical setting */
216 /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
217 /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */
220 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
221 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
222 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
223 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
225 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
226 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
227 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
228 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
232 static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
234 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
236 if (wifi_cfg) {/* for WMM */
237 /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
238 /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */
241 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
242 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
243 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
244 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
246 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
247 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
248 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
249 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
251 } else {/* typical setting */
252 /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
253 /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */
256 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
257 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
258 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
259 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */
261 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
262 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
263 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
264 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
268 bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
270 struct registry_priv *pregistrypriv = &adapter->registrypriv;
271 bool wifi_cfg = (pregistrypriv->wifi_spec) ? true : false;
274 switch (numoutpipe) {
276 two_out_pipe(adapter, wifi_cfg);
279 three_out_pipe(adapter, wifi_cfg);
282 one_out_pipe(adapter);
291 void hal_init_macaddr(struct adapter *adapter)
293 rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR,
294 adapter->eeprompriv.mac_addr);