Commit 1b00e923 authored by Ping-Ke Shih's avatar Ping-Ke Shih Committed by Kalle Valo

rtw89: 8852c: add set channel of BB part

BB does many settings during setting channel. First is to configure CCK
for 2G channels, and then basic channel and bandwidth settings with a
encoded channel index that will report to driver when we receive packets.
Configure spur elimination to avoid spur of CSI and NBI tones in certain
frequencies. Also, it initializes BT grant to arrange path sharing with
BT according to band. Finally, reset TSSI and BB hardware to ensure it
stays in initial state.
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-12-pkshih@realtek.com
parent 63fb5c98
...@@ -307,6 +307,15 @@ const struct rtw89_phy_reg3_tbl _name ## _tbl = { \ ...@@ -307,6 +307,15 @@ const struct rtw89_phy_reg3_tbl _name ## _tbl = { \
.size = ARRAY_SIZE(_name), \ .size = ARRAY_SIZE(_name), \
} }
struct rtw89_nbi_reg_def {
struct rtw89_reg_def notch1_idx;
struct rtw89_reg_def notch1_frac_idx;
struct rtw89_reg_def notch1_en;
struct rtw89_reg_def notch2_idx;
struct rtw89_reg_def notch2_frac_idx;
struct rtw89_reg_def notch2_en;
};
extern const u8 rtw89_rs_idx_max[RTW89_RS_MAX]; extern const u8 rtw89_rs_idx_max[RTW89_RS_MAX];
extern const u8 rtw89_rs_nss_max[RTW89_RS_MAX]; extern const u8 rtw89_rs_nss_max[RTW89_RS_MAX];
......
...@@ -2962,6 +2962,8 @@ ...@@ -2962,6 +2962,8 @@
#define R_AX_PWR_MACID_LMT_TABLE0 0xD36C #define R_AX_PWR_MACID_LMT_TABLE0 0xD36C
#define R_AX_PWR_MACID_LMT_TABLE127 0xD568 #define R_AX_PWR_MACID_LMT_TABLE127 0xD568
#define R_P80_AT_HIGH_FREQ_BB_WRP 0xD848
#define B_P80_AT_HIGH_FREQ_BB_WRP BIT(28)
#define R_AX_TSSI_CTRL_HEAD 0xD908 #define R_AX_TSSI_CTRL_HEAD 0xD908
#define R_AX_BANDEDGE_CFG 0xD94C #define R_AX_BANDEDGE_CFG 0xD94C
#define B_AX_BANDEDGE_CFG_IDX_MASK GENMASK(31, 30) #define B_AX_BANDEDGE_CFG_IDX_MASK GENMASK(31, 30)
...@@ -3192,9 +3194,9 @@ ...@@ -3192,9 +3194,9 @@
#define RR_RXKPLL_POW BIT(19) #define RR_RXKPLL_POW BIT(19)
#define RR_RSV4 0x1f #define RR_RSV4 0x1f
#define RR_RXK 0x20 #define RR_RXK 0x20
#define RR_RXK_PLLEN BIT(5)
#define RR_RXK_SEL5G BIT(7)
#define RR_RXK_SEL2G BIT(8) #define RR_RXK_SEL2G BIT(8)
#define RR_RXK_SEL5G BIT(7)
#define RR_RXK_PLLEN BIT(5)
#define RR_LUTWA 0x33 #define RR_LUTWA 0x33
#define RR_LUTWA_MASK GENMASK(9, 0) #define RR_LUTWA_MASK GENMASK(9, 0)
#define RR_LUTWA_M2 GENMASK(4, 0) #define RR_LUTWA_M2 GENMASK(4, 0)
...@@ -3320,8 +3322,9 @@ ...@@ -3320,8 +3322,9 @@
#define B_SWSI_READ_ADDR_PATH_V1 GENMASK(10, 8) #define B_SWSI_READ_ADDR_PATH_V1 GENMASK(10, 8)
#define B_SWSI_READ_ADDR_V1 GENMASK(10, 0) #define B_SWSI_READ_ADDR_V1 GENMASK(10, 0)
#define R_UPD_CLK_ADC 0x0700 #define R_UPD_CLK_ADC 0x0700
#define B_UPD_CLK_ADC_ON BIT(24)
#define B_UPD_CLK_ADC_VAL GENMASK(26, 25) #define B_UPD_CLK_ADC_VAL GENMASK(26, 25)
#define B_UPD_CLK_ADC_ON BIT(24)
#define B_ENABLE_CCK BIT(5)
#define R_RSTB_ASYNC 0x0704 #define R_RSTB_ASYNC 0x0704
#define B_RSTB_ASYNC_ALL BIT(1) #define B_RSTB_ASYNC_ALL BIT(1)
#define R_MAC_PIN_SEL 0x0734 #define R_MAC_PIN_SEL 0x0734
...@@ -3368,6 +3371,8 @@ ...@@ -3368,6 +3371,8 @@
#define B_PMAC_PTX_EN BIT(4) #define B_PMAC_PTX_EN BIT(4)
#define R_PMAC_TX_CNT 0x09C8 #define R_PMAC_TX_CNT 0x09C8
#define B_PMAC_TX_CNT_MSK GENMASK(31, 0) #define B_PMAC_TX_CNT_MSK GENMASK(31, 0)
#define R_P80_AT_HIGH_FREQ 0x09D8
#define B_P80_AT_HIGH_FREQ BIT(26)
#define R_DBCC_80P80_SEL_EVM_RPT 0x0A10 #define R_DBCC_80P80_SEL_EVM_RPT 0x0A10
#define B_DBCC_80P80_SEL_EVM_RPT_EN BIT(0) #define B_DBCC_80P80_SEL_EVM_RPT_EN BIT(0)
#define R_CCX 0x0C00 #define R_CCX 0x0C00
...@@ -3400,6 +3405,14 @@ ...@@ -3400,6 +3405,14 @@
#define B_PD_HIT_DIS BIT(9) #define B_PD_HIT_DIS BIT(9)
#define R_IOQ_IQK_DPK 0x0C60 #define R_IOQ_IQK_DPK 0x0C60
#define B_IOQ_IQK_DPK_EN BIT(1) #define B_IOQ_IQK_DPK_EN BIT(1)
#define R_GNT_BT_WGT_EN 0x0C6C
#define B_GNT_BT_WGT_EN BIT(21)
#define R_PD_ARBITER_OFF 0x0C80
#define B_PD_ARBITER_OFF BIT(31)
#define R_SNDCCA_A1 0x0C9C
#define B_SNDCCA_A1_EN GENMASK(19, 12)
#define R_SNDCCA_A2 0x0CA0
#define B_SNDCCA_A2_VAL GENMASK(19, 12)
#define R_P0_EN_SOUND_WO_NDP 0x0D7C #define R_P0_EN_SOUND_WO_NDP 0x0D7C
#define B_P0_EN_SOUND_WO_NDP BIT(1) #define B_P0_EN_SOUND_WO_NDP BIT(1)
#define R_SPOOF_ASYNC_RST 0x0D84 #define R_SPOOF_ASYNC_RST 0x0D84
...@@ -3506,6 +3519,9 @@ ...@@ -3506,6 +3519,9 @@
#define B_RXSCOBC_TH GENMASK(18, 0) #define B_RXSCOBC_TH GENMASK(18, 0)
#define R_RXSCOCCK 0x23B4 #define R_RXSCOCCK 0x23B4
#define B_RXSCOCCK_TH GENMASK(18, 0) #define B_RXSCOCCK_TH GENMASK(18, 0)
#define R_P80_AT_HIGH_FREQ_RU_ALLOC 0x2410
#define B_P80_AT_HIGH_FREQ_RU_ALLOC_PHY1 BIT(14)
#define B_P80_AT_HIGH_FREQ_RU_ALLOC_PHY0 BIT(13)
#define R_DBCC_80P80_SEL_EVM_RPT2 0x2A10 #define R_DBCC_80P80_SEL_EVM_RPT2 0x2A10
#define B_DBCC_80P80_SEL_EVM_RPT2_EN BIT(0) #define B_DBCC_80P80_SEL_EVM_RPT2_EN BIT(0)
#define R_P1_EN_SOUND_WO_NDP 0x2D7C #define R_P1_EN_SOUND_WO_NDP 0x2D7C
...@@ -3540,6 +3556,12 @@ ...@@ -3540,6 +3556,12 @@
#define R_CFO_TRK0 0x4404 #define R_CFO_TRK0 0x4404
#define R_CFO_TRK1 0x440C #define R_CFO_TRK1 0x440C
#define B_CFO_TRK_MSK GENMASK(14, 10) #define B_CFO_TRK_MSK GENMASK(14, 10)
#define R_T2F_GI_COMB 0x4424
#define B_T2F_GI_COMB_EN BIT(2)
#define R_BT_DYN_DC_EST_EN 0x441C
#define B_BT_DYN_DC_EST_EN_MSK BIT(31)
#define R_ASSIGN_SBD_OPT 0x4450
#define B_ASSIGN_SBD_OPT_EN BIT(24)
#define R_DCFO_COMP_S0 0x448C #define R_DCFO_COMP_S0 0x448C
#define B_DCFO_COMP_S0_MSK GENMASK(11, 0) #define B_DCFO_COMP_S0_MSK GENMASK(11, 0)
#define R_DCFO_WEIGHT 0x4490 #define R_DCFO_WEIGHT 0x4490
...@@ -3554,6 +3576,22 @@ ...@@ -3554,6 +3576,22 @@
#define B_TXPWR_MSK GENMASK(30, 22) #define B_TXPWR_MSK GENMASK(30, 22)
#define R_TXNSS_MAP 0x45B4 #define R_TXNSS_MAP 0x45B4
#define B_TXNSS_MAP_MSK GENMASK(20, 17) #define B_TXNSS_MAP_MSK GENMASK(20, 17)
#define R_PCOEFF0_V1 0x45BC
#define B_PCOEFF01_MSK_V1 GENMASK(23, 0)
#define R_PCOEFF2_V1 0x45CC
#define B_PCOEFF23_MSK_V1 GENMASK(23, 0)
#define R_PCOEFF4_V1 0x45D0
#define B_PCOEFF45_MSK_V1 GENMASK(23, 0)
#define R_PCOEFF6_V1 0x45D4
#define B_PCOEFF67_MSK_V1 GENMASK(23, 0)
#define R_PCOEFF8_V1 0x45D8
#define B_PCOEFF89_MSK_V1 GENMASK(23, 0)
#define R_PCOEFFA_V1 0x45C0
#define B_PCOEFFAB_MSK_V1 GENMASK(23, 0)
#define R_PCOEFFC_V1 0x45C4
#define B_PCOEFFCD_MSK_V1 GENMASK(23, 0)
#define R_PCOEFFE_V1 0x45C8
#define B_PCOEFFEF_MSK_V1 GENMASK(23, 0)
#define R_PATH0_IB_PKPW 0x4628 #define R_PATH0_IB_PKPW 0x4628
#define B_PATH0_IB_PKPW_MSK GENMASK(11, 6) #define B_PATH0_IB_PKPW_MSK GENMASK(11, 6)
#define R_PATH0_LNA_ERR1 0x462C #define R_PATH0_LNA_ERR1 0x462C
...@@ -3601,6 +3639,14 @@ ...@@ -3601,6 +3639,14 @@
#define R_PATH0_G_TIA1_LNA6_OP1DB_V1 0x4694 #define R_PATH0_G_TIA1_LNA6_OP1DB_V1 0x4694
#define B_PATH0_R_G_OFST_MASK GENMASK(23, 16) #define B_PATH0_R_G_OFST_MASK GENMASK(23, 16)
#define B_PATH0_G_TIA1_LNA6_OP1DB_V1 GENMASK(15, 8) #define B_PATH0_G_TIA1_LNA6_OP1DB_V1 GENMASK(15, 8)
#define R_CDD_EVM_CHK_EN 0x46C0
#define B_CDD_EVM_CHK_EN BIT(0)
#define R_PATH0_BAND_SEL_V1 0x4738
#define B_PATH0_BAND_SEL_MSK_V1 BIT(17)
#define R_PATH0_BT_SHARE_V1 0x4738
#define B_PATH0_BT_SHARE_V1 BIT(19)
#define R_PATH0_BTG_PATH_V1 0x4738
#define B_PATH0_BTG_PATH_V1 BIT(22)
#define R_P0_NBIIDX 0x469C #define R_P0_NBIIDX 0x469C
#define B_P0_NBIIDX_VAL GENMASK(11, 0) #define B_P0_NBIIDX_VAL GENMASK(11, 0)
#define B_P0_NBIIDX_NOTCH_EN BIT(12) #define B_P0_NBIIDX_NOTCH_EN BIT(12)
...@@ -3614,12 +3660,20 @@ ...@@ -3614,12 +3660,20 @@
#define B_PATH1_BTG_SHEN GENMASK(18, 17) #define B_PATH1_BTG_SHEN GENMASK(18, 17)
#define R_PATH1_RXB_INIT 0x472C #define R_PATH1_RXB_INIT 0x472C
#define B_PATH1_RXB_INIT_IDX_MSK GENMASK(9, 5) #define B_PATH1_RXB_INIT_IDX_MSK GENMASK(9, 5)
#define R_PATH1_G_LNA6_OP1DB_V1 0x476C
#define B_PATH1_G_LNA6_OP1DB_V1 GENMASK(31, 24)
#define R_PATH1_P20_FOLLOW_BY_PAGCUGC 0x4774 #define R_PATH1_P20_FOLLOW_BY_PAGCUGC 0x4774
#define B_PATH1_P20_FOLLOW_BY_PAGCUGC_EN_MSK BIT(5) #define B_PATH1_P20_FOLLOW_BY_PAGCUGC_EN_MSK BIT(5)
#define R_PATH1_S20_FOLLOW_BY_PAGCUGC 0x4778 #define R_PATH1_S20_FOLLOW_BY_PAGCUGC 0x4778
#define B_PATH1_S20_FOLLOW_BY_PAGCUGC_EN_MSK BIT(5) #define B_PATH1_S20_FOLLOW_BY_PAGCUGC_EN_MSK BIT(5)
#define R_PATH1_G_TIA0_LNA6_OP1DB_V1 0x4778 #define R_PATH1_G_TIA0_LNA6_OP1DB_V1 0x4778
#define B_PATH1_G_TIA0_LNA6_OP1DB_V1 GENMASK(7, 0) #define B_PATH1_G_TIA0_LNA6_OP1DB_V1 GENMASK(7, 0)
#define R_PATH1_BAND_SEL_V1 0x4AA4
#define B_PATH1_BAND_SEL_MSK_V1 BIT(17)
#define R_PATH1_BT_SHARE_V1 0x4AA4
#define B_PATH1_BT_SHARE_V1 BIT(19)
#define R_PATH1_BTG_PATH_V1 0x4AA4
#define B_PATH1_BTG_PATH_V1 BIT(22)
#define R_P1_NBIIDX 0x4770 #define R_P1_NBIIDX 0x4770
#define B_P1_NBIIDX_VAL GENMASK(11, 0) #define B_P1_NBIIDX_VAL GENMASK(11, 0)
#define B_P1_NBIIDX_NOTCH_EN BIT(12) #define B_P1_NBIIDX_NOTCH_EN BIT(12)
...@@ -3631,9 +3685,28 @@ ...@@ -3631,9 +3685,28 @@
#define R_FC0_BW 0x4974 #define R_FC0_BW 0x4974
#define B_FC0_BW_INV GENMASK(6, 0) #define B_FC0_BW_INV GENMASK(6, 0)
#define B_FC0_BW_SET GENMASK(31, 30) #define B_FC0_BW_SET GENMASK(31, 30)
#define B_ANT_RX_BT_SEG0 GENMASK(25, 22)
#define B_ANT_RX_1RCCA_SEG1 GENMASK(21, 18)
#define B_ANT_RX_1RCCA_SEG0 GENMASK(17, 14)
#define R_CHBW_MOD 0x4978 #define R_CHBW_MOD 0x4978
#define B_CHBW_MOD_PRICH GENMASK(11, 8) #define B_BT_SHARE BIT(14)
#define B_CHBW_MOD_SBW GENMASK(13, 12) #define B_CHBW_MOD_SBW GENMASK(13, 12)
#define B_CHBW_MOD_PRICH GENMASK(11, 8)
#define B_ANT_RX_SEG0 GENMASK(3, 0)
#define R_BK_FC0_INV_V1 0x4A1C
#define B_BK_FC0_INV_MSK_V1 GENMASK(18, 0)
#define R_CCK_FC0_INV_V1 0x4A20
#define B_CCK_FC0_INV_MSK_V1 GENMASK(18, 0)
#define R_PATH0_5MDET 0x4C4C
#define B_PATH0_5MDET_EN BIT(12)
#define B_PATH0_5MDET_SB2 BIT(8)
#define B_PATH0_5MDET_SB0 BIT(6)
#define B_PATH0_5MDET_TH GENMASK(5, 0)
#define R_PATH1_5MDET 0x4D10
#define B_PATH1_5MDET_EN BIT(12)
#define B_PATH1_5MDET_SB2 BIT(8)
#define B_PATH1_5MDET_SB0 BIT(6)
#define B_PATH1_5MDET_TH GENMASK(5, 0)
#define R_RPL_BIAS_COMP 0x4DF0 #define R_RPL_BIAS_COMP 0x4DF0
#define B_RPL_BIAS_COMP_MASK GENMASK(7, 0) #define B_RPL_BIAS_COMP_MASK GENMASK(7, 0)
#define R_RPL_PATHAB 0x4E0C #define R_RPL_PATHAB 0x4E0C
...@@ -3642,6 +3715,10 @@ ...@@ -3642,6 +3715,10 @@
#define R_RSSI_M_PATHAB 0x4E2C #define R_RSSI_M_PATHAB 0x4E2C
#define B_RSSI_M_PATHB_MASK GENMASK(15, 8) #define B_RSSI_M_PATHB_MASK GENMASK(15, 8)
#define B_RSSI_M_PATHA_MASK GENMASK(7, 0) #define B_RSSI_M_PATHA_MASK GENMASK(7, 0)
#define R_FC0_V1 0x4E30
#define B_FC0_MSK_V1 GENMASK(12, 0)
#define R_RX_BW40_2XFFT_EN_V1 0x4E30
#define B_RX_BW40_2XFFT_EN_MSK_V1 BIT(26)
#define R_DCFO_COMP_S0_V1 0x4A40 #define R_DCFO_COMP_S0_V1 0x4A40
#define B_DCFO_COMP_S0_V1_MSK GENMASK(13, 0) #define B_DCFO_COMP_S0_V1_MSK GENMASK(13, 0)
#define R_BMODE_PDTH_V1 0x4B64 #define R_BMODE_PDTH_V1 0x4B64
...@@ -3880,6 +3957,14 @@ ...@@ -3880,6 +3957,14 @@
#define B_IQKINF2_FCNT GENMASK(23, 16) #define B_IQKINF2_FCNT GENMASK(23, 16)
#define B_IQKINF2_KCNT GENMASK(15, 8) #define B_IQKINF2_KCNT GENMASK(15, 8)
#define B_IQKINF2_NCTLV GENMAKS(7, 0) #define B_IQKINF2_NCTLV GENMAKS(7, 0)
#define R_PATH0_SAMPL_DLY_T_V1 0xC0D4
#define B_PATH0_SAMPL_DLY_T_MSK_V1 GENMASK(27, 26)
#define R_PATH1_SAMPL_DLY_T_V1 0xC1D4
#define B_PATH1_SAMPL_DLY_T_MSK_V1 GENMASK(27, 26)
#define R_PATH0_BW_SEL_V1 0xC0D8
#define B_PATH0_BW_SEL_MSK_V1 GENMASK(8, 5)
#define R_PATH1_BW_SEL_V1 0xC1D8
#define B_PATH1_BW_SEL_MSK_V1 GENMASK(8, 5)
#define R_P0_CFCH_BW0 0xC0D4 #define R_P0_CFCH_BW0 0xC0D4
#define B_P0_CFCH_BW0 GENMASK(27, 26) #define B_P0_CFCH_BW0 GENMASK(27, 26)
#define R_P0_CFCH_BW1 0xC0D8 #define R_P0_CFCH_BW1 0xC0D8
......
...@@ -14,4 +14,34 @@ ...@@ -14,4 +14,34 @@
#define rtw89_for_each_rtwvif(rtwdev, rtwvif) \ #define rtw89_for_each_rtwvif(rtwdev, rtwvif) \
list_for_each_entry(rtwvif, &(rtwdev)->rtwvifs_list, list) list_for_each_entry(rtwvif, &(rtwdev)->rtwvifs_list, list)
/* The result of negative dividend and positive divisor is undefined, but it
* should be one case of round-down or round-up. So, make it round-down if the
* result is round-up.
* Note: the maximum value of divisor is 0x7FFF_FFFF, because we cast it to
* signed value to make compiler to use signed divide instruction.
*/
static inline s32 s32_div_u32_round_down(s32 dividend, u32 divisor, s32 *remainder)
{
s32 i_divisor = (s32)divisor;
s32 i_remainder;
s32 quotient;
quotient = dividend / i_divisor;
i_remainder = dividend % i_divisor;
if (i_remainder < 0) {
quotient--;
i_remainder += i_divisor;
}
if (remainder)
*remainder = i_remainder;
return quotient;
}
static inline s32 s32_div_u32_round_closest(s32 dividend, u32 divisor)
{
return s32_div_u32_round_down(dividend + divisor / 2, divisor, NULL);
}
#endif #endif
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