ar9003_hw.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "hw.h"
  17. #include "ar9003_mac.h"
  18. #include "ar9003_2p2_initvals.h"
  19. #include "ar9485_initvals.h"
  20. #include "ar9340_initvals.h"
  21. #include "ar9330_1p1_initvals.h"
  22. #include "ar9330_1p2_initvals.h"
  23. #include "ar955x_1p0_initvals.h"
  24. #include "ar9580_1p0_initvals.h"
  25. #include "ar9462_2p0_initvals.h"
  26. /* General hardware code for the AR9003 hadware family */
  27. /*
  28. * The AR9003 family uses a new INI format (pre, core, post
  29. * arrays per subsystem). This provides support for the
  30. * AR9003 2.2 chipsets.
  31. */
  32. static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
  33. {
  34. #define PCIE_PLL_ON_CREQ_DIS_L1_2P0 \
  35. ar9462_pciephy_pll_on_clkreq_disable_L1_2p0
  36. #define AR9462_BB_CTX_COEFJ(x) \
  37. ar9462_##x##_baseband_core_txfir_coeff_japan_2484
  38. #define AR9462_BBC_TXIFR_COEFFJ \
  39. ar9462_2p0_baseband_core_txfir_coeff_japan_2484
  40. if (AR_SREV_9330_11(ah)) {
  41. /* mac */
  42. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  43. ar9331_1p1_mac_core);
  44. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  45. ar9331_1p1_mac_postamble);
  46. /* bb */
  47. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  48. ar9331_1p1_baseband_core);
  49. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  50. ar9331_1p1_baseband_postamble);
  51. /* radio */
  52. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  53. ar9331_1p1_radio_core);
  54. /* soc */
  55. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  56. ar9331_1p1_soc_preamble);
  57. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  58. ar9331_1p1_soc_postamble);
  59. /* rx/tx gain */
  60. INIT_INI_ARRAY(&ah->iniModesRxGain,
  61. ar9331_common_rx_gain_1p1);
  62. INIT_INI_ARRAY(&ah->iniModesTxGain,
  63. ar9331_modes_lowest_ob_db_tx_gain_1p1);
  64. /* additional clock settings */
  65. if (ah->is_clk_25mhz)
  66. INIT_INI_ARRAY(&ah->iniAdditional,
  67. ar9331_1p1_xtal_25M);
  68. else
  69. INIT_INI_ARRAY(&ah->iniAdditional,
  70. ar9331_1p1_xtal_40M);
  71. } else if (AR_SREV_9330_12(ah)) {
  72. /* mac */
  73. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  74. ar9331_1p2_mac_core);
  75. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  76. ar9331_1p2_mac_postamble);
  77. /* bb */
  78. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  79. ar9331_1p2_baseband_core);
  80. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  81. ar9331_1p2_baseband_postamble);
  82. /* radio */
  83. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  84. ar9331_1p2_radio_core);
  85. /* soc */
  86. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  87. ar9331_1p2_soc_preamble);
  88. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  89. ar9331_1p2_soc_postamble);
  90. /* rx/tx gain */
  91. INIT_INI_ARRAY(&ah->iniModesRxGain,
  92. ar9331_common_rx_gain_1p2);
  93. INIT_INI_ARRAY(&ah->iniModesTxGain,
  94. ar9331_modes_lowest_ob_db_tx_gain_1p2);
  95. /* additional clock settings */
  96. if (ah->is_clk_25mhz)
  97. INIT_INI_ARRAY(&ah->iniAdditional,
  98. ar9331_1p2_xtal_25M);
  99. else
  100. INIT_INI_ARRAY(&ah->iniAdditional,
  101. ar9331_1p2_xtal_40M);
  102. } else if (AR_SREV_9340(ah)) {
  103. /* mac */
  104. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  105. ar9340_1p0_mac_core);
  106. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  107. ar9340_1p0_mac_postamble);
  108. /* bb */
  109. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  110. ar9340_1p0_baseband_core);
  111. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  112. ar9340_1p0_baseband_postamble);
  113. /* radio */
  114. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  115. ar9340_1p0_radio_core);
  116. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  117. ar9340_1p0_radio_postamble);
  118. /* soc */
  119. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  120. ar9340_1p0_soc_preamble);
  121. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  122. ar9340_1p0_soc_postamble);
  123. /* rx/tx gain */
  124. INIT_INI_ARRAY(&ah->iniModesRxGain,
  125. ar9340Common_wo_xlna_rx_gain_table_1p0);
  126. INIT_INI_ARRAY(&ah->iniModesTxGain,
  127. ar9340Modes_high_ob_db_tx_gain_table_1p0);
  128. INIT_INI_ARRAY(&ah->iniModesFastClock,
  129. ar9340Modes_fast_clock_1p0);
  130. if (!ah->is_clk_25mhz)
  131. INIT_INI_ARRAY(&ah->iniAdditional,
  132. ar9340_1p0_radio_core_40M);
  133. } else if (AR_SREV_9485_11(ah)) {
  134. /* mac */
  135. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  136. ar9485_1_1_mac_core);
  137. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  138. ar9485_1_1_mac_postamble);
  139. /* bb */
  140. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1);
  141. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  142. ar9485_1_1_baseband_core);
  143. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  144. ar9485_1_1_baseband_postamble);
  145. /* radio */
  146. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  147. ar9485_1_1_radio_core);
  148. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  149. ar9485_1_1_radio_postamble);
  150. /* soc */
  151. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  152. ar9485_1_1_soc_preamble);
  153. /* rx/tx gain */
  154. INIT_INI_ARRAY(&ah->iniModesRxGain,
  155. ar9485Common_wo_xlna_rx_gain_1_1);
  156. INIT_INI_ARRAY(&ah->iniModesTxGain,
  157. ar9485_modes_lowest_ob_db_tx_gain_1_1);
  158. /* Load PCIE SERDES settings from INI */
  159. /* Awake Setting */
  160. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  161. ar9485_1_1_pcie_phy_clkreq_disable_L1);
  162. /* Sleep Setting */
  163. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  164. ar9485_1_1_pcie_phy_clkreq_disable_L1);
  165. } else if (AR_SREV_9462_20(ah)) {
  166. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core);
  167. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  168. ar9462_2p0_mac_postamble);
  169. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  170. ar9462_2p0_baseband_core);
  171. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  172. ar9462_2p0_baseband_postamble);
  173. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  174. ar9462_2p0_radio_core);
  175. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  176. ar9462_2p0_radio_postamble);
  177. INIT_INI_ARRAY(&ah->ini_radio_post_sys2ant,
  178. ar9462_2p0_radio_postamble_sys2ant);
  179. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  180. ar9462_2p0_soc_preamble);
  181. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  182. ar9462_2p0_soc_postamble);
  183. INIT_INI_ARRAY(&ah->iniModesRxGain,
  184. ar9462_common_rx_gain_table_2p0);
  185. /* Awake -> Sleep Setting */
  186. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  187. PCIE_PLL_ON_CREQ_DIS_L1_2P0);
  188. /* Sleep -> Awake Setting */
  189. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  190. PCIE_PLL_ON_CREQ_DIS_L1_2P0);
  191. /* Fast clock modal settings */
  192. INIT_INI_ARRAY(&ah->iniModesFastClock,
  193. ar9462_modes_fast_clock_2p0);
  194. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  195. AR9462_BB_CTX_COEFJ(2p0));
  196. INIT_INI_ARRAY(&ah->ini_japan2484, AR9462_BBC_TXIFR_COEFFJ);
  197. } else if (AR_SREV_9550(ah)) {
  198. /* mac */
  199. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  200. ar955x_1p0_mac_core);
  201. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  202. ar955x_1p0_mac_postamble);
  203. /* bb */
  204. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  205. ar955x_1p0_baseband_core);
  206. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  207. ar955x_1p0_baseband_postamble);
  208. /* radio */
  209. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  210. ar955x_1p0_radio_core);
  211. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  212. ar955x_1p0_radio_postamble);
  213. /* soc */
  214. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  215. ar955x_1p0_soc_preamble);
  216. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  217. ar955x_1p0_soc_postamble);
  218. /* rx/tx gain */
  219. INIT_INI_ARRAY(&ah->iniModesRxGain,
  220. ar955x_1p0_common_wo_xlna_rx_gain_table);
  221. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  222. ar955x_1p0_common_wo_xlna_rx_gain_bounds);
  223. INIT_INI_ARRAY(&ah->iniModesTxGain,
  224. ar955x_1p0_modes_xpa_tx_gain_table);
  225. /* Fast clock modal settings */
  226. INIT_INI_ARRAY(&ah->iniModesFastClock,
  227. ar955x_1p0_modes_fast_clock);
  228. } else if (AR_SREV_9580(ah)) {
  229. /* mac */
  230. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  231. ar9580_1p0_mac_core);
  232. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  233. ar9580_1p0_mac_postamble);
  234. /* bb */
  235. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  236. ar9580_1p0_baseband_core);
  237. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  238. ar9580_1p0_baseband_postamble);
  239. /* radio */
  240. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  241. ar9580_1p0_radio_core);
  242. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  243. ar9580_1p0_radio_postamble);
  244. /* soc */
  245. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  246. ar9580_1p0_soc_preamble);
  247. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  248. ar9580_1p0_soc_postamble);
  249. /* rx/tx gain */
  250. INIT_INI_ARRAY(&ah->iniModesRxGain,
  251. ar9580_1p0_rx_gain_table);
  252. INIT_INI_ARRAY(&ah->iniModesTxGain,
  253. ar9580_1p0_low_ob_db_tx_gain_table);
  254. INIT_INI_ARRAY(&ah->iniModesFastClock,
  255. ar9580_1p0_modes_fast_clock);
  256. } else {
  257. /* mac */
  258. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  259. ar9300_2p2_mac_core);
  260. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  261. ar9300_2p2_mac_postamble);
  262. /* bb */
  263. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  264. ar9300_2p2_baseband_core);
  265. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  266. ar9300_2p2_baseband_postamble);
  267. /* radio */
  268. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  269. ar9300_2p2_radio_core);
  270. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  271. ar9300_2p2_radio_postamble);
  272. /* soc */
  273. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  274. ar9300_2p2_soc_preamble);
  275. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  276. ar9300_2p2_soc_postamble);
  277. /* rx/tx gain */
  278. INIT_INI_ARRAY(&ah->iniModesRxGain,
  279. ar9300Common_rx_gain_table_2p2);
  280. INIT_INI_ARRAY(&ah->iniModesTxGain,
  281. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  282. /* Load PCIE SERDES settings from INI */
  283. /* Awake Setting */
  284. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  285. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  286. /* Sleep Setting */
  287. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  288. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  289. /* Fast clock modal settings */
  290. INIT_INI_ARRAY(&ah->iniModesFastClock,
  291. ar9300Modes_fast_clock_2p2);
  292. }
  293. }
  294. static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
  295. {
  296. if (AR_SREV_9330_12(ah))
  297. INIT_INI_ARRAY(&ah->iniModesTxGain,
  298. ar9331_modes_lowest_ob_db_tx_gain_1p2);
  299. else if (AR_SREV_9330_11(ah))
  300. INIT_INI_ARRAY(&ah->iniModesTxGain,
  301. ar9331_modes_lowest_ob_db_tx_gain_1p1);
  302. else if (AR_SREV_9340(ah))
  303. INIT_INI_ARRAY(&ah->iniModesTxGain,
  304. ar9340Modes_lowest_ob_db_tx_gain_table_1p0);
  305. else if (AR_SREV_9485_11(ah))
  306. INIT_INI_ARRAY(&ah->iniModesTxGain,
  307. ar9485_modes_lowest_ob_db_tx_gain_1_1);
  308. else if (AR_SREV_9550(ah))
  309. INIT_INI_ARRAY(&ah->iniModesTxGain,
  310. ar955x_1p0_modes_xpa_tx_gain_table);
  311. else if (AR_SREV_9580(ah))
  312. INIT_INI_ARRAY(&ah->iniModesTxGain,
  313. ar9580_1p0_lowest_ob_db_tx_gain_table);
  314. else if (AR_SREV_9462_20(ah))
  315. INIT_INI_ARRAY(&ah->iniModesTxGain,
  316. ar9462_modes_low_ob_db_tx_gain_table_2p0);
  317. else
  318. INIT_INI_ARRAY(&ah->iniModesTxGain,
  319. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  320. }
  321. static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
  322. {
  323. if (AR_SREV_9330_12(ah))
  324. INIT_INI_ARRAY(&ah->iniModesTxGain,
  325. ar9331_modes_high_ob_db_tx_gain_1p2);
  326. else if (AR_SREV_9330_11(ah))
  327. INIT_INI_ARRAY(&ah->iniModesTxGain,
  328. ar9331_modes_high_ob_db_tx_gain_1p1);
  329. else if (AR_SREV_9340(ah))
  330. INIT_INI_ARRAY(&ah->iniModesTxGain,
  331. ar9340Modes_high_ob_db_tx_gain_table_1p0);
  332. else if (AR_SREV_9485_11(ah))
  333. INIT_INI_ARRAY(&ah->iniModesTxGain,
  334. ar9485Modes_high_ob_db_tx_gain_1_1);
  335. else if (AR_SREV_9580(ah))
  336. INIT_INI_ARRAY(&ah->iniModesTxGain,
  337. ar9580_1p0_high_ob_db_tx_gain_table);
  338. else if (AR_SREV_9550(ah))
  339. INIT_INI_ARRAY(&ah->iniModesTxGain,
  340. ar955x_1p0_modes_no_xpa_tx_gain_table);
  341. else if (AR_SREV_9462_20(ah))
  342. INIT_INI_ARRAY(&ah->iniModesTxGain,
  343. ar9462_modes_high_ob_db_tx_gain_table_2p0);
  344. else
  345. INIT_INI_ARRAY(&ah->iniModesTxGain,
  346. ar9300Modes_high_ob_db_tx_gain_table_2p2);
  347. }
  348. static void ar9003_tx_gain_table_mode2(struct ath_hw *ah)
  349. {
  350. if (AR_SREV_9330_12(ah))
  351. INIT_INI_ARRAY(&ah->iniModesTxGain,
  352. ar9331_modes_low_ob_db_tx_gain_1p2);
  353. else if (AR_SREV_9330_11(ah))
  354. INIT_INI_ARRAY(&ah->iniModesTxGain,
  355. ar9331_modes_low_ob_db_tx_gain_1p1);
  356. else if (AR_SREV_9340(ah))
  357. INIT_INI_ARRAY(&ah->iniModesTxGain,
  358. ar9340Modes_low_ob_db_tx_gain_table_1p0);
  359. else if (AR_SREV_9485_11(ah))
  360. INIT_INI_ARRAY(&ah->iniModesTxGain,
  361. ar9485Modes_low_ob_db_tx_gain_1_1);
  362. else if (AR_SREV_9580(ah))
  363. INIT_INI_ARRAY(&ah->iniModesTxGain,
  364. ar9580_1p0_low_ob_db_tx_gain_table);
  365. else
  366. INIT_INI_ARRAY(&ah->iniModesTxGain,
  367. ar9300Modes_low_ob_db_tx_gain_table_2p2);
  368. }
  369. static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
  370. {
  371. if (AR_SREV_9330_12(ah))
  372. INIT_INI_ARRAY(&ah->iniModesTxGain,
  373. ar9331_modes_high_power_tx_gain_1p2);
  374. else if (AR_SREV_9330_11(ah))
  375. INIT_INI_ARRAY(&ah->iniModesTxGain,
  376. ar9331_modes_high_power_tx_gain_1p1);
  377. else if (AR_SREV_9340(ah))
  378. INIT_INI_ARRAY(&ah->iniModesTxGain,
  379. ar9340Modes_high_power_tx_gain_table_1p0);
  380. else if (AR_SREV_9485_11(ah))
  381. INIT_INI_ARRAY(&ah->iniModesTxGain,
  382. ar9485Modes_high_power_tx_gain_1_1);
  383. else if (AR_SREV_9580(ah))
  384. INIT_INI_ARRAY(&ah->iniModesTxGain,
  385. ar9580_1p0_high_power_tx_gain_table);
  386. else
  387. INIT_INI_ARRAY(&ah->iniModesTxGain,
  388. ar9300Modes_high_power_tx_gain_table_2p2);
  389. }
  390. static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
  391. {
  392. if (AR_SREV_9340(ah))
  393. INIT_INI_ARRAY(&ah->iniModesTxGain,
  394. ar9340Modes_mixed_ob_db_tx_gain_table_1p0);
  395. else if (AR_SREV_9580(ah))
  396. INIT_INI_ARRAY(&ah->iniModesTxGain,
  397. ar9580_1p0_mixed_ob_db_tx_gain_table);
  398. }
  399. static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
  400. {
  401. switch (ar9003_hw_get_tx_gain_idx(ah)) {
  402. case 0:
  403. default:
  404. ar9003_tx_gain_table_mode0(ah);
  405. break;
  406. case 1:
  407. ar9003_tx_gain_table_mode1(ah);
  408. break;
  409. case 2:
  410. ar9003_tx_gain_table_mode2(ah);
  411. break;
  412. case 3:
  413. ar9003_tx_gain_table_mode3(ah);
  414. break;
  415. case 4:
  416. ar9003_tx_gain_table_mode4(ah);
  417. break;
  418. }
  419. }
  420. static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
  421. {
  422. if (AR_SREV_9330_12(ah))
  423. INIT_INI_ARRAY(&ah->iniModesRxGain,
  424. ar9331_common_rx_gain_1p2);
  425. else if (AR_SREV_9330_11(ah))
  426. INIT_INI_ARRAY(&ah->iniModesRxGain,
  427. ar9331_common_rx_gain_1p1);
  428. else if (AR_SREV_9340(ah))
  429. INIT_INI_ARRAY(&ah->iniModesRxGain,
  430. ar9340Common_rx_gain_table_1p0);
  431. else if (AR_SREV_9485_11(ah))
  432. INIT_INI_ARRAY(&ah->iniModesRxGain,
  433. ar9485Common_wo_xlna_rx_gain_1_1);
  434. else if (AR_SREV_9550(ah)) {
  435. INIT_INI_ARRAY(&ah->iniModesRxGain,
  436. ar955x_1p0_common_rx_gain_table);
  437. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  438. ar955x_1p0_common_rx_gain_bounds);
  439. } else if (AR_SREV_9580(ah))
  440. INIT_INI_ARRAY(&ah->iniModesRxGain,
  441. ar9580_1p0_rx_gain_table);
  442. else if (AR_SREV_9462_20(ah))
  443. INIT_INI_ARRAY(&ah->iniModesRxGain,
  444. ar9462_common_rx_gain_table_2p0);
  445. else
  446. INIT_INI_ARRAY(&ah->iniModesRxGain,
  447. ar9300Common_rx_gain_table_2p2);
  448. }
  449. static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
  450. {
  451. if (AR_SREV_9330_12(ah))
  452. INIT_INI_ARRAY(&ah->iniModesRxGain,
  453. ar9331_common_wo_xlna_rx_gain_1p2);
  454. else if (AR_SREV_9330_11(ah))
  455. INIT_INI_ARRAY(&ah->iniModesRxGain,
  456. ar9331_common_wo_xlna_rx_gain_1p1);
  457. else if (AR_SREV_9340(ah))
  458. INIT_INI_ARRAY(&ah->iniModesRxGain,
  459. ar9340Common_wo_xlna_rx_gain_table_1p0);
  460. else if (AR_SREV_9485_11(ah))
  461. INIT_INI_ARRAY(&ah->iniModesRxGain,
  462. ar9485Common_wo_xlna_rx_gain_1_1);
  463. else if (AR_SREV_9462_20(ah))
  464. INIT_INI_ARRAY(&ah->iniModesRxGain,
  465. ar9462_common_wo_xlna_rx_gain_table_2p0);
  466. else if (AR_SREV_9550(ah)) {
  467. INIT_INI_ARRAY(&ah->iniModesRxGain,
  468. ar955x_1p0_common_wo_xlna_rx_gain_table);
  469. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  470. ar955x_1p0_common_wo_xlna_rx_gain_bounds);
  471. } else if (AR_SREV_9580(ah))
  472. INIT_INI_ARRAY(&ah->iniModesRxGain,
  473. ar9580_1p0_wo_xlna_rx_gain_table);
  474. else
  475. INIT_INI_ARRAY(&ah->iniModesRxGain,
  476. ar9300Common_wo_xlna_rx_gain_table_2p2);
  477. }
  478. static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
  479. {
  480. if (AR_SREV_9462_20(ah))
  481. INIT_INI_ARRAY(&ah->iniModesRxGain,
  482. ar9462_common_mixed_rx_gain_table_2p0);
  483. }
  484. static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
  485. {
  486. switch (ar9003_hw_get_rx_gain_idx(ah)) {
  487. case 0:
  488. default:
  489. ar9003_rx_gain_table_mode0(ah);
  490. break;
  491. case 1:
  492. ar9003_rx_gain_table_mode1(ah);
  493. break;
  494. case 2:
  495. ar9003_rx_gain_table_mode2(ah);
  496. break;
  497. }
  498. }
  499. /* set gain table pointers according to values read from the eeprom */
  500. static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
  501. {
  502. ar9003_tx_gain_table_apply(ah);
  503. ar9003_rx_gain_table_apply(ah);
  504. }
  505. /*
  506. * Helper for ASPM support.
  507. *
  508. * Disable PLL when in L0s as well as receiver clock when in L1.
  509. * This power saving option must be enabled through the SerDes.
  510. *
  511. * Programming the SerDes must go through the same 288 bit serial shift
  512. * register as the other analog registers. Hence the 9 writes.
  513. */
  514. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  515. bool power_off)
  516. {
  517. /* Nothing to do on restore for 11N */
  518. if (!power_off /* !restore */) {
  519. /* set bit 19 to allow forcing of pcie core into L1 state */
  520. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  521. /* Several PCIe massages to ensure proper behaviour */
  522. if (ah->config.pcie_waen)
  523. REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
  524. else
  525. REG_WRITE(ah, AR_WA, ah->WARegVal);
  526. }
  527. /*
  528. * Configire PCIE after Ini init. SERDES values now come from ini file
  529. * This enables PCIe low power mode.
  530. */
  531. if (ah->config.pcieSerDesWrite) {
  532. unsigned int i;
  533. struct ar5416IniArray *array;
  534. array = power_off ? &ah->iniPcieSerdes :
  535. &ah->iniPcieSerdesLowPower;
  536. for (i = 0; i < array->ia_rows; i++) {
  537. REG_WRITE(ah,
  538. INI_RA(array, i, 0),
  539. INI_RA(array, i, 1));
  540. }
  541. }
  542. }
  543. /* Sets up the AR9003 hardware familiy callbacks */
  544. void ar9003_hw_attach_ops(struct ath_hw *ah)
  545. {
  546. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  547. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  548. priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
  549. priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
  550. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  551. ar9003_hw_attach_phy_ops(ah);
  552. ar9003_hw_attach_calib_ops(ah);
  553. ar9003_hw_attach_mac_ops(ah);
  554. }