xref: /freebsd/sys/contrib/dev/rtw89/rtw8852ae.c (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2020-2021  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 "rtw8852a.h"
11 
12 static const struct rtw89_pci_info rtw8852a_pci_info = {
13 	.txbd_trunc_mode	= MAC_AX_BD_TRUNC,
14 	.rxbd_trunc_mode	= MAC_AX_BD_TRUNC,
15 	.rxbd_mode		= MAC_AX_RXBD_PKT,
16 	.tag_mode		= MAC_AX_TAG_MULTI,
17 	.tx_burst		= MAC_AX_TX_BURST_2048B,
18 	.rx_burst		= MAC_AX_RX_BURST_128B,
19 	.wd_dma_idle_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
20 	.wd_dma_act_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
21 	.multi_tag_num		= MAC_AX_TAG_NUM_8,
22 	.lbc_en			= MAC_AX_PCIE_ENABLE,
23 	.lbc_tmr		= MAC_AX_LBC_TMR_2MS,
24 	.autok_en		= MAC_AX_PCIE_DISABLE,
25 	.io_rcy_en		= MAC_AX_PCIE_DISABLE,
26 	.io_rcy_tmr		= MAC_AX_IO_RCY_ANA_TMR_6MS,
27 
28 	.init_cfg_reg		= R_AX_PCIE_INIT_CFG1,
29 	.txhci_en_bit		= B_AX_TXHCI_EN,
30 	.rxhci_en_bit		= B_AX_RXHCI_EN,
31 	.rxbd_mode_bit		= B_AX_RXBD_MODE,
32 	.exp_ctrl_reg		= R_AX_PCIE_EXP_CTRL,
33 	.max_tag_num_mask	= B_AX_MAX_TAG_NUM,
34 	.rxbd_rwptr_clr_reg	= R_AX_RXBD_RWPTR_CLR,
35 	.txbd_rwptr_clr2_reg	= R_AX_TXBD_RWPTR_CLR2,
36 	.dma_stop1_reg		= R_AX_PCIE_DMA_STOP1,
37 	.dma_stop2_reg		= R_AX_PCIE_DMA_STOP2,
38 	.dma_busy1_reg		= R_AX_PCIE_DMA_BUSY1,
39 	.dma_busy2_reg		= R_AX_PCIE_DMA_BUSY2,
40 	.dma_busy3_reg		= R_AX_PCIE_DMA_BUSY1,
41 
42 	.rpwm_addr		= R_AX_PCIE_HRPWM,
43 	.cpwm_addr		= R_AX_CPWM,
44 	.bd_idx_addr_low_power	= NULL,
45 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set,
46 
47 	.ltr_set		= rtw89_pci_ltr_set,
48 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info,
49 	.config_intr_mask	= rtw89_pci_config_intr_mask,
50 	.enable_intr		= rtw89_pci_enable_intr,
51 	.disable_intr		= rtw89_pci_disable_intr,
52 	.recognize_intrs	= rtw89_pci_recognize_intrs,
53 };
54 
55 static const struct rtw89_driver_info rtw89_8852ae_info = {
56 	.chip = &rtw8852a_chip_info,
57 	.bus = {
58 		.pci = &rtw8852a_pci_info,
59 	},
60 };
61 
62 static const struct pci_device_id rtw89_8852ae_id_table[] = {
63 	{
64 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8852),
65 		.driver_data = (kernel_ulong_t)&rtw89_8852ae_info,
66 	},
67 	{
68 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xa85a),
69 		.driver_data = (kernel_ulong_t)&rtw89_8852ae_info,
70 	},
71 	{},
72 };
73 MODULE_DEVICE_TABLE(pci, rtw89_8852ae_id_table);
74 
75 static struct pci_driver rtw89_8852ae_driver = {
76 	.name		= "rtw89_8852ae",
77 	.id_table	= rtw89_8852ae_id_table,
78 	.probe		= rtw89_pci_probe,
79 	.remove		= rtw89_pci_remove,
80 	.driver.pm	= &rtw89_pm_ops,
81 #if defined(__FreeBSD__)
82 	.bsddriver.name	= KBUILD_MODNAME,
83 #endif
84 };
85 module_pci_driver(rtw89_8852ae_driver);
86 
87 MODULE_AUTHOR("Realtek Corporation");
88 MODULE_DESCRIPTION("Realtek 802.11ax wireless 8852AE driver");
89 MODULE_LICENSE("Dual BSD/GPL");
90