PageRenderTime 69ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c

http://github.com/mirrors/linux
C | 5632 lines | 4677 code | 481 blank | 474 comment | 355 complexity | 28cf6144aaeebaaa42ae4fd940489bd8 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  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. #include <asm/unaligned.h>
  17. #include <linux/kernel.h>
  18. #include "hw.h"
  19. #include "ar9003_phy.h"
  20. #include "ar9003_eeprom.h"
  21. #include "ar9003_mci.h"
  22. #define COMP_HDR_LEN 4
  23. #define COMP_CKSUM_LEN 2
  24. #define LE16(x) cpu_to_le16(x)
  25. #define LE32(x) cpu_to_le32(x)
  26. /* Local defines to distinguish between extension and control CTL's */
  27. #define EXT_ADDITIVE (0x8000)
  28. #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
  29. #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
  30. #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
  31. #define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */
  32. #define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */
  33. #define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6))
  34. #define EEPROM_DATA_LEN_9485 1088
  35. static int ar9003_hw_power_interpolate(int32_t x,
  36. int32_t *px, int32_t *py, u_int16_t np);
  37. static const struct ar9300_eeprom ar9300_default = {
  38. .eepromVersion = 2,
  39. .templateVersion = 2,
  40. .macAddr = {0, 2, 3, 4, 5, 6},
  41. .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  43. .baseEepHeader = {
  44. .regDmn = { LE16(0), LE16(0x1f) },
  45. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  46. .opCapFlags = {
  47. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  48. .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
  49. },
  50. .rfSilent = 0,
  51. .blueToothOptions = 0,
  52. .deviceCap = 0,
  53. .deviceType = 5, /* takes lower byte in eeprom location */
  54. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  55. .params_for_tuning_caps = {0, 0},
  56. .featureEnable = 0x0c,
  57. /*
  58. * bit0 - enable tx temp comp - disabled
  59. * bit1 - enable tx volt comp - disabled
  60. * bit2 - enable fastClock - enabled
  61. * bit3 - enable doubling - enabled
  62. * bit4 - enable internal regulator - disabled
  63. * bit5 - enable pa predistortion - disabled
  64. */
  65. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  66. .eepromWriteEnableGpio = 3,
  67. .wlanDisableGpio = 0,
  68. .wlanLedGpio = 8,
  69. .rxBandSelectGpio = 0xff,
  70. .txrxgain = 0,
  71. .swreg = 0,
  72. },
  73. .modalHeader2G = {
  74. /* ar9300_modal_eep_header 2g */
  75. /* 4 idle,t1,t2,b(4 bits per setting) */
  76. .antCtrlCommon = LE32(0x110),
  77. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  78. .antCtrlCommon2 = LE32(0x22222),
  79. /*
  80. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  81. * rx1, rx12, b (2 bits each)
  82. */
  83. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  84. /*
  85. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  86. * for ar9280 (0xa20c/b20c 5:0)
  87. */
  88. .xatten1DB = {0, 0, 0},
  89. /*
  90. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  91. * for ar9280 (0xa20c/b20c 16:12
  92. */
  93. .xatten1Margin = {0, 0, 0},
  94. .tempSlope = 36,
  95. .voltSlope = 0,
  96. /*
  97. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  98. * channels in usual fbin coding format
  99. */
  100. .spurChans = {0, 0, 0, 0, 0},
  101. /*
  102. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  103. * if the register is per chain
  104. */
  105. .noiseFloorThreshCh = {-1, 0, 0},
  106. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  107. .quick_drop = 0,
  108. .xpaBiasLvl = 0,
  109. .txFrameToDataStart = 0x0e,
  110. .txFrameToPaOn = 0x0e,
  111. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  112. .antennaGain = 0,
  113. .switchSettling = 0x2c,
  114. .adcDesiredSize = -30,
  115. .txEndToXpaOff = 0,
  116. .txEndToRxOn = 0x2,
  117. .txFrameToXpaOn = 0xe,
  118. .thresh62 = 28,
  119. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  120. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  121. .switchcomspdt = 0,
  122. .xlna_bias_strength = 0,
  123. .futureModal = {
  124. 0, 0, 0, 0, 0, 0, 0,
  125. },
  126. },
  127. .base_ext1 = {
  128. .ant_div_control = 0,
  129. .future = {0, 0},
  130. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  131. },
  132. .calFreqPier2G = {
  133. FREQ2FBIN(2412, 1),
  134. FREQ2FBIN(2437, 1),
  135. FREQ2FBIN(2472, 1),
  136. },
  137. /* ar9300_cal_data_per_freq_op_loop 2g */
  138. .calPierData2G = {
  139. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  140. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  141. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  142. },
  143. .calTarget_freqbin_Cck = {
  144. FREQ2FBIN(2412, 1),
  145. FREQ2FBIN(2484, 1),
  146. },
  147. .calTarget_freqbin_2G = {
  148. FREQ2FBIN(2412, 1),
  149. FREQ2FBIN(2437, 1),
  150. FREQ2FBIN(2472, 1)
  151. },
  152. .calTarget_freqbin_2GHT20 = {
  153. FREQ2FBIN(2412, 1),
  154. FREQ2FBIN(2437, 1),
  155. FREQ2FBIN(2472, 1)
  156. },
  157. .calTarget_freqbin_2GHT40 = {
  158. FREQ2FBIN(2412, 1),
  159. FREQ2FBIN(2437, 1),
  160. FREQ2FBIN(2472, 1)
  161. },
  162. .calTargetPowerCck = {
  163. /* 1L-5L,5S,11L,11S */
  164. { {36, 36, 36, 36} },
  165. { {36, 36, 36, 36} },
  166. },
  167. .calTargetPower2G = {
  168. /* 6-24,36,48,54 */
  169. { {32, 32, 28, 24} },
  170. { {32, 32, 28, 24} },
  171. { {32, 32, 28, 24} },
  172. },
  173. .calTargetPower2GHT20 = {
  174. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  175. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  176. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  177. },
  178. .calTargetPower2GHT40 = {
  179. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  180. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  181. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  182. },
  183. .ctlIndex_2G = {
  184. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  185. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  186. },
  187. .ctl_freqbin_2G = {
  188. {
  189. FREQ2FBIN(2412, 1),
  190. FREQ2FBIN(2417, 1),
  191. FREQ2FBIN(2457, 1),
  192. FREQ2FBIN(2462, 1)
  193. },
  194. {
  195. FREQ2FBIN(2412, 1),
  196. FREQ2FBIN(2417, 1),
  197. FREQ2FBIN(2462, 1),
  198. 0xFF,
  199. },
  200. {
  201. FREQ2FBIN(2412, 1),
  202. FREQ2FBIN(2417, 1),
  203. FREQ2FBIN(2462, 1),
  204. 0xFF,
  205. },
  206. {
  207. FREQ2FBIN(2422, 1),
  208. FREQ2FBIN(2427, 1),
  209. FREQ2FBIN(2447, 1),
  210. FREQ2FBIN(2452, 1)
  211. },
  212. {
  213. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  214. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  215. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  216. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  217. },
  218. {
  219. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  220. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  221. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  222. 0,
  223. },
  224. {
  225. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  226. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  227. FREQ2FBIN(2472, 1),
  228. 0,
  229. },
  230. {
  231. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  232. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  233. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  234. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  235. },
  236. {
  237. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  238. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  239. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  240. },
  241. {
  242. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  243. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  244. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  245. 0
  246. },
  247. {
  248. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  249. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  250. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  251. 0
  252. },
  253. {
  254. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  255. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  256. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  257. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  258. }
  259. },
  260. .ctlPowerData_2G = {
  261. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  262. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  263. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  264. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  265. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  266. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  267. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  268. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  269. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  270. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  271. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  272. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  273. },
  274. .modalHeader5G = {
  275. /* 4 idle,t1,t2,b (4 bits per setting) */
  276. .antCtrlCommon = LE32(0x110),
  277. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  278. .antCtrlCommon2 = LE32(0x22222),
  279. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  280. .antCtrlChain = {
  281. LE16(0x000), LE16(0x000), LE16(0x000),
  282. },
  283. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  284. .xatten1DB = {0, 0, 0},
  285. /*
  286. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  287. * for merlin (0xa20c/b20c 16:12
  288. */
  289. .xatten1Margin = {0, 0, 0},
  290. .tempSlope = 68,
  291. .voltSlope = 0,
  292. /* spurChans spur channels in usual fbin coding format */
  293. .spurChans = {0, 0, 0, 0, 0},
  294. /* noiseFloorThreshCh Check if the register is per chain */
  295. .noiseFloorThreshCh = {-1, 0, 0},
  296. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  297. .quick_drop = 0,
  298. .xpaBiasLvl = 0,
  299. .txFrameToDataStart = 0x0e,
  300. .txFrameToPaOn = 0x0e,
  301. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  302. .antennaGain = 0,
  303. .switchSettling = 0x2d,
  304. .adcDesiredSize = -30,
  305. .txEndToXpaOff = 0,
  306. .txEndToRxOn = 0x2,
  307. .txFrameToXpaOn = 0xe,
  308. .thresh62 = 28,
  309. .papdRateMaskHt20 = LE32(0x0c80c080),
  310. .papdRateMaskHt40 = LE32(0x0080c080),
  311. .switchcomspdt = 0,
  312. .xlna_bias_strength = 0,
  313. .futureModal = {
  314. 0, 0, 0, 0, 0, 0, 0,
  315. },
  316. },
  317. .base_ext2 = {
  318. .tempSlopeLow = 0,
  319. .tempSlopeHigh = 0,
  320. .xatten1DBLow = {0, 0, 0},
  321. .xatten1MarginLow = {0, 0, 0},
  322. .xatten1DBHigh = {0, 0, 0},
  323. .xatten1MarginHigh = {0, 0, 0}
  324. },
  325. .calFreqPier5G = {
  326. FREQ2FBIN(5180, 0),
  327. FREQ2FBIN(5220, 0),
  328. FREQ2FBIN(5320, 0),
  329. FREQ2FBIN(5400, 0),
  330. FREQ2FBIN(5500, 0),
  331. FREQ2FBIN(5600, 0),
  332. FREQ2FBIN(5725, 0),
  333. FREQ2FBIN(5825, 0)
  334. },
  335. .calPierData5G = {
  336. {
  337. {0, 0, 0, 0, 0},
  338. {0, 0, 0, 0, 0},
  339. {0, 0, 0, 0, 0},
  340. {0, 0, 0, 0, 0},
  341. {0, 0, 0, 0, 0},
  342. {0, 0, 0, 0, 0},
  343. {0, 0, 0, 0, 0},
  344. {0, 0, 0, 0, 0},
  345. },
  346. {
  347. {0, 0, 0, 0, 0},
  348. {0, 0, 0, 0, 0},
  349. {0, 0, 0, 0, 0},
  350. {0, 0, 0, 0, 0},
  351. {0, 0, 0, 0, 0},
  352. {0, 0, 0, 0, 0},
  353. {0, 0, 0, 0, 0},
  354. {0, 0, 0, 0, 0},
  355. },
  356. {
  357. {0, 0, 0, 0, 0},
  358. {0, 0, 0, 0, 0},
  359. {0, 0, 0, 0, 0},
  360. {0, 0, 0, 0, 0},
  361. {0, 0, 0, 0, 0},
  362. {0, 0, 0, 0, 0},
  363. {0, 0, 0, 0, 0},
  364. {0, 0, 0, 0, 0},
  365. },
  366. },
  367. .calTarget_freqbin_5G = {
  368. FREQ2FBIN(5180, 0),
  369. FREQ2FBIN(5220, 0),
  370. FREQ2FBIN(5320, 0),
  371. FREQ2FBIN(5400, 0),
  372. FREQ2FBIN(5500, 0),
  373. FREQ2FBIN(5600, 0),
  374. FREQ2FBIN(5725, 0),
  375. FREQ2FBIN(5825, 0)
  376. },
  377. .calTarget_freqbin_5GHT20 = {
  378. FREQ2FBIN(5180, 0),
  379. FREQ2FBIN(5240, 0),
  380. FREQ2FBIN(5320, 0),
  381. FREQ2FBIN(5500, 0),
  382. FREQ2FBIN(5700, 0),
  383. FREQ2FBIN(5745, 0),
  384. FREQ2FBIN(5725, 0),
  385. FREQ2FBIN(5825, 0)
  386. },
  387. .calTarget_freqbin_5GHT40 = {
  388. FREQ2FBIN(5180, 0),
  389. FREQ2FBIN(5240, 0),
  390. FREQ2FBIN(5320, 0),
  391. FREQ2FBIN(5500, 0),
  392. FREQ2FBIN(5700, 0),
  393. FREQ2FBIN(5745, 0),
  394. FREQ2FBIN(5725, 0),
  395. FREQ2FBIN(5825, 0)
  396. },
  397. .calTargetPower5G = {
  398. /* 6-24,36,48,54 */
  399. { {20, 20, 20, 10} },
  400. { {20, 20, 20, 10} },
  401. { {20, 20, 20, 10} },
  402. { {20, 20, 20, 10} },
  403. { {20, 20, 20, 10} },
  404. { {20, 20, 20, 10} },
  405. { {20, 20, 20, 10} },
  406. { {20, 20, 20, 10} },
  407. },
  408. .calTargetPower5GHT20 = {
  409. /*
  410. * 0_8_16,1-3_9-11_17-19,
  411. * 4,5,6,7,12,13,14,15,20,21,22,23
  412. */
  413. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  414. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  415. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  416. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  417. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  418. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  419. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  420. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  421. },
  422. .calTargetPower5GHT40 = {
  423. /*
  424. * 0_8_16,1-3_9-11_17-19,
  425. * 4,5,6,7,12,13,14,15,20,21,22,23
  426. */
  427. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  428. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  429. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  430. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  431. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  432. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  433. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  434. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  435. },
  436. .ctlIndex_5G = {
  437. 0x10, 0x16, 0x18, 0x40, 0x46,
  438. 0x48, 0x30, 0x36, 0x38
  439. },
  440. .ctl_freqbin_5G = {
  441. {
  442. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  443. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  444. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  445. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  446. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  447. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  448. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  449. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  450. },
  451. {
  452. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  453. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  454. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  455. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  456. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  457. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  458. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  459. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  460. },
  461. {
  462. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  463. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  464. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  465. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  466. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  467. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  468. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  469. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  470. },
  471. {
  472. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  473. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  474. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  475. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  476. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  477. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  478. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  479. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  480. },
  481. {
  482. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  483. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  484. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  485. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  486. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  487. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  488. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  489. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  490. },
  491. {
  492. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  493. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  494. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  495. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  496. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  497. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  498. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  499. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  500. },
  501. {
  502. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  503. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  504. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  505. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  506. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  507. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  508. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  509. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  510. },
  511. {
  512. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  513. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  514. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  515. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  516. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  517. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  518. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  519. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  520. },
  521. {
  522. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  523. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  524. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  525. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  526. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  527. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  528. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  529. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  530. }
  531. },
  532. .ctlPowerData_5G = {
  533. {
  534. {
  535. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  536. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  537. }
  538. },
  539. {
  540. {
  541. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  542. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  543. }
  544. },
  545. {
  546. {
  547. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  548. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  549. }
  550. },
  551. {
  552. {
  553. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  554. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  555. }
  556. },
  557. {
  558. {
  559. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  560. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  561. }
  562. },
  563. {
  564. {
  565. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  566. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  567. }
  568. },
  569. {
  570. {
  571. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  572. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  573. }
  574. },
  575. {
  576. {
  577. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  578. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  579. }
  580. },
  581. {
  582. {
  583. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  584. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  585. }
  586. },
  587. }
  588. };
  589. static const struct ar9300_eeprom ar9300_x113 = {
  590. .eepromVersion = 2,
  591. .templateVersion = 6,
  592. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  593. .custData = {"x113-023-f0000"},
  594. .baseEepHeader = {
  595. .regDmn = { LE16(0), LE16(0x1f) },
  596. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  597. .opCapFlags = {
  598. .opFlags = AR5416_OPFLAGS_11A,
  599. .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
  600. },
  601. .rfSilent = 0,
  602. .blueToothOptions = 0,
  603. .deviceCap = 0,
  604. .deviceType = 5, /* takes lower byte in eeprom location */
  605. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  606. .params_for_tuning_caps = {0, 0},
  607. .featureEnable = 0x0d,
  608. /*
  609. * bit0 - enable tx temp comp - disabled
  610. * bit1 - enable tx volt comp - disabled
  611. * bit2 - enable fastClock - enabled
  612. * bit3 - enable doubling - enabled
  613. * bit4 - enable internal regulator - disabled
  614. * bit5 - enable pa predistortion - disabled
  615. */
  616. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  617. .eepromWriteEnableGpio = 6,
  618. .wlanDisableGpio = 0,
  619. .wlanLedGpio = 8,
  620. .rxBandSelectGpio = 0xff,
  621. .txrxgain = 0x21,
  622. .swreg = 0,
  623. },
  624. .modalHeader2G = {
  625. /* ar9300_modal_eep_header 2g */
  626. /* 4 idle,t1,t2,b(4 bits per setting) */
  627. .antCtrlCommon = LE32(0x110),
  628. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  629. .antCtrlCommon2 = LE32(0x44444),
  630. /*
  631. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  632. * rx1, rx12, b (2 bits each)
  633. */
  634. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  635. /*
  636. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  637. * for ar9280 (0xa20c/b20c 5:0)
  638. */
  639. .xatten1DB = {0, 0, 0},
  640. /*
  641. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  642. * for ar9280 (0xa20c/b20c 16:12
  643. */
  644. .xatten1Margin = {0, 0, 0},
  645. .tempSlope = 25,
  646. .voltSlope = 0,
  647. /*
  648. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  649. * channels in usual fbin coding format
  650. */
  651. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  652. /*
  653. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  654. * if the register is per chain
  655. */
  656. .noiseFloorThreshCh = {-1, 0, 0},
  657. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  658. .quick_drop = 0,
  659. .xpaBiasLvl = 0,
  660. .txFrameToDataStart = 0x0e,
  661. .txFrameToPaOn = 0x0e,
  662. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  663. .antennaGain = 0,
  664. .switchSettling = 0x2c,
  665. .adcDesiredSize = -30,
  666. .txEndToXpaOff = 0,
  667. .txEndToRxOn = 0x2,
  668. .txFrameToXpaOn = 0xe,
  669. .thresh62 = 28,
  670. .papdRateMaskHt20 = LE32(0x0c80c080),
  671. .papdRateMaskHt40 = LE32(0x0080c080),
  672. .switchcomspdt = 0,
  673. .xlna_bias_strength = 0,
  674. .futureModal = {
  675. 0, 0, 0, 0, 0, 0, 0,
  676. },
  677. },
  678. .base_ext1 = {
  679. .ant_div_control = 0,
  680. .future = {0, 0},
  681. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  682. },
  683. .calFreqPier2G = {
  684. FREQ2FBIN(2412, 1),
  685. FREQ2FBIN(2437, 1),
  686. FREQ2FBIN(2472, 1),
  687. },
  688. /* ar9300_cal_data_per_freq_op_loop 2g */
  689. .calPierData2G = {
  690. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  691. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  692. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  693. },
  694. .calTarget_freqbin_Cck = {
  695. FREQ2FBIN(2412, 1),
  696. FREQ2FBIN(2472, 1),
  697. },
  698. .calTarget_freqbin_2G = {
  699. FREQ2FBIN(2412, 1),
  700. FREQ2FBIN(2437, 1),
  701. FREQ2FBIN(2472, 1)
  702. },
  703. .calTarget_freqbin_2GHT20 = {
  704. FREQ2FBIN(2412, 1),
  705. FREQ2FBIN(2437, 1),
  706. FREQ2FBIN(2472, 1)
  707. },
  708. .calTarget_freqbin_2GHT40 = {
  709. FREQ2FBIN(2412, 1),
  710. FREQ2FBIN(2437, 1),
  711. FREQ2FBIN(2472, 1)
  712. },
  713. .calTargetPowerCck = {
  714. /* 1L-5L,5S,11L,11S */
  715. { {34, 34, 34, 34} },
  716. { {34, 34, 34, 34} },
  717. },
  718. .calTargetPower2G = {
  719. /* 6-24,36,48,54 */
  720. { {34, 34, 32, 32} },
  721. { {34, 34, 32, 32} },
  722. { {34, 34, 32, 32} },
  723. },
  724. .calTargetPower2GHT20 = {
  725. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  726. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  727. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  728. },
  729. .calTargetPower2GHT40 = {
  730. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  731. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  732. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  733. },
  734. .ctlIndex_2G = {
  735. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  736. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  737. },
  738. .ctl_freqbin_2G = {
  739. {
  740. FREQ2FBIN(2412, 1),
  741. FREQ2FBIN(2417, 1),
  742. FREQ2FBIN(2457, 1),
  743. FREQ2FBIN(2462, 1)
  744. },
  745. {
  746. FREQ2FBIN(2412, 1),
  747. FREQ2FBIN(2417, 1),
  748. FREQ2FBIN(2462, 1),
  749. 0xFF,
  750. },
  751. {
  752. FREQ2FBIN(2412, 1),
  753. FREQ2FBIN(2417, 1),
  754. FREQ2FBIN(2462, 1),
  755. 0xFF,
  756. },
  757. {
  758. FREQ2FBIN(2422, 1),
  759. FREQ2FBIN(2427, 1),
  760. FREQ2FBIN(2447, 1),
  761. FREQ2FBIN(2452, 1)
  762. },
  763. {
  764. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  765. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  766. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  767. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  768. },
  769. {
  770. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  771. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  772. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  773. 0,
  774. },
  775. {
  776. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  777. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  778. FREQ2FBIN(2472, 1),
  779. 0,
  780. },
  781. {
  782. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  783. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  784. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  785. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  786. },
  787. {
  788. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  789. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  790. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  791. },
  792. {
  793. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  794. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  795. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  796. 0
  797. },
  798. {
  799. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  800. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  801. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  802. 0
  803. },
  804. {
  805. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  806. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  807. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  808. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  809. }
  810. },
  811. .ctlPowerData_2G = {
  812. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  813. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  814. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  815. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  816. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  817. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  818. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  819. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  820. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  821. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  822. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  823. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  824. },
  825. .modalHeader5G = {
  826. /* 4 idle,t1,t2,b (4 bits per setting) */
  827. .antCtrlCommon = LE32(0x220),
  828. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  829. .antCtrlCommon2 = LE32(0x11111),
  830. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  831. .antCtrlChain = {
  832. LE16(0x150), LE16(0x150), LE16(0x150),
  833. },
  834. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  835. .xatten1DB = {0, 0, 0},
  836. /*
  837. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  838. * for merlin (0xa20c/b20c 16:12
  839. */
  840. .xatten1Margin = {0, 0, 0},
  841. .tempSlope = 68,
  842. .voltSlope = 0,
  843. /* spurChans spur channels in usual fbin coding format */
  844. .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0},
  845. /* noiseFloorThreshCh Check if the register is per chain */
  846. .noiseFloorThreshCh = {-1, 0, 0},
  847. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  848. .quick_drop = 0,
  849. .xpaBiasLvl = 0xf,
  850. .txFrameToDataStart = 0x0e,
  851. .txFrameToPaOn = 0x0e,
  852. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  853. .antennaGain = 0,
  854. .switchSettling = 0x2d,
  855. .adcDesiredSize = -30,
  856. .txEndToXpaOff = 0,
  857. .txEndToRxOn = 0x2,
  858. .txFrameToXpaOn = 0xe,
  859. .thresh62 = 28,
  860. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  861. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  862. .switchcomspdt = 0,
  863. .xlna_bias_strength = 0,
  864. .futureModal = {
  865. 0, 0, 0, 0, 0, 0, 0,
  866. },
  867. },
  868. .base_ext2 = {
  869. .tempSlopeLow = 72,
  870. .tempSlopeHigh = 105,
  871. .xatten1DBLow = {0, 0, 0},
  872. .xatten1MarginLow = {0, 0, 0},
  873. .xatten1DBHigh = {0, 0, 0},
  874. .xatten1MarginHigh = {0, 0, 0}
  875. },
  876. .calFreqPier5G = {
  877. FREQ2FBIN(5180, 0),
  878. FREQ2FBIN(5240, 0),
  879. FREQ2FBIN(5320, 0),
  880. FREQ2FBIN(5400, 0),
  881. FREQ2FBIN(5500, 0),
  882. FREQ2FBIN(5600, 0),
  883. FREQ2FBIN(5745, 0),
  884. FREQ2FBIN(5785, 0)
  885. },
  886. .calPierData5G = {
  887. {
  888. {0, 0, 0, 0, 0},
  889. {0, 0, 0, 0, 0},
  890. {0, 0, 0, 0, 0},
  891. {0, 0, 0, 0, 0},
  892. {0, 0, 0, 0, 0},
  893. {0, 0, 0, 0, 0},
  894. {0, 0, 0, 0, 0},
  895. {0, 0, 0, 0, 0},
  896. },
  897. {
  898. {0, 0, 0, 0, 0},
  899. {0, 0, 0, 0, 0},
  900. {0, 0, 0, 0, 0},
  901. {0, 0, 0, 0, 0},
  902. {0, 0, 0, 0, 0},
  903. {0, 0, 0, 0, 0},
  904. {0, 0, 0, 0, 0},
  905. {0, 0, 0, 0, 0},
  906. },
  907. {
  908. {0, 0, 0, 0, 0},
  909. {0, 0, 0, 0, 0},
  910. {0, 0, 0, 0, 0},
  911. {0, 0, 0, 0, 0},
  912. {0, 0, 0, 0, 0},
  913. {0, 0, 0, 0, 0},
  914. {0, 0, 0, 0, 0},
  915. {0, 0, 0, 0, 0},
  916. },
  917. },
  918. .calTarget_freqbin_5G = {
  919. FREQ2FBIN(5180, 0),
  920. FREQ2FBIN(5220, 0),
  921. FREQ2FBIN(5320, 0),
  922. FREQ2FBIN(5400, 0),
  923. FREQ2FBIN(5500, 0),
  924. FREQ2FBIN(5600, 0),
  925. FREQ2FBIN(5745, 0),
  926. FREQ2FBIN(5785, 0)
  927. },
  928. .calTarget_freqbin_5GHT20 = {
  929. FREQ2FBIN(5180, 0),
  930. FREQ2FBIN(5240, 0),
  931. FREQ2FBIN(5320, 0),
  932. FREQ2FBIN(5400, 0),
  933. FREQ2FBIN(5500, 0),
  934. FREQ2FBIN(5700, 0),
  935. FREQ2FBIN(5745, 0),
  936. FREQ2FBIN(5825, 0)
  937. },
  938. .calTarget_freqbin_5GHT40 = {
  939. FREQ2FBIN(5190, 0),
  940. FREQ2FBIN(5230, 0),
  941. FREQ2FBIN(5320, 0),
  942. FREQ2FBIN(5410, 0),
  943. FREQ2FBIN(5510, 0),
  944. FREQ2FBIN(5670, 0),
  945. FREQ2FBIN(5755, 0),
  946. FREQ2FBIN(5825, 0)
  947. },
  948. .calTargetPower5G = {
  949. /* 6-24,36,48,54 */
  950. { {42, 40, 40, 34} },
  951. { {42, 40, 40, 34} },
  952. { {42, 40, 40, 34} },
  953. { {42, 40, 40, 34} },
  954. { {42, 40, 40, 34} },
  955. { {42, 40, 40, 34} },
  956. { {42, 40, 40, 34} },
  957. { {42, 40, 40, 34} },
  958. },
  959. .calTargetPower5GHT20 = {
  960. /*
  961. * 0_8_16,1-3_9-11_17-19,
  962. * 4,5,6,7,12,13,14,15,20,21,22,23
  963. */
  964. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  965. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  966. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  967. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  968. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  969. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  970. { {38, 38, 38, 38, 32, 28, 38, 38, 32, 28, 38, 38, 32, 26} },
  971. { {36, 36, 36, 36, 32, 28, 36, 36, 32, 28, 36, 36, 32, 26} },
  972. },
  973. .calTargetPower5GHT40 = {
  974. /*
  975. * 0_8_16,1-3_9-11_17-19,
  976. * 4,5,6,7,12,13,14,15,20,21,22,23
  977. */
  978. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  979. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  980. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  981. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  982. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  983. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  984. { {36, 36, 36, 36, 30, 26, 36, 36, 30, 26, 36, 36, 30, 24} },
  985. { {34, 34, 34, 34, 30, 26, 34, 34, 30, 26, 34, 34, 30, 24} },
  986. },
  987. .ctlIndex_5G = {
  988. 0x10, 0x16, 0x18, 0x40, 0x46,
  989. 0x48, 0x30, 0x36, 0x38
  990. },
  991. .ctl_freqbin_5G = {
  992. {
  993. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  994. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  995. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  996. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  997. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  998. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  999. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1000. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1001. },
  1002. {
  1003. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1004. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1005. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1006. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1007. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  1008. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1009. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1010. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1011. },
  1012. {
  1013. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1014. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1015. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1016. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  1017. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  1018. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  1019. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  1020. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  1021. },
  1022. {
  1023. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1024. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1025. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  1026. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  1027. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1028. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1029. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  1030. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  1031. },
  1032. {
  1033. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1034. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1035. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  1036. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  1037. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  1038. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  1039. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  1040. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  1041. },
  1042. {
  1043. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1044. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  1045. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  1046. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1047. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  1048. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1049. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  1050. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  1051. },
  1052. {
  1053. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1054. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1055. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  1056. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  1057. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1058. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  1059. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  1060. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  1061. },
  1062. {
  1063. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1064. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1065. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  1066. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1067. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  1068. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1069. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1070. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1071. },
  1072. {
  1073. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1074. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1075. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1076. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1077. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  1078. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1079. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  1080. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  1081. }
  1082. },
  1083. .ctlPowerData_5G = {
  1084. {
  1085. {
  1086. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1087. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1088. }
  1089. },
  1090. {
  1091. {
  1092. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1093. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1094. }
  1095. },
  1096. {
  1097. {
  1098. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1099. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1100. }
  1101. },
  1102. {
  1103. {
  1104. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1105. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1106. }
  1107. },
  1108. {
  1109. {
  1110. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1111. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1112. }
  1113. },
  1114. {
  1115. {
  1116. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1117. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1118. }
  1119. },
  1120. {
  1121. {
  1122. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1123. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1124. }
  1125. },
  1126. {
  1127. {
  1128. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1129. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1130. }
  1131. },
  1132. {
  1133. {
  1134. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  1135. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1136. }
  1137. },
  1138. }
  1139. };
  1140. static const struct ar9300_eeprom ar9300_h112 = {
  1141. .eepromVersion = 2,
  1142. .templateVersion = 3,
  1143. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  1144. .custData = {"h112-241-f0000"},
  1145. .baseEepHeader = {
  1146. .regDmn = { LE16(0), LE16(0x1f) },
  1147. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  1148. .opCapFlags = {
  1149. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  1150. .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
  1151. },
  1152. .rfSilent = 0,
  1153. .blueToothOptions = 0,
  1154. .deviceCap = 0,
  1155. .deviceType = 5, /* takes lower byte in eeprom location */
  1156. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  1157. .params_for_tuning_caps = {0, 0},
  1158. .featureEnable = 0x0d,
  1159. /*
  1160. * bit0 - enable tx temp comp - disabled
  1161. * bit1 - enable tx volt comp - disabled
  1162. * bit2 - enable fastClock - enabled
  1163. * bit3 - enable doubling - enabled
  1164. * bit4 - enable internal regulator - disabled
  1165. * bit5 - enable pa predistortion - disabled
  1166. */
  1167. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  1168. .eepromWriteEnableGpio = 6,
  1169. .wlanDisableGpio = 0,
  1170. .wlanLedGpio = 8,
  1171. .rxBandSelectGpio = 0xff,
  1172. .txrxgain = 0x10,
  1173. .swreg = 0,
  1174. },
  1175. .modalHeader2G = {
  1176. /* ar9300_modal_eep_header 2g */
  1177. /* 4 idle,t1,t2,b(4 bits per setting) */
  1178. .antCtrlCommon = LE32(0x110),
  1179. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  1180. .antCtrlCommon2 = LE32(0x44444),
  1181. /*
  1182. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  1183. * rx1, rx12, b (2 bits each)
  1184. */
  1185. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  1186. /*
  1187. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  1188. * for ar9280 (0xa20c/b20c 5:0)
  1189. */
  1190. .xatten1DB = {0, 0, 0},
  1191. /*
  1192. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  1193. * for ar9280 (0xa20c/b20c 16:12
  1194. */
  1195. .xatten1Margin = {0, 0, 0},
  1196. .tempSlope = 25,
  1197. .voltSlope = 0,
  1198. /*
  1199. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  1200. * channels in usual fbin coding format
  1201. */
  1202. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  1203. /*
  1204. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  1205. * if the register is per chain
  1206. */
  1207. .noiseFloorThreshCh = {-1, 0, 0},
  1208. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1209. .quick_drop = 0,
  1210. .xpaBiasLvl = 0,
  1211. .txFrameToDataStart = 0x0e,
  1212. .txFrameToPaOn = 0x0e,
  1213. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1214. .antennaGain = 0,
  1215. .switchSettling = 0x2c,
  1216. .adcDesiredSize = -30,
  1217. .txEndToXpaOff = 0,
  1218. .txEndToRxOn = 0x2,
  1219. .txFrameToXpaOn = 0xe,
  1220. .thresh62 = 28,
  1221. .papdRateMaskHt20 = LE32(0x0c80c080),
  1222. .papdRateMaskHt40 = LE32(0x0080c080),
  1223. .switchcomspdt = 0,
  1224. .xlna_bias_strength = 0,
  1225. .futureModal = {
  1226. 0, 0, 0, 0, 0, 0, 0,
  1227. },
  1228. },
  1229. .base_ext1 = {
  1230. .ant_div_control = 0,
  1231. .future = {0, 0},
  1232. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  1233. },
  1234. .calFreqPier2G = {
  1235. FREQ2FBIN(2412, 1),
  1236. FREQ2FBIN(2437, 1),
  1237. FREQ2FBIN(2462, 1),
  1238. },
  1239. /* ar9300_cal_data_per_freq_op_loop 2g */
  1240. .calPierData2G = {
  1241. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1242. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1243. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1244. },
  1245. .calTarget_freqbin_Cck = {
  1246. FREQ2FBIN(2412, 1),
  1247. FREQ2FBIN(2472, 1),
  1248. },
  1249. .calTarget_freqbin_2G = {
  1250. FREQ2FBIN(2412, 1),
  1251. FREQ2FBIN(2437, 1),
  1252. FREQ2FBIN(2472, 1)
  1253. },
  1254. .calTarget_freqbin_2GHT20 = {
  1255. FREQ2FBIN(2412, 1),
  1256. FREQ2FBIN(2437, 1),
  1257. FREQ2FBIN(2472, 1)
  1258. },
  1259. .calTarget_freqbin_2GHT40 = {
  1260. FREQ2FBIN(2412, 1),
  1261. FREQ2FBIN(2437, 1),
  1262. FREQ2FBIN(2472, 1)
  1263. },
  1264. .calTargetPowerCck = {
  1265. /* 1L-5L,5S,11L,11S */
  1266. { {34, 34, 34, 34} },
  1267. { {34, 34, 34, 34} },
  1268. },
  1269. .calTargetPower2G = {
  1270. /* 6-24,36,48,54 */
  1271. { {34, 34, 32, 32} },
  1272. { {34, 34, 32, 32} },
  1273. { {34, 34, 32, 32} },
  1274. },
  1275. .calTargetPower2GHT20 = {
  1276. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1277. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1278. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1279. },
  1280. .calTargetPower2GHT40 = {
  1281. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1282. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1283. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1284. },
  1285. .ctlIndex_2G = {
  1286. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  1287. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  1288. },
  1289. .ctl_freqbin_2G = {
  1290. {
  1291. FREQ2FBIN(2412, 1),
  1292. FREQ2FBIN(2417, 1),
  1293. FREQ2FBIN(2457, 1),
  1294. FREQ2FBIN(2462, 1)
  1295. },
  1296. {
  1297. FREQ2FBIN(2412, 1),
  1298. FREQ2FBIN(2417, 1),
  1299. FREQ2FBIN(2462, 1),
  1300. 0xFF,
  1301. },
  1302. {
  1303. FREQ2FBIN(2412, 1),
  1304. FREQ2FBIN(2417, 1),
  1305. FREQ2FBIN(2462, 1),
  1306. 0xFF,
  1307. },
  1308. {
  1309. FREQ2FBIN(2422, 1),
  1310. FREQ2FBIN(2427, 1),
  1311. FREQ2FBIN(2447, 1),
  1312. FREQ2FBIN(2452, 1)
  1313. },
  1314. {
  1315. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1316. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1317. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1318. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  1319. },
  1320. {
  1321. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1322. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1323. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1324. 0,
  1325. },
  1326. {
  1327. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1328. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1329. FREQ2FBIN(2472, 1),
  1330. 0,
  1331. },
  1332. {
  1333. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  1334. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  1335. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  1336. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  1337. },
  1338. {
  1339. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1340. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1341. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1342. },
  1343. {
  1344. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1345. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1346. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1347. 0
  1348. },
  1349. {
  1350. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1351. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1352. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1353. 0
  1354. },
  1355. {
  1356. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  1357. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  1358. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  1359. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  1360. }
  1361. },
  1362. .ctlPowerData_2G = {
  1363. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1364. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1365. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  1366. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  1367. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1368. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1369. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  1370. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1371. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1372. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1373. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1374. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1375. },
  1376. .modalHeader5G = {
  1377. /* 4 idle,t1,t2,b (4 bits per setting) */
  1378. .antCtrlCommon = LE32(0x220),
  1379. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  1380. .antCtrlCommon2 = LE32(0x44444),
  1381. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  1382. .antCtrlChain = {
  1383. LE16(0x150), LE16(0x150), LE16(0x150),
  1384. },
  1385. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  1386. .xatten1DB = {0, 0, 0},
  1387. /*
  1388. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  1389. * for merlin (0xa20c/b20c 16:12
  1390. */
  1391. .xatten1Margin = {0, 0, 0},
  1392. .tempSlope = 45,
  1393. .voltSlope = 0,
  1394. /* spurChans spur channels in usual fbin coding format */
  1395. .spurChans = {0, 0, 0, 0, 0},
  1396. /* noiseFloorThreshCh Check if the register is per chain */
  1397. .noiseFloorThreshCh = {-1, 0, 0},
  1398. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1399. .quick_drop = 0,
  1400. .xpaBiasLvl = 0,
  1401. .txFrameToDataStart = 0x0e,
  1402. .txFrameToPaOn = 0x0e,
  1403. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1404. .antennaGain = 0,
  1405. .switchSettling = 0x2d,
  1406. .adcDesiredSize = -30,
  1407. .txEndToXpaOff = 0,
  1408. .txEndToRxOn = 0x2,
  1409. .txFrameToXpaOn = 0xe,
  1410. .thresh62 = 28,
  1411. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  1412. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  1413. .switchcomspdt = 0,
  1414. .xlna_bias_strength = 0,
  1415. .futureModal = {
  1416. 0, 0, 0, 0, 0, 0, 0,
  1417. },
  1418. },
  1419. .base_ext2 = {
  1420. .tempSlopeLow = 40,
  1421. .tempSlopeHigh = 50,
  1422. .xatten1DBLow = {0, 0, 0},
  1423. .xatten1MarginLow = {0, 0, 0},
  1424. .xatten1DBHigh = {0, 0, 0},
  1425. .xatten1MarginHigh = {0, 0, 0}
  1426. },
  1427. .calFreqPier5G = {
  1428. FREQ2FBIN(5180, 0),
  1429. FREQ2FBIN(5220, 0),
  1430. FREQ2FBIN(5320, 0),
  1431. FREQ2FBIN(5400, 0),
  1432. FREQ2FBIN(5500, 0),
  1433. FREQ2FBIN(5600, 0),
  1434. FREQ2FBIN(5700, 0),
  1435. FREQ2FBIN(5785, 0)
  1436. },
  1437. .calPierData5G = {
  1438. {
  1439. {0, 0, 0, 0, 0},
  1440. {0, 0, 0, 0, 0},
  1441. {0, 0, 0, 0, 0},
  1442. {0, 0, 0, 0, 0},
  1443. {0, 0, 0, 0, 0},
  1444. {0, 0, 0, 0, 0},
  1445. {0, 0, 0, 0, 0},
  1446. {0, 0, 0, 0, 0},
  1447. },
  1448. {
  1449. {0, 0, 0, 0, 0},
  1450. {0, 0, 0, 0, 0},
  1451. {0, 0, 0, 0, 0},
  1452. {0, 0, 0, 0, 0},
  1453. {0, 0, 0, 0, 0},
  1454. {0, 0, 0, 0, 0},
  1455. {0, 0, 0, 0, 0},
  1456. {0, 0, 0, 0, 0},
  1457. },
  1458. {
  1459. {0, 0, 0, 0, 0},
  1460. {0, 0, 0, 0, 0},
  1461. {0, 0, 0, 0, 0},
  1462. {0, 0, 0, 0, 0},
  1463. {0, 0, 0, 0, 0},
  1464. {0, 0, 0, 0, 0},
  1465. {0, 0, 0, 0, 0},
  1466. {0, 0, 0, 0, 0},
  1467. },
  1468. },
  1469. .calTarget_freqbin_5G = {
  1470. FREQ2FBIN(5180, 0),
  1471. FREQ2FBIN(5240, 0),
  1472. FREQ2FBIN(5320, 0),
  1473. FREQ2FBIN(5400, 0),
  1474. FREQ2FBIN(5500, 0),
  1475. FREQ2FBIN(5600, 0),
  1476. FREQ2FBIN(5700, 0),
  1477. FREQ2FBIN(5825, 0)
  1478. },
  1479. .calTarget_freqbin_5GHT20 = {
  1480. FREQ2FBIN(5180, 0),
  1481. FREQ2FBIN(5240, 0),
  1482. FREQ2FBIN(5320, 0),
  1483. FREQ2FBIN(5400, 0),
  1484. FREQ2FBIN(5500, 0),
  1485. FREQ2FBIN(5700, 0),
  1486. FREQ2FBIN(5745, 0),
  1487. FREQ2FBIN(5825, 0)
  1488. },
  1489. .calTarget_freqbin_5GHT40 = {
  1490. FREQ2FBIN(5180, 0),
  1491. FREQ2FBIN(5240, 0),
  1492. FREQ2FBIN(5320, 0),
  1493. FREQ2FBIN(5400, 0),
  1494. FREQ2FBIN(5500, 0),
  1495. FREQ2FBIN(5700, 0),
  1496. FREQ2FBIN(5745, 0),
  1497. FREQ2FBIN(5825, 0)
  1498. },
  1499. .calTargetPower5G = {
  1500. /* 6-24,36,48,54 */
  1501. { {30, 30, 28, 24} },
  1502. { {30, 30, 28, 24} },
  1503. { {30, 30, 28, 24} },
  1504. { {30, 30, 28, 24} },
  1505. { {30, 30, 28, 24} },
  1506. { {30, 30, 28, 24} },
  1507. { {30, 30, 28, 24} },
  1508. { {30, 30, 28, 24} },
  1509. },
  1510. .calTargetPower5GHT20 = {
  1511. /*
  1512. * 0_8_16,1-3_9-11_17-19,
  1513. * 4,5,6,7,12,13,14,15,20,21,22,23
  1514. */
  1515. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
  1516. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
  1517. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
  1518. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
  1519. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
  1520. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
  1521. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
  1522. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
  1523. },
  1524. .calTargetPower5GHT40 = {
  1525. /*
  1526. * 0_8_16,1-3_9-11_17-19,
  1527. * 4,5,6,7,12,13,14,15,20,21,22,23
  1528. */
  1529. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
  1530. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
  1531. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
  1532. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
  1533. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
  1534. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
  1535. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
  1536. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
  1537. },
  1538. .ctlIndex_5G = {
  1539. 0x10, 0x16, 0x18, 0x40, 0x46,
  1540. 0x48, 0x30, 0x36, 0x38
  1541. },
  1542. .ctl_freqbin_5G = {
  1543. {
  1544. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1545. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1546. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1547. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1548. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  1549. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1550. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1551. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1552. },
  1553. {
  1554. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1555. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1556. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1557. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1558. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  1559. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1560. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1561. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1562. },
  1563. {
  1564. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1565. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1566. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1567. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  1568. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  1569. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  1570. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  1571. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  1572. },
  1573. {
  1574. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1575. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1576. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  1577. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  1578. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1579. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1580. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  1581. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  1582. },
  1583. {
  1584. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1585. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1586. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  1587. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  1588. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  1589. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  1590. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  1591. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  1592. },
  1593. {
  1594. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1595. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  1596. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  1597. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1598. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  1599. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1600. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  1601. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  1602. },
  1603. {
  1604. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1605. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1606. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  1607. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  1608. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1609. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  1610. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  1611. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  1612. },
  1613. {
  1614. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1615. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1616. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  1617. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1618. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  1619. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1620. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1621. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1622. },
  1623. {
  1624. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1625. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1626. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1627. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1628. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  1629. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1630. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  1631. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  1632. }
  1633. },
  1634. .ctlPowerData_5G = {
  1635. {
  1636. {
  1637. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1638. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1639. }
  1640. },
  1641. {
  1642. {
  1643. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1644. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1645. }
  1646. },
  1647. {
  1648. {
  1649. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1650. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1651. }
  1652. },
  1653. {
  1654. {
  1655. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1656. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1657. }
  1658. },
  1659. {
  1660. {
  1661. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1662. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1663. }
  1664. },
  1665. {
  1666. {
  1667. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1668. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1669. }
  1670. },
  1671. {
  1672. {
  1673. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1674. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1675. }
  1676. },
  1677. {
  1678. {
  1679. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1680. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1681. }
  1682. },
  1683. {
  1684. {
  1685. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  1686. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1687. }
  1688. },
  1689. }
  1690. };
  1691. static const struct ar9300_eeprom ar9300_x112 = {
  1692. .eepromVersion = 2,
  1693. .templateVersion = 5,
  1694. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  1695. .custData = {"x112-041-f0000"},
  1696. .baseEepHeader = {
  1697. .regDmn = { LE16(0), LE16(0x1f) },
  1698. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  1699. .opCapFlags = {
  1700. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  1701. .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
  1702. },
  1703. .rfSilent = 0,
  1704. .blueToothOptions = 0,
  1705. .deviceCap = 0,
  1706. .deviceType = 5, /* takes lower byte in eeprom location */
  1707. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  1708. .params_for_tuning_caps = {0, 0},
  1709. .featureEnable = 0x0d,
  1710. /*
  1711. * bit0 - enable tx temp comp - disabled
  1712. * bit1 - enable tx volt comp - disabled
  1713. * bit2 - enable fastclock - enabled
  1714. * bit3 - enable doubling - enabled
  1715. * bit4 - enable internal regulator - disabled
  1716. * bit5 - enable pa predistortion - disabled
  1717. */
  1718. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  1719. .eepromWriteEnableGpio = 6,
  1720. .wlanDisableGpio = 0,
  1721. .wlanLedGpio = 8,
  1722. .rxBandSelectGpio = 0xff,
  1723. .txrxgain = 0x0,
  1724. .swreg = 0,
  1725. },
  1726. .modalHeader2G = {
  1727. /* ar9300_modal_eep_header 2g */
  1728. /* 4 idle,t1,t2,b(4 bits per setting) */
  1729. .antCtrlCommon = LE32(0x110),
  1730. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  1731. .antCtrlCommon2 = LE32(0x22222),
  1732. /*
  1733. * antCtrlChain[ar9300_max_chains]; 6 idle, t, r,
  1734. * rx1, rx12, b (2 bits each)
  1735. */
  1736. .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
  1737. /*
  1738. * xatten1DB[AR9300_max_chains]; 3 xatten1_db
  1739. * for ar9280 (0xa20c/b20c 5:0)
  1740. */
  1741. .xatten1DB = {0x1b, 0x1b, 0x1b},
  1742. /*
  1743. * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin
  1744. * for ar9280 (0xa20c/b20c 16:12
  1745. */
  1746. .xatten1Margin = {0x15, 0x15, 0x15},
  1747. .tempSlope = 50,
  1748. .voltSlope = 0,
  1749. /*
  1750. * spurChans[OSPrey_eeprom_modal_sPURS]; spur
  1751. * channels in usual fbin coding format
  1752. */
  1753. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  1754. /*
  1755. * noiseFloorThreshch[ar9300_max_cHAINS]; 3 Check
  1756. * if the register is per chain
  1757. */
  1758. .noiseFloorThreshCh = {-1, 0, 0},
  1759. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1760. .quick_drop = 0,
  1761. .xpaBiasLvl = 0,
  1762. .txFrameToDataStart = 0x0e,
  1763. .txFrameToPaOn = 0x0e,
  1764. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1765. .antennaGain = 0,
  1766. .switchSettling = 0x2c,
  1767. .adcDesiredSize = -30,
  1768. .txEndToXpaOff = 0,
  1769. .txEndToRxOn = 0x2,
  1770. .txFrameToXpaOn = 0xe,
  1771. .thresh62 = 28,
  1772. .papdRateMaskHt20 = LE32(0x0c80c080),
  1773. .papdRateMaskHt40 = LE32(0x0080c080),
  1774. .switchcomspdt = 0,
  1775. .xlna_bias_strength = 0,
  1776. .futureModal = {
  1777. 0, 0, 0, 0, 0, 0, 0,
  1778. },
  1779. },
  1780. .base_ext1 = {
  1781. .ant_div_control = 0,
  1782. .future = {0, 0},
  1783. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  1784. },
  1785. .calFreqPier2G = {
  1786. FREQ2FBIN(2412, 1),
  1787. FREQ2FBIN(2437, 1),
  1788. FREQ2FBIN(2472, 1),
  1789. },
  1790. /* ar9300_cal_data_per_freq_op_loop 2g */
  1791. .calPierData2G = {
  1792. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1793. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1794. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1795. },
  1796. .calTarget_freqbin_Cck = {
  1797. FREQ2FBIN(2412, 1),
  1798. FREQ2FBIN(2472, 1),
  1799. },
  1800. .calTarget_freqbin_2G = {
  1801. FREQ2FBIN(2412, 1),
  1802. FREQ2FBIN(2437, 1),
  1803. FREQ2FBIN(2472, 1)
  1804. },
  1805. .calTarget_freqbin_2GHT20 = {
  1806. FREQ2FBIN(2412, 1),
  1807. FREQ2FBIN(2437, 1),
  1808. FREQ2FBIN(2472, 1)
  1809. },
  1810. .calTarget_freqbin_2GHT40 = {
  1811. FREQ2FBIN(2412, 1),
  1812. FREQ2FBIN(2437, 1),
  1813. FREQ2FBIN(2472, 1)
  1814. },
  1815. .calTargetPowerCck = {
  1816. /* 1L-5L,5S,11L,11s */
  1817. { {38, 38, 38, 38} },
  1818. { {38, 38, 38, 38} },
  1819. },
  1820. .calTargetPower2G = {
  1821. /* 6-24,36,48,54 */
  1822. { {38, 38, 36, 34} },
  1823. { {38, 38, 36, 34} },
  1824. { {38, 38, 34, 32} },
  1825. },
  1826. .calTargetPower2GHT20 = {
  1827. { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
  1828. { {36, 36, 36, 36, 36, 34, 36, 34, 32, 30, 30, 30, 28, 26} },
  1829. { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
  1830. },
  1831. .calTargetPower2GHT40 = {
  1832. { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
  1833. { {36, 36, 36, 36, 34, 32, 34, 32, 30, 28, 28, 28, 28, 24} },
  1834. { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
  1835. },
  1836. .ctlIndex_2G = {
  1837. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  1838. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  1839. },
  1840. .ctl_freqbin_2G = {
  1841. {
  1842. FREQ2FBIN(2412, 1),
  1843. FREQ2FBIN(2417, 1),
  1844. FREQ2FBIN(2457, 1),
  1845. FREQ2FBIN(2462, 1)
  1846. },
  1847. {
  1848. FREQ2FBIN(2412, 1),
  1849. FREQ2FBIN(2417, 1),
  1850. FREQ2FBIN(2462, 1),
  1851. 0xFF,
  1852. },
  1853. {
  1854. FREQ2FBIN(2412, 1),
  1855. FREQ2FBIN(2417, 1),
  1856. FREQ2FBIN(2462, 1),
  1857. 0xFF,
  1858. },
  1859. {
  1860. FREQ2FBIN(2422, 1),
  1861. FREQ2FBIN(2427, 1),
  1862. FREQ2FBIN(2447, 1),
  1863. FREQ2FBIN(2452, 1)
  1864. },
  1865. {
  1866. /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1867. /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1868. /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1869. /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(2484, 1),
  1870. },
  1871. {
  1872. /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1873. /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1874. /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1875. 0,
  1876. },
  1877. {
  1878. /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1879. /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1880. FREQ2FBIN(2472, 1),
  1881. 0,
  1882. },
  1883. {
  1884. /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(2422, 1),
  1885. /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(2427, 1),
  1886. /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(2447, 1),
  1887. /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(2462, 1),
  1888. },
  1889. {
  1890. /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1891. /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1892. /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1893. },
  1894. {
  1895. /* Data[9].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1896. /* Data[9].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1897. /* Data[9].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1898. 0
  1899. },
  1900. {
  1901. /* Data[10].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1902. /* Data[10].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1903. /* Data[10].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1904. 0
  1905. },
  1906. {
  1907. /* Data[11].ctledges[0].bchannel */ FREQ2FBIN(2422, 1),
  1908. /* Data[11].ctledges[1].bchannel */ FREQ2FBIN(2427, 1),
  1909. /* Data[11].ctledges[2].bchannel */ FREQ2FBIN(2447, 1),
  1910. /* Data[11].ctledges[3].bchannel */ FREQ2FBIN(2462, 1),
  1911. }
  1912. },
  1913. .ctlPowerData_2G = {
  1914. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1915. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1916. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  1917. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  1918. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1919. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1920. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  1921. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1922. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1923. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1924. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1925. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1926. },
  1927. .modalHeader5G = {
  1928. /* 4 idle,t1,t2,b (4 bits per setting) */
  1929. .antCtrlCommon = LE32(0x110),
  1930. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  1931. .antCtrlCommon2 = LE32(0x22222),
  1932. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  1933. .antCtrlChain = {
  1934. LE16(0x0), LE16(0x0), LE16(0x0),
  1935. },
  1936. /* xatten1DB 3 xatten1_db for ar9280 (0xa20c/b20c 5:0) */
  1937. .xatten1DB = {0x13, 0x19, 0x17},
  1938. /*
  1939. * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin
  1940. * for merlin (0xa20c/b20c 16:12
  1941. */
  1942. .xatten1Margin = {0x19, 0x19, 0x19},
  1943. .tempSlope = 70,
  1944. .voltSlope = 15,
  1945. /* spurChans spur channels in usual fbin coding format */
  1946. .spurChans = {0, 0, 0, 0, 0},
  1947. /* noiseFloorThreshch check if the register is per chain */
  1948. .noiseFloorThreshCh = {-1, 0, 0},
  1949. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1950. .quick_drop = 0,
  1951. .xpaBiasLvl = 0,
  1952. .txFrameToDataStart = 0x0e,
  1953. .txFrameToPaOn = 0x0e,
  1954. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1955. .antennaGain = 0,
  1956. .switchSettling = 0x2d,
  1957. .adcDesiredSize = -30,
  1958. .txEndToXpaOff = 0,
  1959. .txEndToRxOn = 0x2,
  1960. .txFrameToXpaOn = 0xe,
  1961. .thresh62 = 28,
  1962. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  1963. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  1964. .switchcomspdt = 0,
  1965. .xlna_bias_strength = 0,
  1966. .futureModal = {
  1967. 0, 0, 0, 0, 0, 0, 0,
  1968. },
  1969. },
  1970. .base_ext2 = {
  1971. .tempSlopeLow = 72,
  1972. .tempSlopeHigh = 105,
  1973. .xatten1DBLow = {0x10, 0x14, 0x10},
  1974. .xatten1MarginLow = {0x19, 0x19 , 0x19},
  1975. .xatten1DBHigh = {0x1d, 0x20, 0x24},
  1976. .xatten1MarginHigh = {0x10, 0x10, 0x10}
  1977. },
  1978. .calFreqPier5G = {
  1979. FREQ2FBIN(5180, 0),
  1980. FREQ2FBIN(5220, 0),
  1981. FREQ2FBIN(5320, 0),
  1982. FREQ2FBIN(5400, 0),
  1983. FREQ2FBIN(5500, 0),
  1984. FREQ2FBIN(5600, 0),
  1985. FREQ2FBIN(5700, 0),
  1986. FREQ2FBIN(5785, 0)
  1987. },
  1988. .calPierData5G = {
  1989. {
  1990. {0, 0, 0, 0, 0},
  1991. {0, 0, 0, 0, 0},
  1992. {0, 0, 0, 0, 0},
  1993. {0, 0, 0, 0, 0},
  1994. {0, 0, 0, 0, 0},
  1995. {0, 0, 0, 0, 0},
  1996. {0, 0, 0, 0, 0},
  1997. {0, 0, 0, 0, 0},
  1998. },
  1999. {
  2000. {0, 0, 0, 0, 0},
  2001. {0, 0, 0, 0, 0},
  2002. {0, 0, 0, 0, 0},
  2003. {0, 0, 0, 0, 0},
  2004. {0, 0, 0, 0, 0},
  2005. {0, 0, 0, 0, 0},
  2006. {0, 0, 0, 0, 0},
  2007. {0, 0, 0, 0, 0},
  2008. },
  2009. {
  2010. {0, 0, 0, 0, 0},
  2011. {0, 0, 0, 0, 0},
  2012. {0, 0, 0, 0, 0},
  2013. {0, 0, 0, 0, 0},
  2014. {0, 0, 0, 0, 0},
  2015. {0, 0, 0, 0, 0},
  2016. {0, 0, 0, 0, 0},
  2017. {0, 0, 0, 0, 0},
  2018. },
  2019. },
  2020. .calTarget_freqbin_5G = {
  2021. FREQ2FBIN(5180, 0),
  2022. FREQ2FBIN(5220, 0),
  2023. FREQ2FBIN(5320, 0),
  2024. FREQ2FBIN(5400, 0),
  2025. FREQ2FBIN(5500, 0),
  2026. FREQ2FBIN(5600, 0),
  2027. FREQ2FBIN(5725, 0),
  2028. FREQ2FBIN(5825, 0)
  2029. },
  2030. .calTarget_freqbin_5GHT20 = {
  2031. FREQ2FBIN(5180, 0),
  2032. FREQ2FBIN(5220, 0),
  2033. FREQ2FBIN(5320, 0),
  2034. FREQ2FBIN(5400, 0),
  2035. FREQ2FBIN(5500, 0),
  2036. FREQ2FBIN(5600, 0),
  2037. FREQ2FBIN(5725, 0),
  2038. FREQ2FBIN(5825, 0)
  2039. },
  2040. .calTarget_freqbin_5GHT40 = {
  2041. FREQ2FBIN(5180, 0),
  2042. FREQ2FBIN(5220, 0),
  2043. FREQ2FBIN(5320, 0),
  2044. FREQ2FBIN(5400, 0),
  2045. FREQ2FBIN(5500, 0),
  2046. FREQ2FBIN(5600, 0),
  2047. FREQ2FBIN(5725, 0),
  2048. FREQ2FBIN(5825, 0)
  2049. },
  2050. .calTargetPower5G = {
  2051. /* 6-24,36,48,54 */
  2052. { {32, 32, 28, 26} },
  2053. { {32, 32, 28, 26} },
  2054. { {32, 32, 28, 26} },
  2055. { {32, 32, 26, 24} },
  2056. { {32, 32, 26, 24} },
  2057. { {32, 32, 24, 22} },
  2058. { {30, 30, 24, 22} },
  2059. { {30, 30, 24, 22} },
  2060. },
  2061. .calTargetPower5GHT20 = {
  2062. /*
  2063. * 0_8_16,1-3_9-11_17-19,
  2064. * 4,5,6,7,12,13,14,15,20,21,22,23
  2065. */
  2066. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2067. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2068. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2069. { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 22, 22, 20, 20} },
  2070. { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 20, 18, 16, 16} },
  2071. { {32, 32, 32, 32, 28, 26, 32, 24, 20, 16, 18, 16, 14, 14} },
  2072. { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
  2073. { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
  2074. },
  2075. .calTargetPower5GHT40 = {
  2076. /*
  2077. * 0_8_16,1-3_9-11_17-19,
  2078. * 4,5,6,7,12,13,14,15,20,21,22,23
  2079. */
  2080. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2081. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2082. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2083. { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 22, 22, 20, 20} },
  2084. { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 20, 18, 16, 16} },
  2085. { {32, 32, 32, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2086. { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2087. { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2088. },
  2089. .ctlIndex_5G = {
  2090. 0x10, 0x16, 0x18, 0x40, 0x46,
  2091. 0x48, 0x30, 0x36, 0x38
  2092. },
  2093. .ctl_freqbin_5G = {
  2094. {
  2095. /* Data[0].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2096. /* Data[0].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2097. /* Data[0].ctledges[2].bchannel */ FREQ2FBIN(5280, 0),
  2098. /* Data[0].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2099. /* Data[0].ctledges[4].bchannel */ FREQ2FBIN(5600, 0),
  2100. /* Data[0].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2101. /* Data[0].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2102. /* Data[0].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2103. },
  2104. {
  2105. /* Data[1].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2106. /* Data[1].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2107. /* Data[1].ctledges[2].bchannel */ FREQ2FBIN(5280, 0),
  2108. /* Data[1].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2109. /* Data[1].ctledges[4].bchannel */ FREQ2FBIN(5520, 0),
  2110. /* Data[1].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2111. /* Data[1].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2112. /* Data[1].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2113. },
  2114. {
  2115. /* Data[2].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2116. /* Data[2].ctledges[1].bchannel */ FREQ2FBIN(5230, 0),
  2117. /* Data[2].ctledges[2].bchannel */ FREQ2FBIN(5270, 0),
  2118. /* Data[2].ctledges[3].bchannel */ FREQ2FBIN(5310, 0),
  2119. /* Data[2].ctledges[4].bchannel */ FREQ2FBIN(5510, 0),
  2120. /* Data[2].ctledges[5].bchannel */ FREQ2FBIN(5550, 0),
  2121. /* Data[2].ctledges[6].bchannel */ FREQ2FBIN(5670, 0),
  2122. /* Data[2].ctledges[7].bchannel */ FREQ2FBIN(5755, 0)
  2123. },
  2124. {
  2125. /* Data[3].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2126. /* Data[3].ctledges[1].bchannel */ FREQ2FBIN(5200, 0),
  2127. /* Data[3].ctledges[2].bchannel */ FREQ2FBIN(5260, 0),
  2128. /* Data[3].ctledges[3].bchannel */ FREQ2FBIN(5320, 0),
  2129. /* Data[3].ctledges[4].bchannel */ FREQ2FBIN(5500, 0),
  2130. /* Data[3].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2131. /* Data[3].ctledges[6].bchannel */ 0xFF,
  2132. /* Data[3].ctledges[7].bchannel */ 0xFF,
  2133. },
  2134. {
  2135. /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2136. /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2137. /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(5500, 0),
  2138. /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(5700, 0),
  2139. /* Data[4].ctledges[4].bchannel */ 0xFF,
  2140. /* Data[4].ctledges[5].bchannel */ 0xFF,
  2141. /* Data[4].ctledges[6].bchannel */ 0xFF,
  2142. /* Data[4].ctledges[7].bchannel */ 0xFF,
  2143. },
  2144. {
  2145. /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2146. /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(5270, 0),
  2147. /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(5310, 0),
  2148. /* Data[5].ctledges[3].bchannel */ FREQ2FBIN(5510, 0),
  2149. /* Data[5].ctledges[4].bchannel */ FREQ2FBIN(5590, 0),
  2150. /* Data[5].ctledges[5].bchannel */ FREQ2FBIN(5670, 0),
  2151. /* Data[5].ctledges[6].bchannel */ 0xFF,
  2152. /* Data[5].ctledges[7].bchannel */ 0xFF
  2153. },
  2154. {
  2155. /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2156. /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(5200, 0),
  2157. /* Data[6].ctledges[2].bchannel */ FREQ2FBIN(5220, 0),
  2158. /* Data[6].ctledges[3].bchannel */ FREQ2FBIN(5260, 0),
  2159. /* Data[6].ctledges[4].bchannel */ FREQ2FBIN(5500, 0),
  2160. /* Data[6].ctledges[5].bchannel */ FREQ2FBIN(5600, 0),
  2161. /* Data[6].ctledges[6].bchannel */ FREQ2FBIN(5700, 0),
  2162. /* Data[6].ctledges[7].bchannel */ FREQ2FBIN(5745, 0)
  2163. },
  2164. {
  2165. /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2166. /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2167. /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(5320, 0),
  2168. /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2169. /* Data[7].ctledges[4].bchannel */ FREQ2FBIN(5560, 0),
  2170. /* Data[7].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2171. /* Data[7].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2172. /* Data[7].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2173. },
  2174. {
  2175. /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2176. /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(5230, 0),
  2177. /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(5270, 0),
  2178. /* Data[8].ctledges[3].bchannel */ FREQ2FBIN(5510, 0),
  2179. /* Data[8].ctledges[4].bchannel */ FREQ2FBIN(5550, 0),
  2180. /* Data[8].ctledges[5].bchannel */ FREQ2FBIN(5670, 0),
  2181. /* Data[8].ctledges[6].bchannel */ FREQ2FBIN(5755, 0),
  2182. /* Data[8].ctledges[7].bchannel */ FREQ2FBIN(5795, 0)
  2183. }
  2184. },
  2185. .ctlPowerData_5G = {
  2186. {
  2187. {
  2188. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2189. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2190. }
  2191. },
  2192. {
  2193. {
  2194. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2195. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2196. }
  2197. },
  2198. {
  2199. {
  2200. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2201. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2202. }
  2203. },
  2204. {
  2205. {
  2206. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2207. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2208. }
  2209. },
  2210. {
  2211. {
  2212. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2213. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2214. }
  2215. },
  2216. {
  2217. {
  2218. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2219. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2220. }
  2221. },
  2222. {
  2223. {
  2224. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2225. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2226. }
  2227. },
  2228. {
  2229. {
  2230. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2231. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2232. }
  2233. },
  2234. {
  2235. {
  2236. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  2237. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2238. }
  2239. },
  2240. }
  2241. };
  2242. static const struct ar9300_eeprom ar9300_h116 = {
  2243. .eepromVersion = 2,
  2244. .templateVersion = 4,
  2245. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  2246. .custData = {"h116-041-f0000"},
  2247. .baseEepHeader = {
  2248. .regDmn = { LE16(0), LE16(0x1f) },
  2249. .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */
  2250. .opCapFlags = {
  2251. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  2252. .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
  2253. },
  2254. .rfSilent = 0,
  2255. .blueToothOptions = 0,
  2256. .deviceCap = 0,
  2257. .deviceType = 5, /* takes lower byte in eeprom location */
  2258. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  2259. .params_for_tuning_caps = {0, 0},
  2260. .featureEnable = 0x0d,
  2261. /*
  2262. * bit0 - enable tx temp comp - disabled
  2263. * bit1 - enable tx volt comp - disabled
  2264. * bit2 - enable fastClock - enabled
  2265. * bit3 - enable doubling - enabled
  2266. * bit4 - enable internal regulator - disabled
  2267. * bit5 - enable pa predistortion - disabled
  2268. */
  2269. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  2270. .eepromWriteEnableGpio = 6,
  2271. .wlanDisableGpio = 0,
  2272. .wlanLedGpio = 8,
  2273. .rxBandSelectGpio = 0xff,
  2274. .txrxgain = 0x10,
  2275. .swreg = 0,
  2276. },
  2277. .modalHeader2G = {
  2278. /* ar9300_modal_eep_header 2g */
  2279. /* 4 idle,t1,t2,b(4 bits per setting) */
  2280. .antCtrlCommon = LE32(0x110),
  2281. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  2282. .antCtrlCommon2 = LE32(0x44444),
  2283. /*
  2284. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  2285. * rx1, rx12, b (2 bits each)
  2286. */
  2287. .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
  2288. /*
  2289. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  2290. * for ar9280 (0xa20c/b20c 5:0)
  2291. */
  2292. .xatten1DB = {0x1f, 0x1f, 0x1f},
  2293. /*
  2294. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  2295. * for ar9280 (0xa20c/b20c 16:12
  2296. */
  2297. .xatten1Margin = {0x12, 0x12, 0x12},
  2298. .tempSlope = 25,
  2299. .voltSlope = 0,
  2300. /*
  2301. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  2302. * channels in usual fbin coding format
  2303. */
  2304. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  2305. /*
  2306. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  2307. * if the register is per chain
  2308. */
  2309. .noiseFloorThreshCh = {-1, 0, 0},
  2310. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2311. .quick_drop = 0,
  2312. .xpaBiasLvl = 0,
  2313. .txFrameToDataStart = 0x0e,
  2314. .txFrameToPaOn = 0x0e,
  2315. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  2316. .antennaGain = 0,
  2317. .switchSettling = 0x2c,
  2318. .adcDesiredSize = -30,
  2319. .txEndToXpaOff = 0,
  2320. .txEndToRxOn = 0x2,
  2321. .txFrameToXpaOn = 0xe,
  2322. .thresh62 = 28,
  2323. .papdRateMaskHt20 = LE32(0x0c80C080),
  2324. .papdRateMaskHt40 = LE32(0x0080C080),
  2325. .switchcomspdt = 0,
  2326. .xlna_bias_strength = 0,
  2327. .futureModal = {
  2328. 0, 0, 0, 0, 0, 0, 0,
  2329. },
  2330. },
  2331. .base_ext1 = {
  2332. .ant_div_control = 0,
  2333. .future = {0, 0},
  2334. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  2335. },
  2336. .calFreqPier2G = {
  2337. FREQ2FBIN(2412, 1),
  2338. FREQ2FBIN(2437, 1),
  2339. FREQ2FBIN(2462, 1),
  2340. },
  2341. /* ar9300_cal_data_per_freq_op_loop 2g */
  2342. .calPierData2G = {
  2343. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2344. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2345. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2346. },
  2347. .calTarget_freqbin_Cck = {
  2348. FREQ2FBIN(2412, 1),
  2349. FREQ2FBIN(2472, 1),
  2350. },
  2351. .calTarget_freqbin_2G = {
  2352. FREQ2FBIN(2412, 1),
  2353. FREQ2FBIN(2437, 1),
  2354. FREQ2FBIN(2472, 1)
  2355. },
  2356. .calTarget_freqbin_2GHT20 = {
  2357. FREQ2FBIN(2412, 1),
  2358. FREQ2FBIN(2437, 1),
  2359. FREQ2FBIN(2472, 1)
  2360. },
  2361. .calTarget_freqbin_2GHT40 = {
  2362. FREQ2FBIN(2412, 1),
  2363. FREQ2FBIN(2437, 1),
  2364. FREQ2FBIN(2472, 1)
  2365. },
  2366. .calTargetPowerCck = {
  2367. /* 1L-5L,5S,11L,11S */
  2368. { {34, 34, 34, 34} },
  2369. { {34, 34, 34, 34} },
  2370. },
  2371. .calTargetPower2G = {
  2372. /* 6-24,36,48,54 */
  2373. { {34, 34, 32, 32} },
  2374. { {34, 34, 32, 32} },
  2375. { {34, 34, 32, 32} },
  2376. },
  2377. .calTargetPower2GHT20 = {
  2378. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2379. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2380. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2381. },
  2382. .calTargetPower2GHT40 = {
  2383. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2384. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2385. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2386. },
  2387. .ctlIndex_2G = {
  2388. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  2389. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  2390. },
  2391. .ctl_freqbin_2G = {
  2392. {
  2393. FREQ2FBIN(2412, 1),
  2394. FREQ2FBIN(2417, 1),
  2395. FREQ2FBIN(2457, 1),
  2396. FREQ2FBIN(2462, 1)
  2397. },
  2398. {
  2399. FREQ2FBIN(2412, 1),
  2400. FREQ2FBIN(2417, 1),
  2401. FREQ2FBIN(2462, 1),
  2402. 0xFF,
  2403. },
  2404. {
  2405. FREQ2FBIN(2412, 1),
  2406. FREQ2FBIN(2417, 1),
  2407. FREQ2FBIN(2462, 1),
  2408. 0xFF,
  2409. },
  2410. {
  2411. FREQ2FBIN(2422, 1),
  2412. FREQ2FBIN(2427, 1),
  2413. FREQ2FBIN(2447, 1),
  2414. FREQ2FBIN(2452, 1)
  2415. },
  2416. {
  2417. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2418. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2419. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2420. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  2421. },
  2422. {
  2423. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2424. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2425. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2426. 0,
  2427. },
  2428. {
  2429. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2430. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2431. FREQ2FBIN(2472, 1),
  2432. 0,
  2433. },
  2434. {
  2435. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  2436. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  2437. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  2438. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  2439. },
  2440. {
  2441. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2442. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2443. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2444. },
  2445. {
  2446. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2447. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2448. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2449. 0
  2450. },
  2451. {
  2452. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2453. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2454. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2455. 0
  2456. },
  2457. {
  2458. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  2459. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  2460. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  2461. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  2462. }
  2463. },
  2464. .ctlPowerData_2G = {
  2465. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2466. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2467. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  2468. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  2469. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2470. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2471. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  2472. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2473. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2474. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2475. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  2476. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  2477. },
  2478. .modalHeader5G = {
  2479. /* 4 idle,t1,t2,b (4 bits per setting) */
  2480. .antCtrlCommon = LE32(0x220),
  2481. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  2482. .antCtrlCommon2 = LE32(0x44444),
  2483. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  2484. .antCtrlChain = {
  2485. LE16(0x150), LE16(0x150), LE16(0x150),
  2486. },
  2487. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  2488. .xatten1DB = {0x19, 0x19, 0x19},
  2489. /*
  2490. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  2491. * for merlin (0xa20c/b20c 16:12
  2492. */
  2493. .xatten1Margin = {0x14, 0x14, 0x14},
  2494. .tempSlope = 70,
  2495. .voltSlope = 0,
  2496. /* spurChans spur channels in usual fbin coding format */
  2497. .spurChans = {0, 0, 0, 0, 0},
  2498. /* noiseFloorThreshCh Check if the register is per chain */
  2499. .noiseFloorThreshCh = {-1, 0, 0},
  2500. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2501. .quick_drop = 0,
  2502. .xpaBiasLvl = 0,
  2503. .txFrameToDataStart = 0x0e,
  2504. .txFrameToPaOn = 0x0e,
  2505. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  2506. .antennaGain = 0,
  2507. .switchSettling = 0x2d,
  2508. .adcDesiredSize = -30,
  2509. .txEndToXpaOff = 0,
  2510. .txEndToRxOn = 0x2,
  2511. .txFrameToXpaOn = 0xe,
  2512. .thresh62 = 28,
  2513. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  2514. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  2515. .switchcomspdt = 0,
  2516. .xlna_bias_strength = 0,
  2517. .futureModal = {
  2518. 0, 0, 0, 0, 0, 0, 0,
  2519. },
  2520. },
  2521. .base_ext2 = {
  2522. .tempSlopeLow = 35,
  2523. .tempSlopeHigh = 50,
  2524. .xatten1DBLow = {0, 0, 0},
  2525. .xatten1MarginLow = {0, 0, 0},
  2526. .xatten1DBHigh = {0, 0, 0},
  2527. .xatten1MarginHigh = {0, 0, 0}
  2528. },
  2529. .calFreqPier5G = {
  2530. FREQ2FBIN(5160, 0),
  2531. FREQ2FBIN(5220, 0),
  2532. FREQ2FBIN(5320, 0),
  2533. FREQ2FBIN(5400, 0),
  2534. FREQ2FBIN(5500, 0),
  2535. FREQ2FBIN(5600, 0),
  2536. FREQ2FBIN(5700, 0),
  2537. FREQ2FBIN(5785, 0)
  2538. },
  2539. .calPierData5G = {
  2540. {
  2541. {0, 0, 0, 0, 0},
  2542. {0, 0, 0, 0, 0},
  2543. {0, 0, 0, 0, 0},
  2544. {0, 0, 0, 0, 0},
  2545. {0, 0, 0, 0, 0},
  2546. {0, 0, 0, 0, 0},
  2547. {0, 0, 0, 0, 0},
  2548. {0, 0, 0, 0, 0},
  2549. },
  2550. {
  2551. {0, 0, 0, 0, 0},
  2552. {0, 0, 0, 0, 0},
  2553. {0, 0, 0, 0, 0},
  2554. {0, 0, 0, 0, 0},
  2555. {0, 0, 0, 0, 0},
  2556. {0, 0, 0, 0, 0},
  2557. {0, 0, 0, 0, 0},
  2558. {0, 0, 0, 0, 0},
  2559. },
  2560. {
  2561. {0, 0, 0, 0, 0},
  2562. {0, 0, 0, 0, 0},
  2563. {0, 0, 0, 0, 0},
  2564. {0, 0, 0, 0, 0},
  2565. {0, 0, 0, 0, 0},
  2566. {0, 0, 0, 0, 0},
  2567. {0, 0, 0, 0, 0},
  2568. {0, 0, 0, 0, 0},
  2569. },
  2570. },
  2571. .calTarget_freqbin_5G = {
  2572. FREQ2FBIN(5180, 0),
  2573. FREQ2FBIN(5240, 0),
  2574. FREQ2FBIN(5320, 0),
  2575. FREQ2FBIN(5400, 0),
  2576. FREQ2FBIN(5500, 0),
  2577. FREQ2FBIN(5600, 0),
  2578. FREQ2FBIN(5700, 0),
  2579. FREQ2FBIN(5825, 0)
  2580. },
  2581. .calTarget_freqbin_5GHT20 = {
  2582. FREQ2FBIN(5180, 0),
  2583. FREQ2FBIN(5240, 0),
  2584. FREQ2FBIN(5320, 0),
  2585. FREQ2FBIN(5400, 0),
  2586. FREQ2FBIN(5500, 0),
  2587. FREQ2FBIN(5700, 0),
  2588. FREQ2FBIN(5745, 0),
  2589. FREQ2FBIN(5825, 0)
  2590. },
  2591. .calTarget_freqbin_5GHT40 = {
  2592. FREQ2FBIN(5180, 0),
  2593. FREQ2FBIN(5240, 0),
  2594. FREQ2FBIN(5320, 0),
  2595. FREQ2FBIN(5400, 0),
  2596. FREQ2FBIN(5500, 0),
  2597. FREQ2FBIN(5700, 0),
  2598. FREQ2FBIN(5745, 0),
  2599. FREQ2FBIN(5825, 0)
  2600. },
  2601. .calTargetPower5G = {
  2602. /* 6-24,36,48,54 */
  2603. { {30, 30, 28, 24} },
  2604. { {30, 30, 28, 24} },
  2605. { {30, 30, 28, 24} },
  2606. { {30, 30, 28, 24} },
  2607. { {30, 30, 28, 24} },
  2608. { {30, 30, 28, 24} },
  2609. { {30, 30, 28, 24} },
  2610. { {30, 30, 28, 24} },
  2611. },
  2612. .calTargetPower5GHT20 = {
  2613. /*
  2614. * 0_8_16,1-3_9-11_17-19,
  2615. * 4,5,6,7,12,13,14,15,20,21,22,23
  2616. */
  2617. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
  2618. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
  2619. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
  2620. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
  2621. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
  2622. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
  2623. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
  2624. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
  2625. },
  2626. .calTargetPower5GHT40 = {
  2627. /*
  2628. * 0_8_16,1-3_9-11_17-19,
  2629. * 4,5,6,7,12,13,14,15,20,21,22,23
  2630. */
  2631. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
  2632. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
  2633. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
  2634. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
  2635. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
  2636. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
  2637. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
  2638. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
  2639. },
  2640. .ctlIndex_5G = {
  2641. 0x10, 0x16, 0x18, 0x40, 0x46,
  2642. 0x48, 0x30, 0x36, 0x38
  2643. },
  2644. .ctl_freqbin_5G = {
  2645. {
  2646. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2647. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2648. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  2649. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2650. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  2651. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2652. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2653. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2654. },
  2655. {
  2656. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2657. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2658. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  2659. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2660. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  2661. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2662. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2663. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2664. },
  2665. {
  2666. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2667. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  2668. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  2669. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  2670. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  2671. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  2672. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  2673. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  2674. },
  2675. {
  2676. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2677. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  2678. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  2679. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  2680. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  2681. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2682. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  2683. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  2684. },
  2685. {
  2686. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2687. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2688. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  2689. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  2690. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  2691. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  2692. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  2693. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  2694. },
  2695. {
  2696. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2697. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  2698. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  2699. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  2700. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  2701. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  2702. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  2703. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  2704. },
  2705. {
  2706. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2707. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  2708. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  2709. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  2710. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  2711. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  2712. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  2713. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  2714. },
  2715. {
  2716. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2717. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2718. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  2719. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2720. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  2721. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2722. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2723. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2724. },
  2725. {
  2726. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2727. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  2728. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  2729. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  2730. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  2731. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  2732. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  2733. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  2734. }
  2735. },
  2736. .ctlPowerData_5G = {
  2737. {
  2738. {
  2739. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2740. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2741. }
  2742. },
  2743. {
  2744. {
  2745. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2746. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2747. }
  2748. },
  2749. {
  2750. {
  2751. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2752. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2753. }
  2754. },
  2755. {
  2756. {
  2757. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2758. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2759. }
  2760. },
  2761. {
  2762. {
  2763. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2764. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2765. }
  2766. },
  2767. {
  2768. {
  2769. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2770. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2771. }
  2772. },
  2773. {
  2774. {
  2775. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2776. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2777. }
  2778. },
  2779. {
  2780. {
  2781. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2782. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2783. }
  2784. },
  2785. {
  2786. {
  2787. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  2788. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2789. }
  2790. },
  2791. }
  2792. };
  2793. static const struct ar9300_eeprom *ar9300_eep_templates[] = {
  2794. &ar9300_default,
  2795. &ar9300_x112,
  2796. &ar9300_h116,
  2797. &ar9300_h112,
  2798. &ar9300_x113,
  2799. };
  2800. static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(int id)
  2801. {
  2802. int it;
  2803. for (it = 0; it < ARRAY_SIZE(ar9300_eep_templates); it++)
  2804. if (ar9300_eep_templates[it]->templateVersion == id)
  2805. return ar9300_eep_templates[it];
  2806. return NULL;
  2807. }
  2808. static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah)
  2809. {
  2810. return 0;
  2811. }
  2812. static int interpolate(int x, int xa, int xb, int ya, int yb)
  2813. {
  2814. int bf, factor, plus;
  2815. bf = 2 * (yb - ya) * (x - xa) / (xb - xa);
  2816. factor = bf / 2;
  2817. plus = bf % 2;
  2818. return ya + factor + plus;
  2819. }
  2820. static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
  2821. enum eeprom_param param)
  2822. {
  2823. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  2824. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  2825. switch (param) {
  2826. case EEP_MAC_LSW:
  2827. return get_unaligned_be16(eep->macAddr);
  2828. case EEP_MAC_MID:
  2829. return get_unaligned_be16(eep->macAddr + 2);
  2830. case EEP_MAC_MSW:
  2831. return get_unaligned_be16(eep->macAddr + 4);
  2832. case EEP_REG_0:
  2833. return le16_to_cpu(pBase->regDmn[0]);
  2834. case EEP_OP_CAP:
  2835. return pBase->deviceCap;
  2836. case EEP_OP_MODE:
  2837. return pBase->opCapFlags.opFlags;
  2838. case EEP_RF_SILENT:
  2839. return pBase->rfSilent;
  2840. case EEP_TX_MASK:
  2841. return (pBase->txrxMask >> 4) & 0xf;
  2842. case EEP_RX_MASK:
  2843. return pBase->txrxMask & 0xf;
  2844. case EEP_PAPRD:
  2845. return !!(pBase->featureEnable & BIT(5));
  2846. case EEP_CHAIN_MASK_REDUCE:
  2847. return (pBase->miscConfiguration >> 0x3) & 0x1;
  2848. case EEP_ANT_DIV_CTL1:
  2849. if (AR_SREV_9565(ah))
  2850. return AR9300_EEP_ANTDIV_CONTROL_DEFAULT_VALUE;
  2851. else
  2852. return eep->base_ext1.ant_div_control;
  2853. case EEP_ANTENNA_GAIN_5G:
  2854. return eep->modalHeader5G.antennaGain;
  2855. case EEP_ANTENNA_GAIN_2G:
  2856. return eep->modalHeader2G.antennaGain;
  2857. default:
  2858. return 0;
  2859. }
  2860. }
  2861. static bool ar9300_eeprom_read_byte(struct ath_hw *ah, int address,
  2862. u8 *buffer)
  2863. {
  2864. u16 val;
  2865. if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
  2866. return false;
  2867. *buffer = (val >> (8 * (address % 2))) & 0xff;
  2868. return true;
  2869. }
  2870. static bool ar9300_eeprom_read_word(struct ath_hw *ah, int address,
  2871. u8 *buffer)
  2872. {
  2873. u16 val;
  2874. if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
  2875. return false;
  2876. buffer[0] = val >> 8;
  2877. buffer[1] = val & 0xff;
  2878. return true;
  2879. }
  2880. static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
  2881. int count)
  2882. {
  2883. struct ath_common *common = ath9k_hw_common(ah);
  2884. int i;
  2885. if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
  2886. ath_dbg(common, EEPROM, "eeprom address not in range\n");
  2887. return false;
  2888. }
  2889. /*
  2890. * Since we're reading the bytes in reverse order from a little-endian
  2891. * word stream, an even address means we only use the lower half of
  2892. * the 16-bit word at that address
  2893. */
  2894. if (address % 2 == 0) {
  2895. if (!ar9300_eeprom_read_byte(ah, address--, buffer++))
  2896. goto error;
  2897. count--;
  2898. }
  2899. for (i = 0; i < count / 2; i++) {
  2900. if (!ar9300_eeprom_read_word(ah, address, buffer))
  2901. goto error;
  2902. address -= 2;
  2903. buffer += 2;
  2904. }
  2905. if (count % 2)
  2906. if (!ar9300_eeprom_read_byte(ah, address, buffer))
  2907. goto error;
  2908. return true;
  2909. error:
  2910. ath_dbg(common, EEPROM, "unable to read eeprom region at offset %d\n",
  2911. address);
  2912. return false;
  2913. }
  2914. static bool ar9300_otp_read_word(struct ath_hw *ah, int addr, u32 *data)
  2915. {
  2916. REG_READ(ah, AR9300_OTP_BASE + (4 * addr));
  2917. if (!ath9k_hw_wait(ah, AR9300_OTP_STATUS, AR9300_OTP_STATUS_TYPE,
  2918. AR9300_OTP_STATUS_VALID, 1000))
  2919. return false;
  2920. *data = REG_READ(ah, AR9300_OTP_READ_DATA);
  2921. return true;
  2922. }
  2923. static bool ar9300_read_otp(struct ath_hw *ah, int address, u8 *buffer,
  2924. int count)
  2925. {
  2926. u32 data;
  2927. int i;
  2928. for (i = 0; i < count; i++) {
  2929. int offset = 8 * ((address - i) % 4);
  2930. if (!ar9300_otp_read_word(ah, (address - i) / 4, &data))
  2931. return false;
  2932. buffer[i] = (data >> offset) & 0xff;
  2933. }
  2934. return true;
  2935. }
  2936. static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
  2937. int *length, int *major, int *minor)
  2938. {
  2939. unsigned long value[4];
  2940. value[0] = best[0];
  2941. value[1] = best[1];
  2942. value[2] = best[2];
  2943. value[3] = best[3];
  2944. *code = ((value[0] >> 5) & 0x0007);
  2945. *reference = (value[0] & 0x001f) | ((value[1] >> 2) & 0x0020);
  2946. *length = ((value[1] << 4) & 0x07f0) | ((value[2] >> 4) & 0x000f);
  2947. *major = (value[2] & 0x000f);
  2948. *minor = (value[3] & 0x00ff);
  2949. }
  2950. static u16 ar9300_comp_cksum(u8 *data, int dsize)
  2951. {
  2952. int it, checksum = 0;
  2953. for (it = 0; it < dsize; it++) {
  2954. checksum += data[it];
  2955. checksum &= 0xffff;
  2956. }
  2957. return checksum;
  2958. }
  2959. static bool ar9300_uncompress_block(struct ath_hw *ah,
  2960. u8 *mptr,
  2961. int mdataSize,
  2962. u8 *block,
  2963. int size)
  2964. {
  2965. int it;
  2966. int spot;
  2967. int offset;
  2968. int length;
  2969. struct ath_common *common = ath9k_hw_common(ah);
  2970. spot = 0;
  2971. for (it = 0; it < size; it += (length+2)) {
  2972. offset = block[it];
  2973. offset &= 0xff;
  2974. spot += offset;
  2975. length = block[it+1];
  2976. length &= 0xff;
  2977. if (length > 0 && spot >= 0 && spot+length <= mdataSize) {
  2978. ath_dbg(common, EEPROM,
  2979. "Restore at %d: spot=%d offset=%d length=%d\n",
  2980. it, spot, offset, length);
  2981. memcpy(&mptr[spot], &block[it+2], length);
  2982. spot += length;
  2983. } else if (length > 0) {
  2984. ath_dbg(common, EEPROM,
  2985. "Bad restore at %d: spot=%d offset=%d length=%d\n",
  2986. it, spot, offset, length);
  2987. return false;
  2988. }
  2989. }
  2990. return true;
  2991. }
  2992. static int ar9300_compress_decision(struct ath_hw *ah,
  2993. int it,
  2994. int code,
  2995. int reference,
  2996. u8 *mptr,
  2997. u8 *word, int length, int mdata_size)
  2998. {
  2999. struct ath_common *common = ath9k_hw_common(ah);
  3000. const struct ar9300_eeprom *eep = NULL;
  3001. switch (code) {
  3002. case _CompressNone:
  3003. if (length != mdata_size) {
  3004. ath_dbg(common, EEPROM,
  3005. "EEPROM structure size mismatch memory=%d eeprom=%d\n",
  3006. mdata_size, length);
  3007. return -1;
  3008. }
  3009. memcpy(mptr, word + COMP_HDR_LEN, length);
  3010. ath_dbg(common, EEPROM,
  3011. "restored eeprom %d: uncompressed, length %d\n",
  3012. it, length);
  3013. break;
  3014. case _CompressBlock:
  3015. if (reference != 0) {
  3016. eep = ar9003_eeprom_struct_find_by_id(reference);
  3017. if (eep == NULL) {
  3018. ath_dbg(common, EEPROM,
  3019. "can't find reference eeprom struct %d\n",
  3020. reference);
  3021. return -1;
  3022. }
  3023. memcpy(mptr, eep, mdata_size);
  3024. }
  3025. ath_dbg(common, EEPROM,
  3026. "restore eeprom %d: block, reference %d, length %d\n",
  3027. it, reference, length);
  3028. ar9300_uncompress_block(ah, mptr, mdata_size,
  3029. (word + COMP_HDR_LEN), length);
  3030. break;
  3031. default:
  3032. ath_dbg(common, EEPROM, "unknown compression code %d\n", code);
  3033. return -1;
  3034. }
  3035. return 0;
  3036. }
  3037. typedef bool (*eeprom_read_op)(struct ath_hw *ah, int address, u8 *buffer,
  3038. int count);
  3039. static bool ar9300_check_header(void *data)
  3040. {
  3041. u32 *word = data;
  3042. return !(*word == 0 || *word == ~0);
  3043. }
  3044. static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read,
  3045. int base_addr)
  3046. {
  3047. u8 header[4];
  3048. if (!read(ah, base_addr, header, 4))
  3049. return false;
  3050. return ar9300_check_header(header);
  3051. }
  3052. static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
  3053. int mdata_size)
  3054. {
  3055. u16 *data = (u16 *) mptr;
  3056. int i;
  3057. for (i = 0; i < mdata_size / 2; i++, data++)
  3058. if (!ath9k_hw_nvram_read(ah, i, data))
  3059. return -EIO;
  3060. return 0;
  3061. }
  3062. /*
  3063. * Read the configuration data from the eeprom.
  3064. * The data can be put in any specified memory buffer.
  3065. *
  3066. * Returns -1 on error.
  3067. * Returns address of next memory location on success.
  3068. */
  3069. static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
  3070. u8 *mptr, int mdata_size)
  3071. {
  3072. #define MDEFAULT 15
  3073. #define MSTATE 100
  3074. int cptr;
  3075. u8 *word;
  3076. int code;
  3077. int reference, length, major, minor;
  3078. int osize;
  3079. int it;
  3080. u16 checksum, mchecksum;
  3081. struct ath_common *common = ath9k_hw_common(ah);
  3082. struct ar9300_eeprom *eep;
  3083. eeprom_read_op read;
  3084. if (ath9k_hw_use_flash(ah)) {
  3085. u8 txrx;
  3086. if (ar9300_eeprom_restore_flash(ah, mptr, mdata_size))
  3087. return -EIO;
  3088. /* check if eeprom contains valid data */
  3089. eep = (struct ar9300_eeprom *) mptr;
  3090. txrx = eep->baseEepHeader.txrxMask;
  3091. if (txrx != 0 && txrx != 0xff)
  3092. return 0;
  3093. }
  3094. word = kzalloc(2048, GFP_KERNEL);
  3095. if (!word)
  3096. return -ENOMEM;
  3097. memcpy(mptr, &ar9300_default, mdata_size);
  3098. read = ar9300_read_eeprom;
  3099. if (AR_SREV_9485(ah))
  3100. cptr = AR9300_BASE_ADDR_4K;
  3101. else if (AR_SREV_9330(ah))
  3102. cptr = AR9300_BASE_ADDR_512;
  3103. else
  3104. cptr = AR9300_BASE_ADDR;
  3105. ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
  3106. cptr);
  3107. if (ar9300_check_eeprom_header(ah, read, cptr))
  3108. goto found;
  3109. cptr = AR9300_BASE_ADDR_4K;
  3110. ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
  3111. cptr);
  3112. if (ar9300_check_eeprom_header(ah, read, cptr))
  3113. goto found;
  3114. cptr = AR9300_BASE_ADDR_512;
  3115. ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
  3116. cptr);
  3117. if (ar9300_check_eeprom_header(ah, read, cptr))
  3118. goto found;
  3119. read = ar9300_read_otp;
  3120. cptr = AR9300_BASE_ADDR;
  3121. ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
  3122. if (ar9300_check_eeprom_header(ah, read, cptr))
  3123. goto found;
  3124. cptr = AR9300_BASE_ADDR_512;
  3125. ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
  3126. if (ar9300_check_eeprom_header(ah, read, cptr))
  3127. goto found;
  3128. goto fail;
  3129. found:
  3130. ath_dbg(common, EEPROM, "Found valid EEPROM data\n");
  3131. for (it = 0; it < MSTATE; it++) {
  3132. if (!read(ah, cptr, word, COMP_HDR_LEN))
  3133. goto fail;
  3134. if (!ar9300_check_header(word))
  3135. break;
  3136. ar9300_comp_hdr_unpack(word, &code, &reference,
  3137. &length, &major, &minor);
  3138. ath_dbg(common, EEPROM,
  3139. "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
  3140. cptr, code, reference, length, major, minor);
  3141. if ((!AR_SREV_9485(ah) && length >= 1024) ||
  3142. (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
  3143. ath_dbg(common, EEPROM, "Skipping bad header\n");
  3144. cptr -= COMP_HDR_LEN;
  3145. continue;
  3146. }
  3147. osize = length;
  3148. read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
  3149. checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length);
  3150. mchecksum = get_unaligned_le16(&word[COMP_HDR_LEN + osize]);
  3151. ath_dbg(common, EEPROM, "checksum %x %x\n",
  3152. checksum, mchecksum);
  3153. if (checksum == mchecksum) {
  3154. ar9300_compress_decision(ah, it, code, reference, mptr,
  3155. word, length, mdata_size);
  3156. } else {
  3157. ath_dbg(common, EEPROM,
  3158. "skipping block with bad checksum\n");
  3159. }
  3160. cptr -= (COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
  3161. }
  3162. kfree(word);
  3163. return cptr;
  3164. fail:
  3165. kfree(word);
  3166. return -1;
  3167. }
  3168. /*
  3169. * Restore the configuration structure by reading the eeprom.
  3170. * This function destroys any existing in-memory structure
  3171. * content.
  3172. */
  3173. static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
  3174. {
  3175. u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
  3176. if (ar9300_eeprom_restore_internal(ah, mptr,
  3177. sizeof(struct ar9300_eeprom)) < 0)
  3178. return false;
  3179. return true;
  3180. }
  3181. #if defined(CONFIG_ATH9K_DEBUGFS) || defined(CONFIG_ATH9K_HTC_DEBUGFS)
  3182. static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size,
  3183. struct ar9300_modal_eep_header *modal_hdr)
  3184. {
  3185. PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  3186. PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
  3187. PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
  3188. PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  3189. PR_EEP("Ant. Common Control2", le32_to_cpu(modal_hdr->antCtrlCommon2));
  3190. PR_EEP("Ant. Gain", modal_hdr->antennaGain);
  3191. PR_EEP("Switch Settle", modal_hdr->switchSettling);
  3192. PR_EEP("Chain0 xatten1DB", modal_hdr->xatten1DB[0]);
  3193. PR_EEP("Chain1 xatten1DB", modal_hdr->xatten1DB[1]);
  3194. PR_EEP("Chain2 xatten1DB", modal_hdr->xatten1DB[2]);
  3195. PR_EEP("Chain0 xatten1Margin", modal_hdr->xatten1Margin[0]);
  3196. PR_EEP("Chain1 xatten1Margin", modal_hdr->xatten1Margin[1]);
  3197. PR_EEP("Chain2 xatten1Margin", modal_hdr->xatten1Margin[2]);
  3198. PR_EEP("Temp Slope", modal_hdr->tempSlope);
  3199. PR_EEP("Volt Slope", modal_hdr->voltSlope);
  3200. PR_EEP("spur Channels0", modal_hdr->spurChans[0]);
  3201. PR_EEP("spur Channels1", modal_hdr->spurChans[1]);
  3202. PR_EEP("spur Channels2", modal_hdr->spurChans[2]);
  3203. PR_EEP("spur Channels3", modal_hdr->spurChans[3]);
  3204. PR_EEP("spur Channels4", modal_hdr->spurChans[4]);
  3205. PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]);
  3206. PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]);
  3207. PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]);
  3208. PR_EEP("Quick Drop", modal_hdr->quick_drop);
  3209. PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff);
  3210. PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl);
  3211. PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart);
  3212. PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn);
  3213. PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn);
  3214. PR_EEP("txClip", modal_hdr->txClip);
  3215. PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize);
  3216. return len;
  3217. }
  3218. static u32 ar9003_dump_cal_data(struct ath_hw *ah, char *buf, u32 len, u32 size,
  3219. bool is_2g)
  3220. {
  3221. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3222. struct ar9300_base_eep_hdr *pBase;
  3223. struct ar9300_cal_data_per_freq_op_loop *cal_pier;
  3224. int cal_pier_nr;
  3225. int freq;
  3226. int i, j;
  3227. pBase = &eep->baseEepHeader;
  3228. if (is_2g)
  3229. cal_pier_nr = AR9300_NUM_2G_CAL_PIERS;
  3230. else
  3231. cal_pier_nr = AR9300_NUM_5G_CAL_PIERS;
  3232. for (i = 0; i < AR9300_MAX_CHAINS; i++) {
  3233. if (!((pBase->txrxMask >> i) & 1))
  3234. continue;
  3235. len += scnprintf(buf + len, size - len, "Chain %d\n", i);
  3236. len += scnprintf(buf + len, size - len,
  3237. "Freq\t ref\tvolt\ttemp\tnf_cal\tnf_pow\trx_temp\n");
  3238. for (j = 0; j < cal_pier_nr; j++) {
  3239. if (is_2g) {
  3240. cal_pier = &eep->calPierData2G[i][j];
  3241. freq = 2300 + eep->calFreqPier2G[j];
  3242. } else {
  3243. cal_pier = &eep->calPierData5G[i][j];
  3244. freq = 4800 + eep->calFreqPier5G[j] * 5;
  3245. }
  3246. len += scnprintf(buf + len, size - len,
  3247. "%d\t", freq);
  3248. len += scnprintf(buf + len, size - len,
  3249. "%d\t%d\t%d\t%d\t%d\t%d\n",
  3250. cal_pier->refPower,
  3251. cal_pier->voltMeas,
  3252. cal_pier->tempMeas,
  3253. cal_pier->rxTempMeas ?
  3254. N2DBM(cal_pier->rxNoisefloorCal) : 0,
  3255. cal_pier->rxTempMeas ?
  3256. N2DBM(cal_pier->rxNoisefloorPower) : 0,
  3257. cal_pier->rxTempMeas);
  3258. }
  3259. }
  3260. return len;
  3261. }
  3262. static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  3263. u8 *buf, u32 len, u32 size)
  3264. {
  3265. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3266. struct ar9300_base_eep_hdr *pBase;
  3267. if (!dump_base_hdr) {
  3268. len += scnprintf(buf + len, size - len,
  3269. "%20s :\n", "2GHz modal Header");
  3270. len = ar9003_dump_modal_eeprom(buf, len, size,
  3271. &eep->modalHeader2G);
  3272. len += scnprintf(buf + len, size - len, "Calibration data\n");
  3273. len = ar9003_dump_cal_data(ah, buf, len, size, true);
  3274. len += scnprintf(buf + len, size - len,
  3275. "%20s :\n", "5GHz modal Header");
  3276. len = ar9003_dump_modal_eeprom(buf, len, size,
  3277. &eep->modalHeader5G);
  3278. len += scnprintf(buf + len, size - len, "Calibration data\n");
  3279. len = ar9003_dump_cal_data(ah, buf, len, size, false);
  3280. goto out;
  3281. }
  3282. pBase = &eep->baseEepHeader;
  3283. PR_EEP("EEPROM Version", ah->eeprom.ar9300_eep.eepromVersion);
  3284. PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  3285. PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  3286. PR_EEP("TX Mask", (pBase->txrxMask >> 4));
  3287. PR_EEP("RX Mask", (pBase->txrxMask & 0x0f));
  3288. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags.opFlags &
  3289. AR5416_OPFLAGS_11A));
  3290. PR_EEP("Allow 2GHz", !!(pBase->opCapFlags.opFlags &
  3291. AR5416_OPFLAGS_11G));
  3292. PR_EEP("Disable 2GHz HT20", !!(pBase->opCapFlags.opFlags &
  3293. AR5416_OPFLAGS_N_2G_HT20));
  3294. PR_EEP("Disable 2GHz HT40", !!(pBase->opCapFlags.opFlags &
  3295. AR5416_OPFLAGS_N_2G_HT40));
  3296. PR_EEP("Disable 5Ghz HT20", !!(pBase->opCapFlags.opFlags &
  3297. AR5416_OPFLAGS_N_5G_HT20));
  3298. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags.opFlags &
  3299. AR5416_OPFLAGS_N_5G_HT40));
  3300. PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc &
  3301. AR5416_EEPMISC_BIG_ENDIAN));
  3302. PR_EEP("RF Silent", pBase->rfSilent);
  3303. PR_EEP("BT option", pBase->blueToothOptions);
  3304. PR_EEP("Device Cap", pBase->deviceCap);
  3305. PR_EEP("Device Type", pBase->deviceType);
  3306. PR_EEP("Power Table Offset", pBase->pwrTableOffset);
  3307. PR_EEP("Tuning Caps1", pBase->params_for_tuning_caps[0]);
  3308. PR_EEP("Tuning Caps2", pBase->params_for_tuning_caps[1]);
  3309. PR_EEP("Enable Tx Temp Comp", !!(pBase->featureEnable & BIT(0)));
  3310. PR_EEP("Enable Tx Volt Comp", !!(pBase->featureEnable & BIT(1)));
  3311. PR_EEP("Enable fast clock", !!(pBase->featureEnable & BIT(2)));
  3312. PR_EEP("Enable doubling", !!(pBase->featureEnable & BIT(3)));
  3313. PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4)));
  3314. PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5)));
  3315. PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0)));
  3316. PR_EEP("Quick Drop", !!(pBase->miscConfiguration & BIT(1)));
  3317. PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1);
  3318. PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio);
  3319. PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio);
  3320. PR_EEP("WLAN LED Gpio", pBase->wlanLedGpio);
  3321. PR_EEP("Rx Band Select Gpio", pBase->rxBandSelectGpio);
  3322. PR_EEP("Tx Gain", pBase->txrxgain >> 4);
  3323. PR_EEP("Rx Gain", pBase->txrxgain & 0xf);
  3324. PR_EEP("SW Reg", le32_to_cpu(pBase->swreg));
  3325. len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
  3326. ah->eeprom.ar9300_eep.macAddr);
  3327. out:
  3328. if (len > size)
  3329. len = size;
  3330. return len;
  3331. }
  3332. #else
  3333. static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  3334. u8 *buf, u32 len, u32 size)
  3335. {
  3336. return 0;
  3337. }
  3338. #endif
  3339. /* XXX: review hardware docs */
  3340. static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah)
  3341. {
  3342. return ah->eeprom.ar9300_eep.eepromVersion;
  3343. }
  3344. /* XXX: could be read from the eepromVersion, not sure yet */
  3345. static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)
  3346. {
  3347. return 0;
  3348. }
  3349. static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
  3350. bool is2ghz)
  3351. {
  3352. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3353. if (is2ghz)
  3354. return &eep->modalHeader2G;
  3355. else
  3356. return &eep->modalHeader5G;
  3357. }
  3358. static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
  3359. {
  3360. int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
  3361. if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
  3362. AR_SREV_9531(ah) || AR_SREV_9561(ah))
  3363. REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias);
  3364. else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9565(ah))
  3365. REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
  3366. else {
  3367. REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
  3368. REG_RMW_FIELD(ah, AR_CH0_THERM,
  3369. AR_CH0_THERM_XPABIASLVL_MSB,
  3370. bias >> 2);
  3371. REG_RMW_FIELD(ah, AR_CH0_THERM,
  3372. AR_CH0_THERM_XPASHORT2GND, 1);
  3373. }
  3374. }
  3375. static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
  3376. {
  3377. return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
  3378. }
  3379. u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
  3380. {
  3381. return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
  3382. }
  3383. u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
  3384. {
  3385. return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
  3386. }
  3387. static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain,
  3388. bool is2ghz)
  3389. {
  3390. __le16 val = ar9003_modal_header(ah, is2ghz)->antCtrlChain[chain];
  3391. return le16_to_cpu(val);
  3392. }
  3393. static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
  3394. {
  3395. struct ath_common *common = ath9k_hw_common(ah);
  3396. struct ath9k_hw_capabilities *pCap = &ah->caps;
  3397. int chain;
  3398. u32 regval, value, gpio;
  3399. static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
  3400. AR_PHY_SWITCH_CHAIN_0,
  3401. AR_PHY_SWITCH_CHAIN_1,
  3402. AR_PHY_SWITCH_CHAIN_2,
  3403. };
  3404. if (AR_SREV_9485(ah) && (ar9003_hw_get_rx_gain_idx(ah) == 0)) {
  3405. if (ah->config.xlna_gpio)
  3406. gpio = ah->config.xlna_gpio;
  3407. else
  3408. gpio = AR9300_EXT_LNA_CTL_GPIO_AR9485;
  3409. ath9k_hw_gpio_request_out(ah, gpio, NULL,
  3410. AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED);
  3411. }
  3412. value = ar9003_hw_ant_ctrl_common_get(ah, is2ghz);
  3413. if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
  3414. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3415. AR_SWITCH_TABLE_COM_AR9462_ALL, value);
  3416. } else if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
  3417. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3418. AR_SWITCH_TABLE_COM_AR9550_ALL, value);
  3419. } else
  3420. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3421. AR_SWITCH_TABLE_COM_ALL, value);
  3422. /*
  3423. * AR9462 defines new switch table for BT/WLAN,
  3424. * here's new field name in XXX.ref for both 2G and 5G.
  3425. * Register: [GLB_CONTROL] GLB_CONTROL (@0x20044)
  3426. * 15:12 R/W SWITCH_TABLE_COM_SPDT_WLAN_RX
  3427. * SWITCH_TABLE_COM_SPDT_WLAN_RX
  3428. *
  3429. * 11:8 R/W SWITCH_TABLE_COM_SPDT_WLAN_TX
  3430. * SWITCH_TABLE_COM_SPDT_WLAN_TX
  3431. *
  3432. * 7:4 R/W SWITCH_TABLE_COM_SPDT_WLAN_IDLE
  3433. * SWITCH_TABLE_COM_SPDT_WLAN_IDLE
  3434. */
  3435. if (AR_SREV_9462_20_OR_LATER(ah) || AR_SREV_9565(ah)) {
  3436. value = ar9003_switch_com_spdt_get(ah, is2ghz);
  3437. REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL,
  3438. AR_SWITCH_TABLE_COM_SPDT_ALL, value);
  3439. REG_SET_BIT(ah, AR_PHY_GLB_CONTROL, AR_BTCOEX_CTRL_SPDT_ENABLE);
  3440. }
  3441. value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
  3442. if (AR_SREV_9485(ah) && common->bt_ant_diversity) {
  3443. value &= ~AR_SWITCH_TABLE_COM2_ALL;
  3444. value |= ah->config.ant_ctrl_comm2g_switch_enable;
  3445. }
  3446. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
  3447. if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
  3448. value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
  3449. REG_RMW_FIELD(ah, switch_chain_reg[0],
  3450. AR_SWITCH_TABLE_ALL, value);
  3451. }
  3452. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  3453. if ((ah->rxchainmask & BIT(chain)) ||
  3454. (ah->txchainmask & BIT(chain))) {
  3455. value = ar9003_hw_ant_ctrl_chain_get(ah, chain,
  3456. is2ghz);
  3457. REG_RMW_FIELD(ah, switch_chain_reg[chain],
  3458. AR_SWITCH_TABLE_ALL, value);
  3459. }
  3460. }
  3461. if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
  3462. value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
  3463. /*
  3464. * main_lnaconf, alt_lnaconf, main_tb, alt_tb
  3465. * are the fields present
  3466. */
  3467. regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
  3468. regval &= (~AR_ANT_DIV_CTRL_ALL);
  3469. regval |= (value & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
  3470. /* enable_lnadiv */
  3471. regval &= (~AR_PHY_ANT_DIV_LNADIV);
  3472. regval |= ((value >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
  3473. if (AR_SREV_9485(ah) && common->bt_ant_diversity)
  3474. regval |= AR_ANT_DIV_ENABLE;
  3475. if (AR_SREV_9565(ah)) {
  3476. if (common->bt_ant_diversity) {
  3477. regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S);
  3478. REG_SET_BIT(ah, AR_PHY_RESTART,
  3479. AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
  3480. /* Force WLAN LNA diversity ON */
  3481. REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
  3482. AR_BTCOEX_WL_LNADIV_FORCE_ON);
  3483. } else {
  3484. regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S);
  3485. regval &= ~(1 << AR_PHY_ANT_SW_RX_PROT_S);
  3486. REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
  3487. (1 << AR_PHY_ANT_SW_RX_PROT_S));
  3488. /* Force WLAN LNA diversity OFF */
  3489. REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
  3490. AR_BTCOEX_WL_LNADIV_FORCE_ON);
  3491. }
  3492. }
  3493. REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
  3494. /* enable fast_div */
  3495. regval = REG_READ(ah, AR_PHY_CCK_DETECT);
  3496. regval &= (~AR_FAST_DIV_ENABLE);
  3497. regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
  3498. if ((AR_SREV_9485(ah) || AR_SREV_9565(ah))
  3499. && common->bt_ant_diversity)
  3500. regval |= AR_FAST_DIV_ENABLE;
  3501. REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
  3502. if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
  3503. regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
  3504. /*
  3505. * clear bits 25-30 main_lnaconf, alt_lnaconf,
  3506. * main_tb, alt_tb
  3507. */
  3508. regval &= (~(AR_PHY_ANT_DIV_MAIN_LNACONF |
  3509. AR_PHY_ANT_DIV_ALT_LNACONF |
  3510. AR_PHY_ANT_DIV_ALT_GAINTB |
  3511. AR_PHY_ANT_DIV_MAIN_GAINTB));
  3512. /* by default use LNA1 for the main antenna */
  3513. regval |= (ATH_ANT_DIV_COMB_LNA1 <<
  3514. AR_PHY_ANT_DIV_MAIN_LNACONF_S);
  3515. regval |= (ATH_ANT_DIV_COMB_LNA2 <<
  3516. AR_PHY_ANT_DIV_ALT_LNACONF_S);
  3517. REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
  3518. }
  3519. }
  3520. }
  3521. static void ar9003_hw_drive_strength_apply(struct ath_hw *ah)
  3522. {
  3523. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3524. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3525. int drive_strength;
  3526. unsigned long reg;
  3527. drive_strength = pBase->miscConfiguration & BIT(0);
  3528. if (!drive_strength)
  3529. return;
  3530. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS1);
  3531. reg &= ~0x00ffffc0;
  3532. reg |= 0x5 << 21;
  3533. reg |= 0x5 << 18;
  3534. reg |= 0x5 << 15;
  3535. reg |= 0x5 << 12;
  3536. reg |= 0x5 << 9;
  3537. reg |= 0x5 << 6;
  3538. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS1, reg);
  3539. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS2);
  3540. reg &= ~0xffffffe0;
  3541. reg |= 0x5 << 29;
  3542. reg |= 0x5 << 26;
  3543. reg |= 0x5 << 23;
  3544. reg |= 0x5 << 20;
  3545. reg |= 0x5 << 17;
  3546. reg |= 0x5 << 14;
  3547. reg |= 0x5 << 11;
  3548. reg |= 0x5 << 8;
  3549. reg |= 0x5 << 5;
  3550. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS2, reg);
  3551. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS4);
  3552. reg &= ~0xff800000;
  3553. reg |= 0x5 << 29;
  3554. reg |= 0x5 << 26;
  3555. reg |= 0x5 << 23;
  3556. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS4, reg);
  3557. }
  3558. static u16 ar9003_hw_atten_chain_get(struct ath_hw *ah, int chain,
  3559. struct ath9k_channel *chan)
  3560. {
  3561. int f[3], t[3];
  3562. u16 value;
  3563. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3564. if (chain >= 0 && chain < 3) {
  3565. if (IS_CHAN_2GHZ(chan))
  3566. return eep->modalHeader2G.xatten1DB[chain];
  3567. else if (eep->base_ext2.xatten1DBLow[chain] != 0) {
  3568. t[0] = eep->base_ext2.xatten1DBLow[chain];
  3569. f[0] = 5180;
  3570. t[1] = eep->modalHeader5G.xatten1DB[chain];
  3571. f[1] = 5500;
  3572. t[2] = eep->base_ext2.xatten1DBHigh[chain];
  3573. f[2] = 5785;
  3574. value = ar9003_hw_power_interpolate((s32) chan->channel,
  3575. f, t, 3);
  3576. return value;
  3577. } else
  3578. return eep->modalHeader5G.xatten1DB[chain];
  3579. }
  3580. return 0;
  3581. }
  3582. static u16 ar9003_hw_atten_chain_get_margin(struct ath_hw *ah, int chain,
  3583. struct ath9k_channel *chan)
  3584. {
  3585. int f[3], t[3];
  3586. u16 value;
  3587. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3588. if (chain >= 0 && chain < 3) {
  3589. if (IS_CHAN_2GHZ(chan))
  3590. return eep->modalHeader2G.xatten1Margin[chain];
  3591. else if (eep->base_ext2.xatten1MarginLow[chain] != 0) {
  3592. t[0] = eep->base_ext2.xatten1MarginLow[chain];
  3593. f[0] = 5180;
  3594. t[1] = eep->modalHeader5G.xatten1Margin[chain];
  3595. f[1] = 5500;
  3596. t[2] = eep->base_ext2.xatten1MarginHigh[chain];
  3597. f[2] = 5785;
  3598. value = ar9003_hw_power_interpolate((s32) chan->channel,
  3599. f, t, 3);
  3600. return value;
  3601. } else
  3602. return eep->modalHeader5G.xatten1Margin[chain];
  3603. }
  3604. return 0;
  3605. }
  3606. static void ar9003_hw_atten_apply(struct ath_hw *ah, struct ath9k_channel *chan)
  3607. {
  3608. int i;
  3609. u16 value;
  3610. unsigned long ext_atten_reg[3] = {AR_PHY_EXT_ATTEN_CTL_0,
  3611. AR_PHY_EXT_ATTEN_CTL_1,
  3612. AR_PHY_EXT_ATTEN_CTL_2,
  3613. };
  3614. if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
  3615. value = ar9003_hw_atten_chain_get(ah, 1, chan);
  3616. REG_RMW_FIELD(ah, ext_atten_reg[0],
  3617. AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
  3618. value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
  3619. REG_RMW_FIELD(ah, ext_atten_reg[0],
  3620. AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
  3621. value);
  3622. }
  3623. /* Test value. if 0 then attenuation is unused. Don't load anything. */
  3624. for (i = 0; i < 3; i++) {
  3625. if (ah->txchainmask & BIT(i)) {
  3626. value = ar9003_hw_atten_chain_get(ah, i, chan);
  3627. REG_RMW_FIELD(ah, ext_atten_reg[i],
  3628. AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
  3629. if (AR_SREV_9485(ah) &&
  3630. (ar9003_hw_get_rx_gain_idx(ah) == 0) &&
  3631. ah->config.xatten_margin_cfg)
  3632. value = 5;
  3633. else
  3634. value = ar9003_hw_atten_chain_get_margin(ah, i, chan);
  3635. if (ah->config.alt_mingainidx)
  3636. REG_RMW_FIELD(ah, AR_PHY_EXT_ATTEN_CTL_0,
  3637. AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
  3638. value);
  3639. REG_RMW_FIELD(ah, ext_atten_reg[i],
  3640. AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
  3641. value);
  3642. }
  3643. }
  3644. }
  3645. static bool is_pmu_set(struct ath_hw *ah, u32 pmu_reg, int pmu_set)
  3646. {
  3647. int timeout = 100;
  3648. while (pmu_set != REG_READ(ah, pmu_reg)) {
  3649. if (timeout-- == 0)
  3650. return false;
  3651. REG_WRITE(ah, pmu_reg, pmu_set);
  3652. udelay(10);
  3653. }
  3654. return true;
  3655. }
  3656. void ar9003_hw_internal_regulator_apply(struct ath_hw *ah)
  3657. {
  3658. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3659. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3660. u32 reg_val;
  3661. if (pBase->featureEnable & BIT(4)) {
  3662. if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
  3663. int reg_pmu_set;
  3664. reg_pmu_set = REG_READ(ah, AR_PHY_PMU2) & ~AR_PHY_PMU2_PGM;
  3665. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3666. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3667. return;
  3668. if (AR_SREV_9330(ah)) {
  3669. if (ah->is_clk_25mhz) {
  3670. reg_pmu_set = (3 << 1) | (8 << 4) |
  3671. (3 << 8) | (1 << 14) |
  3672. (6 << 17) | (1 << 20) |
  3673. (3 << 24);
  3674. } else {
  3675. reg_pmu_set = (4 << 1) | (7 << 4) |
  3676. (3 << 8) | (1 << 14) |
  3677. (6 << 17) | (1 << 20) |
  3678. (3 << 24);
  3679. }
  3680. } else {
  3681. reg_pmu_set = (5 << 1) | (7 << 4) |
  3682. (2 << 8) | (2 << 14) |
  3683. (6 << 17) | (1 << 20) |
  3684. (3 << 24) | (1 << 28);
  3685. }
  3686. REG_WRITE(ah, AR_PHY_PMU1, reg_pmu_set);
  3687. if (!is_pmu_set(ah, AR_PHY_PMU1, reg_pmu_set))
  3688. return;
  3689. reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0xFFC00000)
  3690. | (4 << 26);
  3691. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3692. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3693. return;
  3694. reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0x00200000)
  3695. | (1 << 21);
  3696. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3697. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3698. return;
  3699. } else if (AR_SREV_9462(ah) || AR_SREV_9565(ah) ||
  3700. AR_SREV_9561(ah)) {
  3701. reg_val = le32_to_cpu(pBase->swreg);
  3702. REG_WRITE(ah, AR_PHY_PMU1, reg_val);
  3703. if (AR_SREV_9561(ah))
  3704. REG_WRITE(ah, AR_PHY_PMU2, 0x10200000);
  3705. } else {
  3706. /* Internal regulator is ON. Write swreg register. */
  3707. reg_val = le32_to_cpu(pBase->swreg);
  3708. REG_WRITE(ah, AR_RTC_REG_CONTROL1,
  3709. REG_READ(ah, AR_RTC_REG_CONTROL1) &
  3710. (~AR_RTC_REG_CONTROL1_SWREG_PROGRAM));
  3711. REG_WRITE(ah, AR_RTC_REG_CONTROL0, reg_val);
  3712. /* Set REG_CONTROL1.SWREG_PROGRAM */
  3713. REG_WRITE(ah, AR_RTC_REG_CONTROL1,
  3714. REG_READ(ah,
  3715. AR_RTC_REG_CONTROL1) |
  3716. AR_RTC_REG_CONTROL1_SWREG_PROGRAM);
  3717. }
  3718. } else {
  3719. if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
  3720. REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0);
  3721. while (REG_READ_FIELD(ah, AR_PHY_PMU2,
  3722. AR_PHY_PMU2_PGM))
  3723. udelay(10);
  3724. REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
  3725. while (!REG_READ_FIELD(ah, AR_PHY_PMU1,
  3726. AR_PHY_PMU1_PWD))
  3727. udelay(10);
  3728. REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0x1);
  3729. while (!REG_READ_FIELD(ah, AR_PHY_PMU2,
  3730. AR_PHY_PMU2_PGM))
  3731. udelay(10);
  3732. } else if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
  3733. REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
  3734. else {
  3735. reg_val = REG_READ(ah, AR_RTC_SLEEP_CLK) |
  3736. AR_RTC_FORCE_SWREG_PRD;
  3737. REG_WRITE(ah, AR_RTC_SLEEP_CLK, reg_val);
  3738. }
  3739. }
  3740. }
  3741. static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah)
  3742. {
  3743. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3744. u8 tuning_caps_param = eep->baseEepHeader.params_for_tuning_caps[0];
  3745. if (AR_SREV_9340(ah) || AR_SREV_9531(ah))
  3746. return;
  3747. if (eep->baseEepHeader.featureEnable & 0x40) {
  3748. tuning_caps_param &= 0x7f;
  3749. REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPINDAC,
  3750. tuning_caps_param);
  3751. REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPOUTDAC,
  3752. tuning_caps_param);
  3753. }
  3754. }
  3755. static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq)
  3756. {
  3757. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3758. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3759. int quick_drop;
  3760. s32 t[3], f[3] = {5180, 5500, 5785};
  3761. if (!(pBase->miscConfiguration & BIT(4)))
  3762. return;
  3763. if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9340(ah)) {
  3764. if (freq < 4000) {
  3765. quick_drop = eep->modalHeader2G.quick_drop;
  3766. } else {
  3767. t[0] = eep->base_ext1.quick_drop_low;
  3768. t[1] = eep->modalHeader5G.quick_drop;
  3769. t[2] = eep->base_ext1.quick_drop_high;
  3770. quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
  3771. }
  3772. REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
  3773. }
  3774. }
  3775. static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz)
  3776. {
  3777. u32 value;
  3778. value = ar9003_modal_header(ah, is2ghz)->txEndToXpaOff;
  3779. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3780. AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value);
  3781. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3782. AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value);
  3783. }
  3784. static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz)
  3785. {
  3786. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3787. u8 xpa_ctl;
  3788. if (!(eep->baseEepHeader.featureEnable & 0x80))
  3789. return;
  3790. if (!AR_SREV_9300(ah) &&
  3791. !AR_SREV_9340(ah) &&
  3792. !AR_SREV_9580(ah) &&
  3793. !AR_SREV_9531(ah) &&
  3794. !AR_SREV_9561(ah))
  3795. return;
  3796. xpa_ctl = ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn;
  3797. if (is2ghz)
  3798. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3799. AR_PHY_XPA_TIMING_CTL_FRAME_XPAB_ON, xpa_ctl);
  3800. else
  3801. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3802. AR_PHY_XPA_TIMING_CTL_FRAME_XPAA_ON, xpa_ctl);
  3803. }
  3804. static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz)
  3805. {
  3806. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3807. u8 bias;
  3808. if (!(eep->baseEepHeader.miscConfiguration & 0x40))
  3809. return;
  3810. if (!AR_SREV_9300(ah))
  3811. return;
  3812. bias = ar9003_modal_header(ah, is2ghz)->xlna_bias_strength;
  3813. REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
  3814. bias & 0x3);
  3815. bias >>= 2;
  3816. REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
  3817. bias & 0x3);
  3818. bias >>= 2;
  3819. REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
  3820. bias & 0x3);
  3821. }
  3822. static int ar9003_hw_get_thermometer(struct ath_hw *ah)
  3823. {
  3824. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3825. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3826. int thermometer = (pBase->miscConfiguration >> 1) & 0x3;
  3827. return --thermometer;
  3828. }
  3829. static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
  3830. {
  3831. struct ath9k_hw_capabilities *pCap = &ah->caps;
  3832. int thermometer = ar9003_hw_get_thermometer(ah);
  3833. u8 therm_on = (thermometer < 0) ? 0 : 1;
  3834. REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
  3835. AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
  3836. if (pCap->chip_chainmask & BIT(1))
  3837. REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
  3838. AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
  3839. if (pCap->chip_chainmask & BIT(2))
  3840. REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
  3841. AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
  3842. therm_on = thermometer == 0;
  3843. REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
  3844. AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
  3845. if (pCap->chip_chainmask & BIT(1)) {
  3846. therm_on = thermometer == 1;
  3847. REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
  3848. AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
  3849. }
  3850. if (pCap->chip_chainmask & BIT(2)) {
  3851. therm_on = thermometer == 2;
  3852. REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
  3853. AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
  3854. }
  3855. }
  3856. static void ar9003_hw_thermo_cal_apply(struct ath_hw *ah)
  3857. {
  3858. u32 data = 0, ko, kg;
  3859. if (!AR_SREV_9462_20_OR_LATER(ah))
  3860. return;
  3861. ar9300_otp_read_word(ah, 1, &data);
  3862. ko = data & 0xff;
  3863. kg = (data >> 8) & 0xff;
  3864. if (ko || kg) {
  3865. REG_RMW_FIELD(ah, AR_PHY_BB_THERM_ADC_3,
  3866. AR_PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET, ko);
  3867. REG_RMW_FIELD(ah, AR_PHY_BB_THERM_ADC_3,
  3868. AR_PHY_BB_THERM_ADC_3_THERM_ADC_SCALE_GAIN,
  3869. kg + 256);
  3870. }
  3871. }
  3872. static void ar9003_hw_apply_minccapwr_thresh(struct ath_hw *ah,
  3873. bool is2ghz)
  3874. {
  3875. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3876. const u_int32_t cca_ctrl[AR9300_MAX_CHAINS] = {
  3877. AR_PHY_CCA_CTRL_0,
  3878. AR_PHY_CCA_CTRL_1,
  3879. AR_PHY_CCA_CTRL_2,
  3880. };
  3881. int chain;
  3882. u32 val;
  3883. if (is2ghz) {
  3884. if (!(eep->base_ext1.misc_enable & BIT(2)))
  3885. return;
  3886. } else {
  3887. if (!(eep->base_ext1.misc_enable & BIT(3)))
  3888. return;
  3889. }
  3890. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  3891. if (!(ah->caps.tx_chainmask & BIT(chain)))
  3892. continue;
  3893. val = ar9003_modal_header(ah, is2ghz)->noiseFloorThreshCh[chain];
  3894. REG_RMW_FIELD(ah, cca_ctrl[chain],
  3895. AR_PHY_EXT_CCA0_THRESH62_1, val);
  3896. }
  3897. }
  3898. static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah,
  3899. struct ath9k_channel *chan)
  3900. {
  3901. bool is2ghz = IS_CHAN_2GHZ(chan);
  3902. ar9003_hw_xpa_timing_control_apply(ah, is2ghz);
  3903. ar9003_hw_xpa_bias_level_apply(ah, is2ghz);
  3904. ar9003_hw_ant_ctrl_apply(ah, is2ghz);
  3905. ar9003_hw_drive_strength_apply(ah);
  3906. ar9003_hw_xlna_bias_strength_apply(ah, is2ghz);
  3907. ar9003_hw_atten_apply(ah, chan);
  3908. ar9003_hw_quick_drop_apply(ah, chan->channel);
  3909. if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) && !AR_SREV_9531(ah))
  3910. ar9003_hw_internal_regulator_apply(ah);
  3911. ar9003_hw_apply_tuning_caps(ah);
  3912. ar9003_hw_apply_minccapwr_thresh(ah, is2ghz);
  3913. ar9003_hw_txend_to_xpa_off_apply(ah, is2ghz);
  3914. ar9003_hw_thermometer_apply(ah);
  3915. ar9003_hw_thermo_cal_apply(ah);
  3916. }
  3917. static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah,
  3918. struct ath9k_channel *chan)
  3919. {
  3920. }
  3921. /*
  3922. * Returns the interpolated y value corresponding to the specified x value
  3923. * from the np ordered pairs of data (px,py).
  3924. * The pairs do not have to be in any order.
  3925. * If the specified x value is less than any of the px,
  3926. * the returned y value is equal to the py for the lowest px.
  3927. * If the specified x value is greater than any of the px,
  3928. * the returned y value is equal to the py for the highest px.
  3929. */
  3930. static int ar9003_hw_power_interpolate(int32_t x,
  3931. int32_t *px, int32_t *py, u_int16_t np)
  3932. {
  3933. int ip = 0;
  3934. int lx = 0, ly = 0, lhave = 0;
  3935. int hx = 0, hy = 0, hhave = 0;
  3936. int dx = 0;
  3937. int y = 0;
  3938. lhave = 0;
  3939. hhave = 0;
  3940. /* identify best lower and higher x calibration measurement */
  3941. for (ip = 0; ip < np; ip++) {
  3942. dx = x - px[ip];
  3943. /* this measurement is higher than our desired x */
  3944. if (dx <= 0) {
  3945. if (!hhave || dx > (x - hx)) {
  3946. /* new best higher x measurement */
  3947. hx = px[ip];
  3948. hy = py[ip];
  3949. hhave = 1;
  3950. }
  3951. }
  3952. /* this measurement is lower than our desired x */
  3953. if (dx >= 0) {
  3954. if (!lhave || dx < (x - lx)) {
  3955. /* new best lower x measurement */
  3956. lx = px[ip];
  3957. ly = py[ip];
  3958. lhave = 1;
  3959. }
  3960. }
  3961. }
  3962. /* the low x is good */
  3963. if (lhave) {
  3964. /* so is the high x */
  3965. if (hhave) {
  3966. /* they're the same, so just pick one */
  3967. if (hx == lx)
  3968. y = ly;
  3969. else /* interpolate */
  3970. y = interpolate(x, lx, hx, ly, hy);
  3971. } else /* only low is good, use it */
  3972. y = ly;
  3973. } else if (hhave) /* only high is good, use it */
  3974. y = hy;
  3975. else /* nothing is good,this should never happen unless np=0, ???? */
  3976. y = -(1 << 30);
  3977. return y;
  3978. }
  3979. static u8 ar9003_hw_eeprom_get_tgt_pwr(struct ath_hw *ah,
  3980. u16 rateIndex, u16 freq, bool is2GHz)
  3981. {
  3982. u16 numPiers, i;
  3983. s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3984. s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3985. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3986. struct cal_tgt_pow_legacy *pEepromTargetPwr;
  3987. u8 *pFreqBin;
  3988. if (is2GHz) {
  3989. numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
  3990. pEepromTargetPwr = eep->calTargetPower2G;
  3991. pFreqBin = eep->calTarget_freqbin_2G;
  3992. } else {
  3993. numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
  3994. pEepromTargetPwr = eep->calTargetPower5G;
  3995. pFreqBin = eep->calTarget_freqbin_5G;
  3996. }
  3997. /*
  3998. * create array of channels and targetpower from
  3999. * targetpower piers stored on eeprom
  4000. */
  4001. for (i = 0; i < numPiers; i++) {
  4002. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  4003. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  4004. }
  4005. /* interpolate to get target power for given frequency */
  4006. return (u8) ar9003_hw_power_interpolate((s32) freq,
  4007. freqArray,
  4008. targetPowerArray, numPiers);
  4009. }
  4010. static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(struct ath_hw *ah,
  4011. u16 rateIndex,
  4012. u16 freq, bool is2GHz)
  4013. {
  4014. u16 numPiers, i;
  4015. s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
  4016. s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
  4017. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4018. struct cal_tgt_pow_ht *pEepromTargetPwr;
  4019. u8 *pFreqBin;
  4020. if (is2GHz) {
  4021. numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
  4022. pEepromTargetPwr = eep->calTargetPower2GHT20;
  4023. pFreqBin = eep->calTarget_freqbin_2GHT20;
  4024. } else {
  4025. numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
  4026. pEepromTargetPwr = eep->calTargetPower5GHT20;
  4027. pFreqBin = eep->calTarget_freqbin_5GHT20;
  4028. }
  4029. /*
  4030. * create array of channels and targetpower
  4031. * from targetpower piers stored on eeprom
  4032. */
  4033. for (i = 0; i < numPiers; i++) {
  4034. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  4035. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  4036. }
  4037. /* interpolate to get target power for given frequency */
  4038. return (u8) ar9003_hw_power_interpolate((s32) freq,
  4039. freqArray,
  4040. targetPowerArray, numPiers);
  4041. }
  4042. static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(struct ath_hw *ah,
  4043. u16 rateIndex,
  4044. u16 freq, bool is2GHz)
  4045. {
  4046. u16 numPiers, i;
  4047. s32 targetPowerArray[AR9300_NUM_5G_40_TARGET_POWERS];
  4048. s32 freqArray[AR9300_NUM_5G_40_TARGET_POWERS];
  4049. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4050. struct cal_tgt_pow_ht *pEepromTargetPwr;
  4051. u8 *pFreqBin;
  4052. if (is2GHz) {
  4053. numPiers = AR9300_NUM_2G_40_TARGET_POWERS;
  4054. pEepromTargetPwr = eep->calTargetPower2GHT40;
  4055. pFreqBin = eep->calTarget_freqbin_2GHT40;
  4056. } else {
  4057. numPiers = AR9300_NUM_5G_40_TARGET_POWERS;
  4058. pEepromTargetPwr = eep->calTargetPower5GHT40;
  4059. pFreqBin = eep->calTarget_freqbin_5GHT40;
  4060. }
  4061. /*
  4062. * create array of channels and targetpower from
  4063. * targetpower piers stored on eeprom
  4064. */
  4065. for (i = 0; i < numPiers; i++) {
  4066. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  4067. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  4068. }
  4069. /* interpolate to get target power for given frequency */
  4070. return (u8) ar9003_hw_power_interpolate((s32) freq,
  4071. freqArray,
  4072. targetPowerArray, numPiers);
  4073. }
  4074. static u8 ar9003_hw_eeprom_get_cck_tgt_pwr(struct ath_hw *ah,
  4075. u16 rateIndex, u16 freq)
  4076. {
  4077. u16 numPiers = AR9300_NUM_2G_CCK_TARGET_POWERS, i;
  4078. s32 targetPowerArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
  4079. s32 freqArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
  4080. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4081. struct cal_tgt_pow_legacy *pEepromTargetPwr = eep->calTargetPowerCck;
  4082. u8 *pFreqBin = eep->calTarget_freqbin_Cck;
  4083. /*
  4084. * create array of channels and targetpower from
  4085. * targetpower piers stored on eeprom
  4086. */
  4087. for (i = 0; i < numPiers; i++) {
  4088. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], 1);
  4089. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  4090. }
  4091. /* interpolate to get target power for given frequency */
  4092. return (u8) ar9003_hw_power_interpolate((s32) freq,
  4093. freqArray,
  4094. targetPowerArray, numPiers);
  4095. }
  4096. static void ar9003_hw_selfgen_tpc_txpower(struct ath_hw *ah,
  4097. struct ath9k_channel *chan,
  4098. u8 *pwr_array)
  4099. {
  4100. u32 val;
  4101. /* target power values for self generated frames (ACK,RTS/CTS) */
  4102. if (IS_CHAN_2GHZ(chan)) {
  4103. val = SM(pwr_array[ALL_TARGET_LEGACY_1L_5L], AR_TPC_ACK) |
  4104. SM(pwr_array[ALL_TARGET_LEGACY_1L_5L], AR_TPC_CTS) |
  4105. SM(0x3f, AR_TPC_CHIRP) | SM(0x3f, AR_TPC_RPT);
  4106. } else {
  4107. val = SM(pwr_array[ALL_TARGET_LEGACY_6_24], AR_TPC_ACK) |
  4108. SM(pwr_array[ALL_TARGET_LEGACY_6_24], AR_TPC_CTS) |
  4109. SM(0x3f, AR_TPC_CHIRP) | SM(0x3f, AR_TPC_RPT);
  4110. }
  4111. REG_WRITE(ah, AR_TPC, val);
  4112. }
  4113. /* Set tx power registers to array of values passed in */
  4114. int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray)
  4115. {
  4116. #define POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
  4117. /* make sure forced gain is not set */
  4118. REG_WRITE(ah, AR_PHY_TX_FORCED_GAIN, 0);
  4119. /* Write the OFDM power per rate set */
  4120. /* 6 (LSB), 9, 12, 18 (MSB) */
  4121. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(0),
  4122. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
  4123. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 16) |
  4124. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
  4125. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
  4126. /* 24 (LSB), 36, 48, 54 (MSB) */
  4127. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(1),
  4128. POW_SM(pPwrArray[ALL_TARGET_LEGACY_54], 24) |
  4129. POW_SM(pPwrArray[ALL_TARGET_LEGACY_48], 16) |
  4130. POW_SM(pPwrArray[ALL_TARGET_LEGACY_36], 8) |
  4131. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
  4132. /* Write the CCK power per rate set */
  4133. /* 1L (LSB), reserved, 2L, 2S (MSB) */
  4134. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(2),
  4135. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 24) |
  4136. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
  4137. /* POW_SM(txPowerTimes2, 8) | this is reserved for AR9003 */
  4138. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0));
  4139. /* 5.5L (LSB), 5.5S, 11L, 11S (MSB) */
  4140. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(3),
  4141. POW_SM(pPwrArray[ALL_TARGET_LEGACY_11S], 24) |
  4142. POW_SM(pPwrArray[ALL_TARGET_LEGACY_11L], 16) |
  4143. POW_SM(pPwrArray[ALL_TARGET_LEGACY_5S], 8) |
  4144. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
  4145. );
  4146. /* Write the power for duplicated frames - HT40 */
  4147. /* dup40_cck (LSB), dup40_ofdm, ext20_cck, ext20_ofdm (MSB) */
  4148. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(8),
  4149. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
  4150. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
  4151. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
  4152. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
  4153. );
  4154. /* Write the HT20 power per rate set */
  4155. /* 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB) */
  4156. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(4),
  4157. POW_SM(pPwrArray[ALL_TARGET_HT20_5], 24) |
  4158. POW_SM(pPwrArray[ALL_TARGET_HT20_4], 16) |
  4159. POW_SM(pPwrArray[ALL_TARGET_HT20_1_3_9_11_17_19], 8) |
  4160. POW_SM(pPwrArray[ALL_TARGET_HT20_0_8_16], 0)
  4161. );
  4162. /* 6 (LSB), 7, 12, 13 (MSB) */
  4163. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(5),
  4164. POW_SM(pPwrArray[ALL_TARGET_HT20_13], 24) |
  4165. POW_SM(pPwrArray[ALL_TARGET_HT20_12], 16) |
  4166. POW_SM(pPwrArray[ALL_TARGET_HT20_7], 8) |
  4167. POW_SM(pPwrArray[ALL_TARGET_HT20_6], 0)
  4168. );
  4169. /* 14 (LSB), 15, 20, 21 */
  4170. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(9),
  4171. POW_SM(pPwrArray[ALL_TARGET_HT20_21], 24) |
  4172. POW_SM(pPwrArray[ALL_TARGET_HT20_20], 16) |
  4173. POW_SM(pPwrArray[ALL_TARGET_HT20_15], 8) |
  4174. POW_SM(pPwrArray[ALL_TARGET_HT20_14], 0)
  4175. );
  4176. /* Mixed HT20 and HT40 rates */
  4177. /* HT20 22 (LSB), HT20 23, HT40 22, HT40 23 (MSB) */
  4178. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(10),
  4179. POW_SM(pPwrArray[ALL_TARGET_HT40_23], 24) |
  4180. POW_SM(pPwrArray[ALL_TARGET_HT40_22], 16) |
  4181. POW_SM(pPwrArray[ALL_TARGET_HT20_23], 8) |
  4182. POW_SM(pPwrArray[ALL_TARGET_HT20_22], 0)
  4183. );
  4184. /*
  4185. * Write the HT40 power per rate set
  4186. * correct PAR difference between HT40 and HT20/LEGACY
  4187. * 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB)
  4188. */
  4189. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(6),
  4190. POW_SM(pPwrArray[ALL_TARGET_HT40_5], 24) |
  4191. POW_SM(pPwrArray[ALL_TARGET_HT40_4], 16) |
  4192. POW_SM(pPwrArray[ALL_TARGET_HT40_1_3_9_11_17_19], 8) |
  4193. POW_SM(pPwrArray[ALL_TARGET_HT40_0_8_16], 0)
  4194. );
  4195. /* 6 (LSB), 7, 12, 13 (MSB) */
  4196. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(7),
  4197. POW_SM(pPwrArray[ALL_TARGET_HT40_13], 24) |
  4198. POW_SM(pPwrArray[ALL_TARGET_HT40_12], 16) |
  4199. POW_SM(pPwrArray[ALL_TARGET_HT40_7], 8) |
  4200. POW_SM(pPwrArray[ALL_TARGET_HT40_6], 0)
  4201. );
  4202. /* 14 (LSB), 15, 20, 21 */
  4203. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(11),
  4204. POW_SM(pPwrArray[ALL_TARGET_HT40_21], 24) |
  4205. POW_SM(pPwrArray[ALL_TARGET_HT40_20], 16) |
  4206. POW_SM(pPwrArray[ALL_TARGET_HT40_15], 8) |
  4207. POW_SM(pPwrArray[ALL_TARGET_HT40_14], 0)
  4208. );
  4209. return 0;
  4210. #undef POW_SM
  4211. }
  4212. static void ar9003_hw_get_legacy_target_powers(struct ath_hw *ah, u16 freq,
  4213. u8 *targetPowerValT2,
  4214. bool is2GHz)
  4215. {
  4216. targetPowerValT2[ALL_TARGET_LEGACY_6_24] =
  4217. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_6_24, freq,
  4218. is2GHz);
  4219. targetPowerValT2[ALL_TARGET_LEGACY_36] =
  4220. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_36, freq,
  4221. is2GHz);
  4222. targetPowerValT2[ALL_TARGET_LEGACY_48] =
  4223. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_48, freq,
  4224. is2GHz);
  4225. targetPowerValT2[ALL_TARGET_LEGACY_54] =
  4226. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_54, freq,
  4227. is2GHz);
  4228. }
  4229. static void ar9003_hw_get_cck_target_powers(struct ath_hw *ah, u16 freq,
  4230. u8 *targetPowerValT2)
  4231. {
  4232. targetPowerValT2[ALL_TARGET_LEGACY_1L_5L] =
  4233. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_1L_5L,
  4234. freq);
  4235. targetPowerValT2[ALL_TARGET_LEGACY_5S] =
  4236. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_5S, freq);
  4237. targetPowerValT2[ALL_TARGET_LEGACY_11L] =
  4238. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11L, freq);
  4239. targetPowerValT2[ALL_TARGET_LEGACY_11S] =
  4240. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11S, freq);
  4241. }
  4242. static void ar9003_hw_get_ht20_target_powers(struct ath_hw *ah, u16 freq,
  4243. u8 *targetPowerValT2, bool is2GHz)
  4244. {
  4245. targetPowerValT2[ALL_TARGET_HT20_0_8_16] =
  4246. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
  4247. is2GHz);
  4248. targetPowerValT2[ALL_TARGET_HT20_1_3_9_11_17_19] =
  4249. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
  4250. freq, is2GHz);
  4251. targetPowerValT2[ALL_TARGET_HT20_4] =
  4252. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
  4253. is2GHz);
  4254. targetPowerValT2[ALL_TARGET_HT20_5] =
  4255. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
  4256. is2GHz);
  4257. targetPowerValT2[ALL_TARGET_HT20_6] =
  4258. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
  4259. is2GHz);
  4260. targetPowerValT2[ALL_TARGET_HT20_7] =
  4261. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
  4262. is2GHz);
  4263. targetPowerValT2[ALL_TARGET_HT20_12] =
  4264. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
  4265. is2GHz);
  4266. targetPowerValT2[ALL_TARGET_HT20_13] =
  4267. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
  4268. is2GHz);
  4269. targetPowerValT2[ALL_TARGET_HT20_14] =
  4270. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
  4271. is2GHz);
  4272. targetPowerValT2[ALL_TARGET_HT20_15] =
  4273. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
  4274. is2GHz);
  4275. targetPowerValT2[ALL_TARGET_HT20_20] =
  4276. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
  4277. is2GHz);
  4278. targetPowerValT2[ALL_TARGET_HT20_21] =
  4279. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
  4280. is2GHz);
  4281. targetPowerValT2[ALL_TARGET_HT20_22] =
  4282. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
  4283. is2GHz);
  4284. targetPowerValT2[ALL_TARGET_HT20_23] =
  4285. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
  4286. is2GHz);
  4287. }
  4288. static void ar9003_hw_get_ht40_target_powers(struct ath_hw *ah,
  4289. u16 freq,
  4290. u8 *targetPowerValT2,
  4291. bool is2GHz)
  4292. {
  4293. /* XXX: hard code for now, need to get from eeprom struct */
  4294. u8 ht40PowerIncForPdadc = 0;
  4295. targetPowerValT2[ALL_TARGET_HT40_0_8_16] =
  4296. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
  4297. is2GHz) + ht40PowerIncForPdadc;
  4298. targetPowerValT2[ALL_TARGET_HT40_1_3_9_11_17_19] =
  4299. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
  4300. freq,
  4301. is2GHz) + ht40PowerIncForPdadc;
  4302. targetPowerValT2[ALL_TARGET_HT40_4] =
  4303. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
  4304. is2GHz) + ht40PowerIncForPdadc;
  4305. targetPowerValT2[ALL_TARGET_HT40_5] =
  4306. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
  4307. is2GHz) + ht40PowerIncForPdadc;
  4308. targetPowerValT2[ALL_TARGET_HT40_6] =
  4309. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
  4310. is2GHz) + ht40PowerIncForPdadc;
  4311. targetPowerValT2[ALL_TARGET_HT40_7] =
  4312. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
  4313. is2GHz) + ht40PowerIncForPdadc;
  4314. targetPowerValT2[ALL_TARGET_HT40_12] =
  4315. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
  4316. is2GHz) + ht40PowerIncForPdadc;
  4317. targetPowerValT2[ALL_TARGET_HT40_13] =
  4318. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
  4319. is2GHz) + ht40PowerIncForPdadc;
  4320. targetPowerValT2[ALL_TARGET_HT40_14] =
  4321. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
  4322. is2GHz) + ht40PowerIncForPdadc;
  4323. targetPowerValT2[ALL_TARGET_HT40_15] =
  4324. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
  4325. is2GHz) + ht40PowerIncForPdadc;
  4326. targetPowerValT2[ALL_TARGET_HT40_20] =
  4327. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
  4328. is2GHz) + ht40PowerIncForPdadc;
  4329. targetPowerValT2[ALL_TARGET_HT40_21] =
  4330. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
  4331. is2GHz) + ht40PowerIncForPdadc;
  4332. targetPowerValT2[ALL_TARGET_HT40_22] =
  4333. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
  4334. is2GHz) + ht40PowerIncForPdadc;
  4335. targetPowerValT2[ALL_TARGET_HT40_23] =
  4336. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
  4337. is2GHz) + ht40PowerIncForPdadc;
  4338. }
  4339. static void ar9003_hw_get_target_power_eeprom(struct ath_hw *ah,
  4340. struct ath9k_channel *chan,
  4341. u8 *targetPowerValT2)
  4342. {
  4343. bool is2GHz = IS_CHAN_2GHZ(chan);
  4344. unsigned int i = 0;
  4345. struct ath_common *common = ath9k_hw_common(ah);
  4346. u16 freq = chan->channel;
  4347. if (is2GHz)
  4348. ar9003_hw_get_cck_target_powers(ah, freq, targetPowerValT2);
  4349. ar9003_hw_get_legacy_target_powers(ah, freq, targetPowerValT2, is2GHz);
  4350. ar9003_hw_get_ht20_target_powers(ah, freq, targetPowerValT2, is2GHz);
  4351. if (IS_CHAN_HT40(chan))
  4352. ar9003_hw_get_ht40_target_powers(ah, freq, targetPowerValT2,
  4353. is2GHz);
  4354. for (i = 0; i < ar9300RateSize; i++) {
  4355. ath_dbg(common, REGULATORY, "TPC[%02d] 0x%08x\n",
  4356. i, targetPowerValT2[i]);
  4357. }
  4358. }
  4359. static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
  4360. int mode,
  4361. int ipier,
  4362. int ichain,
  4363. int *pfrequency,
  4364. int *pcorrection,
  4365. int *ptemperature, int *pvoltage,
  4366. int *pnf_cal, int *pnf_power)
  4367. {
  4368. u8 *pCalPier;
  4369. struct ar9300_cal_data_per_freq_op_loop *pCalPierStruct;
  4370. int is2GHz;
  4371. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4372. struct ath_common *common = ath9k_hw_common(ah);
  4373. if (ichain >= AR9300_MAX_CHAINS) {
  4374. ath_dbg(common, EEPROM,
  4375. "Invalid chain index, must be less than %d\n",
  4376. AR9300_MAX_CHAINS);
  4377. return -1;
  4378. }
  4379. if (mode) { /* 5GHz */
  4380. if (ipier >= AR9300_NUM_5G_CAL_PIERS) {
  4381. ath_dbg(common, EEPROM,
  4382. "Invalid 5GHz cal pier index, must be less than %d\n",
  4383. AR9300_NUM_5G_CAL_PIERS);
  4384. return -1;
  4385. }
  4386. pCalPier = &(eep->calFreqPier5G[ipier]);
  4387. pCalPierStruct = &(eep->calPierData5G[ichain][ipier]);
  4388. is2GHz = 0;
  4389. } else {
  4390. if (ipier >= AR9300_NUM_2G_CAL_PIERS) {
  4391. ath_dbg(common, EEPROM,
  4392. "Invalid 2GHz cal pier index, must be less than %d\n",
  4393. AR9300_NUM_2G_CAL_PIERS);
  4394. return -1;
  4395. }
  4396. pCalPier = &(eep->calFreqPier2G[ipier]);
  4397. pCalPierStruct = &(eep->calPierData2G[ichain][ipier]);
  4398. is2GHz = 1;
  4399. }
  4400. *pfrequency = ath9k_hw_fbin2freq(*pCalPier, is2GHz);
  4401. *pcorrection = pCalPierStruct->refPower;
  4402. *ptemperature = pCalPierStruct->tempMeas;
  4403. *pvoltage = pCalPierStruct->voltMeas;
  4404. *pnf_cal = pCalPierStruct->rxTempMeas ?
  4405. N2DBM(pCalPierStruct->rxNoisefloorCal) : 0;
  4406. *pnf_power = pCalPierStruct->rxTempMeas ?
  4407. N2DBM(pCalPierStruct->rxNoisefloorPower) : 0;
  4408. return 0;
  4409. }
  4410. static void ar9003_hw_power_control_override(struct ath_hw *ah,
  4411. int frequency,
  4412. int *correction,
  4413. int *voltage, int *temperature)
  4414. {
  4415. int temp_slope = 0, temp_slope1 = 0, temp_slope2 = 0;
  4416. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4417. int f[8], t[8], t1[3], t2[3], i;
  4418. REG_RMW(ah, AR_PHY_TPC_11_B0,
  4419. (correction[0] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4420. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4421. if (ah->caps.tx_chainmask & BIT(1))
  4422. REG_RMW(ah, AR_PHY_TPC_11_B1,
  4423. (correction[1] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4424. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4425. if (ah->caps.tx_chainmask & BIT(2))
  4426. REG_RMW(ah, AR_PHY_TPC_11_B2,
  4427. (correction[2] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4428. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4429. /* enable open loop power control on chip */
  4430. REG_RMW(ah, AR_PHY_TPC_6_B0,
  4431. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4432. AR_PHY_TPC_6_ERROR_EST_MODE);
  4433. if (ah->caps.tx_chainmask & BIT(1))
  4434. REG_RMW(ah, AR_PHY_TPC_6_B1,
  4435. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4436. AR_PHY_TPC_6_ERROR_EST_MODE);
  4437. if (ah->caps.tx_chainmask & BIT(2))
  4438. REG_RMW(ah, AR_PHY_TPC_6_B2,
  4439. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4440. AR_PHY_TPC_6_ERROR_EST_MODE);
  4441. /*
  4442. * enable temperature compensation
  4443. * Need to use register names
  4444. */
  4445. if (frequency < 4000) {
  4446. temp_slope = eep->modalHeader2G.tempSlope;
  4447. } else {
  4448. if (AR_SREV_9550(ah)) {
  4449. t[0] = eep->base_ext1.tempslopextension[2];
  4450. t1[0] = eep->base_ext1.tempslopextension[3];
  4451. t2[0] = eep->base_ext1.tempslopextension[4];
  4452. f[0] = 5180;
  4453. t[1] = eep->modalHeader5G.tempSlope;
  4454. t1[1] = eep->base_ext1.tempslopextension[0];
  4455. t2[1] = eep->base_ext1.tempslopextension[1];
  4456. f[1] = 5500;
  4457. t[2] = eep->base_ext1.tempslopextension[5];
  4458. t1[2] = eep->base_ext1.tempslopextension[6];
  4459. t2[2] = eep->base_ext1.tempslopextension[7];
  4460. f[2] = 5785;
  4461. temp_slope = ar9003_hw_power_interpolate(frequency,
  4462. f, t, 3);
  4463. temp_slope1 = ar9003_hw_power_interpolate(frequency,
  4464. f, t1, 3);
  4465. temp_slope2 = ar9003_hw_power_interpolate(frequency,
  4466. f, t2, 3);
  4467. goto tempslope;
  4468. }
  4469. if ((eep->baseEepHeader.miscConfiguration & 0x20) != 0) {
  4470. for (i = 0; i < 8; i++) {
  4471. t[i] = eep->base_ext1.tempslopextension[i];
  4472. f[i] = FBIN2FREQ(eep->calFreqPier5G[i], 0);
  4473. }
  4474. temp_slope = ar9003_hw_power_interpolate((s32) frequency,
  4475. f, t, 8);
  4476. } else if (eep->base_ext2.tempSlopeLow != 0) {
  4477. t[0] = eep->base_ext2.tempSlopeLow;
  4478. f[0] = 5180;
  4479. t[1] = eep->modalHeader5G.tempSlope;
  4480. f[1] = 5500;
  4481. t[2] = eep->base_ext2.tempSlopeHigh;
  4482. f[2] = 5785;
  4483. temp_slope = ar9003_hw_power_interpolate((s32) frequency,
  4484. f, t, 3);
  4485. } else {
  4486. temp_slope = eep->modalHeader5G.tempSlope;
  4487. }
  4488. }
  4489. tempslope:
  4490. if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
  4491. u8 txmask = (eep->baseEepHeader.txrxMask & 0xf0) >> 4;
  4492. /*
  4493. * AR955x has tempSlope register for each chain.
  4494. * Check whether temp_compensation feature is enabled or not.
  4495. */
  4496. if (eep->baseEepHeader.featureEnable & 0x1) {
  4497. if (frequency < 4000) {
  4498. if (txmask & BIT(0))
  4499. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4500. AR_PHY_TPC_19_ALPHA_THERM,
  4501. eep->base_ext2.tempSlopeLow);
  4502. if (txmask & BIT(1))
  4503. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4504. AR_PHY_TPC_19_ALPHA_THERM,
  4505. temp_slope);
  4506. if (txmask & BIT(2))
  4507. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
  4508. AR_PHY_TPC_19_ALPHA_THERM,
  4509. eep->base_ext2.tempSlopeHigh);
  4510. } else {
  4511. if (txmask & BIT(0))
  4512. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4513. AR_PHY_TPC_19_ALPHA_THERM,
  4514. temp_slope);
  4515. if (txmask & BIT(1))
  4516. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4517. AR_PHY_TPC_19_ALPHA_THERM,
  4518. temp_slope1);
  4519. if (txmask & BIT(2))
  4520. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
  4521. AR_PHY_TPC_19_ALPHA_THERM,
  4522. temp_slope2);
  4523. }
  4524. } else {
  4525. /*
  4526. * If temp compensation is not enabled,
  4527. * set all registers to 0.
  4528. */
  4529. if (txmask & BIT(0))
  4530. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4531. AR_PHY_TPC_19_ALPHA_THERM, 0);
  4532. if (txmask & BIT(1))
  4533. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4534. AR_PHY_TPC_19_ALPHA_THERM, 0);
  4535. if (txmask & BIT(2))
  4536. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
  4537. AR_PHY_TPC_19_ALPHA_THERM, 0);
  4538. }
  4539. } else {
  4540. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4541. AR_PHY_TPC_19_ALPHA_THERM, temp_slope);
  4542. }
  4543. if (AR_SREV_9462_20_OR_LATER(ah))
  4544. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4545. AR_PHY_TPC_19_B1_ALPHA_THERM, temp_slope);
  4546. REG_RMW_FIELD(ah, AR_PHY_TPC_18, AR_PHY_TPC_18_THERM_CAL_VALUE,
  4547. temperature[0]);
  4548. }
  4549. /* Apply the recorded correction values. */
  4550. static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
  4551. {
  4552. int ichain, ipier, npier;
  4553. int mode;
  4554. int lfrequency[AR9300_MAX_CHAINS],
  4555. lcorrection[AR9300_MAX_CHAINS],
  4556. ltemperature[AR9300_MAX_CHAINS], lvoltage[AR9300_MAX_CHAINS],
  4557. lnf_cal[AR9300_MAX_CHAINS], lnf_pwr[AR9300_MAX_CHAINS];
  4558. int hfrequency[AR9300_MAX_CHAINS],
  4559. hcorrection[AR9300_MAX_CHAINS],
  4560. htemperature[AR9300_MAX_CHAINS], hvoltage[AR9300_MAX_CHAINS],
  4561. hnf_cal[AR9300_MAX_CHAINS], hnf_pwr[AR9300_MAX_CHAINS];
  4562. int fdiff;
  4563. int correction[AR9300_MAX_CHAINS],
  4564. voltage[AR9300_MAX_CHAINS], temperature[AR9300_MAX_CHAINS],
  4565. nf_cal[AR9300_MAX_CHAINS], nf_pwr[AR9300_MAX_CHAINS];
  4566. int pfrequency, pcorrection, ptemperature, pvoltage,
  4567. pnf_cal, pnf_pwr;
  4568. struct ath_common *common = ath9k_hw_common(ah);
  4569. mode = (frequency >= 4000);
  4570. if (mode)
  4571. npier = AR9300_NUM_5G_CAL_PIERS;
  4572. else
  4573. npier = AR9300_NUM_2G_CAL_PIERS;
  4574. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4575. lfrequency[ichain] = 0;
  4576. hfrequency[ichain] = 100000;
  4577. }
  4578. /* identify best lower and higher frequency calibration measurement */
  4579. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4580. for (ipier = 0; ipier < npier; ipier++) {
  4581. if (!ar9003_hw_cal_pier_get(ah, mode, ipier, ichain,
  4582. &pfrequency, &pcorrection,
  4583. &ptemperature, &pvoltage,
  4584. &pnf_cal, &pnf_pwr)) {
  4585. fdiff = frequency - pfrequency;
  4586. /*
  4587. * this measurement is higher than
  4588. * our desired frequency
  4589. */
  4590. if (fdiff <= 0) {
  4591. if (hfrequency[ichain] <= 0 ||
  4592. hfrequency[ichain] >= 100000 ||
  4593. fdiff >
  4594. (frequency - hfrequency[ichain])) {
  4595. /*
  4596. * new best higher
  4597. * frequency measurement
  4598. */
  4599. hfrequency[ichain] = pfrequency;
  4600. hcorrection[ichain] =
  4601. pcorrection;
  4602. htemperature[ichain] =
  4603. ptemperature;
  4604. hvoltage[ichain] = pvoltage;
  4605. hnf_cal[ichain] = pnf_cal;
  4606. hnf_pwr[ichain] = pnf_pwr;
  4607. }
  4608. }
  4609. if (fdiff >= 0) {
  4610. if (lfrequency[ichain] <= 0
  4611. || fdiff <
  4612. (frequency - lfrequency[ichain])) {
  4613. /*
  4614. * new best lower
  4615. * frequency measurement
  4616. */
  4617. lfrequency[ichain] = pfrequency;
  4618. lcorrection[ichain] =
  4619. pcorrection;
  4620. ltemperature[ichain] =
  4621. ptemperature;
  4622. lvoltage[ichain] = pvoltage;
  4623. lnf_cal[ichain] = pnf_cal;
  4624. lnf_pwr[ichain] = pnf_pwr;
  4625. }
  4626. }
  4627. }
  4628. }
  4629. }
  4630. /* interpolate */
  4631. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4632. ath_dbg(common, EEPROM,
  4633. "ch=%d f=%d low=%d %d h=%d %d n=%d %d p=%d %d\n",
  4634. ichain, frequency, lfrequency[ichain],
  4635. lcorrection[ichain], hfrequency[ichain],
  4636. hcorrection[ichain], lnf_cal[ichain],
  4637. hnf_cal[ichain], lnf_pwr[ichain],
  4638. hnf_pwr[ichain]);
  4639. /* they're the same, so just pick one */
  4640. if (hfrequency[ichain] == lfrequency[ichain]) {
  4641. correction[ichain] = lcorrection[ichain];
  4642. voltage[ichain] = lvoltage[ichain];
  4643. temperature[ichain] = ltemperature[ichain];
  4644. nf_cal[ichain] = lnf_cal[ichain];
  4645. nf_pwr[ichain] = lnf_pwr[ichain];
  4646. }
  4647. /* the low frequency is good */
  4648. else if (frequency - lfrequency[ichain] < 1000) {
  4649. /* so is the high frequency, interpolate */
  4650. if (hfrequency[ichain] - frequency < 1000) {
  4651. correction[ichain] = interpolate(frequency,
  4652. lfrequency[ichain],
  4653. hfrequency[ichain],
  4654. lcorrection[ichain],
  4655. hcorrection[ichain]);
  4656. temperature[ichain] = interpolate(frequency,
  4657. lfrequency[ichain],
  4658. hfrequency[ichain],
  4659. ltemperature[ichain],
  4660. htemperature[ichain]);
  4661. voltage[ichain] = interpolate(frequency,
  4662. lfrequency[ichain],
  4663. hfrequency[ichain],
  4664. lvoltage[ichain],
  4665. hvoltage[ichain]);
  4666. nf_cal[ichain] = interpolate(frequency,
  4667. lfrequency[ichain],
  4668. hfrequency[ichain],
  4669. lnf_cal[ichain],
  4670. hnf_cal[ichain]);
  4671. nf_pwr[ichain] = interpolate(frequency,
  4672. lfrequency[ichain],
  4673. hfrequency[ichain],
  4674. lnf_pwr[ichain],
  4675. hnf_pwr[ichain]);
  4676. }
  4677. /* only low is good, use it */
  4678. else {
  4679. correction[ichain] = lcorrection[ichain];
  4680. temperature[ichain] = ltemperature[ichain];
  4681. voltage[ichain] = lvoltage[ichain];
  4682. nf_cal[ichain] = lnf_cal[ichain];
  4683. nf_pwr[ichain] = lnf_pwr[ichain];
  4684. }
  4685. }
  4686. /* only high is good, use it */
  4687. else if (hfrequency[ichain] - frequency < 1000) {
  4688. correction[ichain] = hcorrection[ichain];
  4689. temperature[ichain] = htemperature[ichain];
  4690. voltage[ichain] = hvoltage[ichain];
  4691. nf_cal[ichain] = hnf_cal[ichain];
  4692. nf_pwr[ichain] = hnf_pwr[ichain];
  4693. } else { /* nothing is good, presume 0???? */
  4694. correction[ichain] = 0;
  4695. temperature[ichain] = 0;
  4696. voltage[ichain] = 0;
  4697. nf_cal[ichain] = 0;
  4698. nf_pwr[ichain] = 0;
  4699. }
  4700. }
  4701. ar9003_hw_power_control_override(ah, frequency, correction, voltage,
  4702. temperature);
  4703. ath_dbg(common, EEPROM,
  4704. "for frequency=%d, calibration correction = %d %d %d\n",
  4705. frequency, correction[0], correction[1], correction[2]);
  4706. /* Store calibrated noise floor values */
  4707. for (ichain = 0; ichain < AR5416_MAX_CHAINS; ichain++)
  4708. if (mode) {
  4709. ah->nf_5g.cal[ichain] = nf_cal[ichain];
  4710. ah->nf_5g.pwr[ichain] = nf_pwr[ichain];
  4711. } else {
  4712. ah->nf_2g.cal[ichain] = nf_cal[ichain];
  4713. ah->nf_2g.pwr[ichain] = nf_pwr[ichain];
  4714. }
  4715. return 0;
  4716. }
  4717. static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
  4718. int idx,
  4719. int edge,
  4720. bool is2GHz)
  4721. {
  4722. struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
  4723. struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
  4724. if (is2GHz)
  4725. return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]);
  4726. else
  4727. return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]);
  4728. }
  4729. static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
  4730. int idx,
  4731. unsigned int edge,
  4732. u16 freq,
  4733. bool is2GHz)
  4734. {
  4735. struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
  4736. struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
  4737. u8 *ctl_freqbin = is2GHz ?
  4738. &eep->ctl_freqbin_2G[idx][0] :
  4739. &eep->ctl_freqbin_5G[idx][0];
  4740. if (is2GHz) {
  4741. if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
  4742. CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1]))
  4743. return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]);
  4744. } else {
  4745. if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
  4746. CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1]))
  4747. return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
  4748. }
  4749. return MAX_RATE_POWER;
  4750. }
  4751. /*
  4752. * Find the maximum conformance test limit for the given channel and CTL info
  4753. */
  4754. static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
  4755. u16 freq, int idx, bool is2GHz)
  4756. {
  4757. u16 twiceMaxEdgePower = MAX_RATE_POWER;
  4758. u8 *ctl_freqbin = is2GHz ?
  4759. &eep->ctl_freqbin_2G[idx][0] :
  4760. &eep->ctl_freqbin_5G[idx][0];
  4761. u16 num_edges = is2GHz ?
  4762. AR9300_NUM_BAND_EDGES_2G : AR9300_NUM_BAND_EDGES_5G;
  4763. unsigned int edge;
  4764. /* Get the edge power */
  4765. for (edge = 0;
  4766. (edge < num_edges) && (ctl_freqbin[edge] != AR5416_BCHAN_UNUSED);
  4767. edge++) {
  4768. /*
  4769. * If there's an exact channel match or an inband flag set
  4770. * on the lower channel use the given rdEdgePower
  4771. */
  4772. if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) {
  4773. twiceMaxEdgePower =
  4774. ar9003_hw_get_direct_edge_power(eep, idx,
  4775. edge, is2GHz);
  4776. break;
  4777. } else if ((edge > 0) &&
  4778. (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge],
  4779. is2GHz))) {
  4780. twiceMaxEdgePower =
  4781. ar9003_hw_get_indirect_edge_power(eep, idx,
  4782. edge, freq,
  4783. is2GHz);
  4784. /*
  4785. * Leave loop - no more affecting edges possible in
  4786. * this monotonic increasing list
  4787. */
  4788. break;
  4789. }
  4790. }
  4791. if (is2GHz && !twiceMaxEdgePower)
  4792. twiceMaxEdgePower = 60;
  4793. return twiceMaxEdgePower;
  4794. }
  4795. static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
  4796. struct ath9k_channel *chan,
  4797. u8 *pPwrArray, u16 cfgCtl,
  4798. u8 antenna_reduction,
  4799. u16 powerLimit)
  4800. {
  4801. struct ath_common *common = ath9k_hw_common(ah);
  4802. struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
  4803. u16 twiceMaxEdgePower;
  4804. int i;
  4805. u16 scaledPower = 0, minCtlPower;
  4806. static const u16 ctlModesFor11a[] = {
  4807. CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
  4808. };
  4809. static const u16 ctlModesFor11g[] = {
  4810. CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT,
  4811. CTL_11G_EXT, CTL_2GHT40
  4812. };
  4813. u16 numCtlModes;
  4814. const u16 *pCtlMode;
  4815. u16 ctlMode, freq;
  4816. struct chan_centers centers;
  4817. u8 *ctlIndex;
  4818. u8 ctlNum;
  4819. u16 twiceMinEdgePower;
  4820. bool is2ghz = IS_CHAN_2GHZ(chan);
  4821. ath9k_hw_get_channel_centers(ah, chan, &centers);
  4822. scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
  4823. antenna_reduction);
  4824. if (is2ghz) {
  4825. /* Setup for CTL modes */
  4826. /* CTL_11B, CTL_11G, CTL_2GHT20 */
  4827. numCtlModes =
  4828. ARRAY_SIZE(ctlModesFor11g) -
  4829. SUB_NUM_CTL_MODES_AT_2G_40;
  4830. pCtlMode = ctlModesFor11g;
  4831. if (IS_CHAN_HT40(chan))
  4832. /* All 2G CTL's */
  4833. numCtlModes = ARRAY_SIZE(ctlModesFor11g);
  4834. } else {
  4835. /* Setup for CTL modes */
  4836. /* CTL_11A, CTL_5GHT20 */
  4837. numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
  4838. SUB_NUM_CTL_MODES_AT_5G_40;
  4839. pCtlMode = ctlModesFor11a;
  4840. if (IS_CHAN_HT40(chan))
  4841. /* All 5G CTL's */
  4842. numCtlModes = ARRAY_SIZE(ctlModesFor11a);
  4843. }
  4844. /*
  4845. * For MIMO, need to apply regulatory caps individually across
  4846. * dynamically running modes: CCK, OFDM, HT20, HT40
  4847. *
  4848. * The outer loop walks through each possible applicable runtime mode.
  4849. * The inner loop walks through each ctlIndex entry in EEPROM.
  4850. * The ctl value is encoded as [7:4] == test group, [3:0] == test mode.
  4851. */
  4852. for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
  4853. bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
  4854. (pCtlMode[ctlMode] == CTL_2GHT40);
  4855. if (isHt40CtlMode)
  4856. freq = centers.synth_center;
  4857. else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
  4858. freq = centers.ext_center;
  4859. else
  4860. freq = centers.ctl_center;
  4861. ath_dbg(common, REGULATORY,
  4862. "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, EXT_ADDITIVE %d\n",
  4863. ctlMode, numCtlModes, isHt40CtlMode,
  4864. (pCtlMode[ctlMode] & EXT_ADDITIVE));
  4865. /* walk through each CTL index stored in EEPROM */
  4866. if (is2ghz) {
  4867. ctlIndex = pEepData->ctlIndex_2G;
  4868. ctlNum = AR9300_NUM_CTLS_2G;
  4869. } else {
  4870. ctlIndex = pEepData->ctlIndex_5G;
  4871. ctlNum = AR9300_NUM_CTLS_5G;
  4872. }
  4873. twiceMaxEdgePower = MAX_RATE_POWER;
  4874. for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) {
  4875. ath_dbg(common, REGULATORY,
  4876. "LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n",
  4877. i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i],
  4878. chan->channel);
  4879. /*
  4880. * compare test group from regulatory
  4881. * channel list with test mode from pCtlMode
  4882. * list
  4883. */
  4884. if ((((cfgCtl & ~CTL_MODE_M) |
  4885. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  4886. ctlIndex[i]) ||
  4887. (((cfgCtl & ~CTL_MODE_M) |
  4888. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  4889. ((ctlIndex[i] & CTL_MODE_M) |
  4890. SD_NO_CTL))) {
  4891. twiceMinEdgePower =
  4892. ar9003_hw_get_max_edge_power(pEepData,
  4893. freq, i,
  4894. is2ghz);
  4895. if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL)
  4896. /*
  4897. * Find the minimum of all CTL
  4898. * edge powers that apply to
  4899. * this channel
  4900. */
  4901. twiceMaxEdgePower =
  4902. min(twiceMaxEdgePower,
  4903. twiceMinEdgePower);
  4904. else {
  4905. /* specific */
  4906. twiceMaxEdgePower = twiceMinEdgePower;
  4907. break;
  4908. }
  4909. }
  4910. }
  4911. minCtlPower = (u8)min(twiceMaxEdgePower, scaledPower);
  4912. ath_dbg(common, REGULATORY,
  4913. "SEL-Min ctlMode %d pCtlMode %d 2xMaxEdge %d sP %d minCtlPwr %d\n",
  4914. ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
  4915. scaledPower, minCtlPower);
  4916. /* Apply ctl mode to correct target power set */
  4917. switch (pCtlMode[ctlMode]) {
  4918. case CTL_11B:
  4919. for (i = ALL_TARGET_LEGACY_1L_5L;
  4920. i <= ALL_TARGET_LEGACY_11S; i++)
  4921. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4922. minCtlPower);
  4923. break;
  4924. case CTL_11A:
  4925. case CTL_11G:
  4926. for (i = ALL_TARGET_LEGACY_6_24;
  4927. i <= ALL_TARGET_LEGACY_54; i++)
  4928. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4929. minCtlPower);
  4930. break;
  4931. case CTL_5GHT20:
  4932. case CTL_2GHT20:
  4933. for (i = ALL_TARGET_HT20_0_8_16;
  4934. i <= ALL_TARGET_HT20_23; i++) {
  4935. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4936. minCtlPower);
  4937. if (ath9k_hw_mci_is_enabled(ah))
  4938. pPwrArray[i] =
  4939. (u8)min((u16)pPwrArray[i],
  4940. ar9003_mci_get_max_txpower(ah,
  4941. pCtlMode[ctlMode]));
  4942. }
  4943. break;
  4944. case CTL_5GHT40:
  4945. case CTL_2GHT40:
  4946. for (i = ALL_TARGET_HT40_0_8_16;
  4947. i <= ALL_TARGET_HT40_23; i++) {
  4948. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4949. minCtlPower);
  4950. if (ath9k_hw_mci_is_enabled(ah))
  4951. pPwrArray[i] =
  4952. (u8)min((u16)pPwrArray[i],
  4953. ar9003_mci_get_max_txpower(ah,
  4954. pCtlMode[ctlMode]));
  4955. }
  4956. break;
  4957. default:
  4958. break;
  4959. }
  4960. } /* end ctl mode checking */
  4961. }
  4962. static inline u8 mcsidx_to_tgtpwridx(unsigned int mcs_idx, u8 base_pwridx)
  4963. {
  4964. u8 mod_idx = mcs_idx % 8;
  4965. if (mod_idx <= 3)
  4966. return mod_idx ? (base_pwridx + 1) : base_pwridx;
  4967. else
  4968. return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2;
  4969. }
  4970. static void ar9003_paprd_set_txpower(struct ath_hw *ah,
  4971. struct ath9k_channel *chan,
  4972. u8 *targetPowerValT2)
  4973. {
  4974. int i;
  4975. if (!ar9003_is_paprd_enabled(ah))
  4976. return;
  4977. if (IS_CHAN_HT40(chan))
  4978. i = ALL_TARGET_HT40_7;
  4979. else
  4980. i = ALL_TARGET_HT20_7;
  4981. if (IS_CHAN_2GHZ(chan)) {
  4982. if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) &&
  4983. !AR_SREV_9462(ah) && !AR_SREV_9565(ah)) {
  4984. if (IS_CHAN_HT40(chan))
  4985. i = ALL_TARGET_HT40_0_8_16;
  4986. else
  4987. i = ALL_TARGET_HT20_0_8_16;
  4988. }
  4989. }
  4990. ah->paprd_target_power = targetPowerValT2[i];
  4991. }
  4992. static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
  4993. struct ath9k_channel *chan, u16 cfgCtl,
  4994. u8 twiceAntennaReduction,
  4995. u8 powerLimit, bool test)
  4996. {
  4997. struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
  4998. struct ath_common *common = ath9k_hw_common(ah);
  4999. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  5000. struct ar9300_modal_eep_header *modal_hdr;
  5001. u8 targetPowerValT2[ar9300RateSize];
  5002. u8 target_power_val_t2_eep[ar9300RateSize];
  5003. u8 targetPowerValT2_tpc[ar9300RateSize];
  5004. unsigned int i = 0, paprd_scale_factor = 0;
  5005. u8 pwr_idx, min_pwridx = 0;
  5006. memset(targetPowerValT2, 0 , sizeof(targetPowerValT2));
  5007. /*
  5008. * Get target powers from EEPROM - our baseline for TX Power
  5009. */
  5010. ar9003_hw_get_target_power_eeprom(ah, chan, targetPowerValT2);
  5011. if (ar9003_is_paprd_enabled(ah)) {
  5012. if (IS_CHAN_2GHZ(chan))
  5013. modal_hdr = &eep->modalHeader2G;
  5014. else
  5015. modal_hdr = &eep->modalHeader5G;
  5016. ah->paprd_ratemask =
  5017. le32_to_cpu(modal_hdr->papdRateMaskHt20) &
  5018. AR9300_PAPRD_RATE_MASK;
  5019. ah->paprd_ratemask_ht40 =
  5020. le32_to_cpu(modal_hdr->papdRateMaskHt40) &
  5021. AR9300_PAPRD_RATE_MASK;
  5022. paprd_scale_factor = ar9003_get_paprd_scale_factor(ah, chan);
  5023. min_pwridx = IS_CHAN_HT40(chan) ? ALL_TARGET_HT40_0_8_16 :
  5024. ALL_TARGET_HT20_0_8_16;
  5025. if (!ah->paprd_table_write_done) {
  5026. memcpy(target_power_val_t2_eep, targetPowerValT2,
  5027. sizeof(targetPowerValT2));
  5028. for (i = 0; i < 24; i++) {
  5029. pwr_idx = mcsidx_to_tgtpwridx(i, min_pwridx);
  5030. if (ah->paprd_ratemask & (1 << i)) {
  5031. if (targetPowerValT2[pwr_idx] &&
  5032. targetPowerValT2[pwr_idx] ==
  5033. target_power_val_t2_eep[pwr_idx])
  5034. targetPowerValT2[pwr_idx] -=
  5035. paprd_scale_factor;
  5036. }
  5037. }
  5038. }
  5039. memcpy(target_power_val_t2_eep, targetPowerValT2,
  5040. sizeof(targetPowerValT2));
  5041. }
  5042. ar9003_hw_set_power_per_rate_table(ah, chan,
  5043. targetPowerValT2, cfgCtl,
  5044. twiceAntennaReduction,
  5045. powerLimit);
  5046. memcpy(targetPowerValT2_tpc, targetPowerValT2,
  5047. sizeof(targetPowerValT2));
  5048. if (ar9003_is_paprd_enabled(ah)) {
  5049. for (i = 0; i < ar9300RateSize; i++) {
  5050. if ((ah->paprd_ratemask & (1 << i)) &&
  5051. (abs(targetPowerValT2[i] -
  5052. target_power_val_t2_eep[i]) >
  5053. paprd_scale_factor)) {
  5054. ah->paprd_ratemask &= ~(1 << i);
  5055. ath_dbg(common, EEPROM,
  5056. "paprd disabled for mcs %d\n", i);
  5057. }
  5058. }
  5059. }
  5060. regulatory->max_power_level = 0;
  5061. for (i = 0; i < ar9300RateSize; i++) {
  5062. if (targetPowerValT2[i] > regulatory->max_power_level)
  5063. regulatory->max_power_level = targetPowerValT2[i];
  5064. }
  5065. ath9k_hw_update_regulatory_maxpower(ah);
  5066. if (test)
  5067. return;
  5068. for (i = 0; i < ar9300RateSize; i++) {
  5069. ath_dbg(common, REGULATORY, "TPC[%02d] 0x%08x\n",
  5070. i, targetPowerValT2[i]);
  5071. }
  5072. /* Write target power array to registers */
  5073. ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
  5074. ar9003_hw_calibration_apply(ah, chan->channel);
  5075. ar9003_paprd_set_txpower(ah, chan, targetPowerValT2);
  5076. ar9003_hw_selfgen_tpc_txpower(ah, chan, targetPowerValT2);
  5077. /* TPC initializations */
  5078. if (ah->tpc_enabled) {
  5079. u32 val;
  5080. ar9003_hw_init_rate_txpower(ah, targetPowerValT2_tpc, chan);
  5081. /* Enable TPC */
  5082. REG_WRITE(ah, AR_PHY_PWRTX_MAX,
  5083. AR_PHY_POWER_TX_RATE_MAX_TPC_ENABLE);
  5084. /* Disable per chain power reduction */
  5085. val = REG_READ(ah, AR_PHY_POWER_TX_SUB);
  5086. if (AR_SREV_9340(ah))
  5087. REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
  5088. val & 0xFFFFFFC0);
  5089. else
  5090. REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
  5091. val & 0xFFFFF000);
  5092. } else {
  5093. /* Disable TPC */
  5094. REG_WRITE(ah, AR_PHY_PWRTX_MAX, 0);
  5095. }
  5096. }
  5097. static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah,
  5098. u16 i, bool is2GHz)
  5099. {
  5100. return AR_NO_SPUR;
  5101. }
  5102. s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah)
  5103. {
  5104. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  5105. return (eep->baseEepHeader.txrxgain >> 4) & 0xf; /* bits 7:4 */
  5106. }
  5107. s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah)
  5108. {
  5109. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  5110. return (eep->baseEepHeader.txrxgain) & 0xf; /* bits 3:0 */
  5111. }
  5112. u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is2ghz)
  5113. {
  5114. return ar9003_modal_header(ah, is2ghz)->spurChans;
  5115. }
  5116. unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,
  5117. struct ath9k_channel *chan)
  5118. {
  5119. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  5120. if (IS_CHAN_2GHZ(chan))
  5121. return MS(le32_to_cpu(eep->modalHeader2G.papdRateMaskHt20),
  5122. AR9300_PAPRD_SCALE_1);
  5123. else {
  5124. if (chan->channel >= 5700)
  5125. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20),
  5126. AR9300_PAPRD_SCALE_1);
  5127. else if (chan->channel >= 5400)
  5128. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
  5129. AR9300_PAPRD_SCALE_2);
  5130. else
  5131. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
  5132. AR9300_PAPRD_SCALE_1);
  5133. }
  5134. }
  5135. static u8 ar9003_get_eepmisc(struct ath_hw *ah)
  5136. {
  5137. return ah->eeprom.map4k.baseEepHeader.eepMisc;
  5138. }
  5139. const struct eeprom_ops eep_ar9300_ops = {
  5140. .check_eeprom = ath9k_hw_ar9300_check_eeprom,
  5141. .get_eeprom = ath9k_hw_ar9300_get_eeprom,
  5142. .fill_eeprom = ath9k_hw_ar9300_fill_eeprom,
  5143. .dump_eeprom = ath9k_hw_ar9003_dump_eeprom,
  5144. .get_eeprom_ver = ath9k_hw_ar9300_get_eeprom_ver,
  5145. .get_eeprom_rev = ath9k_hw_ar9300_get_eeprom_rev,
  5146. .set_board_values = ath9k_hw_ar9300_set_board_values,
  5147. .set_addac = ath9k_hw_ar9300_set_addac,
  5148. .set_txpower = ath9k_hw_ar9300_set_txpower,
  5149. .get_spur_channel = ath9k_hw_ar9300_get_spur_channel,
  5150. .get_eepmisc = ar9003_get_eepmisc
  5151. };