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