xref: /linux/drivers/net/wireless/realtek/rtw89/rtw8922de.c (revision 91a4855d6c03e770e42f17c798a36a3c46e63de2)
1*a16ca7d9SPing-Ke Shih // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2*a16ca7d9SPing-Ke Shih /* Copyright(c) 2026  Realtek Corporation
3*a16ca7d9SPing-Ke Shih  */
4*a16ca7d9SPing-Ke Shih 
5*a16ca7d9SPing-Ke Shih #include <linux/module.h>
6*a16ca7d9SPing-Ke Shih #include <linux/pci.h>
7*a16ca7d9SPing-Ke Shih 
8*a16ca7d9SPing-Ke Shih #include "pci.h"
9*a16ca7d9SPing-Ke Shih #include "reg.h"
10*a16ca7d9SPing-Ke Shih #include "rtw8922d.h"
11*a16ca7d9SPing-Ke Shih 
12*a16ca7d9SPing-Ke Shih static const struct rtw89_pci_info rtw8922d_pci_info = {
13*a16ca7d9SPing-Ke Shih 	.gen_def		= &rtw89_pci_gen_be,
14*a16ca7d9SPing-Ke Shih 	.isr_def		= &rtw89_pci_isr_be_v1,
15*a16ca7d9SPing-Ke Shih 	.txbd_trunc_mode	= MAC_AX_BD_TRUNC,
16*a16ca7d9SPing-Ke Shih 	.rxbd_trunc_mode	= MAC_AX_BD_TRUNC,
17*a16ca7d9SPing-Ke Shih 	.rxbd_mode		= MAC_AX_RXBD_PKT,
18*a16ca7d9SPing-Ke Shih 	.tag_mode		= MAC_AX_TAG_MULTI,
19*a16ca7d9SPing-Ke Shih 	.tx_burst		= MAC_AX_TX_BURST_V1_256B,
20*a16ca7d9SPing-Ke Shih 	.rx_burst		= MAC_AX_RX_BURST_V1_128B,
21*a16ca7d9SPing-Ke Shih 	.wd_dma_idle_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
22*a16ca7d9SPing-Ke Shih 	.wd_dma_act_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
23*a16ca7d9SPing-Ke Shih 	.multi_tag_num		= MAC_AX_TAG_NUM_8,
24*a16ca7d9SPing-Ke Shih 	.lbc_en			= MAC_AX_PCIE_ENABLE,
25*a16ca7d9SPing-Ke Shih 	.lbc_tmr		= MAC_AX_LBC_TMR_2MS,
26*a16ca7d9SPing-Ke Shih 	.autok_en		= MAC_AX_PCIE_DISABLE,
27*a16ca7d9SPing-Ke Shih 	.io_rcy_en		= MAC_AX_PCIE_ENABLE,
28*a16ca7d9SPing-Ke Shih 	.io_rcy_tmr		= MAC_AX_IO_RCY_ANA_TMR_DEF,
29*a16ca7d9SPing-Ke Shih 	.rx_ring_eq_is_full	= true,
30*a16ca7d9SPing-Ke Shih 	.check_rx_tag		= true,
31*a16ca7d9SPing-Ke Shih 	.no_rxbd_fs		= true,
32*a16ca7d9SPing-Ke Shih 	.group_bd_addr		= true,
33*a16ca7d9SPing-Ke Shih 	.rpp_fmt_size		= sizeof(struct rtw89_pci_rpp_fmt_v1),
34*a16ca7d9SPing-Ke Shih 
35*a16ca7d9SPing-Ke Shih 	.init_cfg_reg		= R_BE_HAXI_INIT_CFG1,
36*a16ca7d9SPing-Ke Shih 	.txhci_en_bit		= B_BE_TXDMA_EN,
37*a16ca7d9SPing-Ke Shih 	.rxhci_en_bit		= B_BE_RXDMA_EN,
38*a16ca7d9SPing-Ke Shih 	.rxbd_mode_bit		= B_BE_RXQ_RXBD_MODE_MASK,
39*a16ca7d9SPing-Ke Shih 	.exp_ctrl_reg		= R_BE_HAXI_EXP_CTRL_V1,
40*a16ca7d9SPing-Ke Shih 	.max_tag_num_mask	= B_BE_MAX_TAG_NUM_MASK,
41*a16ca7d9SPing-Ke Shih 	.rxbd_rwptr_clr_reg	= R_BE_RXBD_RWPTR_CLR1_V1,
42*a16ca7d9SPing-Ke Shih 	.txbd_rwptr_clr2_reg	= R_BE_TXBD_RWPTR_CLR1,
43*a16ca7d9SPing-Ke Shih 	.dma_io_stop		= {R_BE_HAXI_INIT_CFG1, B_BE_STOP_AXI_MST},
44*a16ca7d9SPing-Ke Shih 	.dma_stop1		= {R_BE_HAXI_DMA_STOP1, B_BE_TX_STOP1_MASK_V1},
45*a16ca7d9SPing-Ke Shih 	.dma_stop2		= {0},
46*a16ca7d9SPing-Ke Shih 	.dma_busy1		= {R_BE_HAXI_DMA_BUSY1, DMA_BUSY1_CHECK_BE_V1},
47*a16ca7d9SPing-Ke Shih 	.dma_busy2_reg		= 0,
48*a16ca7d9SPing-Ke Shih 	.dma_busy3_reg		= R_BE_HAXI_DMA_BUSY1,
49*a16ca7d9SPing-Ke Shih 
50*a16ca7d9SPing-Ke Shih 	.rpwm_addr		= R_BE_PCIE_HRPWM,
51*a16ca7d9SPing-Ke Shih 	.cpwm_addr		= R_BE_PCIE_CRPWM,
52*a16ca7d9SPing-Ke Shih 	.mit_addr		= R_BE_PCIE_MIT_CH_EN,
53*a16ca7d9SPing-Ke Shih 	.wp_sel_addr		= R_BE_WP_ADDR_H_SEL0_3_V1,
54*a16ca7d9SPing-Ke Shih 	.tx_dma_ch_mask		= BIT(RTW89_TXCH_ACH1) | BIT(RTW89_TXCH_ACH3) |
55*a16ca7d9SPing-Ke Shih 				  BIT(RTW89_TXCH_ACH5) | BIT(RTW89_TXCH_ACH7) |
56*a16ca7d9SPing-Ke Shih 				  BIT(RTW89_TXCH_CH9) | BIT(RTW89_TXCH_CH11),
57*a16ca7d9SPing-Ke Shih 	.bd_idx_addr_low_power	= NULL,
58*a16ca7d9SPing-Ke Shih 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set_be_v1,
59*a16ca7d9SPing-Ke Shih 	.bd_ram_table		= NULL,
60*a16ca7d9SPing-Ke Shih 
61*a16ca7d9SPing-Ke Shih 	.ltr_set		= rtw89_pci_ltr_set_v2,
62*a16ca7d9SPing-Ke Shih 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info_v1,
63*a16ca7d9SPing-Ke Shih 	.parse_rpp		= rtw89_pci_parse_rpp_v1,
64*a16ca7d9SPing-Ke Shih 	.config_intr_mask	= rtw89_pci_config_intr_mask_v3,
65*a16ca7d9SPing-Ke Shih 	.enable_intr		= rtw89_pci_enable_intr_v3,
66*a16ca7d9SPing-Ke Shih 	.disable_intr		= rtw89_pci_disable_intr_v3,
67*a16ca7d9SPing-Ke Shih 	.recognize_intrs	= rtw89_pci_recognize_intrs_v3,
68*a16ca7d9SPing-Ke Shih 
69*a16ca7d9SPing-Ke Shih 	.ssid_quirks		= NULL,
70*a16ca7d9SPing-Ke Shih };
71*a16ca7d9SPing-Ke Shih 
72*a16ca7d9SPing-Ke Shih static const struct rtw89_driver_info rtw89_8922de_vs_info = {
73*a16ca7d9SPing-Ke Shih 	.chip = &rtw8922d_chip_info,
74*a16ca7d9SPing-Ke Shih 	.variant = &rtw8922de_vs_variant,
75*a16ca7d9SPing-Ke Shih 	.quirks = NULL,
76*a16ca7d9SPing-Ke Shih 	.bus = {
77*a16ca7d9SPing-Ke Shih 		.pci = &rtw8922d_pci_info,
78*a16ca7d9SPing-Ke Shih 	},
79*a16ca7d9SPing-Ke Shih };
80*a16ca7d9SPing-Ke Shih 
81*a16ca7d9SPing-Ke Shih static const struct rtw89_driver_info rtw89_8922de_info = {
82*a16ca7d9SPing-Ke Shih 	.chip = &rtw8922d_chip_info,
83*a16ca7d9SPing-Ke Shih 	.variant = NULL,
84*a16ca7d9SPing-Ke Shih 	.quirks = NULL,
85*a16ca7d9SPing-Ke Shih 	.bus = {
86*a16ca7d9SPing-Ke Shih 		.pci = &rtw8922d_pci_info,
87*a16ca7d9SPing-Ke Shih 	},
88*a16ca7d9SPing-Ke Shih };
89*a16ca7d9SPing-Ke Shih 
90*a16ca7d9SPing-Ke Shih static const struct pci_device_id rtw89_8922de_id_table[] = {
91*a16ca7d9SPing-Ke Shih 	{
92*a16ca7d9SPing-Ke Shih 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x892D),
93*a16ca7d9SPing-Ke Shih 		.driver_data = (kernel_ulong_t)&rtw89_8922de_vs_info,
94*a16ca7d9SPing-Ke Shih 	},
95*a16ca7d9SPing-Ke Shih 	{
96*a16ca7d9SPing-Ke Shih 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x882D),
97*a16ca7d9SPing-Ke Shih 		.driver_data = (kernel_ulong_t)&rtw89_8922de_vs_info,
98*a16ca7d9SPing-Ke Shih 	},
99*a16ca7d9SPing-Ke Shih 	{
100*a16ca7d9SPing-Ke Shih 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x895D),
101*a16ca7d9SPing-Ke Shih 		.driver_data = (kernel_ulong_t)&rtw89_8922de_info,
102*a16ca7d9SPing-Ke Shih 	},
103*a16ca7d9SPing-Ke Shih 	{},
104*a16ca7d9SPing-Ke Shih };
105*a16ca7d9SPing-Ke Shih MODULE_DEVICE_TABLE(pci, rtw89_8922de_id_table);
106*a16ca7d9SPing-Ke Shih 
107*a16ca7d9SPing-Ke Shih static struct pci_driver rtw89_8922de_driver = {
108*a16ca7d9SPing-Ke Shih 	.name		= "rtw89_8922de",
109*a16ca7d9SPing-Ke Shih 	.id_table	= rtw89_8922de_id_table,
110*a16ca7d9SPing-Ke Shih 	.probe		= rtw89_pci_probe,
111*a16ca7d9SPing-Ke Shih 	.remove		= rtw89_pci_remove,
112*a16ca7d9SPing-Ke Shih 	.driver.pm	= &rtw89_pm_ops_be,
113*a16ca7d9SPing-Ke Shih 	.err_handler    = &rtw89_pci_err_handler,
114*a16ca7d9SPing-Ke Shih };
115*a16ca7d9SPing-Ke Shih module_pci_driver(rtw89_8922de_driver);
116*a16ca7d9SPing-Ke Shih 
117*a16ca7d9SPing-Ke Shih MODULE_AUTHOR("Realtek Corporation");
118*a16ca7d9SPing-Ke Shih MODULE_DESCRIPTION("Realtek 802.11be wireless 8922DE/8922DE-VS driver");
119*a16ca7d9SPing-Ke Shih MODULE_LICENSE("Dual BSD/GPL");
120