diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/rtl8192ce')
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/def.h | 144 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/dm.c | 1361 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/dm.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/fw.c | 59 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 153 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/led.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 2052 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/phy.h | 7 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/reg.h | 73 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 7 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/sw.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 170 | ||||
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192ce/trx.h | 464 |
14 files changed, 661 insertions, 3840 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/Makefile b/drivers/net/wireless/rtlwifi/rtl8192ce/Makefile index 0f0be7c763b8..5c5fdde637cb 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/Makefile +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/Makefile | |||
@@ -10,3 +10,5 @@ rtl8192ce-objs := \ | |||
10 | trx.o | 10 | trx.o |
11 | 11 | ||
12 | obj-$(CONFIG_RTL8192CE) += rtl8192ce.o | 12 | obj-$(CONFIG_RTL8192CE) += rtl8192ce.o |
13 | |||
14 | ccflags-y += -D__CHECK_ENDIAN__ | ||
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h index 83cd64895292..2f577c8828fc 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h | |||
@@ -121,11 +121,37 @@ | |||
121 | #define CHIP_92C 0x01 | 121 | #define CHIP_92C 0x01 |
122 | #define CHIP_88C 0x00 | 122 | #define CHIP_88C 0x00 |
123 | 123 | ||
124 | /* Add vendor information into chip version definition. | ||
125 | * Add UMC B-Cut and RTL8723 chip info definition. | ||
126 | * | ||
127 | * BIT 7 Reserved | ||
128 | * BIT 6 UMC BCut | ||
129 | * BIT 5 Manufacturer(TSMC/UMC) | ||
130 | * BIT 4 TEST/NORMAL | ||
131 | * BIT 3 8723 Version | ||
132 | * BIT 2 8723? | ||
133 | * BIT 1 1T2R? | ||
134 | * BIT 0 88C/92C | ||
135 | */ | ||
136 | |||
124 | enum version_8192c { | 137 | enum version_8192c { |
125 | VERSION_A_CHIP_92C = 0x01, | 138 | VERSION_A_CHIP_92C = 0x01, |
126 | VERSION_A_CHIP_88C = 0x00, | 139 | VERSION_A_CHIP_88C = 0x00, |
127 | VERSION_B_CHIP_92C = 0x11, | 140 | VERSION_B_CHIP_92C = 0x11, |
128 | VERSION_B_CHIP_88C = 0x10, | 141 | VERSION_B_CHIP_88C = 0x10, |
142 | VERSION_TEST_CHIP_88C = 0x00, | ||
143 | VERSION_TEST_CHIP_92C = 0x01, | ||
144 | VERSION_NORMAL_TSMC_CHIP_88C = 0x10, | ||
145 | VERSION_NORMAL_TSMC_CHIP_92C = 0x11, | ||
146 | VERSION_NORMAL_TSMC_CHIP_92C_1T2R = 0x13, | ||
147 | VERSION_NORMAL_UMC_CHIP_88C_A_CUT = 0x30, | ||
148 | VERSION_NORMAL_UMC_CHIP_92C_A_CUT = 0x31, | ||
149 | VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT = 0x33, | ||
150 | VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT = 0x34, | ||
151 | VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT = 0x3c, | ||
152 | VERSION_NORMAL_UMC_CHIP_88C_B_CUT = 0x70, | ||
153 | VERSION_NORMAL_UMC_CHIP_92C_B_CUT = 0x71, | ||
154 | VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT = 0x73, | ||
129 | VERSION_UNKNOWN = 0x88, | 155 | VERSION_UNKNOWN = 0x88, |
130 | }; | 156 | }; |
131 | 157 | ||
@@ -254,4 +280,122 @@ struct h2c_cmd_8192c { | |||
254 | u8 *p_cmdbuffer; | 280 | u8 *p_cmdbuffer; |
255 | }; | 281 | }; |
256 | 282 | ||
283 | static inline u8 _rtl92c_get_chnl_group(u8 chnl) | ||
284 | { | ||
285 | u8 group = 0; | ||
286 | |||
287 | if (chnl < 3) | ||
288 | group = 0; | ||
289 | else if (chnl < 9) | ||
290 | group = 1; | ||
291 | else | ||
292 | group = 2; | ||
293 | |||
294 | return group; | ||
295 | } | ||
296 | |||
297 | /* NOTE: reference to rtl8192c_rates struct */ | ||
298 | static inline int _rtl92c_rate_mapping(struct ieee80211_hw *hw, bool isHT, | ||
299 | u8 desc_rate, bool first_ampdu) | ||
300 | { | ||
301 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
302 | int rate_idx = 0; | ||
303 | |||
304 | if (first_ampdu) { | ||
305 | if (false == isHT) { | ||
306 | switch (desc_rate) { | ||
307 | case DESC92C_RATE1M: | ||
308 | rate_idx = 0; | ||
309 | break; | ||
310 | case DESC92C_RATE2M: | ||
311 | rate_idx = 1; | ||
312 | break; | ||
313 | case DESC92C_RATE5_5M: | ||
314 | rate_idx = 2; | ||
315 | break; | ||
316 | case DESC92C_RATE11M: | ||
317 | rate_idx = 3; | ||
318 | break; | ||
319 | case DESC92C_RATE6M: | ||
320 | rate_idx = 4; | ||
321 | break; | ||
322 | case DESC92C_RATE9M: | ||
323 | rate_idx = 5; | ||
324 | break; | ||
325 | case DESC92C_RATE12M: | ||
326 | rate_idx = 6; | ||
327 | break; | ||
328 | case DESC92C_RATE18M: | ||
329 | rate_idx = 7; | ||
330 | break; | ||
331 | case DESC92C_RATE24M: | ||
332 | rate_idx = 8; | ||
333 | break; | ||
334 | case DESC92C_RATE36M: | ||
335 | rate_idx = 9; | ||
336 | break; | ||
337 | case DESC92C_RATE48M: | ||
338 | rate_idx = 10; | ||
339 | break; | ||
340 | case DESC92C_RATE54M: | ||
341 | rate_idx = 11; | ||
342 | break; | ||
343 | default: | ||
344 | RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, | ||
345 | ("Rate %d is not support, set to " | ||
346 | "1M rate.\n", desc_rate)); | ||
347 | rate_idx = 0; | ||
348 | break; | ||
349 | } | ||
350 | } else { | ||
351 | rate_idx = 11; | ||
352 | } | ||
353 | return rate_idx; | ||
354 | } | ||
355 | switch (desc_rate) { | ||
356 | case DESC92C_RATE1M: | ||
357 | rate_idx = 0; | ||
358 | break; | ||
359 | case DESC92C_RATE2M: | ||
360 | rate_idx = 1; | ||
361 | break; | ||
362 | case DESC92C_RATE5_5M: | ||
363 | rate_idx = 2; | ||
364 | break; | ||
365 | case DESC92C_RATE11M: | ||
366 | rate_idx = 3; | ||
367 | break; | ||
368 | case DESC92C_RATE6M: | ||
369 | rate_idx = 4; | ||
370 | break; | ||
371 | case DESC92C_RATE9M: | ||
372 | rate_idx = 5; | ||
373 | break; | ||
374 | case DESC92C_RATE12M: | ||
375 | rate_idx = 6; | ||
376 | break; | ||
377 | case DESC92C_RATE18M: | ||
378 | rate_idx = 7; | ||
379 | break; | ||
380 | case DESC92C_RATE24M: | ||
381 | rate_idx = 8; | ||
382 | break; | ||
383 | case DESC92C_RATE36M: | ||
384 | rate_idx = 9; | ||
385 | break; | ||
386 | case DESC92C_RATE48M: | ||
387 | rate_idx = 10; | ||
388 | break; | ||
389 | case DESC92C_RATE54M: | ||
390 | rate_idx = 11; | ||
391 | break; | ||
392 | /* TODO: How to mapping MCS rate? */ | ||
393 | /* NOTE: referenc to __ieee80211_rx */ | ||
394 | default: | ||
395 | rate_idx = 11; | ||
396 | break; | ||
397 | } | ||
398 | return rate_idx; | ||
399 | } | ||
400 | |||
257 | #endif | 401 | #endif |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c index 62e7c64e087b..888df5e2d2fc 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c | |||
@@ -35,485 +35,16 @@ | |||
35 | #include "dm.h" | 35 | #include "dm.h" |
36 | #include "fw.h" | 36 | #include "fw.h" |
37 | 37 | ||
38 | struct dig_t dm_digtable; | 38 | #include "../rtl8192c/dm_common.c" |
39 | static struct ps_t dm_pstable; | ||
40 | 39 | ||
41 | static const u32 ofdmswing_table[OFDM_TABLE_SIZE] = { | 40 | void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw) |
42 | 0x7f8001fe, | ||
43 | 0x788001e2, | ||
44 | 0x71c001c7, | ||
45 | 0x6b8001ae, | ||
46 | 0x65400195, | ||
47 | 0x5fc0017f, | ||
48 | 0x5a400169, | ||
49 | 0x55400155, | ||
50 | 0x50800142, | ||
51 | 0x4c000130, | ||
52 | 0x47c0011f, | ||
53 | 0x43c0010f, | ||
54 | 0x40000100, | ||
55 | 0x3c8000f2, | ||
56 | 0x390000e4, | ||
57 | 0x35c000d7, | ||
58 | 0x32c000cb, | ||
59 | 0x300000c0, | ||
60 | 0x2d4000b5, | ||
61 | 0x2ac000ab, | ||
62 | 0x288000a2, | ||
63 | 0x26000098, | ||
64 | 0x24000090, | ||
65 | 0x22000088, | ||
66 | 0x20000080, | ||
67 | 0x1e400079, | ||
68 | 0x1c800072, | ||
69 | 0x1b00006c, | ||
70 | 0x19800066, | ||
71 | 0x18000060, | ||
72 | 0x16c0005b, | ||
73 | 0x15800056, | ||
74 | 0x14400051, | ||
75 | 0x1300004c, | ||
76 | 0x12000048, | ||
77 | 0x11000044, | ||
78 | 0x10000040, | ||
79 | }; | ||
80 | |||
81 | static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE][8] = { | ||
82 | {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, | ||
83 | {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, | ||
84 | {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, | ||
85 | {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, | ||
86 | {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, | ||
87 | {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, | ||
88 | {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, | ||
89 | {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, | ||
90 | {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, | ||
91 | {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, | ||
92 | {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, | ||
93 | {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, | ||
94 | {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, | ||
95 | {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, | ||
96 | {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, | ||
97 | {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, | ||
98 | {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, | ||
99 | {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, | ||
100 | {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, | ||
101 | {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, | ||
102 | {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, | ||
103 | {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, | ||
104 | {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, | ||
105 | {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, | ||
106 | {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, | ||
107 | {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, | ||
108 | {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, | ||
109 | {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, | ||
110 | {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, | ||
111 | {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, | ||
112 | {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, | ||
113 | {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, | ||
114 | {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} | ||
115 | }; | ||
116 | |||
117 | static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = { | ||
118 | {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, | ||
119 | {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, | ||
120 | {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, | ||
121 | {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, | ||
122 | {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, | ||
123 | {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, | ||
124 | {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, | ||
125 | {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, | ||
126 | {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, | ||
127 | {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, | ||
128 | {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, | ||
129 | {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, | ||
130 | {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, | ||
131 | {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, | ||
132 | {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, | ||
133 | {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, | ||
134 | {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, | ||
135 | {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, | ||
136 | {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, | ||
137 | {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, | ||
138 | {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, | ||
139 | {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, | ||
140 | {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, | ||
141 | {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, | ||
142 | {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, | ||
143 | {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, | ||
144 | {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, | ||
145 | {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, | ||
146 | {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||
147 | {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||
148 | {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||
149 | {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||
150 | {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} | ||
151 | }; | ||
152 | |||
153 | static void rtl92c_dm_diginit(struct ieee80211_hw *hw) | ||
154 | { | ||
155 | dm_digtable.dig_enable_flag = true; | ||
156 | dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; | ||
157 | dm_digtable.cur_igvalue = 0x20; | ||
158 | dm_digtable.pre_igvalue = 0x0; | ||
159 | dm_digtable.cursta_connectctate = DIG_STA_DISCONNECT; | ||
160 | dm_digtable.presta_connectstate = DIG_STA_DISCONNECT; | ||
161 | dm_digtable.curmultista_connectstate = DIG_MULTISTA_DISCONNECT; | ||
162 | dm_digtable.rssi_lowthresh = DM_DIG_THRESH_LOW; | ||
163 | dm_digtable.rssi_highthresh = DM_DIG_THRESH_HIGH; | ||
164 | dm_digtable.fa_lowthresh = DM_FALSEALARM_THRESH_LOW; | ||
165 | dm_digtable.fa_highthresh = DM_FALSEALARM_THRESH_HIGH; | ||
166 | dm_digtable.rx_gain_range_max = DM_DIG_MAX; | ||
167 | dm_digtable.rx_gain_range_min = DM_DIG_MIN; | ||
168 | dm_digtable.backoff_val = DM_DIG_BACKOFF_DEFAULT; | ||
169 | dm_digtable.backoff_val_range_max = DM_DIG_BACKOFF_MAX; | ||
170 | dm_digtable.backoff_val_range_min = DM_DIG_BACKOFF_MIN; | ||
171 | dm_digtable.pre_cck_pd_state = CCK_PD_STAGE_MAX; | ||
172 | dm_digtable.cur_cck_pd_state = CCK_PD_STAGE_MAX; | ||
173 | } | ||
174 | |||
175 | static u8 rtl92c_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw) | ||
176 | { | ||
177 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
178 | long rssi_val_min = 0; | ||
179 | |||
180 | if ((dm_digtable.curmultista_connectstate == DIG_MULTISTA_CONNECT) && | ||
181 | (dm_digtable.cursta_connectctate == DIG_STA_CONNECT)) { | ||
182 | if (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb != 0) | ||
183 | rssi_val_min = | ||
184 | (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb > | ||
185 | rtlpriv->dm.undecorated_smoothed_pwdb) ? | ||
186 | rtlpriv->dm.undecorated_smoothed_pwdb : | ||
187 | rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; | ||
188 | else | ||
189 | rssi_val_min = rtlpriv->dm.undecorated_smoothed_pwdb; | ||
190 | } else if (dm_digtable.cursta_connectctate == DIG_STA_CONNECT || | ||
191 | dm_digtable.cursta_connectctate == DIG_STA_BEFORE_CONNECT) { | ||
192 | rssi_val_min = rtlpriv->dm.undecorated_smoothed_pwdb; | ||
193 | } else if (dm_digtable.curmultista_connectstate == | ||
194 | DIG_MULTISTA_CONNECT) { | ||
195 | rssi_val_min = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; | ||
196 | } | ||
197 | |||
198 | return (u8) rssi_val_min; | ||
199 | } | ||
200 | |||
201 | static void rtl92c_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw) | ||
202 | { | ||
203 | u32 ret_value; | ||
204 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
205 | struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); | ||
206 | |||
207 | ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER1, MASKDWORD); | ||
208 | falsealm_cnt->cnt_parity_fail = ((ret_value & 0xffff0000) >> 16); | ||
209 | |||
210 | ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER2, MASKDWORD); | ||
211 | falsealm_cnt->cnt_rate_illegal = (ret_value & 0xffff); | ||
212 | falsealm_cnt->cnt_crc8_fail = ((ret_value & 0xffff0000) >> 16); | ||
213 | |||
214 | ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER3, MASKDWORD); | ||
215 | falsealm_cnt->cnt_mcs_fail = (ret_value & 0xffff); | ||
216 | falsealm_cnt->cnt_ofdm_fail = falsealm_cnt->cnt_parity_fail + | ||
217 | falsealm_cnt->cnt_rate_illegal + | ||
218 | falsealm_cnt->cnt_crc8_fail + falsealm_cnt->cnt_mcs_fail; | ||
219 | |||
220 | rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, BIT(14), 1); | ||
221 | ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERLOWER, MASKBYTE0); | ||
222 | falsealm_cnt->cnt_cck_fail = ret_value; | ||
223 | |||
224 | ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERUPPER, MASKBYTE3); | ||
225 | falsealm_cnt->cnt_cck_fail += (ret_value & 0xff) << 8; | ||
226 | falsealm_cnt->cnt_all = (falsealm_cnt->cnt_parity_fail + | ||
227 | falsealm_cnt->cnt_rate_illegal + | ||
228 | falsealm_cnt->cnt_crc8_fail + | ||
229 | falsealm_cnt->cnt_mcs_fail + | ||
230 | falsealm_cnt->cnt_cck_fail); | ||
231 | |||
232 | rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 1); | ||
233 | rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 0); | ||
234 | rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 0); | ||
235 | rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2); | ||
236 | |||
237 | RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||
238 | ("cnt_parity_fail = %d, cnt_rate_illegal = %d, " | ||
239 | "cnt_crc8_fail = %d, cnt_mcs_fail = %d\n", | ||
240 | falsealm_cnt->cnt_parity_fail, | ||
241 | falsealm_cnt->cnt_rate_illegal, | ||
242 | falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail)); | ||
243 | |||
244 | RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||
245 | ("cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n", | ||
246 | falsealm_cnt->cnt_ofdm_fail, | ||
247 | falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all)); | ||
248 | } | ||
249 | |||
250 | static void rtl92c_dm_ctrl_initgain_by_fa(struct ieee80211_hw *hw) | ||
251 | { | ||
252 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
253 | u8 value_igi = dm_digtable.cur_igvalue; | ||
254 | |||
255 | if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH0) | ||
256 | value_igi--; | ||
257 | else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH1) | ||
258 | value_igi += 0; | ||
259 | else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH2) | ||
260 | value_igi++; | ||
261 | else if (rtlpriv->falsealm_cnt.cnt_all >= DM_DIG_FA_TH2) | ||
262 | value_igi += 2; | ||
263 | if (value_igi > DM_DIG_FA_UPPER) | ||
264 | value_igi = DM_DIG_FA_UPPER; | ||
265 | else if (value_igi < DM_DIG_FA_LOWER) | ||
266 | value_igi = DM_DIG_FA_LOWER; | ||
267 | if (rtlpriv->falsealm_cnt.cnt_all > 10000) | ||
268 | value_igi = 0x32; | ||
269 | |||
270 | dm_digtable.cur_igvalue = value_igi; | ||
271 | rtl92c_dm_write_dig(hw); | ||
272 | } | ||
273 | |||
274 | static void rtl92c_dm_ctrl_initgain_by_rssi(struct ieee80211_hw *hw) | ||
275 | { | ||
276 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
277 | |||
278 | if (rtlpriv->falsealm_cnt.cnt_all > dm_digtable.fa_highthresh) { | ||
279 | if ((dm_digtable.backoff_val - 2) < | ||
280 | dm_digtable.backoff_val_range_min) | ||
281 | dm_digtable.backoff_val = | ||
282 | dm_digtable.backoff_val_range_min; | ||
283 | else | ||
284 | dm_digtable.backoff_val -= 2; | ||
285 | } else if (rtlpriv->falsealm_cnt.cnt_all < dm_digtable.fa_lowthresh) { | ||
286 | if ((dm_digtable.backoff_val + 2) > | ||
287 | dm_digtable.backoff_val_range_max) | ||
288 | dm_digtable.backoff_val = | ||
289 | dm_digtable.backoff_val_range_max; | ||
290 | else | ||
291 | dm_digtable.backoff_val += 2; | ||
292 | } | ||
293 | |||
294 | if ((dm_digtable.rssi_val_min + 10 - dm_digtable.backoff_val) > | ||
295 | dm_digtable.rx_gain_range_max) | ||
296 | dm_digtable.cur_igvalue = dm_digtable.rx_gain_range_max; | ||
297 | else if ((dm_digtable.rssi_val_min + 10 - | ||
298 | dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) | ||
299 | dm_digtable.cur_igvalue = dm_digtable.rx_gain_range_min; | ||
300 | else | ||
301 | dm_digtable.cur_igvalue = dm_digtable.rssi_val_min + 10 - | ||
302 | dm_digtable.backoff_val; | ||
303 | |||
304 | RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||
305 | ("rssi_val_min = %x backoff_val %x\n", | ||
306 | dm_digtable.rssi_val_min, dm_digtable.backoff_val)); | ||
307 | |||
308 | rtl92c_dm_write_dig(hw); | ||
309 | } | ||
310 | |||
311 | static void rtl92c_dm_initial_gain_multi_sta(struct ieee80211_hw *hw) | ||
312 | { | ||
313 | static u8 binitialized; /* initialized to false */ | ||
314 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
315 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||
316 | long rssi_strength = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; | ||
317 | bool b_multi_sta = false; | ||
318 | |||
319 | if (mac->opmode == NL80211_IFTYPE_ADHOC) | ||
320 | b_multi_sta = true; | ||
321 | |||
322 | if ((b_multi_sta == false) || (dm_digtable.cursta_connectctate != | ||
323 | DIG_STA_DISCONNECT)) { | ||
324 | binitialized = false; | ||
325 | dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; | ||
326 | return; | ||
327 | } else if (binitialized == false) { | ||
328 | binitialized = true; | ||
329 | dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_0; | ||
330 | dm_digtable.cur_igvalue = 0x20; | ||
331 | rtl92c_dm_write_dig(hw); | ||
332 | } | ||
333 | |||
334 | if (dm_digtable.curmultista_connectstate == DIG_MULTISTA_CONNECT) { | ||
335 | if ((rssi_strength < dm_digtable.rssi_lowthresh) && | ||
336 | (dm_digtable.dig_ext_port_stage != DIG_EXT_PORT_STAGE_1)) { | ||
337 | |||
338 | if (dm_digtable.dig_ext_port_stage == | ||
339 | DIG_EXT_PORT_STAGE_2) { | ||
340 | dm_digtable.cur_igvalue = 0x20; | ||
341 | rtl92c_dm_write_dig(hw); | ||
342 | } | ||
343 | |||
344 | dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_1; | ||
345 | } else if (rssi_strength > dm_digtable.rssi_highthresh) { | ||
346 | dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_2; | ||
347 | rtl92c_dm_ctrl_initgain_by_fa(hw); | ||
348 | } | ||
349 | } else if (dm_digtable.dig_ext_port_stage != DIG_EXT_PORT_STAGE_0) { | ||
350 | dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_0; | ||
351 | dm_digtable.cur_igvalue = 0x20; | ||
352 | rtl92c_dm_write_dig(hw); | ||
353 | } | ||
354 | |||
355 | RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||
356 | ("curmultista_connectstate = " | ||
357 | "%x dig_ext_port_stage %x\n", | ||
358 | dm_digtable.curmultista_connectstate, | ||
359 | dm_digtable.dig_ext_port_stage)); | ||
360 | } | ||
361 | |||
362 | static void rtl92c_dm_initial_gain_sta(struct ieee80211_hw *hw) | ||
363 | { | ||
364 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
365 | |||
366 | RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||
367 | ("presta_connectstate = %x," | ||
368 | " cursta_connectctate = %x\n", | ||
369 | dm_digtable.presta_connectstate, | ||
370 | dm_digtable.cursta_connectctate)); | ||
371 | |||
372 | if (dm_digtable.presta_connectstate == dm_digtable.cursta_connectctate | ||
373 | || dm_digtable.cursta_connectctate == DIG_STA_BEFORE_CONNECT | ||
374 | || dm_digtable.cursta_connectctate == DIG_STA_CONNECT) { | ||
375 | |||
376 | if (dm_digtable.cursta_connectctate != DIG_STA_DISCONNECT) { | ||
377 | dm_digtable.rssi_val_min = | ||
378 | rtl92c_dm_initial_gain_min_pwdb(hw); | ||
379 | rtl92c_dm_ctrl_initgain_by_rssi(hw); | ||
380 | } | ||
381 | } else { | ||
382 | dm_digtable.rssi_val_min = 0; | ||
383 | dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; | ||
384 | dm_digtable.backoff_val = DM_DIG_BACKOFF_DEFAULT; | ||
385 | dm_digtable.cur_igvalue = 0x20; | ||
386 | dm_digtable.pre_igvalue = 0; | ||
387 | rtl92c_dm_write_dig(hw); | ||
388 | } | ||
389 | } | ||
390 | |||
391 | static void rtl92c_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) | ||
392 | { | ||
393 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
394 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
395 | |||
396 | if (dm_digtable.cursta_connectctate == DIG_STA_CONNECT) { | ||
397 | dm_digtable.rssi_val_min = rtl92c_dm_initial_gain_min_pwdb(hw); | ||
398 | |||
399 | if (dm_digtable.pre_cck_pd_state == CCK_PD_STAGE_LowRssi) { | ||
400 | if (dm_digtable.rssi_val_min <= 25) | ||
401 | dm_digtable.cur_cck_pd_state = | ||
402 | CCK_PD_STAGE_LowRssi; | ||
403 | else | ||
404 | dm_digtable.cur_cck_pd_state = | ||
405 | CCK_PD_STAGE_HighRssi; | ||
406 | } else { | ||
407 | if (dm_digtable.rssi_val_min <= 20) | ||
408 | dm_digtable.cur_cck_pd_state = | ||
409 | CCK_PD_STAGE_LowRssi; | ||
410 | else | ||
411 | dm_digtable.cur_cck_pd_state = | ||
412 | CCK_PD_STAGE_HighRssi; | ||
413 | } | ||
414 | } else { | ||
415 | dm_digtable.cur_cck_pd_state = CCK_PD_STAGE_MAX; | ||
416 | } | ||
417 | |||
418 | if (dm_digtable.pre_cck_pd_state != dm_digtable.cur_cck_pd_state) { | ||
419 | if (dm_digtable.cur_cck_pd_state == CCK_PD_STAGE_LowRssi) { | ||
420 | if (rtlpriv->falsealm_cnt.cnt_cck_fail > 800) | ||
421 | dm_digtable.cur_cck_fa_state = | ||
422 | CCK_FA_STAGE_High; | ||
423 | else | ||
424 | dm_digtable.cur_cck_fa_state = CCK_FA_STAGE_Low; | ||
425 | |||
426 | if (dm_digtable.pre_cck_fa_state != | ||
427 | dm_digtable.cur_cck_fa_state) { | ||
428 | if (dm_digtable.cur_cck_fa_state == | ||
429 | CCK_FA_STAGE_Low) | ||
430 | rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, | ||
431 | 0x83); | ||
432 | else | ||
433 | rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, | ||
434 | 0xcd); | ||
435 | |||
436 | dm_digtable.pre_cck_fa_state = | ||
437 | dm_digtable.cur_cck_fa_state; | ||
438 | } | ||
439 | |||
440 | rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x40); | ||
441 | |||
442 | if (IS_92C_SERIAL(rtlhal->version)) | ||
443 | rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, | ||
444 | MASKBYTE2, 0xd7); | ||
445 | } else { | ||
446 | rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd); | ||
447 | rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x47); | ||
448 | |||
449 | if (IS_92C_SERIAL(rtlhal->version)) | ||
450 | rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, | ||
451 | MASKBYTE2, 0xd3); | ||
452 | } | ||
453 | dm_digtable.pre_cck_pd_state = dm_digtable.cur_cck_pd_state; | ||
454 | } | ||
455 | |||
456 | RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||
457 | ("CCKPDStage=%x\n", dm_digtable.cur_cck_pd_state)); | ||
458 | |||
459 | RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||
460 | ("is92C=%x\n", IS_92C_SERIAL(rtlhal->version))); | ||
461 | } | ||
462 | |||
463 | static void rtl92c_dm_ctrl_initgain_by_twoport(struct ieee80211_hw *hw) | ||
464 | { | ||
465 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||
466 | |||
467 | if (mac->act_scanning == true) | ||
468 | return; | ||
469 | |||
470 | if ((mac->link_state > MAC80211_NOLINK) && | ||
471 | (mac->link_state < MAC80211_LINKED)) | ||
472 | dm_digtable.cursta_connectctate = DIG_STA_BEFORE_CONNECT; | ||
473 | else if (mac->link_state >= MAC80211_LINKED) | ||
474 | dm_digtable.cursta_connectctate = DIG_STA_CONNECT; | ||
475 | else | ||
476 | dm_digtable.cursta_connectctate = DIG_STA_DISCONNECT; | ||
477 | |||
478 | rtl92c_dm_initial_gain_sta(hw); | ||
479 | rtl92c_dm_initial_gain_multi_sta(hw); | ||
480 | rtl92c_dm_cck_packet_detection_thresh(hw); | ||
481 | |||
482 | dm_digtable.presta_connectstate = dm_digtable.cursta_connectctate; | ||
483 | |||
484 | } | ||
485 | |||
486 | static void rtl92c_dm_dig(struct ieee80211_hw *hw) | ||
487 | { | ||
488 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
489 | |||
490 | if (rtlpriv->dm.b_dm_initialgain_enable == false) | ||
491 | return; | ||
492 | if (dm_digtable.dig_enable_flag == false) | ||
493 | return; | ||
494 | |||
495 | rtl92c_dm_ctrl_initgain_by_twoport(hw); | ||
496 | |||
497 | } | ||
498 | |||
499 | static void rtl92c_dm_init_dynamic_txpower(struct ieee80211_hw *hw) | ||
500 | { | ||
501 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
502 | |||
503 | rtlpriv->dm.bdynamic_txpower_enable = false; | ||
504 | |||
505 | rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL; | ||
506 | rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; | ||
507 | } | ||
508 | |||
509 | static void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw) | ||
510 | { | 41 | { |
511 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 42 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
512 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | 43 | struct rtl_phy *rtlphy = &(rtlpriv->phy); |
513 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 44 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
514 | long undecorated_smoothed_pwdb; | 45 | long undecorated_smoothed_pwdb; |
515 | 46 | ||
516 | if (!rtlpriv->dm.bdynamic_txpower_enable) | 47 | if (!rtlpriv->dm.dynamic_txpower_enable) |
517 | return; | 48 | return; |
518 | 49 | ||
519 | if (rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) { | 50 | if (rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) { |
@@ -584,890 +115,4 @@ static void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw) | |||
584 | rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl; | 115 | rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl; |
585 | } | 116 | } |
586 | 117 | ||
587 | void rtl92c_dm_write_dig(struct ieee80211_hw *hw) | ||
588 | { | ||
589 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
590 | |||
591 | RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, | ||
592 | ("cur_igvalue = 0x%x, " | ||
593 | "pre_igvalue = 0x%x, backoff_val = %d\n", | ||
594 | dm_digtable.cur_igvalue, dm_digtable.pre_igvalue, | ||
595 | dm_digtable.backoff_val)); | ||
596 | |||
597 | if (dm_digtable.pre_igvalue != dm_digtable.cur_igvalue) { | ||
598 | rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, | ||
599 | dm_digtable.cur_igvalue); | ||
600 | rtl_set_bbreg(hw, ROFDM0_XBAGCCORE1, 0x7f, | ||
601 | dm_digtable.cur_igvalue); | ||
602 | |||
603 | dm_digtable.pre_igvalue = dm_digtable.cur_igvalue; | ||
604 | } | ||
605 | } | ||
606 | |||
607 | static void rtl92c_dm_pwdb_monitor(struct ieee80211_hw *hw) | ||
608 | { | ||
609 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
610 | long tmpentry_max_pwdb = 0, tmpentry_min_pwdb = 0xff; | ||
611 | |||
612 | u8 h2c_parameter[3] = { 0 }; | ||
613 | |||
614 | return; | ||
615 | |||
616 | if (tmpentry_max_pwdb != 0) { | ||
617 | rtlpriv->dm.entry_max_undecoratedsmoothed_pwdb = | ||
618 | tmpentry_max_pwdb; | ||
619 | } else { | ||
620 | rtlpriv->dm.entry_max_undecoratedsmoothed_pwdb = 0; | ||
621 | } | ||
622 | |||
623 | if (tmpentry_min_pwdb != 0xff) { | ||
624 | rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb = | ||
625 | tmpentry_min_pwdb; | ||
626 | } else { | ||
627 | rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb = 0; | ||
628 | } | ||
629 | |||
630 | h2c_parameter[2] = (u8) (rtlpriv->dm.undecorated_smoothed_pwdb & 0xFF); | ||
631 | h2c_parameter[0] = 0; | ||
632 | |||
633 | rtl92c_fill_h2c_cmd(hw, H2C_RSSI_REPORT, 3, h2c_parameter); | ||
634 | } | ||
635 | |||
636 | void rtl92c_dm_init_edca_turbo(struct ieee80211_hw *hw) | ||
637 | { | ||
638 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
639 | rtlpriv->dm.bcurrent_turbo_edca = false; | ||
640 | rtlpriv->dm.bis_any_nonbepkts = false; | ||
641 | rtlpriv->dm.bis_cur_rdlstate = false; | ||
642 | } | ||
643 | |||
644 | static void rtl92c_dm_check_edca_turbo(struct ieee80211_hw *hw) | ||
645 | { | ||
646 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
647 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||
648 | static u64 last_txok_cnt; | ||
649 | static u64 last_rxok_cnt; | ||
650 | u64 cur_txok_cnt; | ||
651 | u64 cur_rxok_cnt; | ||
652 | u32 edca_be_ul = 0x5ea42b; | ||
653 | u32 edca_be_dl = 0x5ea42b; | ||
654 | |||
655 | if (mac->opmode == NL80211_IFTYPE_ADHOC) | ||
656 | goto dm_checkedcaturbo_exit; | ||
657 | |||
658 | if (mac->link_state != MAC80211_LINKED) { | ||
659 | rtlpriv->dm.bcurrent_turbo_edca = false; | ||
660 | return; | ||
661 | } | ||
662 | |||
663 | if (!mac->ht_enable) { /*FIX MERGE */ | ||
664 | if (!(edca_be_ul & 0xffff0000)) | ||
665 | edca_be_ul |= 0x005e0000; | ||
666 | |||
667 | if (!(edca_be_dl & 0xffff0000)) | ||
668 | edca_be_dl |= 0x005e0000; | ||
669 | } | ||
670 | |||
671 | if ((!rtlpriv->dm.bis_any_nonbepkts) && | ||
672 | (!rtlpriv->dm.b_disable_framebursting)) { | ||
673 | cur_txok_cnt = rtlpriv->stats.txbytesunicast - last_txok_cnt; | ||
674 | cur_rxok_cnt = rtlpriv->stats.rxbytesunicast - last_rxok_cnt; | ||
675 | if (cur_rxok_cnt > 4 * cur_txok_cnt) { | ||
676 | if (!rtlpriv->dm.bis_cur_rdlstate || | ||
677 | !rtlpriv->dm.bcurrent_turbo_edca) { | ||
678 | rtl_write_dword(rtlpriv, | ||
679 | REG_EDCA_BE_PARAM, | ||
680 | edca_be_dl); | ||
681 | rtlpriv->dm.bis_cur_rdlstate = true; | ||
682 | } | ||
683 | } else { | ||
684 | if (rtlpriv->dm.bis_cur_rdlstate || | ||
685 | !rtlpriv->dm.bcurrent_turbo_edca) { | ||
686 | rtl_write_dword(rtlpriv, | ||
687 | REG_EDCA_BE_PARAM, | ||
688 | edca_be_ul); | ||
689 | rtlpriv->dm.bis_cur_rdlstate = false; | ||
690 | } | ||
691 | } | ||
692 | rtlpriv->dm.bcurrent_turbo_edca = true; | ||
693 | } else { | ||
694 | if (rtlpriv->dm.bcurrent_turbo_edca) { | ||
695 | u8 tmp = AC0_BE; | ||
696 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
697 | HW_VAR_AC_PARAM, | ||
698 | (u8 *) (&tmp)); | ||
699 | rtlpriv->dm.bcurrent_turbo_edca = false; | ||
700 | } | ||
701 | } | ||
702 | |||
703 | dm_checkedcaturbo_exit: | ||
704 | rtlpriv->dm.bis_any_nonbepkts = false; | ||
705 | last_txok_cnt = rtlpriv->stats.txbytesunicast; | ||
706 | last_rxok_cnt = rtlpriv->stats.rxbytesunicast; | ||
707 | } | ||
708 | |||
709 | static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw | ||
710 | *hw) | ||
711 | { | ||
712 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
713 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
714 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
715 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||
716 | u8 thermalvalue, delta, delta_lck, delta_iqk; | ||
717 | long ele_a, ele_d, temp_cck, val_x, value32; | ||
718 | long val_y, ele_c; | ||
719 | u8 ofdm_index[2], cck_index, ofdm_index_old[2], cck_index_old; | ||
720 | int i; | ||
721 | bool is2t = IS_92C_SERIAL(rtlhal->version); | ||
722 | u8 txpwr_level[2] = {0, 0}; | ||
723 | u8 ofdm_min_index = 6, rf; | ||
724 | |||
725 | rtlpriv->dm.btxpower_trackingInit = true; | ||
726 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
727 | ("rtl92c_dm_txpower_tracking_callback_thermalmeter\n")); | ||
728 | |||
729 | thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f); | ||
730 | |||
731 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
732 | ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " | ||
733 | "eeprom_thermalmeter 0x%x\n", | ||
734 | thermalvalue, rtlpriv->dm.thermalvalue, | ||
735 | rtlefuse->eeprom_thermalmeter)); | ||
736 | |||
737 | rtl92c_phy_ap_calibrate(hw, (thermalvalue - | ||
738 | rtlefuse->eeprom_thermalmeter)); | ||
739 | if (is2t) | ||
740 | rf = 2; | ||
741 | else | ||
742 | rf = 1; | ||
743 | |||
744 | if (thermalvalue) { | ||
745 | ele_d = rtl_get_bbreg(hw, ROFDM0_XATXIQIMBALANCE, | ||
746 | MASKDWORD) & MASKOFDM_D; | ||
747 | |||
748 | for (i = 0; i < OFDM_TABLE_LENGTH; i++) { | ||
749 | if (ele_d == (ofdmswing_table[i] & MASKOFDM_D)) { | ||
750 | ofdm_index_old[0] = (u8) i; | ||
751 | |||
752 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
753 | ("Initial pathA ele_d reg0x%x = 0x%lx, " | ||
754 | "ofdm_index=0x%x\n", | ||
755 | ROFDM0_XATXIQIMBALANCE, | ||
756 | ele_d, ofdm_index_old[0])); | ||
757 | break; | ||
758 | } | ||
759 | } | ||
760 | |||
761 | if (is2t) { | ||
762 | ele_d = rtl_get_bbreg(hw, ROFDM0_XBTXIQIMBALANCE, | ||
763 | MASKDWORD) & MASKOFDM_D; | ||
764 | |||
765 | for (i = 0; i < OFDM_TABLE_LENGTH; i++) { | ||
766 | if (ele_d == (ofdmswing_table[i] & MASKOFDM_D)) { | ||
767 | ofdm_index_old[1] = (u8) i; | ||
768 | |||
769 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, | ||
770 | DBG_LOUD, | ||
771 | ("Initial pathB ele_d reg0x%x = " | ||
772 | "0x%lx, ofdm_index=0x%x\n", | ||
773 | ROFDM0_XBTXIQIMBALANCE, ele_d, | ||
774 | ofdm_index_old[1])); | ||
775 | break; | ||
776 | } | ||
777 | } | ||
778 | } | ||
779 | |||
780 | temp_cck = | ||
781 | rtl_get_bbreg(hw, RCCK0_TXFILTER2, MASKDWORD) & MASKCCK; | ||
782 | |||
783 | for (i = 0; i < CCK_TABLE_LENGTH; i++) { | ||
784 | if (rtlpriv->dm.b_cck_inch14) { | ||
785 | if (memcmp((void *)&temp_cck, | ||
786 | (void *)&cckswing_table_ch14[i][2], | ||
787 | 4) == 0) { | ||
788 | cck_index_old = (u8) i; | ||
789 | |||
790 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, | ||
791 | DBG_LOUD, | ||
792 | ("Initial reg0x%x = 0x%lx, " | ||
793 | "cck_index=0x%x, ch 14 %d\n", | ||
794 | RCCK0_TXFILTER2, temp_cck, | ||
795 | cck_index_old, | ||
796 | rtlpriv->dm.b_cck_inch14)); | ||
797 | break; | ||
798 | } | ||
799 | } else { | ||
800 | if (memcmp((void *)&temp_cck, | ||
801 | (void *) | ||
802 | &cckswing_table_ch1ch13[i][2], | ||
803 | 4) == 0) { | ||
804 | cck_index_old = (u8) i; | ||
805 | 118 | ||
806 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, | ||
807 | DBG_LOUD, | ||
808 | ("Initial reg0x%x = 0x%lx, " | ||
809 | "cck_index=0x%x, ch14 %d\n", | ||
810 | RCCK0_TXFILTER2, temp_cck, | ||
811 | cck_index_old, | ||
812 | rtlpriv->dm.b_cck_inch14)); | ||
813 | break; | ||
814 | } | ||
815 | } | ||
816 | } | ||
817 | |||
818 | if (!rtlpriv->dm.thermalvalue) { | ||
819 | rtlpriv->dm.thermalvalue = | ||
820 | rtlefuse->eeprom_thermalmeter; | ||
821 | rtlpriv->dm.thermalvalue_lck = thermalvalue; | ||
822 | rtlpriv->dm.thermalvalue_iqk = thermalvalue; | ||
823 | for (i = 0; i < rf; i++) | ||
824 | rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i]; | ||
825 | rtlpriv->dm.cck_index = cck_index_old; | ||
826 | } | ||
827 | |||
828 | delta = (thermalvalue > rtlpriv->dm.thermalvalue) ? | ||
829 | (thermalvalue - rtlpriv->dm.thermalvalue) : | ||
830 | (rtlpriv->dm.thermalvalue - thermalvalue); | ||
831 | |||
832 | delta_lck = (thermalvalue > rtlpriv->dm.thermalvalue_lck) ? | ||
833 | (thermalvalue - rtlpriv->dm.thermalvalue_lck) : | ||
834 | (rtlpriv->dm.thermalvalue_lck - thermalvalue); | ||
835 | |||
836 | delta_iqk = (thermalvalue > rtlpriv->dm.thermalvalue_iqk) ? | ||
837 | (thermalvalue - rtlpriv->dm.thermalvalue_iqk) : | ||
838 | (rtlpriv->dm.thermalvalue_iqk - thermalvalue); | ||
839 | |||
840 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
841 | ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " | ||
842 | "eeprom_thermalmeter 0x%x delta 0x%x " | ||
843 | "delta_lck 0x%x delta_iqk 0x%x\n", | ||
844 | thermalvalue, rtlpriv->dm.thermalvalue, | ||
845 | rtlefuse->eeprom_thermalmeter, delta, delta_lck, | ||
846 | delta_iqk)); | ||
847 | |||
848 | if (delta_lck > 1) { | ||
849 | rtlpriv->dm.thermalvalue_lck = thermalvalue; | ||
850 | rtl92c_phy_lc_calibrate(hw); | ||
851 | } | ||
852 | |||
853 | if (delta > 0 && rtlpriv->dm.txpower_track_control) { | ||
854 | if (thermalvalue > rtlpriv->dm.thermalvalue) { | ||
855 | for (i = 0; i < rf; i++) | ||
856 | rtlpriv->dm.ofdm_index[i] -= delta; | ||
857 | rtlpriv->dm.cck_index -= delta; | ||
858 | } else { | ||
859 | for (i = 0; i < rf; i++) | ||
860 | rtlpriv->dm.ofdm_index[i] += delta; | ||
861 | rtlpriv->dm.cck_index += delta; | ||
862 | } | ||
863 | |||
864 | if (is2t) { | ||
865 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
866 | ("temp OFDM_A_index=0x%x, " | ||
867 | "OFDM_B_index=0x%x," | ||
868 | "cck_index=0x%x\n", | ||
869 | rtlpriv->dm.ofdm_index[0], | ||
870 | rtlpriv->dm.ofdm_index[1], | ||
871 | rtlpriv->dm.cck_index)); | ||
872 | } else { | ||
873 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
874 | ("temp OFDM_A_index=0x%x," | ||
875 | "cck_index=0x%x\n", | ||
876 | rtlpriv->dm.ofdm_index[0], | ||
877 | rtlpriv->dm.cck_index)); | ||
878 | } | ||
879 | |||
880 | if (thermalvalue > rtlefuse->eeprom_thermalmeter) { | ||
881 | for (i = 0; i < rf; i++) | ||
882 | ofdm_index[i] = | ||
883 | rtlpriv->dm.ofdm_index[i] | ||
884 | + 1; | ||
885 | cck_index = rtlpriv->dm.cck_index + 1; | ||
886 | } else { | ||
887 | for (i = 0; i < rf; i++) | ||
888 | ofdm_index[i] = | ||
889 | rtlpriv->dm.ofdm_index[i]; | ||
890 | cck_index = rtlpriv->dm.cck_index; | ||
891 | } | ||
892 | |||
893 | for (i = 0; i < rf; i++) { | ||
894 | if (txpwr_level[i] >= 0 && | ||
895 | txpwr_level[i] <= 26) { | ||
896 | if (thermalvalue > | ||
897 | rtlefuse->eeprom_thermalmeter) { | ||
898 | if (delta < 5) | ||
899 | ofdm_index[i] -= 1; | ||
900 | |||
901 | else | ||
902 | ofdm_index[i] -= 2; | ||
903 | } else if (delta > 5 && thermalvalue < | ||
904 | rtlefuse-> | ||
905 | eeprom_thermalmeter) { | ||
906 | ofdm_index[i] += 1; | ||
907 | } | ||
908 | } else if (txpwr_level[i] >= 27 && | ||
909 | txpwr_level[i] <= 32 | ||
910 | && thermalvalue > | ||
911 | rtlefuse->eeprom_thermalmeter) { | ||
912 | if (delta < 5) | ||
913 | ofdm_index[i] -= 1; | ||
914 | |||
915 | else | ||
916 | ofdm_index[i] -= 2; | ||
917 | } else if (txpwr_level[i] >= 32 && | ||
918 | txpwr_level[i] <= 38 && | ||
919 | thermalvalue > | ||
920 | rtlefuse->eeprom_thermalmeter | ||
921 | && delta > 5) { | ||
922 | ofdm_index[i] -= 1; | ||
923 | } | ||
924 | } | ||
925 | |||
926 | if (txpwr_level[i] >= 0 && txpwr_level[i] <= 26) { | ||
927 | if (thermalvalue > | ||
928 | rtlefuse->eeprom_thermalmeter) { | ||
929 | if (delta < 5) | ||
930 | cck_index -= 1; | ||
931 | |||
932 | else | ||
933 | cck_index -= 2; | ||
934 | } else if (delta > 5 && thermalvalue < | ||
935 | rtlefuse->eeprom_thermalmeter) { | ||
936 | cck_index += 1; | ||
937 | } | ||
938 | } else if (txpwr_level[i] >= 27 && | ||
939 | txpwr_level[i] <= 32 && | ||
940 | thermalvalue > | ||
941 | rtlefuse->eeprom_thermalmeter) { | ||
942 | if (delta < 5) | ||
943 | cck_index -= 1; | ||
944 | |||
945 | else | ||
946 | cck_index -= 2; | ||
947 | } else if (txpwr_level[i] >= 32 && | ||
948 | txpwr_level[i] <= 38 && | ||
949 | thermalvalue > rtlefuse->eeprom_thermalmeter | ||
950 | && delta > 5) { | ||
951 | cck_index -= 1; | ||
952 | } | ||
953 | |||
954 | for (i = 0; i < rf; i++) { | ||
955 | if (ofdm_index[i] > OFDM_TABLE_SIZE - 1) | ||
956 | ofdm_index[i] = OFDM_TABLE_SIZE - 1; | ||
957 | |||
958 | else if (ofdm_index[i] < ofdm_min_index) | ||
959 | ofdm_index[i] = ofdm_min_index; | ||
960 | } | ||
961 | |||
962 | if (cck_index > CCK_TABLE_SIZE - 1) | ||
963 | cck_index = CCK_TABLE_SIZE - 1; | ||
964 | else if (cck_index < 0) | ||
965 | cck_index = 0; | ||
966 | |||
967 | if (is2t) { | ||
968 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
969 | ("new OFDM_A_index=0x%x, " | ||
970 | "OFDM_B_index=0x%x," | ||
971 | "cck_index=0x%x\n", | ||
972 | ofdm_index[0], ofdm_index[1], | ||
973 | cck_index)); | ||
974 | } else { | ||
975 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
976 | ("new OFDM_A_index=0x%x," | ||
977 | "cck_index=0x%x\n", | ||
978 | ofdm_index[0], cck_index)); | ||
979 | } | ||
980 | } | ||
981 | |||
982 | if (rtlpriv->dm.txpower_track_control && delta != 0) { | ||
983 | ele_d = | ||
984 | (ofdmswing_table[ofdm_index[0]] & 0xFFC00000) >> 22; | ||
985 | val_x = rtlphy->reg_e94; | ||
986 | val_y = rtlphy->reg_e9c; | ||
987 | |||
988 | if (val_x != 0) { | ||
989 | if ((val_x & 0x00000200) != 0) | ||
990 | val_x = val_x | 0xFFFFFC00; | ||
991 | ele_a = ((val_x * ele_d) >> 8) & 0x000003FF; | ||
992 | |||
993 | if ((val_y & 0x00000200) != 0) | ||
994 | val_y = val_y | 0xFFFFFC00; | ||
995 | ele_c = ((val_y * ele_d) >> 8) & 0x000003FF; | ||
996 | |||
997 | value32 = (ele_d << 22) | | ||
998 | ((ele_c & 0x3F) << 16) | ele_a; | ||
999 | |||
1000 | rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, | ||
1001 | MASKDWORD, value32); | ||
1002 | |||
1003 | value32 = (ele_c & 0x000003C0) >> 6; | ||
1004 | rtl_set_bbreg(hw, ROFDM0_XCTXAFE, MASKH4BITS, | ||
1005 | value32); | ||
1006 | |||
1007 | value32 = ((val_x * ele_d) >> 7) & 0x01; | ||
1008 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, | ||
1009 | BIT(31), value32); | ||
1010 | |||
1011 | value32 = ((val_y * ele_d) >> 7) & 0x01; | ||
1012 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, | ||
1013 | BIT(29), value32); | ||
1014 | } else { | ||
1015 | rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, | ||
1016 | MASKDWORD, | ||
1017 | ofdmswing_table[ofdm_index[0]]); | ||
1018 | |||
1019 | rtl_set_bbreg(hw, ROFDM0_XCTXAFE, MASKH4BITS, | ||
1020 | 0x00); | ||
1021 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, | ||
1022 | BIT(31) | BIT(29), 0x00); | ||
1023 | } | ||
1024 | |||
1025 | if (!rtlpriv->dm.b_cck_inch14) { | ||
1026 | rtl_write_byte(rtlpriv, 0xa22, | ||
1027 | cckswing_table_ch1ch13[cck_index] | ||
1028 | [0]); | ||
1029 | rtl_write_byte(rtlpriv, 0xa23, | ||
1030 | cckswing_table_ch1ch13[cck_index] | ||
1031 | [1]); | ||
1032 | rtl_write_byte(rtlpriv, 0xa24, | ||
1033 | cckswing_table_ch1ch13[cck_index] | ||
1034 | [2]); | ||
1035 | rtl_write_byte(rtlpriv, 0xa25, | ||
1036 | cckswing_table_ch1ch13[cck_index] | ||
1037 | [3]); | ||
1038 | rtl_write_byte(rtlpriv, 0xa26, | ||
1039 | cckswing_table_ch1ch13[cck_index] | ||
1040 | [4]); | ||
1041 | rtl_write_byte(rtlpriv, 0xa27, | ||
1042 | cckswing_table_ch1ch13[cck_index] | ||
1043 | [5]); | ||
1044 | rtl_write_byte(rtlpriv, 0xa28, | ||
1045 | cckswing_table_ch1ch13[cck_index] | ||
1046 | [6]); | ||
1047 | rtl_write_byte(rtlpriv, 0xa29, | ||
1048 | cckswing_table_ch1ch13[cck_index] | ||
1049 | [7]); | ||
1050 | } else { | ||
1051 | rtl_write_byte(rtlpriv, 0xa22, | ||
1052 | cckswing_table_ch14[cck_index] | ||
1053 | [0]); | ||
1054 | rtl_write_byte(rtlpriv, 0xa23, | ||
1055 | cckswing_table_ch14[cck_index] | ||
1056 | [1]); | ||
1057 | rtl_write_byte(rtlpriv, 0xa24, | ||
1058 | cckswing_table_ch14[cck_index] | ||
1059 | [2]); | ||
1060 | rtl_write_byte(rtlpriv, 0xa25, | ||
1061 | cckswing_table_ch14[cck_index] | ||
1062 | [3]); | ||
1063 | rtl_write_byte(rtlpriv, 0xa26, | ||
1064 | cckswing_table_ch14[cck_index] | ||
1065 | [4]); | ||
1066 | rtl_write_byte(rtlpriv, 0xa27, | ||
1067 | cckswing_table_ch14[cck_index] | ||
1068 | [5]); | ||
1069 | rtl_write_byte(rtlpriv, 0xa28, | ||
1070 | cckswing_table_ch14[cck_index] | ||
1071 | [6]); | ||
1072 | rtl_write_byte(rtlpriv, 0xa29, | ||
1073 | cckswing_table_ch14[cck_index] | ||
1074 | [7]); | ||
1075 | } | ||
1076 | |||
1077 | if (is2t) { | ||
1078 | ele_d = (ofdmswing_table[ofdm_index[1]] & | ||
1079 | 0xFFC00000) >> 22; | ||
1080 | |||
1081 | val_x = rtlphy->reg_eb4; | ||
1082 | val_y = rtlphy->reg_ebc; | ||
1083 | |||
1084 | if (val_x != 0) { | ||
1085 | if ((val_x & 0x00000200) != 0) | ||
1086 | val_x = val_x | 0xFFFFFC00; | ||
1087 | ele_a = ((val_x * ele_d) >> 8) & | ||
1088 | 0x000003FF; | ||
1089 | |||
1090 | if ((val_y & 0x00000200) != 0) | ||
1091 | val_y = val_y | 0xFFFFFC00; | ||
1092 | ele_c = ((val_y * ele_d) >> 8) & | ||
1093 | 0x00003FF; | ||
1094 | |||
1095 | value32 = (ele_d << 22) | | ||
1096 | ((ele_c & 0x3F) << 16) | ele_a; | ||
1097 | rtl_set_bbreg(hw, | ||
1098 | ROFDM0_XBTXIQIMBALANCE, | ||
1099 | MASKDWORD, value32); | ||
1100 | |||
1101 | value32 = (ele_c & 0x000003C0) >> 6; | ||
1102 | rtl_set_bbreg(hw, ROFDM0_XDTXAFE, | ||
1103 | MASKH4BITS, value32); | ||
1104 | |||
1105 | value32 = ((val_x * ele_d) >> 7) & 0x01; | ||
1106 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, | ||
1107 | BIT(27), value32); | ||
1108 | |||
1109 | value32 = ((val_y * ele_d) >> 7) & 0x01; | ||
1110 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, | ||
1111 | BIT(25), value32); | ||
1112 | } else { | ||
1113 | rtl_set_bbreg(hw, | ||
1114 | ROFDM0_XBTXIQIMBALANCE, | ||
1115 | MASKDWORD, | ||
1116 | ofdmswing_table[ofdm_index | ||
1117 | [1]]); | ||
1118 | rtl_set_bbreg(hw, ROFDM0_XDTXAFE, | ||
1119 | MASKH4BITS, 0x00); | ||
1120 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, | ||
1121 | BIT(27) | BIT(25), 0x00); | ||
1122 | } | ||
1123 | |||
1124 | } | ||
1125 | } | ||
1126 | |||
1127 | if (delta_iqk > 3) { | ||
1128 | rtlpriv->dm.thermalvalue_iqk = thermalvalue; | ||
1129 | rtl92c_phy_iq_calibrate(hw, false); | ||
1130 | } | ||
1131 | |||
1132 | if (rtlpriv->dm.txpower_track_control) | ||
1133 | rtlpriv->dm.thermalvalue = thermalvalue; | ||
1134 | } | ||
1135 | |||
1136 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("<===\n")); | ||
1137 | |||
1138 | } | ||
1139 | |||
1140 | static void rtl92c_dm_initialize_txpower_tracking_thermalmeter( | ||
1141 | struct ieee80211_hw *hw) | ||
1142 | { | ||
1143 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1144 | |||
1145 | rtlpriv->dm.btxpower_tracking = true; | ||
1146 | rtlpriv->dm.btxpower_trackingInit = false; | ||
1147 | |||
1148 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
1149 | ("pMgntInfo->btxpower_tracking = %d\n", | ||
1150 | rtlpriv->dm.btxpower_tracking)); | ||
1151 | } | ||
1152 | |||
1153 | static void rtl92c_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) | ||
1154 | { | ||
1155 | rtl92c_dm_initialize_txpower_tracking_thermalmeter(hw); | ||
1156 | } | ||
1157 | |||
1158 | static void rtl92c_dm_txpower_tracking_directcall(struct ieee80211_hw *hw) | ||
1159 | { | ||
1160 | rtl92c_dm_txpower_tracking_callback_thermalmeter(hw); | ||
1161 | } | ||
1162 | |||
1163 | static void rtl92c_dm_check_txpower_tracking_thermal_meter( | ||
1164 | struct ieee80211_hw *hw) | ||
1165 | { | ||
1166 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1167 | static u8 tm_trigger; | ||
1168 | |||
1169 | if (!rtlpriv->dm.btxpower_tracking) | ||
1170 | return; | ||
1171 | |||
1172 | if (!tm_trigger) { | ||
1173 | rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, RFREG_OFFSET_MASK, | ||
1174 | 0x60); | ||
1175 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
1176 | ("Trigger 92S Thermal Meter!!\n")); | ||
1177 | tm_trigger = 1; | ||
1178 | return; | ||
1179 | } else { | ||
1180 | RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||
1181 | ("Schedule TxPowerTracking direct call!!\n")); | ||
1182 | rtl92c_dm_txpower_tracking_directcall(hw); | ||
1183 | tm_trigger = 0; | ||
1184 | } | ||
1185 | } | ||
1186 | |||
1187 | void rtl92c_dm_check_txpower_tracking(struct ieee80211_hw *hw) | ||
1188 | { | ||
1189 | rtl92c_dm_check_txpower_tracking_thermal_meter(hw); | ||
1190 | } | ||
1191 | |||
1192 | void rtl92c_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw) | ||
1193 | { | ||
1194 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1195 | struct rate_adaptive *p_ra = &(rtlpriv->ra); | ||
1196 | |||
1197 | p_ra->ratr_state = DM_RATR_STA_INIT; | ||
1198 | p_ra->pre_ratr_state = DM_RATR_STA_INIT; | ||
1199 | |||
1200 | if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER) | ||
1201 | rtlpriv->dm.b_useramask = true; | ||
1202 | else | ||
1203 | rtlpriv->dm.b_useramask = false; | ||
1204 | |||
1205 | } | ||
1206 | |||
1207 | static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw) | ||
1208 | { | ||
1209 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1210 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
1211 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||
1212 | struct rate_adaptive *p_ra = &(rtlpriv->ra); | ||
1213 | u32 low_rssithresh_for_ra, high_rssithresh_for_ra; | ||
1214 | |||
1215 | if (is_hal_stop(rtlhal)) { | ||
1216 | RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, | ||
1217 | ("<---- driver is going to unload\n")); | ||
1218 | return; | ||
1219 | } | ||
1220 | |||
1221 | if (!rtlpriv->dm.b_useramask) { | ||
1222 | RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, | ||
1223 | ("<---- driver does not control rate adaptive mask\n")); | ||
1224 | return; | ||
1225 | } | ||
1226 | |||
1227 | if (mac->link_state == MAC80211_LINKED) { | ||
1228 | |||
1229 | switch (p_ra->pre_ratr_state) { | ||
1230 | case DM_RATR_STA_HIGH: | ||
1231 | high_rssithresh_for_ra = 50; | ||
1232 | low_rssithresh_for_ra = 20; | ||
1233 | break; | ||
1234 | case DM_RATR_STA_MIDDLE: | ||
1235 | high_rssithresh_for_ra = 55; | ||
1236 | low_rssithresh_for_ra = 20; | ||
1237 | break; | ||
1238 | case DM_RATR_STA_LOW: | ||
1239 | high_rssithresh_for_ra = 50; | ||
1240 | low_rssithresh_for_ra = 25; | ||
1241 | break; | ||
1242 | default: | ||
1243 | high_rssithresh_for_ra = 50; | ||
1244 | low_rssithresh_for_ra = 20; | ||
1245 | break; | ||
1246 | } | ||
1247 | |||
1248 | if (rtlpriv->dm.undecorated_smoothed_pwdb > | ||
1249 | (long)high_rssithresh_for_ra) | ||
1250 | p_ra->ratr_state = DM_RATR_STA_HIGH; | ||
1251 | else if (rtlpriv->dm.undecorated_smoothed_pwdb > | ||
1252 | (long)low_rssithresh_for_ra) | ||
1253 | p_ra->ratr_state = DM_RATR_STA_MIDDLE; | ||
1254 | else | ||
1255 | p_ra->ratr_state = DM_RATR_STA_LOW; | ||
1256 | |||
1257 | if (p_ra->pre_ratr_state != p_ra->ratr_state) { | ||
1258 | RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, | ||
1259 | ("RSSI = %ld\n", | ||
1260 | rtlpriv->dm.undecorated_smoothed_pwdb)); | ||
1261 | RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, | ||
1262 | ("RSSI_LEVEL = %d\n", p_ra->ratr_state)); | ||
1263 | RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, | ||
1264 | ("PreState = %d, CurState = %d\n", | ||
1265 | p_ra->pre_ratr_state, p_ra->ratr_state)); | ||
1266 | |||
1267 | rtlpriv->cfg->ops->update_rate_mask(hw, | ||
1268 | p_ra->ratr_state); | ||
1269 | |||
1270 | p_ra->pre_ratr_state = p_ra->ratr_state; | ||
1271 | } | ||
1272 | } | ||
1273 | } | ||
1274 | |||
1275 | static void rtl92c_dm_init_dynamic_bb_powersaving(struct ieee80211_hw *hw) | ||
1276 | { | ||
1277 | dm_pstable.pre_ccastate = CCA_MAX; | ||
1278 | dm_pstable.cur_ccasate = CCA_MAX; | ||
1279 | dm_pstable.pre_rfstate = RF_MAX; | ||
1280 | dm_pstable.cur_rfstate = RF_MAX; | ||
1281 | dm_pstable.rssi_val_min = 0; | ||
1282 | } | ||
1283 | |||
1284 | static void rtl92c_dm_1r_cca(struct ieee80211_hw *hw) | ||
1285 | { | ||
1286 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1287 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1288 | |||
1289 | if (dm_pstable.rssi_val_min != 0) { | ||
1290 | if (dm_pstable.pre_ccastate == CCA_2R) { | ||
1291 | if (dm_pstable.rssi_val_min >= 35) | ||
1292 | dm_pstable.cur_ccasate = CCA_1R; | ||
1293 | else | ||
1294 | dm_pstable.cur_ccasate = CCA_2R; | ||
1295 | } else { | ||
1296 | if (dm_pstable.rssi_val_min <= 30) | ||
1297 | dm_pstable.cur_ccasate = CCA_2R; | ||
1298 | else | ||
1299 | dm_pstable.cur_ccasate = CCA_1R; | ||
1300 | } | ||
1301 | } else { | ||
1302 | dm_pstable.cur_ccasate = CCA_MAX; | ||
1303 | } | ||
1304 | |||
1305 | if (dm_pstable.pre_ccastate != dm_pstable.cur_ccasate) { | ||
1306 | if (dm_pstable.cur_ccasate == CCA_1R) { | ||
1307 | if (get_rf_type(rtlphy) == RF_2T2R) { | ||
1308 | rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, | ||
1309 | MASKBYTE0, 0x13); | ||
1310 | rtl_set_bbreg(hw, 0xe70, MASKBYTE3, 0x20); | ||
1311 | } else { | ||
1312 | rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, | ||
1313 | MASKBYTE0, 0x23); | ||
1314 | rtl_set_bbreg(hw, 0xe70, 0x7fc00000, 0x10c); | ||
1315 | } | ||
1316 | } else { | ||
1317 | rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, MASKBYTE0, | ||
1318 | 0x33); | ||
1319 | rtl_set_bbreg(hw, 0xe70, MASKBYTE3, 0x63); | ||
1320 | } | ||
1321 | dm_pstable.pre_ccastate = dm_pstable.cur_ccasate; | ||
1322 | } | ||
1323 | |||
1324 | RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, ("CCAStage = %s\n", | ||
1325 | (dm_pstable.cur_ccasate == | ||
1326 | 0) ? "1RCCA" : "2RCCA")); | ||
1327 | } | ||
1328 | |||
1329 | void rtl92c_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal) | ||
1330 | { | ||
1331 | static u8 initialize; | ||
1332 | static u32 reg_874, reg_c70, reg_85c, reg_a74; | ||
1333 | |||
1334 | if (initialize == 0) { | ||
1335 | reg_874 = (rtl_get_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||
1336 | MASKDWORD) & 0x1CC000) >> 14; | ||
1337 | |||
1338 | reg_c70 = (rtl_get_bbreg(hw, ROFDM0_AGCPARAMETER1, | ||
1339 | MASKDWORD) & BIT(3)) >> 3; | ||
1340 | |||
1341 | reg_85c = (rtl_get_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL, | ||
1342 | MASKDWORD) & 0xFF000000) >> 24; | ||
1343 | |||
1344 | reg_a74 = (rtl_get_bbreg(hw, 0xa74, MASKDWORD) & 0xF000) >> 12; | ||
1345 | |||
1346 | initialize = 1; | ||
1347 | } | ||
1348 | |||
1349 | if (!bforce_in_normal) { | ||
1350 | if (dm_pstable.rssi_val_min != 0) { | ||
1351 | if (dm_pstable.pre_rfstate == RF_NORMAL) { | ||
1352 | if (dm_pstable.rssi_val_min >= 30) | ||
1353 | dm_pstable.cur_rfstate = RF_SAVE; | ||
1354 | else | ||
1355 | dm_pstable.cur_rfstate = RF_NORMAL; | ||
1356 | } else { | ||
1357 | if (dm_pstable.rssi_val_min <= 25) | ||
1358 | dm_pstable.cur_rfstate = RF_NORMAL; | ||
1359 | else | ||
1360 | dm_pstable.cur_rfstate = RF_SAVE; | ||
1361 | } | ||
1362 | } else { | ||
1363 | dm_pstable.cur_rfstate = RF_MAX; | ||
1364 | } | ||
1365 | } else { | ||
1366 | dm_pstable.cur_rfstate = RF_NORMAL; | ||
1367 | } | ||
1368 | |||
1369 | if (dm_pstable.pre_rfstate != dm_pstable.cur_rfstate) { | ||
1370 | if (dm_pstable.cur_rfstate == RF_SAVE) { | ||
1371 | rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||
1372 | 0x1C0000, 0x2); | ||
1373 | rtl_set_bbreg(hw, ROFDM0_AGCPARAMETER1, BIT(3), 0); | ||
1374 | rtl_set_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL, | ||
1375 | 0xFF000000, 0x63); | ||
1376 | rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||
1377 | 0xC000, 0x2); | ||
1378 | rtl_set_bbreg(hw, 0xa74, 0xF000, 0x3); | ||
1379 | rtl_set_bbreg(hw, 0x818, BIT(28), 0x0); | ||
1380 | rtl_set_bbreg(hw, 0x818, BIT(28), 0x1); | ||
1381 | } else { | ||
1382 | rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||
1383 | 0x1CC000, reg_874); | ||
1384 | rtl_set_bbreg(hw, ROFDM0_AGCPARAMETER1, BIT(3), | ||
1385 | reg_c70); | ||
1386 | rtl_set_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL, 0xFF000000, | ||
1387 | reg_85c); | ||
1388 | rtl_set_bbreg(hw, 0xa74, 0xF000, reg_a74); | ||
1389 | rtl_set_bbreg(hw, 0x818, BIT(28), 0x0); | ||
1390 | } | ||
1391 | |||
1392 | dm_pstable.pre_rfstate = dm_pstable.cur_rfstate; | ||
1393 | } | ||
1394 | } | ||
1395 | |||
1396 | static void rtl92c_dm_dynamic_bb_powersaving(struct ieee80211_hw *hw) | ||
1397 | { | ||
1398 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1399 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||
1400 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
1401 | |||
1402 | if (((mac->link_state == MAC80211_NOLINK)) && | ||
1403 | (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { | ||
1404 | dm_pstable.rssi_val_min = 0; | ||
1405 | RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||
1406 | ("Not connected to any\n")); | ||
1407 | } | ||
1408 | |||
1409 | if (mac->link_state == MAC80211_LINKED) { | ||
1410 | if (mac->opmode == NL80211_IFTYPE_ADHOC) { | ||
1411 | dm_pstable.rssi_val_min = | ||
1412 | rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; | ||
1413 | RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||
1414 | ("AP Client PWDB = 0x%lx\n", | ||
1415 | dm_pstable.rssi_val_min)); | ||
1416 | } else { | ||
1417 | dm_pstable.rssi_val_min = | ||
1418 | rtlpriv->dm.undecorated_smoothed_pwdb; | ||
1419 | RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||
1420 | ("STA Default Port PWDB = 0x%lx\n", | ||
1421 | dm_pstable.rssi_val_min)); | ||
1422 | } | ||
1423 | } else { | ||
1424 | dm_pstable.rssi_val_min = | ||
1425 | rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; | ||
1426 | |||
1427 | RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||
1428 | ("AP Ext Port PWDB = 0x%lx\n", | ||
1429 | dm_pstable.rssi_val_min)); | ||
1430 | } | ||
1431 | |||
1432 | if (IS_92C_SERIAL(rtlhal->version)) | ||
1433 | rtl92c_dm_1r_cca(hw); | ||
1434 | } | ||
1435 | |||
1436 | void rtl92c_dm_init(struct ieee80211_hw *hw) | ||
1437 | { | ||
1438 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1439 | |||
1440 | rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER; | ||
1441 | rtl92c_dm_diginit(hw); | ||
1442 | rtl92c_dm_init_dynamic_txpower(hw); | ||
1443 | rtl92c_dm_init_edca_turbo(hw); | ||
1444 | rtl92c_dm_init_rate_adaptive_mask(hw); | ||
1445 | rtl92c_dm_initialize_txpower_tracking(hw); | ||
1446 | rtl92c_dm_init_dynamic_bb_powersaving(hw); | ||
1447 | } | ||
1448 | |||
1449 | void rtl92c_dm_watchdog(struct ieee80211_hw *hw) | ||
1450 | { | ||
1451 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1452 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | ||
1453 | bool b_fw_current_inpsmode = false; | ||
1454 | bool b_fw_ps_awake = true; | ||
1455 | |||
1456 | rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, | ||
1457 | (u8 *) (&b_fw_current_inpsmode)); | ||
1458 | rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FWLPS_RF_ON, | ||
1459 | (u8 *) (&b_fw_ps_awake)); | ||
1460 | |||
1461 | if ((ppsc->rfpwr_state == ERFON) && ((!b_fw_current_inpsmode) && | ||
1462 | b_fw_ps_awake) | ||
1463 | && (!ppsc->rfchange_inprogress)) { | ||
1464 | rtl92c_dm_pwdb_monitor(hw); | ||
1465 | rtl92c_dm_dig(hw); | ||
1466 | rtl92c_dm_false_alarm_counter_statistics(hw); | ||
1467 | rtl92c_dm_dynamic_bb_powersaving(hw); | ||
1468 | rtl92c_dm_dynamic_txpower(hw); | ||
1469 | rtl92c_dm_check_txpower_tracking(hw); | ||
1470 | rtl92c_dm_refresh_rate_adaptive_mask(hw); | ||
1471 | rtl92c_dm_check_edca_turbo(hw); | ||
1472 | } | ||
1473 | } | ||
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h index 463439e4074c..5911d52a24ac 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h | |||
@@ -192,5 +192,6 @@ void rtl92c_dm_init_edca_turbo(struct ieee80211_hw *hw); | |||
192 | void rtl92c_dm_check_txpower_tracking(struct ieee80211_hw *hw); | 192 | void rtl92c_dm_check_txpower_tracking(struct ieee80211_hw *hw); |
193 | void rtl92c_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw); | 193 | void rtl92c_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw); |
194 | void rtl92c_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal); | 194 | void rtl92c_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal); |
195 | void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw); | ||
195 | 196 | ||
196 | #endif | 197 | #endif |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/fw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/fw.c index 11dd22b987e7..11c8bdb4af59 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/fw.c | |||
@@ -133,17 +133,15 @@ static void _rtl92c_write_fw(struct ieee80211_hw *hw, | |||
133 | { | 133 | { |
134 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 134 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
135 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | 135 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); |
136 | bool is_version_b; | ||
137 | u8 *bufferPtr = (u8 *) buffer; | 136 | u8 *bufferPtr = (u8 *) buffer; |
138 | 137 | ||
139 | RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, ("FW size is %d bytes,\n", size)); | 138 | RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, ("FW size is %d bytes,\n", size)); |
140 | 139 | ||
141 | is_version_b = IS_CHIP_VER_B(version); | 140 | if (IS_CHIP_VER_B(version)) { |
142 | if (is_version_b) { | ||
143 | u32 pageNums, remainSize; | 141 | u32 pageNums, remainSize; |
144 | u32 page, offset; | 142 | u32 page, offset; |
145 | 143 | ||
146 | if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CE) | 144 | if (IS_HARDWARE_TYPE_8192CE(rtlhal)) |
147 | _rtl92c_fill_dummy(bufferPtr, &size); | 145 | _rtl92c_fill_dummy(bufferPtr, &size); |
148 | 146 | ||
149 | pageNums = size / FW_8192C_PAGE_SIZE; | 147 | pageNums = size / FW_8192C_PAGE_SIZE; |
@@ -231,14 +229,14 @@ int rtl92c_download_fw(struct ieee80211_hw *hw) | |||
231 | u32 fwsize; | 229 | u32 fwsize; |
232 | int err; | 230 | int err; |
233 | enum version_8192c version = rtlhal->version; | 231 | enum version_8192c version = rtlhal->version; |
232 | const struct firmware *firmware; | ||
234 | 233 | ||
235 | const struct firmware *firmware = NULL; | 234 | printk(KERN_INFO "rtl8192cu: Loading firmware file %s\n", |
236 | 235 | rtlpriv->cfg->fw_name); | |
237 | err = request_firmware(&firmware, rtlpriv->cfg->fw_name, | 236 | err = request_firmware(&firmware, rtlpriv->cfg->fw_name, |
238 | rtlpriv->io.dev); | 237 | rtlpriv->io.dev); |
239 | if (err) { | 238 | if (err) { |
240 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | 239 | printk(KERN_ERR "rtl8192cu: Firmware loading failed\n"); |
241 | ("Failed to request firmware!\n")); | ||
242 | return 1; | 240 | return 1; |
243 | } | 241 | } |
244 | 242 | ||
@@ -318,12 +316,12 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, | |||
318 | 316 | ||
319 | while (true) { | 317 | while (true) { |
320 | spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); | 318 | spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); |
321 | if (rtlhal->b_h2c_setinprogress) { | 319 | if (rtlhal->h2c_setinprogress) { |
322 | RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | 320 | RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, |
323 | ("H2C set in progress! Wait to set.." | 321 | ("H2C set in progress! Wait to set.." |
324 | "element_id(%d).\n", element_id)); | 322 | "element_id(%d).\n", element_id)); |
325 | 323 | ||
326 | while (rtlhal->b_h2c_setinprogress) { | 324 | while (rtlhal->h2c_setinprogress) { |
327 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, | 325 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, |
328 | flag); | 326 | flag); |
329 | h2c_waitcounter++; | 327 | h2c_waitcounter++; |
@@ -339,7 +337,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, | |||
339 | } | 337 | } |
340 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); | 338 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); |
341 | } else { | 339 | } else { |
342 | rtlhal->b_h2c_setinprogress = true; | 340 | rtlhal->h2c_setinprogress = true; |
343 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); | 341 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); |
344 | break; | 342 | break; |
345 | } | 343 | } |
@@ -495,7 +493,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, | |||
495 | } | 493 | } |
496 | 494 | ||
497 | spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); | 495 | spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); |
498 | rtlhal->b_h2c_setinprogress = false; | 496 | rtlhal->h2c_setinprogress = false; |
499 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); | 497 | spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); |
500 | 498 | ||
501 | RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("go out\n")); | 499 | RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("go out\n")); |
@@ -507,7 +505,7 @@ void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, | |||
507 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | 505 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); |
508 | u32 tmp_cmdbuf[2]; | 506 | u32 tmp_cmdbuf[2]; |
509 | 507 | ||
510 | if (rtlhal->bfw_ready == false) { | 508 | if (rtlhal->fw_ready == false) { |
511 | RT_ASSERT(false, ("return H2C cmd because of Fw " | 509 | RT_ASSERT(false, ("return H2C cmd because of Fw " |
512 | "download fail!!!\n")); | 510 | "download fail!!!\n")); |
513 | return; | 511 | return; |
@@ -560,39 +558,6 @@ void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) | |||
560 | 558 | ||
561 | } | 559 | } |
562 | 560 | ||
563 | static bool _rtl92c_cmd_send_packet(struct ieee80211_hw *hw, | ||
564 | struct sk_buff *skb) | ||
565 | { | ||
566 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
567 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||
568 | struct rtl8192_tx_ring *ring; | ||
569 | struct rtl_tx_desc *pdesc; | ||
570 | u8 own; | ||
571 | unsigned long flags; | ||
572 | struct sk_buff *pskb = NULL; | ||
573 | |||
574 | ring = &rtlpci->tx_ring[BEACON_QUEUE]; | ||
575 | |||
576 | pskb = __skb_dequeue(&ring->queue); | ||
577 | if (pskb) | ||
578 | kfree_skb(pskb); | ||
579 | |||
580 | spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); | ||
581 | |||
582 | pdesc = &ring->desc[0]; | ||
583 | own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, true, HW_DESC_OWN); | ||
584 | |||
585 | rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *) pdesc, 1, 1, skb); | ||
586 | |||
587 | __skb_queue_tail(&ring->queue, skb); | ||
588 | |||
589 | spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); | ||
590 | |||
591 | rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE); | ||
592 | |||
593 | return true; | ||
594 | } | ||
595 | |||
596 | #define BEACON_PG 0 /*->1*/ | 561 | #define BEACON_PG 0 /*->1*/ |
597 | #define PSPOLL_PG 2 | 562 | #define PSPOLL_PG 2 |
598 | #define NULL_PG 3 | 563 | #define NULL_PG 3 |
@@ -776,7 +741,7 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) | |||
776 | memcpy((u8 *) skb_put(skb, totalpacketlen), | 741 | memcpy((u8 *) skb_put(skb, totalpacketlen), |
777 | &reserved_page_packet, totalpacketlen); | 742 | &reserved_page_packet, totalpacketlen); |
778 | 743 | ||
779 | rtstatus = _rtl92c_cmd_send_packet(hw, skb); | 744 | rtstatus = rtlpriv->cfg->ops->cmd_send_packet(hw, skb); |
780 | 745 | ||
781 | if (rtstatus) | 746 | if (rtstatus) |
782 | b_dlok = true; | 747 | b_dlok = true; |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 1c41a0c93506..0b910921e606 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | |||
@@ -124,7 +124,7 @@ void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) | |||
124 | break; | 124 | break; |
125 | } | 125 | } |
126 | case HW_VAR_FW_PSMODE_STATUS: | 126 | case HW_VAR_FW_PSMODE_STATUS: |
127 | *((bool *) (val)) = ppsc->b_fw_current_inpsmode; | 127 | *((bool *) (val)) = ppsc->fw_current_inpsmode; |
128 | break; | 128 | break; |
129 | case HW_VAR_CORRECT_TSF:{ | 129 | case HW_VAR_CORRECT_TSF:{ |
130 | u64 tsf; | 130 | u64 tsf; |
@@ -173,15 +173,15 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) | |||
173 | break; | 173 | break; |
174 | } | 174 | } |
175 | case HW_VAR_BASIC_RATE:{ | 175 | case HW_VAR_BASIC_RATE:{ |
176 | u16 b_rate_cfg = ((u16 *) val)[0]; | 176 | u16 rate_cfg = ((u16 *) val)[0]; |
177 | u8 rate_index = 0; | 177 | u8 rate_index = 0; |
178 | b_rate_cfg = b_rate_cfg & 0x15f; | 178 | rate_cfg &= 0x15f; |
179 | b_rate_cfg |= 0x01; | 179 | rate_cfg |= 0x01; |
180 | rtl_write_byte(rtlpriv, REG_RRSR, b_rate_cfg & 0xff); | 180 | rtl_write_byte(rtlpriv, REG_RRSR, rate_cfg & 0xff); |
181 | rtl_write_byte(rtlpriv, REG_RRSR + 1, | 181 | rtl_write_byte(rtlpriv, REG_RRSR + 1, |
182 | (b_rate_cfg >> 8)&0xff); | 182 | (rate_cfg >> 8)&0xff); |
183 | while (b_rate_cfg > 0x1) { | 183 | while (rate_cfg > 0x1) { |
184 | b_rate_cfg = (b_rate_cfg >> 1); | 184 | rate_cfg = (rate_cfg >> 1); |
185 | rate_index++; | 185 | rate_index++; |
186 | } | 186 | } |
187 | rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL, | 187 | rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL, |
@@ -318,15 +318,17 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) | |||
318 | } | 318 | } |
319 | case HW_VAR_AC_PARAM:{ | 319 | case HW_VAR_AC_PARAM:{ |
320 | u8 e_aci = *((u8 *) val); | 320 | u8 e_aci = *((u8 *) val); |
321 | u32 u4b_ac_param = 0; | 321 | u32 u4b_ac_param; |
322 | u16 cw_min = le16_to_cpu(mac->ac[e_aci].cw_min); | ||
323 | u16 cw_max = le16_to_cpu(mac->ac[e_aci].cw_max); | ||
324 | u16 tx_op = le16_to_cpu(mac->ac[e_aci].tx_op); | ||
322 | 325 | ||
323 | u4b_ac_param |= (u32) mac->ac[e_aci].aifs; | 326 | u4b_ac_param = (u32) mac->ac[e_aci].aifs; |
324 | u4b_ac_param |= ((u32) mac->ac[e_aci].cw_min | 327 | u4b_ac_param |= ((u32)cw_min |
325 | & 0xF) << AC_PARAM_ECW_MIN_OFFSET; | 328 | & 0xF) << AC_PARAM_ECW_MIN_OFFSET; |
326 | u4b_ac_param |= ((u32) mac->ac[e_aci].cw_max & | 329 | u4b_ac_param |= ((u32)cw_max & |
327 | 0xF) << AC_PARAM_ECW_MAX_OFFSET; | 330 | 0xF) << AC_PARAM_ECW_MAX_OFFSET; |
328 | u4b_ac_param |= (u32) mac->ac[e_aci].tx_op | 331 | u4b_ac_param |= (u32)tx_op << AC_PARAM_TXOP_OFFSET; |
329 | << AC_PARAM_TXOP_LIMIT_OFFSET; | ||
330 | 332 | ||
331 | RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, | 333 | RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, |
332 | ("queue:%x, ac_param:%x\n", e_aci, | 334 | ("queue:%x, ac_param:%x\n", e_aci, |
@@ -469,12 +471,12 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) | |||
469 | break; | 471 | break; |
470 | } | 472 | } |
471 | case HW_VAR_FW_PSMODE_STATUS: | 473 | case HW_VAR_FW_PSMODE_STATUS: |
472 | ppsc->b_fw_current_inpsmode = *((bool *) val); | 474 | ppsc->fw_current_inpsmode = *((bool *) val); |
473 | break; | 475 | break; |
474 | case HW_VAR_H2C_FW_JOINBSSRPT:{ | 476 | case HW_VAR_H2C_FW_JOINBSSRPT:{ |
475 | u8 mstatus = (*(u8 *) val); | 477 | u8 mstatus = (*(u8 *) val); |
476 | u8 tmp_regcr, tmp_reg422; | 478 | u8 tmp_regcr, tmp_reg422; |
477 | bool b_recover = false; | 479 | bool recover = false; |
478 | 480 | ||
479 | if (mstatus == RT_MEDIA_CONNECT) { | 481 | if (mstatus == RT_MEDIA_CONNECT) { |
480 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID, | 482 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID, |
@@ -491,7 +493,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) | |||
491 | rtl_read_byte(rtlpriv, | 493 | rtl_read_byte(rtlpriv, |
492 | REG_FWHW_TXQ_CTRL + 2); | 494 | REG_FWHW_TXQ_CTRL + 2); |
493 | if (tmp_reg422 & BIT(6)) | 495 | if (tmp_reg422 & BIT(6)) |
494 | b_recover = true; | 496 | recover = true; |
495 | rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, | 497 | rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, |
496 | tmp_reg422 & (~BIT(6))); | 498 | tmp_reg422 & (~BIT(6))); |
497 | 499 | ||
@@ -500,7 +502,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) | |||
500 | _rtl92ce_set_bcn_ctrl_reg(hw, BIT(3), 0); | 502 | _rtl92ce_set_bcn_ctrl_reg(hw, BIT(3), 0); |
501 | _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(4)); | 503 | _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(4)); |
502 | 504 | ||
503 | if (b_recover) { | 505 | if (recover) { |
504 | rtl_write_byte(rtlpriv, | 506 | rtl_write_byte(rtlpriv, |
505 | REG_FWHW_TXQ_CTRL + 2, | 507 | REG_FWHW_TXQ_CTRL + 2, |
506 | tmp_reg422); | 508 | tmp_reg422); |
@@ -868,7 +870,7 @@ static void _rtl92ce_enable_aspm_back_door(struct ieee80211_hw *hw) | |||
868 | rtl_write_word(rtlpriv, 0x350, 0x870c); | 870 | rtl_write_word(rtlpriv, 0x350, 0x870c); |
869 | rtl_write_byte(rtlpriv, 0x352, 0x1); | 871 | rtl_write_byte(rtlpriv, 0x352, 0x1); |
870 | 872 | ||
871 | if (ppsc->b_support_backdoor) | 873 | if (ppsc->support_backdoor) |
872 | rtl_write_byte(rtlpriv, 0x349, 0x1b); | 874 | rtl_write_byte(rtlpriv, 0x349, 0x1b); |
873 | else | 875 | else |
874 | rtl_write_byte(rtlpriv, 0x349, 0x03); | 876 | rtl_write_byte(rtlpriv, 0x349, 0x03); |
@@ -940,10 +942,10 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw) | |||
940 | ("Failed to download FW. Init HW " | 942 | ("Failed to download FW. Init HW " |
941 | "without FW now..\n")); | 943 | "without FW now..\n")); |
942 | err = 1; | 944 | err = 1; |
943 | rtlhal->bfw_ready = false; | 945 | rtlhal->fw_ready = false; |
944 | return err; | 946 | return err; |
945 | } else { | 947 | } else { |
946 | rtlhal->bfw_ready = true; | 948 | rtlhal->fw_ready = true; |
947 | } | 949 | } |
948 | 950 | ||
949 | rtlhal->last_hmeboxnum = 0; | 951 | rtlhal->last_hmeboxnum = 0; |
@@ -1170,21 +1172,20 @@ void rtl92ce_set_qos(struct ieee80211_hw *hw, int aci) | |||
1170 | { | 1172 | { |
1171 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1173 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
1172 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 1174 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
1173 | |||
1174 | u32 u4b_ac_param; | 1175 | u32 u4b_ac_param; |
1176 | u16 cw_min = le16_to_cpu(mac->ac[aci].cw_min); | ||
1177 | u16 cw_max = le16_to_cpu(mac->ac[aci].cw_max); | ||
1178 | u16 tx_op = le16_to_cpu(mac->ac[aci].tx_op); | ||
1175 | 1179 | ||
1176 | rtl92c_dm_init_edca_turbo(hw); | 1180 | rtl92c_dm_init_edca_turbo(hw); |
1177 | |||
1178 | u4b_ac_param = (u32) mac->ac[aci].aifs; | 1181 | u4b_ac_param = (u32) mac->ac[aci].aifs; |
1179 | u4b_ac_param |= | 1182 | u4b_ac_param |= (u32) ((cw_min & 0xF) << AC_PARAM_ECW_MIN_OFFSET); |
1180 | ((u32) mac->ac[aci].cw_min & 0xF) << AC_PARAM_ECW_MIN_OFFSET; | 1183 | u4b_ac_param |= (u32) ((cw_max & 0xF) << AC_PARAM_ECW_MAX_OFFSET); |
1181 | u4b_ac_param |= | 1184 | u4b_ac_param |= (u32) (tx_op << AC_PARAM_TXOP_OFFSET); |
1182 | ((u32) mac->ac[aci].cw_max & 0xF) << AC_PARAM_ECW_MAX_OFFSET; | ||
1183 | u4b_ac_param |= (u32) mac->ac[aci].tx_op << AC_PARAM_TXOP_LIMIT_OFFSET; | ||
1184 | RT_TRACE(rtlpriv, COMP_QOS, DBG_DMESG, | 1185 | RT_TRACE(rtlpriv, COMP_QOS, DBG_DMESG, |
1185 | ("queue:%x, ac_param:%x aifs:%x cwmin:%x cwmax:%x txop:%x\n", | 1186 | ("queue:%x, ac_param:%x aifs:%x cwmin:%x cwmax:%x txop:%x\n", |
1186 | aci, u4b_ac_param, mac->ac[aci].aifs, mac->ac[aci].cw_min, | 1187 | aci, u4b_ac_param, mac->ac[aci].aifs, cw_min, |
1187 | mac->ac[aci].cw_max, mac->ac[aci].tx_op)); | 1188 | cw_max, tx_op)); |
1188 | switch (aci) { | 1189 | switch (aci) { |
1189 | case AC1_BK: | 1190 | case AC1_BK: |
1190 | rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, u4b_ac_param); | 1191 | rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, u4b_ac_param); |
@@ -1237,7 +1238,7 @@ static void _rtl92ce_poweroff_adapter(struct ieee80211_hw *hw) | |||
1237 | rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); | 1238 | rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); |
1238 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); | 1239 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); |
1239 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE0); | 1240 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE0); |
1240 | if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) && rtlhal->bfw_ready) | 1241 | if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) && rtlhal->fw_ready) |
1241 | rtl92c_firmware_selfreset(hw); | 1242 | rtl92c_firmware_selfreset(hw); |
1242 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, 0x51); | 1243 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, 0x51); |
1243 | rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); | 1244 | rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); |
@@ -1335,19 +1336,6 @@ void rtl92ce_update_interrupt_mask(struct ieee80211_hw *hw, | |||
1335 | rtl92ce_enable_interrupt(hw); | 1336 | rtl92ce_enable_interrupt(hw); |
1336 | } | 1337 | } |
1337 | 1338 | ||
1338 | static u8 _rtl92c_get_chnl_group(u8 chnl) | ||
1339 | { | ||
1340 | u8 group; | ||
1341 | |||
1342 | if (chnl < 3) | ||
1343 | group = 0; | ||
1344 | else if (chnl < 9) | ||
1345 | group = 1; | ||
1346 | else | ||
1347 | group = 2; | ||
1348 | return group; | ||
1349 | } | ||
1350 | |||
1351 | static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, | 1339 | static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, |
1352 | bool autoload_fail, | 1340 | bool autoload_fail, |
1353 | u8 *hwinfo) | 1341 | u8 *hwinfo) |
@@ -1568,7 +1556,7 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, | |||
1568 | rtlefuse->eeprom_thermalmeter = (tempval & 0x1f); | 1556 | rtlefuse->eeprom_thermalmeter = (tempval & 0x1f); |
1569 | 1557 | ||
1570 | if (rtlefuse->eeprom_thermalmeter == 0x1f || autoload_fail) | 1558 | if (rtlefuse->eeprom_thermalmeter == 0x1f || autoload_fail) |
1571 | rtlefuse->b_apk_thermalmeterignore = true; | 1559 | rtlefuse->apk_thermalmeterignore = true; |
1572 | 1560 | ||
1573 | rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; | 1561 | rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; |
1574 | RTPRINT(rtlpriv, FINIT, INIT_TxPower, | 1562 | RTPRINT(rtlpriv, FINIT, INIT_TxPower, |
@@ -1625,7 +1613,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) | |||
1625 | 1613 | ||
1626 | rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN]; | 1614 | rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN]; |
1627 | rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; | 1615 | rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; |
1628 | rtlefuse->b_txpwr_fromeprom = true; | 1616 | rtlefuse->txpwr_fromeprom = true; |
1629 | rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; | 1617 | rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; |
1630 | 1618 | ||
1631 | RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, | 1619 | RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
@@ -1668,7 +1656,7 @@ static void _rtl92ce_hal_customized_behavior(struct ieee80211_hw *hw) | |||
1668 | 1656 | ||
1669 | switch (rtlhal->oem_id) { | 1657 | switch (rtlhal->oem_id) { |
1670 | case RT_CID_819x_HP: | 1658 | case RT_CID_819x_HP: |
1671 | pcipriv->ledctl.bled_opendrain = true; | 1659 | pcipriv->ledctl.led_opendrain = true; |
1672 | break; | 1660 | break; |
1673 | case RT_CID_819x_Lenovo: | 1661 | case RT_CID_819x_Lenovo: |
1674 | case RT_CID_DEFAULT: | 1662 | case RT_CID_DEFAULT: |
@@ -1693,10 +1681,10 @@ void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw) | |||
1693 | 1681 | ||
1694 | rtlhal->version = _rtl92ce_read_chip_version(hw); | 1682 | rtlhal->version = _rtl92ce_read_chip_version(hw); |
1695 | if (get_rf_type(rtlphy) == RF_1T1R) | 1683 | if (get_rf_type(rtlphy) == RF_1T1R) |
1696 | rtlpriv->dm.brfpath_rxenable[0] = true; | 1684 | rtlpriv->dm.rfpath_rxenable[0] = true; |
1697 | else | 1685 | else |
1698 | rtlpriv->dm.brfpath_rxenable[0] = | 1686 | rtlpriv->dm.rfpath_rxenable[0] = |
1699 | rtlpriv->dm.brfpath_rxenable[1] = true; | 1687 | rtlpriv->dm.rfpath_rxenable[1] = true; |
1700 | RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("VersionID = 0x%4x\n", | 1688 | RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("VersionID = 0x%4x\n", |
1701 | rtlhal->version)); | 1689 | rtlhal->version)); |
1702 | tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); | 1690 | tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); |
@@ -1725,18 +1713,18 @@ void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw) | |||
1725 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 1713 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
1726 | 1714 | ||
1727 | u32 ratr_value = (u32) mac->basic_rates; | 1715 | u32 ratr_value = (u32) mac->basic_rates; |
1728 | u8 *p_mcsrate = mac->mcs; | 1716 | u8 *mcsrate = mac->mcs; |
1729 | u8 ratr_index = 0; | 1717 | u8 ratr_index = 0; |
1730 | u8 b_nmode = mac->ht_enable; | 1718 | u8 nmode = mac->ht_enable; |
1731 | u8 mimo_ps = 1; | 1719 | u8 mimo_ps = 1; |
1732 | u16 shortgi_rate; | 1720 | u16 shortgi_rate; |
1733 | u32 tmp_ratr_value; | 1721 | u32 tmp_ratr_value; |
1734 | u8 b_curtxbw_40mhz = mac->bw_40; | 1722 | u8 curtxbw_40mhz = mac->bw_40; |
1735 | u8 b_curshortgi_40mhz = mac->sgi_40; | 1723 | u8 curshortgi_40mhz = mac->sgi_40; |
1736 | u8 b_curshortgi_20mhz = mac->sgi_20; | 1724 | u8 curshortgi_20mhz = mac->sgi_20; |
1737 | enum wireless_mode wirelessmode = mac->mode; | 1725 | enum wireless_mode wirelessmode = mac->mode; |
1738 | 1726 | ||
1739 | ratr_value |= EF2BYTE((*(u16 *) (p_mcsrate))) << 12; | 1727 | ratr_value |= ((*(u16 *) (mcsrate))) << 12; |
1740 | 1728 | ||
1741 | switch (wirelessmode) { | 1729 | switch (wirelessmode) { |
1742 | case WIRELESS_MODE_B: | 1730 | case WIRELESS_MODE_B: |
@@ -1750,7 +1738,7 @@ void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw) | |||
1750 | break; | 1738 | break; |
1751 | case WIRELESS_MODE_N_24G: | 1739 | case WIRELESS_MODE_N_24G: |
1752 | case WIRELESS_MODE_N_5G: | 1740 | case WIRELESS_MODE_N_5G: |
1753 | b_nmode = 1; | 1741 | nmode = 1; |
1754 | if (mimo_ps == 0) { | 1742 | if (mimo_ps == 0) { |
1755 | ratr_value &= 0x0007F005; | 1743 | ratr_value &= 0x0007F005; |
1756 | } else { | 1744 | } else { |
@@ -1776,9 +1764,8 @@ void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw) | |||
1776 | 1764 | ||
1777 | ratr_value &= 0x0FFFFFFF; | 1765 | ratr_value &= 0x0FFFFFFF; |
1778 | 1766 | ||
1779 | if (b_nmode && ((b_curtxbw_40mhz && | 1767 | if (nmode && ((curtxbw_40mhz && curshortgi_40mhz) || (!curtxbw_40mhz && |
1780 | b_curshortgi_40mhz) || (!b_curtxbw_40mhz && | 1768 | curshortgi_20mhz))) { |
1781 | b_curshortgi_20mhz))) { | ||
1782 | 1769 | ||
1783 | ratr_value |= 0x10000000; | 1770 | ratr_value |= 0x10000000; |
1784 | tmp_ratr_value = (ratr_value >> 12); | 1771 | tmp_ratr_value = (ratr_value >> 12); |
@@ -1806,11 +1793,11 @@ void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
1806 | u32 ratr_bitmap = (u32) mac->basic_rates; | 1793 | u32 ratr_bitmap = (u32) mac->basic_rates; |
1807 | u8 *p_mcsrate = mac->mcs; | 1794 | u8 *p_mcsrate = mac->mcs; |
1808 | u8 ratr_index; | 1795 | u8 ratr_index; |
1809 | u8 b_curtxbw_40mhz = mac->bw_40; | 1796 | u8 curtxbw_40mhz = mac->bw_40; |
1810 | u8 b_curshortgi_40mhz = mac->sgi_40; | 1797 | u8 curshortgi_40mhz = mac->sgi_40; |
1811 | u8 b_curshortgi_20mhz = mac->sgi_20; | 1798 | u8 curshortgi_20mhz = mac->sgi_20; |
1812 | enum wireless_mode wirelessmode = mac->mode; | 1799 | enum wireless_mode wirelessmode = mac->mode; |
1813 | bool b_shortgi = false; | 1800 | bool shortgi = false; |
1814 | u8 rate_mask[5]; | 1801 | u8 rate_mask[5]; |
1815 | u8 macid = 0; | 1802 | u8 macid = 0; |
1816 | u8 mimops = 1; | 1803 | u8 mimops = 1; |
@@ -1852,7 +1839,7 @@ void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
1852 | } else { | 1839 | } else { |
1853 | if (rtlphy->rf_type == RF_1T2R || | 1840 | if (rtlphy->rf_type == RF_1T2R || |
1854 | rtlphy->rf_type == RF_1T1R) { | 1841 | rtlphy->rf_type == RF_1T1R) { |
1855 | if (b_curtxbw_40mhz) { | 1842 | if (curtxbw_40mhz) { |
1856 | if (rssi_level == 1) | 1843 | if (rssi_level == 1) |
1857 | ratr_bitmap &= 0x000f0000; | 1844 | ratr_bitmap &= 0x000f0000; |
1858 | else if (rssi_level == 2) | 1845 | else if (rssi_level == 2) |
@@ -1868,7 +1855,7 @@ void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
1868 | ratr_bitmap &= 0x000ff005; | 1855 | ratr_bitmap &= 0x000ff005; |
1869 | } | 1856 | } |
1870 | } else { | 1857 | } else { |
1871 | if (b_curtxbw_40mhz) { | 1858 | if (curtxbw_40mhz) { |
1872 | if (rssi_level == 1) | 1859 | if (rssi_level == 1) |
1873 | ratr_bitmap &= 0x0f0f0000; | 1860 | ratr_bitmap &= 0x0f0f0000; |
1874 | else if (rssi_level == 2) | 1861 | else if (rssi_level == 2) |
@@ -1886,13 +1873,13 @@ void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
1886 | } | 1873 | } |
1887 | } | 1874 | } |
1888 | 1875 | ||
1889 | if ((b_curtxbw_40mhz && b_curshortgi_40mhz) || | 1876 | if ((curtxbw_40mhz && curshortgi_40mhz) || |
1890 | (!b_curtxbw_40mhz && b_curshortgi_20mhz)) { | 1877 | (!curtxbw_40mhz && curshortgi_20mhz)) { |
1891 | 1878 | ||
1892 | if (macid == 0) | 1879 | if (macid == 0) |
1893 | b_shortgi = true; | 1880 | shortgi = true; |
1894 | else if (macid == 1) | 1881 | else if (macid == 1) |
1895 | b_shortgi = false; | 1882 | shortgi = false; |
1896 | } | 1883 | } |
1897 | break; | 1884 | break; |
1898 | default: | 1885 | default: |
@@ -1906,9 +1893,9 @@ void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
1906 | } | 1893 | } |
1907 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, | 1894 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, |
1908 | ("ratr_bitmap :%x\n", ratr_bitmap)); | 1895 | ("ratr_bitmap :%x\n", ratr_bitmap)); |
1909 | *(u32 *)&rate_mask = EF4BYTE((ratr_bitmap & 0x0fffffff) | | 1896 | *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) | |
1910 | (ratr_index << 28)); | 1897 | (ratr_index << 28); |
1911 | rate_mask[4] = macid | (b_shortgi ? 0x20 : 0x00) | 0x80; | 1898 | rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; |
1912 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("Rate_index:%x, " | 1899 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("Rate_index:%x, " |
1913 | "ratr_val:%x, %x:%x:%x:%x:%x\n", | 1900 | "ratr_val:%x, %x:%x:%x:%x:%x\n", |
1914 | ratr_index, ratr_bitmap, | 1901 | ratr_index, ratr_bitmap, |
@@ -1940,13 +1927,13 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid) | |||
1940 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 1927 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
1941 | enum rf_pwrstate e_rfpowerstate_toset, cur_rfstate; | 1928 | enum rf_pwrstate e_rfpowerstate_toset, cur_rfstate; |
1942 | u8 u1tmp; | 1929 | u8 u1tmp; |
1943 | bool b_actuallyset = false; | 1930 | bool actuallyset = false; |
1944 | unsigned long flag; | 1931 | unsigned long flag; |
1945 | 1932 | ||
1946 | if ((rtlpci->up_first_time == 1) || (rtlpci->being_init_adapter)) | 1933 | if ((rtlpci->up_first_time == 1) || (rtlpci->being_init_adapter)) |
1947 | return false; | 1934 | return false; |
1948 | 1935 | ||
1949 | if (ppsc->b_swrf_processing) | 1936 | if (ppsc->swrf_processing) |
1950 | return false; | 1937 | return false; |
1951 | 1938 | ||
1952 | spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); | 1939 | spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); |
@@ -1972,24 +1959,24 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid) | |||
1972 | u1tmp = rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL); | 1959 | u1tmp = rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL); |
1973 | e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF; | 1960 | e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF; |
1974 | 1961 | ||
1975 | if ((ppsc->b_hwradiooff == true) && (e_rfpowerstate_toset == ERFON)) { | 1962 | if ((ppsc->hwradiooff == true) && (e_rfpowerstate_toset == ERFON)) { |
1976 | RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, | 1963 | RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, |
1977 | ("GPIOChangeRF - HW Radio ON, RF ON\n")); | 1964 | ("GPIOChangeRF - HW Radio ON, RF ON\n")); |
1978 | 1965 | ||
1979 | e_rfpowerstate_toset = ERFON; | 1966 | e_rfpowerstate_toset = ERFON; |
1980 | ppsc->b_hwradiooff = false; | 1967 | ppsc->hwradiooff = false; |
1981 | b_actuallyset = true; | 1968 | actuallyset = true; |
1982 | } else if ((ppsc->b_hwradiooff == false) | 1969 | } else if ((ppsc->hwradiooff == false) |
1983 | && (e_rfpowerstate_toset == ERFOFF)) { | 1970 | && (e_rfpowerstate_toset == ERFOFF)) { |
1984 | RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, | 1971 | RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, |
1985 | ("GPIOChangeRF - HW Radio OFF, RF OFF\n")); | 1972 | ("GPIOChangeRF - HW Radio OFF, RF OFF\n")); |
1986 | 1973 | ||
1987 | e_rfpowerstate_toset = ERFOFF; | 1974 | e_rfpowerstate_toset = ERFOFF; |
1988 | ppsc->b_hwradiooff = true; | 1975 | ppsc->hwradiooff = true; |
1989 | b_actuallyset = true; | 1976 | actuallyset = true; |
1990 | } | 1977 | } |
1991 | 1978 | ||
1992 | if (b_actuallyset) { | 1979 | if (actuallyset) { |
1993 | if (e_rfpowerstate_toset == ERFON) { | 1980 | if (e_rfpowerstate_toset == ERFON) { |
1994 | if ((ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM) && | 1981 | if ((ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM) && |
1995 | RT_IN_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_ASPM)) { | 1982 | RT_IN_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_ASPM)) { |
@@ -2028,7 +2015,7 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid) | |||
2028 | } | 2015 | } |
2029 | 2016 | ||
2030 | *valid = 1; | 2017 | *valid = 1; |
2031 | return !ppsc->b_hwradiooff; | 2018 | return !ppsc->hwradiooff; |
2032 | 2019 | ||
2033 | } | 2020 | } |
2034 | 2021 | ||
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c index 78a0569208ea..7b1da8d7508f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c | |||
@@ -57,7 +57,7 @@ void rtl92ce_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) | |||
57 | ("switch case not process\n")); | 57 | ("switch case not process\n")); |
58 | break; | 58 | break; |
59 | } | 59 | } |
60 | pled->b_ledon = true; | 60 | pled->ledon = true; |
61 | } | 61 | } |
62 | 62 | ||
63 | void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) | 63 | void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) |
@@ -76,7 +76,7 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) | |||
76 | break; | 76 | break; |
77 | case LED_PIN_LED0: | 77 | case LED_PIN_LED0: |
78 | ledcfg &= 0xf0; | 78 | ledcfg &= 0xf0; |
79 | if (pcipriv->ledctl.bled_opendrain == true) | 79 | if (pcipriv->ledctl.led_opendrain == true) |
80 | rtl_write_byte(rtlpriv, REG_LEDCFG2, | 80 | rtl_write_byte(rtlpriv, REG_LEDCFG2, |
81 | (ledcfg | BIT(1) | BIT(5) | BIT(6))); | 81 | (ledcfg | BIT(1) | BIT(5) | BIT(6))); |
82 | else | 82 | else |
@@ -92,7 +92,7 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) | |||
92 | ("switch case not process\n")); | 92 | ("switch case not process\n")); |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | pled->b_ledon = false; | 95 | pled->ledon = false; |
96 | } | 96 | } |
97 | 97 | ||
98 | void rtl92ce_init_sw_leds(struct ieee80211_hw *hw) | 98 | void rtl92ce_init_sw_leds(struct ieee80211_hw *hw) |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c index 45044117139a..191106033b3c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | |||
@@ -37,82 +37,7 @@ | |||
37 | #include "dm.h" | 37 | #include "dm.h" |
38 | #include "table.h" | 38 | #include "table.h" |
39 | 39 | ||
40 | static u32 _rtl92c_phy_fw_rf_serial_read(struct ieee80211_hw *hw, | 40 | #include "../rtl8192c/phy_common.c" |
41 | enum radio_path rfpath, u32 offset); | ||
42 | static void _rtl92c_phy_fw_rf_serial_write(struct ieee80211_hw *hw, | ||
43 | enum radio_path rfpath, u32 offset, | ||
44 | u32 data); | ||
45 | static u32 _rtl92c_phy_rf_serial_read(struct ieee80211_hw *hw, | ||
46 | enum radio_path rfpath, u32 offset); | ||
47 | static void _rtl92c_phy_rf_serial_write(struct ieee80211_hw *hw, | ||
48 | enum radio_path rfpath, u32 offset, | ||
49 | u32 data); | ||
50 | static u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask); | ||
51 | static bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw); | ||
52 | static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw); | ||
53 | static bool _rtl92c_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, | ||
54 | u8 configtype); | ||
55 | static bool _rtl92c_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, | ||
56 | u8 configtype); | ||
57 | static void _rtl92c_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw); | ||
58 | static bool _rtl92c_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, | ||
59 | u32 cmdtableidx, u32 cmdtablesz, | ||
60 | enum swchnlcmd_id cmdid, u32 para1, | ||
61 | u32 para2, u32 msdelay); | ||
62 | static bool _rtl92c_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, | ||
63 | u8 channel, u8 *stage, u8 *step, | ||
64 | u32 *delay); | ||
65 | static u8 _rtl92c_phy_dbm_to_txpwr_Idx(struct ieee80211_hw *hw, | ||
66 | enum wireless_mode wirelessmode, | ||
67 | long power_indbm); | ||
68 | static bool _rtl92c_phy_config_rf_external_pa(struct ieee80211_hw *hw, | ||
69 | enum radio_path rfpath); | ||
70 | static long _rtl92c_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw, | ||
71 | enum wireless_mode wirelessmode, | ||
72 | u8 txpwridx); | ||
73 | u32 rtl92c_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask) | ||
74 | { | ||
75 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
76 | u32 returnvalue, originalvalue, bitshift; | ||
77 | |||
78 | RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " | ||
79 | "bitmask(%#x)\n", regaddr, | ||
80 | bitmask)); | ||
81 | originalvalue = rtl_read_dword(rtlpriv, regaddr); | ||
82 | bitshift = _rtl92c_phy_calculate_bit_shift(bitmask); | ||
83 | returnvalue = (originalvalue & bitmask) >> bitshift; | ||
84 | |||
85 | RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("BBR MASK=0x%x " | ||
86 | "Addr[0x%x]=0x%x\n", bitmask, | ||
87 | regaddr, originalvalue)); | ||
88 | |||
89 | return returnvalue; | ||
90 | |||
91 | } | ||
92 | |||
93 | void rtl92c_phy_set_bb_reg(struct ieee80211_hw *hw, | ||
94 | u32 regaddr, u32 bitmask, u32 data) | ||
95 | { | ||
96 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
97 | u32 originalvalue, bitshift; | ||
98 | |||
99 | RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," | ||
100 | " data(%#x)\n", regaddr, bitmask, | ||
101 | data)); | ||
102 | |||
103 | if (bitmask != MASKDWORD) { | ||
104 | originalvalue = rtl_read_dword(rtlpriv, regaddr); | ||
105 | bitshift = _rtl92c_phy_calculate_bit_shift(bitmask); | ||
106 | data = ((originalvalue & (~bitmask)) | (data << bitshift)); | ||
107 | } | ||
108 | |||
109 | rtl_write_dword(rtlpriv, regaddr, data); | ||
110 | |||
111 | RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," | ||
112 | " data(%#x)\n", regaddr, bitmask, | ||
113 | data)); | ||
114 | |||
115 | } | ||
116 | 41 | ||
117 | u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw, | 42 | u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw, |
118 | enum radio_path rfpath, u32 regaddr, u32 bitmask) | 43 | enum radio_path rfpath, u32 regaddr, u32 bitmask) |
@@ -197,118 +122,6 @@ void rtl92c_phy_set_rf_reg(struct ieee80211_hw *hw, | |||
197 | bitmask, data, rfpath)); | 122 | bitmask, data, rfpath)); |
198 | } | 123 | } |
199 | 124 | ||
200 | static u32 _rtl92c_phy_fw_rf_serial_read(struct ieee80211_hw *hw, | ||
201 | enum radio_path rfpath, u32 offset) | ||
202 | { | ||
203 | RT_ASSERT(false, ("deprecated!\n")); | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static void _rtl92c_phy_fw_rf_serial_write(struct ieee80211_hw *hw, | ||
208 | enum radio_path rfpath, u32 offset, | ||
209 | u32 data) | ||
210 | { | ||
211 | RT_ASSERT(false, ("deprecated!\n")); | ||
212 | } | ||
213 | |||
214 | static u32 _rtl92c_phy_rf_serial_read(struct ieee80211_hw *hw, | ||
215 | enum radio_path rfpath, u32 offset) | ||
216 | { | ||
217 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
218 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
219 | struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; | ||
220 | u32 newoffset; | ||
221 | u32 tmplong, tmplong2; | ||
222 | u8 rfpi_enable = 0; | ||
223 | u32 retvalue; | ||
224 | |||
225 | offset &= 0x3f; | ||
226 | newoffset = offset; | ||
227 | if (RT_CANNOT_IO(hw)) { | ||
228 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("return all one\n")); | ||
229 | return 0xFFFFFFFF; | ||
230 | } | ||
231 | tmplong = rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD); | ||
232 | if (rfpath == RF90_PATH_A) | ||
233 | tmplong2 = tmplong; | ||
234 | else | ||
235 | tmplong2 = rtl_get_bbreg(hw, pphyreg->rfhssi_para2, MASKDWORD); | ||
236 | tmplong2 = (tmplong2 & (~BLSSIREADADDRESS)) | | ||
237 | (newoffset << 23) | BLSSIREADEDGE; | ||
238 | rtl_set_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD, | ||
239 | tmplong & (~BLSSIREADEDGE)); | ||
240 | mdelay(1); | ||
241 | rtl_set_bbreg(hw, pphyreg->rfhssi_para2, MASKDWORD, tmplong2); | ||
242 | mdelay(1); | ||
243 | rtl_set_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD, | ||
244 | tmplong | BLSSIREADEDGE); | ||
245 | mdelay(1); | ||
246 | if (rfpath == RF90_PATH_A) | ||
247 | rfpi_enable = (u8) rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER1, | ||
248 | BIT(8)); | ||
249 | else if (rfpath == RF90_PATH_B) | ||
250 | rfpi_enable = (u8) rtl_get_bbreg(hw, RFPGA0_XB_HSSIPARAMETER1, | ||
251 | BIT(8)); | ||
252 | if (rfpi_enable) | ||
253 | retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readbackpi, | ||
254 | BLSSIREADBACKDATA); | ||
255 | else | ||
256 | retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, | ||
257 | BLSSIREADBACKDATA); | ||
258 | RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x]=0x%x\n", | ||
259 | rfpath, pphyreg->rflssi_readback, | ||
260 | retvalue)); | ||
261 | return retvalue; | ||
262 | } | ||
263 | |||
264 | static void _rtl92c_phy_rf_serial_write(struct ieee80211_hw *hw, | ||
265 | enum radio_path rfpath, u32 offset, | ||
266 | u32 data) | ||
267 | { | ||
268 | u32 data_and_addr; | ||
269 | u32 newoffset; | ||
270 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
271 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
272 | struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; | ||
273 | |||
274 | if (RT_CANNOT_IO(hw)) { | ||
275 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("stop\n")); | ||
276 | return; | ||
277 | } | ||
278 | offset &= 0x3f; | ||
279 | newoffset = offset; | ||
280 | data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; | ||
281 | rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr); | ||
282 | RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", | ||
283 | rfpath, pphyreg->rf3wire_offset, | ||
284 | data_and_addr)); | ||
285 | } | ||
286 | |||
287 | static u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask) | ||
288 | { | ||
289 | u32 i; | ||
290 | |||
291 | for (i = 0; i <= 31; i++) { | ||
292 | if (((bitmask >> i) & 0x1) == 1) | ||
293 | break; | ||
294 | } | ||
295 | return i; | ||
296 | } | ||
297 | |||
298 | static void _rtl92c_phy_bb_config_1t(struct ieee80211_hw *hw) | ||
299 | { | ||
300 | rtl_set_bbreg(hw, RFPGA0_TXINFO, 0x3, 0x2); | ||
301 | rtl_set_bbreg(hw, RFPGA1_TXINFO, 0x300033, 0x200022); | ||
302 | rtl_set_bbreg(hw, RCCK0_AFESETTING, MASKBYTE3, 0x45); | ||
303 | rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, MASKBYTE0, 0x23); | ||
304 | rtl_set_bbreg(hw, ROFDM0_AGCPARAMETER1, 0x30, 0x1); | ||
305 | rtl_set_bbreg(hw, 0xe74, 0x0c000000, 0x2); | ||
306 | rtl_set_bbreg(hw, 0xe78, 0x0c000000, 0x2); | ||
307 | rtl_set_bbreg(hw, 0xe7c, 0x0c000000, 0x2); | ||
308 | rtl_set_bbreg(hw, 0xe80, 0x0c000000, 0x2); | ||
309 | rtl_set_bbreg(hw, 0xe88, 0x0c000000, 0x2); | ||
310 | } | ||
311 | |||
312 | bool rtl92c_phy_mac_config(struct ieee80211_hw *hw) | 125 | bool rtl92c_phy_mac_config(struct ieee80211_hw *hw) |
313 | { | 126 | { |
314 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 127 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
@@ -327,7 +140,7 @@ bool rtl92c_phy_bb_config(struct ieee80211_hw *hw) | |||
327 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 140 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
328 | u16 regval; | 141 | u16 regval; |
329 | u32 regvaldw; | 142 | u32 regvaldw; |
330 | u8 b_reg_hwparafile = 1; | 143 | u8 reg_hwparafile = 1; |
331 | 144 | ||
332 | _rtl92c_phy_init_bb_rf_register_definition(hw); | 145 | _rtl92c_phy_init_bb_rf_register_definition(hw); |
333 | regval = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN); | 146 | regval = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN); |
@@ -342,55 +155,11 @@ bool rtl92c_phy_bb_config(struct ieee80211_hw *hw) | |||
342 | rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL + 1, 0x80); | 155 | rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL + 1, 0x80); |
343 | regvaldw = rtl_read_dword(rtlpriv, REG_LEDCFG0); | 156 | regvaldw = rtl_read_dword(rtlpriv, REG_LEDCFG0); |
344 | rtl_write_dword(rtlpriv, REG_LEDCFG0, regvaldw | BIT(23)); | 157 | rtl_write_dword(rtlpriv, REG_LEDCFG0, regvaldw | BIT(23)); |
345 | if (b_reg_hwparafile == 1) | 158 | if (reg_hwparafile == 1) |
346 | rtstatus = _rtl92c_phy_bb8192c_config_parafile(hw); | 159 | rtstatus = _rtl92c_phy_bb8192c_config_parafile(hw); |
347 | return rtstatus; | 160 | return rtstatus; |
348 | } | 161 | } |
349 | 162 | ||
350 | bool rtl92c_phy_rf_config(struct ieee80211_hw *hw) | ||
351 | { | ||
352 | return rtl92c_phy_rf6052_config(hw); | ||
353 | } | ||
354 | |||
355 | static bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw) | ||
356 | { | ||
357 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
358 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
359 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||
360 | bool rtstatus; | ||
361 | |||
362 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("==>\n")); | ||
363 | rtstatus = _rtl92c_phy_config_bb_with_headerfile(hw, | ||
364 | BASEBAND_CONFIG_PHY_REG); | ||
365 | if (rtstatus != true) { | ||
366 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Write BB Reg Fail!!")); | ||
367 | return false; | ||
368 | } | ||
369 | if (rtlphy->rf_type == RF_1T2R) { | ||
370 | _rtl92c_phy_bb_config_1t(hw); | ||
371 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Config to 1T!!\n")); | ||
372 | } | ||
373 | if (rtlefuse->autoload_failflag == false) { | ||
374 | rtlphy->pwrgroup_cnt = 0; | ||
375 | rtstatus = _rtl92c_phy_config_bb_with_pgheaderfile(hw, | ||
376 | BASEBAND_CONFIG_PHY_REG); | ||
377 | } | ||
378 | if (rtstatus != true) { | ||
379 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("BB_PG Reg Fail!!")); | ||
380 | return false; | ||
381 | } | ||
382 | rtstatus = _rtl92c_phy_config_bb_with_headerfile(hw, | ||
383 | BASEBAND_CONFIG_AGC_TAB); | ||
384 | if (rtstatus != true) { | ||
385 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("AGC Table Fail\n")); | ||
386 | return false; | ||
387 | } | ||
388 | rtlphy->bcck_high_power = (bool) (rtl_get_bbreg(hw, | ||
389 | RFPGA0_XA_HSSIPARAMETER2, | ||
390 | 0x200)); | ||
391 | return true; | ||
392 | } | ||
393 | |||
394 | static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) | 163 | static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) |
395 | { | 164 | { |
396 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 165 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
@@ -408,10 +177,6 @@ static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) | |||
408 | return true; | 177 | return true; |
409 | } | 178 | } |
410 | 179 | ||
411 | void rtl92c_phy_config_bb_external_pa(struct ieee80211_hw *hw) | ||
412 | { | ||
413 | } | ||
414 | |||
415 | static bool _rtl92c_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, | 180 | static bool _rtl92c_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, |
416 | u8 configtype) | 181 | u8 configtype) |
417 | { | 182 | { |
@@ -472,174 +237,6 @@ static bool _rtl92c_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, | |||
472 | return true; | 237 | return true; |
473 | } | 238 | } |
474 | 239 | ||
475 | static void _rtl92c_store_pwrIndex_diffrate_offset(struct ieee80211_hw *hw, | ||
476 | u32 regaddr, u32 bitmask, | ||
477 | u32 data) | ||
478 | { | ||
479 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
480 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
481 | |||
482 | if (regaddr == RTXAGC_A_RATE18_06) { | ||
483 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][0] = | ||
484 | data; | ||
485 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
486 | ("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", | ||
487 | rtlphy->pwrgroup_cnt, | ||
488 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
489 | pwrgroup_cnt][0])); | ||
490 | } | ||
491 | if (regaddr == RTXAGC_A_RATE54_24) { | ||
492 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][1] = | ||
493 | data; | ||
494 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
495 | ("MCSTxPowerLevelOriginalOffset[%d][1] = 0x%x\n", | ||
496 | rtlphy->pwrgroup_cnt, | ||
497 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
498 | pwrgroup_cnt][1])); | ||
499 | } | ||
500 | if (regaddr == RTXAGC_A_CCK1_MCS32) { | ||
501 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][6] = | ||
502 | data; | ||
503 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
504 | ("MCSTxPowerLevelOriginalOffset[%d][6] = 0x%x\n", | ||
505 | rtlphy->pwrgroup_cnt, | ||
506 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
507 | pwrgroup_cnt][6])); | ||
508 | } | ||
509 | if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { | ||
510 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][7] = | ||
511 | data; | ||
512 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
513 | ("MCSTxPowerLevelOriginalOffset[%d][7] = 0x%x\n", | ||
514 | rtlphy->pwrgroup_cnt, | ||
515 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
516 | pwrgroup_cnt][7])); | ||
517 | } | ||
518 | if (regaddr == RTXAGC_A_MCS03_MCS00) { | ||
519 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][2] = | ||
520 | data; | ||
521 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
522 | ("MCSTxPowerLevelOriginalOffset[%d][2] = 0x%x\n", | ||
523 | rtlphy->pwrgroup_cnt, | ||
524 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
525 | pwrgroup_cnt][2])); | ||
526 | } | ||
527 | if (regaddr == RTXAGC_A_MCS07_MCS04) { | ||
528 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][3] = | ||
529 | data; | ||
530 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
531 | ("MCSTxPowerLevelOriginalOffset[%d][3] = 0x%x\n", | ||
532 | rtlphy->pwrgroup_cnt, | ||
533 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
534 | pwrgroup_cnt][3])); | ||
535 | } | ||
536 | if (regaddr == RTXAGC_A_MCS11_MCS08) { | ||
537 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][4] = | ||
538 | data; | ||
539 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
540 | ("MCSTxPowerLevelOriginalOffset[%d][4] = 0x%x\n", | ||
541 | rtlphy->pwrgroup_cnt, | ||
542 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
543 | pwrgroup_cnt][4])); | ||
544 | } | ||
545 | if (regaddr == RTXAGC_A_MCS15_MCS12) { | ||
546 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][5] = | ||
547 | data; | ||
548 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
549 | ("MCSTxPowerLevelOriginalOffset[%d][5] = 0x%x\n", | ||
550 | rtlphy->pwrgroup_cnt, | ||
551 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
552 | pwrgroup_cnt][5])); | ||
553 | } | ||
554 | if (regaddr == RTXAGC_B_RATE18_06) { | ||
555 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][8] = | ||
556 | data; | ||
557 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
558 | ("MCSTxPowerLevelOriginalOffset[%d][8] = 0x%x\n", | ||
559 | rtlphy->pwrgroup_cnt, | ||
560 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
561 | pwrgroup_cnt][8])); | ||
562 | } | ||
563 | if (regaddr == RTXAGC_B_RATE54_24) { | ||
564 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][9] = | ||
565 | data; | ||
566 | |||
567 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
568 | ("MCSTxPowerLevelOriginalOffset[%d][9] = 0x%x\n", | ||
569 | rtlphy->pwrgroup_cnt, | ||
570 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
571 | pwrgroup_cnt][9])); | ||
572 | } | ||
573 | |||
574 | if (regaddr == RTXAGC_B_CCK1_55_MCS32) { | ||
575 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][14] = | ||
576 | data; | ||
577 | |||
578 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
579 | ("MCSTxPowerLevelOriginalOffset[%d][14] = 0x%x\n", | ||
580 | rtlphy->pwrgroup_cnt, | ||
581 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
582 | pwrgroup_cnt][14])); | ||
583 | } | ||
584 | |||
585 | if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { | ||
586 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][15] = | ||
587 | data; | ||
588 | |||
589 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
590 | ("MCSTxPowerLevelOriginalOffset[%d][15] = 0x%x\n", | ||
591 | rtlphy->pwrgroup_cnt, | ||
592 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
593 | pwrgroup_cnt][15])); | ||
594 | } | ||
595 | |||
596 | if (regaddr == RTXAGC_B_MCS03_MCS00) { | ||
597 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][10] = | ||
598 | data; | ||
599 | |||
600 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
601 | ("MCSTxPowerLevelOriginalOffset[%d][10] = 0x%x\n", | ||
602 | rtlphy->pwrgroup_cnt, | ||
603 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
604 | pwrgroup_cnt][10])); | ||
605 | } | ||
606 | |||
607 | if (regaddr == RTXAGC_B_MCS07_MCS04) { | ||
608 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][11] = | ||
609 | data; | ||
610 | |||
611 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
612 | ("MCSTxPowerLevelOriginalOffset[%d][11] = 0x%x\n", | ||
613 | rtlphy->pwrgroup_cnt, | ||
614 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
615 | pwrgroup_cnt][11])); | ||
616 | } | ||
617 | |||
618 | if (regaddr == RTXAGC_B_MCS11_MCS08) { | ||
619 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][12] = | ||
620 | data; | ||
621 | |||
622 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
623 | ("MCSTxPowerLevelOriginalOffset[%d][12] = 0x%x\n", | ||
624 | rtlphy->pwrgroup_cnt, | ||
625 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
626 | pwrgroup_cnt][12])); | ||
627 | } | ||
628 | |||
629 | if (regaddr == RTXAGC_B_MCS15_MCS12) { | ||
630 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][13] = | ||
631 | data; | ||
632 | |||
633 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
634 | ("MCSTxPowerLevelOriginalOffset[%d][13] = 0x%x\n", | ||
635 | rtlphy->pwrgroup_cnt, | ||
636 | rtlphy->mcs_txpwrlevel_origoffset[rtlphy-> | ||
637 | pwrgroup_cnt][13])); | ||
638 | |||
639 | rtlphy->pwrgroup_cnt++; | ||
640 | } | ||
641 | } | ||
642 | |||
643 | static bool _rtl92c_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, | 240 | static bool _rtl92c_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, |
644 | u8 configtype) | 241 | u8 configtype) |
645 | { | 242 | { |
@@ -679,12 +276,6 @@ static bool _rtl92c_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, | |||
679 | return true; | 276 | return true; |
680 | } | 277 | } |
681 | 278 | ||
682 | static bool _rtl92c_phy_config_rf_external_pa(struct ieee80211_hw *hw, | ||
683 | enum radio_path rfpath) | ||
684 | { | ||
685 | return true; | ||
686 | } | ||
687 | |||
688 | bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, | 279 | bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, |
689 | enum radio_path rfpath) | 280 | enum radio_path rfpath) |
690 | { | 281 | { |
@@ -776,345 +367,6 @@ bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, | |||
776 | return true; | 367 | return true; |
777 | } | 368 | } |
778 | 369 | ||
779 | void rtl92c_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw) | ||
780 | { | ||
781 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
782 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
783 | |||
784 | rtlphy->default_initialgain[0] = | ||
785 | (u8) rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, MASKBYTE0); | ||
786 | rtlphy->default_initialgain[1] = | ||
787 | (u8) rtl_get_bbreg(hw, ROFDM0_XBAGCCORE1, MASKBYTE0); | ||
788 | rtlphy->default_initialgain[2] = | ||
789 | (u8) rtl_get_bbreg(hw, ROFDM0_XCAGCCORE1, MASKBYTE0); | ||
790 | rtlphy->default_initialgain[3] = | ||
791 | (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, MASKBYTE0); | ||
792 | |||
793 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
794 | ("Default initial gain (c50=0x%x, " | ||
795 | "c58=0x%x, c60=0x%x, c68=0x%x\n", | ||
796 | rtlphy->default_initialgain[0], | ||
797 | rtlphy->default_initialgain[1], | ||
798 | rtlphy->default_initialgain[2], | ||
799 | rtlphy->default_initialgain[3])); | ||
800 | |||
801 | rtlphy->framesync = (u8) rtl_get_bbreg(hw, | ||
802 | ROFDM0_RXDETECTOR3, MASKBYTE0); | ||
803 | rtlphy->framesync_c34 = rtl_get_bbreg(hw, | ||
804 | ROFDM0_RXDETECTOR2, MASKDWORD); | ||
805 | |||
806 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
807 | ("Default framesync (0x%x) = 0x%x\n", | ||
808 | ROFDM0_RXDETECTOR3, rtlphy->framesync)); | ||
809 | } | ||
810 | |||
811 | static void _rtl92c_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw) | ||
812 | { | ||
813 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
814 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
815 | |||
816 | rtlphy->phyreg_def[RF90_PATH_A].rfintfs = RFPGA0_XAB_RFINTERFACESW; | ||
817 | rtlphy->phyreg_def[RF90_PATH_B].rfintfs = RFPGA0_XAB_RFINTERFACESW; | ||
818 | rtlphy->phyreg_def[RF90_PATH_C].rfintfs = RFPGA0_XCD_RFINTERFACESW; | ||
819 | rtlphy->phyreg_def[RF90_PATH_D].rfintfs = RFPGA0_XCD_RFINTERFACESW; | ||
820 | |||
821 | rtlphy->phyreg_def[RF90_PATH_A].rfintfi = RFPGA0_XAB_RFINTERFACERB; | ||
822 | rtlphy->phyreg_def[RF90_PATH_B].rfintfi = RFPGA0_XAB_RFINTERFACERB; | ||
823 | rtlphy->phyreg_def[RF90_PATH_C].rfintfi = RFPGA0_XCD_RFINTERFACERB; | ||
824 | rtlphy->phyreg_def[RF90_PATH_D].rfintfi = RFPGA0_XCD_RFINTERFACERB; | ||
825 | |||
826 | rtlphy->phyreg_def[RF90_PATH_A].rfintfo = RFPGA0_XA_RFINTERFACEOE; | ||
827 | rtlphy->phyreg_def[RF90_PATH_B].rfintfo = RFPGA0_XB_RFINTERFACEOE; | ||
828 | |||
829 | rtlphy->phyreg_def[RF90_PATH_A].rfintfe = RFPGA0_XA_RFINTERFACEOE; | ||
830 | rtlphy->phyreg_def[RF90_PATH_B].rfintfe = RFPGA0_XB_RFINTERFACEOE; | ||
831 | |||
832 | rtlphy->phyreg_def[RF90_PATH_A].rf3wire_offset = | ||
833 | RFPGA0_XA_LSSIPARAMETER; | ||
834 | rtlphy->phyreg_def[RF90_PATH_B].rf3wire_offset = | ||
835 | RFPGA0_XB_LSSIPARAMETER; | ||
836 | |||
837 | rtlphy->phyreg_def[RF90_PATH_A].rflssi_select = rFPGA0_XAB_RFPARAMETER; | ||
838 | rtlphy->phyreg_def[RF90_PATH_B].rflssi_select = rFPGA0_XAB_RFPARAMETER; | ||
839 | rtlphy->phyreg_def[RF90_PATH_C].rflssi_select = rFPGA0_XCD_RFPARAMETER; | ||
840 | rtlphy->phyreg_def[RF90_PATH_D].rflssi_select = rFPGA0_XCD_RFPARAMETER; | ||
841 | |||
842 | rtlphy->phyreg_def[RF90_PATH_A].rftxgain_stage = RFPGA0_TXGAINSTAGE; | ||
843 | rtlphy->phyreg_def[RF90_PATH_B].rftxgain_stage = RFPGA0_TXGAINSTAGE; | ||
844 | rtlphy->phyreg_def[RF90_PATH_C].rftxgain_stage = RFPGA0_TXGAINSTAGE; | ||
845 | rtlphy->phyreg_def[RF90_PATH_D].rftxgain_stage = RFPGA0_TXGAINSTAGE; | ||
846 | |||
847 | rtlphy->phyreg_def[RF90_PATH_A].rfhssi_para1 = RFPGA0_XA_HSSIPARAMETER1; | ||
848 | rtlphy->phyreg_def[RF90_PATH_B].rfhssi_para1 = RFPGA0_XB_HSSIPARAMETER1; | ||
849 | |||
850 | rtlphy->phyreg_def[RF90_PATH_A].rfhssi_para2 = RFPGA0_XA_HSSIPARAMETER2; | ||
851 | rtlphy->phyreg_def[RF90_PATH_B].rfhssi_para2 = RFPGA0_XB_HSSIPARAMETER2; | ||
852 | |||
853 | rtlphy->phyreg_def[RF90_PATH_A].rfswitch_control = | ||
854 | RFPGA0_XAB_SWITCHCONTROL; | ||
855 | rtlphy->phyreg_def[RF90_PATH_B].rfswitch_control = | ||
856 | RFPGA0_XAB_SWITCHCONTROL; | ||
857 | rtlphy->phyreg_def[RF90_PATH_C].rfswitch_control = | ||
858 | RFPGA0_XCD_SWITCHCONTROL; | ||
859 | rtlphy->phyreg_def[RF90_PATH_D].rfswitch_control = | ||
860 | RFPGA0_XCD_SWITCHCONTROL; | ||
861 | |||
862 | rtlphy->phyreg_def[RF90_PATH_A].rfagc_control1 = ROFDM0_XAAGCCORE1; | ||
863 | rtlphy->phyreg_def[RF90_PATH_B].rfagc_control1 = ROFDM0_XBAGCCORE1; | ||
864 | rtlphy->phyreg_def[RF90_PATH_C].rfagc_control1 = ROFDM0_XCAGCCORE1; | ||
865 | rtlphy->phyreg_def[RF90_PATH_D].rfagc_control1 = ROFDM0_XDAGCCORE1; | ||
866 | |||
867 | rtlphy->phyreg_def[RF90_PATH_A].rfagc_control2 = ROFDM0_XAAGCCORE2; | ||
868 | rtlphy->phyreg_def[RF90_PATH_B].rfagc_control2 = ROFDM0_XBAGCCORE2; | ||
869 | rtlphy->phyreg_def[RF90_PATH_C].rfagc_control2 = ROFDM0_XCAGCCORE2; | ||
870 | rtlphy->phyreg_def[RF90_PATH_D].rfagc_control2 = ROFDM0_XDAGCCORE2; | ||
871 | |||
872 | rtlphy->phyreg_def[RF90_PATH_A].rfrxiq_imbalance = | ||
873 | ROFDM0_XARXIQIMBALANCE; | ||
874 | rtlphy->phyreg_def[RF90_PATH_B].rfrxiq_imbalance = | ||
875 | ROFDM0_XBRXIQIMBALANCE; | ||
876 | rtlphy->phyreg_def[RF90_PATH_C].rfrxiq_imbalance = | ||
877 | ROFDM0_XCRXIQIMBANLANCE; | ||
878 | rtlphy->phyreg_def[RF90_PATH_D].rfrxiq_imbalance = | ||
879 | ROFDM0_XDRXIQIMBALANCE; | ||
880 | |||
881 | rtlphy->phyreg_def[RF90_PATH_A].rfrx_afe = ROFDM0_XARXAFE; | ||
882 | rtlphy->phyreg_def[RF90_PATH_B].rfrx_afe = ROFDM0_XBRXAFE; | ||
883 | rtlphy->phyreg_def[RF90_PATH_C].rfrx_afe = ROFDM0_XCRXAFE; | ||
884 | rtlphy->phyreg_def[RF90_PATH_D].rfrx_afe = ROFDM0_XDRXAFE; | ||
885 | |||
886 | rtlphy->phyreg_def[RF90_PATH_A].rftxiq_imbalance = | ||
887 | ROFDM0_XATXIQIMBALANCE; | ||
888 | rtlphy->phyreg_def[RF90_PATH_B].rftxiq_imbalance = | ||
889 | ROFDM0_XBTXIQIMBALANCE; | ||
890 | rtlphy->phyreg_def[RF90_PATH_C].rftxiq_imbalance = | ||
891 | ROFDM0_XCTXIQIMBALANCE; | ||
892 | rtlphy->phyreg_def[RF90_PATH_D].rftxiq_imbalance = | ||
893 | ROFDM0_XDTXIQIMBALANCE; | ||
894 | |||
895 | rtlphy->phyreg_def[RF90_PATH_A].rftx_afe = ROFDM0_XATXAFE; | ||
896 | rtlphy->phyreg_def[RF90_PATH_B].rftx_afe = ROFDM0_XBTXAFE; | ||
897 | rtlphy->phyreg_def[RF90_PATH_C].rftx_afe = ROFDM0_XCTXAFE; | ||
898 | rtlphy->phyreg_def[RF90_PATH_D].rftx_afe = ROFDM0_XDTXAFE; | ||
899 | |||
900 | rtlphy->phyreg_def[RF90_PATH_A].rflssi_readback = | ||
901 | RFPGA0_XA_LSSIREADBACK; | ||
902 | rtlphy->phyreg_def[RF90_PATH_B].rflssi_readback = | ||
903 | RFPGA0_XB_LSSIREADBACK; | ||
904 | rtlphy->phyreg_def[RF90_PATH_C].rflssi_readback = | ||
905 | RFPGA0_XC_LSSIREADBACK; | ||
906 | rtlphy->phyreg_def[RF90_PATH_D].rflssi_readback = | ||
907 | RFPGA0_XD_LSSIREADBACK; | ||
908 | |||
909 | rtlphy->phyreg_def[RF90_PATH_A].rflssi_readbackpi = | ||
910 | TRANSCEIVEA_HSPI_READBACK; | ||
911 | rtlphy->phyreg_def[RF90_PATH_B].rflssi_readbackpi = | ||
912 | TRANSCEIVEB_HSPI_READBACK; | ||
913 | |||
914 | } | ||
915 | |||
916 | void rtl92c_phy_get_txpower_level(struct ieee80211_hw *hw, long *powerlevel) | ||
917 | { | ||
918 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
919 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
920 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||
921 | u8 txpwr_level; | ||
922 | long txpwr_dbm; | ||
923 | |||
924 | txpwr_level = rtlphy->cur_cck_txpwridx; | ||
925 | txpwr_dbm = _rtl92c_phy_txpwr_idx_to_dbm(hw, | ||
926 | WIRELESS_MODE_B, txpwr_level); | ||
927 | txpwr_level = rtlphy->cur_ofdm24g_txpwridx + | ||
928 | rtlefuse->legacy_ht_txpowerdiff; | ||
929 | if (_rtl92c_phy_txpwr_idx_to_dbm(hw, | ||
930 | WIRELESS_MODE_G, | ||
931 | txpwr_level) > txpwr_dbm) | ||
932 | txpwr_dbm = | ||
933 | _rtl92c_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_G, | ||
934 | txpwr_level); | ||
935 | txpwr_level = rtlphy->cur_ofdm24g_txpwridx; | ||
936 | if (_rtl92c_phy_txpwr_idx_to_dbm(hw, | ||
937 | WIRELESS_MODE_N_24G, | ||
938 | txpwr_level) > txpwr_dbm) | ||
939 | txpwr_dbm = | ||
940 | _rtl92c_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_N_24G, | ||
941 | txpwr_level); | ||
942 | *powerlevel = txpwr_dbm; | ||
943 | } | ||
944 | |||
945 | static void _rtl92c_get_txpower_index(struct ieee80211_hw *hw, u8 channel, | ||
946 | u8 *cckpowerlevel, u8 *ofdmpowerlevel) | ||
947 | { | ||
948 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
949 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
950 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||
951 | u8 index = (channel - 1); | ||
952 | |||
953 | cckpowerlevel[RF90_PATH_A] = | ||
954 | rtlefuse->txpwrlevel_cck[RF90_PATH_A][index]; | ||
955 | cckpowerlevel[RF90_PATH_B] = | ||
956 | rtlefuse->txpwrlevel_cck[RF90_PATH_B][index]; | ||
957 | if (get_rf_type(rtlphy) == RF_1T2R || get_rf_type(rtlphy) == RF_1T1R) { | ||
958 | ofdmpowerlevel[RF90_PATH_A] = | ||
959 | rtlefuse->txpwrlevel_ht40_1s[RF90_PATH_A][index]; | ||
960 | ofdmpowerlevel[RF90_PATH_B] = | ||
961 | rtlefuse->txpwrlevel_ht40_1s[RF90_PATH_B][index]; | ||
962 | } else if (get_rf_type(rtlphy) == RF_2T2R) { | ||
963 | ofdmpowerlevel[RF90_PATH_A] = | ||
964 | rtlefuse->txpwrlevel_ht40_2s[RF90_PATH_A][index]; | ||
965 | ofdmpowerlevel[RF90_PATH_B] = | ||
966 | rtlefuse->txpwrlevel_ht40_2s[RF90_PATH_B][index]; | ||
967 | } | ||
968 | } | ||
969 | |||
970 | static void _rtl92c_ccxpower_index_check(struct ieee80211_hw *hw, | ||
971 | u8 channel, u8 *cckpowerlevel, | ||
972 | u8 *ofdmpowerlevel) | ||
973 | { | ||
974 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
975 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
976 | |||
977 | rtlphy->cur_cck_txpwridx = cckpowerlevel[0]; | ||
978 | rtlphy->cur_ofdm24g_txpwridx = ofdmpowerlevel[0]; | ||
979 | } | ||
980 | |||
981 | void rtl92c_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) | ||
982 | { | ||
983 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||
984 | u8 cckpowerlevel[2], ofdmpowerlevel[2]; | ||
985 | |||
986 | if (rtlefuse->b_txpwr_fromeprom == false) | ||
987 | return; | ||
988 | _rtl92c_get_txpower_index(hw, channel, | ||
989 | &cckpowerlevel[0], &ofdmpowerlevel[0]); | ||
990 | _rtl92c_ccxpower_index_check(hw, | ||
991 | channel, &cckpowerlevel[0], | ||
992 | &ofdmpowerlevel[0]); | ||
993 | rtl92c_phy_rf6052_set_cck_txpower(hw, &cckpowerlevel[0]); | ||
994 | rtl92c_phy_rf6052_set_ofdm_txpower(hw, &ofdmpowerlevel[0], channel); | ||
995 | } | ||
996 | |||
997 | bool rtl92c_phy_update_txpower_dbm(struct ieee80211_hw *hw, long power_indbm) | ||
998 | { | ||
999 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1000 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1001 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||
1002 | u8 idx; | ||
1003 | u8 rf_path; | ||
1004 | |||
1005 | u8 ccktxpwridx = _rtl92c_phy_dbm_to_txpwr_Idx(hw, | ||
1006 | WIRELESS_MODE_B, | ||
1007 | power_indbm); | ||
1008 | u8 ofdmtxpwridx = _rtl92c_phy_dbm_to_txpwr_Idx(hw, | ||
1009 | WIRELESS_MODE_N_24G, | ||
1010 | power_indbm); | ||
1011 | if (ofdmtxpwridx - rtlefuse->legacy_ht_txpowerdiff > 0) | ||
1012 | ofdmtxpwridx -= rtlefuse->legacy_ht_txpowerdiff; | ||
1013 | else | ||
1014 | ofdmtxpwridx = 0; | ||
1015 | RT_TRACE(rtlpriv, COMP_TXAGC, DBG_TRACE, | ||
1016 | ("%lx dBm, ccktxpwridx = %d, ofdmtxpwridx = %d\n", | ||
1017 | power_indbm, ccktxpwridx, ofdmtxpwridx)); | ||
1018 | for (idx = 0; idx < 14; idx++) { | ||
1019 | for (rf_path = 0; rf_path < 2; rf_path++) { | ||
1020 | rtlefuse->txpwrlevel_cck[rf_path][idx] = ccktxpwridx; | ||
1021 | rtlefuse->txpwrlevel_ht40_1s[rf_path][idx] = | ||
1022 | ofdmtxpwridx; | ||
1023 | rtlefuse->txpwrlevel_ht40_2s[rf_path][idx] = | ||
1024 | ofdmtxpwridx; | ||
1025 | } | ||
1026 | } | ||
1027 | rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); | ||
1028 | return true; | ||
1029 | } | ||
1030 | |||
1031 | void rtl92c_phy_set_beacon_hw_reg(struct ieee80211_hw *hw, u16 beaconinterval) | ||
1032 | { | ||
1033 | } | ||
1034 | |||
1035 | static u8 _rtl92c_phy_dbm_to_txpwr_Idx(struct ieee80211_hw *hw, | ||
1036 | enum wireless_mode wirelessmode, | ||
1037 | long power_indbm) | ||
1038 | { | ||
1039 | u8 txpwridx; | ||
1040 | long offset; | ||
1041 | |||
1042 | switch (wirelessmode) { | ||
1043 | case WIRELESS_MODE_B: | ||
1044 | offset = -7; | ||
1045 | break; | ||
1046 | case WIRELESS_MODE_G: | ||
1047 | case WIRELESS_MODE_N_24G: | ||
1048 | offset = -8; | ||
1049 | break; | ||
1050 | default: | ||
1051 | offset = -8; | ||
1052 | break; | ||
1053 | } | ||
1054 | |||
1055 | if ((power_indbm - offset) > 0) | ||
1056 | txpwridx = (u8) ((power_indbm - offset) * 2); | ||
1057 | else | ||
1058 | txpwridx = 0; | ||
1059 | |||
1060 | if (txpwridx > MAX_TXPWR_IDX_NMODE_92S) | ||
1061 | txpwridx = MAX_TXPWR_IDX_NMODE_92S; | ||
1062 | |||
1063 | return txpwridx; | ||
1064 | } | ||
1065 | |||
1066 | static long _rtl92c_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw, | ||
1067 | enum wireless_mode wirelessmode, | ||
1068 | u8 txpwridx) | ||
1069 | { | ||
1070 | long offset; | ||
1071 | long pwrout_dbm; | ||
1072 | |||
1073 | switch (wirelessmode) { | ||
1074 | case WIRELESS_MODE_B: | ||
1075 | offset = -7; | ||
1076 | break; | ||
1077 | case WIRELESS_MODE_G: | ||
1078 | case WIRELESS_MODE_N_24G: | ||
1079 | offset = -8; | ||
1080 | break; | ||
1081 | default: | ||
1082 | offset = -8; | ||
1083 | break; | ||
1084 | } | ||
1085 | pwrout_dbm = txpwridx / 2 + offset; | ||
1086 | return pwrout_dbm; | ||
1087 | } | ||
1088 | |||
1089 | void rtl92c_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation) | ||
1090 | { | ||
1091 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1092 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
1093 | enum io_type iotype; | ||
1094 | |||
1095 | if (!is_hal_stop(rtlhal)) { | ||
1096 | switch (operation) { | ||
1097 | case SCAN_OPT_BACKUP: | ||
1098 | iotype = IO_CMD_PAUSE_DM_BY_SCAN; | ||
1099 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
1100 | HW_VAR_IO_CMD, | ||
1101 | (u8 *)&iotype); | ||
1102 | |||
1103 | break; | ||
1104 | case SCAN_OPT_RESTORE: | ||
1105 | iotype = IO_CMD_RESUME_DM_BY_SCAN; | ||
1106 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
1107 | HW_VAR_IO_CMD, | ||
1108 | (u8 *)&iotype); | ||
1109 | break; | ||
1110 | default: | ||
1111 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||
1112 | ("Unknown Scan Backup operation.\n")); | ||
1113 | break; | ||
1114 | } | ||
1115 | } | ||
1116 | } | ||
1117 | |||
1118 | void rtl92c_phy_set_bw_mode_callback(struct ieee80211_hw *hw) | 370 | void rtl92c_phy_set_bw_mode_callback(struct ieee80211_hw *hw) |
1119 | { | 371 | { |
1120 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 372 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
@@ -1183,644 +435,6 @@ void rtl92c_phy_set_bw_mode_callback(struct ieee80211_hw *hw) | |||
1183 | RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); | 435 | RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); |
1184 | } | 436 | } |
1185 | 437 | ||
1186 | void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw, | ||
1187 | enum nl80211_channel_type ch_type) | ||
1188 | { | ||
1189 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1190 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1191 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
1192 | u8 tmp_bw = rtlphy->current_chan_bw; | ||
1193 | |||
1194 | if (rtlphy->set_bwmode_inprogress) | ||
1195 | return; | ||
1196 | rtlphy->set_bwmode_inprogress = true; | ||
1197 | if ((!is_hal_stop(rtlhal)) && !(RT_CANNOT_IO(hw))) | ||
1198 | rtl92c_phy_set_bw_mode_callback(hw); | ||
1199 | else { | ||
1200 | RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, | ||
1201 | ("FALSE driver sleep or unload\n")); | ||
1202 | rtlphy->set_bwmode_inprogress = false; | ||
1203 | rtlphy->current_chan_bw = tmp_bw; | ||
1204 | } | ||
1205 | } | ||
1206 | |||
1207 | void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw) | ||
1208 | { | ||
1209 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1210 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
1211 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1212 | u32 delay; | ||
1213 | |||
1214 | RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, | ||
1215 | ("switch to channel%d\n", rtlphy->current_channel)); | ||
1216 | if (is_hal_stop(rtlhal)) | ||
1217 | return; | ||
1218 | do { | ||
1219 | if (!rtlphy->sw_chnl_inprogress) | ||
1220 | break; | ||
1221 | if (!_rtl92c_phy_sw_chnl_step_by_step | ||
1222 | (hw, rtlphy->current_channel, &rtlphy->sw_chnl_stage, | ||
1223 | &rtlphy->sw_chnl_step, &delay)) { | ||
1224 | if (delay > 0) | ||
1225 | mdelay(delay); | ||
1226 | else | ||
1227 | continue; | ||
1228 | } else | ||
1229 | rtlphy->sw_chnl_inprogress = false; | ||
1230 | break; | ||
1231 | } while (true); | ||
1232 | RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); | ||
1233 | } | ||
1234 | |||
1235 | u8 rtl92c_phy_sw_chnl(struct ieee80211_hw *hw) | ||
1236 | { | ||
1237 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1238 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1239 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
1240 | |||
1241 | if (rtlphy->sw_chnl_inprogress) | ||
1242 | return 0; | ||
1243 | if (rtlphy->set_bwmode_inprogress) | ||
1244 | return 0; | ||
1245 | RT_ASSERT((rtlphy->current_channel <= 14), | ||
1246 | ("WIRELESS_MODE_G but channel>14")); | ||
1247 | rtlphy->sw_chnl_inprogress = true; | ||
1248 | rtlphy->sw_chnl_stage = 0; | ||
1249 | rtlphy->sw_chnl_step = 0; | ||
1250 | if (!(is_hal_stop(rtlhal)) && !(RT_CANNOT_IO(hw))) { | ||
1251 | rtl92c_phy_sw_chnl_callback(hw); | ||
1252 | RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, | ||
1253 | ("sw_chnl_inprogress false schdule workitem\n")); | ||
1254 | rtlphy->sw_chnl_inprogress = false; | ||
1255 | } else { | ||
1256 | RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, | ||
1257 | ("sw_chnl_inprogress false driver sleep or" | ||
1258 | " unload\n")); | ||
1259 | rtlphy->sw_chnl_inprogress = false; | ||
1260 | } | ||
1261 | return 1; | ||
1262 | } | ||
1263 | |||
1264 | static bool _rtl92c_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, | ||
1265 | u8 channel, u8 *stage, u8 *step, | ||
1266 | u32 *delay) | ||
1267 | { | ||
1268 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1269 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1270 | struct swchnlcmd precommoncmd[MAX_PRECMD_CNT]; | ||
1271 | u32 precommoncmdcnt; | ||
1272 | struct swchnlcmd postcommoncmd[MAX_POSTCMD_CNT]; | ||
1273 | u32 postcommoncmdcnt; | ||
1274 | struct swchnlcmd rfdependcmd[MAX_RFDEPENDCMD_CNT]; | ||
1275 | u32 rfdependcmdcnt; | ||
1276 | struct swchnlcmd *currentcmd = NULL; | ||
1277 | u8 rfpath; | ||
1278 | u8 num_total_rfpath = rtlphy->num_total_rfpath; | ||
1279 | |||
1280 | precommoncmdcnt = 0; | ||
1281 | _rtl92c_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++, | ||
1282 | MAX_PRECMD_CNT, | ||
1283 | CMDID_SET_TXPOWEROWER_LEVEL, 0, 0, 0); | ||
1284 | _rtl92c_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++, | ||
1285 | MAX_PRECMD_CNT, CMDID_END, 0, 0, 0); | ||
1286 | |||
1287 | postcommoncmdcnt = 0; | ||
1288 | |||
1289 | _rtl92c_phy_set_sw_chnl_cmdarray(postcommoncmd, postcommoncmdcnt++, | ||
1290 | MAX_POSTCMD_CNT, CMDID_END, 0, 0, 0); | ||
1291 | |||
1292 | rfdependcmdcnt = 0; | ||
1293 | |||
1294 | RT_ASSERT((channel >= 1 && channel <= 14), | ||
1295 | ("illegal channel for Zebra: %d\n", channel)); | ||
1296 | |||
1297 | _rtl92c_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, | ||
1298 | MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG, | ||
1299 | RF_CHNLBW, channel, 10); | ||
1300 | |||
1301 | _rtl92c_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, | ||
1302 | MAX_RFDEPENDCMD_CNT, CMDID_END, 0, 0, | ||
1303 | 0); | ||
1304 | |||
1305 | do { | ||
1306 | switch (*stage) { | ||
1307 | case 0: | ||
1308 | currentcmd = &precommoncmd[*step]; | ||
1309 | break; | ||
1310 | case 1: | ||
1311 | currentcmd = &rfdependcmd[*step]; | ||
1312 | break; | ||
1313 | case 2: | ||
1314 | currentcmd = &postcommoncmd[*step]; | ||
1315 | break; | ||
1316 | } | ||
1317 | |||
1318 | if (currentcmd->cmdid == CMDID_END) { | ||
1319 | if ((*stage) == 2) { | ||
1320 | return true; | ||
1321 | } else { | ||
1322 | (*stage)++; | ||
1323 | (*step) = 0; | ||
1324 | continue; | ||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | switch (currentcmd->cmdid) { | ||
1329 | case CMDID_SET_TXPOWEROWER_LEVEL: | ||
1330 | rtl92c_phy_set_txpower_level(hw, channel); | ||
1331 | break; | ||
1332 | case CMDID_WRITEPORT_ULONG: | ||
1333 | rtl_write_dword(rtlpriv, currentcmd->para1, | ||
1334 | currentcmd->para2); | ||
1335 | break; | ||
1336 | case CMDID_WRITEPORT_USHORT: | ||
1337 | rtl_write_word(rtlpriv, currentcmd->para1, | ||
1338 | (u16) currentcmd->para2); | ||
1339 | break; | ||
1340 | case CMDID_WRITEPORT_UCHAR: | ||
1341 | rtl_write_byte(rtlpriv, currentcmd->para1, | ||
1342 | (u8) currentcmd->para2); | ||
1343 | break; | ||
1344 | case CMDID_RF_WRITEREG: | ||
1345 | for (rfpath = 0; rfpath < num_total_rfpath; rfpath++) { | ||
1346 | rtlphy->rfreg_chnlval[rfpath] = | ||
1347 | ((rtlphy->rfreg_chnlval[rfpath] & | ||
1348 | 0xfffffc00) | currentcmd->para2); | ||
1349 | |||
1350 | rtl_set_rfreg(hw, (enum radio_path)rfpath, | ||
1351 | currentcmd->para1, | ||
1352 | RFREG_OFFSET_MASK, | ||
1353 | rtlphy->rfreg_chnlval[rfpath]); | ||
1354 | } | ||
1355 | break; | ||
1356 | default: | ||
1357 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||
1358 | ("switch case not process\n")); | ||
1359 | break; | ||
1360 | } | ||
1361 | |||
1362 | break; | ||
1363 | } while (true); | ||
1364 | |||
1365 | (*delay) = currentcmd->msdelay; | ||
1366 | (*step)++; | ||
1367 | return false; | ||
1368 | } | ||
1369 | |||
1370 | static bool _rtl92c_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, | ||
1371 | u32 cmdtableidx, u32 cmdtablesz, | ||
1372 | enum swchnlcmd_id cmdid, | ||
1373 | u32 para1, u32 para2, u32 msdelay) | ||
1374 | { | ||
1375 | struct swchnlcmd *pcmd; | ||
1376 | |||
1377 | if (cmdtable == NULL) { | ||
1378 | RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); | ||
1379 | return false; | ||
1380 | } | ||
1381 | |||
1382 | if (cmdtableidx >= cmdtablesz) | ||
1383 | return false; | ||
1384 | |||
1385 | pcmd = cmdtable + cmdtableidx; | ||
1386 | pcmd->cmdid = cmdid; | ||
1387 | pcmd->para1 = para1; | ||
1388 | pcmd->para2 = para2; | ||
1389 | pcmd->msdelay = msdelay; | ||
1390 | return true; | ||
1391 | } | ||
1392 | |||
1393 | bool rtl8192_phy_check_is_legal_rfpath(struct ieee80211_hw *hw, u32 rfpath) | ||
1394 | { | ||
1395 | return true; | ||
1396 | } | ||
1397 | |||
1398 | static u8 _rtl92c_phy_path_a_iqk(struct ieee80211_hw *hw, bool config_pathb) | ||
1399 | { | ||
1400 | u32 reg_eac, reg_e94, reg_e9c, reg_ea4; | ||
1401 | u8 result = 0x00; | ||
1402 | |||
1403 | rtl_set_bbreg(hw, 0xe30, MASKDWORD, 0x10008c1f); | ||
1404 | rtl_set_bbreg(hw, 0xe34, MASKDWORD, 0x10008c1f); | ||
1405 | rtl_set_bbreg(hw, 0xe38, MASKDWORD, 0x82140102); | ||
1406 | rtl_set_bbreg(hw, 0xe3c, MASKDWORD, | ||
1407 | config_pathb ? 0x28160202 : 0x28160502); | ||
1408 | |||
1409 | if (config_pathb) { | ||
1410 | rtl_set_bbreg(hw, 0xe50, MASKDWORD, 0x10008c22); | ||
1411 | rtl_set_bbreg(hw, 0xe54, MASKDWORD, 0x10008c22); | ||
1412 | rtl_set_bbreg(hw, 0xe58, MASKDWORD, 0x82140102); | ||
1413 | rtl_set_bbreg(hw, 0xe5c, MASKDWORD, 0x28160202); | ||
1414 | } | ||
1415 | |||
1416 | rtl_set_bbreg(hw, 0xe4c, MASKDWORD, 0x001028d1); | ||
1417 | rtl_set_bbreg(hw, 0xe48, MASKDWORD, 0xf9000000); | ||
1418 | rtl_set_bbreg(hw, 0xe48, MASKDWORD, 0xf8000000); | ||
1419 | |||
1420 | mdelay(IQK_DELAY_TIME); | ||
1421 | |||
1422 | reg_eac = rtl_get_bbreg(hw, 0xeac, MASKDWORD); | ||
1423 | reg_e94 = rtl_get_bbreg(hw, 0xe94, MASKDWORD); | ||
1424 | reg_e9c = rtl_get_bbreg(hw, 0xe9c, MASKDWORD); | ||
1425 | reg_ea4 = rtl_get_bbreg(hw, 0xea4, MASKDWORD); | ||
1426 | |||
1427 | if (!(reg_eac & BIT(28)) && | ||
1428 | (((reg_e94 & 0x03FF0000) >> 16) != 0x142) && | ||
1429 | (((reg_e9c & 0x03FF0000) >> 16) != 0x42)) | ||
1430 | result |= 0x01; | ||
1431 | else | ||
1432 | return result; | ||
1433 | |||
1434 | if (!(reg_eac & BIT(27)) && | ||
1435 | (((reg_ea4 & 0x03FF0000) >> 16) != 0x132) && | ||
1436 | (((reg_eac & 0x03FF0000) >> 16) != 0x36)) | ||
1437 | result |= 0x02; | ||
1438 | return result; | ||
1439 | } | ||
1440 | |||
1441 | static u8 _rtl92c_phy_path_b_iqk(struct ieee80211_hw *hw) | ||
1442 | { | ||
1443 | u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc; | ||
1444 | u8 result = 0x00; | ||
1445 | |||
1446 | rtl_set_bbreg(hw, 0xe60, MASKDWORD, 0x00000002); | ||
1447 | rtl_set_bbreg(hw, 0xe60, MASKDWORD, 0x00000000); | ||
1448 | mdelay(IQK_DELAY_TIME); | ||
1449 | reg_eac = rtl_get_bbreg(hw, 0xeac, MASKDWORD); | ||
1450 | reg_eb4 = rtl_get_bbreg(hw, 0xeb4, MASKDWORD); | ||
1451 | reg_ebc = rtl_get_bbreg(hw, 0xebc, MASKDWORD); | ||
1452 | reg_ec4 = rtl_get_bbreg(hw, 0xec4, MASKDWORD); | ||
1453 | reg_ecc = rtl_get_bbreg(hw, 0xecc, MASKDWORD); | ||
1454 | if (!(reg_eac & BIT(31)) && | ||
1455 | (((reg_eb4 & 0x03FF0000) >> 16) != 0x142) && | ||
1456 | (((reg_ebc & 0x03FF0000) >> 16) != 0x42)) | ||
1457 | result |= 0x01; | ||
1458 | else | ||
1459 | return result; | ||
1460 | |||
1461 | if (!(reg_eac & BIT(30)) && | ||
1462 | (((reg_ec4 & 0x03FF0000) >> 16) != 0x132) && | ||
1463 | (((reg_ecc & 0x03FF0000) >> 16) != 0x36)) | ||
1464 | result |= 0x02; | ||
1465 | return result; | ||
1466 | } | ||
1467 | |||
1468 | static void _rtl92c_phy_path_a_fill_iqk_matrix(struct ieee80211_hw *hw, | ||
1469 | bool b_iqk_ok, long result[][8], | ||
1470 | u8 final_candidate, bool btxonly) | ||
1471 | { | ||
1472 | u32 oldval_0, x, tx0_a, reg; | ||
1473 | long y, tx0_c; | ||
1474 | |||
1475 | if (final_candidate == 0xFF) | ||
1476 | return; | ||
1477 | else if (b_iqk_ok) { | ||
1478 | oldval_0 = (rtl_get_bbreg(hw, ROFDM0_XATXIQIMBALANCE, | ||
1479 | MASKDWORD) >> 22) & 0x3FF; | ||
1480 | x = result[final_candidate][0]; | ||
1481 | if ((x & 0x00000200) != 0) | ||
1482 | x = x | 0xFFFFFC00; | ||
1483 | tx0_a = (x * oldval_0) >> 8; | ||
1484 | rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, 0x3FF, tx0_a); | ||
1485 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(31), | ||
1486 | ((x * oldval_0 >> 7) & 0x1)); | ||
1487 | y = result[final_candidate][1]; | ||
1488 | if ((y & 0x00000200) != 0) | ||
1489 | y = y | 0xFFFFFC00; | ||
1490 | tx0_c = (y * oldval_0) >> 8; | ||
1491 | rtl_set_bbreg(hw, ROFDM0_XCTXAFE, 0xF0000000, | ||
1492 | ((tx0_c & 0x3C0) >> 6)); | ||
1493 | rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, 0x003F0000, | ||
1494 | (tx0_c & 0x3F)); | ||
1495 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(29), | ||
1496 | ((y * oldval_0 >> 7) & 0x1)); | ||
1497 | if (btxonly) | ||
1498 | return; | ||
1499 | reg = result[final_candidate][2]; | ||
1500 | rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0x3FF, reg); | ||
1501 | reg = result[final_candidate][3] & 0x3F; | ||
1502 | rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0xFC00, reg); | ||
1503 | reg = (result[final_candidate][3] >> 6) & 0xF; | ||
1504 | rtl_set_bbreg(hw, 0xca0, 0xF0000000, reg); | ||
1505 | } | ||
1506 | } | ||
1507 | |||
1508 | static void _rtl92c_phy_path_b_fill_iqk_matrix(struct ieee80211_hw *hw, | ||
1509 | bool b_iqk_ok, long result[][8], | ||
1510 | u8 final_candidate, bool btxonly) | ||
1511 | { | ||
1512 | u32 oldval_1, x, tx1_a, reg; | ||
1513 | long y, tx1_c; | ||
1514 | |||
1515 | if (final_candidate == 0xFF) | ||
1516 | return; | ||
1517 | else if (b_iqk_ok) { | ||
1518 | oldval_1 = (rtl_get_bbreg(hw, ROFDM0_XBTXIQIMBALANCE, | ||
1519 | MASKDWORD) >> 22) & 0x3FF; | ||
1520 | x = result[final_candidate][4]; | ||
1521 | if ((x & 0x00000200) != 0) | ||
1522 | x = x | 0xFFFFFC00; | ||
1523 | tx1_a = (x * oldval_1) >> 8; | ||
1524 | rtl_set_bbreg(hw, ROFDM0_XBTXIQIMBALANCE, 0x3FF, tx1_a); | ||
1525 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(27), | ||
1526 | ((x * oldval_1 >> 7) & 0x1)); | ||
1527 | y = result[final_candidate][5]; | ||
1528 | if ((y & 0x00000200) != 0) | ||
1529 | y = y | 0xFFFFFC00; | ||
1530 | tx1_c = (y * oldval_1) >> 8; | ||
1531 | rtl_set_bbreg(hw, ROFDM0_XDTXAFE, 0xF0000000, | ||
1532 | ((tx1_c & 0x3C0) >> 6)); | ||
1533 | rtl_set_bbreg(hw, ROFDM0_XBTXIQIMBALANCE, 0x003F0000, | ||
1534 | (tx1_c & 0x3F)); | ||
1535 | rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(25), | ||
1536 | ((y * oldval_1 >> 7) & 0x1)); | ||
1537 | if (btxonly) | ||
1538 | return; | ||
1539 | reg = result[final_candidate][6]; | ||
1540 | rtl_set_bbreg(hw, ROFDM0_XBRXIQIMBALANCE, 0x3FF, reg); | ||
1541 | reg = result[final_candidate][7] & 0x3F; | ||
1542 | rtl_set_bbreg(hw, ROFDM0_XBRXIQIMBALANCE, 0xFC00, reg); | ||
1543 | reg = (result[final_candidate][7] >> 6) & 0xF; | ||
1544 | rtl_set_bbreg(hw, ROFDM0_AGCRSSITABLE, 0x0000F000, reg); | ||
1545 | } | ||
1546 | } | ||
1547 | |||
1548 | static void _rtl92c_phy_save_adda_registers(struct ieee80211_hw *hw, | ||
1549 | u32 *addareg, u32 *addabackup, | ||
1550 | u32 registernum) | ||
1551 | { | ||
1552 | u32 i; | ||
1553 | |||
1554 | for (i = 0; i < registernum; i++) | ||
1555 | addabackup[i] = rtl_get_bbreg(hw, addareg[i], MASKDWORD); | ||
1556 | } | ||
1557 | |||
1558 | static void _rtl92c_phy_save_mac_registers(struct ieee80211_hw *hw, | ||
1559 | u32 *macreg, u32 *macbackup) | ||
1560 | { | ||
1561 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1562 | u32 i; | ||
1563 | |||
1564 | for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) | ||
1565 | macbackup[i] = rtl_read_byte(rtlpriv, macreg[i]); | ||
1566 | macbackup[i] = rtl_read_dword(rtlpriv, macreg[i]); | ||
1567 | } | ||
1568 | |||
1569 | static void _rtl92c_phy_reload_adda_registers(struct ieee80211_hw *hw, | ||
1570 | u32 *addareg, u32 *addabackup, | ||
1571 | u32 regiesternum) | ||
1572 | { | ||
1573 | u32 i; | ||
1574 | |||
1575 | for (i = 0; i < regiesternum; i++) | ||
1576 | rtl_set_bbreg(hw, addareg[i], MASKDWORD, addabackup[i]); | ||
1577 | } | ||
1578 | |||
1579 | static void _rtl92c_phy_reload_mac_registers(struct ieee80211_hw *hw, | ||
1580 | u32 *macreg, u32 *macbackup) | ||
1581 | { | ||
1582 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1583 | u32 i; | ||
1584 | |||
1585 | for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) | ||
1586 | rtl_write_byte(rtlpriv, macreg[i], (u8) macbackup[i]); | ||
1587 | rtl_write_dword(rtlpriv, macreg[i], macbackup[i]); | ||
1588 | } | ||
1589 | |||
1590 | static void _rtl92c_phy_path_adda_on(struct ieee80211_hw *hw, | ||
1591 | u32 *addareg, bool is_patha_on, bool is2t) | ||
1592 | { | ||
1593 | u32 pathOn; | ||
1594 | u32 i; | ||
1595 | |||
1596 | pathOn = is_patha_on ? 0x04db25a4 : 0x0b1b25a4; | ||
1597 | if (false == is2t) { | ||
1598 | pathOn = 0x0bdb25a0; | ||
1599 | rtl_set_bbreg(hw, addareg[0], MASKDWORD, 0x0b1b25a0); | ||
1600 | } else { | ||
1601 | rtl_set_bbreg(hw, addareg[0], MASKDWORD, pathOn); | ||
1602 | } | ||
1603 | |||
1604 | for (i = 1; i < IQK_ADDA_REG_NUM; i++) | ||
1605 | rtl_set_bbreg(hw, addareg[i], MASKDWORD, pathOn); | ||
1606 | } | ||
1607 | |||
1608 | static void _rtl92c_phy_mac_setting_calibration(struct ieee80211_hw *hw, | ||
1609 | u32 *macreg, u32 *macbackup) | ||
1610 | { | ||
1611 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1612 | u32 i; | ||
1613 | |||
1614 | rtl_write_byte(rtlpriv, macreg[0], 0x3F); | ||
1615 | |||
1616 | for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) | ||
1617 | rtl_write_byte(rtlpriv, macreg[i], | ||
1618 | (u8) (macbackup[i] & (~BIT(3)))); | ||
1619 | rtl_write_byte(rtlpriv, macreg[i], (u8) (macbackup[i] & (~BIT(5)))); | ||
1620 | } | ||
1621 | |||
1622 | static void _rtl92c_phy_path_a_standby(struct ieee80211_hw *hw) | ||
1623 | { | ||
1624 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x0); | ||
1625 | rtl_set_bbreg(hw, 0x840, MASKDWORD, 0x00010000); | ||
1626 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x80800000); | ||
1627 | } | ||
1628 | |||
1629 | static void _rtl92c_phy_pi_mode_switch(struct ieee80211_hw *hw, bool pi_mode) | ||
1630 | { | ||
1631 | u32 mode; | ||
1632 | |||
1633 | mode = pi_mode ? 0x01000100 : 0x01000000; | ||
1634 | rtl_set_bbreg(hw, 0x820, MASKDWORD, mode); | ||
1635 | rtl_set_bbreg(hw, 0x828, MASKDWORD, mode); | ||
1636 | } | ||
1637 | |||
1638 | static bool _rtl92c_phy_simularity_compare(struct ieee80211_hw *hw, | ||
1639 | long result[][8], u8 c1, u8 c2) | ||
1640 | { | ||
1641 | u32 i, j, diff, simularity_bitmap, bound; | ||
1642 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
1643 | |||
1644 | u8 final_candidate[2] = { 0xFF, 0xFF }; | ||
1645 | bool bresult = true, is2t = IS_92C_SERIAL(rtlhal->version); | ||
1646 | |||
1647 | if (is2t) | ||
1648 | bound = 8; | ||
1649 | else | ||
1650 | bound = 4; | ||
1651 | |||
1652 | simularity_bitmap = 0; | ||
1653 | |||
1654 | for (i = 0; i < bound; i++) { | ||
1655 | diff = (result[c1][i] > result[c2][i]) ? | ||
1656 | (result[c1][i] - result[c2][i]) : | ||
1657 | (result[c2][i] - result[c1][i]); | ||
1658 | |||
1659 | if (diff > MAX_TOLERANCE) { | ||
1660 | if ((i == 2 || i == 6) && !simularity_bitmap) { | ||
1661 | if (result[c1][i] + result[c1][i + 1] == 0) | ||
1662 | final_candidate[(i / 4)] = c2; | ||
1663 | else if (result[c2][i] + result[c2][i + 1] == 0) | ||
1664 | final_candidate[(i / 4)] = c1; | ||
1665 | else | ||
1666 | simularity_bitmap = simularity_bitmap | | ||
1667 | (1 << i); | ||
1668 | } else | ||
1669 | simularity_bitmap = | ||
1670 | simularity_bitmap | (1 << i); | ||
1671 | } | ||
1672 | } | ||
1673 | |||
1674 | if (simularity_bitmap == 0) { | ||
1675 | for (i = 0; i < (bound / 4); i++) { | ||
1676 | if (final_candidate[i] != 0xFF) { | ||
1677 | for (j = i * 4; j < (i + 1) * 4 - 2; j++) | ||
1678 | result[3][j] = | ||
1679 | result[final_candidate[i]][j]; | ||
1680 | bresult = false; | ||
1681 | } | ||
1682 | } | ||
1683 | return bresult; | ||
1684 | } else if (!(simularity_bitmap & 0x0F)) { | ||
1685 | for (i = 0; i < 4; i++) | ||
1686 | result[3][i] = result[c1][i]; | ||
1687 | return false; | ||
1688 | } else if (!(simularity_bitmap & 0xF0) && is2t) { | ||
1689 | for (i = 4; i < 8; i++) | ||
1690 | result[3][i] = result[c1][i]; | ||
1691 | return false; | ||
1692 | } else { | ||
1693 | return false; | ||
1694 | } | ||
1695 | |||
1696 | } | ||
1697 | |||
1698 | static void _rtl92c_phy_iq_calibrate(struct ieee80211_hw *hw, | ||
1699 | long result[][8], u8 t, bool is2t) | ||
1700 | { | ||
1701 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1702 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1703 | u32 i; | ||
1704 | u8 patha_ok, pathb_ok; | ||
1705 | u32 adda_reg[IQK_ADDA_REG_NUM] = { | ||
1706 | 0x85c, 0xe6c, 0xe70, 0xe74, | ||
1707 | 0xe78, 0xe7c, 0xe80, 0xe84, | ||
1708 | 0xe88, 0xe8c, 0xed0, 0xed4, | ||
1709 | 0xed8, 0xedc, 0xee0, 0xeec | ||
1710 | }; | ||
1711 | |||
1712 | u32 iqk_mac_reg[IQK_MAC_REG_NUM] = { | ||
1713 | 0x522, 0x550, 0x551, 0x040 | ||
1714 | }; | ||
1715 | |||
1716 | const u32 retrycount = 2; | ||
1717 | |||
1718 | u32 bbvalue; | ||
1719 | |||
1720 | if (t == 0) { | ||
1721 | bbvalue = rtl_get_bbreg(hw, 0x800, MASKDWORD); | ||
1722 | |||
1723 | _rtl92c_phy_save_adda_registers(hw, adda_reg, | ||
1724 | rtlphy->adda_backup, 16); | ||
1725 | _rtl92c_phy_save_mac_registers(hw, iqk_mac_reg, | ||
1726 | rtlphy->iqk_mac_backup); | ||
1727 | } | ||
1728 | _rtl92c_phy_path_adda_on(hw, adda_reg, true, is2t); | ||
1729 | if (t == 0) { | ||
1730 | rtlphy->b_rfpi_enable = (u8) rtl_get_bbreg(hw, | ||
1731 | RFPGA0_XA_HSSIPARAMETER1, | ||
1732 | BIT(8)); | ||
1733 | } | ||
1734 | if (!rtlphy->b_rfpi_enable) | ||
1735 | _rtl92c_phy_pi_mode_switch(hw, true); | ||
1736 | if (t == 0) { | ||
1737 | rtlphy->reg_c04 = rtl_get_bbreg(hw, 0xc04, MASKDWORD); | ||
1738 | rtlphy->reg_c08 = rtl_get_bbreg(hw, 0xc08, MASKDWORD); | ||
1739 | rtlphy->reg_874 = rtl_get_bbreg(hw, 0x874, MASKDWORD); | ||
1740 | } | ||
1741 | rtl_set_bbreg(hw, 0xc04, MASKDWORD, 0x03a05600); | ||
1742 | rtl_set_bbreg(hw, 0xc08, MASKDWORD, 0x000800e4); | ||
1743 | rtl_set_bbreg(hw, 0x874, MASKDWORD, 0x22204000); | ||
1744 | if (is2t) { | ||
1745 | rtl_set_bbreg(hw, 0x840, MASKDWORD, 0x00010000); | ||
1746 | rtl_set_bbreg(hw, 0x844, MASKDWORD, 0x00010000); | ||
1747 | } | ||
1748 | _rtl92c_phy_mac_setting_calibration(hw, iqk_mac_reg, | ||
1749 | rtlphy->iqk_mac_backup); | ||
1750 | rtl_set_bbreg(hw, 0xb68, MASKDWORD, 0x00080000); | ||
1751 | if (is2t) | ||
1752 | rtl_set_bbreg(hw, 0xb6c, MASKDWORD, 0x00080000); | ||
1753 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x80800000); | ||
1754 | rtl_set_bbreg(hw, 0xe40, MASKDWORD, 0x01007c00); | ||
1755 | rtl_set_bbreg(hw, 0xe44, MASKDWORD, 0x01004800); | ||
1756 | for (i = 0; i < retrycount; i++) { | ||
1757 | patha_ok = _rtl92c_phy_path_a_iqk(hw, is2t); | ||
1758 | if (patha_ok == 0x03) { | ||
1759 | result[t][0] = (rtl_get_bbreg(hw, 0xe94, MASKDWORD) & | ||
1760 | 0x3FF0000) >> 16; | ||
1761 | result[t][1] = (rtl_get_bbreg(hw, 0xe9c, MASKDWORD) & | ||
1762 | 0x3FF0000) >> 16; | ||
1763 | result[t][2] = (rtl_get_bbreg(hw, 0xea4, MASKDWORD) & | ||
1764 | 0x3FF0000) >> 16; | ||
1765 | result[t][3] = (rtl_get_bbreg(hw, 0xeac, MASKDWORD) & | ||
1766 | 0x3FF0000) >> 16; | ||
1767 | break; | ||
1768 | } else if (i == (retrycount - 1) && patha_ok == 0x01) | ||
1769 | result[t][0] = (rtl_get_bbreg(hw, 0xe94, | ||
1770 | MASKDWORD) & 0x3FF0000) >> | ||
1771 | 16; | ||
1772 | result[t][1] = | ||
1773 | (rtl_get_bbreg(hw, 0xe9c, MASKDWORD) & 0x3FF0000) >> 16; | ||
1774 | |||
1775 | } | ||
1776 | |||
1777 | if (is2t) { | ||
1778 | _rtl92c_phy_path_a_standby(hw); | ||
1779 | _rtl92c_phy_path_adda_on(hw, adda_reg, false, is2t); | ||
1780 | for (i = 0; i < retrycount; i++) { | ||
1781 | pathb_ok = _rtl92c_phy_path_b_iqk(hw); | ||
1782 | if (pathb_ok == 0x03) { | ||
1783 | result[t][4] = (rtl_get_bbreg(hw, | ||
1784 | 0xeb4, | ||
1785 | MASKDWORD) & | ||
1786 | 0x3FF0000) >> 16; | ||
1787 | result[t][5] = | ||
1788 | (rtl_get_bbreg(hw, 0xebc, MASKDWORD) & | ||
1789 | 0x3FF0000) >> 16; | ||
1790 | result[t][6] = | ||
1791 | (rtl_get_bbreg(hw, 0xec4, MASKDWORD) & | ||
1792 | 0x3FF0000) >> 16; | ||
1793 | result[t][7] = | ||
1794 | (rtl_get_bbreg(hw, 0xecc, MASKDWORD) & | ||
1795 | 0x3FF0000) >> 16; | ||
1796 | break; | ||
1797 | } else if (i == (retrycount - 1) && pathb_ok == 0x01) { | ||
1798 | result[t][4] = (rtl_get_bbreg(hw, | ||
1799 | 0xeb4, | ||
1800 | MASKDWORD) & | ||
1801 | 0x3FF0000) >> 16; | ||
1802 | } | ||
1803 | result[t][5] = (rtl_get_bbreg(hw, 0xebc, MASKDWORD) & | ||
1804 | 0x3FF0000) >> 16; | ||
1805 | } | ||
1806 | } | ||
1807 | rtl_set_bbreg(hw, 0xc04, MASKDWORD, rtlphy->reg_c04); | ||
1808 | rtl_set_bbreg(hw, 0x874, MASKDWORD, rtlphy->reg_874); | ||
1809 | rtl_set_bbreg(hw, 0xc08, MASKDWORD, rtlphy->reg_c08); | ||
1810 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0); | ||
1811 | rtl_set_bbreg(hw, 0x840, MASKDWORD, 0x00032ed3); | ||
1812 | if (is2t) | ||
1813 | rtl_set_bbreg(hw, 0x844, MASKDWORD, 0x00032ed3); | ||
1814 | if (t != 0) { | ||
1815 | if (!rtlphy->b_rfpi_enable) | ||
1816 | _rtl92c_phy_pi_mode_switch(hw, false); | ||
1817 | _rtl92c_phy_reload_adda_registers(hw, adda_reg, | ||
1818 | rtlphy->adda_backup, 16); | ||
1819 | _rtl92c_phy_reload_mac_registers(hw, iqk_mac_reg, | ||
1820 | rtlphy->iqk_mac_backup); | ||
1821 | } | ||
1822 | } | ||
1823 | |||
1824 | static void _rtl92c_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) | 438 | static void _rtl92c_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) |
1825 | { | 439 | { |
1826 | u8 tmpreg; | 440 | u8 tmpreg; |
@@ -1866,666 +480,6 @@ static void _rtl92c_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) | |||
1866 | } | 480 | } |
1867 | } | 481 | } |
1868 | 482 | ||
1869 | static void _rtl92c_phy_ap_calibrate(struct ieee80211_hw *hw, | ||
1870 | char delta, bool is2t) | ||
1871 | { | ||
1872 | /* This routine is deliberately dummied out for later fixes */ | ||
1873 | #if 0 | ||
1874 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1875 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
1876 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||
1877 | |||
1878 | u32 reg_d[PATH_NUM]; | ||
1879 | u32 tmpreg, index, offset, path, i, pathbound = PATH_NUM, apkbound; | ||
1880 | |||
1881 | u32 bb_backup[APK_BB_REG_NUM]; | ||
1882 | u32 bb_reg[APK_BB_REG_NUM] = { | ||
1883 | 0x904, 0xc04, 0x800, 0xc08, 0x874 | ||
1884 | }; | ||
1885 | u32 bb_ap_mode[APK_BB_REG_NUM] = { | ||
1886 | 0x00000020, 0x00a05430, 0x02040000, | ||
1887 | 0x000800e4, 0x00204000 | ||
1888 | }; | ||
1889 | u32 bb_normal_ap_mode[APK_BB_REG_NUM] = { | ||
1890 | 0x00000020, 0x00a05430, 0x02040000, | ||
1891 | 0x000800e4, 0x22204000 | ||
1892 | }; | ||
1893 | |||
1894 | u32 afe_backup[APK_AFE_REG_NUM]; | ||
1895 | u32 afe_reg[APK_AFE_REG_NUM] = { | ||
1896 | 0x85c, 0xe6c, 0xe70, 0xe74, 0xe78, | ||
1897 | 0xe7c, 0xe80, 0xe84, 0xe88, 0xe8c, | ||
1898 | 0xed0, 0xed4, 0xed8, 0xedc, 0xee0, | ||
1899 | 0xeec | ||
1900 | }; | ||
1901 | |||
1902 | u32 mac_backup[IQK_MAC_REG_NUM]; | ||
1903 | u32 mac_reg[IQK_MAC_REG_NUM] = { | ||
1904 | 0x522, 0x550, 0x551, 0x040 | ||
1905 | }; | ||
1906 | |||
1907 | u32 apk_rf_init_value[PATH_NUM][APK_BB_REG_NUM] = { | ||
1908 | {0x0852c, 0x1852c, 0x5852c, 0x1852c, 0x5852c}, | ||
1909 | {0x2852e, 0x0852e, 0x3852e, 0x0852e, 0x0852e} | ||
1910 | }; | ||
1911 | |||
1912 | u32 apk_normal_rf_init_value[PATH_NUM][APK_BB_REG_NUM] = { | ||
1913 | {0x0852c, 0x0a52c, 0x3a52c, 0x5a52c, 0x5a52c}, | ||
1914 | {0x0852c, 0x0a52c, 0x5a52c, 0x5a52c, 0x5a52c} | ||
1915 | }; | ||
1916 | |||
1917 | u32 apk_rf_value_0[PATH_NUM][APK_BB_REG_NUM] = { | ||
1918 | {0x52019, 0x52014, 0x52013, 0x5200f, 0x5208d}, | ||
1919 | {0x5201a, 0x52019, 0x52016, 0x52033, 0x52050} | ||
1920 | }; | ||
1921 | |||
1922 | u32 apk_normal_rf_value_0[PATH_NUM][APK_BB_REG_NUM] = { | ||
1923 | {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a}, | ||
1924 | {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a} | ||
1925 | }; | ||
1926 | |||
1927 | u32 afe_on_off[PATH_NUM] = { | ||
1928 | 0x04db25a4, 0x0b1b25a4 | ||
1929 | }; | ||
1930 | |||
1931 | u32 apk_offset[PATH_NUM] = { 0xb68, 0xb6c }; | ||
1932 | |||
1933 | u32 apk_normal_offset[PATH_NUM] = { 0xb28, 0xb98 }; | ||
1934 | |||
1935 | u32 apk_value[PATH_NUM] = { 0x92fc0000, 0x12fc0000 }; | ||
1936 | |||
1937 | u32 apk_normal_value[PATH_NUM] = { 0x92680000, 0x12680000 }; | ||
1938 | |||
1939 | const char apk_delta_mapping[APK_BB_REG_NUM][13] = { | ||
1940 | {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, | ||
1941 | {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, | ||
1942 | {-6, -4, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, | ||
1943 | {-1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6}, | ||
1944 | {-11, -9, -7, -5, -3, -1, 0, 0, 0, 0, 0, 0, 0} | ||
1945 | }; | ||
1946 | |||
1947 | const u32 apk_normal_setting_value_1[13] = { | ||
1948 | 0x01017018, 0xf7ed8f84, 0x1b1a1816, 0x2522201e, 0x322e2b28, | ||
1949 | 0x433f3a36, 0x5b544e49, 0x7b726a62, 0xa69a8f84, 0xdfcfc0b3, | ||
1950 | 0x12680000, 0x00880000, 0x00880000 | ||
1951 | }; | ||
1952 | |||
1953 | const u32 apk_normal_setting_value_2[16] = { | ||
1954 | 0x01c7021d, 0x01670183, 0x01000123, 0x00bf00e2, 0x008d00a3, | ||
1955 | 0x0068007b, 0x004d0059, 0x003a0042, 0x002b0031, 0x001f0025, | ||
1956 | 0x0017001b, 0x00110014, 0x000c000f, 0x0009000b, 0x00070008, | ||
1957 | 0x00050006 | ||
1958 | }; | ||
1959 | |||
1960 | const u32 apk_result[PATH_NUM][APK_BB_REG_NUM]; | ||
1961 | |||
1962 | long bb_offset, delta_v, delta_offset; | ||
1963 | |||
1964 | if (!is2t) | ||
1965 | pathbound = 1; | ||
1966 | |||
1967 | for (index = 0; index < PATH_NUM; index++) { | ||
1968 | apk_offset[index] = apk_normal_offset[index]; | ||
1969 | apk_value[index] = apk_normal_value[index]; | ||
1970 | afe_on_off[index] = 0x6fdb25a4; | ||
1971 | } | ||
1972 | |||
1973 | for (index = 0; index < APK_BB_REG_NUM; index++) { | ||
1974 | for (path = 0; path < pathbound; path++) { | ||
1975 | apk_rf_init_value[path][index] = | ||
1976 | apk_normal_rf_init_value[path][index]; | ||
1977 | apk_rf_value_0[path][index] = | ||
1978 | apk_normal_rf_value_0[path][index]; | ||
1979 | } | ||
1980 | bb_ap_mode[index] = bb_normal_ap_mode[index]; | ||
1981 | |||
1982 | apkbound = 6; | ||
1983 | } | ||
1984 | |||
1985 | for (index = 0; index < APK_BB_REG_NUM; index++) { | ||
1986 | if (index == 0) | ||
1987 | continue; | ||
1988 | bb_backup[index] = rtl_get_bbreg(hw, bb_reg[index], MASKDWORD); | ||
1989 | } | ||
1990 | |||
1991 | _rtl92c_phy_save_mac_registers(hw, mac_reg, mac_backup); | ||
1992 | |||
1993 | _rtl92c_phy_save_adda_registers(hw, afe_reg, afe_backup, 16); | ||
1994 | |||
1995 | for (path = 0; path < pathbound; path++) { | ||
1996 | if (path == RF90_PATH_A) { | ||
1997 | offset = 0xb00; | ||
1998 | for (index = 0; index < 11; index++) { | ||
1999 | rtl_set_bbreg(hw, offset, MASKDWORD, | ||
2000 | apk_normal_setting_value_1 | ||
2001 | [index]); | ||
2002 | |||
2003 | offset += 0x04; | ||
2004 | } | ||
2005 | |||
2006 | rtl_set_bbreg(hw, 0xb98, MASKDWORD, 0x12680000); | ||
2007 | |||
2008 | offset = 0xb68; | ||
2009 | for (; index < 13; index++) { | ||
2010 | rtl_set_bbreg(hw, offset, MASKDWORD, | ||
2011 | apk_normal_setting_value_1 | ||
2012 | [index]); | ||
2013 | |||
2014 | offset += 0x04; | ||
2015 | } | ||
2016 | |||
2017 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x40000000); | ||
2018 | |||
2019 | offset = 0xb00; | ||
2020 | for (index = 0; index < 16; index++) { | ||
2021 | rtl_set_bbreg(hw, offset, MASKDWORD, | ||
2022 | apk_normal_setting_value_2 | ||
2023 | [index]); | ||
2024 | |||
2025 | offset += 0x04; | ||
2026 | } | ||
2027 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x00000000); | ||
2028 | } else if (path == RF90_PATH_B) { | ||
2029 | offset = 0xb70; | ||
2030 | for (index = 0; index < 10; index++) { | ||
2031 | rtl_set_bbreg(hw, offset, MASKDWORD, | ||
2032 | apk_normal_setting_value_1 | ||
2033 | [index]); | ||
2034 | |||
2035 | offset += 0x04; | ||
2036 | } | ||
2037 | rtl_set_bbreg(hw, 0xb28, MASKDWORD, 0x12680000); | ||
2038 | rtl_set_bbreg(hw, 0xb98, MASKDWORD, 0x12680000); | ||
2039 | |||
2040 | offset = 0xb68; | ||
2041 | index = 11; | ||
2042 | for (; index < 13; index++) { | ||
2043 | rtl_set_bbreg(hw, offset, MASKDWORD, | ||
2044 | apk_normal_setting_value_1 | ||
2045 | [index]); | ||
2046 | |||
2047 | offset += 0x04; | ||
2048 | } | ||
2049 | |||
2050 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x40000000); | ||
2051 | |||
2052 | offset = 0xb60; | ||
2053 | for (index = 0; index < 16; index++) { | ||
2054 | rtl_set_bbreg(hw, offset, MASKDWORD, | ||
2055 | apk_normal_setting_value_2 | ||
2056 | [index]); | ||
2057 | |||
2058 | offset += 0x04; | ||
2059 | } | ||
2060 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x00000000); | ||
2061 | } | ||
2062 | |||
2063 | reg_d[path] = rtl_get_rfreg(hw, (enum radio_path)path, | ||
2064 | 0xd, MASKDWORD); | ||
2065 | |||
2066 | for (index = 0; index < APK_AFE_REG_NUM; index++) | ||
2067 | rtl_set_bbreg(hw, afe_reg[index], MASKDWORD, | ||
2068 | afe_on_off[path]); | ||
2069 | |||
2070 | if (path == RF90_PATH_A) { | ||
2071 | for (index = 0; index < APK_BB_REG_NUM; index++) { | ||
2072 | if (index == 0) | ||
2073 | continue; | ||
2074 | rtl_set_bbreg(hw, bb_reg[index], MASKDWORD, | ||
2075 | bb_ap_mode[index]); | ||
2076 | } | ||
2077 | } | ||
2078 | |||
2079 | _rtl92c_phy_mac_setting_calibration(hw, mac_reg, mac_backup); | ||
2080 | |||
2081 | if (path == 0) { | ||
2082 | rtl_set_rfreg(hw, RF90_PATH_B, 0x0, MASKDWORD, 0x10000); | ||
2083 | } else { | ||
2084 | rtl_set_rfreg(hw, RF90_PATH_A, 0x00, MASKDWORD, | ||
2085 | 0x10000); | ||
2086 | rtl_set_rfreg(hw, RF90_PATH_A, 0x10, MASKDWORD, | ||
2087 | 0x1000f); | ||
2088 | rtl_set_rfreg(hw, RF90_PATH_A, 0x11, MASKDWORD, | ||
2089 | 0x20103); | ||
2090 | } | ||
2091 | |||
2092 | delta_offset = ((delta + 14) / 2); | ||
2093 | if (delta_offset < 0) | ||
2094 | delta_offset = 0; | ||
2095 | else if (delta_offset > 12) | ||
2096 | delta_offset = 12; | ||
2097 | |||
2098 | for (index = 0; index < APK_BB_REG_NUM; index++) { | ||
2099 | if (index != 1) | ||
2100 | continue; | ||
2101 | |||
2102 | tmpreg = apk_rf_init_value[path][index]; | ||
2103 | |||
2104 | if (!rtlefuse->b_apk_thermalmeterignore) { | ||
2105 | bb_offset = (tmpreg & 0xF0000) >> 16; | ||
2106 | |||
2107 | if (!(tmpreg & BIT(15))) | ||
2108 | bb_offset = -bb_offset; | ||
2109 | |||
2110 | delta_v = | ||
2111 | apk_delta_mapping[index][delta_offset]; | ||
2112 | |||
2113 | bb_offset += delta_v; | ||
2114 | |||
2115 | if (bb_offset < 0) { | ||
2116 | tmpreg = tmpreg & (~BIT(15)); | ||
2117 | bb_offset = -bb_offset; | ||
2118 | } else { | ||
2119 | tmpreg = tmpreg | BIT(15); | ||
2120 | } | ||
2121 | |||
2122 | tmpreg = | ||
2123 | (tmpreg & 0xFFF0FFFF) | (bb_offset << 16); | ||
2124 | } | ||
2125 | |||
2126 | rtl_set_rfreg(hw, (enum radio_path)path, 0xc, | ||
2127 | MASKDWORD, 0x8992e); | ||
2128 | rtl_set_rfreg(hw, (enum radio_path)path, 0x0, | ||
2129 | MASKDWORD, apk_rf_value_0[path][index]); | ||
2130 | rtl_set_rfreg(hw, (enum radio_path)path, 0xd, | ||
2131 | MASKDWORD, tmpreg); | ||
2132 | |||
2133 | i = 0; | ||
2134 | do { | ||
2135 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x80000000); | ||
2136 | rtl_set_bbreg(hw, apk_offset[path], | ||
2137 | MASKDWORD, apk_value[0]); | ||
2138 | RTPRINT(rtlpriv, FINIT, INIT_IQK, | ||
2139 | ("PHY_APCalibrate() offset 0x%x " | ||
2140 | "value 0x%x\n", | ||
2141 | apk_offset[path], | ||
2142 | rtl_get_bbreg(hw, apk_offset[path], | ||
2143 | MASKDWORD))); | ||
2144 | |||
2145 | mdelay(3); | ||
2146 | |||
2147 | rtl_set_bbreg(hw, apk_offset[path], | ||
2148 | MASKDWORD, apk_value[1]); | ||
2149 | RTPRINT(rtlpriv, FINIT, INIT_IQK, | ||
2150 | ("PHY_APCalibrate() offset 0x%x " | ||
2151 | "value 0x%x\n", | ||
2152 | apk_offset[path], | ||
2153 | rtl_get_bbreg(hw, apk_offset[path], | ||
2154 | MASKDWORD))); | ||
2155 | |||
2156 | mdelay(20); | ||
2157 | |||
2158 | rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x00000000); | ||
2159 | |||
2160 | if (path == RF90_PATH_A) | ||
2161 | tmpreg = rtl_get_bbreg(hw, 0xbd8, | ||
2162 | 0x03E00000); | ||
2163 | else | ||
2164 | tmpreg = rtl_get_bbreg(hw, 0xbd8, | ||
2165 | 0xF8000000); | ||
2166 | |||
2167 | RTPRINT(rtlpriv, FINIT, INIT_IQK, | ||
2168 | ("PHY_APCalibrate() offset " | ||
2169 | "0xbd8[25:21] %x\n", tmpreg)); | ||
2170 | |||
2171 | i++; | ||
2172 | |||
2173 | } while (tmpreg > apkbound && i < 4); | ||
2174 | |||
2175 | apk_result[path][index] = tmpreg; | ||
2176 | } | ||
2177 | } | ||
2178 | |||
2179 | _rtl92c_phy_reload_mac_registers(hw, mac_reg, mac_backup); | ||
2180 | |||
2181 | for (index = 0; index < APK_BB_REG_NUM; index++) { | ||
2182 | if (index == 0) | ||
2183 | continue; | ||
2184 | rtl_set_bbreg(hw, bb_reg[index], MASKDWORD, bb_backup[index]); | ||
2185 | } | ||
2186 | |||
2187 | _rtl92c_phy_reload_adda_registers(hw, afe_reg, afe_backup, 16); | ||
2188 | |||
2189 | for (path = 0; path < pathbound; path++) { | ||
2190 | rtl_set_rfreg(hw, (enum radio_path)path, 0xd, | ||
2191 | MASKDWORD, reg_d[path]); | ||
2192 | |||
2193 | if (path == RF90_PATH_B) { | ||
2194 | rtl_set_rfreg(hw, RF90_PATH_A, 0x10, MASKDWORD, | ||
2195 | 0x1000f); | ||
2196 | rtl_set_rfreg(hw, RF90_PATH_A, 0x11, MASKDWORD, | ||
2197 | 0x20101); | ||
2198 | } | ||
2199 | |||
2200 | if (apk_result[path][1] > 6) | ||
2201 | apk_result[path][1] = 6; | ||
2202 | } | ||
2203 | |||
2204 | for (path = 0; path < pathbound; path++) { | ||
2205 | rtl_set_rfreg(hw, (enum radio_path)path, 0x3, MASKDWORD, | ||
2206 | ((apk_result[path][1] << 15) | | ||
2207 | (apk_result[path][1] << 10) | | ||
2208 | (apk_result[path][1] << 5) | | ||
2209 | apk_result[path][1])); | ||
2210 | |||
2211 | if (path == RF90_PATH_A) | ||
2212 | rtl_set_rfreg(hw, (enum radio_path)path, 0x4, MASKDWORD, | ||
2213 | ((apk_result[path][1] << 15) | | ||
2214 | (apk_result[path][1] << 10) | | ||
2215 | (0x00 << 5) | 0x05)); | ||
2216 | else | ||
2217 | rtl_set_rfreg(hw, (enum radio_path)path, 0x4, MASKDWORD, | ||
2218 | ((apk_result[path][1] << 15) | | ||
2219 | (apk_result[path][1] << 10) | | ||
2220 | (0x02 << 5) | 0x05)); | ||
2221 | |||
2222 | rtl_set_rfreg(hw, (enum radio_path)path, 0xe, MASKDWORD, | ||
2223 | ((0x08 << 15) | (0x08 << 10) | (0x08 << 5) | | ||
2224 | 0x08)); | ||
2225 | |||
2226 | } | ||
2227 | |||
2228 | rtlphy->b_apk_done = true; | ||
2229 | #endif | ||
2230 | } | ||
2231 | |||
2232 | static void _rtl92c_phy_set_rfpath_switch(struct ieee80211_hw *hw, | ||
2233 | bool bmain, bool is2t) | ||
2234 | { | ||
2235 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
2236 | |||
2237 | if (is_hal_stop(rtlhal)) { | ||
2238 | rtl_set_bbreg(hw, REG_LEDCFG0, BIT(23), 0x01); | ||
2239 | rtl_set_bbreg(hw, rFPGA0_XAB_RFPARAMETER, BIT(13), 0x01); | ||
2240 | } | ||
2241 | if (is2t) { | ||
2242 | if (bmain) | ||
2243 | rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, | ||
2244 | BIT(5) | BIT(6), 0x1); | ||
2245 | else | ||
2246 | rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, | ||
2247 | BIT(5) | BIT(6), 0x2); | ||
2248 | } else { | ||
2249 | if (bmain) | ||
2250 | rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, 0x300, 0x2); | ||
2251 | else | ||
2252 | rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, 0x300, 0x1); | ||
2253 | |||
2254 | } | ||
2255 | } | ||
2256 | |||
2257 | #undef IQK_ADDA_REG_NUM | ||
2258 | #undef IQK_DELAY_TIME | ||
2259 | |||
2260 | void rtl92c_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery) | ||
2261 | { | ||
2262 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2263 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
2264 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
2265 | |||
2266 | long result[4][8]; | ||
2267 | u8 i, final_candidate; | ||
2268 | bool b_patha_ok, b_pathb_ok; | ||
2269 | long reg_e94, reg_e9c, reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, | ||
2270 | reg_ecc, reg_tmp = 0; | ||
2271 | bool is12simular, is13simular, is23simular; | ||
2272 | bool b_start_conttx = false, b_singletone = false; | ||
2273 | u32 iqk_bb_reg[10] = { | ||
2274 | ROFDM0_XARXIQIMBALANCE, | ||
2275 | ROFDM0_XBRXIQIMBALANCE, | ||
2276 | ROFDM0_ECCATHRESHOLD, | ||
2277 | ROFDM0_AGCRSSITABLE, | ||
2278 | ROFDM0_XATXIQIMBALANCE, | ||
2279 | ROFDM0_XBTXIQIMBALANCE, | ||
2280 | ROFDM0_XCTXIQIMBALANCE, | ||
2281 | ROFDM0_XCTXAFE, | ||
2282 | ROFDM0_XDTXAFE, | ||
2283 | ROFDM0_RXIQEXTANTA | ||
2284 | }; | ||
2285 | |||
2286 | if (b_recovery) { | ||
2287 | _rtl92c_phy_reload_adda_registers(hw, | ||
2288 | iqk_bb_reg, | ||
2289 | rtlphy->iqk_bb_backup, 10); | ||
2290 | return; | ||
2291 | } | ||
2292 | if (b_start_conttx || b_singletone) | ||
2293 | return; | ||
2294 | for (i = 0; i < 8; i++) { | ||
2295 | result[0][i] = 0; | ||
2296 | result[1][i] = 0; | ||
2297 | result[2][i] = 0; | ||
2298 | result[3][i] = 0; | ||
2299 | } | ||
2300 | final_candidate = 0xff; | ||
2301 | b_patha_ok = false; | ||
2302 | b_pathb_ok = false; | ||
2303 | is12simular = false; | ||
2304 | is23simular = false; | ||
2305 | is13simular = false; | ||
2306 | for (i = 0; i < 3; i++) { | ||
2307 | if (IS_92C_SERIAL(rtlhal->version)) | ||
2308 | _rtl92c_phy_iq_calibrate(hw, result, i, true); | ||
2309 | else | ||
2310 | _rtl92c_phy_iq_calibrate(hw, result, i, false); | ||
2311 | if (i == 1) { | ||
2312 | is12simular = _rtl92c_phy_simularity_compare(hw, | ||
2313 | result, 0, | ||
2314 | 1); | ||
2315 | if (is12simular) { | ||
2316 | final_candidate = 0; | ||
2317 | break; | ||
2318 | } | ||
2319 | } | ||
2320 | if (i == 2) { | ||
2321 | is13simular = _rtl92c_phy_simularity_compare(hw, | ||
2322 | result, 0, | ||
2323 | 2); | ||
2324 | if (is13simular) { | ||
2325 | final_candidate = 0; | ||
2326 | break; | ||
2327 | } | ||
2328 | is23simular = _rtl92c_phy_simularity_compare(hw, | ||
2329 | result, 1, | ||
2330 | 2); | ||
2331 | if (is23simular) | ||
2332 | final_candidate = 1; | ||
2333 | else { | ||
2334 | for (i = 0; i < 8; i++) | ||
2335 | reg_tmp += result[3][i]; | ||
2336 | |||
2337 | if (reg_tmp != 0) | ||
2338 | final_candidate = 3; | ||
2339 | else | ||
2340 | final_candidate = 0xFF; | ||
2341 | } | ||
2342 | } | ||
2343 | } | ||
2344 | for (i = 0; i < 4; i++) { | ||
2345 | reg_e94 = result[i][0]; | ||
2346 | reg_e9c = result[i][1]; | ||
2347 | reg_ea4 = result[i][2]; | ||
2348 | reg_eac = result[i][3]; | ||
2349 | reg_eb4 = result[i][4]; | ||
2350 | reg_ebc = result[i][5]; | ||
2351 | reg_ec4 = result[i][6]; | ||
2352 | reg_ecc = result[i][7]; | ||
2353 | } | ||
2354 | if (final_candidate != 0xff) { | ||
2355 | rtlphy->reg_e94 = reg_e94 = result[final_candidate][0]; | ||
2356 | rtlphy->reg_e9c = reg_e9c = result[final_candidate][1]; | ||
2357 | reg_ea4 = result[final_candidate][2]; | ||
2358 | reg_eac = result[final_candidate][3]; | ||
2359 | rtlphy->reg_eb4 = reg_eb4 = result[final_candidate][4]; | ||
2360 | rtlphy->reg_ebc = reg_ebc = result[final_candidate][5]; | ||
2361 | reg_ec4 = result[final_candidate][6]; | ||
2362 | reg_ecc = result[final_candidate][7]; | ||
2363 | b_patha_ok = b_pathb_ok = true; | ||
2364 | } else { | ||
2365 | rtlphy->reg_e94 = rtlphy->reg_eb4 = 0x100; | ||
2366 | rtlphy->reg_e9c = rtlphy->reg_ebc = 0x0; | ||
2367 | } | ||
2368 | if (reg_e94 != 0) /*&&(reg_ea4 != 0) */ | ||
2369 | _rtl92c_phy_path_a_fill_iqk_matrix(hw, b_patha_ok, result, | ||
2370 | final_candidate, | ||
2371 | (reg_ea4 == 0)); | ||
2372 | if (IS_92C_SERIAL(rtlhal->version)) { | ||
2373 | if (reg_eb4 != 0) /*&&(reg_ec4 != 0) */ | ||
2374 | _rtl92c_phy_path_b_fill_iqk_matrix(hw, b_pathb_ok, | ||
2375 | result, | ||
2376 | final_candidate, | ||
2377 | (reg_ec4 == 0)); | ||
2378 | } | ||
2379 | _rtl92c_phy_save_adda_registers(hw, iqk_bb_reg, | ||
2380 | rtlphy->iqk_bb_backup, 10); | ||
2381 | } | ||
2382 | |||
2383 | void rtl92c_phy_lc_calibrate(struct ieee80211_hw *hw) | ||
2384 | { | ||
2385 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
2386 | bool b_start_conttx = false, b_singletone = false; | ||
2387 | |||
2388 | if (b_start_conttx || b_singletone) | ||
2389 | return; | ||
2390 | if (IS_92C_SERIAL(rtlhal->version)) | ||
2391 | _rtl92c_phy_lc_calibrate(hw, true); | ||
2392 | else | ||
2393 | _rtl92c_phy_lc_calibrate(hw, false); | ||
2394 | } | ||
2395 | |||
2396 | void rtl92c_phy_ap_calibrate(struct ieee80211_hw *hw, char delta) | ||
2397 | { | ||
2398 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2399 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
2400 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
2401 | |||
2402 | if (rtlphy->b_apk_done) | ||
2403 | return; | ||
2404 | if (IS_92C_SERIAL(rtlhal->version)) | ||
2405 | _rtl92c_phy_ap_calibrate(hw, delta, true); | ||
2406 | else | ||
2407 | _rtl92c_phy_ap_calibrate(hw, delta, false); | ||
2408 | } | ||
2409 | |||
2410 | void rtl92c_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain) | ||
2411 | { | ||
2412 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||
2413 | |||
2414 | if (IS_92C_SERIAL(rtlhal->version)) | ||
2415 | _rtl92c_phy_set_rfpath_switch(hw, bmain, true); | ||
2416 | else | ||
2417 | _rtl92c_phy_set_rfpath_switch(hw, bmain, false); | ||
2418 | } | ||
2419 | |||
2420 | bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) | ||
2421 | { | ||
2422 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2423 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
2424 | bool b_postprocessing = false; | ||
2425 | |||
2426 | RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, | ||
2427 | ("-->IO Cmd(%#x), set_io_inprogress(%d)\n", | ||
2428 | iotype, rtlphy->set_io_inprogress)); | ||
2429 | do { | ||
2430 | switch (iotype) { | ||
2431 | case IO_CMD_RESUME_DM_BY_SCAN: | ||
2432 | RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, | ||
2433 | ("[IO CMD] Resume DM after scan.\n")); | ||
2434 | b_postprocessing = true; | ||
2435 | break; | ||
2436 | case IO_CMD_PAUSE_DM_BY_SCAN: | ||
2437 | RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, | ||
2438 | ("[IO CMD] Pause DM before scan.\n")); | ||
2439 | b_postprocessing = true; | ||
2440 | break; | ||
2441 | default: | ||
2442 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||
2443 | ("switch case not process\n")); | ||
2444 | break; | ||
2445 | } | ||
2446 | } while (false); | ||
2447 | if (b_postprocessing && !rtlphy->set_io_inprogress) { | ||
2448 | rtlphy->set_io_inprogress = true; | ||
2449 | rtlphy->current_io_type = iotype; | ||
2450 | } else { | ||
2451 | return false; | ||
2452 | } | ||
2453 | rtl92c_phy_set_io(hw); | ||
2454 | RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, ("<--IO Type(%#x)\n", iotype)); | ||
2455 | return true; | ||
2456 | } | ||
2457 | |||
2458 | void rtl92c_phy_set_io(struct ieee80211_hw *hw) | ||
2459 | { | ||
2460 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2461 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
2462 | |||
2463 | RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, | ||
2464 | ("--->Cmd(%#x), set_io_inprogress(%d)\n", | ||
2465 | rtlphy->current_io_type, rtlphy->set_io_inprogress)); | ||
2466 | switch (rtlphy->current_io_type) { | ||
2467 | case IO_CMD_RESUME_DM_BY_SCAN: | ||
2468 | dm_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1; | ||
2469 | rtl92c_dm_write_dig(hw); | ||
2470 | rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); | ||
2471 | break; | ||
2472 | case IO_CMD_PAUSE_DM_BY_SCAN: | ||
2473 | rtlphy->initgain_backup.xaagccore1 = dm_digtable.cur_igvalue; | ||
2474 | dm_digtable.cur_igvalue = 0x17; | ||
2475 | rtl92c_dm_write_dig(hw); | ||
2476 | break; | ||
2477 | default: | ||
2478 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||
2479 | ("switch case not process\n")); | ||
2480 | break; | ||
2481 | } | ||
2482 | rtlphy->set_io_inprogress = false; | ||
2483 | RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, | ||
2484 | ("<---(%#x)\n", rtlphy->current_io_type)); | ||
2485 | } | ||
2486 | |||
2487 | void rtl92ce_phy_set_rf_on(struct ieee80211_hw *hw) | ||
2488 | { | ||
2489 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2490 | |||
2491 | rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x2b); | ||
2492 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); | ||
2493 | rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x00); | ||
2494 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); | ||
2495 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); | ||
2496 | rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); | ||
2497 | } | ||
2498 | |||
2499 | static void _rtl92ce_phy_set_rf_sleep(struct ieee80211_hw *hw) | ||
2500 | { | ||
2501 | u32 u4b_tmp; | ||
2502 | u8 delay = 5; | ||
2503 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2504 | |||
2505 | rtl_write_byte(rtlpriv, REG_TXPAUSE, 0xFF); | ||
2506 | rtl_set_rfreg(hw, RF90_PATH_A, 0x00, RFREG_OFFSET_MASK, 0x00); | ||
2507 | rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); | ||
2508 | u4b_tmp = rtl_get_rfreg(hw, RF90_PATH_A, 0, RFREG_OFFSET_MASK); | ||
2509 | while (u4b_tmp != 0 && delay > 0) { | ||
2510 | rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x0); | ||
2511 | rtl_set_rfreg(hw, RF90_PATH_A, 0x00, RFREG_OFFSET_MASK, 0x00); | ||
2512 | rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); | ||
2513 | u4b_tmp = rtl_get_rfreg(hw, RF90_PATH_A, 0, RFREG_OFFSET_MASK); | ||
2514 | delay--; | ||
2515 | } | ||
2516 | if (delay == 0) { | ||
2517 | rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x00); | ||
2518 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); | ||
2519 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); | ||
2520 | rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); | ||
2521 | RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, | ||
2522 | ("Switch RF timeout !!!.\n")); | ||
2523 | return; | ||
2524 | } | ||
2525 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); | ||
2526 | rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x22); | ||
2527 | } | ||
2528 | |||
2529 | static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, | 483 | static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, |
2530 | enum rf_pwrstate rfpwr_state) | 484 | enum rf_pwrstate rfpwr_state) |
2531 | { | 485 | { |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h index ca4daee6e9a8..3fc60e434cef 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h | |||
@@ -57,8 +57,6 @@ | |||
57 | #define IQK_MAC_REG_NUM 4 | 57 | #define IQK_MAC_REG_NUM 4 |
58 | 58 | ||
59 | #define RF90_PATH_MAX 2 | 59 | #define RF90_PATH_MAX 2 |
60 | #define CHANNEL_MAX_NUMBER 14 | ||
61 | #define CHANNEL_GROUP_MAX 3 | ||
62 | 60 | ||
63 | #define CT_OFFSET_MAC_ADDR 0X16 | 61 | #define CT_OFFSET_MAC_ADDR 0X16 |
64 | 62 | ||
@@ -78,9 +76,7 @@ | |||
78 | #define CT_OFFSET_CUSTOMER_ID 0x7F | 76 | #define CT_OFFSET_CUSTOMER_ID 0x7F |
79 | 77 | ||
80 | #define RTL92C_MAX_PATH_NUM 2 | 78 | #define RTL92C_MAX_PATH_NUM 2 |
81 | #define CHANNEL_MAX_NUMBER 14 | 79 | #define LLT_LAST_ENTRY_OF_TX_PKT_BUFFER 255 |
82 | #define CHANNEL_GROUP_MAX 3 | ||
83 | |||
84 | enum swchnlcmd_id { | 80 | enum swchnlcmd_id { |
85 | CMDID_END, | 81 | CMDID_END, |
86 | CMDID_SET_TXPOWEROWER_LEVEL, | 82 | CMDID_SET_TXPOWEROWER_LEVEL, |
@@ -233,5 +229,6 @@ void rtl92c_phy_config_bb_external_pa(struct ieee80211_hw *hw); | |||
233 | void rtl92ce_phy_set_rf_on(struct ieee80211_hw *hw); | 229 | void rtl92ce_phy_set_rf_on(struct ieee80211_hw *hw); |
234 | bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); | 230 | bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); |
235 | void rtl92c_phy_set_io(struct ieee80211_hw *hw); | 231 | void rtl92c_phy_set_io(struct ieee80211_hw *hw); |
232 | void rtl92c_bb_block_on(struct ieee80211_hw *hw); | ||
236 | 233 | ||
237 | #endif | 234 | #endif |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h index 875d51465225..b0868a613841 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h | |||
@@ -63,7 +63,15 @@ | |||
63 | #define REG_LEDCFG3 0x004F | 63 | #define REG_LEDCFG3 0x004F |
64 | #define REG_FSIMR 0x0050 | 64 | #define REG_FSIMR 0x0050 |
65 | #define REG_FSISR 0x0054 | 65 | #define REG_FSISR 0x0054 |
66 | 66 | #define REG_HSIMR 0x0058 | |
67 | #define REG_HSISR 0x005c | ||
68 | |||
69 | /* RTL8723 WIFI/BT/GPS Multi-Function GPIO Pin Control. */ | ||
70 | #define REG_GPIO_PIN_CTRL_2 0x0060 | ||
71 | /* RTL8723 WIFI/BT/GPS Multi-Function GPIO Select. */ | ||
72 | #define REG_GPIO_IO_SEL_2 0x0062 | ||
73 | /* RTL8723 WIFI/BT/GPS Multi-Function control source. */ | ||
74 | #define REG_MULTI_FUNC_CTRL 0x0068 | ||
67 | #define REG_MCUFWDL 0x0080 | 75 | #define REG_MCUFWDL 0x0080 |
68 | 76 | ||
69 | #define REG_HMEBOX_EXT_0 0x0088 | 77 | #define REG_HMEBOX_EXT_0 0x0088 |
@@ -79,6 +87,7 @@ | |||
79 | #define REG_PCIE_MIO_INTD 0x00E8 | 87 | #define REG_PCIE_MIO_INTD 0x00E8 |
80 | #define REG_HPON_FSM 0x00EC | 88 | #define REG_HPON_FSM 0x00EC |
81 | #define REG_SYS_CFG 0x00F0 | 89 | #define REG_SYS_CFG 0x00F0 |
90 | #define REG_GPIO_OUTSTS 0x00F4 /* For RTL8723 only.*/ | ||
82 | 91 | ||
83 | #define REG_CR 0x0100 | 92 | #define REG_CR 0x0100 |
84 | #define REG_PBP 0x0104 | 93 | #define REG_PBP 0x0104 |
@@ -209,6 +218,8 @@ | |||
209 | #define REG_RDG_PIFS 0x0513 | 218 | #define REG_RDG_PIFS 0x0513 |
210 | #define REG_SIFS_CTX 0x0514 | 219 | #define REG_SIFS_CTX 0x0514 |
211 | #define REG_SIFS_TRX 0x0516 | 220 | #define REG_SIFS_TRX 0x0516 |
221 | #define REG_SIFS_CCK 0x0514 | ||
222 | #define REG_SIFS_OFDM 0x0516 | ||
212 | #define REG_AGGR_BREAK_TIME 0x051A | 223 | #define REG_AGGR_BREAK_TIME 0x051A |
213 | #define REG_SLOT 0x051B | 224 | #define REG_SLOT 0x051B |
214 | #define REG_TX_PTCL_CTRL 0x0520 | 225 | #define REG_TX_PTCL_CTRL 0x0520 |
@@ -261,6 +272,10 @@ | |||
261 | #define REG_MAC_SPEC_SIFS 0x063A | 272 | #define REG_MAC_SPEC_SIFS 0x063A |
262 | #define REG_RESP_SIFS_CCK 0x063C | 273 | #define REG_RESP_SIFS_CCK 0x063C |
263 | #define REG_RESP_SIFS_OFDM 0x063E | 274 | #define REG_RESP_SIFS_OFDM 0x063E |
275 | /* [15:8]SIFS_R2T_OFDM, [7:0]SIFS_R2T_CCK */ | ||
276 | #define REG_R2T_SIFS 0x063C | ||
277 | /* [15:8]SIFS_T2T_OFDM, [7:0]SIFS_T2T_CCK */ | ||
278 | #define REG_T2T_SIFS 0x063E | ||
264 | #define REG_ACKTO 0x0640 | 279 | #define REG_ACKTO 0x0640 |
265 | #define REG_CTS2TO 0x0641 | 280 | #define REG_CTS2TO 0x0641 |
266 | #define REG_EIFS 0x0642 | 281 | #define REG_EIFS 0x0642 |
@@ -641,9 +656,10 @@ | |||
641 | #define STOPBE BIT(1) | 656 | #define STOPBE BIT(1) |
642 | #define STOPBK BIT(0) | 657 | #define STOPBK BIT(0) |
643 | 658 | ||
644 | #define RCR_APPFCS BIT(31) | 659 | #define RCR_APP_FCS BIT(31) |
645 | #define RCR_APP_MIC BIT(30) | 660 | #define RCR_APP_MIC BIT(30) |
646 | #define RCR_APP_ICV BIT(29) | 661 | #define RCR_APP_ICV BIT(29) |
662 | #define RCR_APP_PHYSTS BIT(28) | ||
647 | #define RCR_APP_PHYST_RXFF BIT(28) | 663 | #define RCR_APP_PHYST_RXFF BIT(28) |
648 | #define RCR_APP_BA_SSN BIT(27) | 664 | #define RCR_APP_BA_SSN BIT(27) |
649 | #define RCR_ENMBID BIT(24) | 665 | #define RCR_ENMBID BIT(24) |
@@ -759,6 +775,7 @@ | |||
759 | 775 | ||
760 | #define BOOT_FROM_EEPROM BIT(4) | 776 | #define BOOT_FROM_EEPROM BIT(4) |
761 | #define EEPROM_EN BIT(5) | 777 | #define EEPROM_EN BIT(5) |
778 | #define EEPROMSEL BOOT_FROM_EEPROM | ||
762 | 779 | ||
763 | #define AFE_BGEN BIT(0) | 780 | #define AFE_BGEN BIT(0) |
764 | #define AFE_MBEN BIT(1) | 781 | #define AFE_MBEN BIT(1) |
@@ -876,6 +893,8 @@ | |||
876 | #define BD_MAC2 BIT(9) | 893 | #define BD_MAC2 BIT(9) |
877 | #define BD_MAC1 BIT(10) | 894 | #define BD_MAC1 BIT(10) |
878 | #define IC_MACPHY_MODE BIT(11) | 895 | #define IC_MACPHY_MODE BIT(11) |
896 | #define BT_FUNC BIT(16) | ||
897 | #define VENDOR_ID BIT(19) | ||
879 | #define PAD_HWPD_IDN BIT(22) | 898 | #define PAD_HWPD_IDN BIT(22) |
880 | #define TRP_VAUX_EN BIT(23) | 899 | #define TRP_VAUX_EN BIT(23) |
881 | #define TRP_BT_EN BIT(24) | 900 | #define TRP_BT_EN BIT(24) |
@@ -883,6 +902,28 @@ | |||
883 | #define BD_HCI_SEL BIT(26) | 902 | #define BD_HCI_SEL BIT(26) |
884 | #define TYPE_ID BIT(27) | 903 | #define TYPE_ID BIT(27) |
885 | 904 | ||
905 | /* REG_GPIO_OUTSTS (For RTL8723 only) */ | ||
906 | #define EFS_HCI_SEL (BIT(0)|BIT(1)) | ||
907 | #define PAD_HCI_SEL (BIT(2)|BIT(3)) | ||
908 | #define HCI_SEL (BIT(4)|BIT(5)) | ||
909 | #define PKG_SEL_HCI BIT(6) | ||
910 | #define FEN_GPS BIT(7) | ||
911 | #define FEN_BT BIT(8) | ||
912 | #define FEN_WL BIT(9) | ||
913 | #define FEN_PCI BIT(10) | ||
914 | #define FEN_USB BIT(11) | ||
915 | #define BTRF_HWPDN_N BIT(12) | ||
916 | #define WLRF_HWPDN_N BIT(13) | ||
917 | #define PDN_BT_N BIT(14) | ||
918 | #define PDN_GPS_N BIT(15) | ||
919 | #define BT_CTL_HWPDN BIT(16) | ||
920 | #define GPS_CTL_HWPDN BIT(17) | ||
921 | #define PPHY_SUSB BIT(20) | ||
922 | #define UPHY_SUSB BIT(21) | ||
923 | #define PCI_SUSEN BIT(22) | ||
924 | #define USB_SUSEN BIT(23) | ||
925 | #define RF_RL_ID (BIT(31) | BIT(30) | BIT(29) | BIT(28)) | ||
926 | |||
886 | #define CHIP_VER_RTL_MASK 0xF000 | 927 | #define CHIP_VER_RTL_MASK 0xF000 |
887 | #define CHIP_VER_RTL_SHIFT 12 | 928 | #define CHIP_VER_RTL_SHIFT 12 |
888 | 929 | ||
@@ -1035,7 +1076,7 @@ | |||
1035 | #define _RARF_RC7(x) (((x) & 0x1F) << 16) | 1076 | #define _RARF_RC7(x) (((x) & 0x1F) << 16) |
1036 | #define _RARF_RC8(x) (((x) & 0x1F) << 24) | 1077 | #define _RARF_RC8(x) (((x) & 0x1F) << 24) |
1037 | 1078 | ||
1038 | #define AC_PARAM_TXOP_LIMIT_OFFSET 16 | 1079 | #define AC_PARAM_TXOP_OFFSET 16 |
1039 | #define AC_PARAM_ECW_MAX_OFFSET 12 | 1080 | #define AC_PARAM_ECW_MAX_OFFSET 12 |
1040 | #define AC_PARAM_ECW_MIN_OFFSET 8 | 1081 | #define AC_PARAM_ECW_MIN_OFFSET 8 |
1041 | #define AC_PARAM_AIFS_OFFSET 0 | 1082 | #define AC_PARAM_AIFS_OFFSET 0 |
@@ -1184,6 +1225,30 @@ | |||
1184 | 1225 | ||
1185 | #define HAL_8192C_HW_GPIO_WPS_BIT BIT(2) | 1226 | #define HAL_8192C_HW_GPIO_WPS_BIT BIT(2) |
1186 | 1227 | ||
1228 | /* REG_MULTI_FUNC_CTRL(For RTL8723 Only) */ | ||
1229 | /* Enable GPIO[9] as WiFi HW PDn source */ | ||
1230 | #define WL_HWPDN_EN BIT(0) | ||
1231 | /* WiFi HW PDn polarity control */ | ||
1232 | #define WL_HWPDN_SL BIT(1) | ||
1233 | /* WiFi function enable */ | ||
1234 | #define WL_FUNC_EN BIT(2) | ||
1235 | /* Enable GPIO[9] as WiFi RF HW PDn source */ | ||
1236 | #define WL_HWROF_EN BIT(3) | ||
1237 | /* Enable GPIO[11] as BT HW PDn source */ | ||
1238 | #define BT_HWPDN_EN BIT(16) | ||
1239 | /* BT HW PDn polarity control */ | ||
1240 | #define BT_HWPDN_SL BIT(17) | ||
1241 | /* BT function enable */ | ||
1242 | #define BT_FUNC_EN BIT(18) | ||
1243 | /* Enable GPIO[11] as BT/GPS RF HW PDn source */ | ||
1244 | #define BT_HWROF_EN BIT(19) | ||
1245 | /* Enable GPIO[10] as GPS HW PDn source */ | ||
1246 | #define GPS_HWPDN_EN BIT(20) | ||
1247 | /* GPS HW PDn polarity control */ | ||
1248 | #define GPS_HWPDN_SL BIT(21) | ||
1249 | /* GPS function enable */ | ||
1250 | #define GPS_FUNC_EN BIT(22) | ||
1251 | |||
1187 | #define RPMAC_RESET 0x100 | 1252 | #define RPMAC_RESET 0x100 |
1188 | #define RPMAC_TXSTART 0x104 | 1253 | #define RPMAC_TXSTART 0x104 |
1189 | #define RPMAC_TXLEGACYSIG 0x108 | 1254 | #define RPMAC_TXLEGACYSIG 0x108 |
@@ -1496,7 +1561,7 @@ | |||
1496 | #define BTXHTSTBC 0x30 | 1561 | #define BTXHTSTBC 0x30 |
1497 | #define BTXHTADVANCECODING 0x40 | 1562 | #define BTXHTADVANCECODING 0x40 |
1498 | #define BTXHTSHORTGI 0x80 | 1563 | #define BTXHTSHORTGI 0x80 |
1499 | #define BTXHTNUMBERHT_LT F 0x300 | 1564 | #define BTXHTNUMBERHT_LTF 0x300 |
1500 | #define BTXHTCRC8 0x3fc00 | 1565 | #define BTXHTCRC8 0x3fc00 |
1501 | #define BCOUNTERRESET 0x10000 | 1566 | #define BCOUNTERRESET 0x10000 |
1502 | #define BNUMOFOFDMTX 0xffff | 1567 | #define BNUMOFOFDMTX 0xffff |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c index b366e8862929..b4df0b332832 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | |||
@@ -46,13 +46,13 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) | |||
46 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 46 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
47 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 47 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
48 | 48 | ||
49 | rtlpriv->dm.b_dm_initialgain_enable = 1; | 49 | rtlpriv->dm.dm_initialgain_enable = 1; |
50 | rtlpriv->dm.dm_flag = 0; | 50 | rtlpriv->dm.dm_flag = 0; |
51 | rtlpriv->dm.b_disable_framebursting = 0;; | 51 | rtlpriv->dm.disable_framebursting = 0; |
52 | rtlpriv->dm.thermalvalue = 0; | 52 | rtlpriv->dm.thermalvalue = 0; |
53 | rtlpci->transmit_config = CFENDFORM | BIT(12) | BIT(13); | 53 | rtlpci->transmit_config = CFENDFORM | BIT(12) | BIT(13); |
54 | 54 | ||
55 | rtlpci->receive_config = (RCR_APPFCS | | 55 | rtlpci->receive_config = (RCR_APP_FCS | |
56 | RCR_AMF | | 56 | RCR_AMF | |
57 | RCR_ADF | | 57 | RCR_ADF | |
58 | RCR_APP_MIC | | 58 | RCR_APP_MIC | |
@@ -135,6 +135,7 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = { | |||
135 | .set_bbreg = rtl92c_phy_set_bb_reg, | 135 | .set_bbreg = rtl92c_phy_set_bb_reg, |
136 | .get_rfreg = rtl92c_phy_query_rf_reg, | 136 | .get_rfreg = rtl92c_phy_query_rf_reg, |
137 | .set_rfreg = rtl92c_phy_set_rf_reg, | 137 | .set_rfreg = rtl92c_phy_set_rf_reg, |
138 | .cmd_send_packet = _rtl92c_cmd_send_packet, | ||
138 | }; | 139 | }; |
139 | 140 | ||
140 | static struct rtl_mod_params rtl92ce_mod_params = { | 141 | static struct rtl_mod_params rtl92ce_mod_params = { |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h index de1198c38d4e..0568d6dc83d7 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h | |||
@@ -33,5 +33,7 @@ | |||
33 | int rtl92c_init_sw_vars(struct ieee80211_hw *hw); | 33 | int rtl92c_init_sw_vars(struct ieee80211_hw *hw); |
34 | void rtl92c_deinit_sw_vars(struct ieee80211_hw *hw); | 34 | void rtl92c_deinit_sw_vars(struct ieee80211_hw *hw); |
35 | void rtl92c_init_var_map(struct ieee80211_hw *hw); | 35 | void rtl92c_init_var_map(struct ieee80211_hw *hw); |
36 | bool _rtl92c_cmd_send_packet(struct ieee80211_hw *hw, | ||
37 | struct sk_buff *skb); | ||
36 | 38 | ||
37 | #endif | 39 | #endif |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c index bf5852f2d634..01b95427fee0 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include "trx.h" | 36 | #include "trx.h" |
37 | #include "led.h" | 37 | #include "led.h" |
38 | 38 | ||
39 | static enum rtl_desc_qsel _rtl92ce_map_hwqueue_to_fwqueue(u16 fc, | 39 | static enum rtl_desc_qsel _rtl92ce_map_hwqueue_to_fwqueue(__le16 fc, |
40 | unsigned int | 40 | unsigned int |
41 | skb_queue) | 41 | skb_queue) |
42 | { | 42 | { |
@@ -245,9 +245,9 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw, | |||
245 | struct rtl_stats *pstats, | 245 | struct rtl_stats *pstats, |
246 | struct rx_desc_92c *pdesc, | 246 | struct rx_desc_92c *pdesc, |
247 | struct rx_fwinfo_92c *p_drvinfo, | 247 | struct rx_fwinfo_92c *p_drvinfo, |
248 | bool bpacket_match_bssid, | 248 | bool packet_match_bssid, |
249 | bool bpacket_toself, | 249 | bool packet_toself, |
250 | bool b_packet_beacon) | 250 | bool packet_beacon) |
251 | { | 251 | { |
252 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 252 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
253 | struct phy_sts_cck_8192s_t *cck_buf; | 253 | struct phy_sts_cck_8192s_t *cck_buf; |
@@ -258,11 +258,11 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw, | |||
258 | bool is_cck_rate; | 258 | bool is_cck_rate; |
259 | 259 | ||
260 | is_cck_rate = RX_HAL_IS_CCK_RATE(pdesc); | 260 | is_cck_rate = RX_HAL_IS_CCK_RATE(pdesc); |
261 | pstats->b_packet_matchbssid = bpacket_match_bssid; | 261 | pstats->packet_matchbssid = packet_match_bssid; |
262 | pstats->b_packet_toself = bpacket_toself; | 262 | pstats->packet_toself = packet_toself; |
263 | pstats->b_is_cck = is_cck_rate; | 263 | pstats->is_cck = is_cck_rate; |
264 | pstats->b_packet_beacon = b_packet_beacon; | 264 | pstats->packet_beacon = packet_beacon; |
265 | pstats->b_is_cck = is_cck_rate; | 265 | pstats->is_cck = is_cck_rate; |
266 | pstats->rx_mimo_signalquality[0] = -1; | 266 | pstats->rx_mimo_signalquality[0] = -1; |
267 | pstats->rx_mimo_signalquality[1] = -1; | 267 | pstats->rx_mimo_signalquality[1] = -1; |
268 | 268 | ||
@@ -315,7 +315,7 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw, | |||
315 | pstats->rx_pwdb_all = pwdb_all; | 315 | pstats->rx_pwdb_all = pwdb_all; |
316 | pstats->recvsignalpower = rx_pwr_all; | 316 | pstats->recvsignalpower = rx_pwr_all; |
317 | 317 | ||
318 | if (bpacket_match_bssid) { | 318 | if (packet_match_bssid) { |
319 | u8 sq; | 319 | u8 sq; |
320 | if (pstats->rx_pwdb_all > 40) | 320 | if (pstats->rx_pwdb_all > 40) |
321 | sq = 100; | 321 | sq = 100; |
@@ -334,10 +334,10 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw, | |||
334 | pstats->rx_mimo_signalquality[1] = -1; | 334 | pstats->rx_mimo_signalquality[1] = -1; |
335 | } | 335 | } |
336 | } else { | 336 | } else { |
337 | rtlpriv->dm.brfpath_rxenable[0] = | 337 | rtlpriv->dm.rfpath_rxenable[0] = |
338 | rtlpriv->dm.brfpath_rxenable[1] = true; | 338 | rtlpriv->dm.rfpath_rxenable[1] = true; |
339 | for (i = RF90_PATH_A; i < RF90_PATH_MAX; i++) { | 339 | for (i = RF90_PATH_A; i < RF90_PATH_MAX; i++) { |
340 | if (rtlpriv->dm.brfpath_rxenable[i]) | 340 | if (rtlpriv->dm.rfpath_rxenable[i]) |
341 | rf_rx_num++; | 341 | rf_rx_num++; |
342 | 342 | ||
343 | rx_pwr[i] = | 343 | rx_pwr[i] = |
@@ -347,7 +347,7 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw, | |||
347 | rtlpriv->stats.rx_snr_db[i] = | 347 | rtlpriv->stats.rx_snr_db[i] = |
348 | (long)(p_drvinfo->rxsnr[i] / 2); | 348 | (long)(p_drvinfo->rxsnr[i] / 2); |
349 | 349 | ||
350 | if (bpacket_match_bssid) | 350 | if (packet_match_bssid) |
351 | pstats->rx_mimo_signalstrength[i] = (u8) rssi; | 351 | pstats->rx_mimo_signalstrength[i] = (u8) rssi; |
352 | } | 352 | } |
353 | 353 | ||
@@ -366,7 +366,7 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw, | |||
366 | for (i = 0; i < max_spatial_stream; i++) { | 366 | for (i = 0; i < max_spatial_stream; i++) { |
367 | evm = _rtl92c_evm_db_to_percentage(p_drvinfo->rxevm[i]); | 367 | evm = _rtl92c_evm_db_to_percentage(p_drvinfo->rxevm[i]); |
368 | 368 | ||
369 | if (bpacket_match_bssid) { | 369 | if (packet_match_bssid) { |
370 | if (i == 0) | 370 | if (i == 0) |
371 | pstats->signalquality = | 371 | pstats->signalquality = |
372 | (u8) (evm & 0xff); | 372 | (u8) (evm & 0xff); |
@@ -393,7 +393,7 @@ static void _rtl92ce_process_ui_rssi(struct ieee80211_hw *hw, | |||
393 | u8 rfpath; | 393 | u8 rfpath; |
394 | u32 last_rssi, tmpval; | 394 | u32 last_rssi, tmpval; |
395 | 395 | ||
396 | if (pstats->b_packet_toself || pstats->b_packet_beacon) { | 396 | if (pstats->packet_toself || pstats->packet_beacon) { |
397 | rtlpriv->stats.rssi_calculate_cnt++; | 397 | rtlpriv->stats.rssi_calculate_cnt++; |
398 | 398 | ||
399 | if (rtlpriv->stats.ui_rssi.total_num++ >= | 399 | if (rtlpriv->stats.ui_rssi.total_num++ >= |
@@ -421,7 +421,7 @@ static void _rtl92ce_process_ui_rssi(struct ieee80211_hw *hw, | |||
421 | pstats->rssi = rtlpriv->stats.signal_strength; | 421 | pstats->rssi = rtlpriv->stats.signal_strength; |
422 | } | 422 | } |
423 | 423 | ||
424 | if (!pstats->b_is_cck && pstats->b_packet_toself) { | 424 | if (!pstats->is_cck && pstats->packet_toself) { |
425 | for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; | 425 | for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; |
426 | rfpath++) { | 426 | rfpath++) { |
427 | 427 | ||
@@ -493,7 +493,7 @@ static void _rtl92ce_process_pwdb(struct ieee80211_hw *hw, | |||
493 | rtlpriv->dm.undecorated_smoothed_pwdb; | 493 | rtlpriv->dm.undecorated_smoothed_pwdb; |
494 | } | 494 | } |
495 | 495 | ||
496 | if (pstats->b_packet_toself || pstats->b_packet_beacon) { | 496 | if (pstats->packet_toself || pstats->packet_beacon) { |
497 | if (undecorated_smoothed_pwdb < 0) | 497 | if (undecorated_smoothed_pwdb < 0) |
498 | undecorated_smoothed_pwdb = pstats->rx_pwdb_all; | 498 | undecorated_smoothed_pwdb = pstats->rx_pwdb_all; |
499 | 499 | ||
@@ -525,7 +525,7 @@ static void _rtl92ce_process_ui_link_quality(struct ieee80211_hw *hw, | |||
525 | u32 last_evm, n_spatialstream, tmpval; | 525 | u32 last_evm, n_spatialstream, tmpval; |
526 | 526 | ||
527 | if (pstats->signalquality != 0) { | 527 | if (pstats->signalquality != 0) { |
528 | if (pstats->b_packet_toself || pstats->b_packet_beacon) { | 528 | if (pstats->packet_toself || pstats->packet_beacon) { |
529 | 529 | ||
530 | if (rtlpriv->stats.ui_link_quality.total_num++ >= | 530 | if (rtlpriv->stats.ui_link_quality.total_num++ >= |
531 | PHY_LINKQUALITY_SLID_WIN_MAX) { | 531 | PHY_LINKQUALITY_SLID_WIN_MAX) { |
@@ -595,8 +595,8 @@ static void _rtl92ce_process_phyinfo(struct ieee80211_hw *hw, | |||
595 | struct rtl_stats *pcurrent_stats) | 595 | struct rtl_stats *pcurrent_stats) |
596 | { | 596 | { |
597 | 597 | ||
598 | if (!pcurrent_stats->b_packet_matchbssid && | 598 | if (!pcurrent_stats->packet_matchbssid && |
599 | !pcurrent_stats->b_packet_beacon) | 599 | !pcurrent_stats->packet_beacon) |
600 | return; | 600 | return; |
601 | 601 | ||
602 | _rtl92ce_process_ui_rssi(hw, pcurrent_stats); | 602 | _rtl92ce_process_ui_rssi(hw, pcurrent_stats); |
@@ -617,34 +617,36 @@ static void _rtl92ce_translate_rx_signal_stuff(struct ieee80211_hw *hw, | |||
617 | u8 *tmp_buf; | 617 | u8 *tmp_buf; |
618 | u8 *praddr; | 618 | u8 *praddr; |
619 | u8 *psaddr; | 619 | u8 *psaddr; |
620 | u16 fc, type; | 620 | __le16 fc; |
621 | bool b_packet_matchbssid, b_packet_toself, b_packet_beacon; | 621 | u16 type, c_fc; |
622 | bool packet_matchbssid, packet_toself, packet_beacon; | ||
622 | 623 | ||
623 | tmp_buf = skb->data + pstats->rx_drvinfo_size + pstats->rx_bufshift; | 624 | tmp_buf = skb->data + pstats->rx_drvinfo_size + pstats->rx_bufshift; |
624 | 625 | ||
625 | hdr = (struct ieee80211_hdr *)tmp_buf; | 626 | hdr = (struct ieee80211_hdr *)tmp_buf; |
626 | fc = le16_to_cpu(hdr->frame_control); | 627 | fc = hdr->frame_control; |
628 | c_fc = le16_to_cpu(fc); | ||
627 | type = WLAN_FC_GET_TYPE(fc); | 629 | type = WLAN_FC_GET_TYPE(fc); |
628 | praddr = hdr->addr1; | 630 | praddr = hdr->addr1; |
629 | psaddr = hdr->addr2; | 631 | psaddr = hdr->addr2; |
630 | 632 | ||
631 | b_packet_matchbssid = | 633 | packet_matchbssid = |
632 | ((IEEE80211_FTYPE_CTL != type) && | 634 | ((IEEE80211_FTYPE_CTL != type) && |
633 | (!compare_ether_addr(mac->bssid, | 635 | (!compare_ether_addr(mac->bssid, |
634 | (fc & IEEE80211_FCTL_TODS) ? | 636 | (c_fc & IEEE80211_FCTL_TODS) ? |
635 | hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? | 637 | hdr->addr1 : (c_fc & IEEE80211_FCTL_FROMDS) ? |
636 | hdr->addr2 : hdr->addr3)) && | 638 | hdr->addr2 : hdr->addr3)) && |
637 | (!pstats->b_hwerror) && (!pstats->b_crc) && (!pstats->b_icv)); | 639 | (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv)); |
638 | 640 | ||
639 | b_packet_toself = b_packet_matchbssid && | 641 | packet_toself = packet_matchbssid && |
640 | (!compare_ether_addr(praddr, rtlefuse->dev_addr)); | 642 | (!compare_ether_addr(praddr, rtlefuse->dev_addr)); |
641 | 643 | ||
642 | if (ieee80211_is_beacon(fc)) | 644 | if (ieee80211_is_beacon(fc)) |
643 | b_packet_beacon = true; | 645 | packet_beacon = true; |
644 | 646 | ||
645 | _rtl92ce_query_rxphystatus(hw, pstats, pdesc, p_drvinfo, | 647 | _rtl92ce_query_rxphystatus(hw, pstats, pdesc, p_drvinfo, |
646 | b_packet_matchbssid, b_packet_toself, | 648 | packet_matchbssid, packet_toself, |
647 | b_packet_beacon); | 649 | packet_beacon); |
648 | 650 | ||
649 | _rtl92ce_process_phyinfo(hw, tmp_buf, pstats); | 651 | _rtl92ce_process_phyinfo(hw, tmp_buf, pstats); |
650 | } | 652 | } |
@@ -662,14 +664,14 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw, | |||
662 | stats->rx_drvinfo_size = (u8) GET_RX_DESC_DRV_INFO_SIZE(pdesc) * | 664 | stats->rx_drvinfo_size = (u8) GET_RX_DESC_DRV_INFO_SIZE(pdesc) * |
663 | RX_DRV_INFO_SIZE_UNIT; | 665 | RX_DRV_INFO_SIZE_UNIT; |
664 | stats->rx_bufshift = (u8) (GET_RX_DESC_SHIFT(pdesc) & 0x03); | 666 | stats->rx_bufshift = (u8) (GET_RX_DESC_SHIFT(pdesc) & 0x03); |
665 | stats->b_icv = (u16) GET_RX_DESC_ICV(pdesc); | 667 | stats->icv = (u16) GET_RX_DESC_ICV(pdesc); |
666 | stats->b_crc = (u16) GET_RX_DESC_CRC32(pdesc); | 668 | stats->crc = (u16) GET_RX_DESC_CRC32(pdesc); |
667 | stats->b_hwerror = (stats->b_crc | stats->b_icv); | 669 | stats->hwerror = (stats->crc | stats->icv); |
668 | stats->decrypted = !GET_RX_DESC_SWDEC(pdesc); | 670 | stats->decrypted = !GET_RX_DESC_SWDEC(pdesc); |
669 | stats->rate = (u8) GET_RX_DESC_RXMCS(pdesc); | 671 | stats->rate = (u8) GET_RX_DESC_RXMCS(pdesc); |
670 | stats->b_shortpreamble = (u16) GET_RX_DESC_SPLCP(pdesc); | 672 | stats->shortpreamble = (u16) GET_RX_DESC_SPLCP(pdesc); |
671 | stats->b_isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1); | 673 | stats->isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1); |
672 | stats->b_isampdu = (bool) ((GET_RX_DESC_PAGGR(pdesc) == 1) | 674 | stats->isampdu = (bool) ((GET_RX_DESC_PAGGR(pdesc) == 1) |
673 | && (GET_RX_DESC_FAGGR(pdesc) == 1)); | 675 | && (GET_RX_DESC_FAGGR(pdesc) == 1)); |
674 | stats->timestamp_low = GET_RX_DESC_TSFL(pdesc); | 676 | stats->timestamp_low = GET_RX_DESC_TSFL(pdesc); |
675 | stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc); | 677 | stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc); |
@@ -727,27 +729,24 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, | |||
727 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 729 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
728 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 730 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
729 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | 731 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); |
730 | bool b_defaultadapter = true; | 732 | bool defaultadapter = true; |
731 | |||
732 | struct ieee80211_sta *sta = ieee80211_find_sta(mac->vif, mac->bssid); | 733 | struct ieee80211_sta *sta = ieee80211_find_sta(mac->vif, mac->bssid); |
733 | |||
734 | u8 *pdesc = (u8 *) pdesc_tx; | 734 | u8 *pdesc = (u8 *) pdesc_tx; |
735 | struct rtl_tcb_desc tcb_desc; | 735 | struct rtl_tcb_desc tcb_desc; |
736 | u8 *qc = ieee80211_get_qos_ctl(hdr); | 736 | u8 *qc = ieee80211_get_qos_ctl(hdr); |
737 | u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; | 737 | u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; |
738 | u16 seq_number; | 738 | u16 seq_number; |
739 | u16 fc = le16_to_cpu(hdr->frame_control); | 739 | __le16 fc = hdr->frame_control; |
740 | u8 rate_flag = info->control.rates[0].flags; | 740 | u8 rate_flag = info->control.rates[0].flags; |
741 | 741 | ||
742 | enum rtl_desc_qsel fw_qsel = | 742 | enum rtl_desc_qsel fw_qsel = |
743 | _rtl92ce_map_hwqueue_to_fwqueue(le16_to_cpu(hdr->frame_control), | 743 | _rtl92ce_map_hwqueue_to_fwqueue(fc, queue_index); |
744 | queue_index); | ||
745 | 744 | ||
746 | bool b_firstseg = ((hdr->seq_ctrl & | 745 | bool firstseg = ((hdr->seq_ctrl & |
747 | cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0); | 746 | cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0); |
748 | 747 | ||
749 | bool b_lastseg = ((hdr->frame_control & | 748 | bool lastseg = ((hdr->frame_control & |
750 | cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0); | 749 | cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0); |
751 | 750 | ||
752 | dma_addr_t mapping = pci_map_single(rtlpci->pdev, | 751 | dma_addr_t mapping = pci_map_single(rtlpci->pdev, |
753 | skb->data, skb->len, | 752 | skb->data, skb->len, |
@@ -759,7 +758,7 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, | |||
759 | 758 | ||
760 | CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_92c)); | 759 | CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_92c)); |
761 | 760 | ||
762 | if (b_firstseg) { | 761 | if (firstseg) { |
763 | SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); | 762 | SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); |
764 | 763 | ||
765 | SET_TX_DESC_TX_RATE(pdesc, tcb_desc.hw_rate); | 764 | SET_TX_DESC_TX_RATE(pdesc, tcb_desc.hw_rate); |
@@ -774,25 +773,25 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, | |||
774 | } | 773 | } |
775 | SET_TX_DESC_SEQ(pdesc, seq_number); | 774 | SET_TX_DESC_SEQ(pdesc, seq_number); |
776 | 775 | ||
777 | SET_TX_DESC_RTS_ENABLE(pdesc, ((tcb_desc.b_rts_enable && | 776 | SET_TX_DESC_RTS_ENABLE(pdesc, ((tcb_desc.rts_enable && |
778 | !tcb_desc. | 777 | !tcb_desc. |
779 | b_cts_enable) ? 1 : 0)); | 778 | cts_enable) ? 1 : 0)); |
780 | SET_TX_DESC_HW_RTS_ENABLE(pdesc, | 779 | SET_TX_DESC_HW_RTS_ENABLE(pdesc, |
781 | ((tcb_desc.b_rts_enable | 780 | ((tcb_desc.rts_enable |
782 | || tcb_desc.b_cts_enable) ? 1 : 0)); | 781 | || tcb_desc.cts_enable) ? 1 : 0)); |
783 | SET_TX_DESC_CTS2SELF(pdesc, ((tcb_desc.b_cts_enable) ? 1 : 0)); | 782 | SET_TX_DESC_CTS2SELF(pdesc, ((tcb_desc.cts_enable) ? 1 : 0)); |
784 | SET_TX_DESC_RTS_STBC(pdesc, ((tcb_desc.b_rts_stbc) ? 1 : 0)); | 783 | SET_TX_DESC_RTS_STBC(pdesc, ((tcb_desc.rts_stbc) ? 1 : 0)); |
785 | 784 | ||
786 | SET_TX_DESC_RTS_RATE(pdesc, tcb_desc.rts_rate); | 785 | SET_TX_DESC_RTS_RATE(pdesc, tcb_desc.rts_rate); |
787 | SET_TX_DESC_RTS_BW(pdesc, 0); | 786 | SET_TX_DESC_RTS_BW(pdesc, 0); |
788 | SET_TX_DESC_RTS_SC(pdesc, tcb_desc.rts_sc); | 787 | SET_TX_DESC_RTS_SC(pdesc, tcb_desc.rts_sc); |
789 | SET_TX_DESC_RTS_SHORT(pdesc, | 788 | SET_TX_DESC_RTS_SHORT(pdesc, |
790 | ((tcb_desc.rts_rate <= DESC92C_RATE54M) ? | 789 | ((tcb_desc.rts_rate <= DESC92C_RATE54M) ? |
791 | (tcb_desc.b_rts_use_shortpreamble ? 1 : 0) | 790 | (tcb_desc.rts_use_shortpreamble ? 1 : 0) |
792 | : (tcb_desc.b_rts_use_shortgi ? 1 : 0))); | 791 | : (tcb_desc.rts_use_shortgi ? 1 : 0))); |
793 | 792 | ||
794 | if (mac->bw_40) { | 793 | if (mac->bw_40) { |
795 | if (tcb_desc.b_packet_bw) { | 794 | if (tcb_desc.packet_bw) { |
796 | SET_TX_DESC_DATA_BW(pdesc, 1); | 795 | SET_TX_DESC_DATA_BW(pdesc, 1); |
797 | SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); | 796 | SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); |
798 | } else { | 797 | } else { |
@@ -854,14 +853,14 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, | |||
854 | } | 853 | } |
855 | } | 854 | } |
856 | 855 | ||
857 | SET_TX_DESC_FIRST_SEG(pdesc, (b_firstseg ? 1 : 0)); | 856 | SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0)); |
858 | SET_TX_DESC_LAST_SEG(pdesc, (b_lastseg ? 1 : 0)); | 857 | SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0)); |
859 | 858 | ||
860 | SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) skb->len); | 859 | SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) skb->len); |
861 | 860 | ||
862 | SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, cpu_to_le32(mapping)); | 861 | SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, cpu_to_le32(mapping)); |
863 | 862 | ||
864 | if (rtlpriv->dm.b_useramask) { | 863 | if (rtlpriv->dm.useramask) { |
865 | SET_TX_DESC_RATE_ID(pdesc, tcb_desc.ratr_index); | 864 | SET_TX_DESC_RATE_ID(pdesc, tcb_desc.ratr_index); |
866 | SET_TX_DESC_MACID(pdesc, tcb_desc.mac_id); | 865 | SET_TX_DESC_MACID(pdesc, tcb_desc.mac_id); |
867 | } else { | 866 | } else { |
@@ -869,16 +868,16 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, | |||
869 | SET_TX_DESC_MACID(pdesc, tcb_desc.ratr_index); | 868 | SET_TX_DESC_MACID(pdesc, tcb_desc.ratr_index); |
870 | } | 869 | } |
871 | 870 | ||
872 | if ((!ieee80211_is_data_qos(fc)) && ppsc->b_leisure_ps && | 871 | if ((!ieee80211_is_data_qos(fc)) && ppsc->leisure_ps && |
873 | ppsc->b_fwctrl_lps) { | 872 | ppsc->fwctrl_lps) { |
874 | SET_TX_DESC_HWSEQ_EN(pdesc, 1); | 873 | SET_TX_DESC_HWSEQ_EN(pdesc, 1); |
875 | SET_TX_DESC_PKT_ID(pdesc, 8); | 874 | SET_TX_DESC_PKT_ID(pdesc, 8); |
876 | 875 | ||
877 | if (!b_defaultadapter) | 876 | if (!defaultadapter) |
878 | SET_TX_DESC_QOS(pdesc, 1); | 877 | SET_TX_DESC_QOS(pdesc, 1); |
879 | } | 878 | } |
880 | 879 | ||
881 | SET_TX_DESC_MORE_FRAG(pdesc, (b_lastseg ? 0 : 1)); | 880 | SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); |
882 | 881 | ||
883 | if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || | 882 | if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || |
884 | is_broadcast_ether_addr(ieee80211_get_DA(hdr))) { | 883 | is_broadcast_ether_addr(ieee80211_get_DA(hdr))) { |
@@ -889,8 +888,8 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, | |||
889 | } | 888 | } |
890 | 889 | ||
891 | void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, | 890 | void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, |
892 | u8 *pdesc, bool b_firstseg, | 891 | u8 *pdesc, bool firstseg, |
893 | bool b_lastseg, struct sk_buff *skb) | 892 | bool lastseg, struct sk_buff *skb) |
894 | { | 893 | { |
895 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 894 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
896 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 895 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
@@ -901,11 +900,11 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, | |||
901 | PCI_DMA_TODEVICE); | 900 | PCI_DMA_TODEVICE); |
902 | 901 | ||
903 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); | 902 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); |
904 | u16 fc = le16_to_cpu(hdr->frame_control); | 903 | __le16 fc = hdr->frame_control; |
905 | 904 | ||
906 | CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE); | 905 | CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE); |
907 | 906 | ||
908 | if (b_firstseg) | 907 | if (firstseg) |
909 | SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); | 908 | SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); |
910 | 909 | ||
911 | SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE1M); | 910 | SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE1M); |
@@ -1029,3 +1028,36 @@ void rtl92ce_tx_polling(struct ieee80211_hw *hw, unsigned int hw_queue) | |||
1029 | BIT(0) << (hw_queue)); | 1028 | BIT(0) << (hw_queue)); |
1030 | } | 1029 | } |
1031 | } | 1030 | } |
1031 | |||
1032 | bool _rtl92c_cmd_send_packet(struct ieee80211_hw *hw, | ||
1033 | struct sk_buff *skb) | ||
1034 | { | ||
1035 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1036 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||
1037 | struct rtl8192_tx_ring *ring; | ||
1038 | struct rtl_tx_desc *pdesc; | ||
1039 | u8 own; | ||
1040 | unsigned long flags; | ||
1041 | struct sk_buff *pskb = NULL; | ||
1042 | |||
1043 | ring = &rtlpci->tx_ring[BEACON_QUEUE]; | ||
1044 | |||
1045 | spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); | ||
1046 | |||
1047 | pskb = __skb_dequeue(&ring->queue); | ||
1048 | if (pskb) | ||
1049 | kfree_skb(pskb); | ||
1050 | |||
1051 | pdesc = &ring->desc[0]; | ||
1052 | own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, true, HW_DESC_OWN); | ||
1053 | |||
1054 | rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *) pdesc, 1, 1, skb); | ||
1055 | |||
1056 | __skb_queue_tail(&ring->queue, skb); | ||
1057 | |||
1058 | spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); | ||
1059 | |||
1060 | rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE); | ||
1061 | |||
1062 | return true; | ||
1063 | } | ||
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h index 53d0e0a5af5c..803adcc80c96 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h | |||
@@ -40,470 +40,494 @@ | |||
40 | #define USB_HWDESC_HEADER_LEN 32 | 40 | #define USB_HWDESC_HEADER_LEN 32 |
41 | #define CRCLENGTH 4 | 41 | #define CRCLENGTH 4 |
42 | 42 | ||
43 | /* Define a macro that takes a le32 word, converts it to host ordering, | ||
44 | * right shifts by a specified count, creates a mask of the specified | ||
45 | * bit count, and extracts that number of bits. | ||
46 | */ | ||
47 | |||
48 | #define SHIFT_AND_MASK_LE(__pdesc, __shift, __mask) \ | ||
49 | ((le32_to_cpu(*(((__le32 *)(__pdesc)))) >> (__shift)) & \ | ||
50 | BIT_LEN_MASK_32(__mask)) | ||
51 | |||
52 | /* Define a macro that clears a bit field in an le32 word and | ||
53 | * sets the specified value into that bit field. The resulting | ||
54 | * value remains in le32 ordering; however, it is properly converted | ||
55 | * to host ordering for the clear and set operations before conversion | ||
56 | * back to le32. | ||
57 | */ | ||
58 | |||
59 | #define SET_BITS_OFFSET_LE(__pdesc, __shift, __len, __val) \ | ||
60 | (*(__le32 *)(__pdesc) = \ | ||
61 | (cpu_to_le32((le32_to_cpu(*((__le32 *)(__pdesc))) & \ | ||
62 | (~(BIT_OFFSET_LEN_MASK_32((__shift), __len)))) | \ | ||
63 | (((u32)(__val) & BIT_LEN_MASK_32(__len)) << (__shift))))); | ||
64 | |||
65 | /* macros to read/write various fields in RX or TX descriptors */ | ||
66 | |||
43 | #define SET_TX_DESC_PKT_SIZE(__pdesc, __val) \ | 67 | #define SET_TX_DESC_PKT_SIZE(__pdesc, __val) \ |
44 | SET_BITS_TO_LE_4BYTE(__pdesc, 0, 16, __val) | 68 | SET_BITS_OFFSET_LE(__pdesc, 0, 16, __val) |
45 | #define SET_TX_DESC_OFFSET(__pdesc, __val) \ | 69 | #define SET_TX_DESC_OFFSET(__pdesc, __val) \ |
46 | SET_BITS_TO_LE_4BYTE(__pdesc, 16, 8, __val) | 70 | SET_BITS_OFFSET_LE(__pdesc, 16, 8, __val) |
47 | #define SET_TX_DESC_BMC(__pdesc, __val) \ | 71 | #define SET_TX_DESC_BMC(__pdesc, __val) \ |
48 | SET_BITS_TO_LE_4BYTE(__pdesc, 24, 1, __val) | 72 | SET_BITS_OFFSET_LE(__pdesc, 24, 1, __val) |
49 | #define SET_TX_DESC_HTC(__pdesc, __val) \ | 73 | #define SET_TX_DESC_HTC(__pdesc, __val) \ |
50 | SET_BITS_TO_LE_4BYTE(__pdesc, 25, 1, __val) | 74 | SET_BITS_OFFSET_LE(__pdesc, 25, 1, __val) |
51 | #define SET_TX_DESC_LAST_SEG(__pdesc, __val) \ | 75 | #define SET_TX_DESC_LAST_SEG(__pdesc, __val) \ |
52 | SET_BITS_TO_LE_4BYTE(__pdesc, 26, 1, __val) | 76 | SET_BITS_OFFSET_LE(__pdesc, 26, 1, __val) |
53 | #define SET_TX_DESC_FIRST_SEG(__pdesc, __val) \ | 77 | #define SET_TX_DESC_FIRST_SEG(__pdesc, __val) \ |
54 | SET_BITS_TO_LE_4BYTE(__pdesc, 27, 1, __val) | 78 | SET_BITS_OFFSET_LE(__pdesc, 27, 1, __val) |
55 | #define SET_TX_DESC_LINIP(__pdesc, __val) \ | 79 | #define SET_TX_DESC_LINIP(__pdesc, __val) \ |
56 | SET_BITS_TO_LE_4BYTE(__pdesc, 28, 1, __val) | 80 | SET_BITS_OFFSET_LE(__pdesc, 28, 1, __val) |
57 | #define SET_TX_DESC_NO_ACM(__pdesc, __val) \ | 81 | #define SET_TX_DESC_NO_ACM(__pdesc, __val) \ |
58 | SET_BITS_TO_LE_4BYTE(__pdesc, 29, 1, __val) | 82 | SET_BITS_OFFSET_LE(__pdesc, 29, 1, __val) |
59 | #define SET_TX_DESC_GF(__pdesc, __val) \ | 83 | #define SET_TX_DESC_GF(__pdesc, __val) \ |
60 | SET_BITS_TO_LE_4BYTE(__pdesc, 30, 1, __val) | 84 | SET_BITS_OFFSET_LE(__pdesc, 30, 1, __val) |
61 | #define SET_TX_DESC_OWN(__pdesc, __val) \ | 85 | #define SET_TX_DESC_OWN(__pdesc, __val) \ |
62 | SET_BITS_TO_LE_4BYTE(__pdesc, 31, 1, __val) | 86 | SET_BITS_OFFSET_LE(__pdesc, 31, 1, __val) |
63 | 87 | ||
64 | #define GET_TX_DESC_PKT_SIZE(__pdesc) \ | 88 | #define GET_TX_DESC_PKT_SIZE(__pdesc) \ |
65 | LE_BITS_TO_4BYTE(__pdesc, 0, 16) | 89 | SHIFT_AND_MASK_LE(__pdesc, 0, 16) |
66 | #define GET_TX_DESC_OFFSET(__pdesc) \ | 90 | #define GET_TX_DESC_OFFSET(__pdesc) \ |
67 | LE_BITS_TO_4BYTE(__pdesc, 16, 8) | 91 | SHIFT_AND_MASK_LE(__pdesc, 16, 8) |
68 | #define GET_TX_DESC_BMC(__pdesc) \ | 92 | #define GET_TX_DESC_BMC(__pdesc) \ |
69 | LE_BITS_TO_4BYTE(__pdesc, 24, 1) | 93 | SHIFT_AND_MASK_LE(__pdesc, 24, 1) |
70 | #define GET_TX_DESC_HTC(__pdesc) \ | 94 | #define GET_TX_DESC_HTC(__pdesc) \ |
71 | LE_BITS_TO_4BYTE(__pdesc, 25, 1) | 95 | SHIFT_AND_MASK_LE(__pdesc, 25, 1) |
72 | #define GET_TX_DESC_LAST_SEG(__pdesc) \ | 96 | #define GET_TX_DESC_LAST_SEG(__pdesc) \ |
73 | LE_BITS_TO_4BYTE(__pdesc, 26, 1) | 97 | SHIFT_AND_MASK_LE(__pdesc, 26, 1) |
74 | #define GET_TX_DESC_FIRST_SEG(__pdesc) \ | 98 | #define GET_TX_DESC_FIRST_SEG(__pdesc) \ |
75 | LE_BITS_TO_4BYTE(__pdesc, 27, 1) | 99 | SHIFT_AND_MASK_LE(__pdesc, 27, 1) |
76 | #define GET_TX_DESC_LINIP(__pdesc) \ | 100 | #define GET_TX_DESC_LINIP(__pdesc) \ |
77 | LE_BITS_TO_4BYTE(__pdesc, 28, 1) | 101 | SHIFT_AND_MASK_LE(__pdesc, 28, 1) |
78 | #define GET_TX_DESC_NO_ACM(__pdesc) \ | 102 | #define GET_TX_DESC_NO_ACM(__pdesc) \ |
79 | LE_BITS_TO_4BYTE(__pdesc, 29, 1) | 103 | SHIFT_AND_MASK_LE(__pdesc, 29, 1) |
80 | #define GET_TX_DESC_GF(__pdesc) \ | 104 | #define GET_TX_DESC_GF(__pdesc) \ |
81 | LE_BITS_TO_4BYTE(__pdesc, 30, 1) | 105 | SHIFT_AND_MASK_LE(__pdesc, 30, 1) |
82 | #define GET_TX_DESC_OWN(__pdesc) \ | 106 | #define GET_TX_DESC_OWN(__pdesc) \ |
83 | LE_BITS_TO_4BYTE(__pdesc, 31, 1) | 107 | SHIFT_AND_MASK_LE(__pdesc, 31, 1) |
84 | 108 | ||
85 | #define SET_TX_DESC_MACID(__pdesc, __val) \ | 109 | #define SET_TX_DESC_MACID(__pdesc, __val) \ |
86 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 0, 5, __val) | 110 | SET_BITS_OFFSET_LE(__pdesc+4, 0, 5, __val) |
87 | #define SET_TX_DESC_AGG_BREAK(__pdesc, __val) \ | 111 | #define SET_TX_DESC_AGG_BREAK(__pdesc, __val) \ |
88 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 5, 1, __val) | 112 | SET_BITS_OFFSET_LE(__pdesc+4, 5, 1, __val) |
89 | #define SET_TX_DESC_BK(__pdesc, __val) \ | 113 | #define SET_TX_DESC_BK(__pdesc, __val) \ |
90 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 6, 1, __val) | 114 | SET_BITS_OFFSET_LE(__pdesc+4, 6, 1, __val) |
91 | #define SET_TX_DESC_RDG_ENABLE(__pdesc, __val) \ | 115 | #define SET_TX_DESC_RDG_ENABLE(__pdesc, __val) \ |
92 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 7, 1, __val) | 116 | SET_BITS_OFFSET_LE(__pdesc+4, 7, 1, __val) |
93 | #define SET_TX_DESC_QUEUE_SEL(__pdesc, __val) \ | 117 | #define SET_TX_DESC_QUEUE_SEL(__pdesc, __val) \ |
94 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 8, 5, __val) | 118 | SET_BITS_OFFSET_LE(__pdesc+4, 8, 5, __val) |
95 | #define SET_TX_DESC_RDG_NAV_EXT(__pdesc, __val) \ | 119 | #define SET_TX_DESC_RDG_NAV_EXT(__pdesc, __val) \ |
96 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 13, 1, __val) | 120 | SET_BITS_OFFSET_LE(__pdesc+4, 13, 1, __val) |
97 | #define SET_TX_DESC_LSIG_TXOP_EN(__pdesc, __val) \ | 121 | #define SET_TX_DESC_LSIG_TXOP_EN(__pdesc, __val) \ |
98 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 14, 1, __val) | 122 | SET_BITS_OFFSET_LE(__pdesc+4, 14, 1, __val) |
99 | #define SET_TX_DESC_PIFS(__pdesc, __val) \ | 123 | #define SET_TX_DESC_PIFS(__pdesc, __val) \ |
100 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 15, 1, __val) | 124 | SET_BITS_OFFSET_LE(__pdesc+4, 15, 1, __val) |
101 | #define SET_TX_DESC_RATE_ID(__pdesc, __val) \ | 125 | #define SET_TX_DESC_RATE_ID(__pdesc, __val) \ |
102 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 16, 4, __val) | 126 | SET_BITS_OFFSET_LE(__pdesc+4, 16, 4, __val) |
103 | #define SET_TX_DESC_NAV_USE_HDR(__pdesc, __val) \ | 127 | #define SET_TX_DESC_NAV_USE_HDR(__pdesc, __val) \ |
104 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 20, 1, __val) | 128 | SET_BITS_OFFSET_LE(__pdesc+4, 20, 1, __val) |
105 | #define SET_TX_DESC_EN_DESC_ID(__pdesc, __val) \ | 129 | #define SET_TX_DESC_EN_DESC_ID(__pdesc, __val) \ |
106 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 21, 1, __val) | 130 | SET_BITS_OFFSET_LE(__pdesc+4, 21, 1, __val) |
107 | #define SET_TX_DESC_SEC_TYPE(__pdesc, __val) \ | 131 | #define SET_TX_DESC_SEC_TYPE(__pdesc, __val) \ |
108 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 22, 2, __val) | 132 | SET_BITS_OFFSET_LE(__pdesc+4, 22, 2, __val) |
109 | #define SET_TX_DESC_PKT_OFFSET(__pdesc, __val) \ | 133 | #define SET_TX_DESC_PKT_OFFSET(__pdesc, __val) \ |
110 | SET_BITS_TO_LE_4BYTE(__pdesc+4, 24, 8, __val) | 134 | SET_BITS_OFFSET_LE(__pdesc+4, 24, 8, __val) |
111 | 135 | ||
112 | #define GET_TX_DESC_MACID(__pdesc) \ | 136 | #define GET_TX_DESC_MACID(__pdesc) \ |
113 | LE_BITS_TO_4BYTE(__pdesc+4, 0, 5) | 137 | SHIFT_AND_MASK_LE(__pdesc+4, 0, 5) |
114 | #define GET_TX_DESC_AGG_ENABLE(__pdesc) \ | 138 | #define GET_TX_DESC_AGG_ENABLE(__pdesc) \ |
115 | LE_BITS_TO_4BYTE(__pdesc+4, 5, 1) | 139 | SHIFT_AND_MASK_LE(__pdesc+4, 5, 1) |
116 | #define GET_TX_DESC_AGG_BREAK(__pdesc) \ | 140 | #define GET_TX_DESC_AGG_BREAK(__pdesc) \ |
117 | LE_BITS_TO_4BYTE(__pdesc+4, 6, 1) | 141 | SHIFT_AND_MASK_LE(__pdesc+4, 6, 1) |
118 | #define GET_TX_DESC_RDG_ENABLE(__pdesc) \ | 142 | #define GET_TX_DESC_RDG_ENABLE(__pdesc) \ |
119 | LE_BITS_TO_4BYTE(__pdesc+4, 7, 1) | 143 | SHIFT_AND_MASK_LE(__pdesc+4, 7, 1) |
120 | #define GET_TX_DESC_QUEUE_SEL(__pdesc) \ | 144 | #define GET_TX_DESC_QUEUE_SEL(__pdesc) \ |
121 | LE_BITS_TO_4BYTE(__pdesc+4, 8, 5) | 145 | SHIFT_AND_MASK_LE(__pdesc+4, 8, 5) |
122 | #define GET_TX_DESC_RDG_NAV_EXT(__pdesc) \ | 146 | #define GET_TX_DESC_RDG_NAV_EXT(__pdesc) \ |
123 | LE_BITS_TO_4BYTE(__pdesc+4, 13, 1) | 147 | SHIFT_AND_MASK_LE(__pdesc+4, 13, 1) |
124 | #define GET_TX_DESC_LSIG_TXOP_EN(__pdesc) \ | 148 | #define GET_TX_DESC_LSIG_TXOP_EN(__pdesc) \ |
125 | LE_BITS_TO_4BYTE(__pdesc+4, 14, 1) | 149 | SHIFT_AND_MASK_LE(__pdesc+4, 14, 1) |
126 | #define GET_TX_DESC_PIFS(__pdesc) \ | 150 | #define GET_TX_DESC_PIFS(__pdesc) \ |
127 | LE_BITS_TO_4BYTE(__pdesc+4, 15, 1) | 151 | SHIFT_AND_MASK_LE(__pdesc+4, 15, 1) |
128 | #define GET_TX_DESC_RATE_ID(__pdesc) \ | 152 | #define GET_TX_DESC_RATE_ID(__pdesc) \ |
129 | LE_BITS_TO_4BYTE(__pdesc+4, 16, 4) | 153 | SHIFT_AND_MASK_LE(__pdesc+4, 16, 4) |
130 | #define GET_TX_DESC_NAV_USE_HDR(__pdesc) \ | 154 | #define GET_TX_DESC_NAV_USE_HDR(__pdesc) \ |
131 | LE_BITS_TO_4BYTE(__pdesc+4, 20, 1) | 155 | SHIFT_AND_MASK_LE(__pdesc+4, 20, 1) |
132 | #define GET_TX_DESC_EN_DESC_ID(__pdesc) \ | 156 | #define GET_TX_DESC_EN_DESC_ID(__pdesc) \ |
133 | LE_BITS_TO_4BYTE(__pdesc+4, 21, 1) | 157 | SHIFT_AND_MASK_LE(__pdesc+4, 21, 1) |
134 | #define GET_TX_DESC_SEC_TYPE(__pdesc) \ | 158 | #define GET_TX_DESC_SEC_TYPE(__pdesc) \ |
135 | LE_BITS_TO_4BYTE(__pdesc+4, 22, 2) | 159 | SHIFT_AND_MASK_LE(__pdesc+4, 22, 2) |
136 | #define GET_TX_DESC_PKT_OFFSET(__pdesc) \ | 160 | #define GET_TX_DESC_PKT_OFFSET(__pdesc) \ |
137 | LE_BITS_TO_4BYTE(__pdesc+4, 24, 8) | 161 | SHIFT_AND_MASK_LE(__pdesc+4, 24, 8) |
138 | 162 | ||
139 | #define SET_TX_DESC_RTS_RC(__pdesc, __val) \ | 163 | #define SET_TX_DESC_RTS_RC(__pdesc, __val) \ |
140 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 0, 6, __val) | 164 | SET_BITS_OFFSET_LE(__pdesc+8, 0, 6, __val) |
141 | #define SET_TX_DESC_DATA_RC(__pdesc, __val) \ | 165 | #define SET_TX_DESC_DATA_RC(__pdesc, __val) \ |
142 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 6, 6, __val) | 166 | SET_BITS_OFFSET_LE(__pdesc+8, 6, 6, __val) |
143 | #define SET_TX_DESC_BAR_RTY_TH(__pdesc, __val) \ | 167 | #define SET_TX_DESC_BAR_RTY_TH(__pdesc, __val) \ |
144 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 14, 2, __val) | 168 | SET_BITS_OFFSET_LE(__pdesc+8, 14, 2, __val) |
145 | #define SET_TX_DESC_MORE_FRAG(__pdesc, __val) \ | 169 | #define SET_TX_DESC_MORE_FRAG(__pdesc, __val) \ |
146 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 17, 1, __val) | 170 | SET_BITS_OFFSET_LE(__pdesc+8, 17, 1, __val) |
147 | #define SET_TX_DESC_RAW(__pdesc, __val) \ | 171 | #define SET_TX_DESC_RAW(__pdesc, __val) \ |
148 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 18, 1, __val) | 172 | SET_BITS_OFFSET_LE(__pdesc+8, 18, 1, __val) |
149 | #define SET_TX_DESC_CCX(__pdesc, __val) \ | 173 | #define SET_TX_DESC_CCX(__pdesc, __val) \ |
150 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 19, 1, __val) | 174 | SET_BITS_OFFSET_LE(__pdesc+8, 19, 1, __val) |
151 | #define SET_TX_DESC_AMPDU_DENSITY(__pdesc, __val) \ | 175 | #define SET_TX_DESC_AMPDU_DENSITY(__pdesc, __val) \ |
152 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 20, 3, __val) | 176 | SET_BITS_OFFSET_LE(__pdesc+8, 20, 3, __val) |
153 | #define SET_TX_DESC_ANTSEL_A(__pdesc, __val) \ | 177 | #define SET_TX_DESC_ANTSEL_A(__pdesc, __val) \ |
154 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 24, 1, __val) | 178 | SET_BITS_OFFSET_LE(__pdesc+8, 24, 1, __val) |
155 | #define SET_TX_DESC_ANTSEL_B(__pdesc, __val) \ | 179 | #define SET_TX_DESC_ANTSEL_B(__pdesc, __val) \ |
156 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 25, 1, __val) | 180 | SET_BITS_OFFSET_LE(__pdesc+8, 25, 1, __val) |
157 | #define SET_TX_DESC_TX_ANT_CCK(__pdesc, __val) \ | 181 | #define SET_TX_DESC_TX_ANT_CCK(__pdesc, __val) \ |
158 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 26, 2, __val) | 182 | SET_BITS_OFFSET_LE(__pdesc+8, 26, 2, __val) |
159 | #define SET_TX_DESC_TX_ANTL(__pdesc, __val) \ | 183 | #define SET_TX_DESC_TX_ANTL(__pdesc, __val) \ |
160 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 28, 2, __val) | 184 | SET_BITS_OFFSET_LE(__pdesc+8, 28, 2, __val) |
161 | #define SET_TX_DESC_TX_ANT_HT(__pdesc, __val) \ | 185 | #define SET_TX_DESC_TX_ANT_HT(__pdesc, __val) \ |
162 | SET_BITS_TO_LE_4BYTE(__pdesc+8, 30, 2, __val) | 186 | SET_BITS_OFFSET_LE(__pdesc+8, 30, 2, __val) |
163 | 187 | ||
164 | #define GET_TX_DESC_RTS_RC(__pdesc) \ | 188 | #define GET_TX_DESC_RTS_RC(__pdesc) \ |
165 | LE_BITS_TO_4BYTE(__pdesc+8, 0, 6) | 189 | SHIFT_AND_MASK_LE(__pdesc+8, 0, 6) |
166 | #define GET_TX_DESC_DATA_RC(__pdesc) \ | 190 | #define GET_TX_DESC_DATA_RC(__pdesc) \ |
167 | LE_BITS_TO_4BYTE(__pdesc+8, 6, 6) | 191 | SHIFT_AND_MASK_LE(__pdesc+8, 6, 6) |
168 | #define GET_TX_DESC_BAR_RTY_TH(__pdesc) \ | 192 | #define GET_TX_DESC_BAR_RTY_TH(__pdesc) \ |
169 | LE_BITS_TO_4BYTE(__pdesc+8, 14, 2) | 193 | SHIFT_AND_MASK_LE(__pdesc+8, 14, 2) |
170 | #define GET_TX_DESC_MORE_FRAG(__pdesc) \ | 194 | #define GET_TX_DESC_MORE_FRAG(__pdesc) \ |
171 | LE_BITS_TO_4BYTE(__pdesc+8, 17, 1) | 195 | SHIFT_AND_MASK_LE(__pdesc+8, 17, 1) |
172 | #define GET_TX_DESC_RAW(__pdesc) \ | 196 | #define GET_TX_DESC_RAW(__pdesc) \ |
173 | LE_BITS_TO_4BYTE(__pdesc+8, 18, 1) | 197 | SHIFT_AND_MASK_LE(__pdesc+8, 18, 1) |
174 | #define GET_TX_DESC_CCX(__pdesc) \ | 198 | #define GET_TX_DESC_CCX(__pdesc) \ |
175 | LE_BITS_TO_4BYTE(__pdesc+8, 19, 1) | 199 | SHIFT_AND_MASK_LE(__pdesc+8, 19, 1) |
176 | #define GET_TX_DESC_AMPDU_DENSITY(__pdesc) \ | 200 | #define GET_TX_DESC_AMPDU_DENSITY(__pdesc) \ |
177 | LE_BITS_TO_4BYTE(__pdesc+8, 20, 3) | 201 | SHIFT_AND_MASK_LE(__pdesc+8, 20, 3) |
178 | #define GET_TX_DESC_ANTSEL_A(__pdesc) \ | 202 | #define GET_TX_DESC_ANTSEL_A(__pdesc) \ |
179 | LE_BITS_TO_4BYTE(__pdesc+8, 24, 1) | 203 | SHIFT_AND_MASK_LE(__pdesc+8, 24, 1) |
180 | #define GET_TX_DESC_ANTSEL_B(__pdesc) \ | 204 | #define GET_TX_DESC_ANTSEL_B(__pdesc) \ |
181 | LE_BITS_TO_4BYTE(__pdesc+8, 25, 1) | 205 | SHIFT_AND_MASK_LE(__pdesc+8, 25, 1) |
182 | #define GET_TX_DESC_TX_ANT_CCK(__pdesc) \ | 206 | #define GET_TX_DESC_TX_ANT_CCK(__pdesc) \ |
183 | LE_BITS_TO_4BYTE(__pdesc+8, 26, 2) | 207 | SHIFT_AND_MASK_LE(__pdesc+8, 26, 2) |
184 | #define GET_TX_DESC_TX_ANTL(__pdesc) \ | 208 | #define GET_TX_DESC_TX_ANTL(__pdesc) \ |
185 | LE_BITS_TO_4BYTE(__pdesc+8, 28, 2) | 209 | SHIFT_AND_MASK_LE(__pdesc+8, 28, 2) |
186 | #define GET_TX_DESC_TX_ANT_HT(__pdesc) \ | 210 | #define GET_TX_DESC_TX_ANT_HT(__pdesc) \ |
187 | LE_BITS_TO_4BYTE(__pdesc+8, 30, 2) | 211 | SHIFT_AND_MASK_LE(__pdesc+8, 30, 2) |
188 | 212 | ||
189 | #define SET_TX_DESC_NEXT_HEAP_PAGE(__pdesc, __val) \ | 213 | #define SET_TX_DESC_NEXT_HEAP_PAGE(__pdesc, __val) \ |
190 | SET_BITS_TO_LE_4BYTE(__pdesc+12, 0, 8, __val) | 214 | SET_BITS_OFFSET_LE(__pdesc+12, 0, 8, __val) |
191 | #define SET_TX_DESC_TAIL_PAGE(__pdesc, __val) \ | 215 | #define SET_TX_DESC_TAIL_PAGE(__pdesc, __val) \ |
192 | SET_BITS_TO_LE_4BYTE(__pdesc+12, 8, 8, __val) | 216 | SET_BITS_OFFSET_LE(__pdesc+12, 8, 8, __val) |
193 | #define SET_TX_DESC_SEQ(__pdesc, __val) \ | 217 | #define SET_TX_DESC_SEQ(__pdesc, __val) \ |
194 | SET_BITS_TO_LE_4BYTE(__pdesc+12, 16, 12, __val) | 218 | SET_BITS_OFFSET_LE(__pdesc+12, 16, 12, __val) |
195 | #define SET_TX_DESC_PKT_ID(__pdesc, __val) \ | 219 | #define SET_TX_DESC_PKT_ID(__pdesc, __val) \ |
196 | SET_BITS_TO_LE_4BYTE(__pdesc+12, 28, 4, __val) | 220 | SET_BITS_OFFSET_LE(__pdesc+12, 28, 4, __val) |
197 | 221 | ||
198 | #define GET_TX_DESC_NEXT_HEAP_PAGE(__pdesc) \ | 222 | #define GET_TX_DESC_NEXT_HEAP_PAGE(__pdesc) \ |
199 | LE_BITS_TO_4BYTE(__pdesc+12, 0, 8) | 223 | SHIFT_AND_MASK_LE(__pdesc+12, 0, 8) |
200 | #define GET_TX_DESC_TAIL_PAGE(__pdesc) \ | 224 | #define GET_TX_DESC_TAIL_PAGE(__pdesc) \ |
201 | LE_BITS_TO_4BYTE(__pdesc+12, 8, 8) | 225 | SHIFT_AND_MASK_LE(__pdesc+12, 8, 8) |
202 | #define GET_TX_DESC_SEQ(__pdesc) \ | 226 | #define GET_TX_DESC_SEQ(__pdesc) \ |
203 | LE_BITS_TO_4BYTE(__pdesc+12, 16, 12) | 227 | SHIFT_AND_MASK_LE(__pdesc+12, 16, 12) |
204 | #define GET_TX_DESC_PKT_ID(__pdesc) \ | 228 | #define GET_TX_DESC_PKT_ID(__pdesc) \ |
205 | LE_BITS_TO_4BYTE(__pdesc+12, 28, 4) | 229 | SHIFT_AND_MASK_LE(__pdesc+12, 28, 4) |
206 | 230 | ||
207 | #define SET_TX_DESC_RTS_RATE(__pdesc, __val) \ | 231 | #define SET_TX_DESC_RTS_RATE(__pdesc, __val) \ |
208 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 0, 5, __val) | 232 | SET_BITS_OFFSET_LE(__pdesc+16, 0, 5, __val) |
209 | #define SET_TX_DESC_AP_DCFE(__pdesc, __val) \ | 233 | #define SET_TX_DESC_AP_DCFE(__pdesc, __val) \ |
210 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 5, 1, __val) | 234 | SET_BITS_OFFSET_LE(__pdesc+16, 5, 1, __val) |
211 | #define SET_TX_DESC_QOS(__pdesc, __val) \ | 235 | #define SET_TX_DESC_QOS(__pdesc, __val) \ |
212 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 6, 1, __val) | 236 | SET_BITS_OFFSET_LE(__pdesc+16, 6, 1, __val) |
213 | #define SET_TX_DESC_HWSEQ_EN(__pdesc, __val) \ | 237 | #define SET_TX_DESC_HWSEQ_EN(__pdesc, __val) \ |
214 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 7, 1, __val) | 238 | SET_BITS_OFFSET_LE(__pdesc+16, 7, 1, __val) |
215 | #define SET_TX_DESC_USE_RATE(__pdesc, __val) \ | 239 | #define SET_TX_DESC_USE_RATE(__pdesc, __val) \ |
216 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 8, 1, __val) | 240 | SET_BITS_OFFSET_LE(__pdesc+16, 8, 1, __val) |
217 | #define SET_TX_DESC_DISABLE_RTS_FB(__pdesc, __val) \ | 241 | #define SET_TX_DESC_DISABLE_RTS_FB(__pdesc, __val) \ |
218 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 9, 1, __val) | 242 | SET_BITS_OFFSET_LE(__pdesc+16, 9, 1, __val) |
219 | #define SET_TX_DESC_DISABLE_FB(__pdesc, __val) \ | 243 | #define SET_TX_DESC_DISABLE_FB(__pdesc, __val) \ |
220 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 10, 1, __val) | 244 | SET_BITS_OFFSET_LE(__pdesc+16, 10, 1, __val) |
221 | #define SET_TX_DESC_CTS2SELF(__pdesc, __val) \ | 245 | #define SET_TX_DESC_CTS2SELF(__pdesc, __val) \ |
222 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 11, 1, __val) | 246 | SET_BITS_OFFSET_LE(__pdesc+16, 11, 1, __val) |
223 | #define SET_TX_DESC_RTS_ENABLE(__pdesc, __val) \ | 247 | #define SET_TX_DESC_RTS_ENABLE(__pdesc, __val) \ |
224 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 12, 1, __val) | 248 | SET_BITS_OFFSET_LE(__pdesc+16, 12, 1, __val) |
225 | #define SET_TX_DESC_HW_RTS_ENABLE(__pdesc, __val) \ | 249 | #define SET_TX_DESC_HW_RTS_ENABLE(__pdesc, __val) \ |
226 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 13, 1, __val) | 250 | SET_BITS_OFFSET_LE(__pdesc+16, 13, 1, __val) |
227 | #define SET_TX_DESC_PORT_ID(__pdesc, __val) \ | 251 | #define SET_TX_DESC_PORT_ID(__pdesc, __val) \ |
228 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 14, 1, __val) | 252 | SET_BITS_OFFSET_LE(__pdesc+16, 14, 1, __val) |
229 | #define SET_TX_DESC_WAIT_DCTS(__pdesc, __val) \ | 253 | #define SET_TX_DESC_WAIT_DCTS(__pdesc, __val) \ |
230 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 18, 1, __val) | 254 | SET_BITS_OFFSET_LE(__pdesc+16, 18, 1, __val) |
231 | #define SET_TX_DESC_CTS2AP_EN(__pdesc, __val) \ | 255 | #define SET_TX_DESC_CTS2AP_EN(__pdesc, __val) \ |
232 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 19, 1, __val) | 256 | SET_BITS_OFFSET_LE(__pdesc+16, 19, 1, __val) |
233 | #define SET_TX_DESC_TX_SUB_CARRIER(__pdesc, __val) \ | 257 | #define SET_TX_DESC_TX_SUB_CARRIER(__pdesc, __val) \ |
234 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 20, 2, __val) | 258 | SET_BITS_OFFSET_LE(__pdesc+16, 20, 2, __val) |
235 | #define SET_TX_DESC_TX_STBC(__pdesc, __val) \ | 259 | #define SET_TX_DESC_TX_STBC(__pdesc, __val) \ |
236 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 22, 2, __val) | 260 | SET_BITS_OFFSET_LE(__pdesc+16, 22, 2, __val) |
237 | #define SET_TX_DESC_DATA_SHORT(__pdesc, __val) \ | 261 | #define SET_TX_DESC_DATA_SHORT(__pdesc, __val) \ |
238 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 24, 1, __val) | 262 | SET_BITS_OFFSET_LE(__pdesc+16, 24, 1, __val) |
239 | #define SET_TX_DESC_DATA_BW(__pdesc, __val) \ | 263 | #define SET_TX_DESC_DATA_BW(__pdesc, __val) \ |
240 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 25, 1, __val) | 264 | SET_BITS_OFFSET_LE(__pdesc+16, 25, 1, __val) |
241 | #define SET_TX_DESC_RTS_SHORT(__pdesc, __val) \ | 265 | #define SET_TX_DESC_RTS_SHORT(__pdesc, __val) \ |
242 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 26, 1, __val) | 266 | SET_BITS_OFFSET_LE(__pdesc+16, 26, 1, __val) |
243 | #define SET_TX_DESC_RTS_BW(__pdesc, __val) \ | 267 | #define SET_TX_DESC_RTS_BW(__pdesc, __val) \ |
244 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 27, 1, __val) | 268 | SET_BITS_OFFSET_LE(__pdesc+16, 27, 1, __val) |
245 | #define SET_TX_DESC_RTS_SC(__pdesc, __val) \ | 269 | #define SET_TX_DESC_RTS_SC(__pdesc, __val) \ |
246 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 28, 2, __val) | 270 | SET_BITS_OFFSET_LE(__pdesc+16, 28, 2, __val) |
247 | #define SET_TX_DESC_RTS_STBC(__pdesc, __val) \ | 271 | #define SET_TX_DESC_RTS_STBC(__pdesc, __val) \ |
248 | SET_BITS_TO_LE_4BYTE(__pdesc+16, 30, 2, __val) | 272 | SET_BITS_OFFSET_LE(__pdesc+16, 30, 2, __val) |
249 | 273 | ||
250 | #define GET_TX_DESC_RTS_RATE(__pdesc) \ | 274 | #define GET_TX_DESC_RTS_RATE(__pdesc) \ |
251 | LE_BITS_TO_4BYTE(__pdesc+16, 0, 5) | 275 | SHIFT_AND_MASK_LE(__pdesc+16, 0, 5) |
252 | #define GET_TX_DESC_AP_DCFE(__pdesc) \ | 276 | #define GET_TX_DESC_AP_DCFE(__pdesc) \ |
253 | LE_BITS_TO_4BYTE(__pdesc+16, 5, 1) | 277 | SHIFT_AND_MASK_LE(__pdesc+16, 5, 1) |
254 | #define GET_TX_DESC_QOS(__pdesc) \ | 278 | #define GET_TX_DESC_QOS(__pdesc) \ |
255 | LE_BITS_TO_4BYTE(__pdesc+16, 6, 1) | 279 | SHIFT_AND_MASK_LE(__pdesc+16, 6, 1) |
256 | #define GET_TX_DESC_HWSEQ_EN(__pdesc) \ | 280 | #define GET_TX_DESC_HWSEQ_EN(__pdesc) \ |
257 | LE_BITS_TO_4BYTE(__pdesc+16, 7, 1) | 281 | SHIFT_AND_MASK_LE(__pdesc+16, 7, 1) |
258 | #define GET_TX_DESC_USE_RATE(__pdesc) \ | 282 | #define GET_TX_DESC_USE_RATE(__pdesc) \ |
259 | LE_BITS_TO_4BYTE(__pdesc+16, 8, 1) | 283 | SHIFT_AND_MASK_LE(__pdesc+16, 8, 1) |
260 | #define GET_TX_DESC_DISABLE_RTS_FB(__pdesc) \ | 284 | #define GET_TX_DESC_DISABLE_RTS_FB(__pdesc) \ |
261 | LE_BITS_TO_4BYTE(__pdesc+16, 9, 1) | 285 | SHIFT_AND_MASK_LE(__pdesc+16, 9, 1) |
262 | #define GET_TX_DESC_DISABLE_FB(__pdesc) \ | 286 | #define GET_TX_DESC_DISABLE_FB(__pdesc) \ |
263 | LE_BITS_TO_4BYTE(__pdesc+16, 10, 1) | 287 | SHIFT_AND_MASK_LE(__pdesc+16, 10, 1) |
264 | #define GET_TX_DESC_CTS2SELF(__pdesc) \ | 288 | #define GET_TX_DESC_CTS2SELF(__pdesc) \ |
265 | LE_BITS_TO_4BYTE(__pdesc+16, 11, 1) | 289 | SHIFT_AND_MASK_LE(__pdesc+16, 11, 1) |
266 | #define GET_TX_DESC_RTS_ENABLE(__pdesc) \ | 290 | #define GET_TX_DESC_RTS_ENABLE(__pdesc) \ |
267 | LE_BITS_TO_4BYTE(__pdesc+16, 12, 1) | 291 | SHIFT_AND_MASK_LE(__pdesc+16, 12, 1) |
268 | #define GET_TX_DESC_HW_RTS_ENABLE(__pdesc) \ | 292 | #define GET_TX_DESC_HW_RTS_ENABLE(__pdesc) \ |
269 | LE_BITS_TO_4BYTE(__pdesc+16, 13, 1) | 293 | SHIFT_AND_MASK_LE(__pdesc+16, 13, 1) |
270 | #define GET_TX_DESC_PORT_ID(__pdesc) \ | 294 | #define GET_TX_DESC_PORT_ID(__pdesc) \ |
271 | LE_BITS_TO_4BYTE(__pdesc+16, 14, 1) | 295 | SHIFT_AND_MASK_LE(__pdesc+16, 14, 1) |
272 | #define GET_TX_DESC_WAIT_DCTS(__pdesc) \ | 296 | #define GET_TX_DESC_WAIT_DCTS(__pdesc) \ |
273 | LE_BITS_TO_4BYTE(__pdesc+16, 18, 1) | 297 | SHIFT_AND_MASK_LE(__pdesc+16, 18, 1) |
274 | #define GET_TX_DESC_CTS2AP_EN(__pdesc) \ | 298 | #define GET_TX_DESC_CTS2AP_EN(__pdesc) \ |
275 | LE_BITS_TO_4BYTE(__pdesc+16, 19, 1) | 299 | SHIFT_AND_MASK_LE(__pdesc+16, 19, 1) |
276 | #define GET_TX_DESC_TX_SUB_CARRIER(__pdesc) \ | 300 | #define GET_TX_DESC_TX_SUB_CARRIER(__pdesc) \ |
277 | LE_BITS_TO_4BYTE(__pdesc+16, 20, 2) | 301 | SHIFT_AND_MASK_LE(__pdesc+16, 20, 2) |
278 | #define GET_TX_DESC_TX_STBC(__pdesc) \ | 302 | #define GET_TX_DESC_TX_STBC(__pdesc) \ |
279 | LE_BITS_TO_4BYTE(__pdesc+16, 22, 2) | 303 | SHIFT_AND_MASK_LE(__pdesc+16, 22, 2) |
280 | #define GET_TX_DESC_DATA_SHORT(__pdesc) \ | 304 | #define GET_TX_DESC_DATA_SHORT(__pdesc) \ |
281 | LE_BITS_TO_4BYTE(__pdesc+16, 24, 1) | 305 | SHIFT_AND_MASK_LE(__pdesc+16, 24, 1) |
282 | #define GET_TX_DESC_DATA_BW(__pdesc) \ | 306 | #define GET_TX_DESC_DATA_BW(__pdesc) \ |
283 | LE_BITS_TO_4BYTE(__pdesc+16, 25, 1) | 307 | SHIFT_AND_MASK_LE(__pdesc+16, 25, 1) |
284 | #define GET_TX_DESC_RTS_SHORT(__pdesc) \ | 308 | #define GET_TX_DESC_RTS_SHORT(__pdesc) \ |
285 | LE_BITS_TO_4BYTE(__pdesc+16, 26, 1) | 309 | SHIFT_AND_MASK_LE(__pdesc+16, 26, 1) |
286 | #define GET_TX_DESC_RTS_BW(__pdesc) \ | 310 | #define GET_TX_DESC_RTS_BW(__pdesc) \ |
287 | LE_BITS_TO_4BYTE(__pdesc+16, 27, 1) | 311 | SHIFT_AND_MASK_LE(__pdesc+16, 27, 1) |
288 | #define GET_TX_DESC_RTS_SC(__pdesc) \ | 312 | #define GET_TX_DESC_RTS_SC(__pdesc) \ |
289 | LE_BITS_TO_4BYTE(__pdesc+16, 28, 2) | 313 | SHIFT_AND_MASK_LE(__pdesc+16, 28, 2) |
290 | #define GET_TX_DESC_RTS_STBC(__pdesc) \ | 314 | #define GET_TX_DESC_RTS_STBC(__pdesc) \ |
291 | LE_BITS_TO_4BYTE(__pdesc+16, 30, 2) | 315 | SHIFT_AND_MASK_LE(__pdesc+16, 30, 2) |
292 | 316 | ||
293 | #define SET_TX_DESC_TX_RATE(__pdesc, __val) \ | 317 | #define SET_TX_DESC_TX_RATE(__pdesc, __val) \ |
294 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 0, 6, __val) | 318 | SET_BITS_OFFSET_LE(__pdesc+20, 0, 6, __val) |
295 | #define SET_TX_DESC_DATA_SHORTGI(__pdesc, __val) \ | 319 | #define SET_TX_DESC_DATA_SHORTGI(__pdesc, __val) \ |
296 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 6, 1, __val) | 320 | SET_BITS_OFFSET_LE(__pdesc+20, 6, 1, __val) |
297 | #define SET_TX_DESC_CCX_TAG(__pdesc, __val) \ | 321 | #define SET_TX_DESC_CCX_TAG(__pdesc, __val) \ |
298 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 7, 1, __val) | 322 | SET_BITS_OFFSET_LE(__pdesc+20, 7, 1, __val) |
299 | #define SET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc, __val) \ | 323 | #define SET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc, __val) \ |
300 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 8, 5, __val) | 324 | SET_BITS_OFFSET_LE(__pdesc+20, 8, 5, __val) |
301 | #define SET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc, __val) \ | 325 | #define SET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc, __val) \ |
302 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 13, 4, __val) | 326 | SET_BITS_OFFSET_LE(__pdesc+20, 13, 4, __val) |
303 | #define SET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc, __val) \ | 327 | #define SET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc, __val) \ |
304 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 17, 1, __val) | 328 | SET_BITS_OFFSET_LE(__pdesc+20, 17, 1, __val) |
305 | #define SET_TX_DESC_DATA_RETRY_LIMIT(__pdesc, __val) \ | 329 | #define SET_TX_DESC_DATA_RETRY_LIMIT(__pdesc, __val) \ |
306 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 18, 6, __val) | 330 | SET_BITS_OFFSET_LE(__pdesc+20, 18, 6, __val) |
307 | #define SET_TX_DESC_USB_TXAGG_NUM(__pdesc, __val) \ | 331 | #define SET_TX_DESC_USB_TXAGG_NUM(__pdesc, __val) \ |
308 | SET_BITS_TO_LE_4BYTE(__pdesc+20, 24, 8, __val) | 332 | SET_BITS_OFFSET_LE(__pdesc+20, 24, 8, __val) |
309 | 333 | ||
310 | #define GET_TX_DESC_TX_RATE(__pdesc) \ | 334 | #define GET_TX_DESC_TX_RATE(__pdesc) \ |
311 | LE_BITS_TO_4BYTE(__pdesc+20, 0, 6) | 335 | SHIFT_AND_MASK_LE(__pdesc+20, 0, 6) |
312 | #define GET_TX_DESC_DATA_SHORTGI(__pdesc) \ | 336 | #define GET_TX_DESC_DATA_SHORTGI(__pdesc) \ |
313 | LE_BITS_TO_4BYTE(__pdesc+20, 6, 1) | 337 | SHIFT_AND_MASK_LE(__pdesc+20, 6, 1) |
314 | #define GET_TX_DESC_CCX_TAG(__pdesc) \ | 338 | #define GET_TX_DESC_CCX_TAG(__pdesc) \ |
315 | LE_BITS_TO_4BYTE(__pdesc+20, 7, 1) | 339 | SHIFT_AND_MASK_LE(__pdesc+20, 7, 1) |
316 | #define GET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc) \ | 340 | #define GET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc) \ |
317 | LE_BITS_TO_4BYTE(__pdesc+20, 8, 5) | 341 | SHIFT_AND_MASK_LE(__pdesc+20, 8, 5) |
318 | #define GET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc) \ | 342 | #define GET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc) \ |
319 | LE_BITS_TO_4BYTE(__pdesc+20, 13, 4) | 343 | SHIFT_AND_MASK_LE(__pdesc+20, 13, 4) |
320 | #define GET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc) \ | 344 | #define GET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc) \ |
321 | LE_BITS_TO_4BYTE(__pdesc+20, 17, 1) | 345 | SHIFT_AND_MASK_LE(__pdesc+20, 17, 1) |
322 | #define GET_TX_DESC_DATA_RETRY_LIMIT(__pdesc) \ | 346 | #define GET_TX_DESC_DATA_RETRY_LIMIT(__pdesc) \ |
323 | LE_BITS_TO_4BYTE(__pdesc+20, 18, 6) | 347 | SHIFT_AND_MASK_LE(__pdesc+20, 18, 6) |
324 | #define GET_TX_DESC_USB_TXAGG_NUM(__pdesc) \ | 348 | #define GET_TX_DESC_USB_TXAGG_NUM(__pdesc) \ |
325 | LE_BITS_TO_4BYTE(__pdesc+20, 24, 8) | 349 | SHIFT_AND_MASK_LE(__pdesc+20, 24, 8) |
326 | 350 | ||
327 | #define SET_TX_DESC_TXAGC_A(__pdesc, __val) \ | 351 | #define SET_TX_DESC_TXAGC_A(__pdesc, __val) \ |
328 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 5, __val) | 352 | SET_BITS_OFFSET_LE(__pdesc+24, 0, 5, __val) |
329 | #define SET_TX_DESC_TXAGC_B(__pdesc, __val) \ | 353 | #define SET_TX_DESC_TXAGC_B(__pdesc, __val) \ |
330 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 5, 5, __val) | 354 | SET_BITS_OFFSET_LE(__pdesc+24, 5, 5, __val) |
331 | #define SET_TX_DESC_USE_MAX_LEN(__pdesc, __val) \ | 355 | #define SET_TX_DESC_USE_MAX_LEN(__pdesc, __val) \ |
332 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 10, 1, __val) | 356 | SET_BITS_OFFSET_LE(__pdesc+24, 10, 1, __val) |
333 | #define SET_TX_DESC_MAX_AGG_NUM(__pdesc, __val) \ | 357 | #define SET_TX_DESC_MAX_AGG_NUM(__pdesc, __val) \ |
334 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 11, 5, __val) | 358 | SET_BITS_OFFSET_LE(__pdesc+24, 11, 5, __val) |
335 | #define SET_TX_DESC_MCSG1_MAX_LEN(__pdesc, __val) \ | 359 | #define SET_TX_DESC_MCSG1_MAX_LEN(__pdesc, __val) \ |
336 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 16, 4, __val) | 360 | SET_BITS_OFFSET_LE(__pdesc+24, 16, 4, __val) |
337 | #define SET_TX_DESC_MCSG2_MAX_LEN(__pdesc, __val) \ | 361 | #define SET_TX_DESC_MCSG2_MAX_LEN(__pdesc, __val) \ |
338 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 20, 4, __val) | 362 | SET_BITS_OFFSET_LE(__pdesc+24, 20, 4, __val) |
339 | #define SET_TX_DESC_MCSG3_MAX_LEN(__pdesc, __val) \ | 363 | #define SET_TX_DESC_MCSG3_MAX_LEN(__pdesc, __val) \ |
340 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 24, 4, __val) | 364 | SET_BITS_OFFSET_LE(__pdesc+24, 24, 4, __val) |
341 | #define SET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc, __val) \ | 365 | #define SET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc, __val) \ |
342 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 28, 4, __val) | 366 | SET_BITS_OFFSET_LE(__pdesc+24, 28, 4, __val) |
343 | 367 | ||
344 | #define GET_TX_DESC_TXAGC_A(__pdesc) \ | 368 | #define GET_TX_DESC_TXAGC_A(__pdesc) \ |
345 | LE_BITS_TO_4BYTE(__pdesc+24, 0, 5) | 369 | SHIFT_AND_MASK_LE(__pdesc+24, 0, 5) |
346 | #define GET_TX_DESC_TXAGC_B(__pdesc) \ | 370 | #define GET_TX_DESC_TXAGC_B(__pdesc) \ |
347 | LE_BITS_TO_4BYTE(__pdesc+24, 5, 5) | 371 | SHIFT_AND_MASK_LE(__pdesc+24, 5, 5) |
348 | #define GET_TX_DESC_USE_MAX_LEN(__pdesc) \ | 372 | #define GET_TX_DESC_USE_MAX_LEN(__pdesc) \ |
349 | LE_BITS_TO_4BYTE(__pdesc+24, 10, 1) | 373 | SHIFT_AND_MASK_LE(__pdesc+24, 10, 1) |
350 | #define GET_TX_DESC_MAX_AGG_NUM(__pdesc) \ | 374 | #define GET_TX_DESC_MAX_AGG_NUM(__pdesc) \ |
351 | LE_BITS_TO_4BYTE(__pdesc+24, 11, 5) | 375 | SHIFT_AND_MASK_LE(__pdesc+24, 11, 5) |
352 | #define GET_TX_DESC_MCSG1_MAX_LEN(__pdesc) \ | 376 | #define GET_TX_DESC_MCSG1_MAX_LEN(__pdesc) \ |
353 | LE_BITS_TO_4BYTE(__pdesc+24, 16, 4) | 377 | SHIFT_AND_MASK_LE(__pdesc+24, 16, 4) |
354 | #define GET_TX_DESC_MCSG2_MAX_LEN(__pdesc) \ | 378 | #define GET_TX_DESC_MCSG2_MAX_LEN(__pdesc) \ |
355 | LE_BITS_TO_4BYTE(__pdesc+24, 20, 4) | 379 | SHIFT_AND_MASK_LE(__pdesc+24, 20, 4) |
356 | #define GET_TX_DESC_MCSG3_MAX_LEN(__pdesc) \ | 380 | #define GET_TX_DESC_MCSG3_MAX_LEN(__pdesc) \ |
357 | LE_BITS_TO_4BYTE(__pdesc+24, 24, 4) | 381 | SHIFT_AND_MASK_LE(__pdesc+24, 24, 4) |
358 | #define GET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc) \ | 382 | #define GET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc) \ |
359 | LE_BITS_TO_4BYTE(__pdesc+24, 28, 4) | 383 | SHIFT_AND_MASK_LE(__pdesc+24, 28, 4) |
360 | 384 | ||
361 | #define SET_TX_DESC_TX_BUFFER_SIZE(__pdesc, __val) \ | 385 | #define SET_TX_DESC_TX_BUFFER_SIZE(__pdesc, __val) \ |
362 | SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 16, __val) | 386 | SET_BITS_OFFSET_LE(__pdesc+28, 0, 16, __val) |
363 | #define SET_TX_DESC_MCSG4_MAX_LEN(__pdesc, __val) \ | 387 | #define SET_TX_DESC_MCSG4_MAX_LEN(__pdesc, __val) \ |
364 | SET_BITS_TO_LE_4BYTE(__pdesc+28, 16, 4, __val) | 388 | SET_BITS_OFFSET_LE(__pdesc+28, 16, 4, __val) |
365 | #define SET_TX_DESC_MCSG5_MAX_LEN(__pdesc, __val) \ | 389 | #define SET_TX_DESC_MCSG5_MAX_LEN(__pdesc, __val) \ |
366 | SET_BITS_TO_LE_4BYTE(__pdesc+28, 20, 4, __val) | 390 | SET_BITS_OFFSET_LE(__pdesc+28, 20, 4, __val) |
367 | #define SET_TX_DESC_MCSG6_MAX_LEN(__pdesc, __val) \ | 391 | #define SET_TX_DESC_MCSG6_MAX_LEN(__pdesc, __val) \ |
368 | SET_BITS_TO_LE_4BYTE(__pdesc+28, 24, 4, __val) | 392 | SET_BITS_OFFSET_LE(__pdesc+28, 24, 4, __val) |
369 | #define SET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc, __val) \ | 393 | #define SET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc, __val) \ |
370 | SET_BITS_TO_LE_4BYTE(__pdesc+28, 28, 4, __val) | 394 | SET_BITS_OFFSET_LE(__pdesc+28, 28, 4, __val) |
371 | 395 | ||
372 | #define GET_TX_DESC_TX_BUFFER_SIZE(__pdesc) \ | 396 | #define GET_TX_DESC_TX_BUFFER_SIZE(__pdesc) \ |
373 | LE_BITS_TO_4BYTE(__pdesc+28, 0, 16) | 397 | SHIFT_AND_MASK_LE(__pdesc+28, 0, 16) |
374 | #define GET_TX_DESC_MCSG4_MAX_LEN(__pdesc) \ | 398 | #define GET_TX_DESC_MCSG4_MAX_LEN(__pdesc) \ |
375 | LE_BITS_TO_4BYTE(__pdesc+28, 16, 4) | 399 | SHIFT_AND_MASK_LE(__pdesc+28, 16, 4) |
376 | #define GET_TX_DESC_MCSG5_MAX_LEN(__pdesc) \ | 400 | #define GET_TX_DESC_MCSG5_MAX_LEN(__pdesc) \ |
377 | LE_BITS_TO_4BYTE(__pdesc+28, 20, 4) | 401 | SHIFT_AND_MASK_LE(__pdesc+28, 20, 4) |
378 | #define GET_TX_DESC_MCSG6_MAX_LEN(__pdesc) \ | 402 | #define GET_TX_DESC_MCSG6_MAX_LEN(__pdesc) \ |
379 | LE_BITS_TO_4BYTE(__pdesc+28, 24, 4) | 403 | SHIFT_AND_MASK_LE(__pdesc+28, 24, 4) |
380 | #define GET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc) \ | 404 | #define GET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc) \ |
381 | LE_BITS_TO_4BYTE(__pdesc+28, 28, 4) | 405 | SHIFT_AND_MASK_LE(__pdesc+28, 28, 4) |
382 | 406 | ||
383 | #define SET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc, __val) \ | 407 | #define SET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc, __val) \ |
384 | SET_BITS_TO_LE_4BYTE(__pdesc+32, 0, 32, __val) | 408 | SET_BITS_OFFSET_LE(__pdesc+32, 0, 32, __val) |
385 | #define SET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc, __val) \ | 409 | #define SET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc, __val) \ |
386 | SET_BITS_TO_LE_4BYTE(__pdesc+36, 0, 32, __val) | 410 | SET_BITS_OFFSET_LE(__pdesc+36, 0, 32, __val) |
387 | 411 | ||
388 | #define GET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc) \ | 412 | #define GET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc) \ |
389 | LE_BITS_TO_4BYTE(__pdesc+32, 0, 32) | 413 | SHIFT_AND_MASK_LE(__pdesc+32, 0, 32) |
390 | #define GET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc) \ | 414 | #define GET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc) \ |
391 | LE_BITS_TO_4BYTE(__pdesc+36, 0, 32) | 415 | SHIFT_AND_MASK_LE(__pdesc+36, 0, 32) |
392 | 416 | ||
393 | #define SET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc, __val) \ | 417 | #define SET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc, __val) \ |
394 | SET_BITS_TO_LE_4BYTE(__pdesc+40, 0, 32, __val) | 418 | SET_BITS_OFFSET_LE(__pdesc+40, 0, 32, __val) |
395 | #define SET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc, __val) \ | 419 | #define SET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc, __val) \ |
396 | SET_BITS_TO_LE_4BYTE(__pdesc+44, 0, 32, __val) | 420 | SET_BITS_OFFSET_LE(__pdesc+44, 0, 32, __val) |
397 | 421 | ||
398 | #define GET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc) \ | 422 | #define GET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc) \ |
399 | LE_BITS_TO_4BYTE(__pdesc+40, 0, 32) | 423 | SHIFT_AND_MASK_LE(__pdesc+40, 0, 32) |
400 | #define GET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc) \ | 424 | #define GET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc) \ |
401 | LE_BITS_TO_4BYTE(__pdesc+44, 0, 32) | 425 | SHIFT_AND_MASK_LE(__pdesc+44, 0, 32) |
402 | 426 | ||
403 | #define GET_RX_DESC_PKT_LEN(__pdesc) \ | 427 | #define GET_RX_DESC_PKT_LEN(__pdesc) \ |
404 | LE_BITS_TO_4BYTE(__pdesc, 0, 14) | 428 | SHIFT_AND_MASK_LE(__pdesc, 0, 14) |
405 | #define GET_RX_DESC_CRC32(__pdesc) \ | 429 | #define GET_RX_DESC_CRC32(__pdesc) \ |
406 | LE_BITS_TO_4BYTE(__pdesc, 14, 1) | 430 | SHIFT_AND_MASK_LE(__pdesc, 14, 1) |
407 | #define GET_RX_DESC_ICV(__pdesc) \ | 431 | #define GET_RX_DESC_ICV(__pdesc) \ |
408 | LE_BITS_TO_4BYTE(__pdesc, 15, 1) | 432 | SHIFT_AND_MASK_LE(__pdesc, 15, 1) |
409 | #define GET_RX_DESC_DRV_INFO_SIZE(__pdesc) \ | 433 | #define GET_RX_DESC_DRV_INFO_SIZE(__pdesc) \ |
410 | LE_BITS_TO_4BYTE(__pdesc, 16, 4) | 434 | SHIFT_AND_MASK_LE(__pdesc, 16, 4) |
411 | #define GET_RX_DESC_SECURITY(__pdesc) \ | 435 | #define GET_RX_DESC_SECURITY(__pdesc) \ |
412 | LE_BITS_TO_4BYTE(__pdesc, 20, 3) | 436 | SHIFT_AND_MASK_LE(__pdesc, 20, 3) |
413 | #define GET_RX_DESC_QOS(__pdesc) \ | 437 | #define GET_RX_DESC_QOS(__pdesc) \ |
414 | LE_BITS_TO_4BYTE(__pdesc, 23, 1) | 438 | SHIFT_AND_MASK_LE(__pdesc, 23, 1) |
415 | #define GET_RX_DESC_SHIFT(__pdesc) \ | 439 | #define GET_RX_DESC_SHIFT(__pdesc) \ |
416 | LE_BITS_TO_4BYTE(__pdesc, 24, 2) | 440 | SHIFT_AND_MASK_LE(__pdesc, 24, 2) |
417 | #define GET_RX_DESC_PHYST(__pdesc) \ | 441 | #define GET_RX_DESC_PHYST(__pdesc) \ |
418 | LE_BITS_TO_4BYTE(__pdesc, 26, 1) | 442 | SHIFT_AND_MASK_LE(__pdesc, 26, 1) |
419 | #define GET_RX_DESC_SWDEC(__pdesc) \ | 443 | #define GET_RX_DESC_SWDEC(__pdesc) \ |
420 | LE_BITS_TO_4BYTE(__pdesc, 27, 1) | 444 | SHIFT_AND_MASK_LE(__pdesc, 27, 1) |
421 | #define GET_RX_DESC_LS(__pdesc) \ | 445 | #define GET_RX_DESC_LS(__pdesc) \ |
422 | LE_BITS_TO_4BYTE(__pdesc, 28, 1) | 446 | SHIFT_AND_MASK_LE(__pdesc, 28, 1) |
423 | #define GET_RX_DESC_FS(__pdesc) \ | 447 | #define GET_RX_DESC_FS(__pdesc) \ |
424 | LE_BITS_TO_4BYTE(__pdesc, 29, 1) | 448 | SHIFT_AND_MASK_LE(__pdesc, 29, 1) |
425 | #define GET_RX_DESC_EOR(__pdesc) \ | 449 | #define GET_RX_DESC_EOR(__pdesc) \ |
426 | LE_BITS_TO_4BYTE(__pdesc, 30, 1) | 450 | SHIFT_AND_MASK_LE(__pdesc, 30, 1) |
427 | #define GET_RX_DESC_OWN(__pdesc) \ | 451 | #define GET_RX_DESC_OWN(__pdesc) \ |
428 | LE_BITS_TO_4BYTE(__pdesc, 31, 1) | 452 | SHIFT_AND_MASK_LE(__pdesc, 31, 1) |
429 | 453 | ||
430 | #define SET_RX_DESC_PKT_LEN(__pdesc, __val) \ | 454 | #define SET_RX_DESC_PKT_LEN(__pdesc, __val) \ |
431 | SET_BITS_TO_LE_4BYTE(__pdesc, 0, 14, __val) | 455 | SET_BITS_OFFSET_LE(__pdesc, 0, 14, __val) |
432 | #define SET_RX_DESC_EOR(__pdesc, __val) \ | 456 | #define SET_RX_DESC_EOR(__pdesc, __val) \ |
433 | SET_BITS_TO_LE_4BYTE(__pdesc, 30, 1, __val) | 457 | SET_BITS_OFFSET_LE(__pdesc, 30, 1, __val) |
434 | #define SET_RX_DESC_OWN(__pdesc, __val) \ | 458 | #define SET_RX_DESC_OWN(__pdesc, __val) \ |
435 | SET_BITS_TO_LE_4BYTE(__pdesc, 31, 1, __val) | 459 | SET_BITS_OFFSET_LE(__pdesc, 31, 1, __val) |
436 | 460 | ||
437 | #define GET_RX_DESC_MACID(__pdesc) \ | 461 | #define GET_RX_DESC_MACID(__pdesc) \ |
438 | LE_BITS_TO_4BYTE(__pdesc+4, 0, 5) | 462 | SHIFT_AND_MASK_LE(__pdesc+4, 0, 5) |
439 | #define GET_RX_DESC_TID(__pdesc) \ | 463 | #define GET_RX_DESC_TID(__pdesc) \ |
440 | LE_BITS_TO_4BYTE(__pdesc+4, 5, 4) | 464 | SHIFT_AND_MASK_LE(__pdesc+4, 5, 4) |
441 | #define GET_RX_DESC_HWRSVD(__pdesc) \ | 465 | #define GET_RX_DESC_HWRSVD(__pdesc) \ |
442 | LE_BITS_TO_4BYTE(__pdesc+4, 9, 5) | 466 | SHIFT_AND_MASK_LE(__pdesc+4, 9, 5) |
443 | #define GET_RX_DESC_PAGGR(__pdesc) \ | 467 | #define GET_RX_DESC_PAGGR(__pdesc) \ |
444 | LE_BITS_TO_4BYTE(__pdesc+4, 14, 1) | 468 | SHIFT_AND_MASK_LE(__pdesc+4, 14, 1) |
445 | #define GET_RX_DESC_FAGGR(__pdesc) \ | 469 | #define GET_RX_DESC_FAGGR(__pdesc) \ |
446 | LE_BITS_TO_4BYTE(__pdesc+4, 15, 1) | 470 | SHIFT_AND_MASK_LE(__pdesc+4, 15, 1) |
447 | #define GET_RX_DESC_A1_FIT(__pdesc) \ | 471 | #define GET_RX_DESC_A1_FIT(__pdesc) \ |
448 | LE_BITS_TO_4BYTE(__pdesc+4, 16, 4) | 472 | SHIFT_AND_MASK_LE(__pdesc+4, 16, 4) |
449 | #define GET_RX_DESC_A2_FIT(__pdesc) \ | 473 | #define GET_RX_DESC_A2_FIT(__pdesc) \ |
450 | LE_BITS_TO_4BYTE(__pdesc+4, 20, 4) | 474 | SHIFT_AND_MASK_LE(__pdesc+4, 20, 4) |
451 | #define GET_RX_DESC_PAM(__pdesc) \ | 475 | #define GET_RX_DESC_PAM(__pdesc) \ |
452 | LE_BITS_TO_4BYTE(__pdesc+4, 24, 1) | 476 | SHIFT_AND_MASK_LE(__pdesc+4, 24, 1) |
453 | #define GET_RX_DESC_PWR(__pdesc) \ | 477 | #define GET_RX_DESC_PWR(__pdesc) \ |
454 | LE_BITS_TO_4BYTE(__pdesc+4, 25, 1) | 478 | SHIFT_AND_MASK_LE(__pdesc+4, 25, 1) |
455 | #define GET_RX_DESC_MD(__pdesc) \ | 479 | #define GET_RX_DESC_MD(__pdesc) \ |
456 | LE_BITS_TO_4BYTE(__pdesc+4, 26, 1) | 480 | SHIFT_AND_MASK_LE(__pdesc+4, 26, 1) |
457 | #define GET_RX_DESC_MF(__pdesc) \ | 481 | #define GET_RX_DESC_MF(__pdesc) \ |
458 | LE_BITS_TO_4BYTE(__pdesc+4, 27, 1) | 482 | SHIFT_AND_MASK_LE(__pdesc+4, 27, 1) |
459 | #define GET_RX_DESC_TYPE(__pdesc) \ | 483 | #define GET_RX_DESC_TYPE(__pdesc) \ |
460 | LE_BITS_TO_4BYTE(__pdesc+4, 28, 2) | 484 | SHIFT_AND_MASK_LE(__pdesc+4, 28, 2) |
461 | #define GET_RX_DESC_MC(__pdesc) \ | 485 | #define GET_RX_DESC_MC(__pdesc) \ |
462 | LE_BITS_TO_4BYTE(__pdesc+4, 30, 1) | 486 | SHIFT_AND_MASK_LE(__pdesc+4, 30, 1) |
463 | #define GET_RX_DESC_BC(__pdesc) \ | 487 | #define GET_RX_DESC_BC(__pdesc) \ |
464 | LE_BITS_TO_4BYTE(__pdesc+4, 31, 1) | 488 | SHIFT_AND_MASK_LE(__pdesc+4, 31, 1) |
465 | #define GET_RX_DESC_SEQ(__pdesc) \ | 489 | #define GET_RX_DESC_SEQ(__pdesc) \ |
466 | LE_BITS_TO_4BYTE(__pdesc+8, 0, 12) | 490 | SHIFT_AND_MASK_LE(__pdesc+8, 0, 12) |
467 | #define GET_RX_DESC_FRAG(__pdesc) \ | 491 | #define GET_RX_DESC_FRAG(__pdesc) \ |
468 | LE_BITS_TO_4BYTE(__pdesc+8, 12, 4) | 492 | SHIFT_AND_MASK_LE(__pdesc+8, 12, 4) |
469 | #define GET_RX_DESC_NEXT_PKT_LEN(__pdesc) \ | 493 | #define GET_RX_DESC_NEXT_PKT_LEN(__pdesc) \ |
470 | LE_BITS_TO_4BYTE(__pdesc+8, 16, 14) | 494 | SHIFT_AND_MASK_LE(__pdesc+8, 16, 14) |
471 | #define GET_RX_DESC_NEXT_IND(__pdesc) \ | 495 | #define GET_RX_DESC_NEXT_IND(__pdesc) \ |
472 | LE_BITS_TO_4BYTE(__pdesc+8, 30, 1) | 496 | SHIFT_AND_MASK_LE(__pdesc+8, 30, 1) |
473 | #define GET_RX_DESC_RSVD(__pdesc) \ | 497 | #define GET_RX_DESC_RSVD(__pdesc) \ |
474 | LE_BITS_TO_4BYTE(__pdesc+8, 31, 1) | 498 | SHIFT_AND_MASK_LE(__pdesc+8, 31, 1) |
475 | 499 | ||
476 | #define GET_RX_DESC_RXMCS(__pdesc) \ | 500 | #define GET_RX_DESC_RXMCS(__pdesc) \ |
477 | LE_BITS_TO_4BYTE(__pdesc+12, 0, 6) | 501 | SHIFT_AND_MASK_LE(__pdesc+12, 0, 6) |
478 | #define GET_RX_DESC_RXHT(__pdesc) \ | 502 | #define GET_RX_DESC_RXHT(__pdesc) \ |
479 | LE_BITS_TO_4BYTE(__pdesc+12, 6, 1) | 503 | SHIFT_AND_MASK_LE(__pdesc+12, 6, 1) |
480 | #define GET_RX_DESC_SPLCP(__pdesc) \ | 504 | #define GET_RX_DESC_SPLCP(__pdesc) \ |
481 | LE_BITS_TO_4BYTE(__pdesc+12, 8, 1) | 505 | SHIFT_AND_MASK_LE(__pdesc+12, 8, 1) |
482 | #define GET_RX_DESC_BW(__pdesc) \ | 506 | #define GET_RX_DESC_BW(__pdesc) \ |
483 | LE_BITS_TO_4BYTE(__pdesc+12, 9, 1) | 507 | SHIFT_AND_MASK_LE(__pdesc+12, 9, 1) |
484 | #define GET_RX_DESC_HTC(__pdesc) \ | 508 | #define GET_RX_DESC_HTC(__pdesc) \ |
485 | LE_BITS_TO_4BYTE(__pdesc+12, 10, 1) | 509 | SHIFT_AND_MASK_LE(__pdesc+12, 10, 1) |
486 | #define GET_RX_DESC_HWPC_ERR(__pdesc) \ | 510 | #define GET_RX_DESC_HWPC_ERR(__pdesc) \ |
487 | LE_BITS_TO_4BYTE(__pdesc+12, 14, 1) | 511 | SHIFT_AND_MASK_LE(__pdesc+12, 14, 1) |
488 | #define GET_RX_DESC_HWPC_IND(__pdesc) \ | 512 | #define GET_RX_DESC_HWPC_IND(__pdesc) \ |
489 | LE_BITS_TO_4BYTE(__pdesc+12, 15, 1) | 513 | SHIFT_AND_MASK_LE(__pdesc+12, 15, 1) |
490 | #define GET_RX_DESC_IV0(__pdesc) \ | 514 | #define GET_RX_DESC_IV0(__pdesc) \ |
491 | LE_BITS_TO_4BYTE(__pdesc+12, 16, 16) | 515 | SHIFT_AND_MASK_LE(__pdesc+12, 16, 16) |
492 | 516 | ||
493 | #define GET_RX_DESC_IV1(__pdesc) \ | 517 | #define GET_RX_DESC_IV1(__pdesc) \ |
494 | LE_BITS_TO_4BYTE(__pdesc+16, 0, 32) | 518 | SHIFT_AND_MASK_LE(__pdesc+16, 0, 32) |
495 | #define GET_RX_DESC_TSFL(__pdesc) \ | 519 | #define GET_RX_DESC_TSFL(__pdesc) \ |
496 | LE_BITS_TO_4BYTE(__pdesc+20, 0, 32) | 520 | SHIFT_AND_MASK_LE(__pdesc+20, 0, 32) |
497 | 521 | ||
498 | #define GET_RX_DESC_BUFF_ADDR(__pdesc) \ | 522 | #define GET_RX_DESC_BUFF_ADDR(__pdesc) \ |
499 | LE_BITS_TO_4BYTE(__pdesc+24, 0, 32) | 523 | SHIFT_AND_MASK_LE(__pdesc+24, 0, 32) |
500 | #define GET_RX_DESC_BUFF_ADDR64(__pdesc) \ | 524 | #define GET_RX_DESC_BUFF_ADDR64(__pdesc) \ |
501 | LE_BITS_TO_4BYTE(__pdesc+28, 0, 32) | 525 | SHIFT_AND_MASK_LE(__pdesc+28, 0, 32) |
502 | 526 | ||
503 | #define SET_RX_DESC_BUFF_ADDR(__pdesc, __val) \ | 527 | #define SET_RX_DESC_BUFF_ADDR(__pdesc, __val) \ |
504 | SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 32, __val) | 528 | SET_BITS_OFFSET_LE(__pdesc+24, 0, 32, __val) |
505 | #define SET_RX_DESC_BUFF_ADDR64(__pdesc, __val) \ | 529 | #define SET_RX_DESC_BUFF_ADDR64(__pdesc, __val) \ |
506 | SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 32, __val) | 530 | SET_BITS_OFFSET_LE(__pdesc+28, 0, 32, __val) |
507 | 531 | ||
508 | #define CLEAR_PCI_TX_DESC_CONTENT(__pdesc, _size) \ | 532 | #define CLEAR_PCI_TX_DESC_CONTENT(__pdesc, _size) \ |
509 | do { \ | 533 | do { \ |
@@ -711,4 +735,6 @@ void rtl92ce_tx_polling(struct ieee80211_hw *hw, unsigned int hw_queue); | |||
711 | void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, | 735 | void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, |
712 | bool b_firstseg, bool b_lastseg, | 736 | bool b_firstseg, bool b_lastseg, |
713 | struct sk_buff *skb); | 737 | struct sk_buff *skb); |
738 | bool _rtl92c_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb); | ||
739 | |||
714 | #endif | 740 | #endif |