hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/net/wireless/realtek/rtlwifi/rtl8723com/phy_common.c
....@@ -1,27 +1,5 @@
1
-/******************************************************************************
2
- *
3
- * Copyright(c) 2009-2014 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-2014 Realtek Corporation.*/
253
264 #include "../wifi.h"
275 #include "phy_common.h"
....@@ -36,15 +14,15 @@
3614 struct rtl_priv *rtlpriv = rtl_priv(hw);
3715 u32 returnvalue, originalvalue, bitshift;
3816
39
- RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
40
- "regaddr(%#x), bitmask(%#x)\n", regaddr, bitmask);
17
+ rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
18
+ "regaddr(%#x), bitmask(%#x)\n", regaddr, bitmask);
4119 originalvalue = rtl_read_dword(rtlpriv, regaddr);
4220 bitshift = rtl8723_phy_calculate_bit_shift(bitmask);
4321 returnvalue = (originalvalue & bitmask) >> bitshift;
4422
45
- RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
46
- "BBR MASK=0x%x Addr[0x%x]=0x%x\n", bitmask,
47
- regaddr, originalvalue);
23
+ rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
24
+ "BBR MASK=0x%x Addr[0x%x]=0x%x\n", bitmask,
25
+ regaddr, originalvalue);
4826 return returnvalue;
4927 }
5028 EXPORT_SYMBOL_GPL(rtl8723_phy_query_bb_reg);
....@@ -55,9 +33,9 @@
5533 struct rtl_priv *rtlpriv = rtl_priv(hw);
5634 u32 originalvalue, bitshift;
5735
58
- RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
59
- "regaddr(%#x), bitmask(%#x), data(%#x)\n", regaddr, bitmask,
60
- data);
36
+ rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
37
+ "regaddr(%#x), bitmask(%#x), data(%#x)\n", regaddr, bitmask,
38
+ data);
6139
6240 if (bitmask != MASKDWORD) {
6341 originalvalue = rtl_read_dword(rtlpriv, regaddr);
....@@ -67,21 +45,17 @@
6745
6846 rtl_write_dword(rtlpriv, regaddr, data);
6947
70
- RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
71
- "regaddr(%#x), bitmask(%#x), data(%#x)\n",
72
- regaddr, bitmask, data);
48
+ rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
49
+ "regaddr(%#x), bitmask(%#x), data(%#x)\n",
50
+ regaddr, bitmask, data);
7351 }
7452 EXPORT_SYMBOL_GPL(rtl8723_phy_set_bb_reg);
7553
7654 u32 rtl8723_phy_calculate_bit_shift(u32 bitmask)
7755 {
78
- u32 i;
56
+ u32 i = ffs(bitmask);
7957
80
- for (i = 0; i <= 31; i++) {
81
- if (((bitmask >> i) & 0x1) == 1)
82
- break;
83
- }
84
- return i;
58
+ return i ? i - 1 : 32;
8559 }
8660 EXPORT_SYMBOL_GPL(rtl8723_phy_calculate_bit_shift);
8761
....@@ -111,12 +85,10 @@
11185 (newoffset << 23) | BLSSIREADEDGE;
11286 rtl_set_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD,
11387 tmplong & (~BLSSIREADEDGE));
114
- mdelay(1);
11588 rtl_set_bbreg(hw, pphyreg->rfhssi_para2, MASKDWORD, tmplong2);
116
- mdelay(1);
11789 rtl_set_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD,
11890 tmplong | BLSSIREADEDGE);
119
- mdelay(1);
91
+ udelay(120);
12092 if (rfpath == RF90_PATH_A)
12193 rfpi_enable = (u8) rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER1,
12294 BIT(8));
....@@ -129,9 +101,9 @@
129101 else
130102 retvalue = rtl_get_bbreg(hw, pphyreg->rf_rb,
131103 BLSSIREADBACKDATA);
132
- RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
133
- "RFR-%d Addr[0x%x]=0x%x\n",
134
- rfpath, pphyreg->rf_rb, retvalue);
104
+ rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
105
+ "RFR-%d Addr[0x%x]=0x%x\n",
106
+ rfpath, pphyreg->rf_rb, retvalue);
135107 return retvalue;
136108 }
137109 EXPORT_SYMBOL_GPL(rtl8723_phy_rf_serial_read);
....@@ -154,10 +126,10 @@
154126 newoffset = offset;
155127 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff;
156128 rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr);
157
- RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
158
- "RFW-%d Addr[0x%x]=0x%x\n",
159
- rfpath, pphyreg->rf3wire_offset,
160
- data_and_addr);
129
+ rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
130
+ "RFW-%d Addr[0x%x]=0x%x\n",
131
+ rfpath, pphyreg->rf3wire_offset,
132
+ data_and_addr);
161133 }
162134 EXPORT_SYMBOL_GPL(rtl8723_phy_rf_serial_write);
163135