ar9003_hw.c 33 KB

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