xref: /openbmc/linux/drivers/net/wireless/realtek/rtw89/rtw8851be.c (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
1*99ff8da5SPing-Ke Shih // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2*99ff8da5SPing-Ke Shih /* Copyright(c) 2022-2023  Realtek Corporation
3*99ff8da5SPing-Ke Shih  */
4*99ff8da5SPing-Ke Shih 
5*99ff8da5SPing-Ke Shih #include <linux/module.h>
6*99ff8da5SPing-Ke Shih #include <linux/pci.h>
7*99ff8da5SPing-Ke Shih 
8*99ff8da5SPing-Ke Shih #include "pci.h"
9*99ff8da5SPing-Ke Shih #include "reg.h"
10*99ff8da5SPing-Ke Shih #include "rtw8851b.h"
11*99ff8da5SPing-Ke Shih 
12*99ff8da5SPing-Ke Shih static const struct rtw89_pci_info rtw8851b_pci_info = {
13*99ff8da5SPing-Ke Shih 	.txbd_trunc_mode	= MAC_AX_BD_TRUNC,
14*99ff8da5SPing-Ke Shih 	.rxbd_trunc_mode	= MAC_AX_BD_TRUNC,
15*99ff8da5SPing-Ke Shih 	.rxbd_mode		= MAC_AX_RXBD_PKT,
16*99ff8da5SPing-Ke Shih 	.tag_mode		= MAC_AX_TAG_MULTI,
17*99ff8da5SPing-Ke Shih 	.tx_burst		= MAC_AX_TX_BURST_2048B,
18*99ff8da5SPing-Ke Shih 	.rx_burst		= MAC_AX_RX_BURST_128B,
19*99ff8da5SPing-Ke Shih 	.wd_dma_idle_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
20*99ff8da5SPing-Ke Shih 	.wd_dma_act_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
21*99ff8da5SPing-Ke Shih 	.multi_tag_num		= MAC_AX_TAG_NUM_8,
22*99ff8da5SPing-Ke Shih 	.lbc_en			= MAC_AX_PCIE_ENABLE,
23*99ff8da5SPing-Ke Shih 	.lbc_tmr		= MAC_AX_LBC_TMR_2MS,
24*99ff8da5SPing-Ke Shih 	.autok_en		= MAC_AX_PCIE_DISABLE,
25*99ff8da5SPing-Ke Shih 	.io_rcy_en		= MAC_AX_PCIE_DISABLE,
26*99ff8da5SPing-Ke Shih 	.io_rcy_tmr		= MAC_AX_IO_RCY_ANA_TMR_6MS,
27*99ff8da5SPing-Ke Shih 
28*99ff8da5SPing-Ke Shih 	.init_cfg_reg		= R_AX_PCIE_INIT_CFG1,
29*99ff8da5SPing-Ke Shih 	.txhci_en_bit		= B_AX_TXHCI_EN,
30*99ff8da5SPing-Ke Shih 	.rxhci_en_bit		= B_AX_RXHCI_EN,
31*99ff8da5SPing-Ke Shih 	.rxbd_mode_bit		= B_AX_RXBD_MODE,
32*99ff8da5SPing-Ke Shih 	.exp_ctrl_reg		= R_AX_PCIE_EXP_CTRL,
33*99ff8da5SPing-Ke Shih 	.max_tag_num_mask	= B_AX_MAX_TAG_NUM,
34*99ff8da5SPing-Ke Shih 	.rxbd_rwptr_clr_reg	= R_AX_RXBD_RWPTR_CLR,
35*99ff8da5SPing-Ke Shih 	.txbd_rwptr_clr2_reg	= 0,
36*99ff8da5SPing-Ke Shih 	.dma_stop1		= {R_AX_PCIE_DMA_STOP1, B_AX_TX_STOP1_MASK_V1},
37*99ff8da5SPing-Ke Shih 	.dma_stop2		= {0},
38*99ff8da5SPing-Ke Shih 	.dma_busy1		= {R_AX_PCIE_DMA_BUSY1, DMA_BUSY1_CHECK_V1},
39*99ff8da5SPing-Ke Shih 	.dma_busy2_reg		= 0,
40*99ff8da5SPing-Ke Shih 	.dma_busy3_reg		= R_AX_PCIE_DMA_BUSY1,
41*99ff8da5SPing-Ke Shih 
42*99ff8da5SPing-Ke Shih 	.rpwm_addr		= R_AX_PCIE_HRPWM,
43*99ff8da5SPing-Ke Shih 	.cpwm_addr		= R_AX_CPWM,
44*99ff8da5SPing-Ke Shih 	.tx_dma_ch_mask		= BIT(RTW89_TXCH_ACH4) | BIT(RTW89_TXCH_ACH5) |
45*99ff8da5SPing-Ke Shih 				  BIT(RTW89_TXCH_ACH6) | BIT(RTW89_TXCH_ACH7) |
46*99ff8da5SPing-Ke Shih 				  BIT(RTW89_TXCH_CH10) | BIT(RTW89_TXCH_CH11),
47*99ff8da5SPing-Ke Shih 	.bd_idx_addr_low_power	= NULL,
48*99ff8da5SPing-Ke Shih 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set,
49*99ff8da5SPing-Ke Shih 	.bd_ram_table		= &rtw89_bd_ram_table_single,
50*99ff8da5SPing-Ke Shih 
51*99ff8da5SPing-Ke Shih 	.ltr_set		= rtw89_pci_ltr_set,
52*99ff8da5SPing-Ke Shih 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info,
53*99ff8da5SPing-Ke Shih 	.config_intr_mask	= rtw89_pci_config_intr_mask,
54*99ff8da5SPing-Ke Shih 	.enable_intr		= rtw89_pci_enable_intr,
55*99ff8da5SPing-Ke Shih 	.disable_intr		= rtw89_pci_disable_intr,
56*99ff8da5SPing-Ke Shih 	.recognize_intrs	= rtw89_pci_recognize_intrs,
57*99ff8da5SPing-Ke Shih };
58*99ff8da5SPing-Ke Shih 
59*99ff8da5SPing-Ke Shih static const struct rtw89_driver_info rtw89_8851be_info = {
60*99ff8da5SPing-Ke Shih 	.chip = &rtw8851b_chip_info,
61*99ff8da5SPing-Ke Shih 	.bus = {
62*99ff8da5SPing-Ke Shih 		.pci = &rtw8851b_pci_info,
63*99ff8da5SPing-Ke Shih 	},
64*99ff8da5SPing-Ke Shih };
65*99ff8da5SPing-Ke Shih 
66*99ff8da5SPing-Ke Shih static const struct pci_device_id rtw89_8851be_id_table[] = {
67*99ff8da5SPing-Ke Shih 	{
68*99ff8da5SPing-Ke Shih 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xb851),
69*99ff8da5SPing-Ke Shih 		.driver_data = (kernel_ulong_t)&rtw89_8851be_info,
70*99ff8da5SPing-Ke Shih 	},
71*99ff8da5SPing-Ke Shih 	{},
72*99ff8da5SPing-Ke Shih };
73*99ff8da5SPing-Ke Shih MODULE_DEVICE_TABLE(pci, rtw89_8851be_id_table);
74*99ff8da5SPing-Ke Shih 
75*99ff8da5SPing-Ke Shih static struct pci_driver rtw89_8851be_driver = {
76*99ff8da5SPing-Ke Shih 	.name		= "rtw89_8851be",
77*99ff8da5SPing-Ke Shih 	.id_table	= rtw89_8851be_id_table,
78*99ff8da5SPing-Ke Shih 	.probe		= rtw89_pci_probe,
79*99ff8da5SPing-Ke Shih 	.remove		= rtw89_pci_remove,
80*99ff8da5SPing-Ke Shih 	.driver.pm	= &rtw89_pm_ops,
81*99ff8da5SPing-Ke Shih };
82*99ff8da5SPing-Ke Shih module_pci_driver(rtw89_8851be_driver);
83*99ff8da5SPing-Ke Shih 
84*99ff8da5SPing-Ke Shih MODULE_AUTHOR("Realtek Corporation");
85*99ff8da5SPing-Ke Shih MODULE_DESCRIPTION("Realtek 802.11ax wireless 8851BE driver");
86*99ff8da5SPing-Ke Shih MODULE_LICENSE("Dual BSD/GPL");
87