regs.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
  3. * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __MT76_REGS_H
  15. #define __MT76_REGS_H
  16. #include <linux/bitops.h>
  17. #ifndef GENMASK
  18. #define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l))
  19. #endif
  20. #define MT_ASIC_VERSION 0x0000
  21. #define MT76XX_REV_E3 0x22
  22. #define MT76XX_REV_E4 0x33
  23. #define MT_CMB_CTRL 0x0020
  24. #define MT_CMB_CTRL_XTAL_RDY BIT(22)
  25. #define MT_CMB_CTRL_PLL_LD BIT(23)
  26. #define MT_EFUSE_CTRL 0x0024
  27. #define MT_EFUSE_CTRL_AOUT GENMASK(5, 0)
  28. #define MT_EFUSE_CTRL_MODE GENMASK(7, 6)
  29. #define MT_EFUSE_CTRL_LDO_OFF_TIME GENMASK(13, 8)
  30. #define MT_EFUSE_CTRL_LDO_ON_TIME GENMASK(15, 14)
  31. #define MT_EFUSE_CTRL_AIN GENMASK(25, 16)
  32. #define MT_EFUSE_CTRL_KICK BIT(30)
  33. #define MT_EFUSE_CTRL_SEL BIT(31)
  34. #define MT_EFUSE_DATA_BASE 0x0028
  35. #define MT_EFUSE_DATA(_n) (MT_EFUSE_DATA_BASE + ((_n) << 2))
  36. #define MT_COEXCFG0 0x0040
  37. #define MT_COEXCFG0_COEX_EN BIT(0)
  38. #define MT_WLAN_FUN_CTRL 0x0080
  39. #define MT_WLAN_FUN_CTRL_WLAN_EN BIT(0)
  40. #define MT_WLAN_FUN_CTRL_WLAN_CLK_EN BIT(1)
  41. #define MT_WLAN_FUN_CTRL_WLAN_RESET_RF BIT(2)
  42. #define MT_WLAN_FUN_CTRL_WLAN_RESET BIT(3) /* MT76x0 */
  43. #define MT_WLAN_FUN_CTRL_CSR_F20M_CKEN BIT(3) /* MT76x2 */
  44. #define MT_WLAN_FUN_CTRL_PCIE_CLK_REQ BIT(4)
  45. #define MT_WLAN_FUN_CTRL_FRC_WL_ANT_SEL BIT(5)
  46. #define MT_WLAN_FUN_CTRL_INV_ANT_SEL BIT(6)
  47. #define MT_WLAN_FUN_CTRL_WAKE_HOST BIT(7)
  48. #define MT_WLAN_FUN_CTRL_THERM_RST BIT(8) /* MT76x2 */
  49. #define MT_WLAN_FUN_CTRL_THERM_CKEN BIT(9) /* MT76x2 */
  50. #define MT_WLAN_FUN_CTRL_GPIO_IN GENMASK(15, 8) /* MT76x0 */
  51. #define MT_WLAN_FUN_CTRL_GPIO_OUT GENMASK(23, 16) /* MT76x0 */
  52. #define MT_WLAN_FUN_CTRL_GPIO_OUT_EN GENMASK(31, 24) /* MT76x0 */
  53. #define MT_XO_CTRL0 0x0100
  54. #define MT_XO_CTRL1 0x0104
  55. #define MT_XO_CTRL2 0x0108
  56. #define MT_XO_CTRL3 0x010c
  57. #define MT_XO_CTRL4 0x0110
  58. #define MT_XO_CTRL5 0x0114
  59. #define MT_XO_CTRL5_C2_VAL GENMASK(14, 8)
  60. #define MT_XO_CTRL6 0x0118
  61. #define MT_XO_CTRL6_C2_CTRL GENMASK(14, 8)
  62. #define MT_XO_CTRL7 0x011c
  63. #define MT_WLAN_MTC_CTRL 0x10148
  64. #define MT_WLAN_MTC_CTRL_MTCMOS_PWR_UP BIT(0)
  65. #define MT_WLAN_MTC_CTRL_PWR_ACK BIT(12)
  66. #define MT_WLAN_MTC_CTRL_PWR_ACK_S BIT(13)
  67. #define MT_WLAN_MTC_CTRL_BBP_MEM_PD GENMASK(19, 16)
  68. #define MT_WLAN_MTC_CTRL_PBF_MEM_PD BIT(20)
  69. #define MT_WLAN_MTC_CTRL_FCE_MEM_PD BIT(21)
  70. #define MT_WLAN_MTC_CTRL_TSO_MEM_PD BIT(22)
  71. #define MT_WLAN_MTC_CTRL_BBP_MEM_RB BIT(24)
  72. #define MT_WLAN_MTC_CTRL_PBF_MEM_RB BIT(25)
  73. #define MT_WLAN_MTC_CTRL_FCE_MEM_RB BIT(26)
  74. #define MT_WLAN_MTC_CTRL_TSO_MEM_RB BIT(27)
  75. #define MT_WLAN_MTC_CTRL_STATE_UP BIT(28)
  76. #define MT_INT_SOURCE_CSR 0x0200
  77. #define MT_INT_MASK_CSR 0x0204
  78. #define MT_INT_RX_DONE(_n) BIT(_n)
  79. #define MT_INT_RX_DONE_ALL GENMASK(1, 0)
  80. #define MT_INT_TX_DONE_ALL GENMASK(13, 4)
  81. #define MT_INT_TX_DONE(_n) BIT(_n + 4)
  82. #define MT_INT_RX_COHERENT BIT(16)
  83. #define MT_INT_TX_COHERENT BIT(17)
  84. #define MT_INT_ANY_COHERENT BIT(18)
  85. #define MT_INT_MCU_CMD BIT(19)
  86. #define MT_INT_TBTT BIT(20)
  87. #define MT_INT_PRE_TBTT BIT(21)
  88. #define MT_INT_TX_STAT BIT(22)
  89. #define MT_INT_AUTO_WAKEUP BIT(23)
  90. #define MT_INT_GPTIMER BIT(24)
  91. #define MT_INT_RXDELAYINT BIT(26)
  92. #define MT_INT_TXDELAYINT BIT(27)
  93. #define MT_WPDMA_GLO_CFG 0x0208
  94. #define MT_WPDMA_GLO_CFG_TX_DMA_EN BIT(0)
  95. #define MT_WPDMA_GLO_CFG_TX_DMA_BUSY BIT(1)
  96. #define MT_WPDMA_GLO_CFG_RX_DMA_EN BIT(2)
  97. #define MT_WPDMA_GLO_CFG_RX_DMA_BUSY BIT(3)
  98. #define MT_WPDMA_GLO_CFG_DMA_BURST_SIZE GENMASK(5, 4)
  99. #define MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE BIT(6)
  100. #define MT_WPDMA_GLO_CFG_BIG_ENDIAN BIT(7)
  101. #define MT_WPDMA_GLO_CFG_HDR_SEG_LEN GENMASK(15, 8)
  102. #define MT_WPDMA_GLO_CFG_CLK_GATE_DIS BIT(30)
  103. #define MT_WPDMA_GLO_CFG_RX_2B_OFFSET BIT(31)
  104. #define MT_WPDMA_RST_IDX 0x020c
  105. #define MT_WPDMA_DELAY_INT_CFG 0x0210
  106. #define MT_WMM_AIFSN 0x0214
  107. #define MT_WMM_AIFSN_MASK GENMASK(3, 0)
  108. #define MT_WMM_AIFSN_SHIFT(_n) ((_n) * 4)
  109. #define MT_WMM_CWMIN 0x0218
  110. #define MT_WMM_CWMIN_MASK GENMASK(3, 0)
  111. #define MT_WMM_CWMIN_SHIFT(_n) ((_n) * 4)
  112. #define MT_WMM_CWMAX 0x021c
  113. #define MT_WMM_CWMAX_MASK GENMASK(3, 0)
  114. #define MT_WMM_CWMAX_SHIFT(_n) ((_n) * 4)
  115. #define MT_WMM_TXOP_BASE 0x0220
  116. #define MT_WMM_TXOP(_n) (MT_WMM_TXOP_BASE + (((_n) / 2) << 2))
  117. #define MT_WMM_TXOP_SHIFT(_n) ((_n & 1) * 16)
  118. #define MT_WMM_TXOP_MASK GENMASK(15, 0)
  119. #define MT_FCE_DMA_ADDR 0x0230
  120. #define MT_FCE_DMA_LEN 0x0234
  121. #define MT_USB_DMA_CFG 0x238
  122. #define MT_USB_DMA_CFG_RX_BULK_AGG_TOUT GENMASK(7, 0)
  123. #define MT_USB_DMA_CFG_RX_BULK_AGG_LMT GENMASK(15, 8)
  124. #define MT_USB_DMA_CFG_PHY_CLR BIT(16)
  125. #define MT_USB_DMA_CFG_TX_CLR BIT(19)
  126. #define MT_USB_DMA_CFG_TXOP_HALT BIT(20)
  127. #define MT_USB_DMA_CFG_RX_BULK_AGG_EN BIT(21)
  128. #define MT_USB_DMA_CFG_RX_BULK_EN BIT(22)
  129. #define MT_USB_DMA_CFG_TX_BULK_EN BIT(23)
  130. #define MT_USB_DMA_CFG_UDMA_RX_WL_DROP BIT(25)
  131. #define MT_USB_DMA_CFG_EP_OUT_VALID GENMASK(29, 27)
  132. #define MT_USB_DMA_CFG_RX_BUSY BIT(30)
  133. #define MT_USB_DMA_CFG_TX_BUSY BIT(31)
  134. #define MT_TSO_CTRL 0x0250
  135. #define MT_HEADER_TRANS_CTRL_REG 0x0260
  136. #define MT_US_CYC_CFG 0x02a4
  137. #define MT_US_CYC_CNT GENMASK(7, 0)
  138. #define MT_TX_RING_BASE 0x0300
  139. #define MT_RX_RING_BASE 0x03c0
  140. #define MT_RING_SIZE 0x10
  141. #define MT_TX_HW_QUEUE_MCU 8
  142. #define MT_TX_HW_QUEUE_MGMT 9
  143. #define MT_PBF_SYS_CTRL 0x0400
  144. #define MT_PBF_SYS_CTRL_MCU_RESET BIT(0)
  145. #define MT_PBF_SYS_CTRL_DMA_RESET BIT(1)
  146. #define MT_PBF_SYS_CTRL_MAC_RESET BIT(2)
  147. #define MT_PBF_SYS_CTRL_PBF_RESET BIT(3)
  148. #define MT_PBF_SYS_CTRL_ASY_RESET BIT(4)
  149. #define MT_PBF_CFG 0x0404
  150. #define MT_PBF_CFG_TX0Q_EN BIT(0)
  151. #define MT_PBF_CFG_TX1Q_EN BIT(1)
  152. #define MT_PBF_CFG_TX2Q_EN BIT(2)
  153. #define MT_PBF_CFG_TX3Q_EN BIT(3)
  154. #define MT_PBF_CFG_RX0Q_EN BIT(4)
  155. #define MT_PBF_CFG_RX_DROP_EN BIT(8)
  156. #define MT_PBF_TX_MAX_PCNT 0x0408
  157. #define MT_PBF_RX_MAX_PCNT 0x040c
  158. #define MT_BCN_OFFSET_BASE 0x041c
  159. #define MT_BCN_OFFSET(_n) (MT_BCN_OFFSET_BASE + ((_n) << 2))
  160. #define MT_RF_CSR_CFG 0x0500
  161. #define MT_RF_CSR_CFG_DATA GENMASK(7, 0)
  162. #define MT_RF_CSR_CFG_REG_ID GENMASK(13, 8)
  163. #define MT_RF_CSR_CFG_REG_BANK GENMASK(17, 14)
  164. #define MT_RF_CSR_CFG_WR BIT(30)
  165. #define MT_RF_CSR_CFG_KICK BIT(31)
  166. #define MT_RF_BYPASS_0 0x0504
  167. #define MT_RF_BYPASS_1 0x0508
  168. #define MT_RF_SETTING_0 0x050c
  169. #define MT_RF_DATA_WRITE 0x0524
  170. #define MT_RF_CTRL 0x0528
  171. #define MT_RF_CTRL_ADDR GENMASK(11, 0)
  172. #define MT_RF_CTRL_WRITE BIT(12)
  173. #define MT_RF_CTRL_BUSY BIT(13)
  174. #define MT_RF_CTRL_IDX BIT(16)
  175. #define MT_RF_DATA_READ 0x052c
  176. #define MT_FCE_PSE_CTRL 0x0800
  177. #define MT_FCE_PARAMETERS 0x0804
  178. #define MT_FCE_CSO 0x0808
  179. #define MT_FCE_L2_STUFF 0x080c
  180. #define MT_FCE_L2_STUFF_HT_L2_EN BIT(0)
  181. #define MT_FCE_L2_STUFF_QOS_L2_EN BIT(1)
  182. #define MT_FCE_L2_STUFF_RX_STUFF_EN BIT(2)
  183. #define MT_FCE_L2_STUFF_TX_STUFF_EN BIT(3)
  184. #define MT_FCE_L2_STUFF_WR_MPDU_LEN_EN BIT(4)
  185. #define MT_FCE_L2_STUFF_MVINV_BSWAP BIT(5)
  186. #define MT_FCE_L2_STUFF_TS_CMD_QSEL_EN GENMASK(15, 8)
  187. #define MT_FCE_L2_STUFF_TS_LEN_EN GENMASK(23, 16)
  188. #define MT_FCE_L2_STUFF_OTHER_PORT GENMASK(25, 24)
  189. #define MT_FCE_WLAN_FLOW_CONTROL1 0x0824
  190. #define MT_TX_CPU_FROM_FCE_BASE_PTR 0x09a0
  191. #define MT_TX_CPU_FROM_FCE_MAX_COUNT 0x09a4
  192. #define MT_TX_CPU_FROM_FCE_CPU_DESC_IDX 0x09a8
  193. #define MT_FCE_PDMA_GLOBAL_CONF 0x09c4
  194. #define MT_PAUSE_ENABLE_CONTROL1 0x0a38
  195. #define MT_FCE_SKIP_FS 0x0a6c
  196. #define MT_MAC_CSR0 0x1000
  197. #define MT_MAC_SYS_CTRL 0x1004
  198. #define MT_MAC_SYS_CTRL_RESET_CSR BIT(0)
  199. #define MT_MAC_SYS_CTRL_RESET_BBP BIT(1)
  200. #define MT_MAC_SYS_CTRL_ENABLE_TX BIT(2)
  201. #define MT_MAC_SYS_CTRL_ENABLE_RX BIT(3)
  202. #define MT_MAC_ADDR_DW0 0x1008
  203. #define MT_MAC_ADDR_DW1 0x100c
  204. #define MT_MAC_ADDR_DW1_U2ME_MASK GENMASK(23, 16)
  205. #define MT_MAC_BSSID_DW0 0x1010
  206. #define MT_MAC_BSSID_DW1 0x1014
  207. #define MT_MAC_BSSID_DW1_ADDR GENMASK(15, 0)
  208. #define MT_MAC_BSSID_DW1_MBSS_MODE GENMASK(17, 16)
  209. #define MT_MAC_BSSID_DW1_MBEACON_N GENMASK(20, 18)
  210. #define MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT BIT(21)
  211. #define MT_MAC_BSSID_DW1_MBSS_MODE_B2 BIT(22)
  212. #define MT_MAC_BSSID_DW1_MBEACON_N_B3 BIT(23)
  213. #define MT_MAC_BSSID_DW1_MBSS_IDX_BYTE GENMASK(26, 24)
  214. #define MT_MAX_LEN_CFG 0x1018
  215. #define MT_MAX_LEN_CFG_AMPDU GENMASK(13, 12)
  216. #define MT_BBP_CSR_CFG 0x101c
  217. #define MT_BBP_CSR_CFG_VAL GENMASK(7, 0)
  218. #define MT_BBP_CSR_CFG_REG_NUM GENMASK(15, 8)
  219. #define MT_BBP_CSR_CFG_READ BIT(16)
  220. #define MT_BBP_CSR_CFG_BUSY BIT(17)
  221. #define MT_BBP_CSR_CFG_PAR_DUR BIT(18)
  222. #define MT_BBP_CSR_CFG_RW_MODE BIT(19)
  223. #define MT_AMPDU_MAX_LEN_20M1S 0x1030
  224. #define MT_AMPDU_MAX_LEN_20M2S 0x1034
  225. #define MT_AMPDU_MAX_LEN_40M1S 0x1038
  226. #define MT_AMPDU_MAX_LEN_40M2S 0x103c
  227. #define MT_AMPDU_MAX_LEN 0x1040
  228. #define MT_WCID_DROP_BASE 0x106c
  229. #define MT_WCID_DROP(_n) (MT_WCID_DROP_BASE + ((_n) >> 5) * 4)
  230. #define MT_WCID_DROP_MASK(_n) BIT((_n) % 32)
  231. #define MT_BCN_BYPASS_MASK 0x108c
  232. #define MT_MAC_APC_BSSID_BASE 0x1090
  233. #define MT_MAC_APC_BSSID_L(_n) (MT_MAC_APC_BSSID_BASE + ((_n) * 8))
  234. #define MT_MAC_APC_BSSID_H(_n) (MT_MAC_APC_BSSID_BASE + ((_n) * 8 + 4))
  235. #define MT_MAC_APC_BSSID_H_ADDR GENMASK(15, 0)
  236. #define MT_MAC_APC_BSSID0_H_EN BIT(16)
  237. #define MT_XIFS_TIME_CFG 0x1100
  238. #define MT_XIFS_TIME_CFG_CCK_SIFS GENMASK(7, 0)
  239. #define MT_XIFS_TIME_CFG_OFDM_SIFS GENMASK(15, 8)
  240. #define MT_XIFS_TIME_CFG_OFDM_XIFS GENMASK(19, 16)
  241. #define MT_XIFS_TIME_CFG_EIFS GENMASK(28, 20)
  242. #define MT_XIFS_TIME_CFG_BB_RXEND_EN BIT(29)
  243. #define MT_BKOFF_SLOT_CFG 0x1104
  244. #define MT_BKOFF_SLOT_CFG_SLOTTIME GENMASK(7, 0)
  245. #define MT_BKOFF_SLOT_CFG_CC_DELAY GENMASK(11, 8)
  246. #define MT_BEACON_TIME_CFG 0x1114
  247. #define MT_BEACON_TIME_CFG_INTVAL GENMASK(15, 0)
  248. #define MT_BEACON_TIME_CFG_TIMER_EN BIT(16)
  249. #define MT_BEACON_TIME_CFG_SYNC_MODE GENMASK(18, 17)
  250. #define MT_BEACON_TIME_CFG_TBTT_EN BIT(19)
  251. #define MT_BEACON_TIME_CFG_BEACON_TX BIT(20)
  252. #define MT_BEACON_TIME_CFG_TSF_COMP GENMASK(31, 24)
  253. #define MT_TBTT_SYNC_CFG 0x1118
  254. #define MT_TBTT_TIMER_CFG 0x1124
  255. #define MT_INT_TIMER_CFG 0x1128
  256. #define MT_INT_TIMER_CFG_PRE_TBTT GENMASK(15, 0)
  257. #define MT_INT_TIMER_CFG_GP_TIMER GENMASK(31, 16)
  258. #define MT_INT_TIMER_EN 0x112c
  259. #define MT_INT_TIMER_EN_PRE_TBTT_EN BIT(0)
  260. #define MT_INT_TIMER_EN_GP_TIMER_EN BIT(1)
  261. #define MT_MAC_STATUS 0x1200
  262. #define MT_MAC_STATUS_TX BIT(0)
  263. #define MT_MAC_STATUS_RX BIT(1)
  264. #define MT_PWR_PIN_CFG 0x1204
  265. #define MT_AUX_CLK_CFG 0x120c
  266. #define MT_BB_PA_MODE_CFG0 0x1214
  267. #define MT_BB_PA_MODE_CFG1 0x1218
  268. #define MT_RF_PA_MODE_CFG0 0x121c
  269. #define MT_RF_PA_MODE_CFG1 0x1220
  270. #define MT_RF_PA_MODE_ADJ0 0x1228
  271. #define MT_RF_PA_MODE_ADJ1 0x122c
  272. #define MT_DACCLK_EN_DLY_CFG 0x1264
  273. #define MT_EDCA_CFG_BASE 0x1300
  274. #define MT_EDCA_CFG_AC(_n) (MT_EDCA_CFG_BASE + ((_n) << 2))
  275. #define MT_EDCA_CFG_TXOP GENMASK(7, 0)
  276. #define MT_EDCA_CFG_AIFSN GENMASK(11, 8)
  277. #define MT_EDCA_CFG_CWMIN GENMASK(15, 12)
  278. #define MT_EDCA_CFG_CWMAX GENMASK(19, 16)
  279. #define MT_TX_PWR_CFG_0 0x1314
  280. #define MT_TX_PWR_CFG_1 0x1318
  281. #define MT_TX_PWR_CFG_2 0x131c
  282. #define MT_TX_PWR_CFG_3 0x1320
  283. #define MT_TX_PWR_CFG_4 0x1324
  284. #define MT_TX_BAND_CFG 0x132c
  285. #define MT_TX_BAND_CFG_UPPER_40M BIT(0)
  286. #define MT_TX_BAND_CFG_5G BIT(1)
  287. #define MT_TX_BAND_CFG_2G BIT(2)
  288. #define MT_HT_FBK_TO_LEGACY 0x1384
  289. #define MT_TX_MPDU_ADJ_INT 0x1388
  290. #define MT_TX_PWR_CFG_7 0x13d4
  291. #define MT_TX_PWR_CFG_8 0x13d8
  292. #define MT_TX_PWR_CFG_9 0x13dc
  293. #define MT_TX_SW_CFG0 0x1330
  294. #define MT_TX_SW_CFG1 0x1334
  295. #define MT_TX_SW_CFG2 0x1338
  296. #define MT_TXOP_CTRL_CFG 0x1340
  297. #define MT_TXOP_TRUN_EN GENMASK(5, 0)
  298. #define MT_TXOP_EXT_CCA_DLY GENMASK(15, 8)
  299. #define MT_TXOP_CTRL
  300. #define MT_TX_RTS_CFG 0x1344
  301. #define MT_TX_RTS_CFG_RETRY_LIMIT GENMASK(7, 0)
  302. #define MT_TX_RTS_CFG_THRESH GENMASK(23, 8)
  303. #define MT_TX_RTS_FALLBACK BIT(24)
  304. #define MT_TX_TIMEOUT_CFG 0x1348
  305. #define MT_TX_RETRY_CFG 0x134c
  306. #define MT_TX_LINK_CFG 0x1350
  307. #define MT_HT_FBK_CFG0 0x1354
  308. #define MT_HT_FBK_CFG1 0x1358
  309. #define MT_LG_FBK_CFG0 0x135c
  310. #define MT_LG_FBK_CFG1 0x1360
  311. #define MT_CCK_PROT_CFG 0x1364
  312. #define MT_OFDM_PROT_CFG 0x1368
  313. #define MT_MM20_PROT_CFG 0x136c
  314. #define MT_MM40_PROT_CFG 0x1370
  315. #define MT_GF20_PROT_CFG 0x1374
  316. #define MT_GF40_PROT_CFG 0x1378
  317. #define MT_PROT_RATE GENMASK(15, 0)
  318. #define MT_PROT_CTRL_RTS_CTS BIT(16)
  319. #define MT_PROT_CTRL_CTS2SELF BIT(17)
  320. #define MT_PROT_NAV_SHORT BIT(18)
  321. #define MT_PROT_NAV_LONG BIT(19)
  322. #define MT_PROT_TXOP_ALLOW_CCK BIT(20)
  323. #define MT_PROT_TXOP_ALLOW_OFDM BIT(21)
  324. #define MT_PROT_TXOP_ALLOW_MM20 BIT(22)
  325. #define MT_PROT_TXOP_ALLOW_MM40 BIT(23)
  326. #define MT_PROT_TXOP_ALLOW_GF20 BIT(24)
  327. #define MT_PROT_TXOP_ALLOW_GF40 BIT(25)
  328. #define MT_PROT_RTS_THR_EN BIT(26)
  329. #define MT_PROT_RATE_CCK_11 0x0003
  330. #define MT_PROT_RATE_OFDM_6 0x4000
  331. #define MT_PROT_RATE_OFDM_24 0x4004
  332. #define MT_PROT_RATE_DUP_OFDM_24 0x4084
  333. #define MT_PROT_TXOP_ALLOW_ALL GENMASK(25, 20)
  334. #define MT_PROT_TXOP_ALLOW_BW20 (MT_PROT_TXOP_ALLOW_ALL & \
  335. ~MT_PROT_TXOP_ALLOW_MM40 & \
  336. ~MT_PROT_TXOP_ALLOW_GF40)
  337. #define MT_EXP_ACK_TIME 0x1380
  338. #define MT_TX_PWR_CFG_0_EXT 0x1390
  339. #define MT_TX_PWR_CFG_1_EXT 0x1394
  340. #define MT_TX_FBK_LIMIT 0x1398
  341. #define MT_TX_FBK_LIMIT_MPDU_FBK GENMASK(7, 0)
  342. #define MT_TX_FBK_LIMIT_AMPDU_FBK GENMASK(15, 8)
  343. #define MT_TX_FBK_LIMIT_MPDU_UP_CLEAR BIT(16)
  344. #define MT_TX_FBK_LIMIT_AMPDU_UP_CLEAR BIT(17)
  345. #define MT_TX_FBK_LIMIT_RATE_LUT BIT(18)
  346. #define MT_TX0_RF_GAIN_CORR 0x13a0
  347. #define MT_TX1_RF_GAIN_CORR 0x13a4
  348. #define MT_TX0_RF_GAIN_ATTEN 0x13a8
  349. #define MT_TX_ALC_CFG_0 0x13b0
  350. #define MT_TX_ALC_CFG_0_CH_INIT_0 GENMASK(5, 0)
  351. #define MT_TX_ALC_CFG_0_CH_INIT_1 GENMASK(13, 8)
  352. #define MT_TX_ALC_CFG_0_LIMIT_0 GENMASK(21, 16)
  353. #define MT_TX_ALC_CFG_0_LIMIT_1 GENMASK(29, 24)
  354. #define MT_TX_ALC_CFG_1 0x13b4
  355. #define MT_TX_ALC_CFG_1_TEMP_COMP GENMASK(5, 0)
  356. #define MT_TX_ALC_CFG_2 0x13a8
  357. #define MT_TX_ALC_CFG_2_TEMP_COMP GENMASK(5, 0)
  358. #define MT_TX0_BB_GAIN_ATTEN 0x13c0
  359. #define MT_TX_ALC_VGA3 0x13c8
  360. #define MT_TX_PROT_CFG6 0x13e0
  361. #define MT_TX_PROT_CFG7 0x13e4
  362. #define MT_TX_PROT_CFG8 0x13e8
  363. #define MT_PIFS_TX_CFG 0x13ec
  364. #define MT_RX_FILTR_CFG 0x1400
  365. #define MT_RX_FILTR_CFG_CRC_ERR BIT(0)
  366. #define MT_RX_FILTR_CFG_PHY_ERR BIT(1)
  367. #define MT_RX_FILTR_CFG_PROMISC BIT(2)
  368. #define MT_RX_FILTR_CFG_OTHER_BSS BIT(3)
  369. #define MT_RX_FILTR_CFG_VER_ERR BIT(4)
  370. #define MT_RX_FILTR_CFG_MCAST BIT(5)
  371. #define MT_RX_FILTR_CFG_BCAST BIT(6)
  372. #define MT_RX_FILTR_CFG_DUP BIT(7)
  373. #define MT_RX_FILTR_CFG_CFACK BIT(8)
  374. #define MT_RX_FILTR_CFG_CFEND BIT(9)
  375. #define MT_RX_FILTR_CFG_ACK BIT(10)
  376. #define MT_RX_FILTR_CFG_CTS BIT(11)
  377. #define MT_RX_FILTR_CFG_RTS BIT(12)
  378. #define MT_RX_FILTR_CFG_PSPOLL BIT(13)
  379. #define MT_RX_FILTR_CFG_BA BIT(14)
  380. #define MT_RX_FILTR_CFG_BAR BIT(15)
  381. #define MT_RX_FILTR_CFG_CTRL_RSV BIT(16)
  382. #define MT_AUTO_RSP_CFG 0x1404
  383. #define MT_AUTO_RSP_PREAMB_SHORT BIT(4)
  384. #define MT_LEGACY_BASIC_RATE 0x1408
  385. #define MT_HT_BASIC_RATE 0x140c
  386. #define MT_RX_PARSER_CFG 0x1418
  387. #define MT_RX_PARSER_RX_SET_NAV_ALL BIT(0)
  388. #define MT_EXT_CCA_CFG 0x141c
  389. #define MT_EXT_CCA_CFG_CCA0 GENMASK(1, 0)
  390. #define MT_EXT_CCA_CFG_CCA1 GENMASK(3, 2)
  391. #define MT_EXT_CCA_CFG_CCA2 GENMASK(5, 4)
  392. #define MT_EXT_CCA_CFG_CCA3 GENMASK(7, 6)
  393. #define MT_EXT_CCA_CFG_CCA_MASK GENMASK(11, 8)
  394. #define MT_EXT_CCA_CFG_ED_CCA_MASK GENMASK(15, 12)
  395. #define MT_TX_SW_CFG3 0x1478
  396. #define MT_PN_PAD_MODE 0x150c
  397. #define MT_TXOP_HLDR_ET 0x1608
  398. #define MT_PROT_AUTO_TX_CFG 0x1648
  399. #define MT_RX_STA_CNT0 0x1700
  400. #define MT_RX_STA_CNT1 0x1704
  401. #define MT_RX_STA_CNT2 0x1708
  402. #define MT_TX_STA_CNT0 0x170c
  403. #define MT_TX_STA_CNT1 0x1710
  404. #define MT_TX_STA_CNT2 0x1714
  405. /* Vendor driver defines content of the second word of STAT_FIFO as follows:
  406. * MT_TX_STAT_FIFO_RATE GENMASK(26, 16)
  407. * MT_TX_STAT_FIFO_ETXBF BIT(27)
  408. * MT_TX_STAT_FIFO_SND BIT(28)
  409. * MT_TX_STAT_FIFO_ITXBF BIT(29)
  410. * However, tests show that b16-31 have the same layout as TXWI rate_ctl
  411. * with rate set to rate at which frame was acked.
  412. */
  413. #define MT_TX_STAT_FIFO 0x1718
  414. #define MT_TX_STAT_FIFO_VALID BIT(0)
  415. #define MT_TX_STAT_FIFO_PID_TYPE GENMASK(4, 1)
  416. #define MT_TX_STAT_FIFO_SUCCESS BIT(5)
  417. #define MT_TX_STAT_FIFO_AGGR BIT(6)
  418. #define MT_TX_STAT_FIFO_ACKREQ BIT(7)
  419. #define MT_TX_STAT_FIFO_WCID GENMASK(15, 8)
  420. #define MT_TX_STAT_FIFO_RATE GENMASK(31, 16)
  421. #define MT_TX_AGG_STAT 0x171c
  422. #define MT_TX_AGG_CNT_BASE0 0x1720
  423. #define MT_MPDU_DENSITY_CNT 0x1740
  424. #define MT_TX_AGG_CNT_BASE1 0x174c
  425. #define MT_TX_AGG_CNT(_id) ((_id) < 8 ? \
  426. MT_TX_AGG_CNT_BASE0 + ((_id) << 2) : \
  427. MT_TX_AGG_CNT_BASE1 + ((_id - 8) << 2))
  428. #define MT_TX_STAT_FIFO_EXT 0x1798
  429. #define MT_TX_STAT_FIFO_EXT_RETRY GENMASK(7, 0)
  430. #define MT_BBP_CORE_BASE 0x2000
  431. #define MT_BBP_IBI_BASE 0x2100
  432. #define MT_BBP_AGC_BASE 0x2300
  433. #define MT_BBP_TXC_BASE 0x2400
  434. #define MT_BBP_RXC_BASE 0x2500
  435. #define MT_BBP_TXO_BASE 0x2600
  436. #define MT_BBP_TXBE_BASE 0x2700
  437. #define MT_BBP_RXFE_BASE 0x2800
  438. #define MT_BBP_RXO_BASE 0x2900
  439. #define MT_BBP_DFS_BASE 0x2a00
  440. #define MT_BBP_TR_BASE 0x2b00
  441. #define MT_BBP_CAL_BASE 0x2c00
  442. #define MT_BBP_DSC_BASE 0x2e00
  443. #define MT_BBP_PFMU_BASE 0x2f00
  444. #define MT_BBP(_type, _n) (MT_BBP_##_type##_BASE + ((_n) << 2))
  445. #define MT_BBP_CORE_R1_BW GENMASK(4, 3)
  446. #define MT_BBP_AGC_R0_CTRL_CHAN GENMASK(9, 8)
  447. #define MT_BBP_AGC_R0_BW GENMASK(14, 12)
  448. /* AGC, R4/R5 */
  449. #define MT_BBP_AGC_LNA_GAIN GENMASK(21, 16)
  450. /* AGC, R8/R9 */
  451. #define MT_BBP_AGC_GAIN GENMASK(14, 8)
  452. #define MT_BBP_AGC20_RSSI0 GENMASK(7, 0)
  453. #define MT_BBP_AGC20_RSSI1 GENMASK(15, 8)
  454. #define MT_BBP_TXBE_R0_CTRL_CHAN GENMASK(1, 0)
  455. #define MT_WCID_ADDR_BASE 0x1800
  456. #define MT_WCID_ADDR(_n) (MT_WCID_ADDR_BASE + (_n) * 8)
  457. #define MT_SRAM_BASE 0x4000
  458. #define MT_WCID_KEY_BASE 0x8000
  459. #define MT_WCID_KEY(_n) (MT_WCID_KEY_BASE + (_n) * 32)
  460. #define MT_WCID_IV_BASE 0xa000
  461. #define MT_WCID_IV(_n) (MT_WCID_IV_BASE + (_n) * 8)
  462. #define MT_WCID_ATTR_BASE 0xa800
  463. #define MT_WCID_ATTR(_n) (MT_WCID_ATTR_BASE + (_n) * 4)
  464. #define MT_WCID_ATTR_PAIRWISE BIT(0)
  465. #define MT_WCID_ATTR_PKEY_MODE GENMASK(3, 1)
  466. #define MT_WCID_ATTR_BSS_IDX GENMASK(6, 4)
  467. #define MT_WCID_ATTR_RXWI_UDF GENMASK(9, 7)
  468. #define MT_WCID_ATTR_PKEY_MODE_EXT BIT(10)
  469. #define MT_WCID_ATTR_BSS_IDX_EXT BIT(11)
  470. #define MT_WCID_ATTR_WAPI_MCBC BIT(15)
  471. #define MT_WCID_ATTR_WAPI_KEYID GENMASK(31, 24)
  472. #define MT_SKEY_BASE_0 0xac00
  473. #define MT_SKEY_BASE_1 0xb400
  474. #define MT_SKEY_0(_bss, _idx) \
  475. (MT_SKEY_BASE_0 + (4 * (_bss) + _idx) * 32)
  476. #define MT_SKEY_1(_bss, _idx) \
  477. (MT_SKEY_BASE_1 + (4 * ((_bss) & 7) + _idx) * 32)
  478. #define MT_SKEY(_bss, _idx) \
  479. ((_bss & 8) ? MT_SKEY_1(_bss, _idx) : MT_SKEY_0(_bss, _idx))
  480. #define MT_SKEY_MODE_BASE_0 0xb000
  481. #define MT_SKEY_MODE_BASE_1 0xb3f0
  482. #define MT_SKEY_MODE_0(_bss) \
  483. (MT_SKEY_MODE_BASE_0 + ((_bss / 2) << 2))
  484. #define MT_SKEY_MODE_1(_bss) \
  485. (MT_SKEY_MODE_BASE_1 + ((((_bss) & 7) / 2) << 2))
  486. #define MT_SKEY_MODE(_bss) \
  487. ((_bss & 8) ? MT_SKEY_MODE_1(_bss) : MT_SKEY_MODE_0(_bss))
  488. #define MT_SKEY_MODE_MASK GENMASK(3, 0)
  489. #define MT_SKEY_MODE_SHIFT(_bss, _idx) (4 * ((_idx) + 4 * (_bss & 1)))
  490. #define MT_BEACON_BASE 0xc000
  491. #define MT_TEMP_SENSOR 0x1d000
  492. #define MT_TEMP_SENSOR_VAL GENMASK(6, 0)
  493. enum mt76_cipher_type {
  494. MT_CIPHER_NONE,
  495. MT_CIPHER_WEP40,
  496. MT_CIPHER_WEP104,
  497. MT_CIPHER_TKIP,
  498. MT_CIPHER_AES_CCMP,
  499. MT_CIPHER_CKIP40,
  500. MT_CIPHER_CKIP104,
  501. MT_CIPHER_CKIP128,
  502. MT_CIPHER_WAPI,
  503. };
  504. #endif