xref: /openbmc/linux/drivers/net/wireless/realtek/rtw89/rtw8852be.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
11bebcf08SPing-Ke Shih // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
21bebcf08SPing-Ke Shih /* Copyright(c) 2020-2022  Realtek Corporation
31bebcf08SPing-Ke Shih  */
41bebcf08SPing-Ke Shih 
51bebcf08SPing-Ke Shih #include <linux/module.h>
61bebcf08SPing-Ke Shih #include <linux/pci.h>
71bebcf08SPing-Ke Shih 
81bebcf08SPing-Ke Shih #include "pci.h"
91bebcf08SPing-Ke Shih #include "reg.h"
109695dc2eSPing-Ke Shih #include "rtw8852b.h"
111bebcf08SPing-Ke Shih 
121bebcf08SPing-Ke Shih static const struct rtw89_pci_info rtw8852b_pci_info = {
139695dc2eSPing-Ke Shih 	.txbd_trunc_mode	= MAC_AX_BD_TRUNC,
149695dc2eSPing-Ke Shih 	.rxbd_trunc_mode	= MAC_AX_BD_TRUNC,
159695dc2eSPing-Ke Shih 	.rxbd_mode		= MAC_AX_RXBD_PKT,
169695dc2eSPing-Ke Shih 	.tag_mode		= MAC_AX_TAG_MULTI,
179695dc2eSPing-Ke Shih 	.tx_burst		= MAC_AX_TX_BURST_2048B,
189695dc2eSPing-Ke Shih 	.rx_burst		= MAC_AX_RX_BURST_128B,
199695dc2eSPing-Ke Shih 	.wd_dma_idle_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
209695dc2eSPing-Ke Shih 	.wd_dma_act_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
219695dc2eSPing-Ke Shih 	.multi_tag_num		= MAC_AX_TAG_NUM_8,
229695dc2eSPing-Ke Shih 	.lbc_en			= MAC_AX_PCIE_ENABLE,
239695dc2eSPing-Ke Shih 	.lbc_tmr		= MAC_AX_LBC_TMR_2MS,
249695dc2eSPing-Ke Shih 	.autok_en		= MAC_AX_PCIE_DISABLE,
259695dc2eSPing-Ke Shih 	.io_rcy_en		= MAC_AX_PCIE_DISABLE,
269695dc2eSPing-Ke Shih 	.io_rcy_tmr		= MAC_AX_IO_RCY_ANA_TMR_6MS,
279695dc2eSPing-Ke Shih 
289695dc2eSPing-Ke Shih 	.init_cfg_reg		= R_AX_PCIE_INIT_CFG1,
299695dc2eSPing-Ke Shih 	.txhci_en_bit		= B_AX_TXHCI_EN,
309695dc2eSPing-Ke Shih 	.rxhci_en_bit		= B_AX_RXHCI_EN,
319695dc2eSPing-Ke Shih 	.rxbd_mode_bit		= B_AX_RXBD_MODE,
329695dc2eSPing-Ke Shih 	.exp_ctrl_reg		= R_AX_PCIE_EXP_CTRL,
339695dc2eSPing-Ke Shih 	.max_tag_num_mask	= B_AX_MAX_TAG_NUM,
349695dc2eSPing-Ke Shih 	.rxbd_rwptr_clr_reg	= R_AX_RXBD_RWPTR_CLR,
359695dc2eSPing-Ke Shih 	.txbd_rwptr_clr2_reg	= 0,
3661bdf7aaSPing-Ke Shih 	.dma_stop1		= {R_AX_PCIE_DMA_STOP1, B_AX_TX_STOP1_MASK_V1},
3761bdf7aaSPing-Ke Shih 	.dma_stop2		= {0},
3861bdf7aaSPing-Ke Shih 	.dma_busy1		= {R_AX_PCIE_DMA_BUSY1, DMA_BUSY1_CHECK_V1},
3961bdf7aaSPing-Ke Shih 	.dma_busy2_reg		= 0,
4061bdf7aaSPing-Ke Shih 	.dma_busy3_reg		= R_AX_PCIE_DMA_BUSY1,
4161bdf7aaSPing-Ke Shih 
429695dc2eSPing-Ke Shih 	.rpwm_addr		= R_AX_PCIE_HRPWM,
439695dc2eSPing-Ke Shih 	.cpwm_addr		= R_AX_CPWM,
441bebcf08SPing-Ke Shih 	.tx_dma_ch_mask		= BIT(RTW89_TXCH_ACH4) | BIT(RTW89_TXCH_ACH5) |
451bebcf08SPing-Ke Shih 				  BIT(RTW89_TXCH_ACH6) | BIT(RTW89_TXCH_ACH7) |
461bebcf08SPing-Ke Shih 				  BIT(RTW89_TXCH_CH10) | BIT(RTW89_TXCH_CH11),
479695dc2eSPing-Ke Shih 	.bd_idx_addr_low_power	= NULL,
489695dc2eSPing-Ke Shih 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set,
49*7f495de6SZong-Zhe Yang 	.bd_ram_table		= &rtw89_bd_ram_table_single,
509695dc2eSPing-Ke Shih 
519695dc2eSPing-Ke Shih 	.ltr_set		= rtw89_pci_ltr_set,
529695dc2eSPing-Ke Shih 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info,
539695dc2eSPing-Ke Shih 	.config_intr_mask	= rtw89_pci_config_intr_mask,
549695dc2eSPing-Ke Shih 	.enable_intr		= rtw89_pci_enable_intr,
559695dc2eSPing-Ke Shih 	.disable_intr		= rtw89_pci_disable_intr,
569695dc2eSPing-Ke Shih 	.recognize_intrs	= rtw89_pci_recognize_intrs,
571bebcf08SPing-Ke Shih };
581bebcf08SPing-Ke Shih 
599695dc2eSPing-Ke Shih static const struct rtw89_driver_info rtw89_8852be_info = {
609695dc2eSPing-Ke Shih 	.chip = &rtw8852b_chip_info,
619695dc2eSPing-Ke Shih 	.bus = {
629695dc2eSPing-Ke Shih 		.pci = &rtw8852b_pci_info,
639695dc2eSPing-Ke Shih 	},
649695dc2eSPing-Ke Shih };
659695dc2eSPing-Ke Shih 
669695dc2eSPing-Ke Shih static const struct pci_device_id rtw89_8852be_id_table[] = {
679695dc2eSPing-Ke Shih 	{
689695dc2eSPing-Ke Shih 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xb852),
699695dc2eSPing-Ke Shih 		.driver_data = (kernel_ulong_t)&rtw89_8852be_info,
709695dc2eSPing-Ke Shih 	},
719695dc2eSPing-Ke Shih 	{
729695dc2eSPing-Ke Shih 		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xb85b),
739695dc2eSPing-Ke Shih 		.driver_data = (kernel_ulong_t)&rtw89_8852be_info,
749695dc2eSPing-Ke Shih 	},
759695dc2eSPing-Ke Shih 	{},
769695dc2eSPing-Ke Shih };
779695dc2eSPing-Ke Shih MODULE_DEVICE_TABLE(pci, rtw89_8852be_id_table);
789695dc2eSPing-Ke Shih 
799695dc2eSPing-Ke Shih static struct pci_driver rtw89_8852be_driver = {
809695dc2eSPing-Ke Shih 	.name		= "rtw89_8852be",
819695dc2eSPing-Ke Shih 	.id_table	= rtw89_8852be_id_table,
829695dc2eSPing-Ke Shih 	.probe		= rtw89_pci_probe,
839695dc2eSPing-Ke Shih 	.remove		= rtw89_pci_remove,
849695dc2eSPing-Ke Shih 	.driver.pm	= &rtw89_pm_ops,
859695dc2eSPing-Ke Shih };
869695dc2eSPing-Ke Shih module_pci_driver(rtw89_8852be_driver);
879695dc2eSPing-Ke Shih 
881bebcf08SPing-Ke Shih MODULE_AUTHOR("Realtek Corporation");
891bebcf08SPing-Ke Shih MODULE_DESCRIPTION("Realtek 802.11ax wireless 8852BE driver");
901bebcf08SPing-Ke Shih MODULE_LICENSE("Dual BSD/GPL");
91