xref: /linux/drivers/net/wireless/realtek/rtw89/rtw8852ce.c (revision 073350da0aa2aead9df7927a1c1046ebf5cdd816)
10ac80e05SPing-Ke Shih // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
20ac80e05SPing-Ke Shih /* Copyright(c) 2020-2022  Realtek Corporation
30ac80e05SPing-Ke Shih  */
40ac80e05SPing-Ke Shih 
50ac80e05SPing-Ke Shih #include <linux/module.h>
60ac80e05SPing-Ke Shih #include <linux/pci.h>
70ac80e05SPing-Ke Shih 
80ac80e05SPing-Ke Shih #include "pci.h"
90ac80e05SPing-Ke Shih #include "reg.h"
100ac80e05SPing-Ke Shih #include "rtw8852c.h"
110ac80e05SPing-Ke Shih 
12*52edbb9fSPing-Ke Shih static const struct rtw89_pci_bd_idx_addr rtw8852c_bd_idx_addr_low_power = {
13*52edbb9fSPing-Ke Shih 	.tx_bd_addrs = {R_AX_DRV_FW_HSK_0, R_AX_DRV_FW_HSK_1, R_AX_DRV_FW_HSK_2,
14*52edbb9fSPing-Ke Shih 			R_AX_DRV_FW_HSK_3, 0, 0,
15*52edbb9fSPing-Ke Shih 			0, 0, R_AX_DRV_FW_HSK_4,
16*52edbb9fSPing-Ke Shih 			0, 0, 0,
17*52edbb9fSPing-Ke Shih 			R_AX_DRV_FW_HSK_5},
18*52edbb9fSPing-Ke Shih 	.rx_bd_addrs = {R_AX_DRV_FW_HSK_6, R_AX_DRV_FW_HSK_7},
19*52edbb9fSPing-Ke Shih };
20*52edbb9fSPing-Ke Shih 
214a9e48acSPing-Ke Shih static const struct rtw89_pci_info rtw8852c_pci_info = {
22b9467e94SPing-Ke Shih 	.txbd_trunc_mode	= MAC_AX_BD_TRUNC,
23b9467e94SPing-Ke Shih 	.rxbd_trunc_mode	= MAC_AX_BD_TRUNC,
24b9467e94SPing-Ke Shih 	.rxbd_mode		= MAC_AX_RXBD_PKT,
25b9467e94SPing-Ke Shih 	.tag_mode		= MAC_AX_TAG_MULTI,
26b9467e94SPing-Ke Shih 	.tx_burst		= MAC_AX_TX_BURST_V1_256B,
27b9467e94SPing-Ke Shih 	.rx_burst		= MAC_AX_RX_BURST_V1_128B,
28b9467e94SPing-Ke Shih 	.wd_dma_idle_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
29b9467e94SPing-Ke Shih 	.wd_dma_act_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
30b9467e94SPing-Ke Shih 	.multi_tag_num		= MAC_AX_TAG_NUM_8,
31b9467e94SPing-Ke Shih 	.lbc_en			= MAC_AX_PCIE_ENABLE,
32b9467e94SPing-Ke Shih 	.lbc_tmr		= MAC_AX_LBC_TMR_2MS,
33b9467e94SPing-Ke Shih 	.autok_en		= MAC_AX_PCIE_DISABLE,
34b9467e94SPing-Ke Shih 	.io_rcy_en		= MAC_AX_PCIE_ENABLE,
35b9467e94SPing-Ke Shih 	.io_rcy_tmr		= MAC_AX_IO_RCY_ANA_TMR_6MS,
36b9467e94SPing-Ke Shih 
37740c431cSPing-Ke Shih 	.init_cfg_reg		= R_AX_HAXI_INIT_CFG1,
38740c431cSPing-Ke Shih 	.txhci_en_bit		= B_AX_TXHCI_EN_V1,
39740c431cSPing-Ke Shih 	.rxhci_en_bit		= B_AX_RXHCI_EN_V1,
40740c431cSPing-Ke Shih 	.rxbd_mode_bit		= B_AX_RXBD_MODE_V1,
41740c431cSPing-Ke Shih 	.exp_ctrl_reg		= R_AX_HAXI_EXP_CTRL,
42740c431cSPing-Ke Shih 	.max_tag_num_mask	= B_AX_MAX_TAG_NUM_V1_MASK,
43740c431cSPing-Ke Shih 	.rxbd_rwptr_clr_reg	= R_AX_RXBD_RWPTR_CLR_V1,
44740c431cSPing-Ke Shih 	.txbd_rwptr_clr2_reg	= R_AX_TXBD_RWPTR_CLR2_V1,
45740c431cSPing-Ke Shih 	.dma_stop1_reg		= R_AX_HAXI_DMA_STOP1,
46740c431cSPing-Ke Shih 	.dma_stop2_reg		= R_AX_HAXI_DMA_STOP2,
471e3f2055SChia-Yuan Li 	.dma_busy1_reg		= R_AX_HAXI_DMA_BUSY1,
481e3f2055SChia-Yuan Li 	.dma_busy2_reg		= R_AX_HAXI_DMA_BUSY2,
491e3f2055SChia-Yuan Li 	.dma_busy3_reg		= R_AX_HAXI_DMA_BUSY3,
50740c431cSPing-Ke Shih 
51e1757e80SPing-Ke Shih 	.rpwm_addr		= R_AX_PCIE_HRPWM_V1,
52e1757e80SPing-Ke Shih 	.cpwm_addr		= R_AX_PCIE_CRPWM,
53*52edbb9fSPing-Ke Shih 	.bd_idx_addr_low_power	= &rtw8852c_bd_idx_addr_low_power,
5497d61bf9SPing-Ke Shih 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set_v1,
556d5b5d62SPing-Ke Shih 
560db862fbSPing-Ke Shih 	.ltr_set		= rtw89_pci_ltr_set_v1,
576d5b5d62SPing-Ke Shih 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info_v1,
58948e521cSPing-Ke Shih 	.config_intr_mask	= rtw89_pci_config_intr_mask_v1,
59948e521cSPing-Ke Shih 	.enable_intr		= rtw89_pci_enable_intr_v1,
60948e521cSPing-Ke Shih 	.disable_intr		= rtw89_pci_disable_intr_v1,
61948e521cSPing-Ke Shih 	.recognize_intrs	= rtw89_pci_recognize_intrs_v1,
624a9e48acSPing-Ke Shih };
634a9e48acSPing-Ke Shih 
640ac80e05SPing-Ke Shih static const struct rtw89_driver_info rtw89_8852ce_info = {
650ac80e05SPing-Ke Shih 	.chip = &rtw8852c_chip_info,
664a9e48acSPing-Ke Shih 	.bus = {
674a9e48acSPing-Ke Shih 		.pci = &rtw8852c_pci_info,
684a9e48acSPing-Ke Shih 	},
690ac80e05SPing-Ke Shih };
700ac80e05SPing-Ke Shih 
710ac80e05SPing-Ke Shih static const struct pci_device_id rtw89_8852ce_id_table[] = {
720ac80e05SPing-Ke Shih 	{
730ac80e05SPing-Ke Shih 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xc852),
740ac80e05SPing-Ke Shih 		.driver_data = (kernel_ulong_t)&rtw89_8852ce_info,
750ac80e05SPing-Ke Shih 	},
760ac80e05SPing-Ke Shih 	{},
770ac80e05SPing-Ke Shih };
780ac80e05SPing-Ke Shih MODULE_DEVICE_TABLE(pci, rtw89_8852ce_id_table);
790ac80e05SPing-Ke Shih 
800ac80e05SPing-Ke Shih static struct pci_driver rtw89_8852ce_driver = {
810ac80e05SPing-Ke Shih 	.name		= "rtw89_8852ce",
820ac80e05SPing-Ke Shih 	.id_table	= rtw89_8852ce_id_table,
830ac80e05SPing-Ke Shih 	.probe		= rtw89_pci_probe,
840ac80e05SPing-Ke Shih 	.remove		= rtw89_pci_remove,
850ac80e05SPing-Ke Shih 	.driver.pm	= &rtw89_pm_ops,
860ac80e05SPing-Ke Shih };
870ac80e05SPing-Ke Shih module_pci_driver(rtw89_8852ce_driver);
880ac80e05SPing-Ke Shih 
890ac80e05SPing-Ke Shih MODULE_AUTHOR("Realtek Corporation");
900ac80e05SPing-Ke Shih MODULE_DESCRIPTION("Realtek 802.11ax wireless 8852CE driver");
910ac80e05SPing-Ke Shih MODULE_LICENSE("Dual BSD/GPL");
92