ar9003_hw.c 27 KB

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