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