ar9003_eeprom.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. /*
  2. * Copyright (c) 2010-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef AR9003_EEPROM_H
  17. #define AR9003_EEPROM_H
  18. #include <linux/types.h>
  19. #define AR9300_EEP_VER 0xD000
  20. #define AR9300_EEP_VER_MINOR_MASK 0xFFF
  21. #define AR9300_EEP_MINOR_VER_1 0x1
  22. #define AR9300_EEP_MINOR_VER AR9300_EEP_MINOR_VER_1
  23. /* 16-bit offset location start of calibration struct */
  24. #define AR9300_EEP_START_LOC 256
  25. #define AR9300_NUM_5G_CAL_PIERS 8
  26. #define AR9300_NUM_2G_CAL_PIERS 3
  27. #define AR9300_NUM_5G_20_TARGET_POWERS 8
  28. #define AR9300_NUM_5G_40_TARGET_POWERS 8
  29. #define AR9300_NUM_2G_CCK_TARGET_POWERS 2
  30. #define AR9300_NUM_2G_20_TARGET_POWERS 3
  31. #define AR9300_NUM_2G_40_TARGET_POWERS 3
  32. /* #define AR9300_NUM_CTLS 21 */
  33. #define AR9300_NUM_CTLS_5G 9
  34. #define AR9300_NUM_CTLS_2G 12
  35. #define AR9300_NUM_BAND_EDGES_5G 8
  36. #define AR9300_NUM_BAND_EDGES_2G 4
  37. #define AR9300_EEPMISC_BIG_ENDIAN 0x01
  38. #define AR9300_EEPMISC_WOW 0x02
  39. #define AR9300_CUSTOMER_DATA_SIZE 20
  40. #define AR9300_MAX_CHAINS 3
  41. #define AR9300_ANT_16S 25
  42. #define AR9300_FUTURE_MODAL_SZ 6
  43. #define AR9300_PAPRD_RATE_MASK 0x01ffffff
  44. #define AR9300_PAPRD_SCALE_1 0x0e000000
  45. #define AR9300_PAPRD_SCALE_1_S 25
  46. #define AR9300_PAPRD_SCALE_2 0x70000000
  47. #define AR9300_PAPRD_SCALE_2_S 28
  48. #define AR9300_EEP_ANTDIV_CONTROL_DEFAULT_VALUE 0xc9
  49. /* Delta from which to start power to pdadc table */
  50. /* This offset is used in both open loop and closed loop power control
  51. * schemes. In open loop power control, it is not really needed, but for
  52. * the "sake of consistency" it was kept. For certain AP designs, this
  53. * value is overwritten by the value in the flag "pwrTableOffset" just
  54. * before writing the pdadc vs pwr into the chip registers.
  55. */
  56. #define AR9300_PWR_TABLE_OFFSET 0
  57. /* byte addressable */
  58. #define AR9300_EEPROM_SIZE (16*1024)
  59. #define AR9300_BASE_ADDR_4K 0xfff
  60. #define AR9300_BASE_ADDR 0x3ff
  61. #define AR9300_BASE_ADDR_512 0x1ff
  62. #define AR9300_OTP_BASE \
  63. ((AR_SREV_9340(ah) || AR_SREV_9550(ah)) ? 0x30000 : 0x14000)
  64. #define AR9300_OTP_STATUS \
  65. ((AR_SREV_9340(ah) || AR_SREV_9550(ah)) ? 0x31018 : 0x15f18)
  66. #define AR9300_OTP_STATUS_TYPE 0x7
  67. #define AR9300_OTP_STATUS_VALID 0x4
  68. #define AR9300_OTP_STATUS_ACCESS_BUSY 0x2
  69. #define AR9300_OTP_STATUS_SM_BUSY 0x1
  70. #define AR9300_OTP_READ_DATA \
  71. ((AR_SREV_9340(ah) || AR_SREV_9550(ah)) ? 0x3101c : 0x15f1c)
  72. enum targetPowerHTRates {
  73. HT_TARGET_RATE_0_8_16,
  74. HT_TARGET_RATE_1_3_9_11_17_19,
  75. HT_TARGET_RATE_4,
  76. HT_TARGET_RATE_5,
  77. HT_TARGET_RATE_6,
  78. HT_TARGET_RATE_7,
  79. HT_TARGET_RATE_12,
  80. HT_TARGET_RATE_13,
  81. HT_TARGET_RATE_14,
  82. HT_TARGET_RATE_15,
  83. HT_TARGET_RATE_20,
  84. HT_TARGET_RATE_21,
  85. HT_TARGET_RATE_22,
  86. HT_TARGET_RATE_23
  87. };
  88. enum targetPowerLegacyRates {
  89. LEGACY_TARGET_RATE_6_24,
  90. LEGACY_TARGET_RATE_36,
  91. LEGACY_TARGET_RATE_48,
  92. LEGACY_TARGET_RATE_54
  93. };
  94. enum targetPowerCckRates {
  95. LEGACY_TARGET_RATE_1L_5L,
  96. LEGACY_TARGET_RATE_5S,
  97. LEGACY_TARGET_RATE_11L,
  98. LEGACY_TARGET_RATE_11S
  99. };
  100. enum ar9300_Rates {
  101. ALL_TARGET_LEGACY_6_24,
  102. ALL_TARGET_LEGACY_36,
  103. ALL_TARGET_LEGACY_48,
  104. ALL_TARGET_LEGACY_54,
  105. ALL_TARGET_LEGACY_1L_5L,
  106. ALL_TARGET_LEGACY_5S,
  107. ALL_TARGET_LEGACY_11L,
  108. ALL_TARGET_LEGACY_11S,
  109. ALL_TARGET_HT20_0_8_16,
  110. ALL_TARGET_HT20_1_3_9_11_17_19,
  111. ALL_TARGET_HT20_4,
  112. ALL_TARGET_HT20_5,
  113. ALL_TARGET_HT20_6,
  114. ALL_TARGET_HT20_7,
  115. ALL_TARGET_HT20_12,
  116. ALL_TARGET_HT20_13,
  117. ALL_TARGET_HT20_14,
  118. ALL_TARGET_HT20_15,
  119. ALL_TARGET_HT20_20,
  120. ALL_TARGET_HT20_21,
  121. ALL_TARGET_HT20_22,
  122. ALL_TARGET_HT20_23,
  123. ALL_TARGET_HT40_0_8_16,
  124. ALL_TARGET_HT40_1_3_9_11_17_19,
  125. ALL_TARGET_HT40_4,
  126. ALL_TARGET_HT40_5,
  127. ALL_TARGET_HT40_6,
  128. ALL_TARGET_HT40_7,
  129. ALL_TARGET_HT40_12,
  130. ALL_TARGET_HT40_13,
  131. ALL_TARGET_HT40_14,
  132. ALL_TARGET_HT40_15,
  133. ALL_TARGET_HT40_20,
  134. ALL_TARGET_HT40_21,
  135. ALL_TARGET_HT40_22,
  136. ALL_TARGET_HT40_23,
  137. ar9300RateSize,
  138. };
  139. struct eepFlags {
  140. u8 opFlags;
  141. u8 eepMisc;
  142. } __packed;
  143. enum CompressAlgorithm {
  144. _CompressNone = 0,
  145. _CompressLzma,
  146. _CompressPairs,
  147. _CompressBlock,
  148. _Compress4,
  149. _Compress5,
  150. _Compress6,
  151. _Compress7,
  152. };
  153. struct ar9300_base_eep_hdr {
  154. __le16 regDmn[2];
  155. /* 4 bits tx and 4 bits rx */
  156. u8 txrxMask;
  157. struct eepFlags opCapFlags;
  158. u8 rfSilent;
  159. u8 blueToothOptions;
  160. u8 deviceCap;
  161. /* takes lower byte in eeprom location */
  162. u8 deviceType;
  163. /* offset in dB to be added to beginning
  164. * of pdadc table in calibration
  165. */
  166. int8_t pwrTableOffset;
  167. u8 params_for_tuning_caps[2];
  168. /*
  169. * bit0 - enable tx temp comp
  170. * bit1 - enable tx volt comp
  171. * bit2 - enable fastClock - default to 1
  172. * bit3 - enable doubling - default to 1
  173. * bit4 - enable internal regulator - default to 1
  174. */
  175. u8 featureEnable;
  176. /* misc flags: bit0 - turn down drivestrength */
  177. u8 miscConfiguration;
  178. u8 eepromWriteEnableGpio;
  179. u8 wlanDisableGpio;
  180. u8 wlanLedGpio;
  181. u8 rxBandSelectGpio;
  182. u8 txrxgain;
  183. /* SW controlled internal regulator fields */
  184. __le32 swreg;
  185. } __packed;
  186. struct ar9300_modal_eep_header {
  187. /* 4 idle, t1, t2, b (4 bits per setting) */
  188. __le32 antCtrlCommon;
  189. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  190. __le32 antCtrlCommon2;
  191. /* 6 idle, t, r, rx1, rx12, b (2 bits each) */
  192. __le16 antCtrlChain[AR9300_MAX_CHAINS];
  193. /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  194. u8 xatten1DB[AR9300_MAX_CHAINS];
  195. /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */
  196. u8 xatten1Margin[AR9300_MAX_CHAINS];
  197. int8_t tempSlope;
  198. int8_t voltSlope;
  199. /* spur channels in usual fbin coding format */
  200. u8 spurChans[AR_EEPROM_MODAL_SPURS];
  201. /* 3 Check if the register is per chain */
  202. int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS];
  203. u8 reserved[11];
  204. int8_t quick_drop;
  205. u8 xpaBiasLvl;
  206. u8 txFrameToDataStart;
  207. u8 txFrameToPaOn;
  208. u8 txClip;
  209. int8_t antennaGain;
  210. u8 switchSettling;
  211. int8_t adcDesiredSize;
  212. u8 txEndToXpaOff;
  213. u8 txEndToRxOn;
  214. u8 txFrameToXpaOn;
  215. u8 thresh62;
  216. __le32 papdRateMaskHt20;
  217. __le32 papdRateMaskHt40;
  218. __le16 switchcomspdt;
  219. u8 xlna_bias_strength;
  220. u8 futureModal[7];
  221. } __packed;
  222. struct ar9300_cal_data_per_freq_op_loop {
  223. int8_t refPower;
  224. /* pdadc voltage at power measurement */
  225. u8 voltMeas;
  226. /* pcdac used for power measurement */
  227. u8 tempMeas;
  228. /* range is -60 to -127 create a mapping equation 1db resolution */
  229. int8_t rxNoisefloorCal;
  230. /*range is same as noisefloor */
  231. int8_t rxNoisefloorPower;
  232. /* temp measured when noisefloor cal was performed */
  233. u8 rxTempMeas;
  234. } __packed;
  235. struct cal_tgt_pow_legacy {
  236. u8 tPow2x[4];
  237. } __packed;
  238. struct cal_tgt_pow_ht {
  239. u8 tPow2x[14];
  240. } __packed;
  241. struct cal_ctl_data_2g {
  242. u8 ctlEdges[AR9300_NUM_BAND_EDGES_2G];
  243. } __packed;
  244. struct cal_ctl_data_5g {
  245. u8 ctlEdges[AR9300_NUM_BAND_EDGES_5G];
  246. } __packed;
  247. #define MAX_BASE_EXTENSION_FUTURE 2
  248. struct ar9300_BaseExtension_1 {
  249. u8 ant_div_control;
  250. u8 future[MAX_BASE_EXTENSION_FUTURE];
  251. /*
  252. * misc_enable:
  253. *
  254. * BIT 0 - TX Gain Cap enable.
  255. * BIT 1 - Uncompressed Checksum enable.
  256. * BIT 2/3 - MinCCApwr enable 2g/5g.
  257. */
  258. u8 misc_enable;
  259. int8_t tempslopextension[8];
  260. int8_t quick_drop_low;
  261. int8_t quick_drop_high;
  262. } __packed;
  263. struct ar9300_BaseExtension_2 {
  264. int8_t tempSlopeLow;
  265. int8_t tempSlopeHigh;
  266. u8 xatten1DBLow[AR9300_MAX_CHAINS];
  267. u8 xatten1MarginLow[AR9300_MAX_CHAINS];
  268. u8 xatten1DBHigh[AR9300_MAX_CHAINS];
  269. u8 xatten1MarginHigh[AR9300_MAX_CHAINS];
  270. } __packed;
  271. struct ar9300_eeprom {
  272. u8 eepromVersion;
  273. u8 templateVersion;
  274. u8 macAddr[6];
  275. u8 custData[AR9300_CUSTOMER_DATA_SIZE];
  276. struct ar9300_base_eep_hdr baseEepHeader;
  277. struct ar9300_modal_eep_header modalHeader2G;
  278. struct ar9300_BaseExtension_1 base_ext1;
  279. u8 calFreqPier2G[AR9300_NUM_2G_CAL_PIERS];
  280. struct ar9300_cal_data_per_freq_op_loop
  281. calPierData2G[AR9300_MAX_CHAINS][AR9300_NUM_2G_CAL_PIERS];
  282. u8 calTarget_freqbin_Cck[AR9300_NUM_2G_CCK_TARGET_POWERS];
  283. u8 calTarget_freqbin_2G[AR9300_NUM_2G_20_TARGET_POWERS];
  284. u8 calTarget_freqbin_2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
  285. u8 calTarget_freqbin_2GHT40[AR9300_NUM_2G_40_TARGET_POWERS];
  286. struct cal_tgt_pow_legacy
  287. calTargetPowerCck[AR9300_NUM_2G_CCK_TARGET_POWERS];
  288. struct cal_tgt_pow_legacy
  289. calTargetPower2G[AR9300_NUM_2G_20_TARGET_POWERS];
  290. struct cal_tgt_pow_ht
  291. calTargetPower2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
  292. struct cal_tgt_pow_ht
  293. calTargetPower2GHT40[AR9300_NUM_2G_40_TARGET_POWERS];
  294. u8 ctlIndex_2G[AR9300_NUM_CTLS_2G];
  295. u8 ctl_freqbin_2G[AR9300_NUM_CTLS_2G][AR9300_NUM_BAND_EDGES_2G];
  296. struct cal_ctl_data_2g ctlPowerData_2G[AR9300_NUM_CTLS_2G];
  297. struct ar9300_modal_eep_header modalHeader5G;
  298. struct ar9300_BaseExtension_2 base_ext2;
  299. u8 calFreqPier5G[AR9300_NUM_5G_CAL_PIERS];
  300. struct ar9300_cal_data_per_freq_op_loop
  301. calPierData5G[AR9300_MAX_CHAINS][AR9300_NUM_5G_CAL_PIERS];
  302. u8 calTarget_freqbin_5G[AR9300_NUM_5G_20_TARGET_POWERS];
  303. u8 calTarget_freqbin_5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
  304. u8 calTarget_freqbin_5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
  305. struct cal_tgt_pow_legacy
  306. calTargetPower5G[AR9300_NUM_5G_20_TARGET_POWERS];
  307. struct cal_tgt_pow_ht
  308. calTargetPower5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
  309. struct cal_tgt_pow_ht
  310. calTargetPower5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
  311. u8 ctlIndex_5G[AR9300_NUM_CTLS_5G];
  312. u8 ctl_freqbin_5G[AR9300_NUM_CTLS_5G][AR9300_NUM_BAND_EDGES_5G];
  313. struct cal_ctl_data_5g ctlPowerData_5G[AR9300_NUM_CTLS_5G];
  314. } __packed;
  315. s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah);
  316. s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah);
  317. u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz);
  318. u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz);
  319. u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz);
  320. unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,
  321. struct ath9k_channel *chan);
  322. void ar9003_hw_internal_regulator_apply(struct ath_hw *ah);
  323. #endif