eeprom.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. /*
  2. * Copyright (c) 2008-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 EEPROM_H
  17. #define EEPROM_H
  18. #define AR_EEPROM_MODAL_SPURS 5
  19. #include "../ath.h"
  20. #include <net/cfg80211.h>
  21. #include "ar9003_eeprom.h"
  22. /* helpers to swap EEPROM fields, which are stored as __le16 or __le32. Since
  23. * we are 100% sure about it we __force these to u16/u32 for the swab calls to
  24. * silence the sparse checks. These macros are used when we have a Big Endian
  25. * EEPROM (according to AR5416_EEPMISC_BIG_ENDIAN) and need to convert the
  26. * fields to __le16/__le32.
  27. */
  28. #define EEPROM_FIELD_SWAB16(field) \
  29. (field = (__force __le16)swab16((__force u16)field))
  30. #define EEPROM_FIELD_SWAB32(field) \
  31. (field = (__force __le32)swab32((__force u32)field))
  32. #ifdef __BIG_ENDIAN
  33. #define AR5416_EEPROM_MAGIC 0x5aa5
  34. #else
  35. #define AR5416_EEPROM_MAGIC 0xa55a
  36. #endif
  37. #define CTRY_DEBUG 0x1ff
  38. #define CTRY_DEFAULT 0
  39. #define AR_EEPROM_EEPCAP_COMPRESS_DIS 0x0001
  40. #define AR_EEPROM_EEPCAP_AES_DIS 0x0002
  41. #define AR_EEPROM_EEPCAP_FASTFRAME_DIS 0x0004
  42. #define AR_EEPROM_EEPCAP_BURST_DIS 0x0008
  43. #define AR_EEPROM_EEPCAP_MAXQCU 0x01F0
  44. #define AR_EEPROM_EEPCAP_MAXQCU_S 4
  45. #define AR_EEPROM_EEPCAP_HEAVY_CLIP_EN 0x0200
  46. #define AR_EEPROM_EEPCAP_KC_ENTRIES 0xF000
  47. #define AR_EEPROM_EEPCAP_KC_ENTRIES_S 12
  48. #define AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND 0x0040
  49. #define AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN 0x0080
  50. #define AR_EEPROM_EEREGCAP_EN_KK_U2 0x0100
  51. #define AR_EEPROM_EEREGCAP_EN_KK_MIDBAND 0x0200
  52. #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD 0x0400
  53. #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A 0x0800
  54. #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD_PRE4_0 0x4000
  55. #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A_PRE4_0 0x8000
  56. #define AR5416_EEPROM_MAGIC_OFFSET 0x0
  57. #define AR5416_EEPROM_S 2
  58. #define AR5416_EEPROM_OFFSET 0x2000
  59. #define AR5416_EEPROM_MAX 0xae0
  60. #define AR5416_EEPROM_START_ADDR \
  61. (AR_SREV_9100(ah)) ? 0x1fff1000 : 0x503f1200
  62. #define SD_NO_CTL 0xE0
  63. #define NO_CTL 0xff
  64. #define CTL_MODE_M 0xf
  65. #define CTL_11A 0
  66. #define CTL_11B 1
  67. #define CTL_11G 2
  68. #define CTL_2GHT20 5
  69. #define CTL_5GHT20 6
  70. #define CTL_2GHT40 7
  71. #define CTL_5GHT40 8
  72. #define EXT_ADDITIVE (0x8000)
  73. #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
  74. #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
  75. #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
  76. #define SUB_NUM_CTL_MODES_AT_5G_40 2
  77. #define SUB_NUM_CTL_MODES_AT_2G_40 3
  78. #define POWER_CORRECTION_FOR_TWO_CHAIN 6 /* 10*log10(2)*2 */
  79. #define POWER_CORRECTION_FOR_THREE_CHAIN 10 /* 10*log10(3)*2 */
  80. /*
  81. * For AR9285 and later chipsets, the following bits are not being programmed
  82. * in EEPROM and so need to be enabled always.
  83. *
  84. * Bit 0: en_fcc_mid
  85. * Bit 1: en_jap_mid
  86. * Bit 2: en_fcc_dfs_ht40
  87. * Bit 3: en_jap_ht40
  88. * Bit 4: en_jap_dfs_ht40
  89. */
  90. #define AR9285_RDEXT_DEFAULT 0x1F
  91. #define ATH9K_POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
  92. #define FREQ2FBIN(x, y) (u8)((y) ? ((x) - 2300) : (((x) - 4800) / 5))
  93. #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x))
  94. #define ath9k_hw_use_flash(_ah) (!(_ah->ah_flags & AH_USE_EEPROM))
  95. #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \
  96. ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
  97. #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
  98. ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
  99. #define EEP_RFSILENT_ENABLED 0x0001
  100. #define EEP_RFSILENT_ENABLED_S 0
  101. #define EEP_RFSILENT_POLARITY 0x0002
  102. #define EEP_RFSILENT_POLARITY_S 1
  103. #define EEP_RFSILENT_GPIO_SEL ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x00fc : 0x001c)
  104. #define EEP_RFSILENT_GPIO_SEL_S 2
  105. #define AR5416_OPFLAGS_11A 0x01
  106. #define AR5416_OPFLAGS_11G 0x02
  107. #define AR5416_OPFLAGS_N_5G_HT40 0x04
  108. #define AR5416_OPFLAGS_N_2G_HT40 0x08
  109. #define AR5416_OPFLAGS_N_5G_HT20 0x10
  110. #define AR5416_OPFLAGS_N_2G_HT20 0x20
  111. #define AR5416_EEP_NO_BACK_VER 0x1
  112. #define AR5416_EEP_VER 0xE
  113. #define AR5416_EEP_VER_MAJOR_SHIFT 12
  114. #define AR5416_EEP_VER_MAJOR_MASK 0xF000
  115. #define AR5416_EEP_VER_MINOR_MASK 0x0FFF
  116. #define AR5416_EEP_MINOR_VER_2 0x2
  117. #define AR5416_EEP_MINOR_VER_3 0x3
  118. #define AR5416_EEP_MINOR_VER_7 0x7
  119. #define AR5416_EEP_MINOR_VER_9 0x9
  120. #define AR5416_EEP_MINOR_VER_16 0x10
  121. #define AR5416_EEP_MINOR_VER_17 0x11
  122. #define AR5416_EEP_MINOR_VER_19 0x13
  123. #define AR5416_EEP_MINOR_VER_20 0x14
  124. #define AR5416_EEP_MINOR_VER_21 0x15
  125. #define AR5416_EEP_MINOR_VER_22 0x16
  126. #define AR5416_NUM_5G_CAL_PIERS 8
  127. #define AR5416_NUM_2G_CAL_PIERS 4
  128. #define AR5416_NUM_5G_20_TARGET_POWERS 8
  129. #define AR5416_NUM_5G_40_TARGET_POWERS 8
  130. #define AR5416_NUM_2G_CCK_TARGET_POWERS 3
  131. #define AR5416_NUM_2G_20_TARGET_POWERS 4
  132. #define AR5416_NUM_2G_40_TARGET_POWERS 4
  133. #define AR5416_NUM_CTLS 24
  134. #define AR5416_NUM_BAND_EDGES 8
  135. #define AR5416_NUM_PD_GAINS 4
  136. #define AR5416_PD_GAINS_IN_MASK 4
  137. #define AR5416_PD_GAIN_ICEPTS 5
  138. #define AR5416_NUM_PDADC_VALUES 128
  139. #define AR5416_BCHAN_UNUSED 0xFF
  140. #define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64
  141. #define AR5416_MAX_CHAINS 3
  142. #define AR9300_MAX_CHAINS 3
  143. #define AR5416_PWR_TABLE_OFFSET_DB -5
  144. /* Rx gain type values */
  145. #define AR5416_EEP_RXGAIN_23DB_BACKOFF 0
  146. #define AR5416_EEP_RXGAIN_13DB_BACKOFF 1
  147. #define AR5416_EEP_RXGAIN_ORIG 2
  148. /* Tx gain type values */
  149. #define AR5416_EEP_TXGAIN_ORIGINAL 0
  150. #define AR5416_EEP_TXGAIN_HIGH_POWER 1
  151. /* Endianness of EEPROM content */
  152. #define AR5416_EEPMISC_BIG_ENDIAN 0x01
  153. #define AR5416_EEP4K_START_LOC 64
  154. #define AR5416_EEP4K_NUM_2G_CAL_PIERS 3
  155. #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3
  156. #define AR5416_EEP4K_NUM_2G_20_TARGET_POWERS 3
  157. #define AR5416_EEP4K_NUM_2G_40_TARGET_POWERS 3
  158. #define AR5416_EEP4K_NUM_CTLS 12
  159. #define AR5416_EEP4K_NUM_BAND_EDGES 4
  160. #define AR5416_EEP4K_NUM_PD_GAINS 2
  161. #define AR5416_EEP4K_MAX_CHAINS 1
  162. #define AR9280_TX_GAIN_TABLE_SIZE 22
  163. #define AR9287_EEP_VER 0xE
  164. #define AR9287_EEP_MINOR_VER_1 0x1
  165. #define AR9287_EEP_MINOR_VER_2 0x2
  166. #define AR9287_EEP_MINOR_VER_3 0x3
  167. #define AR9287_EEP_MINOR_VER AR9287_EEP_MINOR_VER_3
  168. #define AR9287_EEP_MINOR_VER_b AR9287_EEP_MINOR_VER
  169. #define AR9287_EEP_NO_BACK_VER AR9287_EEP_MINOR_VER_1
  170. #define AR9287_EEP_START_LOC 128
  171. #define AR9287_HTC_EEP_START_LOC 256
  172. #define AR9287_NUM_2G_CAL_PIERS 3
  173. #define AR9287_NUM_2G_CCK_TARGET_POWERS 3
  174. #define AR9287_NUM_2G_20_TARGET_POWERS 3
  175. #define AR9287_NUM_2G_40_TARGET_POWERS 3
  176. #define AR9287_NUM_CTLS 12
  177. #define AR9287_NUM_BAND_EDGES 4
  178. #define AR9287_PD_GAIN_ICEPTS 1
  179. #define AR9287_EEPMISC_WOW 0x02
  180. #define AR9287_MAX_CHAINS 2
  181. #define AR9287_ANT_16S 32
  182. #define AR9287_DATA_SZ 32
  183. #define AR9287_PWR_TABLE_OFFSET_DB -5
  184. #define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
  185. #define CTL_EDGE_TPOWER(_ctl) ((_ctl) & 0x3f)
  186. #define CTL_EDGE_FLAGS(_ctl) (((_ctl) >> 6) & 0x03)
  187. #define LNA_CTL_BUF_MODE BIT(0)
  188. #define LNA_CTL_ISEL_LO BIT(1)
  189. #define LNA_CTL_ISEL_HI BIT(2)
  190. #define LNA_CTL_BUF_IN BIT(3)
  191. #define LNA_CTL_FEM_BAND BIT(4)
  192. #define LNA_CTL_LOCAL_BIAS BIT(5)
  193. #define LNA_CTL_FORCE_XPA BIT(6)
  194. #define LNA_CTL_USE_ANT1 BIT(7)
  195. enum eeprom_param {
  196. EEP_NFTHRESH_5,
  197. EEP_NFTHRESH_2,
  198. EEP_MAC_MSW,
  199. EEP_MAC_MID,
  200. EEP_MAC_LSW,
  201. EEP_REG_0,
  202. EEP_OP_CAP,
  203. EEP_OP_MODE,
  204. EEP_RF_SILENT,
  205. EEP_OB_5,
  206. EEP_DB_5,
  207. EEP_OB_2,
  208. EEP_DB_2,
  209. EEP_TX_MASK,
  210. EEP_RX_MASK,
  211. EEP_FSTCLK_5G,
  212. EEP_RXGAIN_TYPE,
  213. EEP_OL_PWRCTRL,
  214. EEP_TXGAIN_TYPE,
  215. EEP_RC_CHAIN_MASK,
  216. EEP_DAC_HPWR_5G,
  217. EEP_FRAC_N_5G,
  218. EEP_DEV_TYPE,
  219. EEP_TEMPSENSE_SLOPE,
  220. EEP_TEMPSENSE_SLOPE_PAL_ON,
  221. EEP_PWR_TABLE_OFFSET,
  222. EEP_PAPRD,
  223. EEP_MODAL_VER,
  224. EEP_ANT_DIV_CTL1,
  225. EEP_CHAIN_MASK_REDUCE,
  226. EEP_ANTENNA_GAIN_2G,
  227. EEP_ANTENNA_GAIN_5G,
  228. };
  229. enum ar5416_rates {
  230. rate6mb, rate9mb, rate12mb, rate18mb,
  231. rate24mb, rate36mb, rate48mb, rate54mb,
  232. rate1l, rate2l, rate2s, rate5_5l,
  233. rate5_5s, rate11l, rate11s, rateXr,
  234. rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3,
  235. rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7,
  236. rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3,
  237. rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7,
  238. rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm,
  239. Ar5416RateSize
  240. };
  241. enum ath9k_hal_freq_band {
  242. ATH9K_HAL_FREQ_BAND_5GHZ = 0,
  243. ATH9K_HAL_FREQ_BAND_2GHZ = 1
  244. };
  245. struct base_eep_header {
  246. __le16 length;
  247. __le16 checksum;
  248. __le16 version;
  249. u8 opCapFlags;
  250. u8 eepMisc;
  251. __le16 regDmn[2];
  252. u8 macAddr[6];
  253. u8 rxMask;
  254. u8 txMask;
  255. __le16 rfSilent;
  256. __le16 blueToothOptions;
  257. __le16 deviceCap;
  258. __le32 binBuildNumber;
  259. u8 deviceType;
  260. u8 pwdclkind;
  261. u8 fastClk5g;
  262. u8 divChain;
  263. u8 rxGainType;
  264. u8 dacHiPwrMode_5G;
  265. u8 openLoopPwrCntl;
  266. u8 dacLpMode;
  267. u8 txGainType;
  268. u8 rcChainMask;
  269. u8 desiredScaleCCK;
  270. u8 pwr_table_offset;
  271. u8 frac_n_5g;
  272. u8 futureBase_3[21];
  273. } __packed;
  274. struct base_eep_header_4k {
  275. __le16 length;
  276. __le16 checksum;
  277. __le16 version;
  278. u8 opCapFlags;
  279. u8 eepMisc;
  280. __le16 regDmn[2];
  281. u8 macAddr[6];
  282. u8 rxMask;
  283. u8 txMask;
  284. __le16 rfSilent;
  285. __le16 blueToothOptions;
  286. __le16 deviceCap;
  287. __le32 binBuildNumber;
  288. u8 deviceType;
  289. u8 txGainType;
  290. } __packed;
  291. struct spur_chan {
  292. __le16 spurChan;
  293. u8 spurRangeLow;
  294. u8 spurRangeHigh;
  295. } __packed;
  296. struct modal_eep_header {
  297. __le32 antCtrlChain[AR5416_MAX_CHAINS];
  298. __le32 antCtrlCommon;
  299. u8 antennaGainCh[AR5416_MAX_CHAINS];
  300. u8 switchSettling;
  301. u8 txRxAttenCh[AR5416_MAX_CHAINS];
  302. u8 rxTxMarginCh[AR5416_MAX_CHAINS];
  303. u8 adcDesiredSize;
  304. u8 pgaDesiredSize;
  305. u8 xlnaGainCh[AR5416_MAX_CHAINS];
  306. u8 txEndToXpaOff;
  307. u8 txEndToRxOn;
  308. u8 txFrameToXpaOn;
  309. u8 thresh62;
  310. u8 noiseFloorThreshCh[AR5416_MAX_CHAINS];
  311. u8 xpdGain;
  312. u8 xpd;
  313. u8 iqCalICh[AR5416_MAX_CHAINS];
  314. u8 iqCalQCh[AR5416_MAX_CHAINS];
  315. u8 pdGainOverlap;
  316. u8 ob;
  317. u8 db;
  318. u8 xpaBiasLvl;
  319. u8 pwrDecreaseFor2Chain;
  320. u8 pwrDecreaseFor3Chain;
  321. u8 txFrameToDataStart;
  322. u8 txFrameToPaOn;
  323. u8 ht40PowerIncForPdadc;
  324. u8 bswAtten[AR5416_MAX_CHAINS];
  325. u8 bswMargin[AR5416_MAX_CHAINS];
  326. u8 swSettleHt40;
  327. u8 xatten2Db[AR5416_MAX_CHAINS];
  328. u8 xatten2Margin[AR5416_MAX_CHAINS];
  329. u8 ob_ch1;
  330. u8 db_ch1;
  331. u8 lna_ctl;
  332. u8 miscBits;
  333. __le16 xpaBiasLvlFreq[3];
  334. u8 futureModal[6];
  335. struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
  336. } __packed;
  337. struct calDataPerFreqOpLoop {
  338. u8 pwrPdg[2][5];
  339. u8 vpdPdg[2][5];
  340. u8 pcdac[2][5];
  341. u8 empty[2][5];
  342. } __packed;
  343. struct modal_eep_4k_header {
  344. __le32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
  345. __le32 antCtrlCommon;
  346. u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS];
  347. u8 switchSettling;
  348. u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS];
  349. u8 rxTxMarginCh[AR5416_EEP4K_MAX_CHAINS];
  350. u8 adcDesiredSize;
  351. u8 pgaDesiredSize;
  352. u8 xlnaGainCh[AR5416_EEP4K_MAX_CHAINS];
  353. u8 txEndToXpaOff;
  354. u8 txEndToRxOn;
  355. u8 txFrameToXpaOn;
  356. u8 thresh62;
  357. u8 noiseFloorThreshCh[AR5416_EEP4K_MAX_CHAINS];
  358. u8 xpdGain;
  359. u8 xpd;
  360. u8 iqCalICh[AR5416_EEP4K_MAX_CHAINS];
  361. u8 iqCalQCh[AR5416_EEP4K_MAX_CHAINS];
  362. u8 pdGainOverlap;
  363. #ifdef __BIG_ENDIAN_BITFIELD
  364. u8 ob_1:4, ob_0:4;
  365. u8 db1_1:4, db1_0:4;
  366. #else
  367. u8 ob_0:4, ob_1:4;
  368. u8 db1_0:4, db1_1:4;
  369. #endif
  370. u8 xpaBiasLvl;
  371. u8 txFrameToDataStart;
  372. u8 txFrameToPaOn;
  373. u8 ht40PowerIncForPdadc;
  374. u8 bswAtten[AR5416_EEP4K_MAX_CHAINS];
  375. u8 bswMargin[AR5416_EEP4K_MAX_CHAINS];
  376. u8 swSettleHt40;
  377. u8 xatten2Db[AR5416_EEP4K_MAX_CHAINS];
  378. u8 xatten2Margin[AR5416_EEP4K_MAX_CHAINS];
  379. #ifdef __BIG_ENDIAN_BITFIELD
  380. u8 db2_1:4, db2_0:4;
  381. #else
  382. u8 db2_0:4, db2_1:4;
  383. #endif
  384. u8 version;
  385. #ifdef __BIG_ENDIAN_BITFIELD
  386. u8 ob_3:4, ob_2:4;
  387. u8 antdiv_ctl1:4, ob_4:4;
  388. u8 db1_3:4, db1_2:4;
  389. u8 antdiv_ctl2:4, db1_4:4;
  390. u8 db2_2:4, db2_3:4;
  391. u8 reserved:4, db2_4:4;
  392. #else
  393. u8 ob_2:4, ob_3:4;
  394. u8 ob_4:4, antdiv_ctl1:4;
  395. u8 db1_2:4, db1_3:4;
  396. u8 db1_4:4, antdiv_ctl2:4;
  397. u8 db2_2:4, db2_3:4;
  398. u8 db2_4:4, reserved:4;
  399. #endif
  400. u8 tx_diversity;
  401. u8 flc_pwr_thresh;
  402. u8 bb_scale_smrt_antenna;
  403. #define EEP_4K_BB_DESIRED_SCALE_MASK 0x1f
  404. u8 futureModal[1];
  405. struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
  406. } __packed;
  407. struct base_eep_ar9287_header {
  408. __le16 length;
  409. __le16 checksum;
  410. __le16 version;
  411. u8 opCapFlags;
  412. u8 eepMisc;
  413. __le16 regDmn[2];
  414. u8 macAddr[6];
  415. u8 rxMask;
  416. u8 txMask;
  417. __le16 rfSilent;
  418. __le16 blueToothOptions;
  419. __le16 deviceCap;
  420. __le32 binBuildNumber;
  421. u8 deviceType;
  422. u8 openLoopPwrCntl;
  423. int8_t pwrTableOffset;
  424. int8_t tempSensSlope;
  425. int8_t tempSensSlopePalOn;
  426. u8 futureBase[29];
  427. } __packed;
  428. struct modal_eep_ar9287_header {
  429. __le32 antCtrlChain[AR9287_MAX_CHAINS];
  430. __le32 antCtrlCommon;
  431. int8_t antennaGainCh[AR9287_MAX_CHAINS];
  432. u8 switchSettling;
  433. u8 txRxAttenCh[AR9287_MAX_CHAINS];
  434. u8 rxTxMarginCh[AR9287_MAX_CHAINS];
  435. int8_t adcDesiredSize;
  436. u8 txEndToXpaOff;
  437. u8 txEndToRxOn;
  438. u8 txFrameToXpaOn;
  439. u8 thresh62;
  440. int8_t noiseFloorThreshCh[AR9287_MAX_CHAINS];
  441. u8 xpdGain;
  442. u8 xpd;
  443. int8_t iqCalICh[AR9287_MAX_CHAINS];
  444. int8_t iqCalQCh[AR9287_MAX_CHAINS];
  445. u8 pdGainOverlap;
  446. u8 xpaBiasLvl;
  447. u8 txFrameToDataStart;
  448. u8 txFrameToPaOn;
  449. u8 ht40PowerIncForPdadc;
  450. u8 bswAtten[AR9287_MAX_CHAINS];
  451. u8 bswMargin[AR9287_MAX_CHAINS];
  452. u8 swSettleHt40;
  453. u8 version;
  454. u8 db1;
  455. u8 db2;
  456. u8 ob_cck;
  457. u8 ob_psk;
  458. u8 ob_qam;
  459. u8 ob_pal_off;
  460. u8 futureModal[30];
  461. struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
  462. } __packed;
  463. struct cal_data_per_freq {
  464. u8 pwrPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  465. u8 vpdPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  466. } __packed;
  467. struct cal_data_per_freq_4k {
  468. u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  469. u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  470. } __packed;
  471. struct cal_target_power_leg {
  472. u8 bChannel;
  473. u8 tPow2x[4];
  474. } __packed;
  475. struct cal_target_power_ht {
  476. u8 bChannel;
  477. u8 tPow2x[8];
  478. } __packed;
  479. struct cal_ctl_edges {
  480. u8 bChannel;
  481. u8 ctl;
  482. } __packed;
  483. struct cal_data_op_loop_ar9287 {
  484. u8 pwrPdg[2][5];
  485. u8 vpdPdg[2][5];
  486. u8 pcdac[2][5];
  487. u8 empty[2][5];
  488. } __packed;
  489. struct cal_data_per_freq_ar9287 {
  490. u8 pwrPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
  491. u8 vpdPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
  492. } __packed;
  493. union cal_data_per_freq_ar9287_u {
  494. struct cal_data_op_loop_ar9287 calDataOpen;
  495. struct cal_data_per_freq_ar9287 calDataClose;
  496. } __packed;
  497. struct cal_ctl_data_ar9287 {
  498. struct cal_ctl_edges
  499. ctlEdges[AR9287_MAX_CHAINS][AR9287_NUM_BAND_EDGES];
  500. } __packed;
  501. struct cal_ctl_data {
  502. struct cal_ctl_edges
  503. ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];
  504. } __packed;
  505. struct cal_ctl_data_4k {
  506. struct cal_ctl_edges
  507. ctlEdges[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_BAND_EDGES];
  508. } __packed;
  509. struct ar5416_eeprom_def {
  510. struct base_eep_header baseEepHeader;
  511. u8 custData[64];
  512. struct modal_eep_header modalHeader[2];
  513. u8 calFreqPier5G[AR5416_NUM_5G_CAL_PIERS];
  514. u8 calFreqPier2G[AR5416_NUM_2G_CAL_PIERS];
  515. struct cal_data_per_freq
  516. calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS];
  517. struct cal_data_per_freq
  518. calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS];
  519. struct cal_target_power_leg
  520. calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS];
  521. struct cal_target_power_ht
  522. calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS];
  523. struct cal_target_power_ht
  524. calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS];
  525. struct cal_target_power_leg
  526. calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS];
  527. struct cal_target_power_leg
  528. calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS];
  529. struct cal_target_power_ht
  530. calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS];
  531. struct cal_target_power_ht
  532. calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS];
  533. u8 ctlIndex[AR5416_NUM_CTLS];
  534. struct cal_ctl_data ctlData[AR5416_NUM_CTLS];
  535. u8 padding;
  536. } __packed;
  537. struct ar5416_eeprom_4k {
  538. struct base_eep_header_4k baseEepHeader;
  539. u8 custData[20];
  540. struct modal_eep_4k_header modalHeader;
  541. u8 calFreqPier2G[AR5416_EEP4K_NUM_2G_CAL_PIERS];
  542. struct cal_data_per_freq_4k
  543. calPierData2G[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_2G_CAL_PIERS];
  544. struct cal_target_power_leg
  545. calTargetPowerCck[AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS];
  546. struct cal_target_power_leg
  547. calTargetPower2G[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
  548. struct cal_target_power_ht
  549. calTargetPower2GHT20[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
  550. struct cal_target_power_ht
  551. calTargetPower2GHT40[AR5416_EEP4K_NUM_2G_40_TARGET_POWERS];
  552. u8 ctlIndex[AR5416_EEP4K_NUM_CTLS];
  553. struct cal_ctl_data_4k ctlData[AR5416_EEP4K_NUM_CTLS];
  554. u8 padding;
  555. } __packed;
  556. struct ar9287_eeprom {
  557. struct base_eep_ar9287_header baseEepHeader;
  558. u8 custData[AR9287_DATA_SZ];
  559. struct modal_eep_ar9287_header modalHeader;
  560. u8 calFreqPier2G[AR9287_NUM_2G_CAL_PIERS];
  561. union cal_data_per_freq_ar9287_u
  562. calPierData2G[AR9287_MAX_CHAINS][AR9287_NUM_2G_CAL_PIERS];
  563. struct cal_target_power_leg
  564. calTargetPowerCck[AR9287_NUM_2G_CCK_TARGET_POWERS];
  565. struct cal_target_power_leg
  566. calTargetPower2G[AR9287_NUM_2G_20_TARGET_POWERS];
  567. struct cal_target_power_ht
  568. calTargetPower2GHT20[AR9287_NUM_2G_20_TARGET_POWERS];
  569. struct cal_target_power_ht
  570. calTargetPower2GHT40[AR9287_NUM_2G_40_TARGET_POWERS];
  571. u8 ctlIndex[AR9287_NUM_CTLS];
  572. struct cal_ctl_data_ar9287 ctlData[AR9287_NUM_CTLS];
  573. u8 padding;
  574. } __packed;
  575. enum reg_ext_bitmap {
  576. REG_EXT_FCC_MIDBAND = 0,
  577. REG_EXT_JAPAN_MIDBAND = 1,
  578. REG_EXT_FCC_DFS_HT40 = 2,
  579. REG_EXT_JAPAN_NONDFS_HT40 = 3,
  580. REG_EXT_JAPAN_DFS_HT40 = 4
  581. };
  582. struct ath9k_country_entry {
  583. u16 countryCode;
  584. u16 regDmnEnum;
  585. u16 regDmn5G;
  586. u16 regDmn2G;
  587. u8 isMultidomain;
  588. u8 iso[3];
  589. };
  590. struct eeprom_ops {
  591. int (*check_eeprom)(struct ath_hw *hw);
  592. u32 (*get_eeprom)(struct ath_hw *hw, enum eeprom_param param);
  593. bool (*fill_eeprom)(struct ath_hw *hw);
  594. u32 (*dump_eeprom)(struct ath_hw *hw, bool dump_base_hdr, u8 *buf,
  595. u32 len, u32 size);
  596. int (*get_eeprom_ver)(struct ath_hw *hw);
  597. int (*get_eeprom_rev)(struct ath_hw *hw);
  598. void (*set_board_values)(struct ath_hw *hw, struct ath9k_channel *chan);
  599. void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
  600. void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
  601. u16 cfgCtl, u8 twiceAntennaReduction,
  602. u8 powerLimit, bool test);
  603. u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
  604. u8 (*get_eepmisc)(struct ath_hw *ah);
  605. };
  606. void ath9k_hw_analog_shift_regwrite(struct ath_hw *ah, u32 reg, u32 val);
  607. void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask,
  608. u32 shift, u32 val);
  609. int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight,
  610. int16_t targetLeft,
  611. int16_t targetRight);
  612. bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize,
  613. u16 *indexL, u16 *indexR);
  614. bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data);
  615. int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size);
  616. bool ath9k_hw_nvram_validate_checksum(struct ath_hw *ah, int size);
  617. bool ath9k_hw_nvram_check_version(struct ath_hw *ah, int version, int minrev);
  618. void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
  619. int eep_start_loc, int size);
  620. void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
  621. u8 *pVpdList, u16 numIntercepts,
  622. u8 *pRetVpdList);
  623. void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah,
  624. struct ath9k_channel *chan,
  625. struct cal_target_power_leg *powInfo,
  626. u16 numChannels,
  627. struct cal_target_power_leg *pNewPower,
  628. u16 numRates, bool isExtTarget);
  629. void ath9k_hw_get_target_powers(struct ath_hw *ah,
  630. struct ath9k_channel *chan,
  631. struct cal_target_power_ht *powInfo,
  632. u16 numChannels,
  633. struct cal_target_power_ht *pNewPower,
  634. u16 numRates, bool isHt40Target);
  635. u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower,
  636. bool is2GHz, int num_band_edges);
  637. u16 ath9k_hw_get_scaled_power(struct ath_hw *ah, u16 power_limit,
  638. u8 antenna_reduction);
  639. void ath9k_hw_update_regulatory_maxpower(struct ath_hw *ah);
  640. int ath9k_hw_eeprom_init(struct ath_hw *ah);
  641. void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
  642. struct ath9k_channel *chan,
  643. void *pRawDataSet,
  644. u8 *bChans, u16 availPiers,
  645. u16 tPdGainOverlap,
  646. u16 *pPdGainBoundaries, u8 *pPDADCValues,
  647. u16 numXpdGains);
  648. static inline u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz)
  649. {
  650. if (fbin == AR5416_BCHAN_UNUSED)
  651. return fbin;
  652. return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
  653. }
  654. #define ar5416_get_ntxchains(_txchainmask) \
  655. (((_txchainmask >> 2) & 1) + \
  656. ((_txchainmask >> 1) & 1) + (_txchainmask & 1))
  657. extern const struct eeprom_ops eep_def_ops;
  658. extern const struct eeprom_ops eep_4k_ops;
  659. extern const struct eeprom_ops eep_ar9287_ops;
  660. extern const struct eeprom_ops eep_ar9287_ops;
  661. extern const struct eeprom_ops eep_ar9300_ops;
  662. #endif /* EEPROM_H */