ar9003_hw.c 20 KB

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