forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
....@@ -1,27 +1,5 @@
1
-/******************************************************************************
2
- *
3
- * Copyright(c) 2009-2012 Realtek Corporation.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of version 2 of the GNU General Public License as
7
- * published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * The full GNU General Public License is included in this distribution in the
15
- * file called LICENSE.
16
- *
17
- * Contact Information:
18
- * wlanfae <wlanfae@realtek.com>
19
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20
- * Hsinchu 300, Taiwan.
21
- *
22
- * Larry Finger <Larry.Finger@lwfinger.net>
23
- *
24
- *****************************************************************************/
1
+// SPDX-License-Identifier: GPL-2.0
2
+/* Copyright(c) 2009-2012 Realtek Corporation.*/
253
264 #include "../wifi.h"
275 #include "../pci.h"
....@@ -69,7 +47,7 @@
6947 u32 pagenums, remainsize;
7048 u32 page, offset;
7149
72
- RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes,\n", size);
50
+ rtl_dbg(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes,\n", size);
7351 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE)
7452 rtl_fill_dummy(bufferptr, &size);
7553 pagenums = size / FW_8192D_PAGE_SIZE;
....@@ -97,7 +75,7 @@
9775 do {
9876 value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
9977 } while ((counter++ < FW_8192D_POLLING_TIMEOUT_COUNT) &&
100
- (!(value32 & FWDL_ChkSum_rpt)));
78
+ (!(value32 & FWDL_CHKSUM_RPT)));
10179 if (counter >= FW_8192D_POLLING_TIMEOUT_COUNT) {
10280 pr_err("chksum report fail! REG_MCUFWDL:0x%08x\n",
10381 value32);
....@@ -126,8 +104,8 @@
126104 u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
127105 }
128106 WARN_ONCE((delay <= 0), "rtl8192de: 8051 reset failed!\n");
129
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
130
- "=====> 8051 reset success (%d)\n", delay);
107
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
108
+ "=====> 8051 reset success (%d)\n", delay);
131109 }
132110
133111 static int _rtl92d_fw_init(struct ieee80211_hw *hw)
....@@ -136,27 +114,27 @@
136114 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
137115 u32 counter;
138116
139
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, "FW already have download\n");
117
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG, "FW already have download\n");
140118 /* polling for FW ready */
141119 counter = 0;
142120 do {
143121 if (rtlhal->interfaceindex == 0) {
144122 if (rtl_read_byte(rtlpriv, FW_MAC0_READY) &
145123 MAC0_READY) {
146
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
147
- "Polling FW ready success!! REG_MCUFWDL: 0x%x\n",
148
- rtl_read_byte(rtlpriv,
149
- FW_MAC0_READY));
124
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
125
+ "Polling FW ready success!! REG_MCUFWDL: 0x%x\n",
126
+ rtl_read_byte(rtlpriv,
127
+ FW_MAC0_READY));
150128 return 0;
151129 }
152130 udelay(5);
153131 } else {
154132 if (rtl_read_byte(rtlpriv, FW_MAC1_READY) &
155133 MAC1_READY) {
156
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
157
- "Polling FW ready success!! REG_MCUFWDL: 0x%x\n",
158
- rtl_read_byte(rtlpriv,
159
- FW_MAC1_READY));
134
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
135
+ "Polling FW ready success!! REG_MCUFWDL: 0x%x\n",
136
+ rtl_read_byte(rtlpriv,
137
+ FW_MAC1_READY));
160138 return 0;
161139 }
162140 udelay(5);
....@@ -164,17 +142,17 @@
164142 } while (counter++ < POLLING_READY_TIMEOUT_COUNT);
165143
166144 if (rtlhal->interfaceindex == 0) {
167
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
168
- "Polling FW ready fail!! MAC0 FW init not ready: 0x%x\n",
169
- rtl_read_byte(rtlpriv, FW_MAC0_READY));
145
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
146
+ "Polling FW ready fail!! MAC0 FW init not ready: 0x%x\n",
147
+ rtl_read_byte(rtlpriv, FW_MAC0_READY));
170148 } else {
171
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
172
- "Polling FW ready fail!! MAC1 FW init not ready: 0x%x\n",
173
- rtl_read_byte(rtlpriv, FW_MAC1_READY));
149
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
150
+ "Polling FW ready fail!! MAC1 FW init not ready: 0x%x\n",
151
+ rtl_read_byte(rtlpriv, FW_MAC1_READY));
174152 }
175
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
176
- "Polling FW ready fail!! REG_MCUFWDL:0x%08x\n",
177
- rtl_read_dword(rtlpriv, REG_MCUFWDL));
153
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
154
+ "Polling FW ready fail!! REG_MCUFWDL:0x%08x\n",
155
+ rtl_read_dword(rtlpriv, REG_MCUFWDL));
178156 return -1;
179157 }
180158
....@@ -199,13 +177,13 @@
199177 pfwdata = rtlhal->pfirmware;
200178 rtlhal->fw_version = (u16) GET_FIRMWARE_HDR_VERSION(pfwheader);
201179 rtlhal->fw_subversion = (u16) GET_FIRMWARE_HDR_SUB_VER(pfwheader);
202
- RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
203
- "FirmwareVersion(%d), FirmwareSubVersion(%d), Signature(%#x)\n",
204
- rtlhal->fw_version, rtlhal->fw_subversion,
205
- GET_FIRMWARE_HDR_SIGNATURE(pfwheader));
180
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
181
+ "FirmwareVersion(%d), FirmwareSubVersion(%d), Signature(%#x)\n",
182
+ rtlhal->fw_version, rtlhal->fw_subversion,
183
+ GET_FIRMWARE_HDR_SIGNATURE(pfwheader));
206184 if (IS_FW_HEADER_EXIST(pfwheader)) {
207
- RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
208
- "Shift 32 bytes for FW header!!\n");
185
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
186
+ "Shift 32 bytes for FW header!!\n");
209187 pfwdata = pfwdata + 32;
210188 fwsize = fwsize - 32;
211189 }
....@@ -236,8 +214,8 @@
236214 else if (!fwdl_in_process)
237215 break;
238216 else
239
- RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
240
- "Wait for another mac download fw\n");
217
+ rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
218
+ "Wait for another mac download fw\n");
241219 }
242220 spin_lock_irqsave(&globalmutex_for_fwdownload, flags);
243221 value = rtl_read_byte(rtlpriv, 0x1f);
....@@ -308,25 +286,25 @@
308286 u8 idx;
309287
310288 if (ppsc->rfpwr_state == ERFOFF || ppsc->inactive_pwrstate == ERFOFF) {
311
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
312
- "Return as RF is off!!!\n");
289
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
290
+ "Return as RF is off!!!\n");
313291 return;
314292 }
315
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n");
293
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n");
316294 while (true) {
317295 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
318296 if (rtlhal->h2c_setinprogress) {
319
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
320
- "H2C set in progress! Wait to set..element_id(%d)\n",
321
- element_id);
297
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
298
+ "H2C set in progress! Wait to set..element_id(%d)\n",
299
+ element_id);
322300
323301 while (rtlhal->h2c_setinprogress) {
324302 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock,
325303 flag);
326304 h2c_waitcounter++;
327
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
328
- "Wait 100 us (%d times)...\n",
329
- h2c_waitcounter);
305
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
306
+ "Wait 100 us (%d times)...\n",
307
+ h2c_waitcounter);
330308 udelay(100);
331309
332310 if (h2c_waitcounter > 1000)
....@@ -375,30 +353,30 @@
375353 while (!isfw_read) {
376354 wait_h2c_limmit--;
377355 if (wait_h2c_limmit == 0) {
378
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
379
- "Waiting too long for FW read clear HMEBox(%d)!\n",
380
- boxnum);
356
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
357
+ "Waiting too long for FW read clear HMEBox(%d)!\n",
358
+ boxnum);
381359 break;
382360 }
383361 udelay(10);
384362 isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum);
385363 u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF);
386
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
387
- "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n",
388
- boxnum, u1b_tmp);
364
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
365
+ "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n",
366
+ boxnum, u1b_tmp);
389367 }
390368 if (!isfw_read) {
391
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
392
- "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n",
393
- boxnum);
369
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
370
+ "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n",
371
+ boxnum);
394372 break;
395373 }
396374 memset(boxcontent, 0, sizeof(boxcontent));
397375 memset(boxextcontent, 0, sizeof(boxextcontent));
398376 boxcontent[0] = element_id;
399
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
400
- "Write element_id box_reg(%4x) = %2x\n",
401
- box_reg, element_id);
377
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
378
+ "Write element_id box_reg(%4x) = %2x\n",
379
+ box_reg, element_id);
402380 switch (cmd_len) {
403381 case 1:
404382 boxcontent[0] &= ~(BIT(7));
....@@ -452,14 +430,14 @@
452430 rtlhal->last_hmeboxnum = boxnum + 1;
453431 if (rtlhal->last_hmeboxnum == 4)
454432 rtlhal->last_hmeboxnum = 0;
455
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
456
- "pHalData->last_hmeboxnum = %d\n",
457
- rtlhal->last_hmeboxnum);
433
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD,
434
+ "pHalData->last_hmeboxnum = %d\n",
435
+ rtlhal->last_hmeboxnum);
458436 }
459437 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
460438 rtlhal->h2c_setinprogress = false;
461439 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
462
- RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n");
440
+ rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n");
463441 }
464442
465443 void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw,
....@@ -621,7 +599,7 @@
621599 struct sk_buff *skb = NULL;
622600 u32 totalpacketlen;
623601 bool rtstatus;
624
- u8 u1RsvdPageLoc[3] = { 0 };
602
+ u8 u1rsvdpageloc[3] = { 0 };
625603 bool dlok = false;
626604 u8 *beacon;
627605 u8 *p_pspoll;
....@@ -640,7 +618,7 @@
640618 SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
641619 SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
642620 SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
643
- SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG);
621
+ SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG);
644622 /*--------------------------------------------------------
645623 (3) null data
646624 ---------------------------------------------------------*/
....@@ -648,7 +626,7 @@
648626 SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid);
649627 SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr);
650628 SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid);
651
- SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1RsvdPageLoc, NULL_PG);
629
+ SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1rsvdpageloc, NULL_PG);
652630 /*---------------------------------------------------------
653631 (4) probe response
654632 ----------------------------------------------------------*/
....@@ -656,14 +634,14 @@
656634 SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid);
657635 SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr);
658636 SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid);
659
- SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG);
637
+ SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1rsvdpageloc, PROBERSP_PG);
660638 totalpacketlen = TOTAL_RESERVED_PKT_LEN;
661639 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
662640 "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL",
663641 &reserved_page_packet[0], totalpacketlen);
664642 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
665643 "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL",
666
- u1RsvdPageLoc, 3);
644
+ u1rsvdpageloc, 3);
667645 skb = dev_alloc_skb(totalpacketlen);
668646 if (!skb) {
669647 dlok = false;
....@@ -675,15 +653,15 @@
675653 dlok = true;
676654 }
677655 if (dlok) {
678
- RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
679
- "Set RSVD page location to Fw\n");
656
+ rtl_dbg(rtlpriv, COMP_POWER, DBG_LOUD,
657
+ "Set RSVD page location to Fw\n");
680658 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
681
- "H2C_RSVDPAGE", u1RsvdPageLoc, 3);
659
+ "H2C_RSVDPAGE", u1rsvdpageloc, 3);
682660 rtl92d_fill_h2c_cmd(hw, H2C_RSVDPAGE,
683
- sizeof(u1RsvdPageLoc), u1RsvdPageLoc);
661
+ sizeof(u1rsvdpageloc), u1rsvdpageloc);
684662 } else
685
- RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
686
- "Set RSVD page location to Fw FAIL!!!!!!\n");
663
+ rtl_dbg(rtlpriv, COMP_ERR, DBG_WARNING,
664
+ "Set RSVD page location to Fw FAIL!!!!!!\n");
687665 }
688666
689667 void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus)