rtw8822b.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright(c) 2018-2019 Realtek Corporation
  3. */
  4. #ifndef __RTW8822B_H__
  5. #define __RTW8822B_H__
  6. #include <asm/byteorder.h>
  7. #define RCR_VHT_ACK BIT(26)
  8. struct rtw8822bu_efuse {
  9. u8 res4[4]; /* 0xd0 */
  10. u8 usb_optional_function;
  11. u8 res5[0x1e];
  12. u8 res6[2];
  13. u8 serial[0x0b]; /* 0xf5 */
  14. u8 vid; /* 0x100 */
  15. u8 res7;
  16. u8 pid;
  17. u8 res8[4];
  18. u8 mac_addr[ETH_ALEN]; /* 0x107 */
  19. u8 res9[2];
  20. u8 vendor_name[0x07];
  21. u8 res10[2];
  22. u8 device_name[0x14];
  23. u8 res11[0xcf];
  24. u8 package_type; /* 0x1fb */
  25. u8 res12[0x4];
  26. };
  27. struct rtw8822be_efuse {
  28. u8 mac_addr[ETH_ALEN]; /* 0xd0 */
  29. u8 vender_id[2];
  30. u8 device_id[2];
  31. u8 sub_vender_id[2];
  32. u8 sub_device_id[2];
  33. u8 pmc[2];
  34. u8 exp_device_cap[2];
  35. u8 msi_cap;
  36. u8 ltr_cap; /* 0xe3 */
  37. u8 exp_link_control[2];
  38. u8 link_cap[4];
  39. u8 link_control[2];
  40. u8 serial_number[8];
  41. u8 res0:2; /* 0xf4 */
  42. u8 ltr_en:1;
  43. u8 res1:2;
  44. u8 obff:2;
  45. u8 res2:3;
  46. u8 obff_cap:2;
  47. u8 res3:4;
  48. u8 res4[3];
  49. u8 class_code[3];
  50. u8 pci_pm_L1_2_supp:1;
  51. u8 pci_pm_L1_1_supp:1;
  52. u8 aspm_pm_L1_2_supp:1;
  53. u8 aspm_pm_L1_1_supp:1;
  54. u8 L1_pm_substates_supp:1;
  55. u8 res5:3;
  56. u8 port_common_mode_restore_time;
  57. u8 port_t_power_on_scale:2;
  58. u8 res6:1;
  59. u8 port_t_power_on_value:5;
  60. u8 res7;
  61. };
  62. struct rtw8822b_efuse {
  63. __le16 rtl_id;
  64. u8 res0[0x0e];
  65. /* power index for four RF paths */
  66. struct rtw_txpwr_idx txpwr_idx_table[4];
  67. u8 channel_plan; /* 0xb8 */
  68. u8 xtal_k;
  69. u8 thermal_meter;
  70. u8 iqk_lck;
  71. u8 pa_type; /* 0xbc */
  72. u8 lna_type_2g[2]; /* 0xbd */
  73. u8 lna_type_5g[2];
  74. u8 rf_board_option;
  75. u8 rf_feature_option;
  76. u8 rf_bt_setting;
  77. u8 eeprom_version;
  78. u8 eeprom_customer_id;
  79. u8 tx_bb_swing_setting_2g;
  80. u8 tx_bb_swing_setting_5g;
  81. u8 tx_pwr_calibrate_rate;
  82. u8 rf_antenna_option; /* 0xc9 */
  83. u8 rfe_option;
  84. u8 country_code[2];
  85. u8 res[3];
  86. union {
  87. struct rtw8822bu_efuse u;
  88. struct rtw8822be_efuse e;
  89. };
  90. };
  91. static inline void
  92. _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
  93. {
  94. /* 0xC00-0xCFF and 0xE00-0xEFF have the same layout */
  95. rtw_write32_mask(rtwdev, addr, mask, data);
  96. rtw_write32_mask(rtwdev, addr + 0x200, mask, data);
  97. }
  98. #define rtw_write32s_mask(rtwdev, addr, mask, data) \
  99. do { \
  100. BUILD_BUG_ON((addr) < 0xC00 || (addr) >= 0xD00); \
  101. \
  102. _rtw_write32s_mask(rtwdev, addr, mask, data); \
  103. } while (0)
  104. /* phy status page0 */
  105. #define GET_PHY_STAT_P0_PWDB(phy_stat) \
  106. le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
  107. /* phy status page1 */
  108. #define GET_PHY_STAT_P1_PWDB_A(phy_stat) \
  109. le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
  110. #define GET_PHY_STAT_P1_PWDB_B(phy_stat) \
  111. le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(23, 16))
  112. #define GET_PHY_STAT_P1_RF_MODE(phy_stat) \
  113. le32_get_bits(*((__le32 *)(phy_stat) + 0x03), GENMASK(29, 28))
  114. #define GET_PHY_STAT_P1_L_RXSC(phy_stat) \
  115. le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
  116. #define GET_PHY_STAT_P1_HT_RXSC(phy_stat) \
  117. le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))
  118. #define GET_PHY_STAT_P1_RXEVM_A(phy_stat) \
  119. le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(7, 0))
  120. #define GET_PHY_STAT_P1_RXEVM_B(phy_stat) \
  121. le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(15, 8))
  122. #define GET_PHY_STAT_P1_CFO_TAIL_A(phy_stat) \
  123. le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(7, 0))
  124. #define GET_PHY_STAT_P1_CFO_TAIL_B(phy_stat) \
  125. le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(15, 8))
  126. #define GET_PHY_STAT_P1_RXSNR_A(phy_stat) \
  127. le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(7, 0))
  128. #define GET_PHY_STAT_P1_RXSNR_B(phy_stat) \
  129. le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8))
  130. #define RTW8822B_EDCCA_MAX 0x7f
  131. #define RTW8822B_EDCCA_SRC_DEF 1
  132. #define REG_HTSTFWT 0x800
  133. #define REG_RXPSEL 0x808
  134. #define BIT_RX_PSEL_RST (BIT(28) | BIT(29))
  135. #define REG_TXPSEL 0x80c
  136. #define REG_RXCCAMSK 0x814
  137. #define REG_CCASEL 0x82c
  138. #define REG_PDMFTH 0x830
  139. #define REG_CCA2ND 0x838
  140. #define REG_L1WT 0x83c
  141. #define REG_L1PKWT 0x840
  142. #define REG_MRC 0x850
  143. #define REG_CLKTRK 0x860
  144. #define REG_EDCCA_POW_MA 0x8a0
  145. #define BIT_MA_LEVEL GENMASK(1, 0)
  146. #define REG_ADCCLK 0x8ac
  147. #define REG_ADC160 0x8c4
  148. #define REG_ADC40 0x8c8
  149. #define REG_EDCCA_DECISION 0x8dc
  150. #define BIT_EDCCA_OPTION BIT(5)
  151. #define REG_CDDTXP 0x93c
  152. #define REG_TXPSEL1 0x940
  153. #define REG_EDCCA_SOURCE 0x944
  154. #define BIT_SOURCE_OPTION GENMASK(29, 28)
  155. #define REG_ACBB0 0x948
  156. #define REG_ACBBRXFIR 0x94c
  157. #define REG_ACGG2TBL 0x958
  158. #define REG_RXSB 0xa00
  159. #define REG_ADCINI 0xa04
  160. #define REG_TXSF2 0xa24
  161. #define REG_TXSF6 0xa28
  162. #define REG_RXDESC 0xa2c
  163. #define REG_ENTXCCK 0xa80
  164. #define REG_AGCTR_A 0xc08
  165. #define REG_TXDFIR 0xc20
  166. #define REG_RXIGI_A 0xc50
  167. #define REG_TRSW 0xca0
  168. #define REG_RFESEL0 0xcb0
  169. #define REG_RFESEL8 0xcb4
  170. #define REG_RFECTL 0xcb8
  171. #define REG_RFEINV 0xcbc
  172. #define REG_AGCTR_B 0xe08
  173. #define REG_RXIGI_B 0xe50
  174. #define REG_ANTWT 0x1904
  175. #define REG_IQKFAILMSK 0x1bf0
  176. extern const struct rtw_chip_info rtw8822b_hw_spec;
  177. #endif