rtw8822c.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright(c) 2018-2019 Realtek Corporation
  3. */
  4. #ifndef __RTW8822C_H__
  5. #define __RTW8822C_H__
  6. #include <asm/byteorder.h>
  7. struct rtw8822cu_efuse {
  8. u8 res0[0x30]; /* 0x120 */
  9. u8 vid[2]; /* 0x150 */
  10. u8 pid[2];
  11. u8 res1[3];
  12. u8 mac_addr[ETH_ALEN]; /* 0x157 */
  13. u8 res2[0x3d];
  14. };
  15. struct rtw8822ce_efuse {
  16. u8 mac_addr[ETH_ALEN]; /* 0x120 */
  17. u8 vender_id[2];
  18. u8 device_id[2];
  19. u8 sub_vender_id[2];
  20. u8 sub_device_id[2];
  21. u8 pmc[2];
  22. u8 exp_device_cap[2];
  23. u8 msi_cap;
  24. u8 ltr_cap; /* 0x133 */
  25. u8 exp_link_control[2];
  26. u8 link_cap[4];
  27. u8 link_control[2];
  28. u8 serial_number[8];
  29. u8 res0:2; /* 0x144 */
  30. u8 ltr_en:1;
  31. u8 res1:2;
  32. u8 obff:2;
  33. u8 res2:3;
  34. u8 obff_cap:2;
  35. u8 res3:4;
  36. u8 class_code[3];
  37. u8 res4;
  38. u8 pci_pm_L1_2_supp:1;
  39. u8 pci_pm_L1_1_supp:1;
  40. u8 aspm_pm_L1_2_supp:1;
  41. u8 aspm_pm_L1_1_supp:1;
  42. u8 L1_pm_substates_supp:1;
  43. u8 res5:3;
  44. u8 port_common_mode_restore_time;
  45. u8 port_t_power_on_scale:2;
  46. u8 res6:1;
  47. u8 port_t_power_on_value:5;
  48. u8 res7;
  49. };
  50. struct rtw8822c_efuse {
  51. __le16 rtl_id;
  52. u8 res0[0x0e];
  53. /* power index for four RF paths */
  54. struct rtw_txpwr_idx txpwr_idx_table[4];
  55. u8 channel_plan; /* 0xb8 */
  56. u8 xtal_k;
  57. u8 res1;
  58. u8 iqk_lck;
  59. u8 res2[5]; /* 0xbc */
  60. u8 rf_board_option;
  61. u8 rf_feature_option;
  62. u8 rf_bt_setting;
  63. u8 eeprom_version;
  64. u8 eeprom_customer_id;
  65. u8 tx_bb_swing_setting_2g;
  66. u8 tx_bb_swing_setting_5g;
  67. u8 tx_pwr_calibrate_rate;
  68. u8 rf_antenna_option; /* 0xc9 */
  69. u8 rfe_option;
  70. u8 country_code[2];
  71. u8 res3[3];
  72. u8 path_a_thermal; /* 0xd0 */
  73. u8 path_b_thermal;
  74. u8 res4[2];
  75. u8 rx_gain_gap_2g_ofdm;
  76. u8 res5;
  77. u8 rx_gain_gap_2g_cck;
  78. u8 res6;
  79. u8 rx_gain_gap_5gl;
  80. u8 res7;
  81. u8 rx_gain_gap_5gm;
  82. u8 res8;
  83. u8 rx_gain_gap_5gh;
  84. u8 res9;
  85. u8 res10[0x42];
  86. union {
  87. struct rtw8822cu_efuse u;
  88. struct rtw8822ce_efuse e;
  89. };
  90. };
  91. enum rtw8822c_dpk_agc_phase {
  92. RTW_DPK_GAIN_CHECK,
  93. RTW_DPK_GAIN_LARGE,
  94. RTW_DPK_GAIN_LESS,
  95. RTW_DPK_GL_LARGE,
  96. RTW_DPK_GL_LESS,
  97. RTW_DPK_LOSS_CHECK,
  98. RTW_DPK_AGC_OUT,
  99. };
  100. enum rtw8822c_dpk_one_shot_action {
  101. RTW_DPK_CAL_PWR,
  102. RTW_DPK_GAIN_LOSS,
  103. RTW_DPK_DO_DPK,
  104. RTW_DPK_DPK_ON,
  105. RTW_DPK_DAGC,
  106. RTW_DPK_ACTION_MAX
  107. };
  108. void rtw8822c_parse_tbl_dpk(struct rtw_dev *rtwdev,
  109. const struct rtw_table *tbl);
  110. extern const struct rtw_chip_info rtw8822c_hw_spec;
  111. #define RTW_DECL_TABLE_DPK(name) \
  112. const struct rtw_table name ## _tbl = { \
  113. .data = name, \
  114. .size = ARRAY_SIZE(name), \
  115. .parse = rtw8822c_parse_tbl_dpk, \
  116. }
  117. #define DACK_PATH_8822C 2
  118. #define DACK_REG_8822C 16
  119. #define DACK_RF_8822C 1
  120. #define DACK_SN_8822C 100
  121. /* phy status page0 */
  122. #define GET_PHY_STAT_P0_PWDB_A(phy_stat) \
  123. le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
  124. #define GET_PHY_STAT_P0_PWDB_B(phy_stat) \
  125. le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(7, 0))
  126. #define GET_PHY_STAT_P0_GAIN_A(phy_stat) \
  127. le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(21, 16))
  128. #define GET_PHY_STAT_P0_CHANNEL(phy_stat) \
  129. le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(23, 16))
  130. #define GET_PHY_STAT_P0_GAIN_B(phy_stat) \
  131. le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(29, 24))
  132. /* phy status page1 */
  133. #define GET_PHY_STAT_P1_PWDB_A(phy_stat) \
  134. le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
  135. #define GET_PHY_STAT_P1_PWDB_B(phy_stat) \
  136. le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(23, 16))
  137. #define GET_PHY_STAT_P1_L_RXSC(phy_stat) \
  138. le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
  139. #define GET_PHY_STAT_P1_HT_RXSC(phy_stat) \
  140. le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))
  141. #define GET_PHY_STAT_P1_CHANNEL(phy_stat) \
  142. le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(23, 16))
  143. #define GET_PHY_STAT_P1_RXEVM_A(phy_stat) \
  144. le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(7, 0))
  145. #define GET_PHY_STAT_P1_RXEVM_B(phy_stat) \
  146. le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(15, 8))
  147. #define GET_PHY_STAT_P1_CFO_TAIL_A(phy_stat) \
  148. le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(7, 0))
  149. #define GET_PHY_STAT_P1_CFO_TAIL_B(phy_stat) \
  150. le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(15, 8))
  151. #define GET_PHY_STAT_P1_RXSNR_A(phy_stat) \
  152. le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(7, 0))
  153. #define GET_PHY_STAT_P1_RXSNR_B(phy_stat) \
  154. le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8))
  155. #define RTW8822C_EDCCA_MAX 0x7f
  156. #define REG_ANAPARLDO_POW_MAC 0x0029
  157. #define BIT_LDOE25_PON BIT(0)
  158. #define XCAP_MASK GENMASK(6, 0)
  159. #define CFO_TRK_ENABLE_TH 20
  160. #define CFO_TRK_STOP_TH 10
  161. #define CFO_TRK_ADJ_TH 10
  162. #define REG_TXDFIR0 0x808
  163. #define REG_DFIRBW 0x810
  164. #define REG_ANTMAP0 0x820
  165. #define BIT_ANT_PATH GENMASK(1, 0)
  166. #define REG_ANTMAP 0x824
  167. #define REG_EDCCA_DECISION 0x844
  168. #define BIT_EDCCA_OPTION GENMASK(30, 29)
  169. #define REG_DYMPRITH 0x86c
  170. #define REG_DYMENTH0 0x870
  171. #define REG_DYMENTH 0x874
  172. #define REG_SBD 0x88c
  173. #define BITS_SUBTUNE GENMASK(15, 12)
  174. #define REG_DYMTHMIN 0x8a4
  175. #define REG_TXBWCTL 0x9b0
  176. #define REG_TXCLK 0x9b4
  177. #define REG_SCOTRK 0xc30
  178. #define REG_MRCM 0xc38
  179. #define REG_AGCSWSH 0xc44
  180. #define REG_ANTWTPD 0xc54
  181. #define REG_PT_CHSMO 0xcbc
  182. #define BIT_PT_OPT BIT(21)
  183. #define REG_ORITXCODE 0x1800
  184. #define BIT_PATH_EN BIT(31)
  185. #define REG_3WIRE 0x180c
  186. #define BIT_DIS_SHARERX_TXGAT BIT(27)
  187. #define BIT_3WIRE_TX_EN BIT(0)
  188. #define BIT_3WIRE_RX_EN BIT(1)
  189. #define BIT_3WIRE_EN GENMASK(1, 0)
  190. #define BIT_3WIRE_PI_ON BIT(28)
  191. #define REG_ANAPAR_A 0x1830
  192. #define BIT_ANAPAR_UPDATE BIT(29)
  193. #define REG_RFTXEN_GCK_A 0x1864
  194. #define BIT_RFTXEN_GCK_FORCE_ON BIT(31)
  195. #define REG_DIS_SHARE_RX_A 0x186c
  196. #define BIT_TX_SCALE_0DB BIT(7)
  197. #define REG_RXAGCCTL0 0x18ac
  198. #define BITS_RXAGC_CCK GENMASK(15, 12)
  199. #define BITS_RXAGC_OFDM GENMASK(8, 4)
  200. #define REG_DCKA_I_0 0x18bc
  201. #define REG_DCKA_I_1 0x18c0
  202. #define REG_DCKA_Q_0 0x18d8
  203. #define REG_DCKA_Q_1 0x18dc
  204. #define REG_CCKSB 0x1a00
  205. #define BIT_BBMODE GENMASK(2, 1)
  206. #define REG_RXCCKSEL 0x1a04
  207. #define REG_BGCTRL 0x1a14
  208. #define BITS_RX_IQ_WEIGHT (BIT(8) | BIT(9))
  209. #define REG_TXF0 0x1a20
  210. #define REG_TXF1 0x1a24
  211. #define REG_TXF2 0x1a28
  212. #define REG_CCANRX 0x1a2c
  213. #define BIT_CCK_FA_RST (BIT(14) | BIT(15))
  214. #define BIT_OFDM_FA_RST (BIT(12) | BIT(13))
  215. #define REG_CCK_FACNT 0x1a5c
  216. #define REG_CCKTXONLY 0x1a80
  217. #define BIT_BB_CCK_CHECK_EN BIT(18)
  218. #define REG_TXF3 0x1a98
  219. #define REG_TXF4 0x1a9c
  220. #define REG_TXF5 0x1aa0
  221. #define REG_TXF6 0x1aac
  222. #define REG_TXF7 0x1ab0
  223. #define REG_CCK_SOURCE 0x1abc
  224. #define BIT_NBI_EN BIT(30)
  225. #define REG_NCTL0 0x1b00
  226. #define BIT_SEL_PATH GENMASK(2, 1)
  227. #define BIT_SUBPAGE GENMASK(3, 0)
  228. #define REG_DPD_CTL0_S0 0x1b04
  229. #define BIT_GS_PWSF GENMASK(27, 0)
  230. #define REG_DPD_CTL1_S0 0x1b08
  231. #define BIT_DPD_EN BIT(31)
  232. #define BIT_PS_EN BIT(7)
  233. #define REG_IQKSTAT 0x1b10
  234. #define REG_IQK_CTL1 0x1b20
  235. #define BIT_TX_CFIR GENMASK(31, 30)
  236. #define BIT_CFIR_EN GENMASK(26, 24)
  237. #define BIT_BYPASS_DPD BIT(25)
  238. #define REG_TX_TONE_IDX 0x1b2c
  239. #define REG_DPD_LUT0 0x1b44
  240. #define BIT_GLOSS_DB GENMASK(14, 12)
  241. #define REG_DPD_CTL0_S1 0x1b5c
  242. #define REG_DPD_CTL1_S1 0x1b60
  243. #define REG_DPD_AGC 0x1b67
  244. #define REG_TABLE_SEL 0x1b98
  245. #define BIT_I_GAIN GENMASK(19, 16)
  246. #define BIT_GAIN_RST BIT(15)
  247. #define BIT_Q_GAIN_SEL GENMASK(14, 12)
  248. #define BIT_Q_GAIN GENMASK(11, 0)
  249. #define REG_TX_GAIN_SET 0x1b9c
  250. #define BIT_GAPK_RPT_IDX GENMASK(11, 8)
  251. #define REG_DPD_CTL0 0x1bb4
  252. #define REG_SINGLE_TONE_SW 0x1bb8
  253. #define BIT_IRQ_TEST_MODE BIT(20)
  254. #define REG_R_CONFIG 0x1bcc
  255. #define BIT_INNER_LB BIT(21)
  256. #define BIT_IQ_SWITCH GENMASK(5, 0)
  257. #define BIT_2G_SWING 0x2d
  258. #define BIT_5G_SWING 0x36
  259. #define REG_RXSRAM_CTL 0x1bd4
  260. #define BIT_RPT_EN BIT(21)
  261. #define BIT_RPT_SEL GENMASK(20, 16)
  262. #define BIT_DPD_CLK GENMASK(7, 4)
  263. #define REG_DPD_CTL11 0x1be4
  264. #define REG_DPD_CTL12 0x1be8
  265. #define REG_DPD_CTL15 0x1bf4
  266. #define REG_DPD_CTL16 0x1bf8
  267. #define REG_STAT_RPT 0x1bfc
  268. #define BIT_RPT_DGAIN GENMASK(27, 16)
  269. #define BIT_GAPK_RPT0 GENMASK(3, 0)
  270. #define BIT_GAPK_RPT1 GENMASK(7, 4)
  271. #define BIT_GAPK_RPT2 GENMASK(11, 8)
  272. #define BIT_GAPK_RPT3 GENMASK(15, 12)
  273. #define BIT_GAPK_RPT4 GENMASK(19, 16)
  274. #define BIT_GAPK_RPT5 GENMASK(23, 20)
  275. #define BIT_GAPK_RPT6 GENMASK(27, 24)
  276. #define BIT_GAPK_RPT7 GENMASK(31, 28)
  277. #define REG_TXANT 0x1c28
  278. #define REG_IQK_CTRL 0x1c38
  279. #define REG_ENCCK 0x1c3c
  280. #define BIT_CCK_BLK_EN BIT(1)
  281. #define BIT_CCK_OFDM_BLK_EN (BIT(0) | BIT(1))
  282. #define REG_CCAMSK 0x1c80
  283. #define REG_RSTB 0x1c90
  284. #define BIT_RSTB_3WIRE BIT(8)
  285. #define REG_CH_DELAY_EXTR2 0x1cd0
  286. #define BIT_TST_IQK2SET_SRC BIT(31)
  287. #define BIT_EN_IOQ_IQK_DPK BIT(30)
  288. #define BIT_IQK_DPK_RESET_SRC BIT(29)
  289. #define BIT_IQK_DPK_CLOCK_SRC BIT(28)
  290. #define REG_RX_BREAK 0x1d2c
  291. #define BIT_COM_RX_GCK_EN BIT(31)
  292. #define REG_RXFNCTL 0x1d30
  293. #define REG_CCA_OFF 0x1d58
  294. #define BIT_CCA_ON_BY_PW GENMASK(11, 3)
  295. #define REG_RXIGI 0x1d70
  296. #define REG_ENFN 0x1e24
  297. #define BIT_IQK_DPK_EN BIT(17)
  298. #define REG_TXANTSEG 0x1e28
  299. #define BIT_ANTSEG GENMASK(3, 0)
  300. #define REG_TXLGMAP 0x1e2c
  301. #define REG_CCKPATH 0x1e5c
  302. #define REG_TX_FIFO 0x1e70
  303. #define BIT_STOP_TX GENMASK(3, 0)
  304. #define REG_CNT_CTRL 0x1eb4
  305. #define BIT_ALL_CNT_RST BIT(25)
  306. #define REG_OFDM_FACNT 0x2d00
  307. #define REG_OFDM_FACNT1 0x2d04
  308. #define REG_OFDM_FACNT2 0x2d08
  309. #define REG_OFDM_FACNT3 0x2d0c
  310. #define REG_OFDM_FACNT4 0x2d10
  311. #define REG_OFDM_FACNT5 0x2d20
  312. #define REG_RPT_CIP 0x2d9c
  313. #define BIT_RPT_CIP_STATUS GENMASK(7, 0)
  314. #define REG_OFDM_TXCNT 0x2de0
  315. #define REG_ORITXCODE2 0x4100
  316. #define REG_3WIRE2 0x410c
  317. #define REG_ANAPAR_B 0x4130
  318. #define REG_RFTXEN_GCK_B 0x4164
  319. #define REG_DIS_SHARE_RX_B 0x416c
  320. #define BIT_EXT_TIA_BW BIT(1)
  321. #define REG_RXAGCCTL 0x41ac
  322. #define REG_DCKB_I_0 0x41bc
  323. #define REG_DCKB_I_1 0x41c0
  324. #define REG_DCKB_Q_0 0x41d8
  325. #define REG_DCKB_Q_1 0x41dc
  326. #define RF_MODE_TRXAGC 0x00
  327. #define BIT_RF_MODE GENMASK(19, 16)
  328. #define BIT_RXAGC GENMASK(9, 5)
  329. #define BIT_TXAGC GENMASK(4, 0)
  330. #define RF_RXAGC_OFFSET 0x19
  331. #define RF_BW_TRXBB 0x1a
  332. #define BIT_TX_CCK_IND BIT(16)
  333. #define BIT_BW_TXBB GENMASK(14, 12)
  334. #define BIT_BW_RXBB GENMASK(11, 10)
  335. #define BIT_DBG_CCK_CCA BIT(1)
  336. #define RF_TX_GAIN_OFFSET 0x55
  337. #define BIT_BB_GAIN GENMASK(18, 14)
  338. #define BIT_RF_GAIN GENMASK(4, 2)
  339. #define RF_TX_GAIN 0x56
  340. #define BIT_GAIN_TXBB GENMASK(4, 0)
  341. #define RF_IDAC 0x58
  342. #define BIT_TX_MODE GENMASK(19, 8)
  343. #define RF_TX_RESULT 0x5f
  344. #define BIT_GAIN_TX_PAD_H GENMASK(11, 8)
  345. #define BIT_GAIN_TX_PAD_L GENMASK(7, 4)
  346. #define RF_PA 0x60
  347. #define RF_PABIAS_2G_MASK GENMASK(15, 12)
  348. #define RF_PABIAS_5G_MASK GENMASK(19, 16)
  349. #define RF_TXA_LB_SW 0x63
  350. #define BIT_TXA_LB_ATT GENMASK(15, 14)
  351. #define BIT_LB_SW GENMASK(13, 12)
  352. #define BIT_LB_ATT GENMASK(4, 2)
  353. #define RF_RXG_GAIN 0x87
  354. #define BIT_RXG_GAIN BIT(18)
  355. #define RF_RXA_MIX_GAIN 0x8a
  356. #define BIT_RXA_MIX_GAIN GENMASK(4, 3)
  357. #define RF_EXT_TIA_BW 0x8f
  358. #define BIT_PW_EXT_TIA BIT(1)
  359. #define RF_DIS_BYPASS_TXBB 0x9e
  360. #define BIT_TXBB BIT(10)
  361. #define BIT_TIA_BYPASS BIT(5)
  362. #define RF_DEBUG 0xde
  363. #define BIT_DE_PWR_TRIM BIT(19)
  364. #define BIT_DE_TX_GAIN BIT(16)
  365. #define BIT_DE_TRXBW BIT(2)
  366. #define PPG_THERMAL_B 0x1b0
  367. #define RF_THEMAL_MASK GENMASK(19, 16)
  368. #define PPG_2GH_TXAB 0x1d2
  369. #define PPG_2G_A_MASK GENMASK(3, 0)
  370. #define PPG_2G_B_MASK GENMASK(7, 4)
  371. #define PPG_2GL_TXAB 0x1d4
  372. #define PPG_PABIAS_2GB 0x1d5
  373. #define PPG_PABIAS_2GA 0x1d6
  374. #define PPG_PABIAS_MASK GENMASK(3, 0)
  375. #define PPG_PABIAS_5GB 0x1d7
  376. #define PPG_PABIAS_5GA 0x1d8
  377. #define PPG_5G_MASK GENMASK(4, 0)
  378. #define PPG_5GH1_TXB 0x1db
  379. #define PPG_5GH1_TXA 0x1dc
  380. #define PPG_5GM2_TXB 0x1df
  381. #define PPG_5GM2_TXA 0x1e0
  382. #define PPG_5GM1_TXB 0x1e3
  383. #define PPG_5GM1_TXA 0x1e4
  384. #define PPG_5GL2_TXB 0x1e7
  385. #define PPG_5GL2_TXA 0x1e8
  386. #define PPG_5GL1_TXB 0x1eb
  387. #define PPG_5GL1_TXA 0x1ec
  388. #define PPG_2GM_TXAB 0x1ee
  389. #define PPG_THERMAL_A 0x1ef
  390. #endif