ar9003_eeprom.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. #ifndef AR9003_EEPROM_H
  2. #define AR9003_EEPROM_H
  3. #include <linux/types.h>
  4. #define AR9300_EEP_VER 0xD000
  5. #define AR9300_EEP_VER_MINOR_MASK 0xFFF
  6. #define AR9300_EEP_MINOR_VER_1 0x1
  7. #define AR9300_EEP_MINOR_VER AR9300_EEP_MINOR_VER_1
  8. /* 16-bit offset location start of calibration struct */
  9. #define AR9300_EEP_START_LOC 256
  10. #define AR9300_NUM_5G_CAL_PIERS 8
  11. #define AR9300_NUM_2G_CAL_PIERS 3
  12. #define AR9300_NUM_5G_20_TARGET_POWERS 8
  13. #define AR9300_NUM_5G_40_TARGET_POWERS 8
  14. #define AR9300_NUM_2G_CCK_TARGET_POWERS 2
  15. #define AR9300_NUM_2G_20_TARGET_POWERS 3
  16. #define AR9300_NUM_2G_40_TARGET_POWERS 3
  17. /* #define AR9300_NUM_CTLS 21 */
  18. #define AR9300_NUM_CTLS_5G 9
  19. #define AR9300_NUM_CTLS_2G 12
  20. #define AR9300_CTL_MODE_M 0xF
  21. #define AR9300_NUM_BAND_EDGES_5G 8
  22. #define AR9300_NUM_BAND_EDGES_2G 4
  23. #define AR9300_NUM_PD_GAINS 4
  24. #define AR9300_PD_GAINS_IN_MASK 4
  25. #define AR9300_PD_GAIN_ICEPTS 5
  26. #define AR9300_EEPROM_MODAL_SPURS 5
  27. #define AR9300_MAX_RATE_POWER 63
  28. #define AR9300_NUM_PDADC_VALUES 128
  29. #define AR9300_NUM_RATES 16
  30. #define AR9300_BCHAN_UNUSED 0xFF
  31. #define AR9300_MAX_PWR_RANGE_IN_HALF_DB 64
  32. #define AR9300_OPFLAGS_11A 0x01
  33. #define AR9300_OPFLAGS_11G 0x02
  34. #define AR9300_OPFLAGS_5G_HT40 0x04
  35. #define AR9300_OPFLAGS_2G_HT40 0x08
  36. #define AR9300_OPFLAGS_5G_HT20 0x10
  37. #define AR9300_OPFLAGS_2G_HT20 0x20
  38. #define AR9300_EEPMISC_BIG_ENDIAN 0x01
  39. #define AR9300_EEPMISC_WOW 0x02
  40. #define AR9300_CUSTOMER_DATA_SIZE 20
  41. #define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))
  42. #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x))
  43. #define AR9300_MAX_CHAINS 3
  44. #define AR9300_ANT_16S 25
  45. #define AR9300_FUTURE_MODAL_SZ 6
  46. #define AR9300_NUM_ANT_CHAIN_FIELDS 7
  47. #define AR9300_NUM_ANT_COMMON_FIELDS 4
  48. #define AR9300_SIZE_ANT_CHAIN_FIELD 3
  49. #define AR9300_SIZE_ANT_COMMON_FIELD 4
  50. #define AR9300_ANT_CHAIN_MASK 0x7
  51. #define AR9300_ANT_COMMON_MASK 0xf
  52. #define AR9300_CHAIN_0_IDX 0
  53. #define AR9300_CHAIN_1_IDX 1
  54. #define AR9300_CHAIN_2_IDX 2
  55. #define AR928X_NUM_ANT_CHAIN_FIELDS 6
  56. #define AR928X_SIZE_ANT_CHAIN_FIELD 2
  57. #define AR928X_ANT_CHAIN_MASK 0x3
  58. /* Delta from which to start power to pdadc table */
  59. /* This offset is used in both open loop and closed loop power control
  60. * schemes. In open loop power control, it is not really needed, but for
  61. * the "sake of consistency" it was kept. For certain AP designs, this
  62. * value is overwritten by the value in the flag "pwrTableOffset" just
  63. * before writing the pdadc vs pwr into the chip registers.
  64. */
  65. #define AR9300_PWR_TABLE_OFFSET 0
  66. /* enable flags for voltage and temp compensation */
  67. #define ENABLE_TEMP_COMPENSATION 0x01
  68. #define ENABLE_VOLT_COMPENSATION 0x02
  69. /* byte addressable */
  70. #define AR9300_EEPROM_SIZE (16*1024)
  71. #define FIXED_CCA_THRESHOLD 15
  72. #define AR9300_BASE_ADDR 0x3ff
  73. enum targetPowerHTRates {
  74. HT_TARGET_RATE_0_8_16,
  75. HT_TARGET_RATE_1_3_9_11_17_19,
  76. HT_TARGET_RATE_4,
  77. HT_TARGET_RATE_5,
  78. HT_TARGET_RATE_6,
  79. HT_TARGET_RATE_7,
  80. HT_TARGET_RATE_12,
  81. HT_TARGET_RATE_13,
  82. HT_TARGET_RATE_14,
  83. HT_TARGET_RATE_15,
  84. HT_TARGET_RATE_20,
  85. HT_TARGET_RATE_21,
  86. HT_TARGET_RATE_22,
  87. HT_TARGET_RATE_23
  88. };
  89. enum targetPowerLegacyRates {
  90. LEGACY_TARGET_RATE_6_24,
  91. LEGACY_TARGET_RATE_36,
  92. LEGACY_TARGET_RATE_48,
  93. LEGACY_TARGET_RATE_54
  94. };
  95. enum targetPowerCckRates {
  96. LEGACY_TARGET_RATE_1L_5L,
  97. LEGACY_TARGET_RATE_5S,
  98. LEGACY_TARGET_RATE_11L,
  99. LEGACY_TARGET_RATE_11S
  100. };
  101. enum ar9300_Rates {
  102. ALL_TARGET_LEGACY_6_24,
  103. ALL_TARGET_LEGACY_36,
  104. ALL_TARGET_LEGACY_48,
  105. ALL_TARGET_LEGACY_54,
  106. ALL_TARGET_LEGACY_1L_5L,
  107. ALL_TARGET_LEGACY_5S,
  108. ALL_TARGET_LEGACY_11L,
  109. ALL_TARGET_LEGACY_11S,
  110. ALL_TARGET_HT20_0_8_16,
  111. ALL_TARGET_HT20_1_3_9_11_17_19,
  112. ALL_TARGET_HT20_4,
  113. ALL_TARGET_HT20_5,
  114. ALL_TARGET_HT20_6,
  115. ALL_TARGET_HT20_7,
  116. ALL_TARGET_HT20_12,
  117. ALL_TARGET_HT20_13,
  118. ALL_TARGET_HT20_14,
  119. ALL_TARGET_HT20_15,
  120. ALL_TARGET_HT20_20,
  121. ALL_TARGET_HT20_21,
  122. ALL_TARGET_HT20_22,
  123. ALL_TARGET_HT20_23,
  124. ALL_TARGET_HT40_0_8_16,
  125. ALL_TARGET_HT40_1_3_9_11_17_19,
  126. ALL_TARGET_HT40_4,
  127. ALL_TARGET_HT40_5,
  128. ALL_TARGET_HT40_6,
  129. ALL_TARGET_HT40_7,
  130. ALL_TARGET_HT40_12,
  131. ALL_TARGET_HT40_13,
  132. ALL_TARGET_HT40_14,
  133. ALL_TARGET_HT40_15,
  134. ALL_TARGET_HT40_20,
  135. ALL_TARGET_HT40_21,
  136. ALL_TARGET_HT40_22,
  137. ALL_TARGET_HT40_23,
  138. ar9300RateSize,
  139. };
  140. struct eepFlags {
  141. u8 opFlags;
  142. u8 eepMisc;
  143. } __packed;
  144. enum CompressAlgorithm {
  145. _CompressNone = 0,
  146. _CompressLzma,
  147. _CompressPairs,
  148. _CompressBlock,
  149. _Compress4,
  150. _Compress5,
  151. _Compress6,
  152. _Compress7,
  153. };
  154. struct ar9300_base_eep_hdr {
  155. __le16 regDmn[2];
  156. /* 4 bits tx and 4 bits rx */
  157. u8 txrxMask;
  158. struct eepFlags opCapFlags;
  159. u8 rfSilent;
  160. u8 blueToothOptions;
  161. u8 deviceCap;
  162. /* takes lower byte in eeprom location */
  163. u8 deviceType;
  164. /* offset in dB to be added to beginning
  165. * of pdadc table in calibration
  166. */
  167. int8_t pwrTableOffset;
  168. u8 params_for_tuning_caps[2];
  169. /*
  170. * bit0 - enable tx temp comp
  171. * bit1 - enable tx volt comp
  172. * bit2 - enable fastClock - default to 1
  173. * bit3 - enable doubling - default to 1
  174. * bit4 - enable internal regulator - default to 1
  175. */
  176. u8 featureEnable;
  177. /* misc flags: bit0 - turn down drivestrength */
  178. u8 miscConfiguration;
  179. u8 eepromWriteEnableGpio;
  180. u8 wlanDisableGpio;
  181. u8 wlanLedGpio;
  182. u8 rxBandSelectGpio;
  183. u8 txrxgain;
  184. /* SW controlled internal regulator fields */
  185. __le32 swreg;
  186. } __packed;
  187. struct ar9300_modal_eep_header {
  188. /* 4 idle, t1, t2, b (4 bits per setting) */
  189. __le32 antCtrlCommon;
  190. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  191. __le32 antCtrlCommon2;
  192. /* 6 idle, t, r, rx1, rx12, b (2 bits each) */
  193. __le16 antCtrlChain[AR9300_MAX_CHAINS];
  194. /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  195. u8 xatten1DB[AR9300_MAX_CHAINS];
  196. /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */
  197. u8 xatten1Margin[AR9300_MAX_CHAINS];
  198. int8_t tempSlope;
  199. int8_t voltSlope;
  200. /* spur channels in usual fbin coding format */
  201. u8 spurChans[AR9300_EEPROM_MODAL_SPURS];
  202. /* 3 Check if the register is per chain */
  203. int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS];
  204. u8 ob[AR9300_MAX_CHAINS];
  205. u8 db_stage2[AR9300_MAX_CHAINS];
  206. u8 db_stage3[AR9300_MAX_CHAINS];
  207. u8 db_stage4[AR9300_MAX_CHAINS];
  208. u8 xpaBiasLvl;
  209. u8 txFrameToDataStart;
  210. u8 txFrameToPaOn;
  211. u8 txClip;
  212. int8_t antennaGain;
  213. u8 switchSettling;
  214. int8_t adcDesiredSize;
  215. u8 txEndToXpaOff;
  216. u8 txEndToRxOn;
  217. u8 txFrameToXpaOn;
  218. u8 thresh62;
  219. __le32 papdRateMaskHt20;
  220. __le32 papdRateMaskHt40;
  221. u8 futureModal[24];
  222. } __packed;
  223. struct ar9300_cal_data_per_freq_op_loop {
  224. int8_t refPower;
  225. /* pdadc voltage at power measurement */
  226. u8 voltMeas;
  227. /* pcdac used for power measurement */
  228. u8 tempMeas;
  229. /* range is -60 to -127 create a mapping equation 1db resolution */
  230. int8_t rxNoisefloorCal;
  231. /*range is same as noisefloor */
  232. int8_t rxNoisefloorPower;
  233. /* temp measured when noisefloor cal was performed */
  234. u8 rxTempMeas;
  235. } __packed;
  236. struct cal_tgt_pow_legacy {
  237. u8 tPow2x[4];
  238. } __packed;
  239. struct cal_tgt_pow_ht {
  240. u8 tPow2x[14];
  241. } __packed;
  242. struct cal_ctl_edge_pwr {
  243. u8 tPower:6,
  244. flag:2;
  245. } __packed;
  246. struct cal_ctl_data_2g {
  247. struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_2G];
  248. } __packed;
  249. struct cal_ctl_data_5g {
  250. struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_5G];
  251. } __packed;
  252. struct ar9300_eeprom {
  253. u8 eepromVersion;
  254. u8 templateVersion;
  255. u8 macAddr[6];
  256. u8 custData[AR9300_CUSTOMER_DATA_SIZE];
  257. struct ar9300_base_eep_hdr baseEepHeader;
  258. struct ar9300_modal_eep_header modalHeader2G;
  259. u8 calFreqPier2G[AR9300_NUM_2G_CAL_PIERS];
  260. struct ar9300_cal_data_per_freq_op_loop
  261. calPierData2G[AR9300_MAX_CHAINS][AR9300_NUM_2G_CAL_PIERS];
  262. u8 calTarget_freqbin_Cck[AR9300_NUM_2G_CCK_TARGET_POWERS];
  263. u8 calTarget_freqbin_2G[AR9300_NUM_2G_20_TARGET_POWERS];
  264. u8 calTarget_freqbin_2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
  265. u8 calTarget_freqbin_2GHT40[AR9300_NUM_2G_40_TARGET_POWERS];
  266. struct cal_tgt_pow_legacy
  267. calTargetPowerCck[AR9300_NUM_2G_CCK_TARGET_POWERS];
  268. struct cal_tgt_pow_legacy
  269. calTargetPower2G[AR9300_NUM_2G_20_TARGET_POWERS];
  270. struct cal_tgt_pow_ht
  271. calTargetPower2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
  272. struct cal_tgt_pow_ht
  273. calTargetPower2GHT40[AR9300_NUM_2G_40_TARGET_POWERS];
  274. u8 ctlIndex_2G[AR9300_NUM_CTLS_2G];
  275. u8 ctl_freqbin_2G[AR9300_NUM_CTLS_2G][AR9300_NUM_BAND_EDGES_2G];
  276. struct cal_ctl_data_2g ctlPowerData_2G[AR9300_NUM_CTLS_2G];
  277. struct ar9300_modal_eep_header modalHeader5G;
  278. u8 calFreqPier5G[AR9300_NUM_5G_CAL_PIERS];
  279. struct ar9300_cal_data_per_freq_op_loop
  280. calPierData5G[AR9300_MAX_CHAINS][AR9300_NUM_5G_CAL_PIERS];
  281. u8 calTarget_freqbin_5G[AR9300_NUM_5G_20_TARGET_POWERS];
  282. u8 calTarget_freqbin_5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
  283. u8 calTarget_freqbin_5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
  284. struct cal_tgt_pow_legacy
  285. calTargetPower5G[AR9300_NUM_5G_20_TARGET_POWERS];
  286. struct cal_tgt_pow_ht
  287. calTargetPower5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
  288. struct cal_tgt_pow_ht
  289. calTargetPower5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
  290. u8 ctlIndex_5G[AR9300_NUM_CTLS_5G];
  291. u8 ctl_freqbin_5G[AR9300_NUM_CTLS_5G][AR9300_NUM_BAND_EDGES_5G];
  292. struct cal_ctl_data_5g ctlPowerData_5G[AR9300_NUM_CTLS_5G];
  293. } __packed;
  294. s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah);
  295. s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah);
  296. #endif