eeprom.h 20 KB

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