ar9003_hw.c 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  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_9485_11_OR_LATER(ah))
  619. INIT_INI_ARRAY(&ah->iniModesTxGain,
  620. ar9485Modes_low_ob_db_tx_gain_1_1);
  621. else if (AR_SREV_9580(ah))
  622. INIT_INI_ARRAY(&ah->iniModesTxGain,
  623. ar9580_1p0_low_ob_db_tx_gain_table);
  624. else if (AR_SREV_9561(ah))
  625. INIT_INI_ARRAY(&ah->iniModesTxGain,
  626. qca956x_1p0_modes_no_xpa_low_ob_db_tx_gain_table);
  627. else if (AR_SREV_9565_11(ah))
  628. INIT_INI_ARRAY(&ah->iniModesTxGain,
  629. ar9565_1p1_modes_low_ob_db_tx_gain_table);
  630. else if (AR_SREV_9565(ah))
  631. INIT_INI_ARRAY(&ah->iniModesTxGain,
  632. ar9565_1p0_modes_low_ob_db_tx_gain_table);
  633. else
  634. INIT_INI_ARRAY(&ah->iniModesTxGain,
  635. ar9300Modes_low_ob_db_tx_gain_table_2p2);
  636. }
  637. static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
  638. {
  639. if (AR_SREV_9330_12(ah))
  640. INIT_INI_ARRAY(&ah->iniModesTxGain,
  641. ar9331_modes_high_power_tx_gain_1p2);
  642. else if (AR_SREV_9330_11(ah))
  643. INIT_INI_ARRAY(&ah->iniModesTxGain,
  644. ar9331_modes_high_power_tx_gain_1p1);
  645. else if (AR_SREV_9340(ah))
  646. INIT_INI_ARRAY(&ah->iniModesTxGain,
  647. ar9340Modes_high_power_tx_gain_table_1p0);
  648. else if (AR_SREV_9485_11_OR_LATER(ah))
  649. INIT_INI_ARRAY(&ah->iniModesTxGain,
  650. ar9485Modes_high_power_tx_gain_1_1);
  651. else if (AR_SREV_9580(ah))
  652. INIT_INI_ARRAY(&ah->iniModesTxGain,
  653. ar9580_1p0_high_power_tx_gain_table);
  654. else if (AR_SREV_9565_11(ah))
  655. INIT_INI_ARRAY(&ah->iniModesTxGain,
  656. ar9565_1p1_modes_high_power_tx_gain_table);
  657. else if (AR_SREV_9565(ah))
  658. INIT_INI_ARRAY(&ah->iniModesTxGain,
  659. ar9565_1p0_modes_high_power_tx_gain_table);
  660. else {
  661. if (ah->config.tx_gain_buffalo)
  662. INIT_INI_ARRAY(&ah->iniModesTxGain,
  663. ar9300Modes_high_power_tx_gain_table_buffalo);
  664. else
  665. INIT_INI_ARRAY(&ah->iniModesTxGain,
  666. ar9300Modes_high_power_tx_gain_table_2p2);
  667. }
  668. }
  669. static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
  670. {
  671. if (AR_SREV_9340(ah))
  672. INIT_INI_ARRAY(&ah->iniModesTxGain,
  673. ar9340Modes_mixed_ob_db_tx_gain_table_1p0);
  674. else if (AR_SREV_9580(ah))
  675. INIT_INI_ARRAY(&ah->iniModesTxGain,
  676. ar9580_1p0_mixed_ob_db_tx_gain_table);
  677. else if (AR_SREV_9462_21(ah))
  678. INIT_INI_ARRAY(&ah->iniModesTxGain,
  679. ar9462_2p1_modes_mix_ob_db_tx_gain);
  680. else if (AR_SREV_9462_20(ah))
  681. INIT_INI_ARRAY(&ah->iniModesTxGain,
  682. ar9462_2p0_modes_mix_ob_db_tx_gain);
  683. else
  684. INIT_INI_ARRAY(&ah->iniModesTxGain,
  685. ar9300Modes_mixed_ob_db_tx_gain_table_2p2);
  686. }
  687. static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)
  688. {
  689. if (AR_SREV_9485_11_OR_LATER(ah))
  690. INIT_INI_ARRAY(&ah->iniModesTxGain,
  691. ar9485Modes_green_ob_db_tx_gain_1_1);
  692. else if (AR_SREV_9580(ah))
  693. INIT_INI_ARRAY(&ah->iniModesTxGain,
  694. ar9580_1p0_type5_tx_gain_table);
  695. else if (AR_SREV_9561(ah))
  696. INIT_INI_ARRAY(&ah->iniModesTxGain,
  697. qca956x_1p0_modes_no_xpa_green_tx_gain_table);
  698. else if (AR_SREV_9300_22(ah))
  699. INIT_INI_ARRAY(&ah->iniModesTxGain,
  700. ar9300Modes_type5_tx_gain_table_2p2);
  701. }
  702. static void ar9003_tx_gain_table_mode6(struct ath_hw *ah)
  703. {
  704. if (AR_SREV_9340(ah))
  705. INIT_INI_ARRAY(&ah->iniModesTxGain,
  706. ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0);
  707. else if (AR_SREV_9485_11_OR_LATER(ah))
  708. INIT_INI_ARRAY(&ah->iniModesTxGain,
  709. ar9485Modes_green_spur_ob_db_tx_gain_1_1);
  710. else if (AR_SREV_9580(ah))
  711. INIT_INI_ARRAY(&ah->iniModesTxGain,
  712. ar9580_1p0_type6_tx_gain_table);
  713. }
  714. static void ar9003_tx_gain_table_mode7(struct ath_hw *ah)
  715. {
  716. if (AR_SREV_9340(ah))
  717. INIT_INI_ARRAY(&ah->iniModesTxGain,
  718. ar9340_cus227_tx_gain_table_1p0);
  719. }
  720. typedef void (*ath_txgain_tab)(struct ath_hw *ah);
  721. static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
  722. {
  723. static const ath_txgain_tab modes[] = {
  724. ar9003_tx_gain_table_mode0,
  725. ar9003_tx_gain_table_mode1,
  726. ar9003_tx_gain_table_mode2,
  727. ar9003_tx_gain_table_mode3,
  728. ar9003_tx_gain_table_mode4,
  729. ar9003_tx_gain_table_mode5,
  730. ar9003_tx_gain_table_mode6,
  731. ar9003_tx_gain_table_mode7,
  732. };
  733. int idx = ar9003_hw_get_tx_gain_idx(ah);
  734. if (idx >= ARRAY_SIZE(modes))
  735. idx = 0;
  736. modes[idx](ah);
  737. }
  738. static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
  739. {
  740. if (AR_SREV_9330_12(ah))
  741. INIT_INI_ARRAY(&ah->iniModesRxGain,
  742. ar9331_common_rx_gain_1p2);
  743. else if (AR_SREV_9330_11(ah))
  744. INIT_INI_ARRAY(&ah->iniModesRxGain,
  745. ar9331_common_rx_gain_1p1);
  746. else if (AR_SREV_9340(ah))
  747. INIT_INI_ARRAY(&ah->iniModesRxGain,
  748. ar9340Common_rx_gain_table_1p0);
  749. else if (AR_SREV_9485_11_OR_LATER(ah))
  750. INIT_INI_ARRAY(&ah->iniModesRxGain,
  751. ar9485_common_rx_gain_1_1);
  752. else if (AR_SREV_9550(ah)) {
  753. INIT_INI_ARRAY(&ah->iniModesRxGain,
  754. ar955x_1p0_common_rx_gain_table);
  755. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  756. ar955x_1p0_common_rx_gain_bounds);
  757. } else if (AR_SREV_9531(ah)) {
  758. INIT_INI_ARRAY(&ah->iniModesRxGain,
  759. qca953x_1p0_common_rx_gain_table);
  760. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  761. qca953x_1p0_common_rx_gain_bounds);
  762. } else if (AR_SREV_9561(ah)) {
  763. INIT_INI_ARRAY(&ah->iniModesRxGain,
  764. qca956x_1p0_common_rx_gain_table);
  765. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  766. qca956x_1p0_common_rx_gain_bounds);
  767. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  768. qca956x_1p0_xlna_only);
  769. } else if (AR_SREV_9580(ah))
  770. INIT_INI_ARRAY(&ah->iniModesRxGain,
  771. ar9580_1p0_rx_gain_table);
  772. else if (AR_SREV_9462_21(ah))
  773. INIT_INI_ARRAY(&ah->iniModesRxGain,
  774. ar9462_2p1_common_rx_gain);
  775. else if (AR_SREV_9462_20(ah))
  776. INIT_INI_ARRAY(&ah->iniModesRxGain,
  777. ar9462_2p0_common_rx_gain);
  778. else if (AR_SREV_9565_11(ah))
  779. INIT_INI_ARRAY(&ah->iniModesRxGain,
  780. ar9565_1p1_Common_rx_gain_table);
  781. else if (AR_SREV_9565(ah))
  782. INIT_INI_ARRAY(&ah->iniModesRxGain,
  783. ar9565_1p0_Common_rx_gain_table);
  784. else
  785. INIT_INI_ARRAY(&ah->iniModesRxGain,
  786. ar9300Common_rx_gain_table_2p2);
  787. }
  788. static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
  789. {
  790. if (AR_SREV_9330_12(ah))
  791. INIT_INI_ARRAY(&ah->iniModesRxGain,
  792. ar9331_common_wo_xlna_rx_gain_1p2);
  793. else if (AR_SREV_9330_11(ah))
  794. INIT_INI_ARRAY(&ah->iniModesRxGain,
  795. ar9331_common_wo_xlna_rx_gain_1p1);
  796. else if (AR_SREV_9340(ah))
  797. INIT_INI_ARRAY(&ah->iniModesRxGain,
  798. ar9340Common_wo_xlna_rx_gain_table_1p0);
  799. else if (AR_SREV_9485_11_OR_LATER(ah))
  800. INIT_INI_ARRAY(&ah->iniModesRxGain,
  801. ar9485Common_wo_xlna_rx_gain_1_1);
  802. else if (AR_SREV_9462_21(ah))
  803. INIT_INI_ARRAY(&ah->iniModesRxGain,
  804. ar9462_2p1_common_wo_xlna_rx_gain);
  805. else if (AR_SREV_9462_20(ah))
  806. INIT_INI_ARRAY(&ah->iniModesRxGain,
  807. ar9462_2p0_common_wo_xlna_rx_gain);
  808. else if (AR_SREV_9550(ah)) {
  809. INIT_INI_ARRAY(&ah->iniModesRxGain,
  810. ar955x_1p0_common_wo_xlna_rx_gain_table);
  811. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  812. ar955x_1p0_common_wo_xlna_rx_gain_bounds);
  813. } else if (AR_SREV_9531_10(ah) || AR_SREV_9531_11(ah)) {
  814. INIT_INI_ARRAY(&ah->iniModesRxGain,
  815. qca953x_1p0_common_wo_xlna_rx_gain_table);
  816. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  817. qca953x_1p0_common_wo_xlna_rx_gain_bounds);
  818. } else if (AR_SREV_9531_20(ah)) {
  819. INIT_INI_ARRAY(&ah->iniModesRxGain,
  820. qca953x_2p0_common_wo_xlna_rx_gain_table);
  821. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  822. qca953x_2p0_common_wo_xlna_rx_gain_bounds);
  823. } else if (AR_SREV_9561(ah)) {
  824. INIT_INI_ARRAY(&ah->iniModesRxGain,
  825. qca956x_1p0_common_wo_xlna_rx_gain_table);
  826. INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
  827. qca956x_1p0_common_wo_xlna_rx_gain_bounds);
  828. } else if (AR_SREV_9580(ah))
  829. INIT_INI_ARRAY(&ah->iniModesRxGain,
  830. ar9580_1p0_wo_xlna_rx_gain_table);
  831. else if (AR_SREV_9565_11(ah))
  832. INIT_INI_ARRAY(&ah->iniModesRxGain,
  833. ar9565_1p1_common_wo_xlna_rx_gain_table);
  834. else if (AR_SREV_9565(ah))
  835. INIT_INI_ARRAY(&ah->iniModesRxGain,
  836. ar9565_1p0_common_wo_xlna_rx_gain_table);
  837. else
  838. INIT_INI_ARRAY(&ah->iniModesRxGain,
  839. ar9300Common_wo_xlna_rx_gain_table_2p2);
  840. }
  841. static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
  842. {
  843. if (AR_SREV_9462_21(ah)) {
  844. INIT_INI_ARRAY(&ah->iniModesRxGain,
  845. ar9462_2p1_common_mixed_rx_gain);
  846. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  847. ar9462_2p1_baseband_core_mix_rxgain);
  848. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  849. ar9462_2p1_baseband_postamble_mix_rxgain);
  850. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  851. ar9462_2p1_baseband_postamble_5g_xlna);
  852. } else if (AR_SREV_9462_20(ah)) {
  853. INIT_INI_ARRAY(&ah->iniModesRxGain,
  854. ar9462_2p0_common_mixed_rx_gain);
  855. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
  856. ar9462_2p0_baseband_core_mix_rxgain);
  857. INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
  858. ar9462_2p0_baseband_postamble_mix_rxgain);
  859. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  860. ar9462_2p0_baseband_postamble_5g_xlna);
  861. }
  862. }
  863. static void ar9003_rx_gain_table_mode3(struct ath_hw *ah)
  864. {
  865. if (AR_SREV_9462_21(ah)) {
  866. INIT_INI_ARRAY(&ah->iniModesRxGain,
  867. ar9462_2p1_common_5g_xlna_only_rxgain);
  868. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  869. ar9462_2p1_baseband_postamble_5g_xlna);
  870. } else if (AR_SREV_9462_20(ah)) {
  871. INIT_INI_ARRAY(&ah->iniModesRxGain,
  872. ar9462_2p0_common_5g_xlna_only_rxgain);
  873. INIT_INI_ARRAY(&ah->ini_modes_rxgain_xlna,
  874. ar9462_2p0_baseband_postamble_5g_xlna);
  875. }
  876. }
  877. static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
  878. {
  879. switch (ar9003_hw_get_rx_gain_idx(ah)) {
  880. case 0:
  881. default:
  882. ar9003_rx_gain_table_mode0(ah);
  883. break;
  884. case 1:
  885. ar9003_rx_gain_table_mode1(ah);
  886. break;
  887. case 2:
  888. ar9003_rx_gain_table_mode2(ah);
  889. break;
  890. case 3:
  891. ar9003_rx_gain_table_mode3(ah);
  892. break;
  893. }
  894. }
  895. /* set gain table pointers according to values read from the eeprom */
  896. static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
  897. {
  898. ar9003_tx_gain_table_apply(ah);
  899. ar9003_rx_gain_table_apply(ah);
  900. }
  901. /*
  902. * Helper for ASPM support.
  903. *
  904. * Disable PLL when in L0s as well as receiver clock when in L1.
  905. * This power saving option must be enabled through the SerDes.
  906. *
  907. * Programming the SerDes must go through the same 288 bit serial shift
  908. * register as the other analog registers. Hence the 9 writes.
  909. */
  910. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  911. bool power_off)
  912. {
  913. unsigned int i;
  914. struct ar5416IniArray *array;
  915. /*
  916. * Increase L1 Entry Latency. Some WB222 boards don't have
  917. * this change in eeprom/OTP.
  918. *
  919. */
  920. if (AR_SREV_9462(ah)) {
  921. u32 val = ah->config.aspm_l1_fix;
  922. if ((val & 0xff000000) == 0x17000000) {
  923. val &= 0x00ffffff;
  924. val |= 0x27000000;
  925. REG_WRITE(ah, 0x570c, val);
  926. }
  927. }
  928. /* Nothing to do on restore for 11N */
  929. if (!power_off /* !restore */) {
  930. /* set bit 19 to allow forcing of pcie core into L1 state */
  931. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  932. REG_WRITE(ah, AR_WA, ah->WARegVal);
  933. }
  934. /*
  935. * Configire PCIE after Ini init. SERDES values now come from ini file
  936. * This enables PCIe low power mode.
  937. */
  938. array = power_off ? &ah->iniPcieSerdes :
  939. &ah->iniPcieSerdesLowPower;
  940. for (i = 0; i < array->ia_rows; i++) {
  941. REG_WRITE(ah,
  942. INI_RA(array, i, 0),
  943. INI_RA(array, i, 1));
  944. }
  945. }
  946. static void ar9003_hw_init_hang_checks(struct ath_hw *ah)
  947. {
  948. /*
  949. * All chips support detection of BB/MAC hangs.
  950. */
  951. ah->config.hw_hang_checks |= HW_BB_WATCHDOG;
  952. ah->config.hw_hang_checks |= HW_MAC_HANG;
  953. /*
  954. * This is not required for AR9580 1.0
  955. */
  956. if (AR_SREV_9300_22(ah))
  957. ah->config.hw_hang_checks |= HW_PHYRESTART_CLC_WAR;
  958. if (AR_SREV_9330(ah))
  959. ah->bb_watchdog_timeout_ms = 85;
  960. else
  961. ah->bb_watchdog_timeout_ms = 25;
  962. }
  963. /*
  964. * MAC HW hang check
  965. * =================
  966. *
  967. * Signature: dcu_chain_state is 0x6 and dcu_complete_state is 0x1.
  968. *
  969. * The state of each DCU chain (mapped to TX queues) is available from these
  970. * DMA debug registers:
  971. *
  972. * Chain 0 state : Bits 4:0 of AR_DMADBG_4
  973. * Chain 1 state : Bits 9:5 of AR_DMADBG_4
  974. * Chain 2 state : Bits 14:10 of AR_DMADBG_4
  975. * Chain 3 state : Bits 19:15 of AR_DMADBG_4
  976. * Chain 4 state : Bits 24:20 of AR_DMADBG_4
  977. * Chain 5 state : Bits 29:25 of AR_DMADBG_4
  978. * Chain 6 state : Bits 4:0 of AR_DMADBG_5
  979. * Chain 7 state : Bits 9:5 of AR_DMADBG_5
  980. * Chain 8 state : Bits 14:10 of AR_DMADBG_5
  981. * Chain 9 state : Bits 19:15 of AR_DMADBG_5
  982. *
  983. * The DCU chain state "0x6" means "WAIT_FRDONE" - wait for TX frame to be done.
  984. */
  985. #define NUM_STATUS_READS 50
  986. static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue)
  987. {
  988. u32 dma_dbg_chain, dma_dbg_complete;
  989. u8 dcu_chain_state, dcu_complete_state;
  990. int i;
  991. for (i = 0; i < NUM_STATUS_READS; i++) {
  992. if (queue < 6)
  993. dma_dbg_chain = REG_READ(ah, AR_DMADBG_4);
  994. else
  995. dma_dbg_chain = REG_READ(ah, AR_DMADBG_5);
  996. dma_dbg_complete = REG_READ(ah, AR_DMADBG_6);
  997. dcu_chain_state = (dma_dbg_chain >> (5 * queue)) & 0x1f;
  998. dcu_complete_state = dma_dbg_complete & 0x3;
  999. if ((dcu_chain_state != 0x6) || (dcu_complete_state != 0x1))
  1000. return false;
  1001. }
  1002. ath_dbg(ath9k_hw_common(ah), RESET,
  1003. "MAC Hang signature found for queue: %d\n", queue);
  1004. return true;
  1005. }
  1006. static bool ar9003_hw_detect_mac_hang(struct ath_hw *ah)
  1007. {
  1008. u32 dma_dbg_4, dma_dbg_5, dma_dbg_6, chk_dbg;
  1009. u8 dcu_chain_state, dcu_complete_state;
  1010. bool dcu_wait_frdone = false;
  1011. unsigned long chk_dcu = 0;
  1012. unsigned int i = 0;
  1013. dma_dbg_4 = REG_READ(ah, AR_DMADBG_4);
  1014. dma_dbg_5 = REG_READ(ah, AR_DMADBG_5);
  1015. dma_dbg_6 = REG_READ(ah, AR_DMADBG_6);
  1016. dcu_complete_state = dma_dbg_6 & 0x3;
  1017. if (dcu_complete_state != 0x1)
  1018. goto exit;
  1019. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  1020. if (i < 6)
  1021. chk_dbg = dma_dbg_4;
  1022. else
  1023. chk_dbg = dma_dbg_5;
  1024. dcu_chain_state = (chk_dbg >> (5 * i)) & 0x1f;
  1025. if (dcu_chain_state == 0x6) {
  1026. dcu_wait_frdone = true;
  1027. chk_dcu |= BIT(i);
  1028. }
  1029. }
  1030. if ((dcu_complete_state == 0x1) && dcu_wait_frdone) {
  1031. for_each_set_bit(i, &chk_dcu, ATH9K_NUM_TX_QUEUES) {
  1032. if (ath9k_hw_verify_hang(ah, i))
  1033. return true;
  1034. }
  1035. }
  1036. exit:
  1037. return false;
  1038. }
  1039. /* Sets up the AR9003 hardware familiy callbacks */
  1040. void ar9003_hw_attach_ops(struct ath_hw *ah)
  1041. {
  1042. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  1043. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  1044. ar9003_hw_init_mode_regs(ah);
  1045. if (AR_SREV_9003_PCOEM(ah)) {
  1046. WARN_ON(!ah->iniPcieSerdes.ia_array);
  1047. WARN_ON(!ah->iniPcieSerdesLowPower.ia_array);
  1048. }
  1049. priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
  1050. priv_ops->init_hang_checks = ar9003_hw_init_hang_checks;
  1051. priv_ops->detect_mac_hang = ar9003_hw_detect_mac_hang;
  1052. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  1053. ar9003_hw_attach_phy_ops(ah);
  1054. ar9003_hw_attach_calib_ops(ah);
  1055. ar9003_hw_attach_mac_ops(ah);
  1056. ar9003_hw_attach_aic_ops(ah);
  1057. }