162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
262306a36Sopenharmony_ci/* Copyright(c) 2022-2023  Realtek Corporation
362306a36Sopenharmony_ci */
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/module.h>
662306a36Sopenharmony_ci#include <linux/pci.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include "pci.h"
962306a36Sopenharmony_ci#include "reg.h"
1062306a36Sopenharmony_ci#include "rtw8851b.h"
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistatic const struct rtw89_pci_info rtw8851b_pci_info = {
1362306a36Sopenharmony_ci	.txbd_trunc_mode	= MAC_AX_BD_TRUNC,
1462306a36Sopenharmony_ci	.rxbd_trunc_mode	= MAC_AX_BD_TRUNC,
1562306a36Sopenharmony_ci	.rxbd_mode		= MAC_AX_RXBD_PKT,
1662306a36Sopenharmony_ci	.tag_mode		= MAC_AX_TAG_MULTI,
1762306a36Sopenharmony_ci	.tx_burst		= MAC_AX_TX_BURST_2048B,
1862306a36Sopenharmony_ci	.rx_burst		= MAC_AX_RX_BURST_128B,
1962306a36Sopenharmony_ci	.wd_dma_idle_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
2062306a36Sopenharmony_ci	.wd_dma_act_intvl	= MAC_AX_WD_DMA_INTVL_256NS,
2162306a36Sopenharmony_ci	.multi_tag_num		= MAC_AX_TAG_NUM_8,
2262306a36Sopenharmony_ci	.lbc_en			= MAC_AX_PCIE_ENABLE,
2362306a36Sopenharmony_ci	.lbc_tmr		= MAC_AX_LBC_TMR_2MS,
2462306a36Sopenharmony_ci	.autok_en		= MAC_AX_PCIE_DISABLE,
2562306a36Sopenharmony_ci	.io_rcy_en		= MAC_AX_PCIE_DISABLE,
2662306a36Sopenharmony_ci	.io_rcy_tmr		= MAC_AX_IO_RCY_ANA_TMR_6MS,
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci	.init_cfg_reg		= R_AX_PCIE_INIT_CFG1,
2962306a36Sopenharmony_ci	.txhci_en_bit		= B_AX_TXHCI_EN,
3062306a36Sopenharmony_ci	.rxhci_en_bit		= B_AX_RXHCI_EN,
3162306a36Sopenharmony_ci	.rxbd_mode_bit		= B_AX_RXBD_MODE,
3262306a36Sopenharmony_ci	.exp_ctrl_reg		= R_AX_PCIE_EXP_CTRL,
3362306a36Sopenharmony_ci	.max_tag_num_mask	= B_AX_MAX_TAG_NUM,
3462306a36Sopenharmony_ci	.rxbd_rwptr_clr_reg	= R_AX_RXBD_RWPTR_CLR,
3562306a36Sopenharmony_ci	.txbd_rwptr_clr2_reg	= 0,
3662306a36Sopenharmony_ci	.dma_stop1		= {R_AX_PCIE_DMA_STOP1, B_AX_TX_STOP1_MASK_V1},
3762306a36Sopenharmony_ci	.dma_stop2		= {0},
3862306a36Sopenharmony_ci	.dma_busy1		= {R_AX_PCIE_DMA_BUSY1, DMA_BUSY1_CHECK_V1},
3962306a36Sopenharmony_ci	.dma_busy2_reg		= 0,
4062306a36Sopenharmony_ci	.dma_busy3_reg		= R_AX_PCIE_DMA_BUSY1,
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci	.rpwm_addr		= R_AX_PCIE_HRPWM,
4362306a36Sopenharmony_ci	.cpwm_addr		= R_AX_CPWM,
4462306a36Sopenharmony_ci	.tx_dma_ch_mask		= BIT(RTW89_TXCH_ACH4) | BIT(RTW89_TXCH_ACH5) |
4562306a36Sopenharmony_ci				  BIT(RTW89_TXCH_ACH6) | BIT(RTW89_TXCH_ACH7) |
4662306a36Sopenharmony_ci				  BIT(RTW89_TXCH_CH10) | BIT(RTW89_TXCH_CH11),
4762306a36Sopenharmony_ci	.bd_idx_addr_low_power	= NULL,
4862306a36Sopenharmony_ci	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set,
4962306a36Sopenharmony_ci	.bd_ram_table		= &rtw89_bd_ram_table_single,
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci	.ltr_set		= rtw89_pci_ltr_set,
5262306a36Sopenharmony_ci	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info,
5362306a36Sopenharmony_ci	.config_intr_mask	= rtw89_pci_config_intr_mask,
5462306a36Sopenharmony_ci	.enable_intr		= rtw89_pci_enable_intr,
5562306a36Sopenharmony_ci	.disable_intr		= rtw89_pci_disable_intr,
5662306a36Sopenharmony_ci	.recognize_intrs	= rtw89_pci_recognize_intrs,
5762306a36Sopenharmony_ci};
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_cistatic const struct rtw89_driver_info rtw89_8851be_info = {
6062306a36Sopenharmony_ci	.chip = &rtw8851b_chip_info,
6162306a36Sopenharmony_ci	.bus = {
6262306a36Sopenharmony_ci		.pci = &rtw8851b_pci_info,
6362306a36Sopenharmony_ci	},
6462306a36Sopenharmony_ci};
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_cistatic const struct pci_device_id rtw89_8851be_id_table[] = {
6762306a36Sopenharmony_ci	{
6862306a36Sopenharmony_ci		PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xb851),
6962306a36Sopenharmony_ci		.driver_data = (kernel_ulong_t)&rtw89_8851be_info,
7062306a36Sopenharmony_ci	},
7162306a36Sopenharmony_ci	{},
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ciMODULE_DEVICE_TABLE(pci, rtw89_8851be_id_table);
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_cistatic struct pci_driver rtw89_8851be_driver = {
7662306a36Sopenharmony_ci	.name		= "rtw89_8851be",
7762306a36Sopenharmony_ci	.id_table	= rtw89_8851be_id_table,
7862306a36Sopenharmony_ci	.probe		= rtw89_pci_probe,
7962306a36Sopenharmony_ci	.remove		= rtw89_pci_remove,
8062306a36Sopenharmony_ci	.driver.pm	= &rtw89_pm_ops,
8162306a36Sopenharmony_ci};
8262306a36Sopenharmony_cimodule_pci_driver(rtw89_8851be_driver);
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciMODULE_AUTHOR("Realtek Corporation");
8562306a36Sopenharmony_ciMODULE_DESCRIPTION("Realtek 802.11ax wireless 8851BE driver");
8662306a36Sopenharmony_ciMODULE_LICENSE("Dual BSD/GPL");
87