ar9003_hw.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  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_OR_LATER(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. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  313. ar9565_1p0_baseband_core_txfir_coeff_japan_2484);
  314. } else {
  315. /* mac */
  316. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  317. ar9300_2p2_mac_core);
  318. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  319. ar9300_2p2_mac_postamble);
  320. /* bb */
  321. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  322. ar9300_2p2_baseband_core);
  323. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  324. ar9300_2p2_baseband_postamble);
  325. /* radio */
  326. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  327. ar9300_2p2_radio_core);
  328. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  329. ar9300_2p2_radio_postamble);
  330. /* soc */
  331. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  332. ar9300_2p2_soc_preamble);
  333. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  334. ar9300_2p2_soc_postamble);
  335. /* rx/tx gain */
  336. INIT_INI_ARRAY(&ah->iniModesRxGain,
  337. ar9300Common_rx_gain_table_2p2);
  338. INIT_INI_ARRAY(&ah->iniModesTxGain,
  339. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  340. /* Load PCIE SERDES settings from INI */
  341. /* Awake Setting */
  342. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  343. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  344. /* Sleep Setting */
  345. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  346. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  347. /* Fast clock modal settings */
  348. INIT_INI_ARRAY(&ah->iniModesFastClock,
  349. ar9300Modes_fast_clock_2p2);
  350. }
  351. }
  352. static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
  353. {
  354. if (AR_SREV_9330_12(ah))
  355. INIT_INI_ARRAY(&ah->iniModesTxGain,
  356. ar9331_modes_lowest_ob_db_tx_gain_1p2);
  357. else if (AR_SREV_9330_11(ah))
  358. INIT_INI_ARRAY(&ah->iniModesTxGain,
  359. ar9331_modes_lowest_ob_db_tx_gain_1p1);
  360. else if (AR_SREV_9340(ah))
  361. INIT_INI_ARRAY(&ah->iniModesTxGain,
  362. ar9340Modes_lowest_ob_db_tx_gain_table_1p0);
  363. else if (AR_SREV_9485_11_OR_LATER(ah))
  364. INIT_INI_ARRAY(&ah->iniModesTxGain,
  365. ar9485_modes_lowest_ob_db_tx_gain_1_1);
  366. else if (AR_SREV_9550(ah))
  367. INIT_INI_ARRAY(&ah->iniModesTxGain,
  368. ar955x_1p0_modes_xpa_tx_gain_table);
  369. else if (AR_SREV_9580(ah))
  370. INIT_INI_ARRAY(&ah->iniModesTxGain,
  371. ar9580_1p0_lowest_ob_db_tx_gain_table);
  372. else if (AR_SREV_9462_21(ah))
  373. INIT_INI_ARRAY(&ah->iniModesTxGain,
  374. ar9462_2p1_modes_low_ob_db_tx_gain);
  375. else if (AR_SREV_9462_20(ah))
  376. INIT_INI_ARRAY(&ah->iniModesTxGain,
  377. ar9462_modes_low_ob_db_tx_gain_table_2p0);
  378. else if (AR_SREV_9565(ah))
  379. INIT_INI_ARRAY(&ah->iniModesTxGain,
  380. ar9565_1p0_modes_low_ob_db_tx_gain_table);
  381. else
  382. INIT_INI_ARRAY(&ah->iniModesTxGain,
  383. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  384. }
  385. static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
  386. {
  387. if (AR_SREV_9330_12(ah))
  388. INIT_INI_ARRAY(&ah->iniModesTxGain,
  389. ar9331_modes_high_ob_db_tx_gain_1p2);
  390. else if (AR_SREV_9330_11(ah))
  391. INIT_INI_ARRAY(&ah->iniModesTxGain,
  392. ar9331_modes_high_ob_db_tx_gain_1p1);
  393. else if (AR_SREV_9340(ah))
  394. INIT_INI_ARRAY(&ah->iniModesTxGain,
  395. ar9340Modes_high_ob_db_tx_gain_table_1p0);
  396. else if (AR_SREV_9485_11_OR_LATER(ah))
  397. INIT_INI_ARRAY(&ah->iniModesTxGain,
  398. ar9485Modes_high_ob_db_tx_gain_1_1);
  399. else if (AR_SREV_9580(ah))
  400. INIT_INI_ARRAY(&ah->iniModesTxGain,
  401. ar9580_1p0_high_ob_db_tx_gain_table);
  402. else if (AR_SREV_9550(ah))
  403. INIT_INI_ARRAY(&ah->iniModesTxGain,
  404. ar955x_1p0_modes_no_xpa_tx_gain_table);
  405. else if (AR_SREV_9462_21(ah))
  406. INIT_INI_ARRAY(&ah->iniModesTxGain,
  407. ar9462_2p1_modes_high_ob_db_tx_gain);
  408. else if (AR_SREV_9462_20(ah))
  409. INIT_INI_ARRAY(&ah->iniModesTxGain,
  410. ar9462_modes_high_ob_db_tx_gain_table_2p0);
  411. else if (AR_SREV_9565(ah))
  412. INIT_INI_ARRAY(&ah->iniModesTxGain,
  413. ar9565_1p0_modes_high_ob_db_tx_gain_table);
  414. else
  415. INIT_INI_ARRAY(&ah->iniModesTxGain,
  416. ar9300Modes_high_ob_db_tx_gain_table_2p2);
  417. }
  418. static void ar9003_tx_gain_table_mode2(struct ath_hw *ah)
  419. {
  420. if (AR_SREV_9330_12(ah))
  421. INIT_INI_ARRAY(&ah->iniModesTxGain,
  422. ar9331_modes_low_ob_db_tx_gain_1p2);
  423. else if (AR_SREV_9330_11(ah))
  424. INIT_INI_ARRAY(&ah->iniModesTxGain,
  425. ar9331_modes_low_ob_db_tx_gain_1p1);
  426. else if (AR_SREV_9340(ah))
  427. INIT_INI_ARRAY(&ah->iniModesTxGain,
  428. ar9340Modes_low_ob_db_tx_gain_table_1p0);
  429. else if (AR_SREV_9485_11_OR_LATER(ah))
  430. INIT_INI_ARRAY(&ah->iniModesTxGain,
  431. ar9485Modes_low_ob_db_tx_gain_1_1);
  432. else if (AR_SREV_9580(ah))
  433. INIT_INI_ARRAY(&ah->iniModesTxGain,
  434. ar9580_1p0_low_ob_db_tx_gain_table);
  435. else if (AR_SREV_9565(ah))
  436. INIT_INI_ARRAY(&ah->iniModesTxGain,
  437. ar9565_1p0_modes_low_ob_db_tx_gain_table);
  438. else
  439. INIT_INI_ARRAY(&ah->iniModesTxGain,
  440. ar9300Modes_low_ob_db_tx_gain_table_2p2);
  441. }
  442. static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
  443. {
  444. if (AR_SREV_9330_12(ah))
  445. INIT_INI_ARRAY(&ah->iniModesTxGain,
  446. ar9331_modes_high_power_tx_gain_1p2);
  447. else if (AR_SREV_9330_11(ah))
  448. INIT_INI_ARRAY(&ah->iniModesTxGain,
  449. ar9331_modes_high_power_tx_gain_1p1);
  450. else if (AR_SREV_9340(ah))
  451. INIT_INI_ARRAY(&ah->iniModesTxGain,
  452. ar9340Modes_high_power_tx_gain_table_1p0);
  453. else if (AR_SREV_9485_11_OR_LATER(ah))
  454. INIT_INI_ARRAY(&ah->iniModesTxGain,
  455. ar9485Modes_high_power_tx_gain_1_1);
  456. else if (AR_SREV_9580(ah))
  457. INIT_INI_ARRAY(&ah->iniModesTxGain,
  458. ar9580_1p0_high_power_tx_gain_table);
  459. else if (AR_SREV_9565(ah))
  460. INIT_INI_ARRAY(&ah->iniModesTxGain,
  461. ar9565_1p0_modes_high_power_tx_gain_table);
  462. else
  463. INIT_INI_ARRAY(&ah->iniModesTxGain,
  464. ar9300Modes_high_power_tx_gain_table_2p2);
  465. }
  466. static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
  467. {
  468. if (AR_SREV_9340(ah))
  469. INIT_INI_ARRAY(&ah->iniModesTxGain,
  470. ar9340Modes_mixed_ob_db_tx_gain_table_1p0);
  471. else if (AR_SREV_9580(ah))
  472. INIT_INI_ARRAY(&ah->iniModesTxGain,
  473. ar9580_1p0_mixed_ob_db_tx_gain_table);
  474. else if (AR_SREV_9462_21(ah))
  475. INIT_INI_ARRAY(&ah->iniModesTxGain,
  476. ar9462_2p1_modes_mix_ob_db_tx_gain);
  477. else if (AR_SREV_9462_20(ah))
  478. INIT_INI_ARRAY(&ah->iniModesTxGain,
  479. ar9462_modes_mix_ob_db_tx_gain_table_2p0);
  480. else
  481. INIT_INI_ARRAY(&ah->iniModesTxGain,
  482. ar9300Modes_mixed_ob_db_tx_gain_table_2p2);
  483. }
  484. static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)
  485. {
  486. if (AR_SREV_9485_11_OR_LATER(ah))
  487. INIT_INI_ARRAY(&ah->iniModesTxGain,
  488. ar9485Modes_green_ob_db_tx_gain_1_1);
  489. else if (AR_SREV_9340(ah))
  490. INIT_INI_ARRAY(&ah->iniModesTxGain,
  491. ar9340Modes_ub124_tx_gain_table_1p0);
  492. else if (AR_SREV_9580(ah))
  493. INIT_INI_ARRAY(&ah->iniModesTxGain,
  494. ar9580_1p0_type5_tx_gain_table);
  495. else if (AR_SREV_9300_22(ah))
  496. INIT_INI_ARRAY(&ah->iniModesTxGain,
  497. ar9300Modes_type5_tx_gain_table_2p2);
  498. }
  499. static void ar9003_tx_gain_table_mode6(struct ath_hw *ah)
  500. {
  501. if (AR_SREV_9340(ah))
  502. INIT_INI_ARRAY(&ah->iniModesTxGain,
  503. ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0);
  504. else if (AR_SREV_9485_11_OR_LATER(ah))
  505. INIT_INI_ARRAY(&ah->iniModesTxGain,
  506. ar9485Modes_green_spur_ob_db_tx_gain_1_1);
  507. else if (AR_SREV_9580(ah))
  508. INIT_INI_ARRAY(&ah->iniModesTxGain,
  509. ar9580_1p0_type6_tx_gain_table);
  510. }
  511. typedef void (*ath_txgain_tab)(struct ath_hw *ah);
  512. static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
  513. {
  514. static const ath_txgain_tab modes[] = {
  515. ar9003_tx_gain_table_mode0,
  516. ar9003_tx_gain_table_mode1,
  517. ar9003_tx_gain_table_mode2,
  518. ar9003_tx_gain_table_mode3,
  519. ar9003_tx_gain_table_mode4,
  520. ar9003_tx_gain_table_mode5,
  521. ar9003_tx_gain_table_mode6,
  522. };
  523. int idx = ar9003_hw_get_tx_gain_idx(ah);
  524. if (idx >= ARRAY_SIZE(modes))
  525. idx = 0;
  526. modes[idx](ah);
  527. }
  528. static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
  529. {
  530. if (AR_SREV_9330_12(ah))
  531. INIT_INI_ARRAY(&ah->iniModesRxGain,
  532. ar9331_common_rx_gain_1p2);
  533. else if (AR_SREV_9330_11(ah))
  534. INIT_INI_ARRAY(&ah->iniModesRxGain,
  535. ar9331_common_rx_gain_1p1);
  536. else if (AR_SREV_9340(ah))
  537. INIT_INI_ARRAY(&ah->iniModesRxGain,
  538. ar9340Common_rx_gain_table_1p0);
  539. else if (AR_SREV_9485_11_OR_LATER(ah))
  540. INIT_INI_ARRAY(&ah->iniModesRxGain,
  541. ar9485_common_rx_gain_1_1);
  542. else if (AR_SREV_9550(ah)) {
  543. INIT_INI_ARRAY(&ah->iniModesRxGain,
  544. ar955x_1p0_common_rx_gain_table);
  545. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  546. ar955x_1p0_common_rx_gain_bounds);
  547. } else if (AR_SREV_9580(ah))
  548. INIT_INI_ARRAY(&ah->iniModesRxGain,
  549. ar9580_1p0_rx_gain_table);
  550. else if (AR_SREV_9462_21(ah))
  551. INIT_INI_ARRAY(&ah->iniModesRxGain,
  552. ar9462_2p1_common_rx_gain);
  553. else if (AR_SREV_9462_20(ah))
  554. INIT_INI_ARRAY(&ah->iniModesRxGain,
  555. ar9462_common_rx_gain_table_2p0);
  556. else if (AR_SREV_9565(ah))
  557. INIT_INI_ARRAY(&ah->iniModesRxGain,
  558. ar9565_1p0_Common_rx_gain_table);
  559. else
  560. INIT_INI_ARRAY(&ah->iniModesRxGain,
  561. ar9300Common_rx_gain_table_2p2);
  562. }
  563. static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
  564. {
  565. if (AR_SREV_9330_12(ah))
  566. INIT_INI_ARRAY(&ah->iniModesRxGain,
  567. ar9331_common_wo_xlna_rx_gain_1p2);
  568. else if (AR_SREV_9330_11(ah))
  569. INIT_INI_ARRAY(&ah->iniModesRxGain,
  570. ar9331_common_wo_xlna_rx_gain_1p1);
  571. else if (AR_SREV_9340(ah))
  572. INIT_INI_ARRAY(&ah->iniModesRxGain,
  573. ar9340Common_wo_xlna_rx_gain_table_1p0);
  574. else if (AR_SREV_9485_11_OR_LATER(ah))
  575. INIT_INI_ARRAY(&ah->iniModesRxGain,
  576. ar9485Common_wo_xlna_rx_gain_1_1);
  577. else if (AR_SREV_9462_21(ah))
  578. INIT_INI_ARRAY(&ah->iniModesRxGain,
  579. ar9462_2p1_common_wo_xlna_rx_gain);
  580. else if (AR_SREV_9462_20(ah))
  581. INIT_INI_ARRAY(&ah->iniModesRxGain,
  582. ar9462_common_wo_xlna_rx_gain_table_2p0);
  583. else if (AR_SREV_9550(ah)) {
  584. INIT_INI_ARRAY(&ah->iniModesRxGain,
  585. ar955x_1p0_common_wo_xlna_rx_gain_table);
  586. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  587. ar955x_1p0_common_wo_xlna_rx_gain_bounds);
  588. } else if (AR_SREV_9580(ah))
  589. INIT_INI_ARRAY(&ah->iniModesRxGain,
  590. ar9580_1p0_wo_xlna_rx_gain_table);
  591. else if (AR_SREV_9565(ah))
  592. INIT_INI_ARRAY(&ah->iniModesRxGain,
  593. ar9565_1p0_common_wo_xlna_rx_gain_table);
  594. else
  595. INIT_INI_ARRAY(&ah->iniModesRxGain,
  596. ar9300Common_wo_xlna_rx_gain_table_2p2);
  597. }
  598. static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
  599. {
  600. if (AR_SREV_9462_21(ah)) {
  601. INIT_INI_ARRAY(&ah->iniModesRxGain,
  602. ar9462_2p1_common_mixed_rx_gain);
  603. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  604. ar9462_2p1_baseband_core_mix_rxgain);
  605. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  606. ar9462_2p1_baseband_postamble_mix_rxgain);
  607. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  608. ar9462_2p1_baseband_postamble_5g_xlna);
  609. } else if (AR_SREV_9462_20(ah)) {
  610. INIT_INI_ARRAY(&ah->iniModesRxGain,
  611. ar9462_common_mixed_rx_gain_table_2p0);
  612. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  613. ar9462_2p0_baseband_core_mix_rxgain);
  614. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  615. ar9462_2p0_baseband_postamble_mix_rxgain);
  616. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  617. ar9462_2p0_baseband_postamble_5g_xlna);
  618. }
  619. }
  620. static void ar9003_rx_gain_table_mode3(struct ath_hw *ah)
  621. {
  622. if (AR_SREV_9462_21(ah)) {
  623. INIT_INI_ARRAY(&ah->iniModesRxGain,
  624. ar9462_2p1_common_5g_xlna_only_rx_gain);
  625. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  626. ar9462_2p1_baseband_postamble_5g_xlna);
  627. } else if (AR_SREV_9462_20(ah)) {
  628. INIT_INI_ARRAY(&ah->iniModesRxGain,
  629. ar9462_2p0_5g_xlna_only_rxgain);
  630. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  631. ar9462_2p0_baseband_postamble_5g_xlna);
  632. }
  633. }
  634. static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
  635. {
  636. switch (ar9003_hw_get_rx_gain_idx(ah)) {
  637. case 0:
  638. default:
  639. ar9003_rx_gain_table_mode0(ah);
  640. break;
  641. case 1:
  642. ar9003_rx_gain_table_mode1(ah);
  643. break;
  644. case 2:
  645. ar9003_rx_gain_table_mode2(ah);
  646. break;
  647. case 3:
  648. ar9003_rx_gain_table_mode3(ah);
  649. break;
  650. }
  651. }
  652. /* set gain table pointers according to values read from the eeprom */
  653. static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
  654. {
  655. ar9003_tx_gain_table_apply(ah);
  656. ar9003_rx_gain_table_apply(ah);
  657. }
  658. /*
  659. * Helper for ASPM support.
  660. *
  661. * Disable PLL when in L0s as well as receiver clock when in L1.
  662. * This power saving option must be enabled through the SerDes.
  663. *
  664. * Programming the SerDes must go through the same 288 bit serial shift
  665. * register as the other analog registers. Hence the 9 writes.
  666. */
  667. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  668. bool power_off)
  669. {
  670. /*
  671. * Increase L1 Entry Latency. Some WB222 boards don't have
  672. * this change in eeprom/OTP.
  673. *
  674. */
  675. if (AR_SREV_9462(ah)) {
  676. u32 val = ah->config.aspm_l1_fix;
  677. if ((val & 0xff000000) == 0x17000000) {
  678. val &= 0x00ffffff;
  679. val |= 0x27000000;
  680. REG_WRITE(ah, 0x570c, val);
  681. }
  682. }
  683. /* Nothing to do on restore for 11N */
  684. if (!power_off /* !restore */) {
  685. /* set bit 19 to allow forcing of pcie core into L1 state */
  686. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  687. REG_WRITE(ah, AR_WA, ah->WARegVal);
  688. }
  689. /*
  690. * Configire PCIE after Ini init. SERDES values now come from ini file
  691. * This enables PCIe low power mode.
  692. */
  693. if (ah->config.pcieSerDesWrite) {
  694. unsigned int i;
  695. struct ar5416IniArray *array;
  696. array = power_off ? &ah->iniPcieSerdes :
  697. &ah->iniPcieSerdesLowPower;
  698. for (i = 0; i < array->ia_rows; i++) {
  699. REG_WRITE(ah,
  700. INI_RA(array, i, 0),
  701. INI_RA(array, i, 1));
  702. }
  703. }
  704. }
  705. /* Sets up the AR9003 hardware familiy callbacks */
  706. void ar9003_hw_attach_ops(struct ath_hw *ah)
  707. {
  708. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  709. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  710. ar9003_hw_init_mode_regs(ah);
  711. priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
  712. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  713. ar9003_hw_attach_phy_ops(ah);
  714. ar9003_hw_attach_calib_ops(ah);
  715. ar9003_hw_attach_mac_ops(ah);
  716. }