tables_nphy.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef B43_TABLES_NPHY_H_
  3. #define B43_TABLES_NPHY_H_
  4. #include <linux/types.h>
  5. struct b43_phy_n_sfo_cfg {
  6. u16 phy_bw1a;
  7. u16 phy_bw2;
  8. u16 phy_bw3;
  9. u16 phy_bw4;
  10. u16 phy_bw5;
  11. u16 phy_bw6;
  12. };
  13. struct b43_wldev;
  14. struct nphy_txiqcal_ladder {
  15. u8 percent;
  16. u8 g_env;
  17. };
  18. struct nphy_rf_control_override_rev2 {
  19. u8 addr0;
  20. u8 addr1;
  21. u16 bmask;
  22. u8 shift;
  23. };
  24. struct nphy_rf_control_override_rev3 {
  25. u16 val_mask;
  26. u8 val_shift;
  27. u8 en_addr0;
  28. u8 val_addr0;
  29. u8 en_addr1;
  30. u8 val_addr1;
  31. };
  32. struct nphy_rf_control_override_rev7 {
  33. u16 field;
  34. u16 val_addr_core0;
  35. u16 val_addr_core1;
  36. u16 val_mask;
  37. u8 val_shift;
  38. };
  39. struct nphy_gain_ctl_workaround_entry {
  40. s8 lna1_gain[4];
  41. s8 lna2_gain[4];
  42. u8 gain_db[10];
  43. u8 gain_bits[10];
  44. u16 init_gain;
  45. u16 rfseq_init[4];
  46. u16 cliphi_gain;
  47. u16 clipmd_gain;
  48. u16 cliplo_gain;
  49. u16 crsmin;
  50. u16 crsminl;
  51. u16 crsminu;
  52. u16 nbclip;
  53. u16 wlclip;
  54. };
  55. /* Get entry with workaround values for gain ctl. Does not return NULL. */
  56. struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
  57. struct b43_wldev *dev, bool ghz5, bool ext_lna);
  58. /* The N-PHY tables. */
  59. #define B43_NTAB_TYPEMASK 0xF0000000
  60. #define B43_NTAB_8BIT 0x10000000
  61. #define B43_NTAB_16BIT 0x20000000
  62. #define B43_NTAB_32BIT 0x30000000
  63. #define B43_NTAB8(table, offset) (((table) << 10) | (offset) | B43_NTAB_8BIT)
  64. #define B43_NTAB16(table, offset) (((table) << 10) | (offset) | B43_NTAB_16BIT)
  65. #define B43_NTAB32(table, offset) (((table) << 10) | (offset) | B43_NTAB_32BIT)
  66. /* Static N-PHY tables */
  67. #define B43_NTAB_FRAMESTRUCT B43_NTAB32(0x0A, 0x000) /* Frame Struct Table */
  68. #define B43_NTAB_FRAMESTRUCT_SIZE 832
  69. #define B43_NTAB_FRAMELT B43_NTAB8 (0x18, 0x000) /* Frame Lookup Table */
  70. #define B43_NTAB_FRAMELT_SIZE 32
  71. #define B43_NTAB_TMAP B43_NTAB32(0x0C, 0x000) /* T Map Table */
  72. #define B43_NTAB_TMAP_SIZE 448
  73. #define B43_NTAB_TDTRN B43_NTAB32(0x0E, 0x000) /* TDTRN Table */
  74. #define B43_NTAB_TDTRN_SIZE 704
  75. #define B43_NTAB_INTLEVEL B43_NTAB32(0x0D, 0x000) /* Int Level Table */
  76. #define B43_NTAB_INTLEVEL_SIZE 7
  77. #define B43_NTAB_PILOT B43_NTAB16(0x0B, 0x000) /* Pilot Table */
  78. #define B43_NTAB_PILOT_SIZE 88
  79. #define B43_NTAB_PILOTLT B43_NTAB32(0x14, 0x000) /* Pilot Lookup Table */
  80. #define B43_NTAB_PILOTLT_SIZE 6
  81. #define B43_NTAB_TDI20A0 B43_NTAB32(0x13, 0x080) /* TDI Table 20 Antenna 0 */
  82. #define B43_NTAB_TDI20A0_SIZE 55
  83. #define B43_NTAB_TDI20A1 B43_NTAB32(0x13, 0x100) /* TDI Table 20 Antenna 1 */
  84. #define B43_NTAB_TDI20A1_SIZE 55
  85. #define B43_NTAB_TDI40A0 B43_NTAB32(0x13, 0x280) /* TDI Table 40 Antenna 0 */
  86. #define B43_NTAB_TDI40A0_SIZE 110
  87. #define B43_NTAB_TDI40A1 B43_NTAB32(0x13, 0x300) /* TDI Table 40 Antenna 1 */
  88. #define B43_NTAB_TDI40A1_SIZE 110
  89. #define B43_NTAB_BDI B43_NTAB16(0x15, 0x000) /* BDI Table */
  90. #define B43_NTAB_BDI_SIZE 6
  91. #define B43_NTAB_CHANEST B43_NTAB32(0x16, 0x000) /* Channel Estimate Table */
  92. #define B43_NTAB_CHANEST_SIZE 96
  93. #define B43_NTAB_MCS B43_NTAB8 (0x12, 0x000) /* MCS Table */
  94. #define B43_NTAB_MCS_SIZE 128
  95. /* Volatile N-PHY tables */
  96. #define B43_NTAB_NOISEVAR10 B43_NTAB32(0x10, 0x000) /* Noise Var Table 10 */
  97. #define B43_NTAB_NOISEVAR10_SIZE 256
  98. #define B43_NTAB_NOISEVAR11 B43_NTAB32(0x10, 0x080) /* Noise Var Table 11 */
  99. #define B43_NTAB_NOISEVAR11_SIZE 256
  100. #define B43_NTAB_C0_ESTPLT B43_NTAB8 (0x1A, 0x000) /* Estimate Power Lookup Table Core 0 */
  101. #define B43_NTAB_C0_ESTPLT_SIZE 64
  102. #define B43_NTAB_C0_ADJPLT B43_NTAB8 (0x1A, 0x040) /* Adjust Power Lookup Table Core 0 */
  103. #define B43_NTAB_C0_ADJPLT_SIZE 128
  104. #define B43_NTAB_C0_GAINCTL B43_NTAB32(0x1A, 0x0C0) /* Gain Control Lookup Table Core 0 */
  105. #define B43_NTAB_C0_GAINCTL_SIZE 128
  106. #define B43_NTAB_C0_IQLT B43_NTAB32(0x1A, 0x140) /* IQ Lookup Table Core 0 */
  107. #define B43_NTAB_C0_IQLT_SIZE 128
  108. #define B43_NTAB_C0_LOFEEDTH B43_NTAB16(0x1A, 0x1C0) /* Local Oscillator Feed Through Lookup Table Core 0 */
  109. #define B43_NTAB_C0_LOFEEDTH_SIZE 128
  110. #define B43_NTAB_C1_ESTPLT B43_NTAB8 (0x1B, 0x000) /* Estimate Power Lookup Table Core 1 */
  111. #define B43_NTAB_C1_ESTPLT_SIZE 64
  112. #define B43_NTAB_C1_ADJPLT B43_NTAB8 (0x1B, 0x040) /* Adjust Power Lookup Table Core 1 */
  113. #define B43_NTAB_C1_ADJPLT_SIZE 128
  114. #define B43_NTAB_C1_GAINCTL B43_NTAB32(0x1B, 0x0C0) /* Gain Control Lookup Table Core 1 */
  115. #define B43_NTAB_C1_GAINCTL_SIZE 128
  116. #define B43_NTAB_C1_IQLT B43_NTAB32(0x1B, 0x140) /* IQ Lookup Table Core 1 */
  117. #define B43_NTAB_C1_IQLT_SIZE 128
  118. #define B43_NTAB_C1_LOFEEDTH B43_NTAB16(0x1B, 0x1C0) /* Local Oscillator Feed Through Lookup Table Core 1 */
  119. #define B43_NTAB_C1_LOFEEDTH_SIZE 128
  120. /* Volatile N-PHY tables, PHY revision >= 3 */
  121. #define B43_NTAB_ANT_SW_CTL_R3 B43_NTAB16( 9, 0) /* antenna software control */
  122. /* Static N-PHY tables, PHY revision >= 3 */
  123. #define B43_NTAB_FRAMESTRUCT_R3 B43_NTAB32(10, 0) /* frame struct */
  124. #define B43_NTAB_PILOT_R3 B43_NTAB16(11, 0) /* pilot */
  125. #define B43_NTAB_TMAP_R3 B43_NTAB32(12, 0) /* TM AP */
  126. #define B43_NTAB_INTLEVEL_R3 B43_NTAB32(13, 0) /* INT LV */
  127. #define B43_NTAB_TDTRN_R3 B43_NTAB32(14, 0) /* TD TRN */
  128. #define B43_NTAB_NOISEVAR_R3 B43_NTAB32(16, 0) /* noise variance */
  129. #define B43_NTAB_MCS_R3 B43_NTAB16(18, 0) /* MCS */
  130. #define B43_NTAB_TDI20A0_R3 B43_NTAB32(19, 128) /* TDI 20/0 */
  131. #define B43_NTAB_TDI20A1_R3 B43_NTAB32(19, 256) /* TDI 20/1 */
  132. #define B43_NTAB_TDI40A0_R3 B43_NTAB32(19, 640) /* TDI 40/0 */
  133. #define B43_NTAB_TDI40A1_R3 B43_NTAB32(19, 768) /* TDI 40/1 */
  134. #define B43_NTAB_PILOTLT_R3 B43_NTAB32(20, 0) /* PLT lookup */
  135. #define B43_NTAB_CHANEST_R3 B43_NTAB32(22, 0) /* channel estimate */
  136. #define B43_NTAB_FRAMELT_R3 B43_NTAB8(24, 0) /* frame lookup */
  137. #define B43_NTAB_C0_ESTPLT_R3 B43_NTAB8(26, 0) /* estimated power lookup 0 */
  138. #define B43_NTAB_C0_ADJPLT_R3 B43_NTAB8(26, 64) /* adjusted power lookup 0 */
  139. #define B43_NTAB_C0_GAINCTL_R3 B43_NTAB32(26, 192) /* gain control lookup 0 */
  140. #define B43_NTAB_C0_IQLT_R3 B43_NTAB32(26, 320) /* I/Q lookup 0 */
  141. #define B43_NTAB_C0_LOFEEDTH_R3 B43_NTAB16(26, 448) /* Local Oscillator Feed Through lookup 0 */
  142. #define B43_NTAB_C0_PAPD_COMP_R3 B43_NTAB16(26, 576)
  143. #define B43_NTAB_C1_ESTPLT_R3 B43_NTAB8(27, 0) /* estimated power lookup 1 */
  144. #define B43_NTAB_C1_ADJPLT_R3 B43_NTAB8(27, 64) /* adjusted power lookup 1 */
  145. #define B43_NTAB_C1_GAINCTL_R3 B43_NTAB32(27, 192) /* gain control lookup 1 */
  146. #define B43_NTAB_C1_IQLT_R3 B43_NTAB32(27, 320) /* I/Q lookup 1 */
  147. #define B43_NTAB_C1_LOFEEDTH_R3 B43_NTAB16(27, 448) /* Local Oscillator Feed Through lookup 1 */
  148. #define B43_NTAB_C1_PAPD_COMP_R3 B43_NTAB16(27, 576)
  149. /* Static N-PHY tables, PHY revision >= 7 */
  150. #define B43_NTAB_TMAP_R7 B43_NTAB32(12, 0) /* TM AP */
  151. #define B43_NTAB_NOISEVAR_R7 B43_NTAB32(16, 0) /* noise variance */
  152. #define B43_NTAB_TX_IQLO_CAL_LOFT_LADDER_40_SIZE 18
  153. #define B43_NTAB_TX_IQLO_CAL_LOFT_LADDER_20_SIZE 18
  154. #define B43_NTAB_TX_IQLO_CAL_IQIMB_LADDER_40_SIZE 18
  155. #define B43_NTAB_TX_IQLO_CAL_IQIMB_LADDER_20_SIZE 18
  156. #define B43_NTAB_TX_IQLO_CAL_STARTCOEFS_REV3 11
  157. #define B43_NTAB_TX_IQLO_CAL_STARTCOEFS 9
  158. #define B43_NTAB_TX_IQLO_CAL_CMDS_RECAL_REV3 12
  159. #define B43_NTAB_TX_IQLO_CAL_CMDS_RECAL 10
  160. #define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL 10
  161. #define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL_REV3 12
  162. u32 b43_ntab_read(struct b43_wldev *dev, u32 offset);
  163. void b43_ntab_read_bulk(struct b43_wldev *dev, u32 offset,
  164. unsigned int nr_elements, void *_data);
  165. void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value);
  166. void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset,
  167. unsigned int nr_elements, const void *_data);
  168. void b43_nphy_tables_init(struct b43_wldev *dev);
  169. const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev);
  170. const s16 *b43_ntab_get_rf_pwr_offset_table(struct b43_wldev *dev);
  171. extern const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[];
  172. extern const u16 tbl_iqcal_gainparams[2][9][8];
  173. extern const struct nphy_txiqcal_ladder ladder_lo[];
  174. extern const struct nphy_txiqcal_ladder ladder_iq[];
  175. extern const u16 loscale[];
  176. extern const u16 tbl_tx_iqlo_cal_loft_ladder_40[];
  177. extern const u16 tbl_tx_iqlo_cal_loft_ladder_20[];
  178. extern const u16 tbl_tx_iqlo_cal_iqimb_ladder_40[];
  179. extern const u16 tbl_tx_iqlo_cal_iqimb_ladder_20[];
  180. extern const u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[];
  181. extern const u16 tbl_tx_iqlo_cal_startcoefs[];
  182. extern const u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[];
  183. extern const u16 tbl_tx_iqlo_cal_cmds_recal[];
  184. extern const u16 tbl_tx_iqlo_cal_cmds_fullcal[];
  185. extern const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[];
  186. extern const s16 tbl_tx_filter_coef_rev4[7][15];
  187. extern const struct nphy_rf_control_override_rev2
  188. tbl_rf_control_override_rev2[];
  189. extern const struct nphy_rf_control_override_rev3
  190. tbl_rf_control_override_rev3[];
  191. const struct nphy_rf_control_override_rev7 *b43_nphy_get_rf_ctl_over_rev7(
  192. struct b43_wldev *dev, u16 field, u8 override);
  193. #endif /* B43_TABLES_NPHY_H_ */