eeprom.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. /*
  2. * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
  3. * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. *
  17. */
  18. /*
  19. * Common ar5xxx EEPROM data offsets (set these on AR5K_EEPROM_BASE)
  20. */
  21. #define AR5K_EEPROM_PCIE_OFFSET 0x02 /* Contains offset to PCI-E infos */
  22. #define AR5K_EEPROM_PCIE_SERDES_SECTION 0x40 /* PCIE_OFFSET points here when
  23. * SERDES infos are present */
  24. #define AR5K_EEPROM_MAGIC 0x003d /* EEPROM Magic number */
  25. #define AR5K_EEPROM_MAGIC_VALUE 0x5aa5 /* Default - found on EEPROM */
  26. #define AR5K_EEPROM_IS_HB63 0x000b /* Talon detect */
  27. #define AR5K_EEPROM_RFKILL 0x0f
  28. #define AR5K_EEPROM_RFKILL_GPIO_SEL 0x0000001c
  29. #define AR5K_EEPROM_RFKILL_GPIO_SEL_S 2
  30. #define AR5K_EEPROM_RFKILL_POLARITY 0x00000002
  31. #define AR5K_EEPROM_RFKILL_POLARITY_S 1
  32. #define AR5K_EEPROM_REG_DOMAIN 0x00bf /* EEPROM regdom */
  33. /* FLASH(EEPROM) Defines for AR531X chips */
  34. #define AR5K_EEPROM_SIZE_LOWER 0x1b /* size info -- lower */
  35. #define AR5K_EEPROM_SIZE_UPPER 0x1c /* size info -- upper */
  36. #define AR5K_EEPROM_SIZE_UPPER_MASK 0xfff0
  37. #define AR5K_EEPROM_SIZE_UPPER_SHIFT 4
  38. #define AR5K_EEPROM_SIZE_ENDLOC_SHIFT 12
  39. #define AR5K_EEPROM_CHECKSUM 0x00c0 /* EEPROM checksum */
  40. #define AR5K_EEPROM_INFO_BASE 0x00c0 /* EEPROM header */
  41. #define AR5K_EEPROM_INFO_MAX (0x400 - AR5K_EEPROM_INFO_BASE)
  42. #define AR5K_EEPROM_INFO_CKSUM 0xffff
  43. #define AR5K_EEPROM_INFO(_n) (AR5K_EEPROM_INFO_BASE + (_n))
  44. #define AR5K_EEPROM_VERSION AR5K_EEPROM_INFO(1) /* EEPROM Version */
  45. #define AR5K_EEPROM_VERSION_3_0 0x3000 /* No idea what's going on before this version */
  46. #define AR5K_EEPROM_VERSION_3_1 0x3001 /* ob/db values for 2GHz (ar5211_rfregs) */
  47. #define AR5K_EEPROM_VERSION_3_2 0x3002 /* different frequency representation (eeprom_bin2freq) */
  48. #define AR5K_EEPROM_VERSION_3_3 0x3003 /* offsets changed, has 32 CTLs (see below) and ee_false_detect (eeprom_read_modes) */
  49. #define AR5K_EEPROM_VERSION_3_4 0x3004 /* has ee_i_gain, ee_cck_ofdm_power_delta (eeprom_read_modes) */
  50. #define AR5K_EEPROM_VERSION_4_0 0x4000 /* has ee_misc, ee_cal_pier, ee_turbo_max_power and ee_xr_power (eeprom_init) */
  51. #define AR5K_EEPROM_VERSION_4_1 0x4001 /* has ee_margin_tx_rx (eeprom_init) */
  52. #define AR5K_EEPROM_VERSION_4_2 0x4002 /* has ee_cck_ofdm_gain_delta (eeprom_init) */
  53. #define AR5K_EEPROM_VERSION_4_3 0x4003 /* power calibration changes */
  54. #define AR5K_EEPROM_VERSION_4_4 0x4004
  55. #define AR5K_EEPROM_VERSION_4_5 0x4005
  56. #define AR5K_EEPROM_VERSION_4_6 0x4006 /* has ee_scaled_cck_delta */
  57. #define AR5K_EEPROM_VERSION_4_7 0x3007 /* 4007 ? */
  58. #define AR5K_EEPROM_VERSION_4_9 0x4009 /* EAR futureproofing */
  59. #define AR5K_EEPROM_VERSION_5_0 0x5000 /* Has 2413 PDADC calibration etc */
  60. #define AR5K_EEPROM_VERSION_5_1 0x5001 /* Has capability values */
  61. #define AR5K_EEPROM_VERSION_5_3 0x5003 /* Has spur mitigation tables */
  62. #define AR5K_EEPROM_MODE_11A 0
  63. #define AR5K_EEPROM_MODE_11B 1
  64. #define AR5K_EEPROM_MODE_11G 2
  65. #define AR5K_EEPROM_HDR AR5K_EEPROM_INFO(2) /* Header that contains the device caps */
  66. #define AR5K_EEPROM_HDR_11A(_v) (((_v) >> AR5K_EEPROM_MODE_11A) & 0x1)
  67. #define AR5K_EEPROM_HDR_11B(_v) (((_v) >> AR5K_EEPROM_MODE_11B) & 0x1)
  68. #define AR5K_EEPROM_HDR_11G(_v) (((_v) >> AR5K_EEPROM_MODE_11G) & 0x1)
  69. #define AR5K_EEPROM_HDR_T_2GHZ_DIS(_v) (((_v) >> 3) & 0x1) /* Disable turbo for 2GHz */
  70. #define AR5K_EEPROM_HDR_T_5GHZ_DBM(_v) (((_v) >> 4) & 0x7f) /* Max turbo power for < 2W power consumption */
  71. #define AR5K_EEPROM_HDR_DEVICE(_v) (((_v) >> 11) & 0x7) /* Device type (1 Cardbus, 2 PCI, 3 MiniPCI, 4 AP) */
  72. #define AR5K_EEPROM_HDR_RFKILL(_v) (((_v) >> 14) & 0x1) /* Device has RFKill support */
  73. #define AR5K_EEPROM_HDR_T_5GHZ_DIS(_v) (((_v) >> 15) & 0x1) /* Disable turbo for 5GHz */
  74. /* Newer EEPROMs are using a different offset */
  75. #define AR5K_EEPROM_OFF(_v, _v3_0, _v3_3) \
  76. (((_v) >= AR5K_EEPROM_VERSION_3_3) ? _v3_3 : _v3_0)
  77. #define AR5K_EEPROM_ANT_GAIN(_v) AR5K_EEPROM_OFF(_v, 0x00c4, 0x00c3)
  78. #define AR5K_EEPROM_ANT_GAIN_5GHZ(_v) ((s8)(((_v) >> 8) & 0xff))
  79. #define AR5K_EEPROM_ANT_GAIN_2GHZ(_v) ((s8)((_v) & 0xff))
  80. /* Misc values available since EEPROM 4.0 */
  81. #define AR5K_EEPROM_MISC0 AR5K_EEPROM_INFO(4)
  82. #define AR5K_EEPROM_EARSTART(_v) ((_v) & 0xfff)
  83. #define AR5K_EEPROM_HDR_XR2_DIS(_v) (((_v) >> 12) & 0x1)
  84. #define AR5K_EEPROM_HDR_XR5_DIS(_v) (((_v) >> 13) & 0x1)
  85. #define AR5K_EEPROM_EEMAP(_v) (((_v) >> 14) & 0x3)
  86. #define AR5K_EEPROM_MISC1 AR5K_EEPROM_INFO(5)
  87. #define AR5K_EEPROM_TARGET_PWRSTART(_v) ((_v) & 0xfff)
  88. #define AR5K_EEPROM_HAS32KHZCRYSTAL(_v) (((_v) >> 14) & 0x1) /* has 32KHz crystal for sleep mode */
  89. #define AR5K_EEPROM_HAS32KHZCRYSTAL_OLD(_v) (((_v) >> 15) & 0x1)
  90. #define AR5K_EEPROM_MISC2 AR5K_EEPROM_INFO(6)
  91. #define AR5K_EEPROM_EEP_FILE_VERSION(_v) (((_v) >> 8) & 0xff)
  92. #define AR5K_EEPROM_EAR_FILE_VERSION(_v) ((_v) & 0xff)
  93. #define AR5K_EEPROM_MISC3 AR5K_EEPROM_INFO(7)
  94. #define AR5K_EEPROM_ART_BUILD_NUM(_v) (((_v) >> 10) & 0x3f)
  95. #define AR5K_EEPROM_EAR_FILE_ID(_v) ((_v) & 0xff)
  96. #define AR5K_EEPROM_MISC4 AR5K_EEPROM_INFO(8)
  97. #define AR5K_EEPROM_CAL_DATA_START(_v) (((_v) >> 4) & 0xfff)
  98. #define AR5K_EEPROM_MASK_R0(_v) (((_v) >> 2) & 0x3) /* modes supported by radio 0 (bit 1: G, bit 2: A) */
  99. #define AR5K_EEPROM_MASK_R1(_v) ((_v) & 0x3) /* modes supported by radio 1 (bit 1: G, bit 2: A) */
  100. #define AR5K_EEPROM_MISC5 AR5K_EEPROM_INFO(9)
  101. #define AR5K_EEPROM_COMP_DIS(_v) ((_v) & 0x1) /* disable compression */
  102. #define AR5K_EEPROM_AES_DIS(_v) (((_v) >> 1) & 0x1) /* disable AES */
  103. #define AR5K_EEPROM_FF_DIS(_v) (((_v) >> 2) & 0x1) /* disable fast frames */
  104. #define AR5K_EEPROM_BURST_DIS(_v) (((_v) >> 3) & 0x1) /* disable bursting */
  105. #define AR5K_EEPROM_MAX_QCU(_v) (((_v) >> 4) & 0xf) /* max number of QCUs. defaults to 10 */
  106. #define AR5K_EEPROM_HEAVY_CLIP_EN(_v) (((_v) >> 8) & 0x1) /* enable heavy clipping */
  107. #define AR5K_EEPROM_KEY_CACHE_SIZE(_v) (((_v) >> 12) & 0xf) /* key cache size. defaults to 128 */
  108. #define AR5K_EEPROM_MISC6 AR5K_EEPROM_INFO(10)
  109. #define AR5K_EEPROM_TX_CHAIN_DIS ((_v) & 0x7) /* MIMO chains disabled for TX bitmask */
  110. #define AR5K_EEPROM_RX_CHAIN_DIS (((_v) >> 3) & 0x7) /* MIMO chains disabled for RX bitmask */
  111. #define AR5K_EEPROM_FCC_MID_EN (((_v) >> 6) & 0x1) /* 5.47-5.7GHz supported */
  112. #define AR5K_EEPROM_JAP_U1EVEN_EN (((_v) >> 7) & 0x1) /* Japan UNII1 band (5.15-5.25GHz) on even channels (5180, 5200, 5220, 5240) supported */
  113. #define AR5K_EEPROM_JAP_U2_EN (((_v) >> 8) & 0x1) /* Japan UNII2 band (5.25-5.35GHz) supported */
  114. #define AR5K_EEPROM_JAP_MID_EN (((_v) >> 9) & 0x1) /* Japan band from 5.47-5.7GHz supported */
  115. #define AR5K_EEPROM_JAP_U1ODD_EN (((_v) >> 10) & 0x1) /* Japan UNII2 band (5.15-5.25GHz) on odd channels (5170, 5190, 5210, 5230) supported */
  116. #define AR5K_EEPROM_JAP_11A_NEW_EN (((_v) >> 11) & 0x1) /* Japan A mode enabled (using even channels) */
  117. /* calibration settings */
  118. #define AR5K_EEPROM_MODES_11A(_v) AR5K_EEPROM_OFF(_v, 0x00c5, 0x00d4)
  119. #define AR5K_EEPROM_MODES_11B(_v) AR5K_EEPROM_OFF(_v, 0x00d0, 0x00f2)
  120. #define AR5K_EEPROM_MODES_11G(_v) AR5K_EEPROM_OFF(_v, 0x00da, 0x010d)
  121. #define AR5K_EEPROM_CTL(_v) AR5K_EEPROM_OFF(_v, 0x00e4, 0x0128) /* Conformance test limits */
  122. #define AR5K_EEPROM_GROUPS_START(_v) AR5K_EEPROM_OFF(_v, 0x0100, 0x0150) /* Start of Groups */
  123. #define AR5K_EEPROM_GROUP1_OFFSET 0x0
  124. #define AR5K_EEPROM_GROUP2_OFFSET 0x5
  125. #define AR5K_EEPROM_GROUP3_OFFSET 0x37
  126. #define AR5K_EEPROM_GROUP4_OFFSET 0x46
  127. #define AR5K_EEPROM_GROUP5_OFFSET 0x55
  128. #define AR5K_EEPROM_GROUP6_OFFSET 0x65
  129. #define AR5K_EEPROM_GROUP7_OFFSET 0x69
  130. #define AR5K_EEPROM_GROUP8_OFFSET 0x6f
  131. #define AR5K_EEPROM_TARGET_PWR_OFF_11A(_v) AR5K_EEPROM_OFF(_v, AR5K_EEPROM_GROUPS_START(_v) + \
  132. AR5K_EEPROM_GROUP5_OFFSET, 0x0000)
  133. #define AR5K_EEPROM_TARGET_PWR_OFF_11B(_v) AR5K_EEPROM_OFF(_v, AR5K_EEPROM_GROUPS_START(_v) + \
  134. AR5K_EEPROM_GROUP6_OFFSET, 0x0010)
  135. #define AR5K_EEPROM_TARGET_PWR_OFF_11G(_v) AR5K_EEPROM_OFF(_v, AR5K_EEPROM_GROUPS_START(_v) + \
  136. AR5K_EEPROM_GROUP7_OFFSET, 0x0014)
  137. /* [3.1 - 3.3] */
  138. #define AR5K_EEPROM_OBDB0_2GHZ 0x00ec
  139. #define AR5K_EEPROM_OBDB1_2GHZ 0x00ed
  140. #define AR5K_EEPROM_PROTECT 0x003f /* EEPROM protect status */
  141. #define AR5K_EEPROM_PROTECT_RD_0_31 0x0001 /* Read protection bit for offsets 0x0 - 0x1f */
  142. #define AR5K_EEPROM_PROTECT_WR_0_31 0x0002 /* Write protection bit for offsets 0x0 - 0x1f */
  143. #define AR5K_EEPROM_PROTECT_RD_32_63 0x0004 /* 0x20 - 0x3f */
  144. #define AR5K_EEPROM_PROTECT_WR_32_63 0x0008
  145. #define AR5K_EEPROM_PROTECT_RD_64_127 0x0010 /* 0x40 - 0x7f */
  146. #define AR5K_EEPROM_PROTECT_WR_64_127 0x0020
  147. #define AR5K_EEPROM_PROTECT_RD_128_191 0x0040 /* 0x80 - 0xbf (regdom) */
  148. #define AR5K_EEPROM_PROTECT_WR_128_191 0x0080
  149. #define AR5K_EEPROM_PROTECT_RD_192_207 0x0100 /* 0xc0 - 0xcf */
  150. #define AR5K_EEPROM_PROTECT_WR_192_207 0x0200
  151. #define AR5K_EEPROM_PROTECT_RD_208_223 0x0400 /* 0xd0 - 0xdf */
  152. #define AR5K_EEPROM_PROTECT_WR_208_223 0x0800
  153. #define AR5K_EEPROM_PROTECT_RD_224_239 0x1000 /* 0xe0 - 0xef */
  154. #define AR5K_EEPROM_PROTECT_WR_224_239 0x2000
  155. #define AR5K_EEPROM_PROTECT_RD_240_255 0x4000 /* 0xf0 - 0xff */
  156. #define AR5K_EEPROM_PROTECT_WR_240_255 0x8000
  157. /* Some EEPROM defines */
  158. #define AR5K_EEPROM_EEP_SCALE 100
  159. #define AR5K_EEPROM_EEP_DELTA 10
  160. #define AR5K_EEPROM_N_MODES 3
  161. #define AR5K_EEPROM_N_5GHZ_CHAN 10
  162. #define AR5K_EEPROM_N_5GHZ_RATE_CHAN 8
  163. #define AR5K_EEPROM_N_2GHZ_CHAN 3
  164. #define AR5K_EEPROM_N_2GHZ_CHAN_2413 4
  165. #define AR5K_EEPROM_N_2GHZ_CHAN_MAX 4
  166. #define AR5K_EEPROM_MAX_CHAN 10
  167. #define AR5K_EEPROM_N_PWR_POINTS_5111 11
  168. #define AR5K_EEPROM_N_PCDAC 11
  169. #define AR5K_EEPROM_N_PHASE_CAL 5
  170. #define AR5K_EEPROM_N_TEST_FREQ 8
  171. #define AR5K_EEPROM_N_EDGES 8
  172. #define AR5K_EEPROM_N_INTERCEPTS 11
  173. #define AR5K_EEPROM_FREQ_M(_v) AR5K_EEPROM_OFF(_v, 0x7f, 0xff)
  174. #define AR5K_EEPROM_PCDAC_M 0x3f
  175. #define AR5K_EEPROM_PCDAC_START 1
  176. #define AR5K_EEPROM_PCDAC_STOP 63
  177. #define AR5K_EEPROM_PCDAC_STEP 1
  178. #define AR5K_EEPROM_NON_EDGE_M 0x40
  179. #define AR5K_EEPROM_CHANNEL_POWER 8
  180. #define AR5K_EEPROM_N_OBDB 4
  181. #define AR5K_EEPROM_OBDB_DIS 0xffff
  182. #define AR5K_EEPROM_CHANNEL_DIS 0xff
  183. #define AR5K_EEPROM_SCALE_OC_DELTA(_x) (((_x) * 2) / 10)
  184. #define AR5K_EEPROM_N_CTLS(_v) AR5K_EEPROM_OFF(_v, 16, 32)
  185. #define AR5K_EEPROM_MAX_CTLS 32
  186. #define AR5K_EEPROM_N_PD_CURVES 4
  187. #define AR5K_EEPROM_N_XPD0_POINTS 4
  188. #define AR5K_EEPROM_N_XPD3_POINTS 3
  189. #define AR5K_EEPROM_N_PD_GAINS 4
  190. #define AR5K_EEPROM_N_PD_POINTS 5
  191. #define AR5K_EEPROM_N_INTERCEPT_10_2GHZ 35
  192. #define AR5K_EEPROM_N_INTERCEPT_10_5GHZ 55
  193. #define AR5K_EEPROM_POWER_M 0x3f
  194. #define AR5K_EEPROM_POWER_MIN 0
  195. #define AR5K_EEPROM_POWER_MAX 3150
  196. #define AR5K_EEPROM_POWER_STEP 50
  197. #define AR5K_EEPROM_POWER_TABLE_SIZE 64
  198. #define AR5K_EEPROM_N_POWER_LOC_11B 4
  199. #define AR5K_EEPROM_N_POWER_LOC_11G 6
  200. #define AR5K_EEPROM_I_GAIN 10
  201. #define AR5K_EEPROM_CCK_OFDM_DELTA 15
  202. #define AR5K_EEPROM_N_IQ_CAL 2
  203. /* 5GHz/2GHz */
  204. enum ath5k_eeprom_freq_bands {
  205. AR5K_EEPROM_BAND_5GHZ = 0,
  206. AR5K_EEPROM_BAND_2GHZ = 1,
  207. AR5K_EEPROM_N_FREQ_BANDS,
  208. };
  209. /* Spur chans per freq band */
  210. #define AR5K_EEPROM_N_SPUR_CHANS 5
  211. /* fbin value for chan 2464 x2 */
  212. #define AR5K_EEPROM_5413_SPUR_CHAN_1 1640
  213. /* fbin value for chan 2420 x2 */
  214. #define AR5K_EEPROM_5413_SPUR_CHAN_2 1200
  215. #define AR5K_EEPROM_SPUR_CHAN_MASK 0x3FFF
  216. #define AR5K_EEPROM_NO_SPUR 0x8000
  217. #define AR5K_SPUR_CHAN_WIDTH 87
  218. #define AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz 3125
  219. #define AR5K_SPUR_SYMBOL_WIDTH_TURBO_100Hz 6250
  220. #define AR5K_EEPROM_READ(_o, _v) do { \
  221. if (!ath5k_hw_nvram_read(ah, (_o), &(_v))) \
  222. return -EIO; \
  223. } while (0)
  224. #define AR5K_EEPROM_READ_HDR(_o, _v) \
  225. AR5K_EEPROM_READ(_o, ah->ah_capabilities.cap_eeprom._v); \
  226. enum ath5k_ant_table {
  227. AR5K_ANT_CTL = 0, /* Idle switch table settings */
  228. AR5K_ANT_SWTABLE_A = 1, /* Switch table for antenna A */
  229. AR5K_ANT_SWTABLE_B = 2, /* Switch table for antenna B */
  230. AR5K_ANT_MAX,
  231. };
  232. enum ath5k_ctl_mode {
  233. AR5K_CTL_11A = 0,
  234. AR5K_CTL_11B = 1,
  235. AR5K_CTL_11G = 2,
  236. AR5K_CTL_TURBO = 3,
  237. AR5K_CTL_TURBOG = 4,
  238. AR5K_CTL_2GHT20 = 5,
  239. AR5K_CTL_5GHT20 = 6,
  240. AR5K_CTL_2GHT40 = 7,
  241. AR5K_CTL_5GHT40 = 8,
  242. AR5K_CTL_MODE_M = 15,
  243. };
  244. /* Per channel calibration data, used for power table setup */
  245. struct ath5k_chan_pcal_info_rf5111 {
  246. /* Power levels in half dBm units
  247. * for one power curve. */
  248. u8 pwr[AR5K_EEPROM_N_PWR_POINTS_5111];
  249. /* PCDAC table steps
  250. * for the above values */
  251. u8 pcdac[AR5K_EEPROM_N_PWR_POINTS_5111];
  252. /* Starting PCDAC step */
  253. u8 pcdac_min;
  254. /* Final PCDAC step */
  255. u8 pcdac_max;
  256. };
  257. struct ath5k_chan_pcal_info_rf5112 {
  258. /* Power levels in quarter dBm units
  259. * for lower (0) and higher (3)
  260. * level curves in 0.25dB units */
  261. s8 pwr_x0[AR5K_EEPROM_N_XPD0_POINTS];
  262. s8 pwr_x3[AR5K_EEPROM_N_XPD3_POINTS];
  263. /* PCDAC table steps
  264. * for the above values */
  265. u8 pcdac_x0[AR5K_EEPROM_N_XPD0_POINTS];
  266. u8 pcdac_x3[AR5K_EEPROM_N_XPD3_POINTS];
  267. };
  268. struct ath5k_chan_pcal_info_rf2413 {
  269. /* Starting pwr/pddac values */
  270. s8 pwr_i[AR5K_EEPROM_N_PD_GAINS];
  271. u8 pddac_i[AR5K_EEPROM_N_PD_GAINS];
  272. /* (pwr,pddac) points
  273. * power levels in 0.5dB units */
  274. s8 pwr[AR5K_EEPROM_N_PD_GAINS]
  275. [AR5K_EEPROM_N_PD_POINTS];
  276. u8 pddac[AR5K_EEPROM_N_PD_GAINS]
  277. [AR5K_EEPROM_N_PD_POINTS];
  278. };
  279. enum ath5k_powertable_type {
  280. AR5K_PWRTABLE_PWR_TO_PCDAC = 0,
  281. AR5K_PWRTABLE_LINEAR_PCDAC = 1,
  282. AR5K_PWRTABLE_PWR_TO_PDADC = 2,
  283. };
  284. struct ath5k_pdgain_info {
  285. u8 pd_points;
  286. u8 *pd_step;
  287. /* Power values are in
  288. * 0.25dB units */
  289. s16 *pd_pwr;
  290. };
  291. struct ath5k_chan_pcal_info {
  292. /* Frequency */
  293. u16 freq;
  294. /* Tx power boundaries */
  295. s16 max_pwr;
  296. s16 min_pwr;
  297. union {
  298. struct ath5k_chan_pcal_info_rf5111 rf5111_info;
  299. struct ath5k_chan_pcal_info_rf5112 rf5112_info;
  300. struct ath5k_chan_pcal_info_rf2413 rf2413_info;
  301. };
  302. /* Raw values used by phy code
  303. * Curves are stored in order from lower
  304. * gain to higher gain (max txpower -> min txpower) */
  305. struct ath5k_pdgain_info *pd_curves;
  306. };
  307. /* Per rate calibration data for each mode,
  308. * used for rate power table setup.
  309. * Note: Values in 0.5dB units */
  310. struct ath5k_rate_pcal_info {
  311. u16 freq; /* Frequency */
  312. /* Power level for 6-24Mbit/s rates or
  313. * 1Mb rate */
  314. u16 target_power_6to24;
  315. /* Power level for 36Mbit rate or
  316. * 2Mb rate */
  317. u16 target_power_36;
  318. /* Power level for 48Mbit rate or
  319. * 5.5Mbit rate */
  320. u16 target_power_48;
  321. /* Power level for 54Mbit rate or
  322. * 11Mbit rate */
  323. u16 target_power_54;
  324. };
  325. /* Power edges for conformance test limits */
  326. struct ath5k_edge_power {
  327. u16 freq;
  328. u16 edge; /* in half dBm */
  329. bool flag;
  330. };
  331. /**
  332. * struct ath5k_eeprom_info - EEPROM calibration data
  333. *
  334. * @ee_regdomain: ath/regd.c takes care of COUNTRY_ERD and WORLDWIDE_ROAMING
  335. * flags
  336. * @ee_ant_gain: Antenna gain in 0.5dB steps signed [5211 only?]
  337. * @ee_cck_ofdm_gain_delta: difference in gainF to output the same power for
  338. * OFDM and CCK packets
  339. * @ee_cck_ofdm_power_delta: power difference between OFDM (6Mbps) and CCK
  340. * (11Mbps) rate in G mode. 0.1dB steps
  341. * @ee_scaled_cck_delta: for Japan Channel 14: 0.1dB resolution
  342. *
  343. * @ee_i_cal: Initial I coefficient to correct I/Q mismatch in the receive path
  344. * @ee_q_cal: Initial Q coefficient to correct I/Q mismatch in the receive path
  345. * @ee_fixed_bias: use ee_ob and ee_db settings or use automatic control
  346. * @ee_switch_settling: RX/TX Switch settling time
  347. * @ee_atn_tx_rx: Difference in attenuation between TX and RX in 1dB steps
  348. * @ee_ant_control: Antenna Control Settings
  349. * @ee_ob: Bias current for Output stage of PA
  350. * B/G mode: Index [0] is used for AR2112/5112, otherwise [1]
  351. * A mode: [0] 5.15-5.25 [1] 5.25-5.50 [2] 5.50-5.70 [3] 5.70-5.85 GHz
  352. * @ee_db: Bias current for Output stage of PA. see @ee_ob
  353. * @ee_tx_end2xlna_enable: Time difference from when BB finishes sending a frame
  354. * to when the external LNA is activated
  355. * @ee_tx_end2xpa_disable: Time difference from when BB finishes sending a frame
  356. * to when the external PA switch is deactivated
  357. * @ee_tx_frm2xpa_enable: Time difference from when MAC sends frame to when
  358. * external PA switch is activated
  359. * @ee_thr_62: Clear Channel Assessment (CCA) sensitivity
  360. * (IEEE802.11a section 17.3.10.5 )
  361. * @ee_xlna_gain: Total gain of the LNA (information only)
  362. * @ee_xpd: Use external (1) or internal power detector
  363. * @ee_x_gain: Gain for external power detector output (differences in EEMAP
  364. * versions!)
  365. * @ee_i_gain: Initial gain value after reset
  366. * @ee_margin_tx_rx: Margin in dB when final attenuation stage should be used
  367. *
  368. * @ee_false_detect: Backoff in Sensitivity (dB) on channels with spur signals
  369. * @ee_noise_floor_thr: Noise floor threshold in 1dB steps
  370. * @ee_adc_desired_size: Desired amplitude for ADC, used by AGC; in 0.5 dB steps
  371. * @ee_pga_desired_size: Desired output of PGA (for BB gain) in 0.5 dB steps
  372. * @ee_pd_gain_overlap: PD ADC curves need to overlap in 0.5dB steps (ee_map>=2)
  373. */
  374. struct ath5k_eeprom_info {
  375. /* Header information */
  376. u16 ee_magic;
  377. u16 ee_protect;
  378. u16 ee_regdomain;
  379. u16 ee_version;
  380. u16 ee_header;
  381. u16 ee_ant_gain;
  382. u8 ee_rfkill_pin;
  383. bool ee_rfkill_pol;
  384. bool ee_is_hb63;
  385. bool ee_serdes;
  386. u16 ee_misc0;
  387. u16 ee_misc1;
  388. u16 ee_misc2;
  389. u16 ee_misc3;
  390. u16 ee_misc4;
  391. u16 ee_misc5;
  392. u16 ee_misc6;
  393. u16 ee_cck_ofdm_gain_delta;
  394. u16 ee_cck_ofdm_power_delta;
  395. u16 ee_scaled_cck_delta;
  396. /* RF Calibration settings (reset, rfregs) */
  397. u16 ee_i_cal[AR5K_EEPROM_N_MODES];
  398. u16 ee_q_cal[AR5K_EEPROM_N_MODES];
  399. u16 ee_fixed_bias[AR5K_EEPROM_N_MODES];
  400. u16 ee_turbo_max_power[AR5K_EEPROM_N_MODES];
  401. u16 ee_xr_power[AR5K_EEPROM_N_MODES];
  402. u16 ee_switch_settling[AR5K_EEPROM_N_MODES];
  403. u16 ee_atn_tx_rx[AR5K_EEPROM_N_MODES];
  404. u16 ee_ant_control[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_PCDAC];
  405. u16 ee_ob[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_OBDB];
  406. u16 ee_db[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_OBDB];
  407. u16 ee_tx_end2xlna_enable[AR5K_EEPROM_N_MODES];
  408. u16 ee_tx_end2xpa_disable[AR5K_EEPROM_N_MODES];
  409. u16 ee_tx_frm2xpa_enable[AR5K_EEPROM_N_MODES];
  410. u16 ee_thr_62[AR5K_EEPROM_N_MODES];
  411. u16 ee_xlna_gain[AR5K_EEPROM_N_MODES];
  412. u16 ee_xpd[AR5K_EEPROM_N_MODES];
  413. u16 ee_x_gain[AR5K_EEPROM_N_MODES];
  414. u16 ee_i_gain[AR5K_EEPROM_N_MODES];
  415. u16 ee_margin_tx_rx[AR5K_EEPROM_N_MODES];
  416. u16 ee_switch_settling_turbo[AR5K_EEPROM_N_MODES];
  417. u16 ee_margin_tx_rx_turbo[AR5K_EEPROM_N_MODES];
  418. u16 ee_atn_tx_rx_turbo[AR5K_EEPROM_N_MODES];
  419. /* Power calibration data */
  420. u16 ee_false_detect[AR5K_EEPROM_N_MODES];
  421. /* Number of pd gain curves per mode */
  422. u8 ee_pd_gains[AR5K_EEPROM_N_MODES];
  423. /* Back mapping pdcurve number -> pdcurve index in pd->pd_curves */
  424. u8 ee_pdc_to_idx[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_PD_GAINS];
  425. u8 ee_n_piers[AR5K_EEPROM_N_MODES];
  426. struct ath5k_chan_pcal_info ee_pwr_cal_a[AR5K_EEPROM_N_5GHZ_CHAN];
  427. struct ath5k_chan_pcal_info ee_pwr_cal_b[AR5K_EEPROM_N_2GHZ_CHAN_MAX];
  428. struct ath5k_chan_pcal_info ee_pwr_cal_g[AR5K_EEPROM_N_2GHZ_CHAN_MAX];
  429. /* Per rate target power levels */
  430. u8 ee_rate_target_pwr_num[AR5K_EEPROM_N_MODES];
  431. struct ath5k_rate_pcal_info ee_rate_tpwr_a[AR5K_EEPROM_N_5GHZ_CHAN];
  432. struct ath5k_rate_pcal_info ee_rate_tpwr_b[AR5K_EEPROM_N_2GHZ_CHAN_MAX];
  433. struct ath5k_rate_pcal_info ee_rate_tpwr_g[AR5K_EEPROM_N_2GHZ_CHAN_MAX];
  434. /* Conformance test limits (Unused) */
  435. u8 ee_ctls;
  436. u8 ee_ctl[AR5K_EEPROM_MAX_CTLS];
  437. struct ath5k_edge_power ee_ctl_pwr[AR5K_EEPROM_N_EDGES * AR5K_EEPROM_MAX_CTLS];
  438. /* Noise Floor Calibration settings */
  439. s16 ee_noise_floor_thr[AR5K_EEPROM_N_MODES];
  440. s8 ee_adc_desired_size[AR5K_EEPROM_N_MODES];
  441. s8 ee_pga_desired_size[AR5K_EEPROM_N_MODES];
  442. s8 ee_adc_desired_size_turbo[AR5K_EEPROM_N_MODES];
  443. s8 ee_pga_desired_size_turbo[AR5K_EEPROM_N_MODES];
  444. s8 ee_pd_gain_overlap;
  445. /* Spur mitigation data (fbin values for spur channels) */
  446. u16 ee_spur_chans[AR5K_EEPROM_N_SPUR_CHANS][AR5K_EEPROM_N_FREQ_BANDS];
  447. /* Antenna raw switch tables */
  448. u32 ee_antenna[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
  449. };