wifi: rtl8xxxu: Support new chip RTL8188FU
PATCH v2 1/1 wifi: rtl8xxxu: Support new chip RTL8188FU
This chip is found in the cheapest USB adapters, e.g. 1.17 USD with VAT and shipping from China included.
It's a gen 2 chip, similar to the RTL8723BU, but without Bluetooth.
Features: 2.4 GHz, b/g/n mode, 1T1R, 150 Mbps.
The vendor driver rtl8188fu version 4.3.23.6_20964.20170110 [0] was used as reference. The CD shipped with the device includes a newer driver, version 5.11.5-1-g12f7cde4b.20201102, but that one couldn't complete the WPA2 key exchange thing for whatever reason.
[0] https://github.com/kelebek333/rtl8188fu
---
v2:
- Make some functions static, remove an unused variable.
- Remove "The speed is not great yet, but it's usable." from the commit message. Other patches will improve the speed.
--- .../net/wireless/realtek/rtl8xxxu/Makefile | 2 +- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 56 + .../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 1696 +++++++++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8192c.c | 1 + .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 + .../realtek/rtl8xxxu/rtl8xxxu_8723a.c | 1 + .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 3 +- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 137 +- .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 19 + 9 files changed, 1891 insertions(+), 25 deletions(-) create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
drivers/net/wireless/realtek/rtl8xxxu/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-$(CONFIG_RTL8XXXU) += rtl8xxxu.o rtl8xxxu-y := rtl8xxxu_core.o rtl8xxxu_8192e.o rtl8xxxu_8723b.o \ - rtl8xxxu_8723a.o rtl8xxxu_8192c.o + rtl8xxxu_8723a.o rtl8xxxu_8192c.o rtl8xxxu_8188f.o
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +56 -0
102 lines not on this page · raw message
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +1696 -0
1,696 lines not on this page · raw message
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +1 -0
@@ -549,6 +549,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = { .llt_init = rtl8xxxu_init_llt_table, .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, .init_phy_rf = rtl8192cu_init_phy_rf, + .phy_lc_calibrate = rtl8723a_phy_lc_calibrate, .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, .config_channel = rtl8xxxu_gen1_config_channel, .parse_rx_desc = rtl8xxxu_parse_rxdesc16,
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +1 -0
@@ -1680,6 +1680,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = { .llt_init = rtl8xxxu_auto_llt_table, .init_phy_bb = rtl8192eu_init_phy_bb, .init_phy_rf = rtl8192eu_init_phy_rf, + .phy_lc_calibrate = rtl8723a_phy_lc_calibrate, .phy_iq_calibrate = rtl8192eu_phy_iq_calibrate, .config_channel = rtl8xxxu_gen2_config_channel, .parse_rx_desc = rtl8xxxu_parse_rxdesc24,
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +1 -0
@@ -366,6 +366,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = { .llt_init = rtl8xxxu_init_llt_table, .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, .init_phy_rf = rtl8723au_init_phy_rf, + .phy_lc_calibrate = rtl8723a_phy_lc_calibrate, .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, .config_channel = rtl8xxxu_gen1_config_channel, .parse_rx_desc = rtl8xxxu_parse_rxdesc16,
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +2 -1
@@ -518,7 +518,7 @@ static int rtl8723bu_init_phy_rf(struct rtl8xxxu_priv *priv)return ret; } -static void rtl8723bu_phy_init_antenna_selection (struct rtl8xxxu_priv *priv) +void rtl8723bu_phy_init_antenna_selection (struct rtl8xxxu_priv *priv) {u32 val32;
@@ -1650,6 +1650,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = { .init_phy_bb = rtl8723bu_init_phy_bb, .init_phy_rf = rtl8723bu_init_phy_rf, .phy_init_antenna_selection = rtl8723bu_phy_init_antenna_selection, + .phy_lc_calibrate = rtl8723a_phy_lc_calibrate, .phy_iq_calibrate = rtl8723bu_phy_iq_calibrate, .config_channel = rtl8xxxu_gen2_config_channel, .parse_rx_desc = rtl8xxxu_parse_rxdesc24,
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +114 -23
280 lines not on this page · raw message
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +19 -0
@@ -135,6 +135,7 @@#define REG_CAL_TIMER 0x003c#define REG_ACLK_MON 0x003e#define REG_GPIO_MUXCFG 0x0040 +#define GPIO_MUXCFG_IO_SEL_ENBT BIT(5)#define REG_GPIO_IO_SEL 0x0042#define REG_MAC_PINMUX_CFG 0x0043#define REG_GPIO_PIN_CTRL 0x0044
@@ -391,6 +392,7 @@#define REG_CPWM 0x012f#define REG_FWIMR 0x0130#define REG_FWISR 0x0134 +#define REG_FTIMR 0x0138#define REG_PKTBUF_DBG_CTRL 0x0140#define REG_PKTBUF_DBG_DATA_L 0x0144#define REG_PKTBUF_DBG_DATA_H 0x0148
@@ -440,6 +442,9 @@#define REG_FIFOPAGE 0x0204#define REG_TDECTRL 0x0208 + +#define REG_DWBCN0_CTRL_8188F REG_TDECTRL +#define REG_TXDMA_OFFSET_CHK 0x020c#define TXDMA_OFFSET_DROP_DATA_EN BIT(9)#define REG_TXDMA_STATUS 0x0210
@@ -925,6 +930,7 @@#define REG_FPGA0_XA_LSSI_READBACK 0x08a0/* Tranceiver LSSI Readback */ #define REG_FPGA0_XB_LSSI_READBACK 0x08a4 +#define REG_FPGA0_PSD_REPORT 0x08b4#define REG_HSPI_XA_READBACK 0x08b8/* Transceiver A HSPI read */ #define REG_HSPI_XB_READBACK 0x08bc/* Transceiver B HSPI read */
@@ -936,6 +942,7 @@#define REG_RFE_PATH_SELECT 0x0940/* 8723BU */ #define REG_RFE_BUFFER 0x0944/* 8723BU */ #define REG_S0S1_PATH_SWITCH 0x0948/* 8723BU */ +#define REG_OFDM_RX_DFIR 0x954#define REG_CCK0_SYSTEM 0x0a00#define CCK0_SIDEBAND BIT(4)
@@ -946,6 +953,13 @@#define CCK0_AFE_RX_ANT_A 0#define CCK0_AFE_RX_ANT_B (BIT(24) | BIT(26)) +#define REG_CCK_PD_THRESH 0x0a0a +#define CCK_PD_TYPE1_LV0_TH 0x40 +#define CCK_PD_TYPE1_LV1_TH 0x83 +#define CCK_PD_TYPE1_LV2_TH 0xcd +#define CCK_PD_TYPE1_LV3_TH 0xdd +#define CCK_PD_TYPE1_LV4_TH 0xed +#define REG_CONFIG_ANT_A 0x0b68#define REG_CONFIG_ANT_B 0x0b6c
@@ -965,6 +979,7 @@#define REG_OFDM0_FA_RSTC 0x0c0c +#define REG_OFDM0_XA_RX_AFE 0x0c10#define REG_OFDM0_XA_RX_IQ_IMBALANCE 0x0c14#define REG_OFDM0_XB_RX_IQ_IMBALANCE 0x0c1c
@@ -1011,6 +1026,9 @@#define OFDM_LSTF_MASK 0x70000000#define REG_OFDM1_TRX_PATH_ENABLE 0x0d04 +#define REG_OFDM1_CFO_TRACKING 0x0d2c +#define REG_OFDM1_CSI_FIX_MASK1 0x0d40 +#define REG_OFDM1_CSI_FIX_MASK2 0x0d44#define REG_TX_AGC_A_RATE18_06 0x0e00#define REG_TX_AGC_A_RATE54_24 0x0e04
@@ -1202,6 +1220,7 @@#define RF6052_REG_UNKNOWN_43 0x43#define RF6052_REG_UNKNOWN_55 0x55#define RF6052_REG_UNKNOWN_56 0x56 +#define RF6052_REG_RXG_MIX_SWBW 0x87#define RF6052_REG_S0S1 0xb0#define RF6052_REG_UNKNOWN_DF 0xdf#define RF6052_REG_UNKNOWN_ED 0xed
Signature · 1 line
2.37.2
Quoted 14 lines · Bitterblue Smith
This chip is found in the cheapest USB adapters, e.g. 1.17 USD with VAT and shipping from China included.
It's a gen 2 chip, similar to the RTL8723BU, but without Bluetooth.
Features: 2.4 GHz, b/g/n mode, 1T1R, 150 Mbps.The vendor driver rtl8188fu version 4.3.23.6_20964.20170110 [0] was used as reference. The CD shipped with the device includes a newer driver, version 5.11.5-1-g12f7cde4b.20201102, but that one couldn't complete the WPA2 key exchange thing for whatever reason.
[0] https://github.com/kelebek333/rtl8188fu
Signed-off-by Bitterblue Smith <[email protected]>
[...]
Quoted 16 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +10
-0@@ -0,0 +1,1696 @@ +/* +* RTL8XXXU mac80211 USB driver - 8188f specific subdriver +* +* Copyright (c) 2022 Bitterblue Smith <[email protected]> +* +* Portions copied from existing rtl8xxxu code: +* Copyright (c) 2014 - 2017 Jes Sorensen <[email protected]> +* +* Portions, notably calibration code: +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c line 20
Quoted 10 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +10
-0+* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/
Please use SPDX tags instead of the license text, you can see examples from other rtl8xxxu files.
Quoted 1 line
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +1
-0+static struct rtl8xxxu_reg8val rtl8188f_mac_init_table[] = {
[...]
Quoted 1 line
+static struct
rtl8xxxu_reg32valrtl8188fu_phy_init_table[] = {
[...]
Quoted 1 line
+static struct
rtl8xxxu_reg32valrtl8188f_agc_table[] = {
[...]
Quoted 1 line
+static struct
rtl8xxxu_rfregvalrtl8188fu_radioa_init_table[] = {
[...]
Quoted 1 line
+static struct
rtl8xxxu_rfregvalrtl8188fu_cut_b_radioa_init_table[] = {
Can these arrays be static const?
Quoted 18 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +18
-0+/* A workaround to eliminate the 2400MHz, 2440MHz, 2480MHz spur of 8188F. */ +static void rtl8188f_spur_calibration (struct rtl8xxxu_priv *priv,u8 channel) +{ +const u32 frequencies[14 +1 ] = { + [5 ] =0xFCCD , + [6 ] =0xFC4D , + [7 ] =0xFFCD , + [8 ] =0xFF4D , + [11 ] =0xFDCD , + [13 ] =0xFCCD , + [14 ] =0xFF9A + }; + +const u32 reg_d40[14 +1 ] = { + [5 ] =0x06000000 , + [6 ] =0x00000600 , + [13 ] =0x06000000 + };
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c line 420
Quoted 10 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +10
-0+ +const u32 reg_d44[14 +1 ] = { + [11 ] =0x04000000 + }; + +const u32 reg_d4c[14 +1 ] = { + [7 ] =0x06000000 , + [8 ] =0x00000380 , + [14 ] =0x00180000 + };
Also can these be static const?
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c line 430
Quoted 1 line
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +1
-0+/*enable notch filter */
Add a space after '/*':
/* enable notch filter */
I see similar problems in other comments, please go through them.
This is nitpicking, but to improve readability I prefer to have an empty line before a comment. I saw several cases which didn't have that.
Quoted 28 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +28
-0+if (t) { +if (!priv->pi_enabled) { +/* +* Switch back BB to SI mode after finishing +* IQ Calibration +*/ + val32 =0x01000000 ; +rtl8xxxu_write32 (priv,REG_FPGA0_XA_HSSI_PARM1 , val32); +rtl8xxxu_write32 (priv,REG_FPGA0_XB_HSSI_PARM1 , val32); + } + +/* Reload ADDA power saving parameters */ +rtl8xxxu_restore_regs (priv, adda_regs, priv->adda_backup, +RTL8XXXU_ADDA_REGS ); + +/* Reload MAC parameters */ +rtl8xxxu_restore_mac_regs (priv, iqk_mac_regs, priv->mac_backup); + +/* Reload BB parameters */ +rtl8xxxu_restore_regs (priv, iqk_bb_regs, + priv->bb_backup,RTL8XXXU_BB_REGS ); + +/* Reload RF path */ +rtl8xxxu_write32 (priv,REG_S0S1_PATH_SWITCH , path_sel_bb); +rtl8xxxu_write_rfreg (priv,RF_A ,RF6052_REG_S0S1 , path_sel_rf); + +/* Restore RX initial gain */ + val32 =rtl8xxxu_read32 (priv,REG_OFDM0_XA_AGC_CORE1 );
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c line 1226
Quoted 10 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +10
-0+ val32 &=0xffffff00 ; + val32 |=0x50 ; +rtl8xxxu_write32 (priv,REG_OFDM0_XA_AGC_CORE1 , val32); +rtl8xxxu_write32 (priv,REG_OFDM0_XA_AGC_CORE1 , rx_initial_gain &0xff ); + +/* Load 0xe30 IQC default value */ +rtl8xxxu_write32 (priv,REG_TX_IQK_TONE_A ,0x01008c00 ); +rtl8xxxu_write32 (priv,REG_RX_IQK_TONE_A ,0x01008c00 ); + } +}
You can avoid the indentation and extra block with:
if (!t)
return;
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c line 1591
Quoted 4 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c new file +4
-0+static void rtl8188f_enable_rf (struct rtl8xxxu_priv *priv) +{ +#define PPG_BB_GAIN_2G_TXA_OFFSET_8188F 0xee +#define PPG_BB_GAIN_2G_TX_OFFSET_MASK 0x0f
Please move the defines outside of the function (ie. few lines above).
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 16 lines · Kalle Valo
Bitterblue Smith <[email protected]> writes:
[...]
Quoted 1 line
+static struct
rtl8xxxu_reg8valrtl8188f_mac_init_table[] = {[...]
Quoted 1 line
+static struct
rtl8xxxu_reg32valrtl8188fu_phy_init_table[] = {[...]
Quoted 1 line
+static struct
rtl8xxxu_reg32valrtl8188f_agc_table[] = {[...]
Quoted 8 lines
Quoted 1 line
+static struct
rtl8xxxu_rfregvalrtl8188fu_radioa_init_table[] = {[...]
Quoted 1 line
+static struct
rtl8xxxu_rfregvalrtl8188fu_cut_b_radioa_init_table[] = {Can these arrays be static const?
Only if I modify the functions rtl8xxxu_init_phy_regs and rtl8xxxu_init_phy_rf, and the struct rtl8xxxu_fileops. Otherwise the compiler complains about discarded const. Perhaps in a future patch?
I implemented everything else you mentioned.
Quoted 22 lines · Bitterblue Smith
Quoted 20 lines · Kalle Valo
Bitterblue Smith <[email protected]> writes:
[...]
Quoted 1 line
+static struct
rtl8xxxu_reg8valrtl8188f_mac_init_table[] = {[...]
Quoted 1 line
+static struct
rtl8xxxu_reg32valrtl8188fu_phy_init_table[] = {[...]
Quoted 1 line
+static struct
rtl8xxxu_reg32valrtl8188f_agc_table[] = {[...]
Quoted 1 line
+static struct
rtl8xxxu_rfregvalrtl8188fu_radioa_init_table[] = {[...]
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+static struct
rtl8xxxu_rfregvalrtl8188fu_cut_b_radioa_init_table[] = {Can these arrays be static const?
Only if I modify the functions
rtl8xxxu_init_phy_regsandrtl8xxxu_init_phy_rf, and the structrtl8xxxu_fileops. Otherwise the compiler complains about discarded const. Perhaps in a future patch?
Yeah, a future patch sounds good.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches