ar9003_hw.c 21 KB

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