ar9003_hw.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  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 "ar9003_buffalo_initvals.h"
  20. #include "ar9485_initvals.h"
  21. #include "ar9340_initvals.h"
  22. #include "ar9330_1p1_initvals.h"
  23. #include "ar9330_1p2_initvals.h"
  24. #include "ar955x_1p0_initvals.h"
  25. #include "ar9580_1p0_initvals.h"
  26. #include "ar9462_2p0_initvals.h"
  27. #include "ar9462_2p1_initvals.h"
  28. #include "ar9565_1p0_initvals.h"
  29. #include "ar9565_1p1_initvals.h"
  30. #include "ar953x_initvals.h"
  31. #include "ar956x_initvals.h"
  32. /* General hardware code for the AR9003 hadware family */
  33. /*
  34. * The AR9003 family uses a new INI format (pre, core, post
  35. * arrays per subsystem). This provides support for the
  36. * AR9003 2.2 chipsets.
  37. */
  38. static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
  39. {
  40. if (AR_SREV_9330_11(ah)) {
  41. /* mac */
  42. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  43. ar9331_1p1_mac_core);
  44. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  45. ar9331_1p1_mac_postamble);
  46. /* bb */
  47. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  48. ar9331_1p1_baseband_core);
  49. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  50. ar9331_1p1_baseband_postamble);
  51. /* radio */
  52. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  53. ar9331_1p1_radio_core);
  54. /* soc */
  55. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  56. ar9331_1p1_soc_preamble);
  57. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  58. ar9331_1p1_soc_postamble);
  59. /* rx/tx gain */
  60. INIT_INI_ARRAY(&ah->iniModesRxGain,
  61. ar9331_common_rx_gain_1p1);
  62. INIT_INI_ARRAY(&ah->iniModesTxGain,
  63. ar9331_modes_lowest_ob_db_tx_gain_1p1);
  64. /* Japan 2484 Mhz CCK */
  65. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  66. ar9331_1p1_baseband_core_txfir_coeff_japan_2484);
  67. /* additional clock settings */
  68. if (ah->is_clk_25mhz)
  69. INIT_INI_ARRAY(&ah->iniAdditional,
  70. ar9331_1p1_xtal_25M);
  71. else
  72. INIT_INI_ARRAY(&ah->iniAdditional,
  73. ar9331_1p1_xtal_40M);
  74. } else if (AR_SREV_9330_12(ah)) {
  75. /* mac */
  76. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  77. ar9331_1p2_mac_core);
  78. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  79. ar9331_1p2_mac_postamble);
  80. /* bb */
  81. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  82. ar9331_1p2_baseband_core);
  83. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  84. ar9331_1p2_baseband_postamble);
  85. /* radio */
  86. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  87. ar9331_1p2_radio_core);
  88. /* soc */
  89. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  90. ar9331_1p2_soc_preamble);
  91. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  92. ar9331_1p2_soc_postamble);
  93. /* rx/tx gain */
  94. INIT_INI_ARRAY(&ah->iniModesRxGain,
  95. ar9331_common_rx_gain_1p2);
  96. INIT_INI_ARRAY(&ah->iniModesTxGain,
  97. ar9331_modes_lowest_ob_db_tx_gain_1p2);
  98. /* Japan 2484 Mhz CCK */
  99. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  100. ar9331_1p2_baseband_core_txfir_coeff_japan_2484);
  101. /* additional clock settings */
  102. if (ah->is_clk_25mhz)
  103. INIT_INI_ARRAY(&ah->iniAdditional,
  104. ar9331_1p2_xtal_25M);
  105. else
  106. INIT_INI_ARRAY(&ah->iniAdditional,
  107. ar9331_1p2_xtal_40M);
  108. } else if (AR_SREV_9340(ah)) {
  109. /* mac */
  110. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  111. ar9340_1p0_mac_core);
  112. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  113. ar9340_1p0_mac_postamble);
  114. /* bb */
  115. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  116. ar9340_1p0_baseband_core);
  117. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  118. ar9340_1p0_baseband_postamble);
  119. /* radio */
  120. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  121. ar9340_1p0_radio_core);
  122. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  123. ar9340_1p0_radio_postamble);
  124. /* soc */
  125. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  126. ar9340_1p0_soc_preamble);
  127. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  128. ar9340_1p0_soc_postamble);
  129. /* rx/tx gain */
  130. INIT_INI_ARRAY(&ah->iniModesRxGain,
  131. ar9340Common_wo_xlna_rx_gain_table_1p0);
  132. INIT_INI_ARRAY(&ah->iniModesTxGain,
  133. ar9340Modes_high_ob_db_tx_gain_table_1p0);
  134. INIT_INI_ARRAY(&ah->iniModesFastClock,
  135. ar9340Modes_fast_clock_1p0);
  136. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  137. ar9340_1p0_baseband_core_txfir_coeff_japan_2484);
  138. INIT_INI_ARRAY(&ah->ini_dfs,
  139. ar9340_1p0_baseband_postamble_dfs_channel);
  140. if (!ah->is_clk_25mhz)
  141. INIT_INI_ARRAY(&ah->iniAdditional,
  142. ar9340_1p0_radio_core_40M);
  143. } else if (AR_SREV_9485_11_OR_LATER(ah)) {
  144. /* mac */
  145. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  146. ar9485_1_1_mac_core);
  147. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  148. ar9485_1_1_mac_postamble);
  149. /* bb */
  150. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1);
  151. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  152. ar9485_1_1_baseband_core);
  153. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  154. ar9485_1_1_baseband_postamble);
  155. /* radio */
  156. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  157. ar9485_1_1_radio_core);
  158. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  159. ar9485_1_1_radio_postamble);
  160. /* soc */
  161. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  162. ar9485_1_1_soc_preamble);
  163. /* rx/tx gain */
  164. INIT_INI_ARRAY(&ah->iniModesRxGain,
  165. ar9485Common_wo_xlna_rx_gain_1_1);
  166. INIT_INI_ARRAY(&ah->iniModesTxGain,
  167. ar9485_modes_lowest_ob_db_tx_gain_1_1);
  168. /* Japan 2484 Mhz CCK */
  169. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  170. ar9485_1_1_baseband_core_txfir_coeff_japan_2484);
  171. if (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) {
  172. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  173. ar9485_1_1_pll_on_cdr_on_clkreq_disable_L1);
  174. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  175. ar9485_1_1_pll_on_cdr_on_clkreq_disable_L1);
  176. } else {
  177. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  178. ar9485_1_1_pcie_phy_clkreq_disable_L1);
  179. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  180. ar9485_1_1_pcie_phy_clkreq_disable_L1);
  181. }
  182. } else if (AR_SREV_9462_21(ah)) {
  183. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  184. ar9462_2p1_mac_core);
  185. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  186. ar9462_2p1_mac_postamble);
  187. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  188. ar9462_2p1_baseband_core);
  189. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  190. ar9462_2p1_baseband_postamble);
  191. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  192. ar9462_2p1_radio_core);
  193. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  194. ar9462_2p1_radio_postamble);
  195. INIT_INI_ARRAY(&ah->ini_radio_post_sys2ant,
  196. ar9462_2p1_radio_postamble_sys2ant);
  197. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  198. ar9462_2p1_soc_preamble);
  199. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  200. ar9462_2p1_soc_postamble);
  201. INIT_INI_ARRAY(&ah->iniModesRxGain,
  202. ar9462_2p1_common_rx_gain);
  203. INIT_INI_ARRAY(&ah->iniModesFastClock,
  204. ar9462_2p1_modes_fast_clock);
  205. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  206. ar9462_2p1_baseband_core_txfir_coeff_japan_2484);
  207. /* Awake -> Sleep Setting */
  208. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  209. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D3)) {
  210. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  211. ar9462_2p1_pciephy_clkreq_disable_L1);
  212. }
  213. /* Sleep -> Awake Setting */
  214. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  215. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D0)) {
  216. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  217. ar9462_2p1_pciephy_clkreq_disable_L1);
  218. }
  219. } else if (AR_SREV_9462_20(ah)) {
  220. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core);
  221. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  222. ar9462_2p0_mac_postamble);
  223. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  224. ar9462_2p0_baseband_core);
  225. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  226. ar9462_2p0_baseband_postamble);
  227. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  228. ar9462_2p0_radio_core);
  229. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  230. ar9462_2p0_radio_postamble);
  231. INIT_INI_ARRAY(&ah->ini_radio_post_sys2ant,
  232. ar9462_2p0_radio_postamble_sys2ant);
  233. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  234. ar9462_2p0_soc_preamble);
  235. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  236. ar9462_2p0_soc_postamble);
  237. INIT_INI_ARRAY(&ah->iniModesRxGain,
  238. ar9462_2p0_common_rx_gain);
  239. /* Awake -> Sleep Setting */
  240. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  241. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D3)) {
  242. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  243. ar9462_2p0_pciephy_clkreq_disable_L1);
  244. }
  245. /* Sleep -> Awake Setting */
  246. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  247. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D0)) {
  248. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  249. ar9462_2p0_pciephy_clkreq_disable_L1);
  250. }
  251. /* Fast clock modal settings */
  252. INIT_INI_ARRAY(&ah->iniModesFastClock,
  253. ar9462_2p0_modes_fast_clock);
  254. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  255. ar9462_2p0_baseband_core_txfir_coeff_japan_2484);
  256. } else if (AR_SREV_9550(ah)) {
  257. /* mac */
  258. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  259. ar955x_1p0_mac_core);
  260. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  261. ar955x_1p0_mac_postamble);
  262. /* bb */
  263. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  264. ar955x_1p0_baseband_core);
  265. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  266. ar955x_1p0_baseband_postamble);
  267. /* radio */
  268. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  269. ar955x_1p0_radio_core);
  270. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  271. ar955x_1p0_radio_postamble);
  272. /* soc */
  273. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  274. ar955x_1p0_soc_preamble);
  275. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  276. ar955x_1p0_soc_postamble);
  277. /* rx/tx gain */
  278. INIT_INI_ARRAY(&ah->iniModesRxGain,
  279. ar955x_1p0_common_wo_xlna_rx_gain_table);
  280. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  281. ar955x_1p0_common_wo_xlna_rx_gain_bounds);
  282. INIT_INI_ARRAY(&ah->iniModesTxGain,
  283. ar955x_1p0_modes_xpa_tx_gain_table);
  284. /* Fast clock modal settings */
  285. INIT_INI_ARRAY(&ah->iniModesFastClock,
  286. ar955x_1p0_modes_fast_clock);
  287. } else if (AR_SREV_9531(ah)) {
  288. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  289. qca953x_1p0_mac_core);
  290. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  291. qca953x_1p0_mac_postamble);
  292. if (AR_SREV_9531_20(ah)) {
  293. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  294. qca953x_2p0_baseband_core);
  295. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  296. qca953x_2p0_baseband_postamble);
  297. } else {
  298. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  299. qca953x_1p0_baseband_core);
  300. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  301. qca953x_1p0_baseband_postamble);
  302. }
  303. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  304. qca953x_1p0_radio_core);
  305. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  306. qca953x_1p0_radio_postamble);
  307. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  308. qca953x_1p0_soc_preamble);
  309. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  310. qca953x_1p0_soc_postamble);
  311. if (AR_SREV_9531_20(ah)) {
  312. INIT_INI_ARRAY(&ah->iniModesRxGain,
  313. qca953x_2p0_common_wo_xlna_rx_gain_table);
  314. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  315. qca953x_2p0_common_wo_xlna_rx_gain_bounds);
  316. } else {
  317. INIT_INI_ARRAY(&ah->iniModesRxGain,
  318. qca953x_1p0_common_wo_xlna_rx_gain_table);
  319. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  320. qca953x_1p0_common_wo_xlna_rx_gain_bounds);
  321. }
  322. if (AR_SREV_9531_20(ah))
  323. INIT_INI_ARRAY(&ah->iniModesTxGain,
  324. qca953x_2p0_modes_no_xpa_tx_gain_table);
  325. else if (AR_SREV_9531_11(ah))
  326. INIT_INI_ARRAY(&ah->iniModesTxGain,
  327. qca953x_1p1_modes_no_xpa_tx_gain_table);
  328. else
  329. INIT_INI_ARRAY(&ah->iniModesTxGain,
  330. qca953x_1p0_modes_no_xpa_tx_gain_table);
  331. INIT_INI_ARRAY(&ah->iniModesFastClock,
  332. qca953x_1p0_modes_fast_clock);
  333. } else if (AR_SREV_9561(ah)) {
  334. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  335. qca956x_1p0_mac_core);
  336. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  337. qca956x_1p0_mac_postamble);
  338. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  339. qca956x_1p0_baseband_core);
  340. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  341. qca956x_1p0_baseband_postamble);
  342. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  343. qca956x_1p0_radio_core);
  344. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  345. qca956x_1p0_radio_postamble);
  346. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  347. qca956x_1p0_soc_preamble);
  348. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  349. qca956x_1p0_soc_postamble);
  350. INIT_INI_ARRAY(&ah->iniModesRxGain,
  351. qca956x_1p0_common_wo_xlna_rx_gain_table);
  352. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  353. qca956x_1p0_common_wo_xlna_rx_gain_bounds);
  354. INIT_INI_ARRAY(&ah->iniModesTxGain,
  355. qca956x_1p0_modes_no_xpa_tx_gain_table);
  356. INIT_INI_ARRAY(&ah->ini_dfs,
  357. qca956x_1p0_baseband_postamble_dfs_channel);
  358. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  359. qca956x_1p0_baseband_core_txfir_coeff_japan_2484);
  360. INIT_INI_ARRAY(&ah->iniModesFastClock,
  361. qca956x_1p0_modes_fast_clock);
  362. } else if (AR_SREV_9580(ah)) {
  363. /* mac */
  364. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  365. ar9580_1p0_mac_core);
  366. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  367. ar9580_1p0_mac_postamble);
  368. /* bb */
  369. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  370. ar9580_1p0_baseband_core);
  371. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  372. ar9580_1p0_baseband_postamble);
  373. /* radio */
  374. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  375. ar9580_1p0_radio_core);
  376. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  377. ar9580_1p0_radio_postamble);
  378. /* soc */
  379. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  380. ar9580_1p0_soc_preamble);
  381. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  382. ar9580_1p0_soc_postamble);
  383. /* rx/tx gain */
  384. INIT_INI_ARRAY(&ah->iniModesRxGain,
  385. ar9580_1p0_rx_gain_table);
  386. INIT_INI_ARRAY(&ah->iniModesTxGain,
  387. ar9580_1p0_low_ob_db_tx_gain_table);
  388. INIT_INI_ARRAY(&ah->iniModesFastClock,
  389. ar9580_1p0_modes_fast_clock);
  390. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  391. ar9580_1p0_baseband_core_txfir_coeff_japan_2484);
  392. INIT_INI_ARRAY(&ah->ini_dfs,
  393. ar9580_1p0_baseband_postamble_dfs_channel);
  394. } else if (AR_SREV_9565_11_OR_LATER(ah)) {
  395. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  396. ar9565_1p1_mac_core);
  397. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  398. ar9565_1p1_mac_postamble);
  399. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  400. ar9565_1p1_baseband_core);
  401. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  402. ar9565_1p1_baseband_postamble);
  403. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  404. ar9565_1p1_radio_core);
  405. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  406. ar9565_1p1_radio_postamble);
  407. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  408. ar9565_1p1_soc_preamble);
  409. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  410. ar9565_1p1_soc_postamble);
  411. INIT_INI_ARRAY(&ah->iniModesRxGain,
  412. ar9565_1p1_Common_rx_gain_table);
  413. INIT_INI_ARRAY(&ah->iniModesTxGain,
  414. ar9565_1p1_Modes_lowest_ob_db_tx_gain_table);
  415. /* Awake -> Sleep Setting */
  416. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  417. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D3)) {
  418. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  419. ar9565_1p1_pciephy_clkreq_disable_L1);
  420. }
  421. /* Sleep -> Awake Setting */
  422. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  423. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D0)) {
  424. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  425. ar9565_1p1_pciephy_clkreq_disable_L1);
  426. }
  427. INIT_INI_ARRAY(&ah->iniModesFastClock,
  428. ar9565_1p1_modes_fast_clock);
  429. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  430. ar9565_1p1_baseband_core_txfir_coeff_japan_2484);
  431. } else if (AR_SREV_9565(ah)) {
  432. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  433. ar9565_1p0_mac_core);
  434. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  435. ar9565_1p0_mac_postamble);
  436. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  437. ar9565_1p0_baseband_core);
  438. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  439. ar9565_1p0_baseband_postamble);
  440. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  441. ar9565_1p0_radio_core);
  442. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  443. ar9565_1p0_radio_postamble);
  444. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  445. ar9565_1p0_soc_preamble);
  446. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  447. ar9565_1p0_soc_postamble);
  448. INIT_INI_ARRAY(&ah->iniModesRxGain,
  449. ar9565_1p0_Common_rx_gain_table);
  450. INIT_INI_ARRAY(&ah->iniModesTxGain,
  451. ar9565_1p0_Modes_lowest_ob_db_tx_gain_table);
  452. /* Awake -> Sleep Setting */
  453. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  454. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D3)) {
  455. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  456. ar9565_1p0_pciephy_clkreq_disable_L1);
  457. }
  458. /* Sleep -> Awake Setting */
  459. if ((ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_CONTROL) &&
  460. (ah->config.pll_pwrsave & AR_PCIE_PLL_PWRSAVE_ON_D0)) {
  461. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  462. ar9565_1p0_pciephy_clkreq_disable_L1);
  463. }
  464. INIT_INI_ARRAY(&ah->iniModesFastClock,
  465. ar9565_1p0_modes_fast_clock);
  466. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  467. ar9565_1p0_baseband_core_txfir_coeff_japan_2484);
  468. } else {
  469. /* mac */
  470. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  471. ar9300_2p2_mac_core);
  472. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  473. ar9300_2p2_mac_postamble);
  474. /* bb */
  475. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  476. ar9300_2p2_baseband_core);
  477. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  478. ar9300_2p2_baseband_postamble);
  479. /* radio */
  480. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  481. ar9300_2p2_radio_core);
  482. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  483. ar9300_2p2_radio_postamble);
  484. /* soc */
  485. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  486. ar9300_2p2_soc_preamble);
  487. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  488. ar9300_2p2_soc_postamble);
  489. /* rx/tx gain */
  490. INIT_INI_ARRAY(&ah->iniModesRxGain,
  491. ar9300Common_rx_gain_table_2p2);
  492. INIT_INI_ARRAY(&ah->iniModesTxGain,
  493. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  494. /* Load PCIE SERDES settings from INI */
  495. /* Awake Setting */
  496. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  497. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  498. /* Sleep Setting */
  499. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  500. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  501. /* Fast clock modal settings */
  502. INIT_INI_ARRAY(&ah->iniModesFastClock,
  503. ar9300Modes_fast_clock_2p2);
  504. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  505. ar9300_2p2_baseband_core_txfir_coeff_japan_2484);
  506. INIT_INI_ARRAY(&ah->ini_dfs,
  507. ar9300_2p2_baseband_postamble_dfs_channel);
  508. }
  509. }
  510. static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
  511. {
  512. if (AR_SREV_9330_12(ah))
  513. INIT_INI_ARRAY(&ah->iniModesTxGain,
  514. ar9331_modes_lowest_ob_db_tx_gain_1p2);
  515. else if (AR_SREV_9330_11(ah))
  516. INIT_INI_ARRAY(&ah->iniModesTxGain,
  517. ar9331_modes_lowest_ob_db_tx_gain_1p1);
  518. else if (AR_SREV_9340(ah))
  519. INIT_INI_ARRAY(&ah->iniModesTxGain,
  520. ar9340Modes_lowest_ob_db_tx_gain_table_1p0);
  521. else if (AR_SREV_9485_11_OR_LATER(ah))
  522. INIT_INI_ARRAY(&ah->iniModesTxGain,
  523. ar9485_modes_lowest_ob_db_tx_gain_1_1);
  524. else if (AR_SREV_9550(ah))
  525. INIT_INI_ARRAY(&ah->iniModesTxGain,
  526. ar955x_1p0_modes_xpa_tx_gain_table);
  527. else if (AR_SREV_9531_10(ah))
  528. INIT_INI_ARRAY(&ah->iniModesTxGain,
  529. qca953x_1p0_modes_xpa_tx_gain_table);
  530. else if (AR_SREV_9531_11(ah))
  531. INIT_INI_ARRAY(&ah->iniModesTxGain,
  532. qca953x_1p1_modes_xpa_tx_gain_table);
  533. else if (AR_SREV_9531_20(ah))
  534. INIT_INI_ARRAY(&ah->iniModesTxGain,
  535. qca953x_2p0_modes_xpa_tx_gain_table);
  536. else if (AR_SREV_9561(ah))
  537. INIT_INI_ARRAY(&ah->iniModesTxGain,
  538. qca956x_1p0_modes_xpa_tx_gain_table);
  539. else if (AR_SREV_9580(ah))
  540. INIT_INI_ARRAY(&ah->iniModesTxGain,
  541. ar9580_1p0_lowest_ob_db_tx_gain_table);
  542. else if (AR_SREV_9462_21(ah))
  543. INIT_INI_ARRAY(&ah->iniModesTxGain,
  544. ar9462_2p1_modes_low_ob_db_tx_gain);
  545. else if (AR_SREV_9462_20(ah))
  546. INIT_INI_ARRAY(&ah->iniModesTxGain,
  547. ar9462_2p0_modes_low_ob_db_tx_gain);
  548. else if (AR_SREV_9565_11(ah))
  549. INIT_INI_ARRAY(&ah->iniModesTxGain,
  550. ar9565_1p1_modes_low_ob_db_tx_gain_table);
  551. else if (AR_SREV_9565(ah))
  552. INIT_INI_ARRAY(&ah->iniModesTxGain,
  553. ar9565_1p0_modes_low_ob_db_tx_gain_table);
  554. else
  555. INIT_INI_ARRAY(&ah->iniModesTxGain,
  556. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  557. }
  558. static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
  559. {
  560. if (AR_SREV_9330_12(ah))
  561. INIT_INI_ARRAY(&ah->iniModesTxGain,
  562. ar9331_modes_high_ob_db_tx_gain_1p2);
  563. else if (AR_SREV_9330_11(ah))
  564. INIT_INI_ARRAY(&ah->iniModesTxGain,
  565. ar9331_modes_high_ob_db_tx_gain_1p1);
  566. else if (AR_SREV_9340(ah))
  567. INIT_INI_ARRAY(&ah->iniModesTxGain,
  568. ar9340Modes_high_ob_db_tx_gain_table_1p0);
  569. else if (AR_SREV_9485_11_OR_LATER(ah))
  570. INIT_INI_ARRAY(&ah->iniModesTxGain,
  571. ar9485Modes_high_ob_db_tx_gain_1_1);
  572. else if (AR_SREV_9580(ah))
  573. INIT_INI_ARRAY(&ah->iniModesTxGain,
  574. ar9580_1p0_high_ob_db_tx_gain_table);
  575. else if (AR_SREV_9550(ah))
  576. INIT_INI_ARRAY(&ah->iniModesTxGain,
  577. ar955x_1p0_modes_no_xpa_tx_gain_table);
  578. else if (AR_SREV_9531(ah)) {
  579. if (AR_SREV_9531_20(ah))
  580. INIT_INI_ARRAY(&ah->iniModesTxGain,
  581. qca953x_2p0_modes_no_xpa_tx_gain_table);
  582. else if (AR_SREV_9531_11(ah))
  583. INIT_INI_ARRAY(&ah->iniModesTxGain,
  584. qca953x_1p1_modes_no_xpa_tx_gain_table);
  585. else
  586. INIT_INI_ARRAY(&ah->iniModesTxGain,
  587. qca953x_1p0_modes_no_xpa_tx_gain_table);
  588. } else if (AR_SREV_9561(ah))
  589. INIT_INI_ARRAY(&ah->iniModesTxGain,
  590. qca956x_1p0_modes_no_xpa_tx_gain_table);
  591. else if (AR_SREV_9462_21(ah))
  592. INIT_INI_ARRAY(&ah->iniModesTxGain,
  593. ar9462_2p1_modes_high_ob_db_tx_gain);
  594. else if (AR_SREV_9462_20(ah))
  595. INIT_INI_ARRAY(&ah->iniModesTxGain,
  596. ar9462_2p0_modes_high_ob_db_tx_gain);
  597. else if (AR_SREV_9565_11(ah))
  598. INIT_INI_ARRAY(&ah->iniModesTxGain,
  599. ar9565_1p1_modes_high_ob_db_tx_gain_table);
  600. else if (AR_SREV_9565(ah))
  601. INIT_INI_ARRAY(&ah->iniModesTxGain,
  602. ar9565_1p0_modes_high_ob_db_tx_gain_table);
  603. else
  604. INIT_INI_ARRAY(&ah->iniModesTxGain,
  605. ar9300Modes_high_ob_db_tx_gain_table_2p2);
  606. }
  607. static void ar9003_tx_gain_table_mode2(struct ath_hw *ah)
  608. {
  609. if (AR_SREV_9330_12(ah))
  610. INIT_INI_ARRAY(&ah->iniModesTxGain,
  611. ar9331_modes_low_ob_db_tx_gain_1p2);
  612. else if (AR_SREV_9330_11(ah))
  613. INIT_INI_ARRAY(&ah->iniModesTxGain,
  614. ar9331_modes_low_ob_db_tx_gain_1p1);
  615. else if (AR_SREV_9340(ah))
  616. INIT_INI_ARRAY(&ah->iniModesTxGain,
  617. ar9340Modes_low_ob_db_tx_gain_table_1p0);
  618. else if (AR_SREV_9531_11(ah))
  619. INIT_INI_ARRAY(&ah->iniModesTxGain,
  620. qca953x_1p1_modes_no_xpa_low_power_tx_gain_table);
  621. else if (AR_SREV_9485_11_OR_LATER(ah))
  622. INIT_INI_ARRAY(&ah->iniModesTxGain,
  623. ar9485Modes_low_ob_db_tx_gain_1_1);
  624. else if (AR_SREV_9580(ah))
  625. INIT_INI_ARRAY(&ah->iniModesTxGain,
  626. ar9580_1p0_low_ob_db_tx_gain_table);
  627. else if (AR_SREV_9561(ah))
  628. INIT_INI_ARRAY(&ah->iniModesTxGain,
  629. qca956x_1p0_modes_no_xpa_low_ob_db_tx_gain_table);
  630. else if (AR_SREV_9565_11(ah))
  631. INIT_INI_ARRAY(&ah->iniModesTxGain,
  632. ar9565_1p1_modes_low_ob_db_tx_gain_table);
  633. else if (AR_SREV_9565(ah))
  634. INIT_INI_ARRAY(&ah->iniModesTxGain,
  635. ar9565_1p0_modes_low_ob_db_tx_gain_table);
  636. else
  637. INIT_INI_ARRAY(&ah->iniModesTxGain,
  638. ar9300Modes_low_ob_db_tx_gain_table_2p2);
  639. }
  640. static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
  641. {
  642. if (AR_SREV_9330_12(ah))
  643. INIT_INI_ARRAY(&ah->iniModesTxGain,
  644. ar9331_modes_high_power_tx_gain_1p2);
  645. else if (AR_SREV_9330_11(ah))
  646. INIT_INI_ARRAY(&ah->iniModesTxGain,
  647. ar9331_modes_high_power_tx_gain_1p1);
  648. else if (AR_SREV_9340(ah))
  649. INIT_INI_ARRAY(&ah->iniModesTxGain,
  650. ar9340Modes_high_power_tx_gain_table_1p0);
  651. else if (AR_SREV_9485_11_OR_LATER(ah))
  652. INIT_INI_ARRAY(&ah->iniModesTxGain,
  653. ar9485Modes_high_power_tx_gain_1_1);
  654. else if (AR_SREV_9580(ah))
  655. INIT_INI_ARRAY(&ah->iniModesTxGain,
  656. ar9580_1p0_high_power_tx_gain_table);
  657. else if (AR_SREV_9565_11(ah))
  658. INIT_INI_ARRAY(&ah->iniModesTxGain,
  659. ar9565_1p1_modes_high_power_tx_gain_table);
  660. else if (AR_SREV_9565(ah))
  661. INIT_INI_ARRAY(&ah->iniModesTxGain,
  662. ar9565_1p0_modes_high_power_tx_gain_table);
  663. else {
  664. if (ah->config.tx_gain_buffalo)
  665. INIT_INI_ARRAY(&ah->iniModesTxGain,
  666. ar9300Modes_high_power_tx_gain_table_buffalo);
  667. else
  668. INIT_INI_ARRAY(&ah->iniModesTxGain,
  669. ar9300Modes_high_power_tx_gain_table_2p2);
  670. }
  671. }
  672. static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
  673. {
  674. if (AR_SREV_9340(ah))
  675. INIT_INI_ARRAY(&ah->iniModesTxGain,
  676. ar9340Modes_mixed_ob_db_tx_gain_table_1p0);
  677. else if (AR_SREV_9580(ah))
  678. INIT_INI_ARRAY(&ah->iniModesTxGain,
  679. ar9580_1p0_mixed_ob_db_tx_gain_table);
  680. else if (AR_SREV_9462_21(ah))
  681. INIT_INI_ARRAY(&ah->iniModesTxGain,
  682. ar9462_2p1_modes_mix_ob_db_tx_gain);
  683. else if (AR_SREV_9462_20(ah))
  684. INIT_INI_ARRAY(&ah->iniModesTxGain,
  685. ar9462_2p0_modes_mix_ob_db_tx_gain);
  686. else
  687. INIT_INI_ARRAY(&ah->iniModesTxGain,
  688. ar9300Modes_mixed_ob_db_tx_gain_table_2p2);
  689. }
  690. static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)
  691. {
  692. if (AR_SREV_9485_11_OR_LATER(ah))
  693. INIT_INI_ARRAY(&ah->iniModesTxGain,
  694. ar9485Modes_green_ob_db_tx_gain_1_1);
  695. else if (AR_SREV_9580(ah))
  696. INIT_INI_ARRAY(&ah->iniModesTxGain,
  697. ar9580_1p0_type5_tx_gain_table);
  698. else if (AR_SREV_9561(ah))
  699. INIT_INI_ARRAY(&ah->iniModesTxGain,
  700. qca956x_1p0_modes_no_xpa_green_tx_gain_table);
  701. else if (AR_SREV_9300_22(ah))
  702. INIT_INI_ARRAY(&ah->iniModesTxGain,
  703. ar9300Modes_type5_tx_gain_table_2p2);
  704. }
  705. static void ar9003_tx_gain_table_mode6(struct ath_hw *ah)
  706. {
  707. if (AR_SREV_9340(ah))
  708. INIT_INI_ARRAY(&ah->iniModesTxGain,
  709. ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0);
  710. else if (AR_SREV_9485_11_OR_LATER(ah))
  711. INIT_INI_ARRAY(&ah->iniModesTxGain,
  712. ar9485Modes_green_spur_ob_db_tx_gain_1_1);
  713. else if (AR_SREV_9580(ah))
  714. INIT_INI_ARRAY(&ah->iniModesTxGain,
  715. ar9580_1p0_type6_tx_gain_table);
  716. }
  717. static void ar9003_tx_gain_table_mode7(struct ath_hw *ah)
  718. {
  719. if (AR_SREV_9340(ah))
  720. INIT_INI_ARRAY(&ah->iniModesTxGain,
  721. ar9340_cus227_tx_gain_table_1p0);
  722. }
  723. typedef void (*ath_txgain_tab)(struct ath_hw *ah);
  724. static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
  725. {
  726. static const ath_txgain_tab modes[] = {
  727. ar9003_tx_gain_table_mode0,
  728. ar9003_tx_gain_table_mode1,
  729. ar9003_tx_gain_table_mode2,
  730. ar9003_tx_gain_table_mode3,
  731. ar9003_tx_gain_table_mode4,
  732. ar9003_tx_gain_table_mode5,
  733. ar9003_tx_gain_table_mode6,
  734. ar9003_tx_gain_table_mode7,
  735. };
  736. int idx = ar9003_hw_get_tx_gain_idx(ah);
  737. if (idx >= ARRAY_SIZE(modes))
  738. idx = 0;
  739. modes[idx](ah);
  740. }
  741. static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
  742. {
  743. if (AR_SREV_9330_12(ah))
  744. INIT_INI_ARRAY(&ah->iniModesRxGain,
  745. ar9331_common_rx_gain_1p2);
  746. else if (AR_SREV_9330_11(ah))
  747. INIT_INI_ARRAY(&ah->iniModesRxGain,
  748. ar9331_common_rx_gain_1p1);
  749. else if (AR_SREV_9340(ah))
  750. INIT_INI_ARRAY(&ah->iniModesRxGain,
  751. ar9340Common_rx_gain_table_1p0);
  752. else if (AR_SREV_9485_11_OR_LATER(ah))
  753. INIT_INI_ARRAY(&ah->iniModesRxGain,
  754. ar9485_common_rx_gain_1_1);
  755. else if (AR_SREV_9550(ah)) {
  756. INIT_INI_ARRAY(&ah->iniModesRxGain,
  757. ar955x_1p0_common_rx_gain_table);
  758. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  759. ar955x_1p0_common_rx_gain_bounds);
  760. } else if (AR_SREV_9531(ah)) {
  761. INIT_INI_ARRAY(&ah->iniModesRxGain,
  762. qca953x_1p0_common_rx_gain_table);
  763. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  764. qca953x_1p0_common_rx_gain_bounds);
  765. } else if (AR_SREV_9561(ah)) {
  766. INIT_INI_ARRAY(&ah->iniModesRxGain,
  767. qca956x_1p0_common_rx_gain_table);
  768. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  769. qca956x_1p0_common_rx_gain_bounds);
  770. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  771. qca956x_1p0_xlna_only);
  772. } else if (AR_SREV_9580(ah))
  773. INIT_INI_ARRAY(&ah->iniModesRxGain,
  774. ar9580_1p0_rx_gain_table);
  775. else if (AR_SREV_9462_21(ah))
  776. INIT_INI_ARRAY(&ah->iniModesRxGain,
  777. ar9462_2p1_common_rx_gain);
  778. else if (AR_SREV_9462_20(ah))
  779. INIT_INI_ARRAY(&ah->iniModesRxGain,
  780. ar9462_2p0_common_rx_gain);
  781. else if (AR_SREV_9565_11(ah))
  782. INIT_INI_ARRAY(&ah->iniModesRxGain,
  783. ar9565_1p1_Common_rx_gain_table);
  784. else if (AR_SREV_9565(ah))
  785. INIT_INI_ARRAY(&ah->iniModesRxGain,
  786. ar9565_1p0_Common_rx_gain_table);
  787. else
  788. INIT_INI_ARRAY(&ah->iniModesRxGain,
  789. ar9300Common_rx_gain_table_2p2);
  790. }
  791. static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
  792. {
  793. if (AR_SREV_9330_12(ah))
  794. INIT_INI_ARRAY(&ah->iniModesRxGain,
  795. ar9331_common_wo_xlna_rx_gain_1p2);
  796. else if (AR_SREV_9330_11(ah))
  797. INIT_INI_ARRAY(&ah->iniModesRxGain,
  798. ar9331_common_wo_xlna_rx_gain_1p1);
  799. else if (AR_SREV_9340(ah))
  800. INIT_INI_ARRAY(&ah->iniModesRxGain,
  801. ar9340Common_wo_xlna_rx_gain_table_1p0);
  802. else if (AR_SREV_9485_11_OR_LATER(ah))
  803. INIT_INI_ARRAY(&ah->iniModesRxGain,
  804. ar9485Common_wo_xlna_rx_gain_1_1);
  805. else if (AR_SREV_9462_21(ah))
  806. INIT_INI_ARRAY(&ah->iniModesRxGain,
  807. ar9462_2p1_common_wo_xlna_rx_gain);
  808. else if (AR_SREV_9462_20(ah))
  809. INIT_INI_ARRAY(&ah->iniModesRxGain,
  810. ar9462_2p0_common_wo_xlna_rx_gain);
  811. else if (AR_SREV_9550(ah)) {
  812. INIT_INI_ARRAY(&ah->iniModesRxGain,
  813. ar955x_1p0_common_wo_xlna_rx_gain_table);
  814. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  815. ar955x_1p0_common_wo_xlna_rx_gain_bounds);
  816. } else if (AR_SREV_9531_10(ah) || AR_SREV_9531_11(ah)) {
  817. INIT_INI_ARRAY(&ah->iniModesRxGain,
  818. qca953x_1p0_common_wo_xlna_rx_gain_table);
  819. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  820. qca953x_1p0_common_wo_xlna_rx_gain_bounds);
  821. } else if (AR_SREV_9531_20(ah)) {
  822. INIT_INI_ARRAY(&ah->iniModesRxGain,
  823. qca953x_2p0_common_wo_xlna_rx_gain_table);
  824. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  825. qca953x_2p0_common_wo_xlna_rx_gain_bounds);
  826. } else if (AR_SREV_9561(ah)) {
  827. INIT_INI_ARRAY(&ah->iniModesRxGain,
  828. qca956x_1p0_common_wo_xlna_rx_gain_table);
  829. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  830. qca956x_1p0_common_wo_xlna_rx_gain_bounds);
  831. } else if (AR_SREV_9580(ah))
  832. INIT_INI_ARRAY(&ah->iniModesRxGain,
  833. ar9580_1p0_wo_xlna_rx_gain_table);
  834. else if (AR_SREV_9565_11(ah))
  835. INIT_INI_ARRAY(&ah->iniModesRxGain,
  836. ar9565_1p1_common_wo_xlna_rx_gain_table);
  837. else if (AR_SREV_9565(ah))
  838. INIT_INI_ARRAY(&ah->iniModesRxGain,
  839. ar9565_1p0_common_wo_xlna_rx_gain_table);
  840. else
  841. INIT_INI_ARRAY(&ah->iniModesRxGain,
  842. ar9300Common_wo_xlna_rx_gain_table_2p2);
  843. }
  844. static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
  845. {
  846. if (AR_SREV_9462_21(ah)) {
  847. INIT_INI_ARRAY(&ah->iniModesRxGain,
  848. ar9462_2p1_common_mixed_rx_gain);
  849. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  850. ar9462_2p1_baseband_core_mix_rxgain);
  851. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  852. ar9462_2p1_baseband_postamble_mix_rxgain);
  853. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  854. ar9462_2p1_baseband_postamble_5g_xlna);
  855. } else if (AR_SREV_9462_20(ah)) {
  856. INIT_INI_ARRAY(&ah->iniModesRxGain,
  857. ar9462_2p0_common_mixed_rx_gain);
  858. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  859. ar9462_2p0_baseband_core_mix_rxgain);
  860. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  861. ar9462_2p0_baseband_postamble_mix_rxgain);
  862. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  863. ar9462_2p0_baseband_postamble_5g_xlna);
  864. }
  865. }
  866. static void ar9003_rx_gain_table_mode3(struct ath_hw *ah)
  867. {
  868. if (AR_SREV_9462_21(ah)) {
  869. INIT_INI_ARRAY(&ah->iniModesRxGain,
  870. ar9462_2p1_common_5g_xlna_only_rxgain);
  871. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  872. ar9462_2p1_baseband_postamble_5g_xlna);
  873. } else if (AR_SREV_9462_20(ah)) {
  874. INIT_INI_ARRAY(&ah->iniModesRxGain,
  875. ar9462_2p0_common_5g_xlna_only_rxgain);
  876. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  877. ar9462_2p0_baseband_postamble_5g_xlna);
  878. }
  879. }
  880. static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
  881. {
  882. switch (ar9003_hw_get_rx_gain_idx(ah)) {
  883. case 0:
  884. default:
  885. ar9003_rx_gain_table_mode0(ah);
  886. break;
  887. case 1:
  888. ar9003_rx_gain_table_mode1(ah);
  889. break;
  890. case 2:
  891. ar9003_rx_gain_table_mode2(ah);
  892. break;
  893. case 3:
  894. ar9003_rx_gain_table_mode3(ah);
  895. break;
  896. }
  897. }
  898. /* set gain table pointers according to values read from the eeprom */
  899. static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
  900. {
  901. ar9003_tx_gain_table_apply(ah);
  902. ar9003_rx_gain_table_apply(ah);
  903. }
  904. /*
  905. * Helper for ASPM support.
  906. *
  907. * Disable PLL when in L0s as well as receiver clock when in L1.
  908. * This power saving option must be enabled through the SerDes.
  909. *
  910. * Programming the SerDes must go through the same 288 bit serial shift
  911. * register as the other analog registers. Hence the 9 writes.
  912. */
  913. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  914. bool power_off)
  915. {
  916. unsigned int i;
  917. struct ar5416IniArray *array;
  918. /*
  919. * Increase L1 Entry Latency. Some WB222 boards don't have
  920. * this change in eeprom/OTP.
  921. *
  922. */
  923. if (AR_SREV_9462(ah)) {
  924. u32 val = ah->config.aspm_l1_fix;
  925. if ((val & 0xff000000) == 0x17000000) {
  926. val &= 0x00ffffff;
  927. val |= 0x27000000;
  928. REG_WRITE(ah, 0x570c, val);
  929. }
  930. }
  931. /* Nothing to do on restore for 11N */
  932. if (!power_off /* !restore */) {
  933. /* set bit 19 to allow forcing of pcie core into L1 state */
  934. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  935. REG_WRITE(ah, AR_WA, ah->WARegVal);
  936. }
  937. /*
  938. * Configire PCIE after Ini init. SERDES values now come from ini file
  939. * This enables PCIe low power mode.
  940. */
  941. array = power_off ? &ah->iniPcieSerdes :
  942. &ah->iniPcieSerdesLowPower;
  943. for (i = 0; i < array->ia_rows; i++) {
  944. REG_WRITE(ah,
  945. INI_RA(array, i, 0),
  946. INI_RA(array, i, 1));
  947. }
  948. }
  949. static void ar9003_hw_init_hang_checks(struct ath_hw *ah)
  950. {
  951. /*
  952. * All chips support detection of BB/MAC hangs.
  953. */
  954. ah->config.hw_hang_checks |= HW_BB_WATCHDOG;
  955. ah->config.hw_hang_checks |= HW_MAC_HANG;
  956. /*
  957. * This is not required for AR9580 1.0
  958. */
  959. if (AR_SREV_9300_22(ah))
  960. ah->config.hw_hang_checks |= HW_PHYRESTART_CLC_WAR;
  961. if (AR_SREV_9330(ah))
  962. ah->bb_watchdog_timeout_ms = 85;
  963. else
  964. ah->bb_watchdog_timeout_ms = 25;
  965. }
  966. /*
  967. * MAC HW hang check
  968. * =================
  969. *
  970. * Signature: dcu_chain_state is 0x6 and dcu_complete_state is 0x1.
  971. *
  972. * The state of each DCU chain (mapped to TX queues) is available from these
  973. * DMA debug registers:
  974. *
  975. * Chain 0 state : Bits 4:0 of AR_DMADBG_4
  976. * Chain 1 state : Bits 9:5 of AR_DMADBG_4
  977. * Chain 2 state : Bits 14:10 of AR_DMADBG_4
  978. * Chain 3 state : Bits 19:15 of AR_DMADBG_4
  979. * Chain 4 state : Bits 24:20 of AR_DMADBG_4
  980. * Chain 5 state : Bits 29:25 of AR_DMADBG_4
  981. * Chain 6 state : Bits 4:0 of AR_DMADBG_5
  982. * Chain 7 state : Bits 9:5 of AR_DMADBG_5
  983. * Chain 8 state : Bits 14:10 of AR_DMADBG_5
  984. * Chain 9 state : Bits 19:15 of AR_DMADBG_5
  985. *
  986. * The DCU chain state "0x6" means "WAIT_FRDONE" - wait for TX frame to be done.
  987. */
  988. #define NUM_STATUS_READS 50
  989. static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue)
  990. {
  991. u32 dma_dbg_chain, dma_dbg_complete;
  992. u8 dcu_chain_state, dcu_complete_state;
  993. int i;
  994. for (i = 0; i < NUM_STATUS_READS; i++) {
  995. if (queue < 6)
  996. dma_dbg_chain = REG_READ(ah, AR_DMADBG_4);
  997. else
  998. dma_dbg_chain = REG_READ(ah, AR_DMADBG_5);
  999. dma_dbg_complete = REG_READ(ah, AR_DMADBG_6);
  1000. dcu_chain_state = (dma_dbg_chain >> (5 * queue)) & 0x1f;
  1001. dcu_complete_state = dma_dbg_complete & 0x3;
  1002. if ((dcu_chain_state != 0x6) || (dcu_complete_state != 0x1))
  1003. return false;
  1004. }
  1005. ath_dbg(ath9k_hw_common(ah), RESET,
  1006. "MAC Hang signature found for queue: %d\n", queue);
  1007. return true;
  1008. }
  1009. static bool ar9003_hw_detect_mac_hang(struct ath_hw *ah)
  1010. {
  1011. u32 dma_dbg_4, dma_dbg_5, dma_dbg_6, chk_dbg;
  1012. u8 dcu_chain_state, dcu_complete_state;
  1013. bool dcu_wait_frdone = false;
  1014. unsigned long chk_dcu = 0;
  1015. unsigned int i = 0;
  1016. dma_dbg_4 = REG_READ(ah, AR_DMADBG_4);
  1017. dma_dbg_5 = REG_READ(ah, AR_DMADBG_5);
  1018. dma_dbg_6 = REG_READ(ah, AR_DMADBG_6);
  1019. dcu_complete_state = dma_dbg_6 & 0x3;
  1020. if (dcu_complete_state != 0x1)
  1021. goto exit;
  1022. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  1023. if (i < 6)
  1024. chk_dbg = dma_dbg_4;
  1025. else
  1026. chk_dbg = dma_dbg_5;
  1027. dcu_chain_state = (chk_dbg >> (5 * i)) & 0x1f;
  1028. if (dcu_chain_state == 0x6) {
  1029. dcu_wait_frdone = true;
  1030. chk_dcu |= BIT(i);
  1031. }
  1032. }
  1033. if ((dcu_complete_state == 0x1) && dcu_wait_frdone) {
  1034. for_each_set_bit(i, &chk_dcu, ATH9K_NUM_TX_QUEUES) {
  1035. if (ath9k_hw_verify_hang(ah, i))
  1036. return true;
  1037. }
  1038. }
  1039. exit:
  1040. return false;
  1041. }
  1042. /* Sets up the AR9003 hardware familiy callbacks */
  1043. void ar9003_hw_attach_ops(struct ath_hw *ah)
  1044. {
  1045. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  1046. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  1047. ar9003_hw_init_mode_regs(ah);
  1048. if (AR_SREV_9003_PCOEM(ah)) {
  1049. WARN_ON(!ah->iniPcieSerdes.ia_array);
  1050. WARN_ON(!ah->iniPcieSerdesLowPower.ia_array);
  1051. }
  1052. priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
  1053. priv_ops->init_hang_checks = ar9003_hw_init_hang_checks;
  1054. priv_ops->detect_mac_hang = ar9003_hw_detect_mac_hang;
  1055. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  1056. ar9003_hw_attach_phy_ops(ah);
  1057. ar9003_hw_attach_calib_ops(ah);
  1058. ar9003_hw_attach_mac_ops(ah);
  1059. ar9003_hw_attach_aic_ops(ah);
  1060. }