ar9003_hw.c 32 KB

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