ar9003_hw.c 24 KB

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