Commit 3dfb8e84 authored by Jes Sorensen's avatar Jes Sorensen Committed by Kalle Valo

wifi: rtl8xxxu: Support new chip RTL8188EU

This chip is found in cheap USB devices from TP-Link, D-Link, etc.

Features: 2.4 GHz, b/g/n mode, 1T1R, 150 Mbps.

Chip versions older than "I cut" need software rate control. That will
be in the next commit. Until then MCS7 is used for all data frames.

The "I cut" chips are not supported. They require different firmware
and initialisation tables. Support can be added if someone has the
hardware to test it.
Co-developed-by: default avatarAndrea Merello <andrea.merello@gmail.com>
Signed-off-by: default avatarAndrea Merello <andrea.merello@gmail.com>
Co-developed-by: default avatarTaehee Yoo <ap420073@gmail.com>
Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@gmail.com>
Co-developed-by: default avatarBitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: default avatarBitterblue Smith <rtl8821cerfe2@gmail.com>
Reviewed-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/3aad60f6-23f9-81e8-c741-4bd51e99f423@gmail.com
parent b75289e8
...@@ -10,7 +10,7 @@ config RTL8XXXU ...@@ -10,7 +10,7 @@ config RTL8XXXU
parts written to utilize the Linux mac80211 stack. parts written to utilize the Linux mac80211 stack.
The driver is known to work with a number of RTL8723AU, The driver is known to work with a number of RTL8723AU,
RL8188CU, RTL8188RU, RTL8191CU, RTL8192CU, RTL8723BU, RTL8192EU, RL8188CU, RTL8188RU, RTL8191CU, RTL8192CU, RTL8723BU, RTL8192EU,
and RTL8188FU devices. RTL8188FU, and RTL8188EU devices.
This driver is under development and has a limited feature This driver is under development and has a limited feature
set. In particular it does not yet support 40MHz channels set. In particular it does not yet support 40MHz channels
......
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
obj-$(CONFIG_RTL8XXXU) += rtl8xxxu.o obj-$(CONFIG_RTL8XXXU) += rtl8xxxu.o
rtl8xxxu-y := rtl8xxxu_core.o rtl8xxxu_8192e.o rtl8xxxu_8723b.o \ rtl8xxxu-y := rtl8xxxu_core.o rtl8xxxu_8192e.o rtl8xxxu_8723b.o \
rtl8xxxu_8723a.o rtl8xxxu_8192c.o rtl8xxxu_8188f.o rtl8xxxu_8723a.o rtl8xxxu_8192c.o rtl8xxxu_8188f.o \
rtl8xxxu_8188e.o
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#define TX_TOTAL_PAGE_NUM 0xf8 #define TX_TOTAL_PAGE_NUM 0xf8
#define TX_TOTAL_PAGE_NUM_8188F 0xf7 #define TX_TOTAL_PAGE_NUM_8188F 0xf7
#define TX_TOTAL_PAGE_NUM_8188E 0xa9
#define TX_TOTAL_PAGE_NUM_8192E 0xf3 #define TX_TOTAL_PAGE_NUM_8192E 0xf3
#define TX_TOTAL_PAGE_NUM_8723B 0xf7 #define TX_TOTAL_PAGE_NUM_8723B 0xf7
/* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */ /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */
...@@ -49,6 +50,11 @@ ...@@ -49,6 +50,11 @@
#define TX_PAGE_NUM_LO_PQ_8188F 0x02 #define TX_PAGE_NUM_LO_PQ_8188F 0x02
#define TX_PAGE_NUM_NORM_PQ_8188F 0x02 #define TX_PAGE_NUM_NORM_PQ_8188F 0x02
#define TX_PAGE_NUM_PUBQ_8188E 0x47
#define TX_PAGE_NUM_HI_PQ_8188E 0x29
#define TX_PAGE_NUM_LO_PQ_8188E 0x1c
#define TX_PAGE_NUM_NORM_PQ_8188E 0x1c
#define TX_PAGE_NUM_PUBQ_8192E 0xe7 #define TX_PAGE_NUM_PUBQ_8192E 0xe7
#define TX_PAGE_NUM_HI_PQ_8192E 0x08 #define TX_PAGE_NUM_HI_PQ_8192E 0x08
#define TX_PAGE_NUM_LO_PQ_8192E 0x0c #define TX_PAGE_NUM_LO_PQ_8192E 0x0c
...@@ -153,7 +159,8 @@ struct rtl8xxxu_rxdesc16 { ...@@ -153,7 +159,8 @@ struct rtl8xxxu_rxdesc16 {
u32 htc:1; u32 htc:1;
u32 eosp:1; u32 eosp:1;
u32 bssidfit:2; u32 bssidfit:2;
u32 reserved1:16; u32 rpt_sel:2; /* 8188e */
u32 reserved1:14;
u32 unicastwake:1; u32 unicastwake:1;
u32 magicwake:1; u32 magicwake:1;
...@@ -211,7 +218,8 @@ struct rtl8xxxu_rxdesc16 { ...@@ -211,7 +218,8 @@ struct rtl8xxxu_rxdesc16 {
u32 magicwake:1; u32 magicwake:1;
u32 unicastwake:1; u32 unicastwake:1;
u32 reserved1:16; u32 reserved1:14;
u32 rpt_sel:2; /* 8188e */
u32 bssidfit:2; u32 bssidfit:2;
u32 eosp:1; u32 eosp:1;
u32 htc:1; u32 htc:1;
...@@ -502,6 +510,8 @@ struct rtl8xxxu_txdesc40 { ...@@ -502,6 +510,8 @@ struct rtl8xxxu_txdesc40 {
#define TXDESC_AMPDU_DENSITY_SHIFT 20 #define TXDESC_AMPDU_DENSITY_SHIFT 20
#define TXDESC40_BT_INT BIT(23) #define TXDESC40_BT_INT BIT(23)
#define TXDESC40_GID_SHIFT 24 #define TXDESC40_GID_SHIFT 24
#define TXDESC_ANTENNA_SELECT_A BIT(24)
#define TXDESC_ANTENNA_SELECT_B BIT(25)
/* Word 3 */ /* Word 3 */
#define TXDESC40_USE_DRIVER_RATE BIT(8) #define TXDESC40_USE_DRIVER_RATE BIT(8)
...@@ -546,6 +556,10 @@ struct rtl8xxxu_txdesc40 { ...@@ -546,6 +556,10 @@ struct rtl8xxxu_txdesc40 {
/* Word 6 */ /* Word 6 */
#define TXDESC_MAX_AGG_SHIFT 11 #define TXDESC_MAX_AGG_SHIFT 11
#define TXDESC_USB_TX_AGG_SHIT 24
/* Word 7 */
#define TXDESC_ANTENNA_SELECT_C BIT(29)
/* Word 8 */ /* Word 8 */
#define TXDESC40_HW_SEQ_ENABLE BIT(15) #define TXDESC40_HW_SEQ_ENABLE BIT(15)
...@@ -912,6 +926,42 @@ struct rtl8188fu_efuse { ...@@ -912,6 +926,42 @@ struct rtl8188fu_efuse {
u8 res11[0xc3]; u8 res11[0xc3];
}; };
struct rtl8188eu_efuse {
__le16 rtl_id;
u8 res0[0x0e];
struct rtl8192eu_efuse_tx_power tx_power_index_A; /* 0x10 */
u8 res1[0x7e]; /* 0x3a */
u8 channel_plan; /* 0xb8 */
u8 xtal_k;
u8 thermal_meter;
u8 iqk_lck;
u8 res2[5];
u8 rf_board_option;
u8 rf_feature_option;
u8 rf_bt_setting;
u8 eeprom_version;
u8 eeprom_customer_id;
u8 res3[3];
u8 rf_antenna_option; /* 0xc9 */
u8 res4[6];
u8 vid; /* 0xd0 */
u8 res5[1];
u8 pid; /* 0xd2 */
u8 res6[1];
u8 usb_optional_function;
u8 res7[2];
u8 mac_addr[ETH_ALEN]; /* 0xd7 */
u8 res8[2];
u8 vendor_name[7];
u8 res9[2];
u8 device_name[0x0b]; /* 0xe8 */
u8 res10[2];
u8 serial[0x0b]; /* 0xf5 */
u8 res11[0x30];
u8 unknown[0x0d]; /* 0x130 */
u8 res12[0xc3];
} __packed;
struct rtl8xxxu_reg8val { struct rtl8xxxu_reg8val {
u16 reg; u16 reg;
u8 val; u8 val;
...@@ -1435,6 +1485,7 @@ struct rtl8xxxu_priv { ...@@ -1435,6 +1485,7 @@ struct rtl8xxxu_priv {
struct rtl8192cu_efuse efuse8192; struct rtl8192cu_efuse efuse8192;
struct rtl8192eu_efuse efuse8192eu; struct rtl8192eu_efuse efuse8192eu;
struct rtl8188fu_efuse efuse8188fu; struct rtl8188fu_efuse efuse8188fu;
struct rtl8188eu_efuse efuse8188eu;
} efuse_wifi; } efuse_wifi;
u32 adda_backup[RTL8XXXU_ADDA_REGS]; u32 adda_backup[RTL8XXXU_ADDA_REGS];
u32 mac_backup[RTL8XXXU_MAC_REGS]; u32 mac_backup[RTL8XXXU_MAC_REGS];
...@@ -1526,6 +1577,7 @@ struct rtl8xxxu_fileops { ...@@ -1526,6 +1577,7 @@ struct rtl8xxxu_fileops {
u8 page_num_hi; u8 page_num_hi;
u8 page_num_lo; u8 page_num_lo;
u8 page_num_norm; u8 page_num_norm;
u8 last_llt_entry;
}; };
extern int rtl8xxxu_debug; extern int rtl8xxxu_debug;
...@@ -1585,6 +1637,8 @@ void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv); ...@@ -1585,6 +1637,8 @@ void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv);
void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv); void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv);
void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv,
int channel, bool ht40); int channel, bool ht40);
void rtl8188f_set_tx_power(struct rtl8xxxu_priv *priv,
int channel, bool ht40);
void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw); void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw);
void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw); void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw);
void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv); void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv);
...@@ -1605,6 +1659,8 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv); ...@@ -1605,6 +1659,8 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv);
int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb); int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb);
int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb); int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb);
int rtl8xxxu_gen2_channel_to_group(int channel); int rtl8xxxu_gen2_channel_to_group(int channel);
bool rtl8xxxu_simularity_compare(struct rtl8xxxu_priv *priv,
int result[][8], int c1, int c2);
bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv, bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv,
int result[][8], int c1, int c2); int result[][8], int c1, int c2);
void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
...@@ -1617,13 +1673,20 @@ void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, ...@@ -1617,13 +1673,20 @@ void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi, struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
bool short_preamble, bool ampdu_enable, bool short_preamble, bool ampdu_enable,
u32 rts_rate); u32 rts_rate);
void rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
struct ieee80211_tx_info *tx_info,
struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
bool short_preamble, bool ampdu_enable,
u32 rts_rate);
void rtl8723bu_set_ps_tdma(struct rtl8xxxu_priv *priv, void rtl8723bu_set_ps_tdma(struct rtl8xxxu_priv *priv,
u8 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); u8 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5);
void rtl8723bu_phy_init_antenna_selection(struct rtl8xxxu_priv *priv); void rtl8723bu_phy_init_antenna_selection(struct rtl8xxxu_priv *priv);
void rtl8723a_set_crystal_cap(struct rtl8xxxu_priv *priv, u8 crystal_cap); void rtl8723a_set_crystal_cap(struct rtl8xxxu_priv *priv, u8 crystal_cap);
void rtl8188f_set_crystal_cap(struct rtl8xxxu_priv *priv, u8 crystal_cap);
s8 rtl8723a_cck_rssi(struct rtl8xxxu_priv *priv, u8 cck_agc_rpt); s8 rtl8723a_cck_rssi(struct rtl8xxxu_priv *priv, u8 cck_agc_rpt);
extern struct rtl8xxxu_fileops rtl8188fu_fops; extern struct rtl8xxxu_fileops rtl8188fu_fops;
extern struct rtl8xxxu_fileops rtl8188eu_fops;
extern struct rtl8xxxu_fileops rtl8192cu_fops; extern struct rtl8xxxu_fileops rtl8192cu_fops;
extern struct rtl8xxxu_fileops rtl8192eu_fops; extern struct rtl8xxxu_fileops rtl8192eu_fops;
extern struct rtl8xxxu_fileops rtl8723au_fops; extern struct rtl8xxxu_fileops rtl8723au_fops;
......
This diff is collapsed.
...@@ -370,7 +370,7 @@ static void rtl8188f_channel_to_group(int channel, int *group, int *cck_group) ...@@ -370,7 +370,7 @@ static void rtl8188f_channel_to_group(int channel, int *group, int *cck_group)
*cck_group = *group; *cck_group = *group;
} }
static void void
rtl8188f_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) rtl8188f_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40)
{ {
u32 val32, ofdm, mcs; u32 val32, ofdm, mcs;
...@@ -1651,7 +1651,7 @@ static void rtl8188f_usb_quirks(struct rtl8xxxu_priv *priv) ...@@ -1651,7 +1651,7 @@ static void rtl8188f_usb_quirks(struct rtl8xxxu_priv *priv)
#define XTAL1 GENMASK(22, 17) #define XTAL1 GENMASK(22, 17)
#define XTAL0 GENMASK(16, 11) #define XTAL0 GENMASK(16, 11)
static void rtl8188f_set_crystal_cap(struct rtl8xxxu_priv *priv, u8 crystal_cap) void rtl8188f_set_crystal_cap(struct rtl8xxxu_priv *priv, u8 crystal_cap)
{ {
struct rtl8xxxu_cfo_tracking *cfo = &priv->cfo_tracking; struct rtl8xxxu_cfo_tracking *cfo = &priv->cfo_tracking;
u32 val32; u32 val32;
......
...@@ -371,6 +371,11 @@ ...@@ -371,6 +371,11 @@
#define PBP_PAGE_SIZE_512 0x3 #define PBP_PAGE_SIZE_512 0x3
#define PBP_PAGE_SIZE_1024 0x4 #define PBP_PAGE_SIZE_1024 0x4
/* 8188eu IOL magic */
#define REG_PKT_BUF_ACCESS_CTRL 0x0106
#define PKT_BUF_ACCESS_CTRL_TX 0x69
#define PKT_BUF_ACCESS_CTRL_RX 0xa5
#define REG_TRXDMA_CTRL 0x010c #define REG_TRXDMA_CTRL 0x010c
#define TRXDMA_CTRL_RXDMA_AGG_EN BIT(2) #define TRXDMA_CTRL_RXDMA_AGG_EN BIT(2)
#define TRXDMA_CTRL_VOQ_SHIFT 4 #define TRXDMA_CTRL_VOQ_SHIFT 4
...@@ -407,6 +412,8 @@ ...@@ -407,6 +412,8 @@
#define REG_MBIST_START 0x0174 #define REG_MBIST_START 0x0174
#define REG_MBIST_DONE 0x0178 #define REG_MBIST_DONE 0x0178
#define REG_MBIST_FAIL 0x017c #define REG_MBIST_FAIL 0x017c
/* 8188EU */
#define REG_32K_CTRL 0x0194
#define REG_C2HEVT_MSG_NORMAL 0x01a0 #define REG_C2HEVT_MSG_NORMAL 0x01a0
/* 8192EU/8723BU/8812 */ /* 8192EU/8723BU/8812 */
#define REG_C2HEVT_CMD_ID_8723B 0x01ae #define REG_C2HEVT_CMD_ID_8723B 0x01ae
...@@ -942,6 +949,16 @@ ...@@ -942,6 +949,16 @@
#define REG_FPGA1_RF_MODE 0x0900 #define REG_FPGA1_RF_MODE 0x0900
#define REG_FPGA1_TX_INFO 0x090c #define REG_FPGA1_TX_INFO 0x090c
#define FPGA1_TX_ANT_MASK 0x0000000f
#define FPGA1_TX_ANT_L_MASK 0x000000f0
#define FPGA1_TX_ANT_NON_HT_MASK 0x00000f00
#define FPGA1_TX_ANT_HT1_MASK 0x0000f000
#define FPGA1_TX_ANT_HT2_MASK 0x000f0000
#define FPGA1_TX_ANT_HT_S1_MASK 0x00f00000
#define FPGA1_TX_ANT_NON_HT_S1_MASK 0x0f000000
#define FPGA1_TX_OFDM_TXSC_MASK 0x30000000
#define REG_ANT_MAPPING1 0x0914
#define REG_DPDT_CTRL 0x092c /* 8723BU */ #define REG_DPDT_CTRL 0x092c /* 8723BU */
#define REG_RFE_CTRL_ANTA_SRC 0x0930 /* 8723BU */ #define REG_RFE_CTRL_ANTA_SRC 0x0930 /* 8723BU */
#define REG_RFE_PATH_SELECT 0x0940 /* 8723BU */ #define REG_RFE_PATH_SELECT 0x0940 /* 8723BU */
...@@ -954,9 +971,25 @@ ...@@ -954,9 +971,25 @@
#define REG_CCK0_AFE_SETTING 0x0a04 #define REG_CCK0_AFE_SETTING 0x0a04
#define CCK0_AFE_RX_MASK 0x0f000000 #define CCK0_AFE_RX_MASK 0x0f000000
#define CCK0_AFE_RX_ANT_AB BIT(24) #define CCK0_AFE_TX_MASK 0xf0000000
#define CCK0_AFE_RX_ANT_A 0 #define CCK0_AFE_RX_ANT_A 0
#define CCK0_AFE_RX_ANT_B (BIT(24) | BIT(26)) #define CCK0_AFE_RX_ANT_B BIT(26)
#define CCK0_AFE_RX_ANT_C BIT(27)
#define CCK0_AFE_RX_ANT_D (BIT(26) | BIT(27))
#define CCK0_AFE_RX_ANT_OPTION_A 0
#define CCK0_AFE_RX_ANT_OPTION_B BIT(24)
#define CCK0_AFE_RX_ANT_OPTION_C BIT(25)
#define CCK0_AFE_RX_ANT_OPTION_D (BIT(24) | BIT(25))
#define CCK0_AFE_TX_ANT_A BIT(31)
#define CCK0_AFE_TX_ANT_B BIT(30)
#define REG_CCK_ANTDIV_PARA2 0x0a04
#define REG_BB_POWER_SAVE4 0x0a74
/* 8188eu */
#define REG_LNA_SWITCH 0x0b2c
#define LNA_SWITCH_DISABLE_CSCG BIT(22)
#define LNA_SWITCH_OUTPUT_CG BIT(31)
#define REG_CCK_PD_THRESH 0x0a0a #define REG_CCK_PD_THRESH 0x0a0a
#define CCK_PD_TYPE1_LV0_TH 0x40 #define CCK_PD_TYPE1_LV0_TH 0x40
...@@ -1020,6 +1053,9 @@ ...@@ -1020,6 +1053,9 @@
#define REG_OFDM0_RX_IQ_EXT_ANTA 0x0ca0 #define REG_OFDM0_RX_IQ_EXT_ANTA 0x0ca0
/* 8188eu */
#define REG_ANTDIV_PARA1 0x0ca4
/* 8723bu */ /* 8723bu */
#define REG_OFDM0_TX_PSDO_NOISE_WEIGHT 0x0ce4 #define REG_OFDM0_TX_PSDO_NOISE_WEIGHT 0x0ce4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment