ar9003_hw.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  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. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  278. qca953x_1p0_baseband_core);
  279. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  280. qca953x_1p0_baseband_postamble);
  281. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  282. qca953x_1p0_radio_core);
  283. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  284. qca953x_1p0_radio_postamble);
  285. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  286. qca953x_1p0_soc_preamble);
  287. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  288. qca953x_1p0_soc_postamble);
  289. INIT_INI_ARRAY(&ah->iniModesRxGain,
  290. qca953x_1p0_common_wo_xlna_rx_gain_table);
  291. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  292. qca953x_1p0_common_wo_xlna_rx_gain_bounds);
  293. INIT_INI_ARRAY(&ah->iniModesTxGain,
  294. qca953x_1p0_modes_no_xpa_tx_gain_table);
  295. INIT_INI_ARRAY(&ah->iniModesFastClock,
  296. qca953x_1p0_modes_fast_clock);
  297. } else if (AR_SREV_9580(ah)) {
  298. /* mac */
  299. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  300. ar9580_1p0_mac_core);
  301. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  302. ar9580_1p0_mac_postamble);
  303. /* bb */
  304. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  305. ar9580_1p0_baseband_core);
  306. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  307. ar9580_1p0_baseband_postamble);
  308. /* radio */
  309. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  310. ar9580_1p0_radio_core);
  311. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  312. ar9580_1p0_radio_postamble);
  313. /* soc */
  314. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  315. ar9580_1p0_soc_preamble);
  316. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  317. ar9580_1p0_soc_postamble);
  318. /* rx/tx gain */
  319. INIT_INI_ARRAY(&ah->iniModesRxGain,
  320. ar9580_1p0_rx_gain_table);
  321. INIT_INI_ARRAY(&ah->iniModesTxGain,
  322. ar9580_1p0_low_ob_db_tx_gain_table);
  323. INIT_INI_ARRAY(&ah->iniModesFastClock,
  324. ar9580_1p0_modes_fast_clock);
  325. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  326. ar9580_1p0_baseband_core_txfir_coeff_japan_2484);
  327. INIT_INI_ARRAY(&ah->ini_dfs,
  328. ar9580_1p0_baseband_postamble_dfs_channel);
  329. } else if (AR_SREV_9565_11_OR_LATER(ah)) {
  330. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  331. ar9565_1p1_mac_core);
  332. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  333. ar9565_1p1_mac_postamble);
  334. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  335. ar9565_1p1_baseband_core);
  336. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  337. ar9565_1p1_baseband_postamble);
  338. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  339. ar9565_1p1_radio_core);
  340. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  341. ar9565_1p1_radio_postamble);
  342. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  343. ar9565_1p1_soc_preamble);
  344. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  345. ar9565_1p1_soc_postamble);
  346. INIT_INI_ARRAY(&ah->iniModesRxGain,
  347. ar9565_1p1_Common_rx_gain_table);
  348. INIT_INI_ARRAY(&ah->iniModesTxGain,
  349. ar9565_1p1_Modes_lowest_ob_db_tx_gain_table);
  350. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  351. ar9565_1p1_pciephy_clkreq_disable_L1);
  352. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  353. ar9565_1p1_pciephy_clkreq_disable_L1);
  354. INIT_INI_ARRAY(&ah->iniModesFastClock,
  355. ar9565_1p1_modes_fast_clock);
  356. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  357. ar9565_1p1_baseband_core_txfir_coeff_japan_2484);
  358. } else if (AR_SREV_9565(ah)) {
  359. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  360. ar9565_1p0_mac_core);
  361. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  362. ar9565_1p0_mac_postamble);
  363. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  364. ar9565_1p0_baseband_core);
  365. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  366. ar9565_1p0_baseband_postamble);
  367. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  368. ar9565_1p0_radio_core);
  369. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  370. ar9565_1p0_radio_postamble);
  371. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  372. ar9565_1p0_soc_preamble);
  373. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  374. ar9565_1p0_soc_postamble);
  375. INIT_INI_ARRAY(&ah->iniModesRxGain,
  376. ar9565_1p0_Common_rx_gain_table);
  377. INIT_INI_ARRAY(&ah->iniModesTxGain,
  378. ar9565_1p0_Modes_lowest_ob_db_tx_gain_table);
  379. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  380. ar9565_1p0_pciephy_clkreq_disable_L1);
  381. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  382. ar9565_1p0_pciephy_clkreq_disable_L1);
  383. INIT_INI_ARRAY(&ah->iniModesFastClock,
  384. ar9565_1p0_modes_fast_clock);
  385. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  386. ar9565_1p0_baseband_core_txfir_coeff_japan_2484);
  387. } else {
  388. /* mac */
  389. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  390. ar9300_2p2_mac_core);
  391. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  392. ar9300_2p2_mac_postamble);
  393. /* bb */
  394. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  395. ar9300_2p2_baseband_core);
  396. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  397. ar9300_2p2_baseband_postamble);
  398. /* radio */
  399. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  400. ar9300_2p2_radio_core);
  401. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  402. ar9300_2p2_radio_postamble);
  403. /* soc */
  404. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  405. ar9300_2p2_soc_preamble);
  406. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  407. ar9300_2p2_soc_postamble);
  408. /* rx/tx gain */
  409. INIT_INI_ARRAY(&ah->iniModesRxGain,
  410. ar9300Common_rx_gain_table_2p2);
  411. INIT_INI_ARRAY(&ah->iniModesTxGain,
  412. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  413. /* Load PCIE SERDES settings from INI */
  414. /* Awake Setting */
  415. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  416. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  417. /* Sleep Setting */
  418. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  419. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
  420. /* Fast clock modal settings */
  421. INIT_INI_ARRAY(&ah->iniModesFastClock,
  422. ar9300Modes_fast_clock_2p2);
  423. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  424. ar9300_2p2_baseband_core_txfir_coeff_japan_2484);
  425. INIT_INI_ARRAY(&ah->ini_dfs,
  426. ar9300_2p2_baseband_postamble_dfs_channel);
  427. }
  428. }
  429. static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
  430. {
  431. if (AR_SREV_9330_12(ah))
  432. INIT_INI_ARRAY(&ah->iniModesTxGain,
  433. ar9331_modes_lowest_ob_db_tx_gain_1p2);
  434. else if (AR_SREV_9330_11(ah))
  435. INIT_INI_ARRAY(&ah->iniModesTxGain,
  436. ar9331_modes_lowest_ob_db_tx_gain_1p1);
  437. else if (AR_SREV_9340(ah))
  438. INIT_INI_ARRAY(&ah->iniModesTxGain,
  439. ar9340Modes_lowest_ob_db_tx_gain_table_1p0);
  440. else if (AR_SREV_9485_11_OR_LATER(ah))
  441. INIT_INI_ARRAY(&ah->iniModesTxGain,
  442. ar9485_modes_lowest_ob_db_tx_gain_1_1);
  443. else if (AR_SREV_9550(ah))
  444. INIT_INI_ARRAY(&ah->iniModesTxGain,
  445. ar955x_1p0_modes_xpa_tx_gain_table);
  446. else if (AR_SREV_9531(ah))
  447. INIT_INI_ARRAY(&ah->iniModesTxGain,
  448. qca953x_1p0_modes_xpa_tx_gain_table);
  449. else if (AR_SREV_9580(ah))
  450. INIT_INI_ARRAY(&ah->iniModesTxGain,
  451. ar9580_1p0_lowest_ob_db_tx_gain_table);
  452. else if (AR_SREV_9462_21(ah))
  453. INIT_INI_ARRAY(&ah->iniModesTxGain,
  454. ar9462_2p1_modes_low_ob_db_tx_gain);
  455. else if (AR_SREV_9462_20(ah))
  456. INIT_INI_ARRAY(&ah->iniModesTxGain,
  457. ar9462_2p0_modes_low_ob_db_tx_gain);
  458. else if (AR_SREV_9565_11(ah))
  459. INIT_INI_ARRAY(&ah->iniModesTxGain,
  460. ar9565_1p1_modes_low_ob_db_tx_gain_table);
  461. else if (AR_SREV_9565(ah))
  462. INIT_INI_ARRAY(&ah->iniModesTxGain,
  463. ar9565_1p0_modes_low_ob_db_tx_gain_table);
  464. else
  465. INIT_INI_ARRAY(&ah->iniModesTxGain,
  466. ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
  467. }
  468. static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
  469. {
  470. if (AR_SREV_9330_12(ah))
  471. INIT_INI_ARRAY(&ah->iniModesTxGain,
  472. ar9331_modes_high_ob_db_tx_gain_1p2);
  473. else if (AR_SREV_9330_11(ah))
  474. INIT_INI_ARRAY(&ah->iniModesTxGain,
  475. ar9331_modes_high_ob_db_tx_gain_1p1);
  476. else if (AR_SREV_9340(ah))
  477. INIT_INI_ARRAY(&ah->iniModesTxGain,
  478. ar9340Modes_high_ob_db_tx_gain_table_1p0);
  479. else if (AR_SREV_9485_11_OR_LATER(ah))
  480. INIT_INI_ARRAY(&ah->iniModesTxGain,
  481. ar9485Modes_high_ob_db_tx_gain_1_1);
  482. else if (AR_SREV_9580(ah))
  483. INIT_INI_ARRAY(&ah->iniModesTxGain,
  484. ar9580_1p0_high_ob_db_tx_gain_table);
  485. else if (AR_SREV_9550(ah))
  486. INIT_INI_ARRAY(&ah->iniModesTxGain,
  487. ar955x_1p0_modes_no_xpa_tx_gain_table);
  488. else if (AR_SREV_9531(ah)) {
  489. if (AR_SREV_9531_11(ah))
  490. INIT_INI_ARRAY(&ah->iniModesTxGain,
  491. qca953x_1p1_modes_no_xpa_tx_gain_table);
  492. else
  493. INIT_INI_ARRAY(&ah->iniModesTxGain,
  494. qca953x_1p0_modes_no_xpa_tx_gain_table);
  495. } else if (AR_SREV_9462_21(ah))
  496. INIT_INI_ARRAY(&ah->iniModesTxGain,
  497. ar9462_2p1_modes_high_ob_db_tx_gain);
  498. else if (AR_SREV_9462_20(ah))
  499. INIT_INI_ARRAY(&ah->iniModesTxGain,
  500. ar9462_2p0_modes_high_ob_db_tx_gain);
  501. else if (AR_SREV_9565_11(ah))
  502. INIT_INI_ARRAY(&ah->iniModesTxGain,
  503. ar9565_1p1_modes_high_ob_db_tx_gain_table);
  504. else if (AR_SREV_9565(ah))
  505. INIT_INI_ARRAY(&ah->iniModesTxGain,
  506. ar9565_1p0_modes_high_ob_db_tx_gain_table);
  507. else
  508. INIT_INI_ARRAY(&ah->iniModesTxGain,
  509. ar9300Modes_high_ob_db_tx_gain_table_2p2);
  510. }
  511. static void ar9003_tx_gain_table_mode2(struct ath_hw *ah)
  512. {
  513. if (AR_SREV_9330_12(ah))
  514. INIT_INI_ARRAY(&ah->iniModesTxGain,
  515. ar9331_modes_low_ob_db_tx_gain_1p2);
  516. else if (AR_SREV_9330_11(ah))
  517. INIT_INI_ARRAY(&ah->iniModesTxGain,
  518. ar9331_modes_low_ob_db_tx_gain_1p1);
  519. else if (AR_SREV_9340(ah))
  520. INIT_INI_ARRAY(&ah->iniModesTxGain,
  521. ar9340Modes_low_ob_db_tx_gain_table_1p0);
  522. else if (AR_SREV_9485_11_OR_LATER(ah))
  523. INIT_INI_ARRAY(&ah->iniModesTxGain,
  524. ar9485Modes_low_ob_db_tx_gain_1_1);
  525. else if (AR_SREV_9580(ah))
  526. INIT_INI_ARRAY(&ah->iniModesTxGain,
  527. ar9580_1p0_low_ob_db_tx_gain_table);
  528. else if (AR_SREV_9565_11(ah))
  529. INIT_INI_ARRAY(&ah->iniModesTxGain,
  530. ar9565_1p1_modes_low_ob_db_tx_gain_table);
  531. else if (AR_SREV_9565(ah))
  532. INIT_INI_ARRAY(&ah->iniModesTxGain,
  533. ar9565_1p0_modes_low_ob_db_tx_gain_table);
  534. else
  535. INIT_INI_ARRAY(&ah->iniModesTxGain,
  536. ar9300Modes_low_ob_db_tx_gain_table_2p2);
  537. }
  538. static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
  539. {
  540. if (AR_SREV_9330_12(ah))
  541. INIT_INI_ARRAY(&ah->iniModesTxGain,
  542. ar9331_modes_high_power_tx_gain_1p2);
  543. else if (AR_SREV_9330_11(ah))
  544. INIT_INI_ARRAY(&ah->iniModesTxGain,
  545. ar9331_modes_high_power_tx_gain_1p1);
  546. else if (AR_SREV_9340(ah))
  547. INIT_INI_ARRAY(&ah->iniModesTxGain,
  548. ar9340Modes_high_power_tx_gain_table_1p0);
  549. else if (AR_SREV_9485_11_OR_LATER(ah))
  550. INIT_INI_ARRAY(&ah->iniModesTxGain,
  551. ar9485Modes_high_power_tx_gain_1_1);
  552. else if (AR_SREV_9580(ah))
  553. INIT_INI_ARRAY(&ah->iniModesTxGain,
  554. ar9580_1p0_high_power_tx_gain_table);
  555. else if (AR_SREV_9565_11(ah))
  556. INIT_INI_ARRAY(&ah->iniModesTxGain,
  557. ar9565_1p1_modes_high_power_tx_gain_table);
  558. else if (AR_SREV_9565(ah))
  559. INIT_INI_ARRAY(&ah->iniModesTxGain,
  560. ar9565_1p0_modes_high_power_tx_gain_table);
  561. else {
  562. if (ah->config.tx_gain_buffalo)
  563. INIT_INI_ARRAY(&ah->iniModesTxGain,
  564. ar9300Modes_high_power_tx_gain_table_buffalo);
  565. else
  566. INIT_INI_ARRAY(&ah->iniModesTxGain,
  567. ar9300Modes_high_power_tx_gain_table_2p2);
  568. }
  569. }
  570. static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
  571. {
  572. if (AR_SREV_9340(ah))
  573. INIT_INI_ARRAY(&ah->iniModesTxGain,
  574. ar9340Modes_mixed_ob_db_tx_gain_table_1p0);
  575. else if (AR_SREV_9580(ah))
  576. INIT_INI_ARRAY(&ah->iniModesTxGain,
  577. ar9580_1p0_mixed_ob_db_tx_gain_table);
  578. else if (AR_SREV_9462_21(ah))
  579. INIT_INI_ARRAY(&ah->iniModesTxGain,
  580. ar9462_2p1_modes_mix_ob_db_tx_gain);
  581. else if (AR_SREV_9462_20(ah))
  582. INIT_INI_ARRAY(&ah->iniModesTxGain,
  583. ar9462_2p0_modes_mix_ob_db_tx_gain);
  584. else
  585. INIT_INI_ARRAY(&ah->iniModesTxGain,
  586. ar9300Modes_mixed_ob_db_tx_gain_table_2p2);
  587. }
  588. static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)
  589. {
  590. if (AR_SREV_9485_11_OR_LATER(ah))
  591. INIT_INI_ARRAY(&ah->iniModesTxGain,
  592. ar9485Modes_green_ob_db_tx_gain_1_1);
  593. else if (AR_SREV_9340(ah))
  594. INIT_INI_ARRAY(&ah->iniModesTxGain,
  595. ar9340Modes_ub124_tx_gain_table_1p0);
  596. else if (AR_SREV_9580(ah))
  597. INIT_INI_ARRAY(&ah->iniModesTxGain,
  598. ar9580_1p0_type5_tx_gain_table);
  599. else if (AR_SREV_9300_22(ah))
  600. INIT_INI_ARRAY(&ah->iniModesTxGain,
  601. ar9300Modes_type5_tx_gain_table_2p2);
  602. }
  603. static void ar9003_tx_gain_table_mode6(struct ath_hw *ah)
  604. {
  605. if (AR_SREV_9340(ah))
  606. INIT_INI_ARRAY(&ah->iniModesTxGain,
  607. ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0);
  608. else if (AR_SREV_9485_11_OR_LATER(ah))
  609. INIT_INI_ARRAY(&ah->iniModesTxGain,
  610. ar9485Modes_green_spur_ob_db_tx_gain_1_1);
  611. else if (AR_SREV_9580(ah))
  612. INIT_INI_ARRAY(&ah->iniModesTxGain,
  613. ar9580_1p0_type6_tx_gain_table);
  614. }
  615. static void ar9003_tx_gain_table_mode7(struct ath_hw *ah)
  616. {
  617. if (AR_SREV_9340(ah))
  618. INIT_INI_ARRAY(&ah->iniModesTxGain,
  619. ar9340_cus227_tx_gain_table_1p0);
  620. }
  621. typedef void (*ath_txgain_tab)(struct ath_hw *ah);
  622. static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
  623. {
  624. static const ath_txgain_tab modes[] = {
  625. ar9003_tx_gain_table_mode0,
  626. ar9003_tx_gain_table_mode1,
  627. ar9003_tx_gain_table_mode2,
  628. ar9003_tx_gain_table_mode3,
  629. ar9003_tx_gain_table_mode4,
  630. ar9003_tx_gain_table_mode5,
  631. ar9003_tx_gain_table_mode6,
  632. ar9003_tx_gain_table_mode7,
  633. };
  634. int idx = ar9003_hw_get_tx_gain_idx(ah);
  635. if (idx >= ARRAY_SIZE(modes))
  636. idx = 0;
  637. modes[idx](ah);
  638. }
  639. static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
  640. {
  641. if (AR_SREV_9330_12(ah))
  642. INIT_INI_ARRAY(&ah->iniModesRxGain,
  643. ar9331_common_rx_gain_1p2);
  644. else if (AR_SREV_9330_11(ah))
  645. INIT_INI_ARRAY(&ah->iniModesRxGain,
  646. ar9331_common_rx_gain_1p1);
  647. else if (AR_SREV_9340(ah))
  648. INIT_INI_ARRAY(&ah->iniModesRxGain,
  649. ar9340Common_rx_gain_table_1p0);
  650. else if (AR_SREV_9485_11_OR_LATER(ah))
  651. INIT_INI_ARRAY(&ah->iniModesRxGain,
  652. ar9485_common_rx_gain_1_1);
  653. else if (AR_SREV_9550(ah)) {
  654. INIT_INI_ARRAY(&ah->iniModesRxGain,
  655. ar955x_1p0_common_rx_gain_table);
  656. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  657. ar955x_1p0_common_rx_gain_bounds);
  658. } else if (AR_SREV_9531(ah)) {
  659. INIT_INI_ARRAY(&ah->iniModesRxGain,
  660. qca953x_1p0_common_rx_gain_table);
  661. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  662. qca953x_1p0_common_rx_gain_bounds);
  663. } else if (AR_SREV_9580(ah))
  664. INIT_INI_ARRAY(&ah->iniModesRxGain,
  665. ar9580_1p0_rx_gain_table);
  666. else if (AR_SREV_9462_21(ah))
  667. INIT_INI_ARRAY(&ah->iniModesRxGain,
  668. ar9462_2p1_common_rx_gain);
  669. else if (AR_SREV_9462_20(ah))
  670. INIT_INI_ARRAY(&ah->iniModesRxGain,
  671. ar9462_2p0_common_rx_gain);
  672. else if (AR_SREV_9565_11(ah))
  673. INIT_INI_ARRAY(&ah->iniModesRxGain,
  674. ar9565_1p1_Common_rx_gain_table);
  675. else if (AR_SREV_9565(ah))
  676. INIT_INI_ARRAY(&ah->iniModesRxGain,
  677. ar9565_1p0_Common_rx_gain_table);
  678. else
  679. INIT_INI_ARRAY(&ah->iniModesRxGain,
  680. ar9300Common_rx_gain_table_2p2);
  681. }
  682. static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
  683. {
  684. if (AR_SREV_9330_12(ah))
  685. INIT_INI_ARRAY(&ah->iniModesRxGain,
  686. ar9331_common_wo_xlna_rx_gain_1p2);
  687. else if (AR_SREV_9330_11(ah))
  688. INIT_INI_ARRAY(&ah->iniModesRxGain,
  689. ar9331_common_wo_xlna_rx_gain_1p1);
  690. else if (AR_SREV_9340(ah))
  691. INIT_INI_ARRAY(&ah->iniModesRxGain,
  692. ar9340Common_wo_xlna_rx_gain_table_1p0);
  693. else if (AR_SREV_9485_11_OR_LATER(ah))
  694. INIT_INI_ARRAY(&ah->iniModesRxGain,
  695. ar9485Common_wo_xlna_rx_gain_1_1);
  696. else if (AR_SREV_9462_21(ah))
  697. INIT_INI_ARRAY(&ah->iniModesRxGain,
  698. ar9462_2p1_common_wo_xlna_rx_gain);
  699. else if (AR_SREV_9462_20(ah))
  700. INIT_INI_ARRAY(&ah->iniModesRxGain,
  701. ar9462_2p0_common_wo_xlna_rx_gain);
  702. else if (AR_SREV_9550(ah)) {
  703. INIT_INI_ARRAY(&ah->iniModesRxGain,
  704. ar955x_1p0_common_wo_xlna_rx_gain_table);
  705. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  706. ar955x_1p0_common_wo_xlna_rx_gain_bounds);
  707. } else if (AR_SREV_9531(ah)) {
  708. INIT_INI_ARRAY(&ah->iniModesRxGain,
  709. qca953x_1p0_common_wo_xlna_rx_gain_table);
  710. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  711. qca953x_1p0_common_wo_xlna_rx_gain_bounds);
  712. } else if (AR_SREV_9580(ah))
  713. INIT_INI_ARRAY(&ah->iniModesRxGain,
  714. ar9580_1p0_wo_xlna_rx_gain_table);
  715. else if (AR_SREV_9565_11(ah))
  716. INIT_INI_ARRAY(&ah->iniModesRxGain,
  717. ar9565_1p1_common_wo_xlna_rx_gain_table);
  718. else if (AR_SREV_9565(ah))
  719. INIT_INI_ARRAY(&ah->iniModesRxGain,
  720. ar9565_1p0_common_wo_xlna_rx_gain_table);
  721. else
  722. INIT_INI_ARRAY(&ah->iniModesRxGain,
  723. ar9300Common_wo_xlna_rx_gain_table_2p2);
  724. }
  725. static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
  726. {
  727. if (AR_SREV_9462_21(ah)) {
  728. INIT_INI_ARRAY(&ah->iniModesRxGain,
  729. ar9462_2p1_common_mixed_rx_gain);
  730. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  731. ar9462_2p1_baseband_core_mix_rxgain);
  732. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  733. ar9462_2p1_baseband_postamble_mix_rxgain);
  734. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  735. ar9462_2p1_baseband_postamble_5g_xlna);
  736. } else if (AR_SREV_9462_20(ah)) {
  737. INIT_INI_ARRAY(&ah->iniModesRxGain,
  738. ar9462_2p0_common_mixed_rx_gain);
  739. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  740. ar9462_2p0_baseband_core_mix_rxgain);
  741. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  742. ar9462_2p0_baseband_postamble_mix_rxgain);
  743. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  744. ar9462_2p0_baseband_postamble_5g_xlna);
  745. }
  746. }
  747. static void ar9003_rx_gain_table_mode3(struct ath_hw *ah)
  748. {
  749. if (AR_SREV_9462_21(ah)) {
  750. INIT_INI_ARRAY(&ah->iniModesRxGain,
  751. ar9462_2p1_common_5g_xlna_only_rxgain);
  752. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  753. ar9462_2p1_baseband_postamble_5g_xlna);
  754. } else if (AR_SREV_9462_20(ah)) {
  755. INIT_INI_ARRAY(&ah->iniModesRxGain,
  756. ar9462_2p0_common_5g_xlna_only_rxgain);
  757. INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
  758. ar9462_2p0_baseband_postamble_5g_xlna);
  759. }
  760. }
  761. static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
  762. {
  763. switch (ar9003_hw_get_rx_gain_idx(ah)) {
  764. case 0:
  765. default:
  766. ar9003_rx_gain_table_mode0(ah);
  767. break;
  768. case 1:
  769. ar9003_rx_gain_table_mode1(ah);
  770. break;
  771. case 2:
  772. ar9003_rx_gain_table_mode2(ah);
  773. break;
  774. case 3:
  775. ar9003_rx_gain_table_mode3(ah);
  776. break;
  777. }
  778. }
  779. /* set gain table pointers according to values read from the eeprom */
  780. static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
  781. {
  782. ar9003_tx_gain_table_apply(ah);
  783. ar9003_rx_gain_table_apply(ah);
  784. }
  785. /*
  786. * Helper for ASPM support.
  787. *
  788. * Disable PLL when in L0s as well as receiver clock when in L1.
  789. * This power saving option must be enabled through the SerDes.
  790. *
  791. * Programming the SerDes must go through the same 288 bit serial shift
  792. * register as the other analog registers. Hence the 9 writes.
  793. */
  794. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  795. bool power_off)
  796. {
  797. unsigned int i;
  798. struct ar5416IniArray *array;
  799. /*
  800. * Increase L1 Entry Latency. Some WB222 boards don't have
  801. * this change in eeprom/OTP.
  802. *
  803. */
  804. if (AR_SREV_9462(ah)) {
  805. u32 val = ah->config.aspm_l1_fix;
  806. if ((val & 0xff000000) == 0x17000000) {
  807. val &= 0x00ffffff;
  808. val |= 0x27000000;
  809. REG_WRITE(ah, 0x570c, val);
  810. }
  811. }
  812. /* Nothing to do on restore for 11N */
  813. if (!power_off /* !restore */) {
  814. /* set bit 19 to allow forcing of pcie core into L1 state */
  815. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  816. REG_WRITE(ah, AR_WA, ah->WARegVal);
  817. }
  818. /*
  819. * Configire PCIE after Ini init. SERDES values now come from ini file
  820. * This enables PCIe low power mode.
  821. */
  822. array = power_off ? &ah->iniPcieSerdes :
  823. &ah->iniPcieSerdesLowPower;
  824. for (i = 0; i < array->ia_rows; i++) {
  825. REG_WRITE(ah,
  826. INI_RA(array, i, 0),
  827. INI_RA(array, i, 1));
  828. }
  829. }
  830. static void ar9003_hw_init_hang_checks(struct ath_hw *ah)
  831. {
  832. /*
  833. * All chips support detection of BB/MAC hangs.
  834. */
  835. ah->config.hw_hang_checks |= HW_BB_WATCHDOG;
  836. ah->config.hw_hang_checks |= HW_MAC_HANG;
  837. /*
  838. * This is not required for AR9580 1.0
  839. */
  840. if (AR_SREV_9300_22(ah))
  841. ah->config.hw_hang_checks |= HW_PHYRESTART_CLC_WAR;
  842. if (AR_SREV_9330(ah))
  843. ah->bb_watchdog_timeout_ms = 85;
  844. else
  845. ah->bb_watchdog_timeout_ms = 25;
  846. }
  847. /*
  848. * MAC HW hang check
  849. * =================
  850. *
  851. * Signature: dcu_chain_state is 0x6 and dcu_complete_state is 0x1.
  852. *
  853. * The state of each DCU chain (mapped to TX queues) is available from these
  854. * DMA debug registers:
  855. *
  856. * Chain 0 state : Bits 4:0 of AR_DMADBG_4
  857. * Chain 1 state : Bits 9:5 of AR_DMADBG_4
  858. * Chain 2 state : Bits 14:10 of AR_DMADBG_4
  859. * Chain 3 state : Bits 19:15 of AR_DMADBG_4
  860. * Chain 4 state : Bits 24:20 of AR_DMADBG_4
  861. * Chain 5 state : Bits 29:25 of AR_DMADBG_4
  862. * Chain 6 state : Bits 4:0 of AR_DMADBG_5
  863. * Chain 7 state : Bits 9:5 of AR_DMADBG_5
  864. * Chain 8 state : Bits 14:10 of AR_DMADBG_5
  865. * Chain 9 state : Bits 19:15 of AR_DMADBG_5
  866. *
  867. * The DCU chain state "0x6" means "WAIT_FRDONE" - wait for TX frame to be done.
  868. */
  869. #define NUM_STATUS_READS 50
  870. static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue)
  871. {
  872. u32 dma_dbg_chain, dma_dbg_complete;
  873. u8 dcu_chain_state, dcu_complete_state;
  874. int i;
  875. for (i = 0; i < NUM_STATUS_READS; i++) {
  876. if (queue < 6)
  877. dma_dbg_chain = REG_READ(ah, AR_DMADBG_4);
  878. else
  879. dma_dbg_chain = REG_READ(ah, AR_DMADBG_5);
  880. dma_dbg_complete = REG_READ(ah, AR_DMADBG_6);
  881. dcu_chain_state = (dma_dbg_chain >> (5 * queue)) & 0x1f;
  882. dcu_complete_state = dma_dbg_complete & 0x3;
  883. if ((dcu_chain_state != 0x6) || (dcu_complete_state != 0x1))
  884. return false;
  885. }
  886. ath_dbg(ath9k_hw_common(ah), RESET,
  887. "MAC Hang signature found for queue: %d\n", queue);
  888. return true;
  889. }
  890. static bool ar9003_hw_detect_mac_hang(struct ath_hw *ah)
  891. {
  892. u32 dma_dbg_4, dma_dbg_5, dma_dbg_6, chk_dbg;
  893. u8 dcu_chain_state, dcu_complete_state;
  894. bool dcu_wait_frdone = false;
  895. unsigned long chk_dcu = 0;
  896. unsigned int i = 0;
  897. dma_dbg_4 = REG_READ(ah, AR_DMADBG_4);
  898. dma_dbg_5 = REG_READ(ah, AR_DMADBG_5);
  899. dma_dbg_6 = REG_READ(ah, AR_DMADBG_6);
  900. dcu_complete_state = dma_dbg_6 & 0x3;
  901. if (dcu_complete_state != 0x1)
  902. goto exit;
  903. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  904. if (i < 6)
  905. chk_dbg = dma_dbg_4;
  906. else
  907. chk_dbg = dma_dbg_5;
  908. dcu_chain_state = (chk_dbg >> (5 * i)) & 0x1f;
  909. if (dcu_chain_state == 0x6) {
  910. dcu_wait_frdone = true;
  911. chk_dcu |= BIT(i);
  912. }
  913. }
  914. if ((dcu_complete_state == 0x1) && dcu_wait_frdone) {
  915. for_each_set_bit(i, &chk_dcu, ATH9K_NUM_TX_QUEUES) {
  916. if (ath9k_hw_verify_hang(ah, i))
  917. return true;
  918. }
  919. }
  920. exit:
  921. return false;
  922. }
  923. /* Sets up the AR9003 hardware familiy callbacks */
  924. void ar9003_hw_attach_ops(struct ath_hw *ah)
  925. {
  926. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  927. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  928. ar9003_hw_init_mode_regs(ah);
  929. priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
  930. priv_ops->init_hang_checks = ar9003_hw_init_hang_checks;
  931. priv_ops->detect_mac_hang = ar9003_hw_detect_mac_hang;
  932. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  933. ar9003_hw_attach_phy_ops(ah);
  934. ar9003_hw_attach_calib_ops(ah);
  935. ar9003_hw_attach_mac_ops(ah);
  936. }