hw.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. /* SPDX-License-Identifier: ISC */
  2. /*
  3. * Copyright (c) 2005-2011 Atheros Communications Inc.
  4. * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
  5. * Copyright (c) 2018 The Linux Foundation. All rights reserved.
  6. */
  7. #ifndef _HW_H_
  8. #define _HW_H_
  9. #include "targaddrs.h"
  10. enum ath10k_bus {
  11. ATH10K_BUS_PCI,
  12. ATH10K_BUS_AHB,
  13. ATH10K_BUS_SDIO,
  14. ATH10K_BUS_USB,
  15. ATH10K_BUS_SNOC,
  16. };
  17. #define ATH10K_FW_DIR "ath10k"
  18. #define QCA988X_2_0_DEVICE_ID_UBNT (0x11ac)
  19. #define QCA988X_2_0_DEVICE_ID (0x003c)
  20. #define QCA6164_2_1_DEVICE_ID (0x0041)
  21. #define QCA6174_2_1_DEVICE_ID (0x003e)
  22. #define QCA6174_3_2_DEVICE_ID (0x0042)
  23. #define QCA99X0_2_0_DEVICE_ID (0x0040)
  24. #define QCA9888_2_0_DEVICE_ID (0x0056)
  25. #define QCA9984_1_0_DEVICE_ID (0x0046)
  26. #define QCA9377_1_0_DEVICE_ID (0x0042)
  27. #define QCA9887_1_0_DEVICE_ID (0x0050)
  28. /* QCA988X 1.0 definitions (unsupported) */
  29. #define QCA988X_HW_1_0_CHIP_ID_REV 0x0
  30. /* QCA988X 2.0 definitions */
  31. #define QCA988X_HW_2_0_VERSION 0x4100016c
  32. #define QCA988X_HW_2_0_CHIP_ID_REV 0x2
  33. #define QCA988X_HW_2_0_FW_DIR ATH10K_FW_DIR "/QCA988X/hw2.0"
  34. #define QCA988X_HW_2_0_BOARD_DATA_FILE "board.bin"
  35. #define QCA988X_HW_2_0_PATCH_LOAD_ADDR 0x1234
  36. /* QCA9887 1.0 definitions */
  37. #define QCA9887_HW_1_0_VERSION 0x4100016d
  38. #define QCA9887_HW_1_0_CHIP_ID_REV 0
  39. #define QCA9887_HW_1_0_FW_DIR ATH10K_FW_DIR "/QCA9887/hw1.0"
  40. #define QCA9887_HW_1_0_BOARD_DATA_FILE "board.bin"
  41. #define QCA9887_HW_1_0_PATCH_LOAD_ADDR 0x1234
  42. /* QCA6174 target BMI version signatures */
  43. #define QCA6174_HW_1_0_VERSION 0x05000000
  44. #define QCA6174_HW_1_1_VERSION 0x05000001
  45. #define QCA6174_HW_1_3_VERSION 0x05000003
  46. #define QCA6174_HW_2_1_VERSION 0x05010000
  47. #define QCA6174_HW_3_0_VERSION 0x05020000
  48. #define QCA6174_HW_3_2_VERSION 0x05030000
  49. /* QCA9377 target BMI version signatures */
  50. #define QCA9377_HW_1_0_DEV_VERSION 0x05020000
  51. #define QCA9377_HW_1_1_DEV_VERSION 0x05020001
  52. enum qca6174_pci_rev {
  53. QCA6174_PCI_REV_1_1 = 0x11,
  54. QCA6174_PCI_REV_1_3 = 0x13,
  55. QCA6174_PCI_REV_2_0 = 0x20,
  56. QCA6174_PCI_REV_3_0 = 0x30,
  57. };
  58. enum qca6174_chip_id_rev {
  59. QCA6174_HW_1_0_CHIP_ID_REV = 0,
  60. QCA6174_HW_1_1_CHIP_ID_REV = 1,
  61. QCA6174_HW_1_3_CHIP_ID_REV = 2,
  62. QCA6174_HW_2_1_CHIP_ID_REV = 4,
  63. QCA6174_HW_2_2_CHIP_ID_REV = 5,
  64. QCA6174_HW_3_0_CHIP_ID_REV = 8,
  65. QCA6174_HW_3_1_CHIP_ID_REV = 9,
  66. QCA6174_HW_3_2_CHIP_ID_REV = 10,
  67. };
  68. enum qca9377_chip_id_rev {
  69. QCA9377_HW_1_0_CHIP_ID_REV = 0x0,
  70. QCA9377_HW_1_1_CHIP_ID_REV = 0x1,
  71. };
  72. #define QCA6174_HW_2_1_FW_DIR ATH10K_FW_DIR "/QCA6174/hw2.1"
  73. #define QCA6174_HW_2_1_BOARD_DATA_FILE "board.bin"
  74. #define QCA6174_HW_2_1_PATCH_LOAD_ADDR 0x1234
  75. #define QCA6174_HW_3_0_FW_DIR ATH10K_FW_DIR "/QCA6174/hw3.0"
  76. #define QCA6174_HW_3_0_BOARD_DATA_FILE "board.bin"
  77. #define QCA6174_HW_3_0_PATCH_LOAD_ADDR 0x1234
  78. /* QCA99X0 1.0 definitions (unsupported) */
  79. #define QCA99X0_HW_1_0_CHIP_ID_REV 0x0
  80. /* QCA99X0 2.0 definitions */
  81. #define QCA99X0_HW_2_0_DEV_VERSION 0x01000000
  82. #define QCA99X0_HW_2_0_CHIP_ID_REV 0x1
  83. #define QCA99X0_HW_2_0_FW_DIR ATH10K_FW_DIR "/QCA99X0/hw2.0"
  84. #define QCA99X0_HW_2_0_BOARD_DATA_FILE "board.bin"
  85. #define QCA99X0_HW_2_0_PATCH_LOAD_ADDR 0x1234
  86. /* QCA9984 1.0 defines */
  87. #define QCA9984_HW_1_0_DEV_VERSION 0x1000000
  88. #define QCA9984_HW_DEV_TYPE 0xa
  89. #define QCA9984_HW_1_0_CHIP_ID_REV 0x0
  90. #define QCA9984_HW_1_0_FW_DIR ATH10K_FW_DIR "/QCA9984/hw1.0"
  91. #define QCA9984_HW_1_0_BOARD_DATA_FILE "board.bin"
  92. #define QCA9984_HW_1_0_EBOARD_DATA_FILE "eboard.bin"
  93. #define QCA9984_HW_1_0_PATCH_LOAD_ADDR 0x1234
  94. /* QCA9888 2.0 defines */
  95. #define QCA9888_HW_2_0_DEV_VERSION 0x1000000
  96. #define QCA9888_HW_DEV_TYPE 0xc
  97. #define QCA9888_HW_2_0_CHIP_ID_REV 0x0
  98. #define QCA9888_HW_2_0_FW_DIR ATH10K_FW_DIR "/QCA9888/hw2.0"
  99. #define QCA9888_HW_2_0_BOARD_DATA_FILE "board.bin"
  100. #define QCA9888_HW_2_0_PATCH_LOAD_ADDR 0x1234
  101. /* QCA9377 1.0 definitions */
  102. #define QCA9377_HW_1_0_FW_DIR ATH10K_FW_DIR "/QCA9377/hw1.0"
  103. #define QCA9377_HW_1_0_BOARD_DATA_FILE "board.bin"
  104. #define QCA9377_HW_1_0_PATCH_LOAD_ADDR 0x1234
  105. /* QCA4019 1.0 definitions */
  106. #define QCA4019_HW_1_0_DEV_VERSION 0x01000000
  107. #define QCA4019_HW_1_0_FW_DIR ATH10K_FW_DIR "/QCA4019/hw1.0"
  108. #define QCA4019_HW_1_0_BOARD_DATA_FILE "board.bin"
  109. #define QCA4019_HW_1_0_PATCH_LOAD_ADDR 0x1234
  110. /* WCN3990 1.0 definitions */
  111. #define WCN3990_HW_1_0_DEV_VERSION ATH10K_HW_WCN3990
  112. #define WCN3990_HW_1_0_FW_DIR ATH10K_FW_DIR "/WCN3990/hw1.0"
  113. #define ATH10K_FW_FILE_BASE "firmware"
  114. #define ATH10K_FW_API_MAX 6
  115. #define ATH10K_FW_API_MIN 2
  116. #define ATH10K_FW_API2_FILE "firmware-2.bin"
  117. #define ATH10K_FW_API3_FILE "firmware-3.bin"
  118. /* added support for ATH10K_FW_IE_WMI_OP_VERSION */
  119. #define ATH10K_FW_API4_FILE "firmware-4.bin"
  120. /* HTT id conflict fix for management frames over HTT */
  121. #define ATH10K_FW_API5_FILE "firmware-5.bin"
  122. /* the firmware-6.bin blob */
  123. #define ATH10K_FW_API6_FILE "firmware-6.bin"
  124. #define ATH10K_FW_UTF_FILE "utf.bin"
  125. #define ATH10K_FW_UTF_API2_FILE "utf-2.bin"
  126. #define ATH10K_FW_UTF_FILE_BASE "utf"
  127. /* includes also the null byte */
  128. #define ATH10K_FIRMWARE_MAGIC "QCA-ATH10K"
  129. #define ATH10K_BOARD_MAGIC "QCA-ATH10K-BOARD"
  130. #define ATH10K_BOARD_API2_FILE "board-2.bin"
  131. #define REG_DUMP_COUNT_QCA988X 60
  132. struct ath10k_fw_ie {
  133. __le32 id;
  134. __le32 len;
  135. u8 data[];
  136. };
  137. enum ath10k_fw_ie_type {
  138. ATH10K_FW_IE_FW_VERSION = 0,
  139. ATH10K_FW_IE_TIMESTAMP = 1,
  140. ATH10K_FW_IE_FEATURES = 2,
  141. ATH10K_FW_IE_FW_IMAGE = 3,
  142. ATH10K_FW_IE_OTP_IMAGE = 4,
  143. /* WMI "operations" interface version, 32 bit value. Supported from
  144. * FW API 4 and above.
  145. */
  146. ATH10K_FW_IE_WMI_OP_VERSION = 5,
  147. /* HTT "operations" interface version, 32 bit value. Supported from
  148. * FW API 5 and above.
  149. */
  150. ATH10K_FW_IE_HTT_OP_VERSION = 6,
  151. /* Code swap image for firmware binary */
  152. ATH10K_FW_IE_FW_CODE_SWAP_IMAGE = 7,
  153. };
  154. enum ath10k_fw_wmi_op_version {
  155. ATH10K_FW_WMI_OP_VERSION_UNSET = 0,
  156. ATH10K_FW_WMI_OP_VERSION_MAIN = 1,
  157. ATH10K_FW_WMI_OP_VERSION_10_1 = 2,
  158. ATH10K_FW_WMI_OP_VERSION_10_2 = 3,
  159. ATH10K_FW_WMI_OP_VERSION_TLV = 4,
  160. ATH10K_FW_WMI_OP_VERSION_10_2_4 = 5,
  161. ATH10K_FW_WMI_OP_VERSION_10_4 = 6,
  162. /* keep last */
  163. ATH10K_FW_WMI_OP_VERSION_MAX,
  164. };
  165. enum ath10k_fw_htt_op_version {
  166. ATH10K_FW_HTT_OP_VERSION_UNSET = 0,
  167. ATH10K_FW_HTT_OP_VERSION_MAIN = 1,
  168. /* also used in 10.2 and 10.2.4 branches */
  169. ATH10K_FW_HTT_OP_VERSION_10_1 = 2,
  170. ATH10K_FW_HTT_OP_VERSION_TLV = 3,
  171. ATH10K_FW_HTT_OP_VERSION_10_4 = 4,
  172. /* keep last */
  173. ATH10K_FW_HTT_OP_VERSION_MAX,
  174. };
  175. enum ath10k_bd_ie_type {
  176. /* contains sub IEs of enum ath10k_bd_ie_board_type */
  177. ATH10K_BD_IE_BOARD = 0,
  178. ATH10K_BD_IE_BOARD_EXT = 1,
  179. };
  180. enum ath10k_bd_ie_board_type {
  181. ATH10K_BD_IE_BOARD_NAME = 0,
  182. ATH10K_BD_IE_BOARD_DATA = 1,
  183. };
  184. enum ath10k_hw_rev {
  185. ATH10K_HW_QCA988X,
  186. ATH10K_HW_QCA6174,
  187. ATH10K_HW_QCA99X0,
  188. ATH10K_HW_QCA9888,
  189. ATH10K_HW_QCA9984,
  190. ATH10K_HW_QCA9377,
  191. ATH10K_HW_QCA4019,
  192. ATH10K_HW_QCA9887,
  193. ATH10K_HW_WCN3990,
  194. };
  195. struct ath10k_hw_regs {
  196. u32 rtc_soc_base_address;
  197. u32 rtc_wmac_base_address;
  198. u32 soc_core_base_address;
  199. u32 wlan_mac_base_address;
  200. u32 ce_wrapper_base_address;
  201. u32 ce0_base_address;
  202. u32 ce1_base_address;
  203. u32 ce2_base_address;
  204. u32 ce3_base_address;
  205. u32 ce4_base_address;
  206. u32 ce5_base_address;
  207. u32 ce6_base_address;
  208. u32 ce7_base_address;
  209. u32 ce8_base_address;
  210. u32 ce9_base_address;
  211. u32 ce10_base_address;
  212. u32 ce11_base_address;
  213. u32 soc_reset_control_si0_rst_mask;
  214. u32 soc_reset_control_ce_rst_mask;
  215. u32 soc_chip_id_address;
  216. u32 scratch_3_address;
  217. u32 fw_indicator_address;
  218. u32 pcie_local_base_address;
  219. u32 ce_wrap_intr_sum_host_msi_lsb;
  220. u32 ce_wrap_intr_sum_host_msi_mask;
  221. u32 pcie_intr_fw_mask;
  222. u32 pcie_intr_ce_mask_all;
  223. u32 pcie_intr_clr_address;
  224. u32 cpu_pll_init_address;
  225. u32 cpu_speed_address;
  226. u32 core_clk_div_address;
  227. };
  228. extern const struct ath10k_hw_regs qca988x_regs;
  229. extern const struct ath10k_hw_regs qca6174_regs;
  230. extern const struct ath10k_hw_regs qca99x0_regs;
  231. extern const struct ath10k_hw_regs qca4019_regs;
  232. extern const struct ath10k_hw_regs wcn3990_regs;
  233. struct ath10k_hw_ce_regs_addr_map {
  234. u32 msb;
  235. u32 lsb;
  236. u32 mask;
  237. };
  238. struct ath10k_hw_ce_ctrl1 {
  239. u32 addr;
  240. u32 hw_mask;
  241. u32 sw_mask;
  242. u32 hw_wr_mask;
  243. u32 sw_wr_mask;
  244. u32 reset_mask;
  245. u32 reset;
  246. struct ath10k_hw_ce_regs_addr_map *src_ring;
  247. struct ath10k_hw_ce_regs_addr_map *dst_ring;
  248. struct ath10k_hw_ce_regs_addr_map *dmax; };
  249. struct ath10k_hw_ce_cmd_halt {
  250. u32 status_reset;
  251. u32 msb;
  252. u32 mask;
  253. struct ath10k_hw_ce_regs_addr_map *status; };
  254. struct ath10k_hw_ce_host_ie {
  255. u32 copy_complete_reset;
  256. struct ath10k_hw_ce_regs_addr_map *copy_complete; };
  257. struct ath10k_hw_ce_host_wm_regs {
  258. u32 dstr_lmask;
  259. u32 dstr_hmask;
  260. u32 srcr_lmask;
  261. u32 srcr_hmask;
  262. u32 cc_mask;
  263. u32 wm_mask;
  264. u32 addr;
  265. };
  266. struct ath10k_hw_ce_misc_regs {
  267. u32 axi_err;
  268. u32 dstr_add_err;
  269. u32 srcr_len_err;
  270. u32 dstr_mlen_vio;
  271. u32 dstr_overflow;
  272. u32 srcr_overflow;
  273. u32 err_mask;
  274. u32 addr;
  275. };
  276. struct ath10k_hw_ce_dst_src_wm_regs {
  277. u32 addr;
  278. u32 low_rst;
  279. u32 high_rst;
  280. struct ath10k_hw_ce_regs_addr_map *wm_low;
  281. struct ath10k_hw_ce_regs_addr_map *wm_high; };
  282. struct ath10k_hw_ce_ctrl1_upd {
  283. u32 shift;
  284. u32 mask;
  285. u32 enable;
  286. };
  287. struct ath10k_hw_ce_regs {
  288. u32 sr_base_addr_lo;
  289. u32 sr_base_addr_hi;
  290. u32 sr_size_addr;
  291. u32 dr_base_addr_lo;
  292. u32 dr_base_addr_hi;
  293. u32 dr_size_addr;
  294. u32 ce_cmd_addr;
  295. u32 misc_ie_addr;
  296. u32 sr_wr_index_addr;
  297. u32 dst_wr_index_addr;
  298. u32 current_srri_addr;
  299. u32 current_drri_addr;
  300. u32 ddr_addr_for_rri_low;
  301. u32 ddr_addr_for_rri_high;
  302. u32 ce_rri_low;
  303. u32 ce_rri_high;
  304. u32 host_ie_addr;
  305. struct ath10k_hw_ce_host_wm_regs *wm_regs;
  306. struct ath10k_hw_ce_misc_regs *misc_regs;
  307. struct ath10k_hw_ce_ctrl1 *ctrl1_regs;
  308. struct ath10k_hw_ce_cmd_halt *cmd_halt;
  309. struct ath10k_hw_ce_host_ie *host_ie;
  310. struct ath10k_hw_ce_dst_src_wm_regs *wm_srcr;
  311. struct ath10k_hw_ce_dst_src_wm_regs *wm_dstr;
  312. struct ath10k_hw_ce_ctrl1_upd *upd;
  313. };
  314. struct ath10k_hw_values {
  315. u32 rtc_state_val_on;
  316. u8 ce_count;
  317. u8 msi_assign_ce_max;
  318. u8 num_target_ce_config_wlan;
  319. u16 ce_desc_meta_data_mask;
  320. u8 ce_desc_meta_data_lsb;
  321. u32 rfkill_pin;
  322. u32 rfkill_cfg;
  323. bool rfkill_on_level;
  324. };
  325. extern const struct ath10k_hw_values qca988x_values;
  326. extern const struct ath10k_hw_values qca6174_values;
  327. extern const struct ath10k_hw_values qca99x0_values;
  328. extern const struct ath10k_hw_values qca9888_values;
  329. extern const struct ath10k_hw_values qca4019_values;
  330. extern const struct ath10k_hw_values wcn3990_values;
  331. extern const struct ath10k_hw_ce_regs wcn3990_ce_regs;
  332. extern const struct ath10k_hw_ce_regs qcax_ce_regs;
  333. void ath10k_hw_fill_survey_time(struct ath10k *ar, struct survey_info *survey,
  334. u32 cc, u32 rcc, u32 cc_prev, u32 rcc_prev);
  335. int ath10k_hw_diag_fast_download(struct ath10k *ar,
  336. u32 address,
  337. const void *buffer,
  338. u32 length);
  339. #define QCA_REV_988X(ar) ((ar)->hw_rev == ATH10K_HW_QCA988X)
  340. #define QCA_REV_9887(ar) ((ar)->hw_rev == ATH10K_HW_QCA9887)
  341. #define QCA_REV_6174(ar) ((ar)->hw_rev == ATH10K_HW_QCA6174)
  342. #define QCA_REV_99X0(ar) ((ar)->hw_rev == ATH10K_HW_QCA99X0)
  343. #define QCA_REV_9888(ar) ((ar)->hw_rev == ATH10K_HW_QCA9888)
  344. #define QCA_REV_9984(ar) ((ar)->hw_rev == ATH10K_HW_QCA9984)
  345. #define QCA_REV_9377(ar) ((ar)->hw_rev == ATH10K_HW_QCA9377)
  346. #define QCA_REV_40XX(ar) ((ar)->hw_rev == ATH10K_HW_QCA4019)
  347. #define QCA_REV_WCN3990(ar) ((ar)->hw_rev == ATH10K_HW_WCN3990)
  348. /* Known peculiarities:
  349. * - raw appears in nwifi decap, raw and nwifi appear in ethernet decap
  350. * - raw have FCS, nwifi doesn't
  351. * - ethernet frames have 802.11 header decapped and parts (base hdr, cipher
  352. * param, llc/snap) are aligned to 4byte boundaries each
  353. */
  354. enum ath10k_hw_txrx_mode {
  355. ATH10K_HW_TXRX_RAW = 0,
  356. /* Native Wifi decap mode is used to align IP frames to 4-byte
  357. * boundaries and avoid a very expensive re-alignment in mac80211.
  358. */
  359. ATH10K_HW_TXRX_NATIVE_WIFI = 1,
  360. ATH10K_HW_TXRX_ETHERNET = 2,
  361. /* Valid for HTT >= 3.0. Used for management frames in TX_FRM. */
  362. ATH10K_HW_TXRX_MGMT = 3,
  363. };
  364. enum ath10k_mcast2ucast_mode {
  365. ATH10K_MCAST2UCAST_DISABLED = 0,
  366. ATH10K_MCAST2UCAST_ENABLED = 1,
  367. };
  368. enum ath10k_hw_rate_ofdm {
  369. ATH10K_HW_RATE_OFDM_48M = 0,
  370. ATH10K_HW_RATE_OFDM_24M,
  371. ATH10K_HW_RATE_OFDM_12M,
  372. ATH10K_HW_RATE_OFDM_6M,
  373. ATH10K_HW_RATE_OFDM_54M,
  374. ATH10K_HW_RATE_OFDM_36M,
  375. ATH10K_HW_RATE_OFDM_18M,
  376. ATH10K_HW_RATE_OFDM_9M,
  377. };
  378. enum ath10k_hw_rate_cck {
  379. ATH10K_HW_RATE_CCK_LP_11M = 0,
  380. ATH10K_HW_RATE_CCK_LP_5_5M,
  381. ATH10K_HW_RATE_CCK_LP_2M,
  382. ATH10K_HW_RATE_CCK_LP_1M,
  383. ATH10K_HW_RATE_CCK_SP_11M,
  384. ATH10K_HW_RATE_CCK_SP_5_5M,
  385. ATH10K_HW_RATE_CCK_SP_2M,
  386. };
  387. enum ath10k_hw_rate_rev2_cck {
  388. ATH10K_HW_RATE_REV2_CCK_LP_1M = 1,
  389. ATH10K_HW_RATE_REV2_CCK_LP_2M,
  390. ATH10K_HW_RATE_REV2_CCK_LP_5_5M,
  391. ATH10K_HW_RATE_REV2_CCK_LP_11M,
  392. ATH10K_HW_RATE_REV2_CCK_SP_2M,
  393. ATH10K_HW_RATE_REV2_CCK_SP_5_5M,
  394. ATH10K_HW_RATE_REV2_CCK_SP_11M,
  395. };
  396. enum ath10k_hw_cc_wraparound_type {
  397. ATH10K_HW_CC_WRAP_DISABLED = 0,
  398. /* This type is when the HW chip has a quirky Cycle Counter
  399. * wraparound which resets to 0x7fffffff instead of 0. All
  400. * other CC related counters (e.g. Rx Clear Count) are divided
  401. * by 2 so they never wraparound themselves.
  402. */
  403. ATH10K_HW_CC_WRAP_SHIFTED_ALL = 1,
  404. /* Each hw counter wrapsaround independently. When the
  405. * counter overflows the repestive counter is right shifted
  406. * by 1, i.e reset to 0x7fffffff, and other counters will be
  407. * running unaffected. In this type of wraparound, it should
  408. * be possible to report accurate Rx busy time unlike the
  409. * first type.
  410. */
  411. ATH10K_HW_CC_WRAP_SHIFTED_EACH = 2,
  412. };
  413. enum ath10k_hw_refclk_speed {
  414. ATH10K_HW_REFCLK_UNKNOWN = -1,
  415. ATH10K_HW_REFCLK_48_MHZ = 0,
  416. ATH10K_HW_REFCLK_19_2_MHZ = 1,
  417. ATH10K_HW_REFCLK_24_MHZ = 2,
  418. ATH10K_HW_REFCLK_26_MHZ = 3,
  419. ATH10K_HW_REFCLK_37_4_MHZ = 4,
  420. ATH10K_HW_REFCLK_38_4_MHZ = 5,
  421. ATH10K_HW_REFCLK_40_MHZ = 6,
  422. ATH10K_HW_REFCLK_52_MHZ = 7,
  423. /* must be the last one */
  424. ATH10K_HW_REFCLK_COUNT,
  425. };
  426. struct ath10k_hw_clk_params {
  427. u32 refclk;
  428. u32 div;
  429. u32 rnfrac;
  430. u32 settle_time;
  431. u32 refdiv;
  432. u32 outdiv;
  433. };
  434. struct htt_rx_desc_ops;
  435. struct ath10k_hw_params {
  436. u32 id;
  437. u16 dev_id;
  438. enum ath10k_bus bus;
  439. const char *name;
  440. u32 patch_load_addr;
  441. int uart_pin;
  442. u32 otp_exe_param;
  443. /* Type of hw cycle counter wraparound logic, for more info
  444. * refer enum ath10k_hw_cc_wraparound_type.
  445. */
  446. enum ath10k_hw_cc_wraparound_type cc_wraparound_type;
  447. /* Some of chip expects fragment descriptor to be continuous
  448. * memory for any TX operation. Set continuous_frag_desc flag
  449. * for the hardware which have such requirement.
  450. */
  451. bool continuous_frag_desc;
  452. /* CCK hardware rate table mapping for the newer chipsets
  453. * like QCA99X0, QCA4019 got revised. The CCK h/w rate values
  454. * are in a proper order with respect to the rate/preamble
  455. */
  456. bool cck_rate_map_rev2;
  457. u32 channel_counters_freq_hz;
  458. /* Mgmt tx descriptors threshold for limiting probe response
  459. * frames.
  460. */
  461. u32 max_probe_resp_desc_thres;
  462. u32 tx_chain_mask;
  463. u32 rx_chain_mask;
  464. u32 max_spatial_stream;
  465. u32 cal_data_len;
  466. struct ath10k_hw_params_fw {
  467. const char *dir;
  468. const char *board;
  469. size_t board_size;
  470. const char *eboard;
  471. size_t ext_board_size;
  472. size_t board_ext_size;
  473. } fw;
  474. /* qca99x0 family chips deliver broadcast/multicast management
  475. * frames encrypted and expect software do decryption.
  476. */
  477. bool sw_decrypt_mcast_mgmt;
  478. /* Rx descriptor abstraction */
  479. const struct ath10k_htt_rx_desc_ops *rx_desc_ops;
  480. const struct ath10k_hw_ops *hw_ops;
  481. /* Number of bytes used for alignment in rx_hdr_status of rx desc. */
  482. int decap_align_bytes;
  483. /* hw specific clock control parameters */
  484. const struct ath10k_hw_clk_params *hw_clk;
  485. int target_cpu_freq;
  486. /* Number of bytes to be discarded for each FFT sample */
  487. int spectral_bin_discard;
  488. /* The board may have a restricted NSS for 160 or 80+80 vs what it
  489. * can do for 80Mhz.
  490. */
  491. int vht160_mcs_rx_highest;
  492. int vht160_mcs_tx_highest;
  493. /* Number of ciphers supported (i.e First N) in cipher_suites array */
  494. int n_cipher_suites;
  495. u32 num_peers;
  496. u32 ast_skid_limit;
  497. u32 num_wds_entries;
  498. /* Targets supporting physical addressing capability above 32-bits */
  499. bool target_64bit;
  500. /* Target rx ring fill level */
  501. u32 rx_ring_fill_level;
  502. /* target supporting shadow register for ce write */
  503. bool shadow_reg_support;
  504. /* target supporting retention restore on ddr */
  505. bool rri_on_ddr;
  506. /* Number of bytes to be the offset for each FFT sample */
  507. int spectral_bin_offset;
  508. /* targets which require hw filter reset during boot up,
  509. * to avoid it sending spurious acks.
  510. */
  511. bool hw_filter_reset_required;
  512. /* target supporting fw download via diag ce */
  513. bool fw_diag_ce_download;
  514. /* target supporting fw download via large size BMI */
  515. bool bmi_large_size_download;
  516. /* need to set uart pin if disable uart print, workaround for a
  517. * firmware bug
  518. */
  519. bool uart_pin_workaround;
  520. /* Workaround for the credit size calculation */
  521. bool credit_size_workaround;
  522. /* tx stats support over pktlog */
  523. bool tx_stats_over_pktlog;
  524. /* provides bitrates for sta_statistics using WMI_TLV_PEER_STATS_INFO_EVENTID */
  525. bool supports_peer_stats_info;
  526. bool dynamic_sar_support;
  527. bool hw_restart_disconnect;
  528. bool use_fw_tx_credits;
  529. bool delay_unmap_buffer;
  530. };
  531. struct htt_resp;
  532. struct htt_data_tx_completion_ext;
  533. struct htt_rx_ring_rx_desc_offsets;
  534. /* Defines needed for Rx descriptor abstraction */
  535. struct ath10k_hw_ops {
  536. void (*set_coverage_class)(struct ath10k *ar, s16 value);
  537. int (*enable_pll_clk)(struct ath10k *ar);
  538. int (*tx_data_rssi_pad_bytes)(struct htt_resp *htt);
  539. int (*is_rssi_enable)(struct htt_resp *resp);
  540. };
  541. extern const struct ath10k_hw_ops qca988x_ops;
  542. extern const struct ath10k_hw_ops qca99x0_ops;
  543. extern const struct ath10k_hw_ops qca6174_ops;
  544. extern const struct ath10k_hw_ops qca6174_sdio_ops;
  545. extern const struct ath10k_hw_ops wcn3990_ops;
  546. extern const struct ath10k_hw_clk_params qca6174_clk[];
  547. static inline int
  548. ath10k_tx_data_rssi_get_pad_bytes(struct ath10k_hw_params *hw,
  549. struct htt_resp *htt)
  550. {
  551. if (hw->hw_ops->tx_data_rssi_pad_bytes)
  552. return hw->hw_ops->tx_data_rssi_pad_bytes(htt);
  553. return 0;
  554. }
  555. static inline int
  556. ath10k_is_rssi_enable(struct ath10k_hw_params *hw,
  557. struct htt_resp *resp)
  558. {
  559. if (hw->hw_ops->is_rssi_enable)
  560. return hw->hw_ops->is_rssi_enable(resp);
  561. return 0;
  562. }
  563. /* Target specific defines for MAIN firmware */
  564. #define TARGET_NUM_VDEVS 8
  565. #define TARGET_NUM_PEER_AST 2
  566. #define TARGET_NUM_WDS_ENTRIES 32
  567. #define TARGET_DMA_BURST_SIZE 0
  568. #define TARGET_MAC_AGGR_DELIM 0
  569. #define TARGET_AST_SKID_LIMIT 16
  570. #define TARGET_NUM_STATIONS 16
  571. #define TARGET_NUM_PEERS ((TARGET_NUM_STATIONS) + \
  572. (TARGET_NUM_VDEVS))
  573. #define TARGET_NUM_OFFLOAD_PEERS 0
  574. #define TARGET_NUM_OFFLOAD_REORDER_BUFS 0
  575. #define TARGET_NUM_PEER_KEYS 2
  576. #define TARGET_NUM_TIDS ((TARGET_NUM_PEERS) * 2)
  577. #define TARGET_TX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2))
  578. #define TARGET_RX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2))
  579. #define TARGET_RX_TIMEOUT_LO_PRI 100
  580. #define TARGET_RX_TIMEOUT_HI_PRI 40
  581. #define TARGET_SCAN_MAX_PENDING_REQS 4
  582. #define TARGET_BMISS_OFFLOAD_MAX_VDEV 3
  583. #define TARGET_ROAM_OFFLOAD_MAX_VDEV 3
  584. #define TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES 8
  585. #define TARGET_GTK_OFFLOAD_MAX_VDEV 3
  586. #define TARGET_NUM_MCAST_GROUPS 0
  587. #define TARGET_NUM_MCAST_TABLE_ELEMS 0
  588. #define TARGET_MCAST2UCAST_MODE ATH10K_MCAST2UCAST_DISABLED
  589. #define TARGET_TX_DBG_LOG_SIZE 1024
  590. #define TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 0
  591. #define TARGET_VOW_CONFIG 0
  592. #define TARGET_NUM_MSDU_DESC (1024 + 400)
  593. #define TARGET_MAX_FRAG_ENTRIES 0
  594. /* Target specific defines for 10.X firmware */
  595. #define TARGET_10X_NUM_VDEVS 16
  596. #define TARGET_10X_NUM_PEER_AST 2
  597. #define TARGET_10X_NUM_WDS_ENTRIES 32
  598. #define TARGET_10X_DMA_BURST_SIZE 0
  599. #define TARGET_10X_MAC_AGGR_DELIM 0
  600. #define TARGET_10X_AST_SKID_LIMIT 128
  601. #define TARGET_10X_NUM_STATIONS 128
  602. #define TARGET_10X_TX_STATS_NUM_STATIONS 118
  603. #define TARGET_10X_NUM_PEERS ((TARGET_10X_NUM_STATIONS) + \
  604. (TARGET_10X_NUM_VDEVS))
  605. #define TARGET_10X_TX_STATS_NUM_PEERS ((TARGET_10X_TX_STATS_NUM_STATIONS) + \
  606. (TARGET_10X_NUM_VDEVS))
  607. #define TARGET_10X_NUM_OFFLOAD_PEERS 0
  608. #define TARGET_10X_NUM_OFFLOAD_REORDER_BUFS 0
  609. #define TARGET_10X_NUM_PEER_KEYS 2
  610. #define TARGET_10X_NUM_TIDS_MAX 256
  611. #define TARGET_10X_NUM_TIDS min((TARGET_10X_NUM_TIDS_MAX), \
  612. (TARGET_10X_NUM_PEERS) * 2)
  613. #define TARGET_10X_TX_STATS_NUM_TIDS min((TARGET_10X_NUM_TIDS_MAX), \
  614. (TARGET_10X_TX_STATS_NUM_PEERS) * 2)
  615. #define TARGET_10X_TX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2))
  616. #define TARGET_10X_RX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2))
  617. #define TARGET_10X_RX_TIMEOUT_LO_PRI 100
  618. #define TARGET_10X_RX_TIMEOUT_HI_PRI 40
  619. #define TARGET_10X_SCAN_MAX_PENDING_REQS 4
  620. #define TARGET_10X_BMISS_OFFLOAD_MAX_VDEV 2
  621. #define TARGET_10X_ROAM_OFFLOAD_MAX_VDEV 2
  622. #define TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES 8
  623. #define TARGET_10X_GTK_OFFLOAD_MAX_VDEV 3
  624. #define TARGET_10X_NUM_MCAST_GROUPS 0
  625. #define TARGET_10X_NUM_MCAST_TABLE_ELEMS 0
  626. #define TARGET_10X_MCAST2UCAST_MODE ATH10K_MCAST2UCAST_DISABLED
  627. #define TARGET_10X_TX_DBG_LOG_SIZE 1024
  628. #define TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
  629. #define TARGET_10X_VOW_CONFIG 0
  630. #define TARGET_10X_NUM_MSDU_DESC (1024 + 400)
  631. #define TARGET_10X_MAX_FRAG_ENTRIES 0
  632. /* 10.2 parameters */
  633. #define TARGET_10_2_DMA_BURST_SIZE 0
  634. /* Target specific defines for WMI-TLV firmware */
  635. #define TARGET_TLV_NUM_VDEVS 4
  636. #define TARGET_TLV_NUM_STATIONS 32
  637. #define TARGET_TLV_NUM_PEERS 33
  638. #define TARGET_TLV_NUM_TDLS_VDEVS 1
  639. #define TARGET_TLV_NUM_TIDS ((TARGET_TLV_NUM_PEERS) * 2)
  640. #define TARGET_TLV_NUM_MSDU_DESC (1024 + 32)
  641. #define TARGET_TLV_NUM_MSDU_DESC_HL 1024
  642. #define TARGET_TLV_NUM_WOW_PATTERNS 22
  643. #define TARGET_TLV_MGMT_NUM_MSDU_DESC (50)
  644. /* Target specific defines for WMI-HL-1.0 firmware */
  645. #define TARGET_HL_TLV_NUM_PEERS 33
  646. #define TARGET_HL_TLV_AST_SKID_LIMIT 16
  647. #define TARGET_HL_TLV_NUM_WDS_ENTRIES 2
  648. /* Target specific defines for QCA9377 high latency firmware */
  649. #define TARGET_QCA9377_HL_NUM_PEERS 15
  650. /* Diagnostic Window */
  651. #define CE_DIAG_PIPE 7
  652. #define NUM_TARGET_CE_CONFIG_WLAN ar->hw_values->num_target_ce_config_wlan
  653. /* Target specific defines for 10.4 firmware */
  654. #define TARGET_10_4_NUM_VDEVS 16
  655. #define TARGET_10_4_NUM_STATIONS 32
  656. #define TARGET_10_4_NUM_PEERS ((TARGET_10_4_NUM_STATIONS) + \
  657. (TARGET_10_4_NUM_VDEVS))
  658. #define TARGET_10_4_ACTIVE_PEERS 0
  659. #define TARGET_10_4_NUM_QCACHE_PEERS_MAX 512
  660. #define TARGET_10_4_QCACHE_ACTIVE_PEERS 50
  661. #define TARGET_10_4_QCACHE_ACTIVE_PEERS_PFC 35
  662. #define TARGET_10_4_NUM_OFFLOAD_PEERS 0
  663. #define TARGET_10_4_NUM_OFFLOAD_REORDER_BUFFS 0
  664. #define TARGET_10_4_NUM_PEER_KEYS 2
  665. #define TARGET_10_4_TGT_NUM_TIDS ((TARGET_10_4_NUM_PEERS) * 2)
  666. #define TARGET_10_4_NUM_MSDU_DESC (1024 + 400)
  667. #define TARGET_10_4_NUM_MSDU_DESC_PFC 2500
  668. #define TARGET_10_4_AST_SKID_LIMIT 32
  669. /* 100 ms for video, best-effort, and background */
  670. #define TARGET_10_4_RX_TIMEOUT_LO_PRI 100
  671. /* 40 ms for voice */
  672. #define TARGET_10_4_RX_TIMEOUT_HI_PRI 40
  673. #define TARGET_10_4_RX_DECAP_MODE ATH10K_HW_TXRX_NATIVE_WIFI
  674. #define TARGET_10_4_SCAN_MAX_REQS 4
  675. #define TARGET_10_4_BMISS_OFFLOAD_MAX_VDEV 3
  676. #define TARGET_10_4_ROAM_OFFLOAD_MAX_VDEV 3
  677. #define TARGET_10_4_ROAM_OFFLOAD_MAX_PROFILES 8
  678. /* Note: mcast to ucast is disabled by default */
  679. #define TARGET_10_4_NUM_MCAST_GROUPS 0
  680. #define TARGET_10_4_NUM_MCAST_TABLE_ELEMS 0
  681. #define TARGET_10_4_MCAST2UCAST_MODE 0
  682. #define TARGET_10_4_TX_DBG_LOG_SIZE 1024
  683. #define TARGET_10_4_NUM_WDS_ENTRIES 32
  684. #define TARGET_10_4_DMA_BURST_SIZE 1
  685. #define TARGET_10_4_MAC_AGGR_DELIM 0
  686. #define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
  687. #define TARGET_10_4_VOW_CONFIG 0
  688. #define TARGET_10_4_GTK_OFFLOAD_MAX_VDEV 3
  689. #define TARGET_10_4_11AC_TX_MAX_FRAGS 2
  690. #define TARGET_10_4_MAX_PEER_EXT_STATS 16
  691. #define TARGET_10_4_SMART_ANT_CAP 0
  692. #define TARGET_10_4_BK_MIN_FREE 0
  693. #define TARGET_10_4_BE_MIN_FREE 0
  694. #define TARGET_10_4_VI_MIN_FREE 0
  695. #define TARGET_10_4_VO_MIN_FREE 0
  696. #define TARGET_10_4_RX_BATCH_MODE 1
  697. #define TARGET_10_4_THERMAL_THROTTLING_CONFIG 0
  698. #define TARGET_10_4_ATF_CONFIG 0
  699. #define TARGET_10_4_IPHDR_PAD_CONFIG 1
  700. #define TARGET_10_4_QWRAP_CONFIG 0
  701. /* TDLS config */
  702. #define TARGET_10_4_NUM_TDLS_VDEVS 1
  703. #define TARGET_10_4_NUM_TDLS_BUFFER_STA 1
  704. #define TARGET_10_4_NUM_TDLS_SLEEP_STA 1
  705. /* Maximum number of Copy Engine's supported */
  706. #define CE_COUNT_MAX 12
  707. /* Number of Copy Engines supported */
  708. #define CE_COUNT ar->hw_values->ce_count
  709. /*
  710. * Granted MSIs are assigned as follows:
  711. * Firmware uses the first
  712. * Remaining MSIs, if any, are used by Copy Engines
  713. * This mapping is known to both Target firmware and Host software.
  714. * It may be changed as long as Host and Target are kept in sync.
  715. */
  716. /* MSI for firmware (errors, etc.) */
  717. #define MSI_ASSIGN_FW 0
  718. /* MSIs for Copy Engines */
  719. #define MSI_ASSIGN_CE_INITIAL 1
  720. #define MSI_ASSIGN_CE_MAX ar->hw_values->msi_assign_ce_max
  721. /* as of IP3.7.1 */
  722. #define RTC_STATE_V_ON ar->hw_values->rtc_state_val_on
  723. #define RTC_STATE_V_LSB 0
  724. #define RTC_STATE_V_MASK 0x00000007
  725. #define RTC_STATE_ADDRESS 0x0000
  726. #define PCIE_SOC_WAKE_V_MASK 0x00000001
  727. #define PCIE_SOC_WAKE_ADDRESS 0x0004
  728. #define PCIE_SOC_WAKE_RESET 0x00000000
  729. #define SOC_GLOBAL_RESET_ADDRESS 0x0008
  730. #define RTC_SOC_BASE_ADDRESS ar->regs->rtc_soc_base_address
  731. #define RTC_WMAC_BASE_ADDRESS ar->regs->rtc_wmac_base_address
  732. #define MAC_COEX_BASE_ADDRESS 0x00006000
  733. #define BT_COEX_BASE_ADDRESS 0x00007000
  734. #define SOC_PCIE_BASE_ADDRESS 0x00008000
  735. #define SOC_CORE_BASE_ADDRESS ar->regs->soc_core_base_address
  736. #define WLAN_UART_BASE_ADDRESS 0x0000c000
  737. #define WLAN_SI_BASE_ADDRESS 0x00010000
  738. #define WLAN_GPIO_BASE_ADDRESS 0x00014000
  739. #define WLAN_ANALOG_INTF_BASE_ADDRESS 0x0001c000
  740. #define WLAN_MAC_BASE_ADDRESS ar->regs->wlan_mac_base_address
  741. #define EFUSE_BASE_ADDRESS 0x00030000
  742. #define FPGA_REG_BASE_ADDRESS 0x00039000
  743. #define WLAN_UART2_BASE_ADDRESS 0x00054c00
  744. #define CE_WRAPPER_BASE_ADDRESS ar->regs->ce_wrapper_base_address
  745. #define CE0_BASE_ADDRESS ar->regs->ce0_base_address
  746. #define CE1_BASE_ADDRESS ar->regs->ce1_base_address
  747. #define CE2_BASE_ADDRESS ar->regs->ce2_base_address
  748. #define CE3_BASE_ADDRESS ar->regs->ce3_base_address
  749. #define CE4_BASE_ADDRESS ar->regs->ce4_base_address
  750. #define CE5_BASE_ADDRESS ar->regs->ce5_base_address
  751. #define CE6_BASE_ADDRESS ar->regs->ce6_base_address
  752. #define CE7_BASE_ADDRESS ar->regs->ce7_base_address
  753. #define DBI_BASE_ADDRESS 0x00060000
  754. #define WLAN_ANALOG_INTF_PCIE_BASE_ADDRESS 0x0006c000
  755. #define PCIE_LOCAL_BASE_ADDRESS ar->regs->pcie_local_base_address
  756. #define SOC_RESET_CONTROL_ADDRESS 0x00000000
  757. #define SOC_RESET_CONTROL_OFFSET 0x00000000
  758. #define SOC_RESET_CONTROL_SI0_RST_MASK ar->regs->soc_reset_control_si0_rst_mask
  759. #define SOC_RESET_CONTROL_CE_RST_MASK ar->regs->soc_reset_control_ce_rst_mask
  760. #define SOC_RESET_CONTROL_CPU_WARM_RST_MASK 0x00000040
  761. #define SOC_CPU_CLOCK_OFFSET 0x00000020
  762. #define SOC_CPU_CLOCK_STANDARD_LSB 0
  763. #define SOC_CPU_CLOCK_STANDARD_MASK 0x00000003
  764. #define SOC_CLOCK_CONTROL_OFFSET 0x00000028
  765. #define SOC_CLOCK_CONTROL_SI0_CLK_MASK 0x00000001
  766. #define SOC_SYSTEM_SLEEP_OFFSET 0x000000c4
  767. #define SOC_LPO_CAL_OFFSET 0x000000e0
  768. #define SOC_LPO_CAL_ENABLE_LSB 20
  769. #define SOC_LPO_CAL_ENABLE_MASK 0x00100000
  770. #define SOC_LF_TIMER_CONTROL0_ADDRESS 0x00000050
  771. #define SOC_LF_TIMER_CONTROL0_ENABLE_MASK 0x00000004
  772. #define SOC_CHIP_ID_ADDRESS ar->regs->soc_chip_id_address
  773. #define SOC_CHIP_ID_REV_LSB 8
  774. #define SOC_CHIP_ID_REV_MASK 0x00000f00
  775. #define WLAN_RESET_CONTROL_COLD_RST_MASK 0x00000008
  776. #define WLAN_RESET_CONTROL_WARM_RST_MASK 0x00000004
  777. #define WLAN_SYSTEM_SLEEP_DISABLE_LSB 0
  778. #define WLAN_SYSTEM_SLEEP_DISABLE_MASK 0x00000001
  779. #define WLAN_GPIO_PIN0_ADDRESS 0x00000028
  780. #define WLAN_GPIO_PIN0_CONFIG_LSB 11
  781. #define WLAN_GPIO_PIN0_CONFIG_MASK 0x00007800
  782. #define WLAN_GPIO_PIN0_PAD_PULL_LSB 5
  783. #define WLAN_GPIO_PIN0_PAD_PULL_MASK 0x00000060
  784. #define WLAN_GPIO_PIN1_ADDRESS 0x0000002c
  785. #define WLAN_GPIO_PIN1_CONFIG_MASK 0x00007800
  786. #define WLAN_GPIO_PIN10_ADDRESS 0x00000050
  787. #define WLAN_GPIO_PIN11_ADDRESS 0x00000054
  788. #define WLAN_GPIO_PIN12_ADDRESS 0x00000058
  789. #define WLAN_GPIO_PIN13_ADDRESS 0x0000005c
  790. #define CLOCK_GPIO_OFFSET 0xffffffff
  791. #define CLOCK_GPIO_BT_CLK_OUT_EN_LSB 0
  792. #define CLOCK_GPIO_BT_CLK_OUT_EN_MASK 0
  793. #define SI_CONFIG_OFFSET 0x00000000
  794. #define SI_CONFIG_ERR_INT_LSB 19
  795. #define SI_CONFIG_ERR_INT_MASK 0x00080000
  796. #define SI_CONFIG_BIDIR_OD_DATA_LSB 18
  797. #define SI_CONFIG_BIDIR_OD_DATA_MASK 0x00040000
  798. #define SI_CONFIG_I2C_LSB 16
  799. #define SI_CONFIG_I2C_MASK 0x00010000
  800. #define SI_CONFIG_POS_SAMPLE_LSB 7
  801. #define SI_CONFIG_POS_SAMPLE_MASK 0x00000080
  802. #define SI_CONFIG_INACTIVE_DATA_LSB 5
  803. #define SI_CONFIG_INACTIVE_DATA_MASK 0x00000020
  804. #define SI_CONFIG_INACTIVE_CLK_LSB 4
  805. #define SI_CONFIG_INACTIVE_CLK_MASK 0x00000010
  806. #define SI_CONFIG_DIVIDER_LSB 0
  807. #define SI_CONFIG_DIVIDER_MASK 0x0000000f
  808. #define SI_CS_OFFSET 0x00000004
  809. #define SI_CS_DONE_ERR_LSB 10
  810. #define SI_CS_DONE_ERR_MASK 0x00000400
  811. #define SI_CS_DONE_INT_LSB 9
  812. #define SI_CS_DONE_INT_MASK 0x00000200
  813. #define SI_CS_START_LSB 8
  814. #define SI_CS_START_MASK 0x00000100
  815. #define SI_CS_RX_CNT_LSB 4
  816. #define SI_CS_RX_CNT_MASK 0x000000f0
  817. #define SI_CS_TX_CNT_LSB 0
  818. #define SI_CS_TX_CNT_MASK 0x0000000f
  819. #define SI_TX_DATA0_OFFSET 0x00000008
  820. #define SI_TX_DATA1_OFFSET 0x0000000c
  821. #define SI_RX_DATA0_OFFSET 0x00000010
  822. #define SI_RX_DATA1_OFFSET 0x00000014
  823. #define CORE_CTRL_CPU_INTR_MASK 0x00002000
  824. #define CORE_CTRL_PCIE_REG_31_MASK 0x00000800
  825. #define CORE_CTRL_ADDRESS 0x0000
  826. #define PCIE_INTR_ENABLE_ADDRESS 0x0008
  827. #define PCIE_INTR_CAUSE_ADDRESS 0x000c
  828. #define PCIE_INTR_CLR_ADDRESS ar->regs->pcie_intr_clr_address
  829. #define SCRATCH_3_ADDRESS ar->regs->scratch_3_address
  830. #define CPU_INTR_ADDRESS 0x0010
  831. #define FW_RAM_CONFIG_ADDRESS 0x0018
  832. #define CCNT_TO_MSEC(ar, x) ((x) / ar->hw_params.channel_counters_freq_hz)
  833. /* Firmware indications to the Host via SCRATCH_3 register. */
  834. #define FW_INDICATOR_ADDRESS ar->regs->fw_indicator_address
  835. #define FW_IND_EVENT_PENDING 1
  836. #define FW_IND_INITIALIZED 2
  837. #define FW_IND_HOST_READY 0x80000000
  838. /* HOST_REG interrupt from firmware */
  839. #define PCIE_INTR_FIRMWARE_MASK ar->regs->pcie_intr_fw_mask
  840. #define PCIE_INTR_CE_MASK_ALL ar->regs->pcie_intr_ce_mask_all
  841. #define DRAM_BASE_ADDRESS 0x00400000
  842. #define PCIE_BAR_REG_ADDRESS 0x40030
  843. #define MISSING 0
  844. #define SYSTEM_SLEEP_OFFSET SOC_SYSTEM_SLEEP_OFFSET
  845. #define WLAN_SYSTEM_SLEEP_OFFSET SOC_SYSTEM_SLEEP_OFFSET
  846. #define WLAN_RESET_CONTROL_OFFSET SOC_RESET_CONTROL_OFFSET
  847. #define CLOCK_CONTROL_OFFSET SOC_CLOCK_CONTROL_OFFSET
  848. #define CLOCK_CONTROL_SI0_CLK_MASK SOC_CLOCK_CONTROL_SI0_CLK_MASK
  849. #define RESET_CONTROL_MBOX_RST_MASK MISSING
  850. #define RESET_CONTROL_SI0_RST_MASK SOC_RESET_CONTROL_SI0_RST_MASK
  851. #define GPIO_BASE_ADDRESS WLAN_GPIO_BASE_ADDRESS
  852. #define GPIO_PIN0_OFFSET WLAN_GPIO_PIN0_ADDRESS
  853. #define GPIO_PIN1_OFFSET WLAN_GPIO_PIN1_ADDRESS
  854. #define GPIO_PIN0_CONFIG_LSB WLAN_GPIO_PIN0_CONFIG_LSB
  855. #define GPIO_PIN0_CONFIG_MASK WLAN_GPIO_PIN0_CONFIG_MASK
  856. #define GPIO_PIN0_PAD_PULL_LSB WLAN_GPIO_PIN0_PAD_PULL_LSB
  857. #define GPIO_PIN0_PAD_PULL_MASK WLAN_GPIO_PIN0_PAD_PULL_MASK
  858. #define GPIO_PIN1_CONFIG_MASK WLAN_GPIO_PIN1_CONFIG_MASK
  859. #define SI_BASE_ADDRESS WLAN_SI_BASE_ADDRESS
  860. #define SCRATCH_BASE_ADDRESS SOC_CORE_BASE_ADDRESS
  861. #define LOCAL_SCRATCH_OFFSET 0x18
  862. #define CPU_CLOCK_OFFSET SOC_CPU_CLOCK_OFFSET
  863. #define LPO_CAL_OFFSET SOC_LPO_CAL_OFFSET
  864. #define GPIO_PIN10_OFFSET WLAN_GPIO_PIN10_ADDRESS
  865. #define GPIO_PIN11_OFFSET WLAN_GPIO_PIN11_ADDRESS
  866. #define GPIO_PIN12_OFFSET WLAN_GPIO_PIN12_ADDRESS
  867. #define GPIO_PIN13_OFFSET WLAN_GPIO_PIN13_ADDRESS
  868. #define CPU_CLOCK_STANDARD_LSB SOC_CPU_CLOCK_STANDARD_LSB
  869. #define CPU_CLOCK_STANDARD_MASK SOC_CPU_CLOCK_STANDARD_MASK
  870. #define LPO_CAL_ENABLE_LSB SOC_LPO_CAL_ENABLE_LSB
  871. #define LPO_CAL_ENABLE_MASK SOC_LPO_CAL_ENABLE_MASK
  872. #define ANALOG_INTF_BASE_ADDRESS WLAN_ANALOG_INTF_BASE_ADDRESS
  873. #define MBOX_BASE_ADDRESS MISSING
  874. #define INT_STATUS_ENABLE_ERROR_LSB MISSING
  875. #define INT_STATUS_ENABLE_ERROR_MASK MISSING
  876. #define INT_STATUS_ENABLE_CPU_LSB MISSING
  877. #define INT_STATUS_ENABLE_CPU_MASK MISSING
  878. #define INT_STATUS_ENABLE_COUNTER_LSB MISSING
  879. #define INT_STATUS_ENABLE_COUNTER_MASK MISSING
  880. #define INT_STATUS_ENABLE_MBOX_DATA_LSB MISSING
  881. #define INT_STATUS_ENABLE_MBOX_DATA_MASK MISSING
  882. #define ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB MISSING
  883. #define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK MISSING
  884. #define ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB MISSING
  885. #define ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK MISSING
  886. #define COUNTER_INT_STATUS_ENABLE_BIT_LSB MISSING
  887. #define COUNTER_INT_STATUS_ENABLE_BIT_MASK MISSING
  888. #define INT_STATUS_ENABLE_ADDRESS MISSING
  889. #define CPU_INT_STATUS_ENABLE_BIT_LSB MISSING
  890. #define CPU_INT_STATUS_ENABLE_BIT_MASK MISSING
  891. #define HOST_INT_STATUS_ADDRESS MISSING
  892. #define CPU_INT_STATUS_ADDRESS MISSING
  893. #define ERROR_INT_STATUS_ADDRESS MISSING
  894. #define ERROR_INT_STATUS_WAKEUP_MASK MISSING
  895. #define ERROR_INT_STATUS_WAKEUP_LSB MISSING
  896. #define ERROR_INT_STATUS_RX_UNDERFLOW_MASK MISSING
  897. #define ERROR_INT_STATUS_RX_UNDERFLOW_LSB MISSING
  898. #define ERROR_INT_STATUS_TX_OVERFLOW_MASK MISSING
  899. #define ERROR_INT_STATUS_TX_OVERFLOW_LSB MISSING
  900. #define COUNT_DEC_ADDRESS MISSING
  901. #define HOST_INT_STATUS_CPU_MASK MISSING
  902. #define HOST_INT_STATUS_CPU_LSB MISSING
  903. #define HOST_INT_STATUS_ERROR_MASK MISSING
  904. #define HOST_INT_STATUS_ERROR_LSB MISSING
  905. #define HOST_INT_STATUS_COUNTER_MASK MISSING
  906. #define HOST_INT_STATUS_COUNTER_LSB MISSING
  907. #define RX_LOOKAHEAD_VALID_ADDRESS MISSING
  908. #define WINDOW_DATA_ADDRESS MISSING
  909. #define WINDOW_READ_ADDR_ADDRESS MISSING
  910. #define WINDOW_WRITE_ADDR_ADDRESS MISSING
  911. #define QCA9887_1_0_I2C_SDA_GPIO_PIN 5
  912. #define QCA9887_1_0_I2C_SDA_PIN_CONFIG 3
  913. #define QCA9887_1_0_SI_CLK_GPIO_PIN 17
  914. #define QCA9887_1_0_SI_CLK_PIN_CONFIG 3
  915. #define QCA9887_1_0_GPIO_ENABLE_W1TS_LOW_ADDRESS 0x00000010
  916. #define QCA9887_EEPROM_SELECT_READ 0xa10000a0
  917. #define QCA9887_EEPROM_ADDR_HI_MASK 0x0000ff00
  918. #define QCA9887_EEPROM_ADDR_HI_LSB 8
  919. #define QCA9887_EEPROM_ADDR_LO_MASK 0x00ff0000
  920. #define QCA9887_EEPROM_ADDR_LO_LSB 16
  921. #define MBOX_RESET_CONTROL_ADDRESS 0x00000000
  922. #define MBOX_HOST_INT_STATUS_ADDRESS 0x00000800
  923. #define MBOX_HOST_INT_STATUS_ERROR_LSB 7
  924. #define MBOX_HOST_INT_STATUS_ERROR_MASK 0x00000080
  925. #define MBOX_HOST_INT_STATUS_CPU_LSB 6
  926. #define MBOX_HOST_INT_STATUS_CPU_MASK 0x00000040
  927. #define MBOX_HOST_INT_STATUS_COUNTER_LSB 4
  928. #define MBOX_HOST_INT_STATUS_COUNTER_MASK 0x00000010
  929. #define MBOX_CPU_INT_STATUS_ADDRESS 0x00000801
  930. #define MBOX_ERROR_INT_STATUS_ADDRESS 0x00000802
  931. #define MBOX_ERROR_INT_STATUS_WAKEUP_LSB 2
  932. #define MBOX_ERROR_INT_STATUS_WAKEUP_MASK 0x00000004
  933. #define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_LSB 1
  934. #define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_MASK 0x00000002
  935. #define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_LSB 0
  936. #define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_MASK 0x00000001
  937. #define MBOX_COUNTER_INT_STATUS_ADDRESS 0x00000803
  938. #define MBOX_COUNTER_INT_STATUS_COUNTER_LSB 0
  939. #define MBOX_COUNTER_INT_STATUS_COUNTER_MASK 0x000000ff
  940. #define MBOX_RX_LOOKAHEAD_VALID_ADDRESS 0x00000805
  941. #define MBOX_INT_STATUS_ENABLE_ADDRESS 0x00000828
  942. #define MBOX_INT_STATUS_ENABLE_ERROR_LSB 7
  943. #define MBOX_INT_STATUS_ENABLE_ERROR_MASK 0x00000080
  944. #define MBOX_INT_STATUS_ENABLE_CPU_LSB 6
  945. #define MBOX_INT_STATUS_ENABLE_CPU_MASK 0x00000040
  946. #define MBOX_INT_STATUS_ENABLE_INT_LSB 5
  947. #define MBOX_INT_STATUS_ENABLE_INT_MASK 0x00000020
  948. #define MBOX_INT_STATUS_ENABLE_COUNTER_LSB 4
  949. #define MBOX_INT_STATUS_ENABLE_COUNTER_MASK 0x00000010
  950. #define MBOX_INT_STATUS_ENABLE_MBOX_DATA_LSB 0
  951. #define MBOX_INT_STATUS_ENABLE_MBOX_DATA_MASK 0x0000000f
  952. #define MBOX_CPU_INT_STATUS_ENABLE_ADDRESS 0x00000819
  953. #define MBOX_CPU_INT_STATUS_ENABLE_BIT_LSB 0
  954. #define MBOX_CPU_INT_STATUS_ENABLE_BIT_MASK 0x000000ff
  955. #define MBOX_CPU_STATUS_ENABLE_ASSERT_MASK 0x00000001
  956. #define MBOX_ERROR_STATUS_ENABLE_ADDRESS 0x0000081a
  957. #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB 1
  958. #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x00000002
  959. #define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB 0
  960. #define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK 0x00000001
  961. #define MBOX_COUNTER_INT_STATUS_ENABLE_ADDRESS 0x0000081b
  962. #define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_LSB 0
  963. #define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_MASK 0x000000ff
  964. #define MBOX_COUNT_ADDRESS 0x00000820
  965. #define MBOX_COUNT_DEC_ADDRESS 0x00000840
  966. #define MBOX_WINDOW_DATA_ADDRESS 0x00000874
  967. #define MBOX_WINDOW_WRITE_ADDR_ADDRESS 0x00000878
  968. #define MBOX_WINDOW_READ_ADDR_ADDRESS 0x0000087c
  969. #define MBOX_CPU_DBG_SEL_ADDRESS 0x00000883
  970. #define MBOX_CPU_DBG_ADDRESS 0x00000884
  971. #define MBOX_RTC_BASE_ADDRESS 0x00000000
  972. #define MBOX_GPIO_BASE_ADDRESS 0x00005000
  973. #define MBOX_MBOX_BASE_ADDRESS 0x00008000
  974. #define RTC_STATE_V_GET(x) (((x) & RTC_STATE_V_MASK) >> RTC_STATE_V_LSB)
  975. /* Register definitions for first generation ath10k cards. These cards include
  976. * a mac thich has a register allocation similar to ath9k and at least some
  977. * registers including the ones relevant for modifying the coverage class are
  978. * identical to the ath9k definitions.
  979. * These registers are usually managed by the ath10k firmware. However by
  980. * overriding them it is possible to support coverage class modifications.
  981. */
  982. #define WAVE1_PCU_ACK_CTS_TIMEOUT 0x8014
  983. #define WAVE1_PCU_ACK_CTS_TIMEOUT_MAX 0x00003FFF
  984. #define WAVE1_PCU_ACK_CTS_TIMEOUT_ACK_MASK 0x00003FFF
  985. #define WAVE1_PCU_ACK_CTS_TIMEOUT_ACK_LSB 0
  986. #define WAVE1_PCU_ACK_CTS_TIMEOUT_CTS_MASK 0x3FFF0000
  987. #define WAVE1_PCU_ACK_CTS_TIMEOUT_CTS_LSB 16
  988. #define WAVE1_PCU_GBL_IFS_SLOT 0x1070
  989. #define WAVE1_PCU_GBL_IFS_SLOT_MASK 0x0000FFFF
  990. #define WAVE1_PCU_GBL_IFS_SLOT_MAX 0x0000FFFF
  991. #define WAVE1_PCU_GBL_IFS_SLOT_LSB 0
  992. #define WAVE1_PCU_GBL_IFS_SLOT_RESV0 0xFFFF0000
  993. #define WAVE1_PHYCLK 0x801C
  994. #define WAVE1_PHYCLK_USEC_MASK 0x0000007F
  995. #define WAVE1_PHYCLK_USEC_LSB 0
  996. /* qca6174 PLL offset/mask */
  997. #define SOC_CORE_CLK_CTRL_OFFSET 0x00000114
  998. #define SOC_CORE_CLK_CTRL_DIV_LSB 0
  999. #define SOC_CORE_CLK_CTRL_DIV_MASK 0x00000007
  1000. #define EFUSE_OFFSET 0x0000032c
  1001. #define EFUSE_XTAL_SEL_LSB 8
  1002. #define EFUSE_XTAL_SEL_MASK 0x00000700
  1003. #define BB_PLL_CONFIG_OFFSET 0x000002f4
  1004. #define BB_PLL_CONFIG_FRAC_LSB 0
  1005. #define BB_PLL_CONFIG_FRAC_MASK 0x0003ffff
  1006. #define BB_PLL_CONFIG_OUTDIV_LSB 18
  1007. #define BB_PLL_CONFIG_OUTDIV_MASK 0x001c0000
  1008. #define WLAN_PLL_SETTLE_OFFSET 0x0018
  1009. #define WLAN_PLL_SETTLE_TIME_LSB 0
  1010. #define WLAN_PLL_SETTLE_TIME_MASK 0x000007ff
  1011. #define WLAN_PLL_CONTROL_OFFSET 0x0014
  1012. #define WLAN_PLL_CONTROL_DIV_LSB 0
  1013. #define WLAN_PLL_CONTROL_DIV_MASK 0x000003ff
  1014. #define WLAN_PLL_CONTROL_REFDIV_LSB 10
  1015. #define WLAN_PLL_CONTROL_REFDIV_MASK 0x00003c00
  1016. #define WLAN_PLL_CONTROL_BYPASS_LSB 16
  1017. #define WLAN_PLL_CONTROL_BYPASS_MASK 0x00010000
  1018. #define WLAN_PLL_CONTROL_NOPWD_LSB 18
  1019. #define WLAN_PLL_CONTROL_NOPWD_MASK 0x00040000
  1020. #define RTC_SYNC_STATUS_OFFSET 0x0244
  1021. #define RTC_SYNC_STATUS_PLL_CHANGING_LSB 5
  1022. #define RTC_SYNC_STATUS_PLL_CHANGING_MASK 0x00000020
  1023. /* qca6174 PLL offset/mask end */
  1024. /* CPU_ADDR_MSB is a register, bit[3:0] is to specify which memory
  1025. * region is accessed. The memory region size is 1M.
  1026. * If host wants to access 0xX12345 at target, then CPU_ADDR_MSB[3:0]
  1027. * is 0xX.
  1028. * The following MACROs are defined to get the 0xX and the size limit.
  1029. */
  1030. #define CPU_ADDR_MSB_REGION_MASK GENMASK(23, 20)
  1031. #define CPU_ADDR_MSB_REGION_VAL(X) FIELD_GET(CPU_ADDR_MSB_REGION_MASK, X)
  1032. #define REGION_ACCESS_SIZE_LIMIT 0x100000
  1033. #define REGION_ACCESS_SIZE_MASK (REGION_ACCESS_SIZE_LIMIT - 1)
  1034. #endif /* _HW_H_ */