1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <osdep_service.h>
21#include <drv_types.h>
22
23#include <hal_intf.h>
24#include <hal_com.h>
25#include <rtl8188e_hal.h>
26
27#define _HAL_INIT_C_
28
29void dump_chip_info(struct HAL_VERSION chip_vers)
30{
31 uint cnt = 0;
32 char buf[128];
33
34 if (IS_81XXC(chip_vers)) {
35 cnt += sprintf((buf+cnt), "Chip Version Info: %s_",
36 IS_92C_SERIAL(chip_vers) ?
37 "CHIP_8192C" : "CHIP_8188C");
38 } else if (IS_92D(chip_vers)) {
39 cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8192D_");
40 } else if (IS_8723_SERIES(chip_vers)) {
41 cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8723A_");
42 } else if (IS_8188E(chip_vers)) {
43 cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_");
44 }
45
46 cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
47 "Normal_Chip" : "Test_Chip");
48 cnt += sprintf((buf+cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
49 "TSMC" : "UMC");
50 if (IS_A_CUT(chip_vers))
51 cnt += sprintf((buf+cnt), "A_CUT_");
52 else if (IS_B_CUT(chip_vers))
53 cnt += sprintf((buf+cnt), "B_CUT_");
54 else if (IS_C_CUT(chip_vers))
55 cnt += sprintf((buf+cnt), "C_CUT_");
56 else if (IS_D_CUT(chip_vers))
57 cnt += sprintf((buf+cnt), "D_CUT_");
58 else if (IS_E_CUT(chip_vers))
59 cnt += sprintf((buf+cnt), "E_CUT_");
60 else
61 cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_",
62 chip_vers.CUTVersion);
63
64 if (IS_1T1R(chip_vers))
65 cnt += sprintf((buf+cnt), "1T1R_");
66 else if (IS_1T2R(chip_vers))
67 cnt += sprintf((buf+cnt), "1T2R_");
68 else if (IS_2T2R(chip_vers))
69 cnt += sprintf((buf+cnt), "2T2R_");
70 else
71 cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_",
72 chip_vers.RFType);
73
74 cnt += sprintf((buf+cnt), "RomVer(%d)\n", chip_vers.ROMVer);
75
76 pr_info("%s", buf);
77}
78
79#define CHAN_PLAN_HW 0x80
80
81u8
82hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan,
83 u8 sw_channel_plan, u8 def_channel_plan,
84 bool load_fail)
85{
86 u8 sw_cfg;
87 u8 chnlplan;
88
89 sw_cfg = true;
90 if (!load_fail) {
91 if (!rtw_is_channel_plan_valid(sw_channel_plan))
92 sw_cfg = false;
93 if (hw_channel_plan & CHAN_PLAN_HW)
94 sw_cfg = false;
95 }
96
97 if (sw_cfg)
98 chnlplan = sw_channel_plan;
99 else
100 chnlplan = hw_channel_plan & (~CHAN_PLAN_HW);
101
102 if (!rtw_is_channel_plan_valid(chnlplan))
103 chnlplan = def_channel_plan;
104
105 return chnlplan;
106}
107
108u8 MRateToHwRate(u8 rate)
109{
110 u8 ret = DESC_RATE1M;
111
112 switch (rate) {
113
114 case IEEE80211_CCK_RATE_1MB:
115 ret = DESC_RATE1M;
116 break;
117 case IEEE80211_CCK_RATE_2MB:
118 ret = DESC_RATE2M;
119 break;
120 case IEEE80211_CCK_RATE_5MB:
121 ret = DESC_RATE5_5M;
122 break;
123 case IEEE80211_CCK_RATE_11MB:
124 ret = DESC_RATE11M;
125 break;
126 case IEEE80211_OFDM_RATE_6MB:
127 ret = DESC_RATE6M;
128 break;
129 case IEEE80211_OFDM_RATE_9MB:
130 ret = DESC_RATE9M;
131 break;
132 case IEEE80211_OFDM_RATE_12MB:
133 ret = DESC_RATE12M;
134 break;
135 case IEEE80211_OFDM_RATE_18MB:
136 ret = DESC_RATE18M;
137 break;
138 case IEEE80211_OFDM_RATE_24MB:
139 ret = DESC_RATE24M;
140 break;
141 case IEEE80211_OFDM_RATE_36MB:
142 ret = DESC_RATE36M;
143 break;
144 case IEEE80211_OFDM_RATE_48MB:
145 ret = DESC_RATE48M;
146 break;
147 case IEEE80211_OFDM_RATE_54MB:
148 ret = DESC_RATE54M;
149 break;
150 default:
151 break;
152 }
153 return ret;
154}
155
156void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg)
157{
158 u8 i, is_brate, brate;
159
160 for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
161 is_brate = brates[i] & IEEE80211_BASIC_RATE_MASK;
162 brate = brates[i] & 0x7f;
163
164 if (is_brate) {
165 switch (brate) {
166 case IEEE80211_CCK_RATE_1MB:
167 *rate_cfg |= RATE_1M;
168 break;
169 case IEEE80211_CCK_RATE_2MB:
170 *rate_cfg |= RATE_2M;
171 break;
172 case IEEE80211_CCK_RATE_5MB:
173 *rate_cfg |= RATE_5_5M;
174 break;
175 case IEEE80211_CCK_RATE_11MB:
176 *rate_cfg |= RATE_11M;
177 break;
178 case IEEE80211_OFDM_RATE_6MB:
179 *rate_cfg |= RATE_6M;
180 break;
181 case IEEE80211_OFDM_RATE_9MB:
182 *rate_cfg |= RATE_9M;
183 break;
184 case IEEE80211_OFDM_RATE_12MB:
185 *rate_cfg |= RATE_12M;
186 break;
187 case IEEE80211_OFDM_RATE_18MB:
188 *rate_cfg |= RATE_18M;
189 break;
190 case IEEE80211_OFDM_RATE_24MB:
191 *rate_cfg |= RATE_24M;
192 break;
193 case IEEE80211_OFDM_RATE_36MB:
194 *rate_cfg |= RATE_36M;
195 break;
196 case IEEE80211_OFDM_RATE_48MB:
197 *rate_cfg |= RATE_48M;
198 break;
199 case IEEE80211_OFDM_RATE_54MB:
200 *rate_cfg |= RATE_54M;
201 break;
202 }
203 }
204 }
205}
206
207static void one_out_pipe(struct adapter *adapter)
208{
209 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
210
211 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];
212 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];
213 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];
214 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];
215
216 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];
217 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];
218 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];
219 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];
220}
221
222static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
223{
224 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
225
226 if (wifi_cfg) {
227
228
229
230
231 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];
232 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];
233 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];
234 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];
235
236 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];
237 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];
238 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];
239 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];
240
241 } else {
242
243
244
245
246 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];
247 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];
248 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];
249 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];
250
251 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];
252 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];
253 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];
254 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];
255 }
256}
257
258static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
259{
260 struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
261
262 if (wifi_cfg) {
263
264
265
266
267 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];
268 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];
269 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];
270 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];
271
272 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];
273 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];
274 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];
275 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];
276
277 } else {
278
279
280
281
282 pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];
283 pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];
284 pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];
285 pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];
286
287 pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];
288 pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];
289 pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];
290 pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];
291 }
292}
293
294bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
295{
296 struct registry_priv *pregistrypriv = &adapter->registrypriv;
297 bool wifi_cfg = (pregistrypriv->wifi_spec) ? true : false;
298 bool result = true;
299
300 switch (numoutpipe) {
301 case 2:
302 two_out_pipe(adapter, wifi_cfg);
303 break;
304 case 3:
305 three_out_pipe(adapter, wifi_cfg);
306 break;
307 case 1:
308 one_out_pipe(adapter);
309 break;
310 default:
311 result = false;
312 break;
313 }
314 return result;
315}
316
317void hal_init_macaddr(struct adapter *adapter)
318{
319 rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR,
320 adapter->eeprompriv.mac_addr);
321}
322