Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ISC */
0002 /*
0003  * Copyright (c) 2005-2011 Atheros Communications Inc.
0004  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
0005  * Copyright (c) 2018 The Linux Foundation. All rights reserved.
0006  */
0007 
0008 #ifndef _HW_H_
0009 #define _HW_H_
0010 
0011 #include "targaddrs.h"
0012 
0013 enum ath10k_bus {
0014     ATH10K_BUS_PCI,
0015     ATH10K_BUS_AHB,
0016     ATH10K_BUS_SDIO,
0017     ATH10K_BUS_USB,
0018     ATH10K_BUS_SNOC,
0019 };
0020 
0021 #define ATH10K_FW_DIR           "ath10k"
0022 
0023 #define QCA988X_2_0_DEVICE_ID_UBNT   (0x11ac)
0024 #define QCA988X_2_0_DEVICE_ID   (0x003c)
0025 #define QCA6164_2_1_DEVICE_ID   (0x0041)
0026 #define QCA6174_2_1_DEVICE_ID   (0x003e)
0027 #define QCA6174_3_2_DEVICE_ID   (0x0042)
0028 #define QCA99X0_2_0_DEVICE_ID   (0x0040)
0029 #define QCA9888_2_0_DEVICE_ID   (0x0056)
0030 #define QCA9984_1_0_DEVICE_ID   (0x0046)
0031 #define QCA9377_1_0_DEVICE_ID   (0x0042)
0032 #define QCA9887_1_0_DEVICE_ID   (0x0050)
0033 
0034 /* QCA988X 1.0 definitions (unsupported) */
0035 #define QCA988X_HW_1_0_CHIP_ID_REV  0x0
0036 
0037 /* QCA988X 2.0 definitions */
0038 #define QCA988X_HW_2_0_VERSION      0x4100016c
0039 #define QCA988X_HW_2_0_CHIP_ID_REV  0x2
0040 #define QCA988X_HW_2_0_FW_DIR       ATH10K_FW_DIR "/QCA988X/hw2.0"
0041 #define QCA988X_HW_2_0_BOARD_DATA_FILE  "board.bin"
0042 #define QCA988X_HW_2_0_PATCH_LOAD_ADDR  0x1234
0043 
0044 /* QCA9887 1.0 definitions */
0045 #define QCA9887_HW_1_0_VERSION      0x4100016d
0046 #define QCA9887_HW_1_0_CHIP_ID_REV  0
0047 #define QCA9887_HW_1_0_FW_DIR       ATH10K_FW_DIR "/QCA9887/hw1.0"
0048 #define QCA9887_HW_1_0_BOARD_DATA_FILE  "board.bin"
0049 #define QCA9887_HW_1_0_PATCH_LOAD_ADDR  0x1234
0050 
0051 /* QCA6174 target BMI version signatures */
0052 #define QCA6174_HW_1_0_VERSION      0x05000000
0053 #define QCA6174_HW_1_1_VERSION      0x05000001
0054 #define QCA6174_HW_1_3_VERSION      0x05000003
0055 #define QCA6174_HW_2_1_VERSION      0x05010000
0056 #define QCA6174_HW_3_0_VERSION      0x05020000
0057 #define QCA6174_HW_3_2_VERSION      0x05030000
0058 
0059 /* QCA9377 target BMI version signatures */
0060 #define QCA9377_HW_1_0_DEV_VERSION  0x05020000
0061 #define QCA9377_HW_1_1_DEV_VERSION  0x05020001
0062 
0063 enum qca6174_pci_rev {
0064     QCA6174_PCI_REV_1_1 = 0x11,
0065     QCA6174_PCI_REV_1_3 = 0x13,
0066     QCA6174_PCI_REV_2_0 = 0x20,
0067     QCA6174_PCI_REV_3_0 = 0x30,
0068 };
0069 
0070 enum qca6174_chip_id_rev {
0071     QCA6174_HW_1_0_CHIP_ID_REV = 0,
0072     QCA6174_HW_1_1_CHIP_ID_REV = 1,
0073     QCA6174_HW_1_3_CHIP_ID_REV = 2,
0074     QCA6174_HW_2_1_CHIP_ID_REV = 4,
0075     QCA6174_HW_2_2_CHIP_ID_REV = 5,
0076     QCA6174_HW_3_0_CHIP_ID_REV = 8,
0077     QCA6174_HW_3_1_CHIP_ID_REV = 9,
0078     QCA6174_HW_3_2_CHIP_ID_REV = 10,
0079 };
0080 
0081 enum qca9377_chip_id_rev {
0082     QCA9377_HW_1_0_CHIP_ID_REV = 0x0,
0083     QCA9377_HW_1_1_CHIP_ID_REV = 0x1,
0084 };
0085 
0086 #define QCA6174_HW_2_1_FW_DIR       ATH10K_FW_DIR "/QCA6174/hw2.1"
0087 #define QCA6174_HW_2_1_BOARD_DATA_FILE  "board.bin"
0088 #define QCA6174_HW_2_1_PATCH_LOAD_ADDR  0x1234
0089 
0090 #define QCA6174_HW_3_0_FW_DIR       ATH10K_FW_DIR "/QCA6174/hw3.0"
0091 #define QCA6174_HW_3_0_BOARD_DATA_FILE  "board.bin"
0092 #define QCA6174_HW_3_0_PATCH_LOAD_ADDR  0x1234
0093 
0094 /* QCA99X0 1.0 definitions (unsupported) */
0095 #define QCA99X0_HW_1_0_CHIP_ID_REV     0x0
0096 
0097 /* QCA99X0 2.0 definitions */
0098 #define QCA99X0_HW_2_0_DEV_VERSION     0x01000000
0099 #define QCA99X0_HW_2_0_CHIP_ID_REV     0x1
0100 #define QCA99X0_HW_2_0_FW_DIR          ATH10K_FW_DIR "/QCA99X0/hw2.0"
0101 #define QCA99X0_HW_2_0_BOARD_DATA_FILE "board.bin"
0102 #define QCA99X0_HW_2_0_PATCH_LOAD_ADDR  0x1234
0103 
0104 /* QCA9984 1.0 defines */
0105 #define QCA9984_HW_1_0_DEV_VERSION  0x1000000
0106 #define QCA9984_HW_DEV_TYPE     0xa
0107 #define QCA9984_HW_1_0_CHIP_ID_REV  0x0
0108 #define QCA9984_HW_1_0_FW_DIR       ATH10K_FW_DIR "/QCA9984/hw1.0"
0109 #define QCA9984_HW_1_0_BOARD_DATA_FILE "board.bin"
0110 #define QCA9984_HW_1_0_EBOARD_DATA_FILE "eboard.bin"
0111 #define QCA9984_HW_1_0_PATCH_LOAD_ADDR  0x1234
0112 
0113 /* QCA9888 2.0 defines */
0114 #define QCA9888_HW_2_0_DEV_VERSION  0x1000000
0115 #define QCA9888_HW_DEV_TYPE     0xc
0116 #define QCA9888_HW_2_0_CHIP_ID_REV  0x0
0117 #define QCA9888_HW_2_0_FW_DIR       ATH10K_FW_DIR "/QCA9888/hw2.0"
0118 #define QCA9888_HW_2_0_BOARD_DATA_FILE "board.bin"
0119 #define QCA9888_HW_2_0_PATCH_LOAD_ADDR  0x1234
0120 
0121 /* QCA9377 1.0 definitions */
0122 #define QCA9377_HW_1_0_FW_DIR          ATH10K_FW_DIR "/QCA9377/hw1.0"
0123 #define QCA9377_HW_1_0_BOARD_DATA_FILE "board.bin"
0124 #define QCA9377_HW_1_0_PATCH_LOAD_ADDR  0x1234
0125 
0126 /* QCA4019 1.0 definitions */
0127 #define QCA4019_HW_1_0_DEV_VERSION     0x01000000
0128 #define QCA4019_HW_1_0_FW_DIR          ATH10K_FW_DIR "/QCA4019/hw1.0"
0129 #define QCA4019_HW_1_0_BOARD_DATA_FILE "board.bin"
0130 #define QCA4019_HW_1_0_PATCH_LOAD_ADDR  0x1234
0131 
0132 /* WCN3990 1.0 definitions */
0133 #define WCN3990_HW_1_0_DEV_VERSION  ATH10K_HW_WCN3990
0134 #define WCN3990_HW_1_0_FW_DIR       ATH10K_FW_DIR "/WCN3990/hw1.0"
0135 
0136 #define ATH10K_FW_FILE_BASE     "firmware"
0137 #define ATH10K_FW_API_MAX       6
0138 #define ATH10K_FW_API_MIN       2
0139 
0140 #define ATH10K_FW_API2_FILE     "firmware-2.bin"
0141 #define ATH10K_FW_API3_FILE     "firmware-3.bin"
0142 
0143 /* added support for ATH10K_FW_IE_WMI_OP_VERSION */
0144 #define ATH10K_FW_API4_FILE     "firmware-4.bin"
0145 
0146 /* HTT id conflict fix for management frames over HTT */
0147 #define ATH10K_FW_API5_FILE     "firmware-5.bin"
0148 
0149 /* the firmware-6.bin blob */
0150 #define ATH10K_FW_API6_FILE     "firmware-6.bin"
0151 
0152 #define ATH10K_FW_UTF_FILE      "utf.bin"
0153 #define ATH10K_FW_UTF_API2_FILE     "utf-2.bin"
0154 
0155 #define ATH10K_FW_UTF_FILE_BASE     "utf"
0156 
0157 /* includes also the null byte */
0158 #define ATH10K_FIRMWARE_MAGIC               "QCA-ATH10K"
0159 #define ATH10K_BOARD_MAGIC                  "QCA-ATH10K-BOARD"
0160 
0161 #define ATH10K_BOARD_API2_FILE         "board-2.bin"
0162 
0163 #define REG_DUMP_COUNT_QCA988X 60
0164 
0165 struct ath10k_fw_ie {
0166     __le32 id;
0167     __le32 len;
0168     u8 data[];
0169 };
0170 
0171 enum ath10k_fw_ie_type {
0172     ATH10K_FW_IE_FW_VERSION = 0,
0173     ATH10K_FW_IE_TIMESTAMP = 1,
0174     ATH10K_FW_IE_FEATURES = 2,
0175     ATH10K_FW_IE_FW_IMAGE = 3,
0176     ATH10K_FW_IE_OTP_IMAGE = 4,
0177 
0178     /* WMI "operations" interface version, 32 bit value. Supported from
0179      * FW API 4 and above.
0180      */
0181     ATH10K_FW_IE_WMI_OP_VERSION = 5,
0182 
0183     /* HTT "operations" interface version, 32 bit value. Supported from
0184      * FW API 5 and above.
0185      */
0186     ATH10K_FW_IE_HTT_OP_VERSION = 6,
0187 
0188     /* Code swap image for firmware binary */
0189     ATH10K_FW_IE_FW_CODE_SWAP_IMAGE = 7,
0190 };
0191 
0192 enum ath10k_fw_wmi_op_version {
0193     ATH10K_FW_WMI_OP_VERSION_UNSET = 0,
0194 
0195     ATH10K_FW_WMI_OP_VERSION_MAIN = 1,
0196     ATH10K_FW_WMI_OP_VERSION_10_1 = 2,
0197     ATH10K_FW_WMI_OP_VERSION_10_2 = 3,
0198     ATH10K_FW_WMI_OP_VERSION_TLV = 4,
0199     ATH10K_FW_WMI_OP_VERSION_10_2_4 = 5,
0200     ATH10K_FW_WMI_OP_VERSION_10_4 = 6,
0201 
0202     /* keep last */
0203     ATH10K_FW_WMI_OP_VERSION_MAX,
0204 };
0205 
0206 enum ath10k_fw_htt_op_version {
0207     ATH10K_FW_HTT_OP_VERSION_UNSET = 0,
0208 
0209     ATH10K_FW_HTT_OP_VERSION_MAIN = 1,
0210 
0211     /* also used in 10.2 and 10.2.4 branches */
0212     ATH10K_FW_HTT_OP_VERSION_10_1 = 2,
0213 
0214     ATH10K_FW_HTT_OP_VERSION_TLV = 3,
0215 
0216     ATH10K_FW_HTT_OP_VERSION_10_4 = 4,
0217 
0218     /* keep last */
0219     ATH10K_FW_HTT_OP_VERSION_MAX,
0220 };
0221 
0222 enum ath10k_bd_ie_type {
0223     /* contains sub IEs of enum ath10k_bd_ie_board_type */
0224     ATH10K_BD_IE_BOARD = 0,
0225     ATH10K_BD_IE_BOARD_EXT = 1,
0226 };
0227 
0228 enum ath10k_bd_ie_board_type {
0229     ATH10K_BD_IE_BOARD_NAME = 0,
0230     ATH10K_BD_IE_BOARD_DATA = 1,
0231 };
0232 
0233 enum ath10k_hw_rev {
0234     ATH10K_HW_QCA988X,
0235     ATH10K_HW_QCA6174,
0236     ATH10K_HW_QCA99X0,
0237     ATH10K_HW_QCA9888,
0238     ATH10K_HW_QCA9984,
0239     ATH10K_HW_QCA9377,
0240     ATH10K_HW_QCA4019,
0241     ATH10K_HW_QCA9887,
0242     ATH10K_HW_WCN3990,
0243 };
0244 
0245 struct ath10k_hw_regs {
0246     u32 rtc_soc_base_address;
0247     u32 rtc_wmac_base_address;
0248     u32 soc_core_base_address;
0249     u32 wlan_mac_base_address;
0250     u32 ce_wrapper_base_address;
0251     u32 ce0_base_address;
0252     u32 ce1_base_address;
0253     u32 ce2_base_address;
0254     u32 ce3_base_address;
0255     u32 ce4_base_address;
0256     u32 ce5_base_address;
0257     u32 ce6_base_address;
0258     u32 ce7_base_address;
0259     u32 ce8_base_address;
0260     u32 ce9_base_address;
0261     u32 ce10_base_address;
0262     u32 ce11_base_address;
0263     u32 soc_reset_control_si0_rst_mask;
0264     u32 soc_reset_control_ce_rst_mask;
0265     u32 soc_chip_id_address;
0266     u32 scratch_3_address;
0267     u32 fw_indicator_address;
0268     u32 pcie_local_base_address;
0269     u32 ce_wrap_intr_sum_host_msi_lsb;
0270     u32 ce_wrap_intr_sum_host_msi_mask;
0271     u32 pcie_intr_fw_mask;
0272     u32 pcie_intr_ce_mask_all;
0273     u32 pcie_intr_clr_address;
0274     u32 cpu_pll_init_address;
0275     u32 cpu_speed_address;
0276     u32 core_clk_div_address;
0277 };
0278 
0279 extern const struct ath10k_hw_regs qca988x_regs;
0280 extern const struct ath10k_hw_regs qca6174_regs;
0281 extern const struct ath10k_hw_regs qca99x0_regs;
0282 extern const struct ath10k_hw_regs qca4019_regs;
0283 extern const struct ath10k_hw_regs wcn3990_regs;
0284 
0285 struct ath10k_hw_ce_regs_addr_map {
0286     u32 msb;
0287     u32 lsb;
0288     u32 mask;
0289 };
0290 
0291 struct ath10k_hw_ce_ctrl1 {
0292     u32 addr;
0293     u32 hw_mask;
0294     u32 sw_mask;
0295     u32 hw_wr_mask;
0296     u32 sw_wr_mask;
0297     u32 reset_mask;
0298     u32 reset;
0299     struct ath10k_hw_ce_regs_addr_map *src_ring;
0300     struct ath10k_hw_ce_regs_addr_map *dst_ring;
0301     struct ath10k_hw_ce_regs_addr_map *dmax; };
0302 
0303 struct ath10k_hw_ce_cmd_halt {
0304     u32 status_reset;
0305     u32 msb;
0306     u32 mask;
0307     struct ath10k_hw_ce_regs_addr_map *status; };
0308 
0309 struct ath10k_hw_ce_host_ie {
0310     u32 copy_complete_reset;
0311     struct ath10k_hw_ce_regs_addr_map *copy_complete; };
0312 
0313 struct ath10k_hw_ce_host_wm_regs {
0314     u32 dstr_lmask;
0315     u32 dstr_hmask;
0316     u32 srcr_lmask;
0317     u32 srcr_hmask;
0318     u32 cc_mask;
0319     u32 wm_mask;
0320     u32 addr;
0321 };
0322 
0323 struct ath10k_hw_ce_misc_regs {
0324     u32 axi_err;
0325     u32 dstr_add_err;
0326     u32 srcr_len_err;
0327     u32 dstr_mlen_vio;
0328     u32 dstr_overflow;
0329     u32 srcr_overflow;
0330     u32 err_mask;
0331     u32 addr;
0332 };
0333 
0334 struct ath10k_hw_ce_dst_src_wm_regs {
0335     u32 addr;
0336     u32 low_rst;
0337     u32 high_rst;
0338     struct ath10k_hw_ce_regs_addr_map *wm_low;
0339     struct ath10k_hw_ce_regs_addr_map *wm_high; };
0340 
0341 struct ath10k_hw_ce_ctrl1_upd {
0342     u32 shift;
0343     u32 mask;
0344     u32 enable;
0345 };
0346 
0347 struct ath10k_hw_ce_regs {
0348     u32 sr_base_addr_lo;
0349     u32 sr_base_addr_hi;
0350     u32 sr_size_addr;
0351     u32 dr_base_addr_lo;
0352     u32 dr_base_addr_hi;
0353     u32 dr_size_addr;
0354     u32 ce_cmd_addr;
0355     u32 misc_ie_addr;
0356     u32 sr_wr_index_addr;
0357     u32 dst_wr_index_addr;
0358     u32 current_srri_addr;
0359     u32 current_drri_addr;
0360     u32 ddr_addr_for_rri_low;
0361     u32 ddr_addr_for_rri_high;
0362     u32 ce_rri_low;
0363     u32 ce_rri_high;
0364     u32 host_ie_addr;
0365     struct ath10k_hw_ce_host_wm_regs *wm_regs;
0366     struct ath10k_hw_ce_misc_regs *misc_regs;
0367     struct ath10k_hw_ce_ctrl1 *ctrl1_regs;
0368     struct ath10k_hw_ce_cmd_halt *cmd_halt;
0369     struct ath10k_hw_ce_host_ie *host_ie;
0370     struct ath10k_hw_ce_dst_src_wm_regs *wm_srcr;
0371     struct ath10k_hw_ce_dst_src_wm_regs *wm_dstr;
0372     struct ath10k_hw_ce_ctrl1_upd *upd;
0373 };
0374 
0375 struct ath10k_hw_values {
0376     u32 rtc_state_val_on;
0377     u8 ce_count;
0378     u8 msi_assign_ce_max;
0379     u8 num_target_ce_config_wlan;
0380     u16 ce_desc_meta_data_mask;
0381     u8 ce_desc_meta_data_lsb;
0382     u32 rfkill_pin;
0383     u32 rfkill_cfg;
0384     bool rfkill_on_level;
0385 };
0386 
0387 extern const struct ath10k_hw_values qca988x_values;
0388 extern const struct ath10k_hw_values qca6174_values;
0389 extern const struct ath10k_hw_values qca99x0_values;
0390 extern const struct ath10k_hw_values qca9888_values;
0391 extern const struct ath10k_hw_values qca4019_values;
0392 extern const struct ath10k_hw_values wcn3990_values;
0393 extern const struct ath10k_hw_ce_regs wcn3990_ce_regs;
0394 extern const struct ath10k_hw_ce_regs qcax_ce_regs;
0395 
0396 void ath10k_hw_fill_survey_time(struct ath10k *ar, struct survey_info *survey,
0397                 u32 cc, u32 rcc, u32 cc_prev, u32 rcc_prev);
0398 
0399 int ath10k_hw_diag_fast_download(struct ath10k *ar,
0400                  u32 address,
0401                  const void *buffer,
0402                  u32 length);
0403 
0404 #define QCA_REV_988X(ar) ((ar)->hw_rev == ATH10K_HW_QCA988X)
0405 #define QCA_REV_9887(ar) ((ar)->hw_rev == ATH10K_HW_QCA9887)
0406 #define QCA_REV_6174(ar) ((ar)->hw_rev == ATH10K_HW_QCA6174)
0407 #define QCA_REV_99X0(ar) ((ar)->hw_rev == ATH10K_HW_QCA99X0)
0408 #define QCA_REV_9888(ar) ((ar)->hw_rev == ATH10K_HW_QCA9888)
0409 #define QCA_REV_9984(ar) ((ar)->hw_rev == ATH10K_HW_QCA9984)
0410 #define QCA_REV_9377(ar) ((ar)->hw_rev == ATH10K_HW_QCA9377)
0411 #define QCA_REV_40XX(ar) ((ar)->hw_rev == ATH10K_HW_QCA4019)
0412 #define QCA_REV_WCN3990(ar) ((ar)->hw_rev == ATH10K_HW_WCN3990)
0413 
0414 /* Known peculiarities:
0415  *  - raw appears in nwifi decap, raw and nwifi appear in ethernet decap
0416  *  - raw have FCS, nwifi doesn't
0417  *  - ethernet frames have 802.11 header decapped and parts (base hdr, cipher
0418  *    param, llc/snap) are aligned to 4byte boundaries each
0419  */
0420 enum ath10k_hw_txrx_mode {
0421     ATH10K_HW_TXRX_RAW = 0,
0422 
0423     /* Native Wifi decap mode is used to align IP frames to 4-byte
0424      * boundaries and avoid a very expensive re-alignment in mac80211.
0425      */
0426     ATH10K_HW_TXRX_NATIVE_WIFI = 1,
0427     ATH10K_HW_TXRX_ETHERNET = 2,
0428 
0429     /* Valid for HTT >= 3.0. Used for management frames in TX_FRM. */
0430     ATH10K_HW_TXRX_MGMT = 3,
0431 };
0432 
0433 enum ath10k_mcast2ucast_mode {
0434     ATH10K_MCAST2UCAST_DISABLED = 0,
0435     ATH10K_MCAST2UCAST_ENABLED = 1,
0436 };
0437 
0438 enum ath10k_hw_rate_ofdm {
0439     ATH10K_HW_RATE_OFDM_48M = 0,
0440     ATH10K_HW_RATE_OFDM_24M,
0441     ATH10K_HW_RATE_OFDM_12M,
0442     ATH10K_HW_RATE_OFDM_6M,
0443     ATH10K_HW_RATE_OFDM_54M,
0444     ATH10K_HW_RATE_OFDM_36M,
0445     ATH10K_HW_RATE_OFDM_18M,
0446     ATH10K_HW_RATE_OFDM_9M,
0447 };
0448 
0449 enum ath10k_hw_rate_cck {
0450     ATH10K_HW_RATE_CCK_LP_11M = 0,
0451     ATH10K_HW_RATE_CCK_LP_5_5M,
0452     ATH10K_HW_RATE_CCK_LP_2M,
0453     ATH10K_HW_RATE_CCK_LP_1M,
0454     ATH10K_HW_RATE_CCK_SP_11M,
0455     ATH10K_HW_RATE_CCK_SP_5_5M,
0456     ATH10K_HW_RATE_CCK_SP_2M,
0457 };
0458 
0459 enum ath10k_hw_rate_rev2_cck {
0460     ATH10K_HW_RATE_REV2_CCK_LP_1M = 1,
0461     ATH10K_HW_RATE_REV2_CCK_LP_2M,
0462     ATH10K_HW_RATE_REV2_CCK_LP_5_5M,
0463     ATH10K_HW_RATE_REV2_CCK_LP_11M,
0464     ATH10K_HW_RATE_REV2_CCK_SP_2M,
0465     ATH10K_HW_RATE_REV2_CCK_SP_5_5M,
0466     ATH10K_HW_RATE_REV2_CCK_SP_11M,
0467 };
0468 
0469 enum ath10k_hw_cc_wraparound_type {
0470     ATH10K_HW_CC_WRAP_DISABLED = 0,
0471 
0472     /* This type is when the HW chip has a quirky Cycle Counter
0473      * wraparound which resets to 0x7fffffff instead of 0. All
0474      * other CC related counters (e.g. Rx Clear Count) are divided
0475      * by 2 so they never wraparound themselves.
0476      */
0477     ATH10K_HW_CC_WRAP_SHIFTED_ALL = 1,
0478 
0479     /* Each hw counter wrapsaround independently. When the
0480      * counter overflows the repestive counter is right shifted
0481      * by 1, i.e reset to 0x7fffffff, and other counters will be
0482      * running unaffected. In this type of wraparound, it should
0483      * be possible to report accurate Rx busy time unlike the
0484      * first type.
0485      */
0486     ATH10K_HW_CC_WRAP_SHIFTED_EACH = 2,
0487 };
0488 
0489 enum ath10k_hw_refclk_speed {
0490     ATH10K_HW_REFCLK_UNKNOWN = -1,
0491     ATH10K_HW_REFCLK_48_MHZ = 0,
0492     ATH10K_HW_REFCLK_19_2_MHZ = 1,
0493     ATH10K_HW_REFCLK_24_MHZ = 2,
0494     ATH10K_HW_REFCLK_26_MHZ = 3,
0495     ATH10K_HW_REFCLK_37_4_MHZ = 4,
0496     ATH10K_HW_REFCLK_38_4_MHZ = 5,
0497     ATH10K_HW_REFCLK_40_MHZ = 6,
0498     ATH10K_HW_REFCLK_52_MHZ = 7,
0499 
0500     /* must be the last one */
0501     ATH10K_HW_REFCLK_COUNT,
0502 };
0503 
0504 struct ath10k_hw_clk_params {
0505     u32 refclk;
0506     u32 div;
0507     u32 rnfrac;
0508     u32 settle_time;
0509     u32 refdiv;
0510     u32 outdiv;
0511 };
0512 
0513 struct htt_rx_desc_ops;
0514 
0515 struct ath10k_hw_params {
0516     u32 id;
0517     u16 dev_id;
0518     enum ath10k_bus bus;
0519     const char *name;
0520     u32 patch_load_addr;
0521     int uart_pin;
0522     u32 otp_exe_param;
0523 
0524     /* Type of hw cycle counter wraparound logic, for more info
0525      * refer enum ath10k_hw_cc_wraparound_type.
0526      */
0527     enum ath10k_hw_cc_wraparound_type cc_wraparound_type;
0528 
0529     /* Some of chip expects fragment descriptor to be continuous
0530      * memory for any TX operation. Set continuous_frag_desc flag
0531      * for the hardware which have such requirement.
0532      */
0533     bool continuous_frag_desc;
0534 
0535     /* CCK hardware rate table mapping for the newer chipsets
0536      * like QCA99X0, QCA4019 got revised. The CCK h/w rate values
0537      * are in a proper order with respect to the rate/preamble
0538      */
0539     bool cck_rate_map_rev2;
0540 
0541     u32 channel_counters_freq_hz;
0542 
0543     /* Mgmt tx descriptors threshold for limiting probe response
0544      * frames.
0545      */
0546     u32 max_probe_resp_desc_thres;
0547 
0548     u32 tx_chain_mask;
0549     u32 rx_chain_mask;
0550     u32 max_spatial_stream;
0551     u32 cal_data_len;
0552 
0553     struct ath10k_hw_params_fw {
0554         const char *dir;
0555         const char *board;
0556         size_t board_size;
0557         const char *eboard;
0558         size_t ext_board_size;
0559         size_t board_ext_size;
0560     } fw;
0561 
0562     /* qca99x0 family chips deliver broadcast/multicast management
0563      * frames encrypted and expect software do decryption.
0564      */
0565     bool sw_decrypt_mcast_mgmt;
0566 
0567     /* Rx descriptor abstraction */
0568     const struct ath10k_htt_rx_desc_ops *rx_desc_ops;
0569 
0570     const struct ath10k_hw_ops *hw_ops;
0571 
0572     /* Number of bytes used for alignment in rx_hdr_status of rx desc. */
0573     int decap_align_bytes;
0574 
0575     /* hw specific clock control parameters */
0576     const struct ath10k_hw_clk_params *hw_clk;
0577     int target_cpu_freq;
0578 
0579     /* Number of bytes to be discarded for each FFT sample */
0580     int spectral_bin_discard;
0581 
0582     /* The board may have a restricted NSS for 160 or 80+80 vs what it
0583      * can do for 80Mhz.
0584      */
0585     int vht160_mcs_rx_highest;
0586     int vht160_mcs_tx_highest;
0587 
0588     /* Number of ciphers supported (i.e First N) in cipher_suites array */
0589     int n_cipher_suites;
0590 
0591     u32 num_peers;
0592     u32 ast_skid_limit;
0593     u32 num_wds_entries;
0594 
0595     /* Targets supporting physical addressing capability above 32-bits */
0596     bool target_64bit;
0597 
0598     /* Target rx ring fill level */
0599     u32 rx_ring_fill_level;
0600 
0601     /* target supporting shadow register for ce write */
0602     bool shadow_reg_support;
0603 
0604     /* target supporting retention restore on ddr */
0605     bool rri_on_ddr;
0606 
0607     /* Number of bytes to be the offset for each FFT sample */
0608     int spectral_bin_offset;
0609 
0610     /* targets which require hw filter reset during boot up,
0611      * to avoid it sending spurious acks.
0612      */
0613     bool hw_filter_reset_required;
0614 
0615     /* target supporting fw download via diag ce */
0616     bool fw_diag_ce_download;
0617 
0618     /* target supporting fw download via large size BMI */
0619     bool bmi_large_size_download;
0620 
0621     /* need to set uart pin if disable uart print, workaround for a
0622      * firmware bug
0623      */
0624     bool uart_pin_workaround;
0625 
0626     /* Workaround for the credit size calculation */
0627     bool credit_size_workaround;
0628 
0629     /* tx stats support over pktlog */
0630     bool tx_stats_over_pktlog;
0631 
0632     /* provides bitrates for sta_statistics using WMI_TLV_PEER_STATS_INFO_EVENTID */
0633     bool supports_peer_stats_info;
0634 
0635     bool dynamic_sar_support;
0636 
0637     bool hw_restart_disconnect;
0638 };
0639 
0640 struct htt_resp;
0641 struct htt_data_tx_completion_ext;
0642 struct htt_rx_ring_rx_desc_offsets;
0643 
0644 /* Defines needed for Rx descriptor abstraction */
0645 struct ath10k_hw_ops {
0646     void (*set_coverage_class)(struct ath10k *ar, s16 value);
0647     int (*enable_pll_clk)(struct ath10k *ar);
0648     int (*tx_data_rssi_pad_bytes)(struct htt_resp *htt);
0649     int (*is_rssi_enable)(struct htt_resp *resp);
0650 };
0651 
0652 extern const struct ath10k_hw_ops qca988x_ops;
0653 extern const struct ath10k_hw_ops qca99x0_ops;
0654 extern const struct ath10k_hw_ops qca6174_ops;
0655 extern const struct ath10k_hw_ops qca6174_sdio_ops;
0656 extern const struct ath10k_hw_ops wcn3990_ops;
0657 
0658 extern const struct ath10k_hw_clk_params qca6174_clk[];
0659 
0660 static inline int
0661 ath10k_tx_data_rssi_get_pad_bytes(struct ath10k_hw_params *hw,
0662                   struct htt_resp *htt)
0663 {
0664     if (hw->hw_ops->tx_data_rssi_pad_bytes)
0665         return hw->hw_ops->tx_data_rssi_pad_bytes(htt);
0666     return 0;
0667 }
0668 
0669 static inline int
0670 ath10k_is_rssi_enable(struct ath10k_hw_params *hw,
0671               struct htt_resp *resp)
0672 {
0673     if (hw->hw_ops->is_rssi_enable)
0674         return hw->hw_ops->is_rssi_enable(resp);
0675     return 0;
0676 }
0677 
0678 /* Target specific defines for MAIN firmware */
0679 #define TARGET_NUM_VDEVS            8
0680 #define TARGET_NUM_PEER_AST         2
0681 #define TARGET_NUM_WDS_ENTRIES          32
0682 #define TARGET_DMA_BURST_SIZE           0
0683 #define TARGET_MAC_AGGR_DELIM           0
0684 #define TARGET_AST_SKID_LIMIT           16
0685 #define TARGET_NUM_STATIONS         16
0686 #define TARGET_NUM_PEERS            ((TARGET_NUM_STATIONS) + \
0687                          (TARGET_NUM_VDEVS))
0688 #define TARGET_NUM_OFFLOAD_PEERS        0
0689 #define TARGET_NUM_OFFLOAD_REORDER_BUFS         0
0690 #define TARGET_NUM_PEER_KEYS            2
0691 #define TARGET_NUM_TIDS             ((TARGET_NUM_PEERS) * 2)
0692 #define TARGET_TX_CHAIN_MASK            (BIT(0) | BIT(1) | BIT(2))
0693 #define TARGET_RX_CHAIN_MASK            (BIT(0) | BIT(1) | BIT(2))
0694 #define TARGET_RX_TIMEOUT_LO_PRI        100
0695 #define TARGET_RX_TIMEOUT_HI_PRI        40
0696 
0697 #define TARGET_SCAN_MAX_PENDING_REQS        4
0698 #define TARGET_BMISS_OFFLOAD_MAX_VDEV       3
0699 #define TARGET_ROAM_OFFLOAD_MAX_VDEV        3
0700 #define TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES 8
0701 #define TARGET_GTK_OFFLOAD_MAX_VDEV     3
0702 #define TARGET_NUM_MCAST_GROUPS         0
0703 #define TARGET_NUM_MCAST_TABLE_ELEMS        0
0704 #define TARGET_MCAST2UCAST_MODE         ATH10K_MCAST2UCAST_DISABLED
0705 #define TARGET_TX_DBG_LOG_SIZE          1024
0706 #define TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 0
0707 #define TARGET_VOW_CONFIG           0
0708 #define TARGET_NUM_MSDU_DESC            (1024 + 400)
0709 #define TARGET_MAX_FRAG_ENTRIES         0
0710 
0711 /* Target specific defines for 10.X firmware */
0712 #define TARGET_10X_NUM_VDEVS            16
0713 #define TARGET_10X_NUM_PEER_AST         2
0714 #define TARGET_10X_NUM_WDS_ENTRIES      32
0715 #define TARGET_10X_DMA_BURST_SIZE       0
0716 #define TARGET_10X_MAC_AGGR_DELIM       0
0717 #define TARGET_10X_AST_SKID_LIMIT       128
0718 #define TARGET_10X_NUM_STATIONS         128
0719 #define TARGET_10X_TX_STATS_NUM_STATIONS    118
0720 #define TARGET_10X_NUM_PEERS            ((TARGET_10X_NUM_STATIONS) + \
0721                          (TARGET_10X_NUM_VDEVS))
0722 #define TARGET_10X_TX_STATS_NUM_PEERS       ((TARGET_10X_TX_STATS_NUM_STATIONS) + \
0723                          (TARGET_10X_NUM_VDEVS))
0724 #define TARGET_10X_NUM_OFFLOAD_PEERS        0
0725 #define TARGET_10X_NUM_OFFLOAD_REORDER_BUFS 0
0726 #define TARGET_10X_NUM_PEER_KEYS        2
0727 #define TARGET_10X_NUM_TIDS_MAX         256
0728 #define TARGET_10X_NUM_TIDS         min((TARGET_10X_NUM_TIDS_MAX), \
0729                             (TARGET_10X_NUM_PEERS) * 2)
0730 #define TARGET_10X_TX_STATS_NUM_TIDS        min((TARGET_10X_NUM_TIDS_MAX), \
0731                             (TARGET_10X_TX_STATS_NUM_PEERS) * 2)
0732 #define TARGET_10X_TX_CHAIN_MASK        (BIT(0) | BIT(1) | BIT(2))
0733 #define TARGET_10X_RX_CHAIN_MASK        (BIT(0) | BIT(1) | BIT(2))
0734 #define TARGET_10X_RX_TIMEOUT_LO_PRI        100
0735 #define TARGET_10X_RX_TIMEOUT_HI_PRI        40
0736 #define TARGET_10X_SCAN_MAX_PENDING_REQS    4
0737 #define TARGET_10X_BMISS_OFFLOAD_MAX_VDEV   2
0738 #define TARGET_10X_ROAM_OFFLOAD_MAX_VDEV    2
0739 #define TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES 8
0740 #define TARGET_10X_GTK_OFFLOAD_MAX_VDEV     3
0741 #define TARGET_10X_NUM_MCAST_GROUPS     0
0742 #define TARGET_10X_NUM_MCAST_TABLE_ELEMS    0
0743 #define TARGET_10X_MCAST2UCAST_MODE     ATH10K_MCAST2UCAST_DISABLED
0744 #define TARGET_10X_TX_DBG_LOG_SIZE      1024
0745 #define TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
0746 #define TARGET_10X_VOW_CONFIG           0
0747 #define TARGET_10X_NUM_MSDU_DESC        (1024 + 400)
0748 #define TARGET_10X_MAX_FRAG_ENTRIES     0
0749 
0750 /* 10.2 parameters */
0751 #define TARGET_10_2_DMA_BURST_SIZE      0
0752 
0753 /* Target specific defines for WMI-TLV firmware */
0754 #define TARGET_TLV_NUM_VDEVS            4
0755 #define TARGET_TLV_NUM_STATIONS         32
0756 #define TARGET_TLV_NUM_PEERS            33
0757 #define TARGET_TLV_NUM_TDLS_VDEVS       1
0758 #define TARGET_TLV_NUM_TIDS         ((TARGET_TLV_NUM_PEERS) * 2)
0759 #define TARGET_TLV_NUM_MSDU_DESC        (1024 + 32)
0760 #define TARGET_TLV_NUM_MSDU_DESC_HL     1024
0761 #define TARGET_TLV_NUM_WOW_PATTERNS     22
0762 #define TARGET_TLV_MGMT_NUM_MSDU_DESC       (50)
0763 
0764 /* Target specific defines for WMI-HL-1.0 firmware */
0765 #define TARGET_HL_TLV_NUM_PEERS         33
0766 #define TARGET_HL_TLV_AST_SKID_LIMIT        16
0767 #define TARGET_HL_TLV_NUM_WDS_ENTRIES       2
0768 
0769 /* Target specific defines for QCA9377 high latency firmware */
0770 #define TARGET_QCA9377_HL_NUM_PEERS     15
0771 
0772 /* Diagnostic Window */
0773 #define CE_DIAG_PIPE    7
0774 
0775 #define NUM_TARGET_CE_CONFIG_WLAN ar->hw_values->num_target_ce_config_wlan
0776 
0777 /* Target specific defines for 10.4 firmware */
0778 #define TARGET_10_4_NUM_VDEVS           16
0779 #define TARGET_10_4_NUM_STATIONS        32
0780 #define TARGET_10_4_NUM_PEERS           ((TARGET_10_4_NUM_STATIONS) + \
0781                          (TARGET_10_4_NUM_VDEVS))
0782 #define TARGET_10_4_ACTIVE_PEERS        0
0783 
0784 #define TARGET_10_4_NUM_QCACHE_PEERS_MAX    512
0785 #define TARGET_10_4_QCACHE_ACTIVE_PEERS     50
0786 #define TARGET_10_4_QCACHE_ACTIVE_PEERS_PFC 35
0787 #define TARGET_10_4_NUM_OFFLOAD_PEERS       0
0788 #define TARGET_10_4_NUM_OFFLOAD_REORDER_BUFFS   0
0789 #define TARGET_10_4_NUM_PEER_KEYS       2
0790 #define TARGET_10_4_TGT_NUM_TIDS        ((TARGET_10_4_NUM_PEERS) * 2)
0791 #define TARGET_10_4_NUM_MSDU_DESC       (1024 + 400)
0792 #define TARGET_10_4_NUM_MSDU_DESC_PFC       2500
0793 #define TARGET_10_4_AST_SKID_LIMIT      32
0794 
0795 /* 100 ms for video, best-effort, and background */
0796 #define TARGET_10_4_RX_TIMEOUT_LO_PRI       100
0797 
0798 /* 40 ms for voice */
0799 #define TARGET_10_4_RX_TIMEOUT_HI_PRI       40
0800 
0801 #define TARGET_10_4_RX_DECAP_MODE       ATH10K_HW_TXRX_NATIVE_WIFI
0802 #define TARGET_10_4_SCAN_MAX_REQS       4
0803 #define TARGET_10_4_BMISS_OFFLOAD_MAX_VDEV  3
0804 #define TARGET_10_4_ROAM_OFFLOAD_MAX_VDEV   3
0805 #define TARGET_10_4_ROAM_OFFLOAD_MAX_PROFILES   8
0806 
0807 /* Note: mcast to ucast is disabled by default */
0808 #define TARGET_10_4_NUM_MCAST_GROUPS        0
0809 #define TARGET_10_4_NUM_MCAST_TABLE_ELEMS   0
0810 #define TARGET_10_4_MCAST2UCAST_MODE        0
0811 
0812 #define TARGET_10_4_TX_DBG_LOG_SIZE     1024
0813 #define TARGET_10_4_NUM_WDS_ENTRIES     32
0814 #define TARGET_10_4_DMA_BURST_SIZE      1
0815 #define TARGET_10_4_MAC_AGGR_DELIM      0
0816 #define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
0817 #define TARGET_10_4_VOW_CONFIG          0
0818 #define TARGET_10_4_GTK_OFFLOAD_MAX_VDEV    3
0819 #define TARGET_10_4_11AC_TX_MAX_FRAGS       2
0820 #define TARGET_10_4_MAX_PEER_EXT_STATS      16
0821 #define TARGET_10_4_SMART_ANT_CAP       0
0822 #define TARGET_10_4_BK_MIN_FREE         0
0823 #define TARGET_10_4_BE_MIN_FREE         0
0824 #define TARGET_10_4_VI_MIN_FREE         0
0825 #define TARGET_10_4_VO_MIN_FREE         0
0826 #define TARGET_10_4_RX_BATCH_MODE       1
0827 #define TARGET_10_4_THERMAL_THROTTLING_CONFIG   0
0828 #define TARGET_10_4_ATF_CONFIG          0
0829 #define TARGET_10_4_IPHDR_PAD_CONFIG        1
0830 #define TARGET_10_4_QWRAP_CONFIG        0
0831 
0832 /* TDLS config */
0833 #define TARGET_10_4_NUM_TDLS_VDEVS      1
0834 #define TARGET_10_4_NUM_TDLS_BUFFER_STA     1
0835 #define TARGET_10_4_NUM_TDLS_SLEEP_STA      1
0836 
0837 /* Maximum number of Copy Engine's supported */
0838 #define CE_COUNT_MAX 12
0839 
0840 /* Number of Copy Engines supported */
0841 #define CE_COUNT ar->hw_values->ce_count
0842 
0843 /*
0844  * Granted MSIs are assigned as follows:
0845  * Firmware uses the first
0846  * Remaining MSIs, if any, are used by Copy Engines
0847  * This mapping is known to both Target firmware and Host software.
0848  * It may be changed as long as Host and Target are kept in sync.
0849  */
0850 /* MSI for firmware (errors, etc.) */
0851 #define MSI_ASSIGN_FW       0
0852 
0853 /* MSIs for Copy Engines */
0854 #define MSI_ASSIGN_CE_INITIAL   1
0855 #define MSI_ASSIGN_CE_MAX   ar->hw_values->msi_assign_ce_max
0856 
0857 /* as of IP3.7.1 */
0858 #define RTC_STATE_V_ON              ar->hw_values->rtc_state_val_on
0859 
0860 #define RTC_STATE_V_LSB             0
0861 #define RTC_STATE_V_MASK            0x00000007
0862 #define RTC_STATE_ADDRESS           0x0000
0863 #define PCIE_SOC_WAKE_V_MASK            0x00000001
0864 #define PCIE_SOC_WAKE_ADDRESS           0x0004
0865 #define PCIE_SOC_WAKE_RESET         0x00000000
0866 #define SOC_GLOBAL_RESET_ADDRESS        0x0008
0867 
0868 #define RTC_SOC_BASE_ADDRESS            ar->regs->rtc_soc_base_address
0869 #define RTC_WMAC_BASE_ADDRESS           ar->regs->rtc_wmac_base_address
0870 #define MAC_COEX_BASE_ADDRESS           0x00006000
0871 #define BT_COEX_BASE_ADDRESS            0x00007000
0872 #define SOC_PCIE_BASE_ADDRESS           0x00008000
0873 #define SOC_CORE_BASE_ADDRESS           ar->regs->soc_core_base_address
0874 #define WLAN_UART_BASE_ADDRESS          0x0000c000
0875 #define WLAN_SI_BASE_ADDRESS            0x00010000
0876 #define WLAN_GPIO_BASE_ADDRESS          0x00014000
0877 #define WLAN_ANALOG_INTF_BASE_ADDRESS       0x0001c000
0878 #define WLAN_MAC_BASE_ADDRESS           ar->regs->wlan_mac_base_address
0879 #define EFUSE_BASE_ADDRESS          0x00030000
0880 #define FPGA_REG_BASE_ADDRESS           0x00039000
0881 #define WLAN_UART2_BASE_ADDRESS         0x00054c00
0882 #define CE_WRAPPER_BASE_ADDRESS         ar->regs->ce_wrapper_base_address
0883 #define CE0_BASE_ADDRESS            ar->regs->ce0_base_address
0884 #define CE1_BASE_ADDRESS            ar->regs->ce1_base_address
0885 #define CE2_BASE_ADDRESS            ar->regs->ce2_base_address
0886 #define CE3_BASE_ADDRESS            ar->regs->ce3_base_address
0887 #define CE4_BASE_ADDRESS            ar->regs->ce4_base_address
0888 #define CE5_BASE_ADDRESS            ar->regs->ce5_base_address
0889 #define CE6_BASE_ADDRESS            ar->regs->ce6_base_address
0890 #define CE7_BASE_ADDRESS            ar->regs->ce7_base_address
0891 #define DBI_BASE_ADDRESS            0x00060000
0892 #define WLAN_ANALOG_INTF_PCIE_BASE_ADDRESS  0x0006c000
0893 #define PCIE_LOCAL_BASE_ADDRESS     ar->regs->pcie_local_base_address
0894 
0895 #define SOC_RESET_CONTROL_ADDRESS       0x00000000
0896 #define SOC_RESET_CONTROL_OFFSET        0x00000000
0897 #define SOC_RESET_CONTROL_SI0_RST_MASK      ar->regs->soc_reset_control_si0_rst_mask
0898 #define SOC_RESET_CONTROL_CE_RST_MASK       ar->regs->soc_reset_control_ce_rst_mask
0899 #define SOC_RESET_CONTROL_CPU_WARM_RST_MASK 0x00000040
0900 #define SOC_CPU_CLOCK_OFFSET            0x00000020
0901 #define SOC_CPU_CLOCK_STANDARD_LSB      0
0902 #define SOC_CPU_CLOCK_STANDARD_MASK     0x00000003
0903 #define SOC_CLOCK_CONTROL_OFFSET        0x00000028
0904 #define SOC_CLOCK_CONTROL_SI0_CLK_MASK      0x00000001
0905 #define SOC_SYSTEM_SLEEP_OFFSET         0x000000c4
0906 #define SOC_LPO_CAL_OFFSET          0x000000e0
0907 #define SOC_LPO_CAL_ENABLE_LSB          20
0908 #define SOC_LPO_CAL_ENABLE_MASK         0x00100000
0909 #define SOC_LF_TIMER_CONTROL0_ADDRESS       0x00000050
0910 #define SOC_LF_TIMER_CONTROL0_ENABLE_MASK   0x00000004
0911 
0912 #define SOC_CHIP_ID_ADDRESS         ar->regs->soc_chip_id_address
0913 #define SOC_CHIP_ID_REV_LSB         8
0914 #define SOC_CHIP_ID_REV_MASK            0x00000f00
0915 
0916 #define WLAN_RESET_CONTROL_COLD_RST_MASK    0x00000008
0917 #define WLAN_RESET_CONTROL_WARM_RST_MASK    0x00000004
0918 #define WLAN_SYSTEM_SLEEP_DISABLE_LSB       0
0919 #define WLAN_SYSTEM_SLEEP_DISABLE_MASK      0x00000001
0920 
0921 #define WLAN_GPIO_PIN0_ADDRESS          0x00000028
0922 #define WLAN_GPIO_PIN0_CONFIG_LSB       11
0923 #define WLAN_GPIO_PIN0_CONFIG_MASK      0x00007800
0924 #define WLAN_GPIO_PIN0_PAD_PULL_LSB     5
0925 #define WLAN_GPIO_PIN0_PAD_PULL_MASK        0x00000060
0926 #define WLAN_GPIO_PIN1_ADDRESS          0x0000002c
0927 #define WLAN_GPIO_PIN1_CONFIG_MASK      0x00007800
0928 #define WLAN_GPIO_PIN10_ADDRESS         0x00000050
0929 #define WLAN_GPIO_PIN11_ADDRESS         0x00000054
0930 #define WLAN_GPIO_PIN12_ADDRESS         0x00000058
0931 #define WLAN_GPIO_PIN13_ADDRESS         0x0000005c
0932 
0933 #define CLOCK_GPIO_OFFSET           0xffffffff
0934 #define CLOCK_GPIO_BT_CLK_OUT_EN_LSB        0
0935 #define CLOCK_GPIO_BT_CLK_OUT_EN_MASK       0
0936 
0937 #define SI_CONFIG_OFFSET            0x00000000
0938 #define SI_CONFIG_ERR_INT_LSB           19
0939 #define SI_CONFIG_ERR_INT_MASK          0x00080000
0940 #define SI_CONFIG_BIDIR_OD_DATA_LSB     18
0941 #define SI_CONFIG_BIDIR_OD_DATA_MASK        0x00040000
0942 #define SI_CONFIG_I2C_LSB           16
0943 #define SI_CONFIG_I2C_MASK          0x00010000
0944 #define SI_CONFIG_POS_SAMPLE_LSB        7
0945 #define SI_CONFIG_POS_SAMPLE_MASK       0x00000080
0946 #define SI_CONFIG_INACTIVE_DATA_LSB     5
0947 #define SI_CONFIG_INACTIVE_DATA_MASK        0x00000020
0948 #define SI_CONFIG_INACTIVE_CLK_LSB      4
0949 #define SI_CONFIG_INACTIVE_CLK_MASK     0x00000010
0950 #define SI_CONFIG_DIVIDER_LSB           0
0951 #define SI_CONFIG_DIVIDER_MASK          0x0000000f
0952 #define SI_CS_OFFSET                0x00000004
0953 #define SI_CS_DONE_ERR_LSB          10
0954 #define SI_CS_DONE_ERR_MASK         0x00000400
0955 #define SI_CS_DONE_INT_LSB          9
0956 #define SI_CS_DONE_INT_MASK         0x00000200
0957 #define SI_CS_START_LSB             8
0958 #define SI_CS_START_MASK            0x00000100
0959 #define SI_CS_RX_CNT_LSB            4
0960 #define SI_CS_RX_CNT_MASK           0x000000f0
0961 #define SI_CS_TX_CNT_LSB            0
0962 #define SI_CS_TX_CNT_MASK           0x0000000f
0963 
0964 #define SI_TX_DATA0_OFFSET          0x00000008
0965 #define SI_TX_DATA1_OFFSET          0x0000000c
0966 #define SI_RX_DATA0_OFFSET          0x00000010
0967 #define SI_RX_DATA1_OFFSET          0x00000014
0968 
0969 #define CORE_CTRL_CPU_INTR_MASK         0x00002000
0970 #define CORE_CTRL_PCIE_REG_31_MASK      0x00000800
0971 #define CORE_CTRL_ADDRESS           0x0000
0972 #define PCIE_INTR_ENABLE_ADDRESS        0x0008
0973 #define PCIE_INTR_CAUSE_ADDRESS         0x000c
0974 #define PCIE_INTR_CLR_ADDRESS           ar->regs->pcie_intr_clr_address
0975 #define SCRATCH_3_ADDRESS           ar->regs->scratch_3_address
0976 #define CPU_INTR_ADDRESS            0x0010
0977 #define FW_RAM_CONFIG_ADDRESS           0x0018
0978 
0979 #define CCNT_TO_MSEC(ar, x) ((x) / ar->hw_params.channel_counters_freq_hz)
0980 
0981 /* Firmware indications to the Host via SCRATCH_3 register. */
0982 #define FW_INDICATOR_ADDRESS            ar->regs->fw_indicator_address
0983 #define FW_IND_EVENT_PENDING            1
0984 #define FW_IND_INITIALIZED          2
0985 #define FW_IND_HOST_READY           0x80000000
0986 
0987 /* HOST_REG interrupt from firmware */
0988 #define PCIE_INTR_FIRMWARE_MASK         ar->regs->pcie_intr_fw_mask
0989 #define PCIE_INTR_CE_MASK_ALL           ar->regs->pcie_intr_ce_mask_all
0990 
0991 #define DRAM_BASE_ADDRESS           0x00400000
0992 
0993 #define PCIE_BAR_REG_ADDRESS            0x40030
0994 
0995 #define MISSING 0
0996 
0997 #define SYSTEM_SLEEP_OFFSET         SOC_SYSTEM_SLEEP_OFFSET
0998 #define WLAN_SYSTEM_SLEEP_OFFSET        SOC_SYSTEM_SLEEP_OFFSET
0999 #define WLAN_RESET_CONTROL_OFFSET       SOC_RESET_CONTROL_OFFSET
1000 #define CLOCK_CONTROL_OFFSET            SOC_CLOCK_CONTROL_OFFSET
1001 #define CLOCK_CONTROL_SI0_CLK_MASK      SOC_CLOCK_CONTROL_SI0_CLK_MASK
1002 #define RESET_CONTROL_MBOX_RST_MASK     MISSING
1003 #define RESET_CONTROL_SI0_RST_MASK      SOC_RESET_CONTROL_SI0_RST_MASK
1004 #define GPIO_BASE_ADDRESS           WLAN_GPIO_BASE_ADDRESS
1005 #define GPIO_PIN0_OFFSET            WLAN_GPIO_PIN0_ADDRESS
1006 #define GPIO_PIN1_OFFSET            WLAN_GPIO_PIN1_ADDRESS
1007 #define GPIO_PIN0_CONFIG_LSB            WLAN_GPIO_PIN0_CONFIG_LSB
1008 #define GPIO_PIN0_CONFIG_MASK           WLAN_GPIO_PIN0_CONFIG_MASK
1009 #define GPIO_PIN0_PAD_PULL_LSB          WLAN_GPIO_PIN0_PAD_PULL_LSB
1010 #define GPIO_PIN0_PAD_PULL_MASK         WLAN_GPIO_PIN0_PAD_PULL_MASK
1011 #define GPIO_PIN1_CONFIG_MASK           WLAN_GPIO_PIN1_CONFIG_MASK
1012 #define SI_BASE_ADDRESS             WLAN_SI_BASE_ADDRESS
1013 #define SCRATCH_BASE_ADDRESS            SOC_CORE_BASE_ADDRESS
1014 #define LOCAL_SCRATCH_OFFSET            0x18
1015 #define CPU_CLOCK_OFFSET            SOC_CPU_CLOCK_OFFSET
1016 #define LPO_CAL_OFFSET              SOC_LPO_CAL_OFFSET
1017 #define GPIO_PIN10_OFFSET           WLAN_GPIO_PIN10_ADDRESS
1018 #define GPIO_PIN11_OFFSET           WLAN_GPIO_PIN11_ADDRESS
1019 #define GPIO_PIN12_OFFSET           WLAN_GPIO_PIN12_ADDRESS
1020 #define GPIO_PIN13_OFFSET           WLAN_GPIO_PIN13_ADDRESS
1021 #define CPU_CLOCK_STANDARD_LSB          SOC_CPU_CLOCK_STANDARD_LSB
1022 #define CPU_CLOCK_STANDARD_MASK         SOC_CPU_CLOCK_STANDARD_MASK
1023 #define LPO_CAL_ENABLE_LSB          SOC_LPO_CAL_ENABLE_LSB
1024 #define LPO_CAL_ENABLE_MASK         SOC_LPO_CAL_ENABLE_MASK
1025 #define ANALOG_INTF_BASE_ADDRESS        WLAN_ANALOG_INTF_BASE_ADDRESS
1026 #define MBOX_BASE_ADDRESS           MISSING
1027 #define INT_STATUS_ENABLE_ERROR_LSB     MISSING
1028 #define INT_STATUS_ENABLE_ERROR_MASK        MISSING
1029 #define INT_STATUS_ENABLE_CPU_LSB       MISSING
1030 #define INT_STATUS_ENABLE_CPU_MASK      MISSING
1031 #define INT_STATUS_ENABLE_COUNTER_LSB       MISSING
1032 #define INT_STATUS_ENABLE_COUNTER_MASK      MISSING
1033 #define INT_STATUS_ENABLE_MBOX_DATA_LSB     MISSING
1034 #define INT_STATUS_ENABLE_MBOX_DATA_MASK    MISSING
1035 #define ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB    MISSING
1036 #define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK   MISSING
1037 #define ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB MISSING
1038 #define ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK    MISSING
1039 #define COUNTER_INT_STATUS_ENABLE_BIT_LSB   MISSING
1040 #define COUNTER_INT_STATUS_ENABLE_BIT_MASK  MISSING
1041 #define INT_STATUS_ENABLE_ADDRESS       MISSING
1042 #define CPU_INT_STATUS_ENABLE_BIT_LSB       MISSING
1043 #define CPU_INT_STATUS_ENABLE_BIT_MASK      MISSING
1044 #define HOST_INT_STATUS_ADDRESS         MISSING
1045 #define CPU_INT_STATUS_ADDRESS          MISSING
1046 #define ERROR_INT_STATUS_ADDRESS        MISSING
1047 #define ERROR_INT_STATUS_WAKEUP_MASK        MISSING
1048 #define ERROR_INT_STATUS_WAKEUP_LSB     MISSING
1049 #define ERROR_INT_STATUS_RX_UNDERFLOW_MASK  MISSING
1050 #define ERROR_INT_STATUS_RX_UNDERFLOW_LSB   MISSING
1051 #define ERROR_INT_STATUS_TX_OVERFLOW_MASK   MISSING
1052 #define ERROR_INT_STATUS_TX_OVERFLOW_LSB    MISSING
1053 #define COUNT_DEC_ADDRESS           MISSING
1054 #define HOST_INT_STATUS_CPU_MASK        MISSING
1055 #define HOST_INT_STATUS_CPU_LSB         MISSING
1056 #define HOST_INT_STATUS_ERROR_MASK      MISSING
1057 #define HOST_INT_STATUS_ERROR_LSB       MISSING
1058 #define HOST_INT_STATUS_COUNTER_MASK        MISSING
1059 #define HOST_INT_STATUS_COUNTER_LSB     MISSING
1060 #define RX_LOOKAHEAD_VALID_ADDRESS      MISSING
1061 #define WINDOW_DATA_ADDRESS         MISSING
1062 #define WINDOW_READ_ADDR_ADDRESS        MISSING
1063 #define WINDOW_WRITE_ADDR_ADDRESS       MISSING
1064 
1065 #define QCA9887_1_0_I2C_SDA_GPIO_PIN        5
1066 #define QCA9887_1_0_I2C_SDA_PIN_CONFIG      3
1067 #define QCA9887_1_0_SI_CLK_GPIO_PIN     17
1068 #define QCA9887_1_0_SI_CLK_PIN_CONFIG       3
1069 #define QCA9887_1_0_GPIO_ENABLE_W1TS_LOW_ADDRESS 0x00000010
1070 
1071 #define QCA9887_EEPROM_SELECT_READ      0xa10000a0
1072 #define QCA9887_EEPROM_ADDR_HI_MASK     0x0000ff00
1073 #define QCA9887_EEPROM_ADDR_HI_LSB      8
1074 #define QCA9887_EEPROM_ADDR_LO_MASK     0x00ff0000
1075 #define QCA9887_EEPROM_ADDR_LO_LSB      16
1076 
1077 #define MBOX_RESET_CONTROL_ADDRESS      0x00000000
1078 #define MBOX_HOST_INT_STATUS_ADDRESS        0x00000800
1079 #define MBOX_HOST_INT_STATUS_ERROR_LSB      7
1080 #define MBOX_HOST_INT_STATUS_ERROR_MASK     0x00000080
1081 #define MBOX_HOST_INT_STATUS_CPU_LSB        6
1082 #define MBOX_HOST_INT_STATUS_CPU_MASK       0x00000040
1083 #define MBOX_HOST_INT_STATUS_COUNTER_LSB    4
1084 #define MBOX_HOST_INT_STATUS_COUNTER_MASK   0x00000010
1085 #define MBOX_CPU_INT_STATUS_ADDRESS     0x00000801
1086 #define MBOX_ERROR_INT_STATUS_ADDRESS       0x00000802
1087 #define MBOX_ERROR_INT_STATUS_WAKEUP_LSB    2
1088 #define MBOX_ERROR_INT_STATUS_WAKEUP_MASK   0x00000004
1089 #define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_LSB  1
1090 #define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_MASK 0x00000002
1091 #define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_LSB   0
1092 #define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_MASK  0x00000001
1093 #define MBOX_COUNTER_INT_STATUS_ADDRESS     0x00000803
1094 #define MBOX_COUNTER_INT_STATUS_COUNTER_LSB 0
1095 #define MBOX_COUNTER_INT_STATUS_COUNTER_MASK    0x000000ff
1096 #define MBOX_RX_LOOKAHEAD_VALID_ADDRESS     0x00000805
1097 #define MBOX_INT_STATUS_ENABLE_ADDRESS      0x00000828
1098 #define MBOX_INT_STATUS_ENABLE_ERROR_LSB    7
1099 #define MBOX_INT_STATUS_ENABLE_ERROR_MASK   0x00000080
1100 #define MBOX_INT_STATUS_ENABLE_CPU_LSB      6
1101 #define MBOX_INT_STATUS_ENABLE_CPU_MASK     0x00000040
1102 #define MBOX_INT_STATUS_ENABLE_INT_LSB      5
1103 #define MBOX_INT_STATUS_ENABLE_INT_MASK     0x00000020
1104 #define MBOX_INT_STATUS_ENABLE_COUNTER_LSB  4
1105 #define MBOX_INT_STATUS_ENABLE_COUNTER_MASK 0x00000010
1106 #define MBOX_INT_STATUS_ENABLE_MBOX_DATA_LSB    0
1107 #define MBOX_INT_STATUS_ENABLE_MBOX_DATA_MASK   0x0000000f
1108 #define MBOX_CPU_INT_STATUS_ENABLE_ADDRESS  0x00000819
1109 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_LSB  0
1110 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_MASK 0x000000ff
1111 #define MBOX_CPU_STATUS_ENABLE_ASSERT_MASK 0x00000001
1112 #define MBOX_ERROR_STATUS_ENABLE_ADDRESS    0x0000081a
1113 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB  1
1114 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x00000002
1115 #define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB   0
1116 #define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK  0x00000001
1117 #define MBOX_COUNTER_INT_STATUS_ENABLE_ADDRESS  0x0000081b
1118 #define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_LSB  0
1119 #define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_MASK 0x000000ff
1120 #define MBOX_COUNT_ADDRESS          0x00000820
1121 #define MBOX_COUNT_DEC_ADDRESS          0x00000840
1122 #define MBOX_WINDOW_DATA_ADDRESS        0x00000874
1123 #define MBOX_WINDOW_WRITE_ADDR_ADDRESS      0x00000878
1124 #define MBOX_WINDOW_READ_ADDR_ADDRESS       0x0000087c
1125 #define MBOX_CPU_DBG_SEL_ADDRESS        0x00000883
1126 #define MBOX_CPU_DBG_ADDRESS            0x00000884
1127 #define MBOX_RTC_BASE_ADDRESS           0x00000000
1128 #define MBOX_GPIO_BASE_ADDRESS          0x00005000
1129 #define MBOX_MBOX_BASE_ADDRESS          0x00008000
1130 
1131 #define RTC_STATE_V_GET(x) (((x) & RTC_STATE_V_MASK) >> RTC_STATE_V_LSB)
1132 
1133 /* Register definitions for first generation ath10k cards. These cards include
1134  * a mac thich has a register allocation similar to ath9k and at least some
1135  * registers including the ones relevant for modifying the coverage class are
1136  * identical to the ath9k definitions.
1137  * These registers are usually managed by the ath10k firmware. However by
1138  * overriding them it is possible to support coverage class modifications.
1139  */
1140 #define WAVE1_PCU_ACK_CTS_TIMEOUT       0x8014
1141 #define WAVE1_PCU_ACK_CTS_TIMEOUT_MAX       0x00003FFF
1142 #define WAVE1_PCU_ACK_CTS_TIMEOUT_ACK_MASK  0x00003FFF
1143 #define WAVE1_PCU_ACK_CTS_TIMEOUT_ACK_LSB   0
1144 #define WAVE1_PCU_ACK_CTS_TIMEOUT_CTS_MASK  0x3FFF0000
1145 #define WAVE1_PCU_ACK_CTS_TIMEOUT_CTS_LSB   16
1146 
1147 #define WAVE1_PCU_GBL_IFS_SLOT          0x1070
1148 #define WAVE1_PCU_GBL_IFS_SLOT_MASK     0x0000FFFF
1149 #define WAVE1_PCU_GBL_IFS_SLOT_MAX      0x0000FFFF
1150 #define WAVE1_PCU_GBL_IFS_SLOT_LSB      0
1151 #define WAVE1_PCU_GBL_IFS_SLOT_RESV0        0xFFFF0000
1152 
1153 #define WAVE1_PHYCLK                0x801C
1154 #define WAVE1_PHYCLK_USEC_MASK          0x0000007F
1155 #define WAVE1_PHYCLK_USEC_LSB           0
1156 
1157 /* qca6174 PLL offset/mask */
1158 #define SOC_CORE_CLK_CTRL_OFFSET        0x00000114
1159 #define SOC_CORE_CLK_CTRL_DIV_LSB       0
1160 #define SOC_CORE_CLK_CTRL_DIV_MASK      0x00000007
1161 
1162 #define EFUSE_OFFSET                0x0000032c
1163 #define EFUSE_XTAL_SEL_LSB          8
1164 #define EFUSE_XTAL_SEL_MASK         0x00000700
1165 
1166 #define BB_PLL_CONFIG_OFFSET            0x000002f4
1167 #define BB_PLL_CONFIG_FRAC_LSB          0
1168 #define BB_PLL_CONFIG_FRAC_MASK         0x0003ffff
1169 #define BB_PLL_CONFIG_OUTDIV_LSB        18
1170 #define BB_PLL_CONFIG_OUTDIV_MASK       0x001c0000
1171 
1172 #define WLAN_PLL_SETTLE_OFFSET          0x0018
1173 #define WLAN_PLL_SETTLE_TIME_LSB        0
1174 #define WLAN_PLL_SETTLE_TIME_MASK       0x000007ff
1175 
1176 #define WLAN_PLL_CONTROL_OFFSET         0x0014
1177 #define WLAN_PLL_CONTROL_DIV_LSB        0
1178 #define WLAN_PLL_CONTROL_DIV_MASK       0x000003ff
1179 #define WLAN_PLL_CONTROL_REFDIV_LSB     10
1180 #define WLAN_PLL_CONTROL_REFDIV_MASK        0x00003c00
1181 #define WLAN_PLL_CONTROL_BYPASS_LSB     16
1182 #define WLAN_PLL_CONTROL_BYPASS_MASK        0x00010000
1183 #define WLAN_PLL_CONTROL_NOPWD_LSB      18
1184 #define WLAN_PLL_CONTROL_NOPWD_MASK     0x00040000
1185 
1186 #define RTC_SYNC_STATUS_OFFSET          0x0244
1187 #define RTC_SYNC_STATUS_PLL_CHANGING_LSB    5
1188 #define RTC_SYNC_STATUS_PLL_CHANGING_MASK   0x00000020
1189 /* qca6174 PLL offset/mask end */
1190 
1191 /* CPU_ADDR_MSB is a register, bit[3:0] is to specify which memory
1192  * region is accessed. The memory region size is 1M.
1193  * If host wants to access 0xX12345 at target, then CPU_ADDR_MSB[3:0]
1194  * is 0xX.
1195  * The following MACROs are defined to get the 0xX and the size limit.
1196  */
1197 #define CPU_ADDR_MSB_REGION_MASK    GENMASK(23, 20)
1198 #define CPU_ADDR_MSB_REGION_VAL(X)  FIELD_GET(CPU_ADDR_MSB_REGION_MASK, X)
1199 #define REGION_ACCESS_SIZE_LIMIT    0x100000
1200 #define REGION_ACCESS_SIZE_MASK     (REGION_ACCESS_SIZE_LIMIT - 1)
1201 
1202 #endif /* _HW_H_ */