mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 18:13:26 -04:00
wifi: rtw89: pci: implement PCI mac_post_init for WiFi 7 chips
For normal use, we do additional settings than mac_pre_init, such as more TX/RX DMA channels, interrupt mitigation and etc. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20231101072149.21997-6-pkshih@realtek.com
This commit is contained in:
@@ -708,6 +708,45 @@
|
||||
#define B_BE_END_PL1_CNT_MASK GENMASK(23, 16)
|
||||
#define B_BE_START_PL1_CNT_MASK GENMASK(7, 0)
|
||||
|
||||
#define R_BE_PCIE_MIT0_TMR 0x3330
|
||||
#define B_BE_PCIE_MIT0_RX_TMR_MASK GENMASK(5, 4)
|
||||
#define BE_MIT0_TMR_UNIT_1MS 0
|
||||
#define BE_MIT0_TMR_UNIT_2MS 1
|
||||
#define BE_MIT0_TMR_UNIT_4MS 2
|
||||
#define BE_MIT0_TMR_UNIT_8MS 3
|
||||
#define B_BE_PCIE_MIT0_TX_TMR_MASK GENMASK(1, 0)
|
||||
|
||||
#define R_BE_PCIE_MIT0_CNT 0x3334
|
||||
#define B_BE_PCIE_RX_MIT0_CNT_MASK GENMASK(31, 24)
|
||||
#define B_BE_PCIE_TX_MIT0_CNT_MASK GENMASK(23, 16)
|
||||
#define B_BE_PCIE_RX_MIT0_TMR_CNT_MASK GENMASK(15, 8)
|
||||
#define B_BE_PCIE_TX_MIT0_TMR_CNT_MASK GENMASK(7, 0)
|
||||
|
||||
#define R_BE_PCIE_MIT_CH_EN 0x3338
|
||||
#define B_BE_PCIE_MIT_RX1P1_EN BIT(23)
|
||||
#define B_BE_PCIE_MIT_RX0P1_EN BIT(22)
|
||||
#define B_BE_PCIE_MIT_ROQ1_EN BIT(21)
|
||||
#define B_BE_PCIE_MIT_RPQ1_EN BIT(20)
|
||||
#define B_BE_PCIE_MIT_RX1P2_EN BIT(19)
|
||||
#define B_BE_PCIE_MIT_ROQ0_EN BIT(18)
|
||||
#define B_BE_PCIE_MIT_RPQ0_EN BIT(17)
|
||||
#define B_BE_PCIE_MIT_RX0P2_EN BIT(16)
|
||||
#define B_BE_PCIE_MIT_TXCH14_EN BIT(14)
|
||||
#define B_BE_PCIE_MIT_TXCH13_EN BIT(13)
|
||||
#define B_BE_PCIE_MIT_TXCH12_EN BIT(12)
|
||||
#define B_BE_PCIE_MIT_TXCH11_EN BIT(11)
|
||||
#define B_BE_PCIE_MIT_TXCH10_EN BIT(10)
|
||||
#define B_BE_PCIE_MIT_TXCH9_EN BIT(9)
|
||||
#define B_BE_PCIE_MIT_TXCH8_EN BIT(8)
|
||||
#define B_BE_PCIE_MIT_TXCH7_EN BIT(7)
|
||||
#define B_BE_PCIE_MIT_TXCH6_EN BIT(6)
|
||||
#define B_BE_PCIE_MIT_TXCH5_EN BIT(5)
|
||||
#define B_BE_PCIE_MIT_TXCH4_EN BIT(4)
|
||||
#define B_BE_PCIE_MIT_TXCH3_EN BIT(3)
|
||||
#define B_BE_PCIE_MIT_TXCH2_EN BIT(2)
|
||||
#define B_BE_PCIE_MIT_TXCH1_EN BIT(1)
|
||||
#define B_BE_PCIE_MIT_TXCH0_EN BIT(0)
|
||||
|
||||
#define R_BE_SER_PL1_CTRL 0x34A8
|
||||
#define B_BE_PL1_SER_PL1_EN BIT(31)
|
||||
#define B_BE_PL1_IGNORE_HOT_RST BIT(30)
|
||||
@@ -800,12 +839,15 @@
|
||||
#define RTW89_PCI_MULTITAG 8
|
||||
|
||||
/* PCIE CFG register */
|
||||
#define RTW89_PCIE_CAPABILITY_SPEED 0x7C
|
||||
#define RTW89_PCIE_SUPPORT_GEN_MASK GENMASK(3, 0)
|
||||
#define RTW89_PCIE_L1_STS_V1 0x80
|
||||
#define RTW89_BCFG_LINK_SPEED_MASK GENMASK(19, 16)
|
||||
#define RTW89_PCIE_GEN1_SPEED 0x01
|
||||
#define RTW89_PCIE_GEN2_SPEED 0x02
|
||||
#define RTW89_PCIE_PHY_RATE 0x82
|
||||
#define RTW89_PCIE_PHY_RATE_MASK GENMASK(1, 0)
|
||||
#define RTW89_PCIE_LINK_CHANGE_SPEED 0xA0
|
||||
#define RTW89_PCIE_L1SS_STS_V1 0x0168
|
||||
#define RTW89_PCIE_BIT_ASPM_L11 BIT(3)
|
||||
#define RTW89_PCIE_BIT_ASPM_L12 BIT(2)
|
||||
@@ -820,6 +862,8 @@
|
||||
#define RTW89_PCIE_BIT_CLK BIT(4)
|
||||
#define RTW89_PCIE_BIT_L1 BIT(3)
|
||||
#define RTW89_PCIE_CLK_CTRL 0x0725
|
||||
#define RTW89_PCIE_FTS 0x080C
|
||||
#define RTW89_PCIE_POLLING_BIT BIT(17)
|
||||
#define RTW89_PCIE_RST_MSTATE 0x0B48
|
||||
#define RTW89_PCIE_BIT_CFG_RST_MSTATE BIT(0)
|
||||
|
||||
|
||||
@@ -385,8 +385,44 @@ int rtw89_pci_ltr_set_v2(struct rtw89_dev *rtwdev, bool en)
|
||||
}
|
||||
EXPORT_SYMBOL(rtw89_pci_ltr_set_v2);
|
||||
|
||||
static void rtw89_pci_configure_mit_be(struct rtw89_dev *rtwdev)
|
||||
{
|
||||
u32 cnt;
|
||||
u32 val;
|
||||
|
||||
rtw89_write32_mask(rtwdev, R_BE_PCIE_MIT0_TMR,
|
||||
B_BE_PCIE_MIT0_RX_TMR_MASK, BE_MIT0_TMR_UNIT_1MS);
|
||||
|
||||
val = rtw89_read32(rtwdev, R_BE_PCIE_MIT0_CNT);
|
||||
cnt = min_t(u32, U8_MAX, RTW89_PCI_RXBD_NUM_MAX / 2);
|
||||
val = u32_replace_bits(val, cnt, B_BE_PCIE_RX_MIT0_CNT_MASK);
|
||||
val = u32_replace_bits(val, 2, B_BE_PCIE_RX_MIT0_TMR_CNT_MASK);
|
||||
rtw89_write32(rtwdev, R_BE_PCIE_MIT0_CNT, val);
|
||||
}
|
||||
|
||||
static int rtw89_pci_ops_mac_post_init_be(struct rtw89_dev *rtwdev)
|
||||
{
|
||||
const struct rtw89_pci_info *info = rtwdev->pci_info;
|
||||
int ret;
|
||||
|
||||
ret = info->ltr_set(rtwdev, true);
|
||||
if (ret) {
|
||||
rtw89_err(rtwdev, "pci ltr set fail\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
rtw89_pci_ctrl_trxdma_pcie_be(rtwdev, MAC_AX_PCIE_IGNORE,
|
||||
MAC_AX_PCIE_IGNORE, MAC_AX_PCIE_ENABLE);
|
||||
rtw89_pci_ctrl_wpdma_pcie_be(rtwdev, true);
|
||||
rtw89_pci_ctrl_txdma_ch_be(rtwdev, true, true);
|
||||
rtw89_pci_configure_mit_be(rtwdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct rtw89_pci_gen_def rtw89_pci_gen_be = {
|
||||
.mac_pre_init = rtw89_pci_ops_mac_pre_init_be,
|
||||
.mac_post_init = rtw89_pci_ops_mac_post_init_be,
|
||||
|
||||
.clr_idx_all = rtw89_pci_clr_idx_all_be,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user