162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 262306a36Sopenharmony_ci/* Copyright(c) 2019-2020 Realtek Corporation 362306a36Sopenharmony_ci */ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#ifndef __RTW89_MAC_H__ 662306a36Sopenharmony_ci#define __RTW89_MAC_H__ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include "core.h" 962306a36Sopenharmony_ci#include "reg.h" 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define MAC_MEM_DUMP_PAGE_SIZE 0x40000 1262306a36Sopenharmony_ci#define ADDR_CAM_ENT_SIZE 0x40 1362306a36Sopenharmony_ci#define BSSID_CAM_ENT_SIZE 0x08 1462306a36Sopenharmony_ci#define HFC_PAGE_UNIT 64 1562306a36Sopenharmony_ci#define RPWM_TRY_CNT 3 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cienum rtw89_mac_hwmod_sel { 1862306a36Sopenharmony_ci RTW89_DMAC_SEL = 0, 1962306a36Sopenharmony_ci RTW89_CMAC_SEL = 1, 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci RTW89_MAC_INVALID, 2262306a36Sopenharmony_ci}; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_cienum rtw89_mac_fwd_target { 2562306a36Sopenharmony_ci RTW89_FWD_DONT_CARE = 0, 2662306a36Sopenharmony_ci RTW89_FWD_TO_HOST = 1, 2762306a36Sopenharmony_ci RTW89_FWD_TO_WLAN_CPU = 2 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cienum rtw89_mac_wd_dma_intvl { 3162306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_0S, 3262306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_256NS, 3362306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_512NS, 3462306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_768NS, 3562306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_1US, 3662306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_1_5US, 3762306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_2US, 3862306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_4US, 3962306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_8US, 4062306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_16US, 4162306a36Sopenharmony_ci RTW89_MAC_WD_DMA_INTVL_DEF = 0xFE 4262306a36Sopenharmony_ci}; 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cienum rtw89_mac_multi_tag_num { 4562306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_1, 4662306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_2, 4762306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_3, 4862306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_4, 4962306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_5, 5062306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_6, 5162306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_7, 5262306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_8, 5362306a36Sopenharmony_ci RTW89_MAC_TAG_NUM_DEF = 0xFE 5462306a36Sopenharmony_ci}; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cienum rtw89_mac_lbc_tmr { 5762306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_8US = 0, 5862306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_16US, 5962306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_32US, 6062306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_64US, 6162306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_128US, 6262306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_256US, 6362306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_512US, 6462306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_1MS, 6562306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_2MS, 6662306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_4MS, 6762306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_8MS, 6862306a36Sopenharmony_ci RTW89_MAC_LBC_TMR_DEF = 0xFE 6962306a36Sopenharmony_ci}; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_cienum rtw89_mac_cpuio_op_cmd_type { 7262306a36Sopenharmony_ci CPUIO_OP_CMD_GET_1ST_PID = 0, 7362306a36Sopenharmony_ci CPUIO_OP_CMD_GET_NEXT_PID = 1, 7462306a36Sopenharmony_ci CPUIO_OP_CMD_ENQ_TO_TAIL = 4, 7562306a36Sopenharmony_ci CPUIO_OP_CMD_ENQ_TO_HEAD = 5, 7662306a36Sopenharmony_ci CPUIO_OP_CMD_DEQ = 8, 7762306a36Sopenharmony_ci CPUIO_OP_CMD_DEQ_ENQ_ALL = 9, 7862306a36Sopenharmony_ci CPUIO_OP_CMD_DEQ_ENQ_TO_TAIL = 12 7962306a36Sopenharmony_ci}; 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_cienum rtw89_mac_wde_dle_port_id { 8262306a36Sopenharmony_ci WDE_DLE_PORT_ID_DISPATCH = 0, 8362306a36Sopenharmony_ci WDE_DLE_PORT_ID_PKTIN = 1, 8462306a36Sopenharmony_ci WDE_DLE_PORT_ID_CMAC0 = 3, 8562306a36Sopenharmony_ci WDE_DLE_PORT_ID_CMAC1 = 4, 8662306a36Sopenharmony_ci WDE_DLE_PORT_ID_CPU_IO = 6, 8762306a36Sopenharmony_ci WDE_DLE_PORT_ID_WDRLS = 7, 8862306a36Sopenharmony_ci WDE_DLE_PORT_ID_END = 8 8962306a36Sopenharmony_ci}; 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_cienum rtw89_mac_wde_dle_queid_wdrls { 9262306a36Sopenharmony_ci WDE_DLE_QUEID_TXOK = 0, 9362306a36Sopenharmony_ci WDE_DLE_QUEID_DROP_RETRY_LIMIT = 1, 9462306a36Sopenharmony_ci WDE_DLE_QUEID_DROP_LIFETIME_TO = 2, 9562306a36Sopenharmony_ci WDE_DLE_QUEID_DROP_MACID_DROP = 3, 9662306a36Sopenharmony_ci WDE_DLE_QUEID_NO_REPORT = 4 9762306a36Sopenharmony_ci}; 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_cienum rtw89_mac_ple_dle_port_id { 10062306a36Sopenharmony_ci PLE_DLE_PORT_ID_DISPATCH = 0, 10162306a36Sopenharmony_ci PLE_DLE_PORT_ID_MPDU = 1, 10262306a36Sopenharmony_ci PLE_DLE_PORT_ID_SEC = 2, 10362306a36Sopenharmony_ci PLE_DLE_PORT_ID_CMAC0 = 3, 10462306a36Sopenharmony_ci PLE_DLE_PORT_ID_CMAC1 = 4, 10562306a36Sopenharmony_ci PLE_DLE_PORT_ID_WDRLS = 5, 10662306a36Sopenharmony_ci PLE_DLE_PORT_ID_CPU_IO = 6, 10762306a36Sopenharmony_ci PLE_DLE_PORT_ID_PLRLS = 7, 10862306a36Sopenharmony_ci PLE_DLE_PORT_ID_END = 8 10962306a36Sopenharmony_ci}; 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_cienum rtw89_mac_ple_dle_queid_plrls { 11262306a36Sopenharmony_ci PLE_DLE_QUEID_NO_REPORT = 0x0 11362306a36Sopenharmony_ci}; 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_cienum rtw89_machdr_frame_type { 11662306a36Sopenharmony_ci RTW89_MGNT = 0, 11762306a36Sopenharmony_ci RTW89_CTRL = 1, 11862306a36Sopenharmony_ci RTW89_DATA = 2, 11962306a36Sopenharmony_ci}; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_cienum rtw89_mac_dle_dfi_type { 12262306a36Sopenharmony_ci DLE_DFI_TYPE_FREEPG = 0, 12362306a36Sopenharmony_ci DLE_DFI_TYPE_QUOTA = 1, 12462306a36Sopenharmony_ci DLE_DFI_TYPE_PAGELLT = 2, 12562306a36Sopenharmony_ci DLE_DFI_TYPE_PKTINFO = 3, 12662306a36Sopenharmony_ci DLE_DFI_TYPE_PREPKTLLT = 4, 12762306a36Sopenharmony_ci DLE_DFI_TYPE_NXTPKTLLT = 5, 12862306a36Sopenharmony_ci DLE_DFI_TYPE_QLNKTBL = 6, 12962306a36Sopenharmony_ci DLE_DFI_TYPE_QEMPTY = 7, 13062306a36Sopenharmony_ci}; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_cienum rtw89_mac_dle_wde_quota_id { 13362306a36Sopenharmony_ci WDE_QTAID_HOST_IF = 0, 13462306a36Sopenharmony_ci WDE_QTAID_WLAN_CPU = 1, 13562306a36Sopenharmony_ci WDE_QTAID_DATA_CPU = 2, 13662306a36Sopenharmony_ci WDE_QTAID_PKTIN = 3, 13762306a36Sopenharmony_ci WDE_QTAID_CPUIO = 4, 13862306a36Sopenharmony_ci}; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_cienum rtw89_mac_dle_ple_quota_id { 14162306a36Sopenharmony_ci PLE_QTAID_B0_TXPL = 0, 14262306a36Sopenharmony_ci PLE_QTAID_B1_TXPL = 1, 14362306a36Sopenharmony_ci PLE_QTAID_C2H = 2, 14462306a36Sopenharmony_ci PLE_QTAID_H2C = 3, 14562306a36Sopenharmony_ci PLE_QTAID_WLAN_CPU = 4, 14662306a36Sopenharmony_ci PLE_QTAID_MPDU = 5, 14762306a36Sopenharmony_ci PLE_QTAID_CMAC0_RX = 6, 14862306a36Sopenharmony_ci PLE_QTAID_CMAC1_RX = 7, 14962306a36Sopenharmony_ci PLE_QTAID_CMAC1_BBRPT = 8, 15062306a36Sopenharmony_ci PLE_QTAID_WDRLS = 9, 15162306a36Sopenharmony_ci PLE_QTAID_CPUIO = 10, 15262306a36Sopenharmony_ci}; 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_cienum rtw89_mac_dle_ctrl_type { 15562306a36Sopenharmony_ci DLE_CTRL_TYPE_WDE = 0, 15662306a36Sopenharmony_ci DLE_CTRL_TYPE_PLE = 1, 15762306a36Sopenharmony_ci DLE_CTRL_TYPE_NUM = 2, 15862306a36Sopenharmony_ci}; 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_cienum rtw89_mac_ax_l0_to_l1_event { 16162306a36Sopenharmony_ci MAC_AX_L0_TO_L1_CHIF_IDLE = 0, 16262306a36Sopenharmony_ci MAC_AX_L0_TO_L1_CMAC_DMA_IDLE = 1, 16362306a36Sopenharmony_ci MAC_AX_L0_TO_L1_RLS_PKID = 2, 16462306a36Sopenharmony_ci MAC_AX_L0_TO_L1_PTCL_IDLE = 3, 16562306a36Sopenharmony_ci MAC_AX_L0_TO_L1_RX_QTA_LOST = 4, 16662306a36Sopenharmony_ci MAC_AX_L0_TO_L1_DLE_STAT_HANG = 5, 16762306a36Sopenharmony_ci MAC_AX_L0_TO_L1_PCIE_STUCK = 6, 16862306a36Sopenharmony_ci MAC_AX_L0_TO_L1_EVENT_MAX = 15, 16962306a36Sopenharmony_ci}; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#define RTW89_PORT_OFFSET_TU_TO_32US(shift_tu) ((shift_tu) * 1024 / 32) 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_cienum rtw89_mac_dbg_port_sel { 17462306a36Sopenharmony_ci /* CMAC 0 related */ 17562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PTCL_C0 = 0, 17662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_SCH_C0, 17762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TMAC_C0, 17862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_RMAC_C0, 17962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_RMACST_C0, 18062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_RMAC_PLCP_C0, 18162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TRXPTCL_C0, 18262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TX_INFOL_C0, 18362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TX_INFOH_C0, 18462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TXTF_INFOL_C0, 18562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TXTF_INFOH_C0, 18662306a36Sopenharmony_ci /* CMAC 1 related */ 18762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PTCL_C1, 18862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_SCH_C1, 18962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TMAC_C1, 19062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_RMAC_C1, 19162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_RMACST_C1, 19262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_RMAC_PLCP_C1, 19362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TRXPTCL_C1, 19462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TX_INFOL_C1, 19562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TX_INFOH_C1, 19662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TXTF_INFOL_C1, 19762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_TXTF_INFOH_C1, 19862306a36Sopenharmony_ci /* DLE related */ 19962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_BUFMGN_FREEPG, 20062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_BUFMGN_QUOTA, 20162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_BUFMGN_PAGELLT, 20262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_BUFMGN_PKTINFO, 20362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_QUEMGN_PREPKT, 20462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_QUEMGN_NXTPKT, 20562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_QUEMGN_QLNKTBL, 20662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_WDE_QUEMGN_QEMPTY, 20762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_BUFMGN_FREEPG, 20862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_BUFMGN_QUOTA, 20962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_BUFMGN_PAGELLT, 21062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_BUFMGN_PKTINFO, 21162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_QUEMGN_PREPKT, 21262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_QUEMGN_NXTPKT, 21362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_QUEMGN_QLNKTBL, 21462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PLE_QUEMGN_QEMPTY, 21562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PKTINFO, 21662306a36Sopenharmony_ci /* DISPATCHER related */ 21762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX0, 21862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX1, 21962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX2, 22062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX3, 22162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX4, 22262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX5, 22362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX6, 22462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX7, 22562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX8, 22662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TX9, 22762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TXA, 22862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TXB, 22962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TXC, 23062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TXD, 23162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TXE, 23262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_TXF, 23362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX0, 23462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX1, 23562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX3, 23662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX4, 23762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX5, 23862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX6, 23962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX7, 24062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX8, 24162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TX9, 24262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TXA, 24362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TXB, 24462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_TXC, 24562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_RX0, 24662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_RX1, 24762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_RX2, 24862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_RX3, 24962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_RX4, 25062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_HDT_RX5, 25162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_RX_P0, 25262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_RX_P0_0, 25362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_RX_P0_1, 25462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_RX_P0_2, 25562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_CDT_RX_P1, 25662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_STF_CTRL, 25762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_ADDR_CTRL, 25862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_WDE_INTF, 25962306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_PLE_INTF, 26062306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_DSPT_FLOW_CTRL, 26162306a36Sopenharmony_ci /* PCIE related */ 26262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PCIE_TXDMA, 26362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PCIE_RXDMA, 26462306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PCIE_CVT, 26562306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PCIE_CXPL, 26662306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PCIE_IO, 26762306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PCIE_MISC, 26862306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_PCIE_MISC2, 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci /* keep last */ 27162306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_LAST, 27262306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_MAX = RTW89_DBG_PORT_SEL_LAST, 27362306a36Sopenharmony_ci RTW89_DBG_PORT_SEL_INVALID = RTW89_DBG_PORT_SEL_LAST, 27462306a36Sopenharmony_ci}; 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci/* SRAM mem dump */ 27762306a36Sopenharmony_ci#define R_AX_INDIR_ACCESS_ENTRY 0x40000 27862306a36Sopenharmony_ci#define R_BE_INDIR_ACCESS_ENTRY 0x80000 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci#define AXIDMA_BASE_ADDR 0x18006000 28162306a36Sopenharmony_ci#define STA_SCHED_BASE_ADDR 0x18808000 28262306a36Sopenharmony_ci#define RXPLD_FLTR_CAM_BASE_ADDR 0x18813000 28362306a36Sopenharmony_ci#define SECURITY_CAM_BASE_ADDR 0x18814000 28462306a36Sopenharmony_ci#define WOW_CAM_BASE_ADDR 0x18815000 28562306a36Sopenharmony_ci#define CMAC_TBL_BASE_ADDR 0x18840000 28662306a36Sopenharmony_ci#define ADDR_CAM_BASE_ADDR 0x18850000 28762306a36Sopenharmony_ci#define BSSID_CAM_BASE_ADDR 0x18853000 28862306a36Sopenharmony_ci#define BA_CAM_BASE_ADDR 0x18854000 28962306a36Sopenharmony_ci#define BCN_IE_CAM0_BASE_ADDR 0x18855000 29062306a36Sopenharmony_ci#define SHARED_BUF_BASE_ADDR 0x18700000 29162306a36Sopenharmony_ci#define DMAC_TBL_BASE_ADDR 0x18800000 29262306a36Sopenharmony_ci#define SHCUT_MACHDR_BASE_ADDR 0x18800800 29362306a36Sopenharmony_ci#define BCN_IE_CAM1_BASE_ADDR 0x188A0000 29462306a36Sopenharmony_ci#define TXD_FIFO_0_BASE_ADDR 0x18856200 29562306a36Sopenharmony_ci#define TXD_FIFO_1_BASE_ADDR 0x188A1080 29662306a36Sopenharmony_ci#define TXD_FIFO_0_BASE_ADDR_V1 0x18856400 /* for 8852C */ 29762306a36Sopenharmony_ci#define TXD_FIFO_1_BASE_ADDR_V1 0x188A1080 /* for 8852C */ 29862306a36Sopenharmony_ci#define TXDATA_FIFO_0_BASE_ADDR 0x18856000 29962306a36Sopenharmony_ci#define TXDATA_FIFO_1_BASE_ADDR 0x188A1000 30062306a36Sopenharmony_ci#define CPU_LOCAL_BASE_ADDR 0x18003000 30162306a36Sopenharmony_ci 30262306a36Sopenharmony_ci#define WD_PAGE_BASE_ADDR_BE 0x0 30362306a36Sopenharmony_ci#define CPU_LOCAL_BASE_ADDR_BE 0x18003000 30462306a36Sopenharmony_ci#define AXIDMA_BASE_ADDR_BE 0x18006000 30562306a36Sopenharmony_ci#define SHARED_BUF_BASE_ADDR_BE 0x18700000 30662306a36Sopenharmony_ci#define DMAC_TBL_BASE_ADDR_BE 0x18800000 30762306a36Sopenharmony_ci#define SHCUT_MACHDR_BASE_ADDR_BE 0x18800800 30862306a36Sopenharmony_ci#define STA_SCHED_BASE_ADDR_BE 0x18818000 30962306a36Sopenharmony_ci#define NAT25_CAM_BASE_ADDR_BE 0x18820000 31062306a36Sopenharmony_ci#define RXPLD_FLTR_CAM_BASE_ADDR_BE 0x18823000 31162306a36Sopenharmony_ci#define SEC_CAM_BASE_ADDR_BE 0x18824000 31262306a36Sopenharmony_ci#define WOW_CAM_BASE_ADDR_BE 0x18828000 31362306a36Sopenharmony_ci#define MLD_TBL_BASE_ADDR_BE 0x18829000 31462306a36Sopenharmony_ci#define RX_CLSF_CAM_BASE_ADDR_BE 0x1882A000 31562306a36Sopenharmony_ci#define CMAC_TBL_BASE_ADDR_BE 0x18840000 31662306a36Sopenharmony_ci#define ADDR_CAM_BASE_ADDR_BE 0x18850000 31762306a36Sopenharmony_ci#define BSSID_CAM_BASE_ADDR_BE 0x18858000 31862306a36Sopenharmony_ci#define BA_CAM_BASE_ADDR_BE 0x18859000 31962306a36Sopenharmony_ci#define BCN_IE_CAM0_BASE_ADDR_BE 0x18860000 32062306a36Sopenharmony_ci#define TXDATA_FIFO_0_BASE_ADDR_BE 0x18861000 32162306a36Sopenharmony_ci#define TXD_FIFO_0_BASE_ADDR_BE 0x18862000 32262306a36Sopenharmony_ci#define BCN_IE_CAM1_BASE_ADDR_BE 0x18880000 32362306a36Sopenharmony_ci#define TXDATA_FIFO_1_BASE_ADDR_BE 0x18881000 32462306a36Sopenharmony_ci#define TXD_FIFO_1_BASE_ADDR_BE 0x18881800 32562306a36Sopenharmony_ci#define DCPU_LOCAL_BASE_ADDR_BE 0x19C02000 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci#define CCTL_INFO_SIZE 32 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_cienum rtw89_mac_mem_sel { 33062306a36Sopenharmony_ci RTW89_MAC_MEM_AXIDMA, 33162306a36Sopenharmony_ci RTW89_MAC_MEM_SHARED_BUF, 33262306a36Sopenharmony_ci RTW89_MAC_MEM_DMAC_TBL, 33362306a36Sopenharmony_ci RTW89_MAC_MEM_SHCUT_MACHDR, 33462306a36Sopenharmony_ci RTW89_MAC_MEM_STA_SCHED, 33562306a36Sopenharmony_ci RTW89_MAC_MEM_RXPLD_FLTR_CAM, 33662306a36Sopenharmony_ci RTW89_MAC_MEM_SECURITY_CAM, 33762306a36Sopenharmony_ci RTW89_MAC_MEM_WOW_CAM, 33862306a36Sopenharmony_ci RTW89_MAC_MEM_CMAC_TBL, 33962306a36Sopenharmony_ci RTW89_MAC_MEM_ADDR_CAM, 34062306a36Sopenharmony_ci RTW89_MAC_MEM_BA_CAM, 34162306a36Sopenharmony_ci RTW89_MAC_MEM_BCN_IE_CAM0, 34262306a36Sopenharmony_ci RTW89_MAC_MEM_BCN_IE_CAM1, 34362306a36Sopenharmony_ci RTW89_MAC_MEM_TXD_FIFO_0, 34462306a36Sopenharmony_ci RTW89_MAC_MEM_TXD_FIFO_1, 34562306a36Sopenharmony_ci RTW89_MAC_MEM_TXDATA_FIFO_0, 34662306a36Sopenharmony_ci RTW89_MAC_MEM_TXDATA_FIFO_1, 34762306a36Sopenharmony_ci RTW89_MAC_MEM_CPU_LOCAL, 34862306a36Sopenharmony_ci RTW89_MAC_MEM_BSSID_CAM, 34962306a36Sopenharmony_ci RTW89_MAC_MEM_TXD_FIFO_0_V1, 35062306a36Sopenharmony_ci RTW89_MAC_MEM_TXD_FIFO_1_V1, 35162306a36Sopenharmony_ci RTW89_MAC_MEM_WD_PAGE, 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci /* keep last */ 35462306a36Sopenharmony_ci RTW89_MAC_MEM_NUM, 35562306a36Sopenharmony_ci}; 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_cienum rtw89_rpwm_req_pwr_state { 35862306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_ACTIVE = 0, 35962306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_BAND0_RFON = 1, 36062306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_BAND1_RFON = 2, 36162306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_BAND0_RFOFF = 3, 36262306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_BAND1_RFOFF = 4, 36362306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_CLK_GATED = 5, 36462306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_PWR_GATED = 6, 36562306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_HIOE_PWR_GATED = 7, 36662306a36Sopenharmony_ci RTW89_MAC_RPWM_REQ_PWR_STATE_MAX, 36762306a36Sopenharmony_ci}; 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_cistruct rtw89_pwr_cfg { 37062306a36Sopenharmony_ci u16 addr; 37162306a36Sopenharmony_ci u8 cv_msk; 37262306a36Sopenharmony_ci u8 intf_msk; 37362306a36Sopenharmony_ci u8 base:4; 37462306a36Sopenharmony_ci u8 cmd:4; 37562306a36Sopenharmony_ci u8 msk; 37662306a36Sopenharmony_ci u8 val; 37762306a36Sopenharmony_ci}; 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_cienum rtw89_mac_c2h_ofld_func { 38062306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_EFUSE_DUMP, 38162306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_READ_RSP, 38262306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_PKT_OFLD_RSP, 38362306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_BCN_RESEND, 38462306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_MACID_PAUSE, 38562306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_TSF32_TOGL_RPT = 0x6, 38662306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_SCANOFLD_RSP = 0x9, 38762306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_BCNFLTR_RPT = 0xd, 38862306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_OFLD_MAX, 38962306a36Sopenharmony_ci}; 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_cienum rtw89_mac_c2h_info_func { 39262306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_REC_ACK, 39362306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_DONE_ACK, 39462306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_C2H_LOG, 39562306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_BCN_CNT, 39662306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_INFO_MAX, 39762306a36Sopenharmony_ci}; 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_cienum rtw89_mac_c2h_mcc_func { 40062306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_MCC_RCV_ACK = 0, 40162306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_MCC_REQ_ACK = 1, 40262306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_MCC_TSF_RPT = 2, 40362306a36Sopenharmony_ci RTW89_MAC_C2H_FUNC_MCC_STATUS_RPT = 3, 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci NUM_OF_RTW89_MAC_C2H_FUNC_MCC, 40662306a36Sopenharmony_ci}; 40762306a36Sopenharmony_ci 40862306a36Sopenharmony_cienum rtw89_mac_c2h_class { 40962306a36Sopenharmony_ci RTW89_MAC_C2H_CLASS_INFO, 41062306a36Sopenharmony_ci RTW89_MAC_C2H_CLASS_OFLD, 41162306a36Sopenharmony_ci RTW89_MAC_C2H_CLASS_TWT, 41262306a36Sopenharmony_ci RTW89_MAC_C2H_CLASS_WOW, 41362306a36Sopenharmony_ci RTW89_MAC_C2H_CLASS_MCC, 41462306a36Sopenharmony_ci RTW89_MAC_C2H_CLASS_FWDBG, 41562306a36Sopenharmony_ci RTW89_MAC_C2H_CLASS_MAX, 41662306a36Sopenharmony_ci}; 41762306a36Sopenharmony_ci 41862306a36Sopenharmony_cienum rtw89_mac_mcc_status { 41962306a36Sopenharmony_ci RTW89_MAC_MCC_ADD_ROLE_OK = 0, 42062306a36Sopenharmony_ci RTW89_MAC_MCC_START_GROUP_OK = 1, 42162306a36Sopenharmony_ci RTW89_MAC_MCC_STOP_GROUP_OK = 2, 42262306a36Sopenharmony_ci RTW89_MAC_MCC_DEL_GROUP_OK = 3, 42362306a36Sopenharmony_ci RTW89_MAC_MCC_RESET_GROUP_OK = 4, 42462306a36Sopenharmony_ci RTW89_MAC_MCC_SWITCH_CH_OK = 5, 42562306a36Sopenharmony_ci RTW89_MAC_MCC_TXNULL0_OK = 6, 42662306a36Sopenharmony_ci RTW89_MAC_MCC_TXNULL1_OK = 7, 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci RTW89_MAC_MCC_SWITCH_EARLY = 10, 42962306a36Sopenharmony_ci RTW89_MAC_MCC_TBTT = 11, 43062306a36Sopenharmony_ci RTW89_MAC_MCC_DURATION_START = 12, 43162306a36Sopenharmony_ci RTW89_MAC_MCC_DURATION_END = 13, 43262306a36Sopenharmony_ci 43362306a36Sopenharmony_ci RTW89_MAC_MCC_ADD_ROLE_FAIL = 20, 43462306a36Sopenharmony_ci RTW89_MAC_MCC_START_GROUP_FAIL = 21, 43562306a36Sopenharmony_ci RTW89_MAC_MCC_STOP_GROUP_FAIL = 22, 43662306a36Sopenharmony_ci RTW89_MAC_MCC_DEL_GROUP_FAIL = 23, 43762306a36Sopenharmony_ci RTW89_MAC_MCC_RESET_GROUP_FAIL = 24, 43862306a36Sopenharmony_ci RTW89_MAC_MCC_SWITCH_CH_FAIL = 25, 43962306a36Sopenharmony_ci RTW89_MAC_MCC_TXNULL0_FAIL = 26, 44062306a36Sopenharmony_ci RTW89_MAC_MCC_TXNULL1_FAIL = 27, 44162306a36Sopenharmony_ci}; 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_cistruct rtw89_mac_ax_coex { 44462306a36Sopenharmony_ci#define RTW89_MAC_AX_COEX_RTK_MODE 0 44562306a36Sopenharmony_ci#define RTW89_MAC_AX_COEX_CSR_MODE 1 44662306a36Sopenharmony_ci u8 pta_mode; 44762306a36Sopenharmony_ci#define RTW89_MAC_AX_COEX_INNER 0 44862306a36Sopenharmony_ci#define RTW89_MAC_AX_COEX_OUTPUT 1 44962306a36Sopenharmony_ci#define RTW89_MAC_AX_COEX_INPUT 2 45062306a36Sopenharmony_ci u8 direction; 45162306a36Sopenharmony_ci}; 45262306a36Sopenharmony_ci 45362306a36Sopenharmony_cistruct rtw89_mac_ax_plt { 45462306a36Sopenharmony_ci#define RTW89_MAC_AX_PLT_LTE_RX BIT(0) 45562306a36Sopenharmony_ci#define RTW89_MAC_AX_PLT_GNT_BT_TX BIT(1) 45662306a36Sopenharmony_ci#define RTW89_MAC_AX_PLT_GNT_BT_RX BIT(2) 45762306a36Sopenharmony_ci#define RTW89_MAC_AX_PLT_GNT_WL BIT(3) 45862306a36Sopenharmony_ci u8 band; 45962306a36Sopenharmony_ci u8 tx; 46062306a36Sopenharmony_ci u8 rx; 46162306a36Sopenharmony_ci}; 46262306a36Sopenharmony_ci 46362306a36Sopenharmony_cienum rtw89_mac_bf_rrsc_rate { 46462306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_6M = 0, 46562306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_9M = 1, 46662306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_12M, 46762306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_18M, 46862306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_24M, 46962306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_36M, 47062306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_48M, 47162306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_54M, 47262306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC0, 47362306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC1, 47462306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC2, 47562306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC3, 47662306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC4, 47762306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC5, 47862306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC6, 47962306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HT_MSC7, 48062306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC0, 48162306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC1, 48262306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC2, 48362306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC3, 48462306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC4, 48562306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC5, 48662306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC6, 48762306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_VHT_MSC7, 48862306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC0, 48962306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC1, 49062306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC2, 49162306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC3, 49262306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC4, 49362306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC5, 49462306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC6, 49562306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_HE_MSC7 = 31, 49662306a36Sopenharmony_ci RTW89_MAC_BF_RRSC_MAX = 32 49762306a36Sopenharmony_ci}; 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_ci#define RTW89_R32_EA 0xEAEAEAEA 50062306a36Sopenharmony_ci#define RTW89_R32_DEAD 0xDEADBEEF 50162306a36Sopenharmony_ci#define MAC_REG_POOL_COUNT 10 50262306a36Sopenharmony_ci#define ACCESS_CMAC(_addr) \ 50362306a36Sopenharmony_ci ({typeof(_addr) __addr = (_addr); \ 50462306a36Sopenharmony_ci __addr >= R_AX_CMAC_REG_START && __addr <= R_AX_CMAC_REG_END; }) 50562306a36Sopenharmony_ci#define RTW89_MAC_AX_BAND_REG_OFFSET 0x2000 50662306a36Sopenharmony_ci#define RTW89_MAC_BE_BAND_REG_OFFSET 0x4000 50762306a36Sopenharmony_ci 50862306a36Sopenharmony_ci#define PTCL_IDLE_POLL_CNT 10000 50962306a36Sopenharmony_ci#define SW_CVR_DUR_US 8 51062306a36Sopenharmony_ci#define SW_CVR_CNT 8 51162306a36Sopenharmony_ci 51262306a36Sopenharmony_ci#define DLE_BOUND_UNIT (8 * 1024) 51362306a36Sopenharmony_ci#define DLE_WAIT_CNT 2000 51462306a36Sopenharmony_ci#define TRXCFG_WAIT_CNT 2000 51562306a36Sopenharmony_ci 51662306a36Sopenharmony_ci#define RTW89_WDE_PG_64 64 51762306a36Sopenharmony_ci#define RTW89_WDE_PG_128 128 51862306a36Sopenharmony_ci#define RTW89_WDE_PG_256 256 51962306a36Sopenharmony_ci 52062306a36Sopenharmony_ci#define S_AX_WDE_PAGE_SEL_64 0 52162306a36Sopenharmony_ci#define S_AX_WDE_PAGE_SEL_128 1 52262306a36Sopenharmony_ci#define S_AX_WDE_PAGE_SEL_256 2 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci#define RTW89_PLE_PG_64 64 52562306a36Sopenharmony_ci#define RTW89_PLE_PG_128 128 52662306a36Sopenharmony_ci#define RTW89_PLE_PG_256 256 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_ci#define S_AX_PLE_PAGE_SEL_64 0 52962306a36Sopenharmony_ci#define S_AX_PLE_PAGE_SEL_128 1 53062306a36Sopenharmony_ci#define S_AX_PLE_PAGE_SEL_256 2 53162306a36Sopenharmony_ci 53262306a36Sopenharmony_ci#define B_CMAC0_MGQ_NORMAL BIT(2) 53362306a36Sopenharmony_ci#define B_CMAC0_MGQ_NO_PWRSAV BIT(3) 53462306a36Sopenharmony_ci#define B_CMAC0_CPUMGQ BIT(4) 53562306a36Sopenharmony_ci#define B_CMAC1_MGQ_NORMAL BIT(10) 53662306a36Sopenharmony_ci#define B_CMAC1_MGQ_NO_PWRSAV BIT(11) 53762306a36Sopenharmony_ci#define B_CMAC1_CPUMGQ BIT(12) 53862306a36Sopenharmony_ci 53962306a36Sopenharmony_ci#define QEMP_ACQ_GRP_MACID_NUM 8 54062306a36Sopenharmony_ci#define QEMP_ACQ_GRP_QSEL_SH 4 54162306a36Sopenharmony_ci#define QEMP_ACQ_GRP_QSEL_MASK 0xF 54262306a36Sopenharmony_ci 54362306a36Sopenharmony_ci#define SDIO_LOCAL_BASE_ADDR 0x80000000 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_ci#define PWR_CMD_WRITE 0 54662306a36Sopenharmony_ci#define PWR_CMD_POLL 1 54762306a36Sopenharmony_ci#define PWR_CMD_DELAY 2 54862306a36Sopenharmony_ci#define PWR_CMD_END 3 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_ci#define PWR_INTF_MSK_SDIO BIT(0) 55162306a36Sopenharmony_ci#define PWR_INTF_MSK_USB BIT(1) 55262306a36Sopenharmony_ci#define PWR_INTF_MSK_PCIE BIT(2) 55362306a36Sopenharmony_ci#define PWR_INTF_MSK_ALL 0x7 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_ci#define PWR_BASE_MAC 0 55662306a36Sopenharmony_ci#define PWR_BASE_USB 1 55762306a36Sopenharmony_ci#define PWR_BASE_PCIE 2 55862306a36Sopenharmony_ci#define PWR_BASE_SDIO 3 55962306a36Sopenharmony_ci 56062306a36Sopenharmony_ci#define PWR_CV_MSK_A BIT(0) 56162306a36Sopenharmony_ci#define PWR_CV_MSK_B BIT(1) 56262306a36Sopenharmony_ci#define PWR_CV_MSK_C BIT(2) 56362306a36Sopenharmony_ci#define PWR_CV_MSK_D BIT(3) 56462306a36Sopenharmony_ci#define PWR_CV_MSK_E BIT(4) 56562306a36Sopenharmony_ci#define PWR_CV_MSK_F BIT(5) 56662306a36Sopenharmony_ci#define PWR_CV_MSK_G BIT(6) 56762306a36Sopenharmony_ci#define PWR_CV_MSK_TEST BIT(7) 56862306a36Sopenharmony_ci#define PWR_CV_MSK_ALL 0xFF 56962306a36Sopenharmony_ci 57062306a36Sopenharmony_ci#define PWR_DELAY_US 0 57162306a36Sopenharmony_ci#define PWR_DELAY_MS 1 57262306a36Sopenharmony_ci 57362306a36Sopenharmony_ci/* STA scheduler */ 57462306a36Sopenharmony_ci#define SS_MACID_SH 8 57562306a36Sopenharmony_ci#define SS_TX_LEN_MSK 0x1FFFFF 57662306a36Sopenharmony_ci#define SS_CTRL1_R_TX_LEN 5 57762306a36Sopenharmony_ci#define SS_CTRL1_R_NEXT_LINK 20 57862306a36Sopenharmony_ci#define SS_LINK_SIZE 256 57962306a36Sopenharmony_ci 58062306a36Sopenharmony_ci/* MAC debug port */ 58162306a36Sopenharmony_ci#define TMAC_DBG_SEL_C0 0xA5 58262306a36Sopenharmony_ci#define RMAC_DBG_SEL_C0 0xA6 58362306a36Sopenharmony_ci#define TRXPTCL_DBG_SEL_C0 0xA7 58462306a36Sopenharmony_ci#define TMAC_DBG_SEL_C1 0xB5 58562306a36Sopenharmony_ci#define RMAC_DBG_SEL_C1 0xB6 58662306a36Sopenharmony_ci#define TRXPTCL_DBG_SEL_C1 0xB7 58762306a36Sopenharmony_ci#define FW_PROG_CNTR_DBG_SEL 0xF2 58862306a36Sopenharmony_ci#define PCIE_TXDMA_DBG_SEL 0x30 58962306a36Sopenharmony_ci#define PCIE_RXDMA_DBG_SEL 0x31 59062306a36Sopenharmony_ci#define PCIE_CVT_DBG_SEL 0x32 59162306a36Sopenharmony_ci#define PCIE_CXPL_DBG_SEL 0x33 59262306a36Sopenharmony_ci#define PCIE_IO_DBG_SEL 0x37 59362306a36Sopenharmony_ci#define PCIE_MISC_DBG_SEL 0x38 59462306a36Sopenharmony_ci#define PCIE_MISC2_DBG_SEL 0x00 59562306a36Sopenharmony_ci#define MAC_DBG_SEL 1 59662306a36Sopenharmony_ci#define RMAC_CMAC_DBG_SEL 1 59762306a36Sopenharmony_ci 59862306a36Sopenharmony_ci/* TRXPTCL dbg port sel */ 59962306a36Sopenharmony_ci#define TRXPTRL_DBG_SEL_TMAC 0 60062306a36Sopenharmony_ci#define TRXPTRL_DBG_SEL_RMAC 1 60162306a36Sopenharmony_ci 60262306a36Sopenharmony_cistruct rtw89_cpuio_ctrl { 60362306a36Sopenharmony_ci u16 pkt_num; 60462306a36Sopenharmony_ci u16 start_pktid; 60562306a36Sopenharmony_ci u16 end_pktid; 60662306a36Sopenharmony_ci u8 cmd_type; 60762306a36Sopenharmony_ci u8 macid; 60862306a36Sopenharmony_ci u8 src_pid; 60962306a36Sopenharmony_ci u8 src_qid; 61062306a36Sopenharmony_ci u8 dst_pid; 61162306a36Sopenharmony_ci u8 dst_qid; 61262306a36Sopenharmony_ci u16 pktid; 61362306a36Sopenharmony_ci}; 61462306a36Sopenharmony_ci 61562306a36Sopenharmony_cistruct rtw89_mac_dbg_port_info { 61662306a36Sopenharmony_ci u32 sel_addr; 61762306a36Sopenharmony_ci u8 sel_byte; 61862306a36Sopenharmony_ci u32 sel_msk; 61962306a36Sopenharmony_ci u32 srt; 62062306a36Sopenharmony_ci u32 end; 62162306a36Sopenharmony_ci u32 rd_addr; 62262306a36Sopenharmony_ci u8 rd_byte; 62362306a36Sopenharmony_ci u32 rd_msk; 62462306a36Sopenharmony_ci}; 62562306a36Sopenharmony_ci 62662306a36Sopenharmony_ci#define QLNKTBL_ADDR_INFO_SEL BIT(0) 62762306a36Sopenharmony_ci#define QLNKTBL_ADDR_INFO_SEL_0 0 62862306a36Sopenharmony_ci#define QLNKTBL_ADDR_INFO_SEL_1 1 62962306a36Sopenharmony_ci#define QLNKTBL_ADDR_TBL_IDX_MASK GENMASK(10, 1) 63062306a36Sopenharmony_ci#define QLNKTBL_DATA_SEL1_PKT_CNT_MASK GENMASK(11, 0) 63162306a36Sopenharmony_ci 63262306a36Sopenharmony_cistruct rtw89_mac_dle_dfi_ctrl { 63362306a36Sopenharmony_ci enum rtw89_mac_dle_ctrl_type type; 63462306a36Sopenharmony_ci u32 target; 63562306a36Sopenharmony_ci u32 addr; 63662306a36Sopenharmony_ci u32 out_data; 63762306a36Sopenharmony_ci}; 63862306a36Sopenharmony_ci 63962306a36Sopenharmony_cistruct rtw89_mac_dle_dfi_quota { 64062306a36Sopenharmony_ci enum rtw89_mac_dle_ctrl_type dle_type; 64162306a36Sopenharmony_ci u32 qtaid; 64262306a36Sopenharmony_ci u16 rsv_pgnum; 64362306a36Sopenharmony_ci u16 use_pgnum; 64462306a36Sopenharmony_ci}; 64562306a36Sopenharmony_ci 64662306a36Sopenharmony_cistruct rtw89_mac_dle_dfi_qempty { 64762306a36Sopenharmony_ci enum rtw89_mac_dle_ctrl_type dle_type; 64862306a36Sopenharmony_ci u32 grpsel; 64962306a36Sopenharmony_ci u32 qempty; 65062306a36Sopenharmony_ci}; 65162306a36Sopenharmony_ci 65262306a36Sopenharmony_cienum rtw89_mac_error_scenario { 65362306a36Sopenharmony_ci RTW89_RXI300_ERROR = 1, 65462306a36Sopenharmony_ci RTW89_WCPU_CPU_EXCEPTION = 2, 65562306a36Sopenharmony_ci RTW89_WCPU_ASSERTION = 3, 65662306a36Sopenharmony_ci}; 65762306a36Sopenharmony_ci 65862306a36Sopenharmony_ci#define RTW89_ERROR_SCENARIO(__err) ((__err) >> 28) 65962306a36Sopenharmony_ci 66062306a36Sopenharmony_ci/* Define DBG and recovery enum */ 66162306a36Sopenharmony_cienum mac_ax_err_info { 66262306a36Sopenharmony_ci /* Get error info */ 66362306a36Sopenharmony_ci 66462306a36Sopenharmony_ci /* L0 */ 66562306a36Sopenharmony_ci MAC_AX_ERR_L0_ERR_CMAC0 = 0x0001, 66662306a36Sopenharmony_ci MAC_AX_ERR_L0_ERR_CMAC1 = 0x0002, 66762306a36Sopenharmony_ci MAC_AX_ERR_L0_RESET_DONE = 0x0003, 66862306a36Sopenharmony_ci MAC_AX_ERR_L0_PROMOTE_TO_L1 = 0x0010, 66962306a36Sopenharmony_ci 67062306a36Sopenharmony_ci /* L1 */ 67162306a36Sopenharmony_ci MAC_AX_ERR_L1_PREERR_DMAC = 0x999, 67262306a36Sopenharmony_ci MAC_AX_ERR_L1_ERR_DMAC = 0x1000, 67362306a36Sopenharmony_ci MAC_AX_ERR_L1_RESET_DISABLE_DMAC_DONE = 0x1001, 67462306a36Sopenharmony_ci MAC_AX_ERR_L1_RESET_RECOVERY_DONE = 0x1002, 67562306a36Sopenharmony_ci MAC_AX_ERR_L1_PROMOTE_TO_L2 = 0x1010, 67662306a36Sopenharmony_ci MAC_AX_ERR_L1_RCVY_STOP_DONE = 0x1011, 67762306a36Sopenharmony_ci 67862306a36Sopenharmony_ci /* L2 */ 67962306a36Sopenharmony_ci /* address hole (master) */ 68062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_DMA = 0x2000, 68162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_HCI = 0x2010, 68262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_RLX4081 = 0x2020, 68362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_IDDMA = 0x2030, 68462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_HIOE = 0x2040, 68562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_IPSEC = 0x2050, 68662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_RX4281 = 0x2060, 68762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AH_OTHERS = 0x2070, 68862306a36Sopenharmony_ci 68962306a36Sopenharmony_ci /* AHB bridge timeout (master) */ 69062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_DMA = 0x2100, 69162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_HCI = 0x2110, 69262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_RLX4081 = 0x2120, 69362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_IDDMA = 0x2130, 69462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_HIOE = 0x2140, 69562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_IPSEC = 0x2150, 69662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_RX4281 = 0x2160, 69762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_AHB_TO_OTHERS = 0x2170, 69862306a36Sopenharmony_ci 69962306a36Sopenharmony_ci /* APB_SA bridge timeout (master + slave) */ 70062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_WVA = 0x2200, 70162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_UART = 0x2201, 70262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_CPULOCAL = 0x2202, 70362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_AXIDMA = 0x2203, 70462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_HIOE = 0x2204, 70562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_IDDMA = 0x2205, 70662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_IPSEC = 0x2206, 70762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_WON = 0x2207, 70862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_WDMAC = 0x2208, 70962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_WCMAC = 0x2209, 71062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_DMA_OTHERS = 0x220A, 71162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_WVA = 0x2210, 71262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_UART = 0x2211, 71362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_CPULOCAL = 0x2212, 71462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_AXIDMA = 0x2213, 71562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_HIOE = 0x2214, 71662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_IDDMA = 0x2215, 71762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_IPSEC = 0x2216, 71862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_WDMAC = 0x2218, 71962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_WCMAC = 0x2219, 72062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_OTHERS = 0x221A, 72162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_WVA = 0x2220, 72262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_UART = 0x2221, 72362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_CPULOCAL = 0x2222, 72462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_AXIDMA = 0x2223, 72562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_HIOE = 0x2224, 72662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_IDDMA = 0x2225, 72762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_IPSEC = 0x2226, 72862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_WON = 0x2227, 72962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_WDMAC = 0x2228, 73062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_WCMAC = 0x2229, 73162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RLX4081_OTHERS = 0x222A, 73262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_WVA = 0x2230, 73362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_UART = 0x2231, 73462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_CPULOCAL = 0x2232, 73562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_AXIDMA = 0x2233, 73662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_HIOE = 0x2234, 73762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_IDDMA = 0x2235, 73862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_IPSEC = 0x2236, 73962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_WON = 0x2237, 74062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_WDMAC = 0x2238, 74162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_WCMAC = 0x2239, 74262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IDDMA_OTHERS = 0x223A, 74362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_WVA = 0x2240, 74462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_UART = 0x2241, 74562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_CPULOCAL = 0x2242, 74662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_AXIDMA = 0x2243, 74762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_HIOE = 0x2244, 74862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_IDDMA = 0x2245, 74962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_IPSEC = 0x2246, 75062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_WON = 0x2247, 75162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_WDMAC = 0x2248, 75262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_WCMAC = 0x2249, 75362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_HIOE_OTHERS = 0x224A, 75462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_WVA = 0x2250, 75562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_UART = 0x2251, 75662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_CPULOCAL = 0x2252, 75762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_AXIDMA = 0x2253, 75862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_HIOE = 0x2254, 75962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_IDDMA = 0x2255, 76062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_IPSEC = 0x2256, 76162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_WON = 0x2257, 76262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_WDMAC = 0x2258, 76362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_WCMAC = 0x2259, 76462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_IPSEC_OTHERS = 0x225A, 76562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_WVA = 0x2260, 76662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_UART = 0x2261, 76762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_CPULOCAL = 0x2262, 76862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_AXIDMA = 0x2263, 76962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_HIOE = 0x2264, 77062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_IDDMA = 0x2265, 77162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_IPSEC = 0x2266, 77262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_WON = 0x2267, 77362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_WDMAC = 0x2268, 77462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_WCMAC = 0x2269, 77562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_RX4281_OTHERS = 0x226A, 77662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_WVA = 0x2270, 77762306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_UART = 0x2271, 77862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_CPULOCAL = 0x2272, 77962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_AXIDMA = 0x2273, 78062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_HIOE = 0x2274, 78162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_IDDMA = 0x2275, 78262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_IPSEC = 0x2276, 78362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_WON = 0x2277, 78462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_WDMAC = 0x2278, 78562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_WCMAC = 0x2279, 78662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_SA_TO_OTHERS_OTHERS = 0x227A, 78762306a36Sopenharmony_ci 78862306a36Sopenharmony_ci /* APB_BBRF bridge timeout (master) */ 78962306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_DMA = 0x2300, 79062306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_HCI = 0x2310, 79162306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_RLX4081 = 0x2320, 79262306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_IDDMA = 0x2330, 79362306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_HIOE = 0x2340, 79462306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_IPSEC = 0x2350, 79562306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_RX4281 = 0x2360, 79662306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_APB_BBRF_TO_OTHERS = 0x2370, 79762306a36Sopenharmony_ci MAC_AX_ERR_L2_RESET_DONE = 0x2400, 79862306a36Sopenharmony_ci MAC_AX_ERR_L2_ERR_WDT_TIMEOUT_INT = 0x2599, 79962306a36Sopenharmony_ci MAC_AX_ERR_CPU_EXCEPTION = 0x3000, 80062306a36Sopenharmony_ci MAC_AX_ERR_ASSERTION = 0x4000, 80162306a36Sopenharmony_ci MAC_AX_ERR_RXI300 = 0x5000, 80262306a36Sopenharmony_ci MAC_AX_GET_ERR_MAX, 80362306a36Sopenharmony_ci MAC_AX_DUMP_SHAREBUFF_INDICATOR = 0x80000000, 80462306a36Sopenharmony_ci 80562306a36Sopenharmony_ci /* set error info */ 80662306a36Sopenharmony_ci MAC_AX_ERR_L1_DISABLE_EN = 0x0001, 80762306a36Sopenharmony_ci MAC_AX_ERR_L1_RCVY_EN = 0x0002, 80862306a36Sopenharmony_ci MAC_AX_ERR_L1_RCVY_STOP_REQ = 0x0003, 80962306a36Sopenharmony_ci MAC_AX_ERR_L1_RCVY_START_REQ = 0x0004, 81062306a36Sopenharmony_ci MAC_AX_ERR_L1_RESET_START_DMAC = 0x000A, 81162306a36Sopenharmony_ci MAC_AX_ERR_L0_CFG_NOTIFY = 0x0010, 81262306a36Sopenharmony_ci MAC_AX_ERR_L0_CFG_DIS_NOTIFY = 0x0011, 81362306a36Sopenharmony_ci MAC_AX_ERR_L0_CFG_HANDSHAKE = 0x0012, 81462306a36Sopenharmony_ci MAC_AX_ERR_L0_RCVY_EN = 0x0013, 81562306a36Sopenharmony_ci MAC_AX_SET_ERR_MAX, 81662306a36Sopenharmony_ci}; 81762306a36Sopenharmony_ci 81862306a36Sopenharmony_cistruct rtw89_mac_size_set { 81962306a36Sopenharmony_ci const struct rtw89_hfc_prec_cfg hfc_preccfg_pcie; 82062306a36Sopenharmony_ci const struct rtw89_dle_size wde_size0; 82162306a36Sopenharmony_ci const struct rtw89_dle_size wde_size4; 82262306a36Sopenharmony_ci const struct rtw89_dle_size wde_size6; 82362306a36Sopenharmony_ci const struct rtw89_dle_size wde_size7; 82462306a36Sopenharmony_ci const struct rtw89_dle_size wde_size9; 82562306a36Sopenharmony_ci const struct rtw89_dle_size wde_size18; 82662306a36Sopenharmony_ci const struct rtw89_dle_size wde_size19; 82762306a36Sopenharmony_ci const struct rtw89_dle_size ple_size0; 82862306a36Sopenharmony_ci const struct rtw89_dle_size ple_size4; 82962306a36Sopenharmony_ci const struct rtw89_dle_size ple_size6; 83062306a36Sopenharmony_ci const struct rtw89_dle_size ple_size8; 83162306a36Sopenharmony_ci const struct rtw89_dle_size ple_size18; 83262306a36Sopenharmony_ci const struct rtw89_dle_size ple_size19; 83362306a36Sopenharmony_ci const struct rtw89_wde_quota wde_qt0; 83462306a36Sopenharmony_ci const struct rtw89_wde_quota wde_qt4; 83562306a36Sopenharmony_ci const struct rtw89_wde_quota wde_qt6; 83662306a36Sopenharmony_ci const struct rtw89_wde_quota wde_qt7; 83762306a36Sopenharmony_ci const struct rtw89_wde_quota wde_qt17; 83862306a36Sopenharmony_ci const struct rtw89_wde_quota wde_qt18; 83962306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt4; 84062306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt5; 84162306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt13; 84262306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt18; 84362306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt44; 84462306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt45; 84562306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt46; 84662306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt47; 84762306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt58; 84862306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt_52a_wow; 84962306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt_52b_wow; 85062306a36Sopenharmony_ci const struct rtw89_ple_quota ple_qt_51b_wow; 85162306a36Sopenharmony_ci}; 85262306a36Sopenharmony_ci 85362306a36Sopenharmony_ciextern const struct rtw89_mac_size_set rtw89_mac_size; 85462306a36Sopenharmony_ci 85562306a36Sopenharmony_cistruct rtw89_mac_gen_def { 85662306a36Sopenharmony_ci u32 band1_offset; 85762306a36Sopenharmony_ci u32 filter_model_addr; 85862306a36Sopenharmony_ci u32 indir_access_addr; 85962306a36Sopenharmony_ci const u32 *mem_base_addrs; 86062306a36Sopenharmony_ci u32 rx_fltr; 86162306a36Sopenharmony_ci}; 86262306a36Sopenharmony_ci 86362306a36Sopenharmony_ciextern const struct rtw89_mac_gen_def rtw89_mac_gen_ax; 86462306a36Sopenharmony_ciextern const struct rtw89_mac_gen_def rtw89_mac_gen_be; 86562306a36Sopenharmony_ci 86662306a36Sopenharmony_cistatic inline 86762306a36Sopenharmony_ciu32 rtw89_mac_reg_by_idx(struct rtw89_dev *rtwdev, u32 reg_base, u8 band) 86862306a36Sopenharmony_ci{ 86962306a36Sopenharmony_ci const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; 87062306a36Sopenharmony_ci 87162306a36Sopenharmony_ci return band == 0 ? reg_base : (reg_base + mac->band1_offset); 87262306a36Sopenharmony_ci} 87362306a36Sopenharmony_ci 87462306a36Sopenharmony_cistatic inline 87562306a36Sopenharmony_ciu32 rtw89_mac_reg_by_port(struct rtw89_dev *rtwdev, u32 base, u8 port, u8 mac_idx) 87662306a36Sopenharmony_ci{ 87762306a36Sopenharmony_ci return rtw89_mac_reg_by_idx(rtwdev, base + port * 0x40, mac_idx); 87862306a36Sopenharmony_ci} 87962306a36Sopenharmony_ci 88062306a36Sopenharmony_cistatic inline u32 88162306a36Sopenharmony_cirtw89_read32_port(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, u32 base) 88262306a36Sopenharmony_ci{ 88362306a36Sopenharmony_ci u32 reg; 88462306a36Sopenharmony_ci 88562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 88662306a36Sopenharmony_ci return rtw89_read32(rtwdev, reg); 88762306a36Sopenharmony_ci} 88862306a36Sopenharmony_ci 88962306a36Sopenharmony_cistatic inline u32 89062306a36Sopenharmony_cirtw89_read32_port_mask(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 89162306a36Sopenharmony_ci u32 base, u32 mask) 89262306a36Sopenharmony_ci{ 89362306a36Sopenharmony_ci u32 reg; 89462306a36Sopenharmony_ci 89562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 89662306a36Sopenharmony_ci return rtw89_read32_mask(rtwdev, reg, mask); 89762306a36Sopenharmony_ci} 89862306a36Sopenharmony_ci 89962306a36Sopenharmony_cistatic inline void 90062306a36Sopenharmony_cirtw89_write32_port(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, u32 base, 90162306a36Sopenharmony_ci u32 data) 90262306a36Sopenharmony_ci{ 90362306a36Sopenharmony_ci u32 reg; 90462306a36Sopenharmony_ci 90562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 90662306a36Sopenharmony_ci rtw89_write32(rtwdev, reg, data); 90762306a36Sopenharmony_ci} 90862306a36Sopenharmony_ci 90962306a36Sopenharmony_cistatic inline void 91062306a36Sopenharmony_cirtw89_write32_port_mask(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 91162306a36Sopenharmony_ci u32 base, u32 mask, u32 data) 91262306a36Sopenharmony_ci{ 91362306a36Sopenharmony_ci u32 reg; 91462306a36Sopenharmony_ci 91562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 91662306a36Sopenharmony_ci rtw89_write32_mask(rtwdev, reg, mask, data); 91762306a36Sopenharmony_ci} 91862306a36Sopenharmony_ci 91962306a36Sopenharmony_cistatic inline void 92062306a36Sopenharmony_cirtw89_write16_port_mask(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 92162306a36Sopenharmony_ci u32 base, u32 mask, u16 data) 92262306a36Sopenharmony_ci{ 92362306a36Sopenharmony_ci u32 reg; 92462306a36Sopenharmony_ci 92562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 92662306a36Sopenharmony_ci rtw89_write16_mask(rtwdev, reg, mask, data); 92762306a36Sopenharmony_ci} 92862306a36Sopenharmony_ci 92962306a36Sopenharmony_cistatic inline void 93062306a36Sopenharmony_cirtw89_write32_port_clr(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 93162306a36Sopenharmony_ci u32 base, u32 bit) 93262306a36Sopenharmony_ci{ 93362306a36Sopenharmony_ci u32 reg; 93462306a36Sopenharmony_ci 93562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 93662306a36Sopenharmony_ci rtw89_write32_clr(rtwdev, reg, bit); 93762306a36Sopenharmony_ci} 93862306a36Sopenharmony_ci 93962306a36Sopenharmony_cistatic inline void 94062306a36Sopenharmony_cirtw89_write16_port_clr(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 94162306a36Sopenharmony_ci u32 base, u16 bit) 94262306a36Sopenharmony_ci{ 94362306a36Sopenharmony_ci u32 reg; 94462306a36Sopenharmony_ci 94562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 94662306a36Sopenharmony_ci rtw89_write16_clr(rtwdev, reg, bit); 94762306a36Sopenharmony_ci} 94862306a36Sopenharmony_ci 94962306a36Sopenharmony_cistatic inline void 95062306a36Sopenharmony_cirtw89_write32_port_set(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 95162306a36Sopenharmony_ci u32 base, u32 bit) 95262306a36Sopenharmony_ci{ 95362306a36Sopenharmony_ci u32 reg; 95462306a36Sopenharmony_ci 95562306a36Sopenharmony_ci reg = rtw89_mac_reg_by_port(rtwdev, base, rtwvif->port, rtwvif->mac_idx); 95662306a36Sopenharmony_ci rtw89_write32_set(rtwdev, reg, bit); 95762306a36Sopenharmony_ci} 95862306a36Sopenharmony_ci 95962306a36Sopenharmony_civoid rtw89_mac_pwr_off(struct rtw89_dev *rtwdev); 96062306a36Sopenharmony_ciint rtw89_mac_partial_init(struct rtw89_dev *rtwdev); 96162306a36Sopenharmony_ciint rtw89_mac_init(struct rtw89_dev *rtwdev); 96262306a36Sopenharmony_ciint rtw89_mac_check_mac_en(struct rtw89_dev *rtwdev, u8 band, 96362306a36Sopenharmony_ci enum rtw89_mac_hwmod_sel sel); 96462306a36Sopenharmony_ciint rtw89_mac_write_lte(struct rtw89_dev *rtwdev, const u32 offset, u32 val); 96562306a36Sopenharmony_ciint rtw89_mac_read_lte(struct rtw89_dev *rtwdev, const u32 offset, u32 *val); 96662306a36Sopenharmony_ciint rtw89_mac_add_vif(struct rtw89_dev *rtwdev, struct rtw89_vif *vif); 96762306a36Sopenharmony_ciint rtw89_mac_port_update(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif); 96862306a36Sopenharmony_civoid rtw89_mac_port_tsf_sync(struct rtw89_dev *rtwdev, 96962306a36Sopenharmony_ci struct rtw89_vif *rtwvif, 97062306a36Sopenharmony_ci struct rtw89_vif *rtwvif_src, 97162306a36Sopenharmony_ci u16 offset_tu); 97262306a36Sopenharmony_ciint rtw89_mac_port_get_tsf(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, 97362306a36Sopenharmony_ci u64 *tsf); 97462306a36Sopenharmony_civoid rtw89_mac_set_he_obss_narrow_bw_ru(struct rtw89_dev *rtwdev, 97562306a36Sopenharmony_ci struct ieee80211_vif *vif); 97662306a36Sopenharmony_civoid rtw89_mac_stop_ap(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif); 97762306a36Sopenharmony_civoid rtw89_mac_enable_beacon_for_ap_vifs(struct rtw89_dev *rtwdev, bool en); 97862306a36Sopenharmony_ciint rtw89_mac_remove_vif(struct rtw89_dev *rtwdev, struct rtw89_vif *vif); 97962306a36Sopenharmony_civoid rtw89_mac_disable_cpu(struct rtw89_dev *rtwdev); 98062306a36Sopenharmony_ciint rtw89_mac_enable_cpu(struct rtw89_dev *rtwdev, u8 boot_reason, bool dlfw); 98162306a36Sopenharmony_ciint rtw89_mac_enable_bb_rf(struct rtw89_dev *rtwdev); 98262306a36Sopenharmony_ciint rtw89_mac_disable_bb_rf(struct rtw89_dev *rtwdev); 98362306a36Sopenharmony_ci 98462306a36Sopenharmony_cistatic inline int rtw89_chip_enable_bb_rf(struct rtw89_dev *rtwdev) 98562306a36Sopenharmony_ci{ 98662306a36Sopenharmony_ci const struct rtw89_chip_info *chip = rtwdev->chip; 98762306a36Sopenharmony_ci 98862306a36Sopenharmony_ci return chip->ops->enable_bb_rf(rtwdev); 98962306a36Sopenharmony_ci} 99062306a36Sopenharmony_ci 99162306a36Sopenharmony_cistatic inline int rtw89_chip_disable_bb_rf(struct rtw89_dev *rtwdev) 99262306a36Sopenharmony_ci{ 99362306a36Sopenharmony_ci const struct rtw89_chip_info *chip = rtwdev->chip; 99462306a36Sopenharmony_ci 99562306a36Sopenharmony_ci return chip->ops->disable_bb_rf(rtwdev); 99662306a36Sopenharmony_ci} 99762306a36Sopenharmony_ci 99862306a36Sopenharmony_ciu32 rtw89_mac_get_err_status(struct rtw89_dev *rtwdev); 99962306a36Sopenharmony_ciint rtw89_mac_set_err_status(struct rtw89_dev *rtwdev, u32 err); 100062306a36Sopenharmony_cibool rtw89_mac_c2h_chk_atomic(struct rtw89_dev *rtwdev, u8 class, u8 func); 100162306a36Sopenharmony_civoid rtw89_mac_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb, 100262306a36Sopenharmony_ci u32 len, u8 class, u8 func); 100362306a36Sopenharmony_ciint rtw89_mac_setup_phycap(struct rtw89_dev *rtwdev); 100462306a36Sopenharmony_ciint rtw89_mac_stop_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, 100562306a36Sopenharmony_ci u32 *tx_en, enum rtw89_sch_tx_sel sel); 100662306a36Sopenharmony_ciint rtw89_mac_stop_sch_tx_v1(struct rtw89_dev *rtwdev, u8 mac_idx, 100762306a36Sopenharmony_ci u32 *tx_en, enum rtw89_sch_tx_sel sel); 100862306a36Sopenharmony_ciint rtw89_mac_resume_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en); 100962306a36Sopenharmony_ciint rtw89_mac_resume_sch_tx_v1(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en); 101062306a36Sopenharmony_ciint rtw89_mac_cfg_ppdu_status(struct rtw89_dev *rtwdev, u8 mac_ids, bool enable); 101162306a36Sopenharmony_civoid rtw89_mac_update_rts_threshold(struct rtw89_dev *rtwdev, u8 mac_idx); 101262306a36Sopenharmony_civoid rtw89_mac_flush_txq(struct rtw89_dev *rtwdev, u32 queues, bool drop); 101362306a36Sopenharmony_ciint rtw89_mac_coex_init(struct rtw89_dev *rtwdev, const struct rtw89_mac_ax_coex *coex); 101462306a36Sopenharmony_ciint rtw89_mac_coex_init_v1(struct rtw89_dev *rtwdev, 101562306a36Sopenharmony_ci const struct rtw89_mac_ax_coex *coex); 101662306a36Sopenharmony_ciint rtw89_mac_cfg_gnt(struct rtw89_dev *rtwdev, 101762306a36Sopenharmony_ci const struct rtw89_mac_ax_coex_gnt *gnt_cfg); 101862306a36Sopenharmony_ciint rtw89_mac_cfg_gnt_v1(struct rtw89_dev *rtwdev, 101962306a36Sopenharmony_ci const struct rtw89_mac_ax_coex_gnt *gnt_cfg); 102062306a36Sopenharmony_ciint rtw89_mac_cfg_plt(struct rtw89_dev *rtwdev, struct rtw89_mac_ax_plt *plt); 102162306a36Sopenharmony_ciu16 rtw89_mac_get_plt_cnt(struct rtw89_dev *rtwdev, u8 band); 102262306a36Sopenharmony_civoid rtw89_mac_cfg_sb(struct rtw89_dev *rtwdev, u32 val); 102362306a36Sopenharmony_ciu32 rtw89_mac_get_sb(struct rtw89_dev *rtwdev); 102462306a36Sopenharmony_cibool rtw89_mac_get_ctrl_path(struct rtw89_dev *rtwdev); 102562306a36Sopenharmony_ciint rtw89_mac_cfg_ctrl_path(struct rtw89_dev *rtwdev, bool wl); 102662306a36Sopenharmony_ciint rtw89_mac_cfg_ctrl_path_v1(struct rtw89_dev *rtwdev, bool wl); 102762306a36Sopenharmony_cibool rtw89_mac_get_txpwr_cr(struct rtw89_dev *rtwdev, 102862306a36Sopenharmony_ci enum rtw89_phy_idx phy_idx, 102962306a36Sopenharmony_ci u32 reg_base, u32 *cr); 103062306a36Sopenharmony_civoid rtw89_mac_power_mode_change(struct rtw89_dev *rtwdev, bool enter); 103162306a36Sopenharmony_civoid rtw89_mac_notify_wake(struct rtw89_dev *rtwdev); 103262306a36Sopenharmony_civoid rtw89_mac_bf_assoc(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, 103362306a36Sopenharmony_ci struct ieee80211_sta *sta); 103462306a36Sopenharmony_civoid rtw89_mac_bf_disassoc(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, 103562306a36Sopenharmony_ci struct ieee80211_sta *sta); 103662306a36Sopenharmony_civoid rtw89_mac_bf_set_gid_table(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, 103762306a36Sopenharmony_ci struct ieee80211_bss_conf *conf); 103862306a36Sopenharmony_civoid rtw89_mac_bf_monitor_calc(struct rtw89_dev *rtwdev, 103962306a36Sopenharmony_ci struct ieee80211_sta *sta, bool disconnect); 104062306a36Sopenharmony_civoid _rtw89_mac_bf_monitor_track(struct rtw89_dev *rtwdev); 104162306a36Sopenharmony_ciint rtw89_mac_vif_init(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif); 104262306a36Sopenharmony_ciint rtw89_mac_vif_deinit(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif); 104362306a36Sopenharmony_ciint rtw89_mac_set_hw_muedca_ctrl(struct rtw89_dev *rtwdev, 104462306a36Sopenharmony_ci struct rtw89_vif *rtwvif, bool en); 104562306a36Sopenharmony_ciint rtw89_mac_set_macid_pause(struct rtw89_dev *rtwdev, u8 macid, bool pause); 104662306a36Sopenharmony_ci 104762306a36Sopenharmony_cistatic inline void rtw89_mac_bf_monitor_track(struct rtw89_dev *rtwdev) 104862306a36Sopenharmony_ci{ 104962306a36Sopenharmony_ci if (!test_bit(RTW89_FLAG_BFEE_MON, rtwdev->flags)) 105062306a36Sopenharmony_ci return; 105162306a36Sopenharmony_ci 105262306a36Sopenharmony_ci _rtw89_mac_bf_monitor_track(rtwdev); 105362306a36Sopenharmony_ci} 105462306a36Sopenharmony_ci 105562306a36Sopenharmony_cistatic inline int rtw89_mac_txpwr_read32(struct rtw89_dev *rtwdev, 105662306a36Sopenharmony_ci enum rtw89_phy_idx phy_idx, 105762306a36Sopenharmony_ci u32 reg_base, u32 *val) 105862306a36Sopenharmony_ci{ 105962306a36Sopenharmony_ci u32 cr; 106062306a36Sopenharmony_ci 106162306a36Sopenharmony_ci if (!rtw89_mac_get_txpwr_cr(rtwdev, phy_idx, reg_base, &cr)) 106262306a36Sopenharmony_ci return -EINVAL; 106362306a36Sopenharmony_ci 106462306a36Sopenharmony_ci *val = rtw89_read32(rtwdev, cr); 106562306a36Sopenharmony_ci return 0; 106662306a36Sopenharmony_ci} 106762306a36Sopenharmony_ci 106862306a36Sopenharmony_cistatic inline int rtw89_mac_txpwr_write32(struct rtw89_dev *rtwdev, 106962306a36Sopenharmony_ci enum rtw89_phy_idx phy_idx, 107062306a36Sopenharmony_ci u32 reg_base, u32 val) 107162306a36Sopenharmony_ci{ 107262306a36Sopenharmony_ci u32 cr; 107362306a36Sopenharmony_ci 107462306a36Sopenharmony_ci if (!rtw89_mac_get_txpwr_cr(rtwdev, phy_idx, reg_base, &cr)) 107562306a36Sopenharmony_ci return -EINVAL; 107662306a36Sopenharmony_ci 107762306a36Sopenharmony_ci rtw89_write32(rtwdev, cr, val); 107862306a36Sopenharmony_ci return 0; 107962306a36Sopenharmony_ci} 108062306a36Sopenharmony_ci 108162306a36Sopenharmony_cistatic inline int rtw89_mac_txpwr_write32_mask(struct rtw89_dev *rtwdev, 108262306a36Sopenharmony_ci enum rtw89_phy_idx phy_idx, 108362306a36Sopenharmony_ci u32 reg_base, u32 mask, u32 val) 108462306a36Sopenharmony_ci{ 108562306a36Sopenharmony_ci u32 cr; 108662306a36Sopenharmony_ci 108762306a36Sopenharmony_ci if (!rtw89_mac_get_txpwr_cr(rtwdev, phy_idx, reg_base, &cr)) 108862306a36Sopenharmony_ci return -EINVAL; 108962306a36Sopenharmony_ci 109062306a36Sopenharmony_ci rtw89_write32_mask(rtwdev, cr, mask, val); 109162306a36Sopenharmony_ci return 0; 109262306a36Sopenharmony_ci} 109362306a36Sopenharmony_ci 109462306a36Sopenharmony_cistatic inline void rtw89_mac_ctrl_hci_dma_tx(struct rtw89_dev *rtwdev, 109562306a36Sopenharmony_ci bool enable) 109662306a36Sopenharmony_ci{ 109762306a36Sopenharmony_ci const struct rtw89_chip_info *chip = rtwdev->chip; 109862306a36Sopenharmony_ci 109962306a36Sopenharmony_ci if (enable) 110062306a36Sopenharmony_ci rtw89_write32_set(rtwdev, chip->hci_func_en_addr, 110162306a36Sopenharmony_ci B_AX_HCI_TXDMA_EN); 110262306a36Sopenharmony_ci else 110362306a36Sopenharmony_ci rtw89_write32_clr(rtwdev, chip->hci_func_en_addr, 110462306a36Sopenharmony_ci B_AX_HCI_TXDMA_EN); 110562306a36Sopenharmony_ci} 110662306a36Sopenharmony_ci 110762306a36Sopenharmony_cistatic inline void rtw89_mac_ctrl_hci_dma_rx(struct rtw89_dev *rtwdev, 110862306a36Sopenharmony_ci bool enable) 110962306a36Sopenharmony_ci{ 111062306a36Sopenharmony_ci const struct rtw89_chip_info *chip = rtwdev->chip; 111162306a36Sopenharmony_ci 111262306a36Sopenharmony_ci if (enable) 111362306a36Sopenharmony_ci rtw89_write32_set(rtwdev, chip->hci_func_en_addr, 111462306a36Sopenharmony_ci B_AX_HCI_RXDMA_EN); 111562306a36Sopenharmony_ci else 111662306a36Sopenharmony_ci rtw89_write32_clr(rtwdev, chip->hci_func_en_addr, 111762306a36Sopenharmony_ci B_AX_HCI_RXDMA_EN); 111862306a36Sopenharmony_ci} 111962306a36Sopenharmony_ci 112062306a36Sopenharmony_cistatic inline void rtw89_mac_ctrl_hci_dma_trx(struct rtw89_dev *rtwdev, 112162306a36Sopenharmony_ci bool enable) 112262306a36Sopenharmony_ci{ 112362306a36Sopenharmony_ci const struct rtw89_chip_info *chip = rtwdev->chip; 112462306a36Sopenharmony_ci 112562306a36Sopenharmony_ci if (enable) 112662306a36Sopenharmony_ci rtw89_write32_set(rtwdev, chip->hci_func_en_addr, 112762306a36Sopenharmony_ci B_AX_HCI_TXDMA_EN | B_AX_HCI_RXDMA_EN); 112862306a36Sopenharmony_ci else 112962306a36Sopenharmony_ci rtw89_write32_clr(rtwdev, chip->hci_func_en_addr, 113062306a36Sopenharmony_ci B_AX_HCI_TXDMA_EN | B_AX_HCI_RXDMA_EN); 113162306a36Sopenharmony_ci} 113262306a36Sopenharmony_ci 113362306a36Sopenharmony_cistatic inline bool rtw89_mac_get_power_state(struct rtw89_dev *rtwdev) 113462306a36Sopenharmony_ci{ 113562306a36Sopenharmony_ci u32 val; 113662306a36Sopenharmony_ci 113762306a36Sopenharmony_ci val = rtw89_read32_mask(rtwdev, R_AX_IC_PWR_STATE, 113862306a36Sopenharmony_ci B_AX_WLMAC_PWR_STE_MASK); 113962306a36Sopenharmony_ci 114062306a36Sopenharmony_ci return !!val; 114162306a36Sopenharmony_ci} 114262306a36Sopenharmony_ci 114362306a36Sopenharmony_ciint rtw89_mac_set_tx_time(struct rtw89_dev *rtwdev, struct rtw89_sta *rtwsta, 114462306a36Sopenharmony_ci bool resume, u32 tx_time); 114562306a36Sopenharmony_ciint rtw89_mac_get_tx_time(struct rtw89_dev *rtwdev, struct rtw89_sta *rtwsta, 114662306a36Sopenharmony_ci u32 *tx_time); 114762306a36Sopenharmony_ciint rtw89_mac_set_tx_retry_limit(struct rtw89_dev *rtwdev, 114862306a36Sopenharmony_ci struct rtw89_sta *rtwsta, 114962306a36Sopenharmony_ci bool resume, u8 tx_retry); 115062306a36Sopenharmony_ciint rtw89_mac_get_tx_retry_limit(struct rtw89_dev *rtwdev, 115162306a36Sopenharmony_ci struct rtw89_sta *rtwsta, u8 *tx_retry); 115262306a36Sopenharmony_ci 115362306a36Sopenharmony_cienum rtw89_mac_xtal_si_offset { 115462306a36Sopenharmony_ci XTAL0 = 0x0, 115562306a36Sopenharmony_ci XTAL3 = 0x3, 115662306a36Sopenharmony_ci XTAL_SI_XTAL_SC_XI = 0x04, 115762306a36Sopenharmony_ci#define XTAL_SC_XI_MASK GENMASK(7, 0) 115862306a36Sopenharmony_ci XTAL_SI_XTAL_SC_XO = 0x05, 115962306a36Sopenharmony_ci#define XTAL_SC_XO_MASK GENMASK(7, 0) 116062306a36Sopenharmony_ci XTAL_SI_PWR_CUT = 0x10, 116162306a36Sopenharmony_ci#define XTAL_SI_SMALL_PWR_CUT BIT(0) 116262306a36Sopenharmony_ci#define XTAL_SI_BIG_PWR_CUT BIT(1) 116362306a36Sopenharmony_ci XTAL_SI_XTAL_DRV = 0x15, 116462306a36Sopenharmony_ci#define XTAL_SI_DRV_LATCH BIT(4) 116562306a36Sopenharmony_ci XTAL_SI_XTAL_XMD_2 = 0x24, 116662306a36Sopenharmony_ci#define XTAL_SI_LDO_LPS GENMASK(6, 4) 116762306a36Sopenharmony_ci XTAL_SI_XTAL_XMD_4 = 0x26, 116862306a36Sopenharmony_ci#define XTAL_SI_LPS_CAP GENMASK(3, 0) 116962306a36Sopenharmony_ci XTAL_SI_CV = 0x41, 117062306a36Sopenharmony_ci#define XTAL_SI_ACV_MASK GENMASK(3, 0) 117162306a36Sopenharmony_ci XTAL_SI_LOW_ADDR = 0x62, 117262306a36Sopenharmony_ci#define XTAL_SI_LOW_ADDR_MASK GENMASK(7, 0) 117362306a36Sopenharmony_ci XTAL_SI_CTRL = 0x63, 117462306a36Sopenharmony_ci#define XTAL_SI_MODE_SEL_MASK GENMASK(7, 6) 117562306a36Sopenharmony_ci#define XTAL_SI_RDY BIT(5) 117662306a36Sopenharmony_ci#define XTAL_SI_HIGH_ADDR_MASK GENMASK(2, 0) 117762306a36Sopenharmony_ci XTAL_SI_READ_VAL = 0x7A, 117862306a36Sopenharmony_ci XTAL_SI_WL_RFC_S0 = 0x80, 117962306a36Sopenharmony_ci#define XTAL_SI_RF00S_EN GENMASK(2, 0) 118062306a36Sopenharmony_ci#define XTAL_SI_RF00 BIT(0) 118162306a36Sopenharmony_ci XTAL_SI_WL_RFC_S1 = 0x81, 118262306a36Sopenharmony_ci#define XTAL_SI_RF10S_EN GENMASK(2, 0) 118362306a36Sopenharmony_ci#define XTAL_SI_RF10 BIT(0) 118462306a36Sopenharmony_ci XTAL_SI_ANAPAR_WL = 0x90, 118562306a36Sopenharmony_ci#define XTAL_SI_SRAM2RFC BIT(7) 118662306a36Sopenharmony_ci#define XTAL_SI_GND_SHDN_WL BIT(6) 118762306a36Sopenharmony_ci#define XTAL_SI_SHDN_WL BIT(5) 118862306a36Sopenharmony_ci#define XTAL_SI_RFC2RF BIT(4) 118962306a36Sopenharmony_ci#define XTAL_SI_OFF_EI BIT(3) 119062306a36Sopenharmony_ci#define XTAL_SI_OFF_WEI BIT(2) 119162306a36Sopenharmony_ci#define XTAL_SI_PON_EI BIT(1) 119262306a36Sopenharmony_ci#define XTAL_SI_PON_WEI BIT(0) 119362306a36Sopenharmony_ci XTAL_SI_SRAM_CTRL = 0xA1, 119462306a36Sopenharmony_ci#define XTAL_SI_SRAM_DIS BIT(1) 119562306a36Sopenharmony_ci#define FULL_BIT_MASK GENMASK(7, 0) 119662306a36Sopenharmony_ci}; 119762306a36Sopenharmony_ci 119862306a36Sopenharmony_ciint rtw89_mac_write_xtal_si(struct rtw89_dev *rtwdev, u8 offset, u8 val, u8 mask); 119962306a36Sopenharmony_ciint rtw89_mac_read_xtal_si(struct rtw89_dev *rtwdev, u8 offset, u8 *val); 120062306a36Sopenharmony_civoid rtw89_mac_pkt_drop_vif(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif); 120162306a36Sopenharmony_ciint rtw89_mac_dle_buf_req(struct rtw89_dev *rtwdev, u16 buf_len, bool wd, u16 *pkt_id); 120262306a36Sopenharmony_ciint rtw89_mac_set_cpuio(struct rtw89_dev *rtwdev, 120362306a36Sopenharmony_ci struct rtw89_cpuio_ctrl *ctrl_para, bool wd); 120462306a36Sopenharmony_ciint rtw89_mac_typ_fltr_opt(struct rtw89_dev *rtwdev, 120562306a36Sopenharmony_ci enum rtw89_machdr_frame_type type, 120662306a36Sopenharmony_ci enum rtw89_mac_fwd_target fwd_target, u8 mac_idx); 120762306a36Sopenharmony_ciint rtw89_mac_resize_ple_rx_quota(struct rtw89_dev *rtwdev, bool wow); 120862306a36Sopenharmony_ciint rtw89_mac_ptk_drop_by_band_and_wait(struct rtw89_dev *rtwdev, 120962306a36Sopenharmony_ci enum rtw89_mac_idx band); 121062306a36Sopenharmony_civoid rtw89_mac_hw_mgnt_sec(struct rtw89_dev *rtwdev, bool wow); 121162306a36Sopenharmony_ci 121262306a36Sopenharmony_ci#endif 1213