ar9003_hw.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  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 "ar9485_initvals.h"
  20. #include "ar9340_initvals.h"
  21. #include "ar9330_1p1_initvals.h"
  22. #include "ar9330_1p2_initvals.h"
  23. #include "ar955x_1p0_initvals.h"
  24. #include "ar9580_1p0_initvals.h"
  25. #include "ar9462_2p0_initvals.h"
  26. /* General hardware code for the AR9003 hadware family */
  27. /*
  28. * The AR9003 family uses a new INI format (pre, core, post
  29. * arrays per subsystem). This provides support for the
  30. * AR9003 2.2 chipsets.
  31. */
  32. static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
  33. {
  34. #define PCIE_PLL_ON_CREQ_DIS_L1_2P0 \
  35. ar9462_pciephy_pll_on_clkreq_disable_L1_2p0
  36. #define AR9462_BB_CTX_COEFJ(x) \
  37. ar9462_##x##_baseband_core_txfir_coeff_japan_2484
  38. #define AR9462_BBC_TXIFR_COEFFJ \
  39. ar9462_2p0_baseband_core_txfir_coeff_japan_2484
  40. if (AR_SREV_9330_11(ah)) {
  41. /* mac */
  42. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  43. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  44. ar9331_1p1_mac_core,
  45. ARRAY_SIZE(ar9331_1p1_mac_core), 2);
  46. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  47. ar9331_1p1_mac_postamble,
  48. ARRAY_SIZE(ar9331_1p1_mac_postamble), 5);
  49. /* bb */
  50. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  51. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  52. ar9331_1p1_baseband_core,
  53. ARRAY_SIZE(ar9331_1p1_baseband_core), 2);
  54. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  55. ar9331_1p1_baseband_postamble,
  56. ARRAY_SIZE(ar9331_1p1_baseband_postamble), 5);
  57. /* radio */
  58. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  59. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  60. ar9331_1p1_radio_core,
  61. ARRAY_SIZE(ar9331_1p1_radio_core), 2);
  62. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0);
  63. /* soc */
  64. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  65. ar9331_1p1_soc_preamble,
  66. ARRAY_SIZE(ar9331_1p1_soc_preamble), 2);
  67. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  68. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  69. ar9331_1p1_soc_postamble,
  70. ARRAY_SIZE(ar9331_1p1_soc_postamble), 2);
  71. /* rx/tx gain */
  72. INIT_INI_ARRAY(&ah->iniModesRxGain,
  73. ar9331_common_rx_gain_1p1,
  74. ARRAY_SIZE(ar9331_common_rx_gain_1p1), 2);
  75. INIT_INI_ARRAY(&ah->iniModesTxGain,
  76. ar9331_modes_lowest_ob_db_tx_gain_1p1,
  77. ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1),
  78. 5);
  79. /* additional clock settings */
  80. if (ah->is_clk_25mhz)
  81. INIT_INI_ARRAY(&ah->iniAdditional,
  82. ar9331_1p1_xtal_25M,
  83. ARRAY_SIZE(ar9331_1p1_xtal_25M), 2);
  84. else
  85. INIT_INI_ARRAY(&ah->iniAdditional,
  86. ar9331_1p1_xtal_40M,
  87. ARRAY_SIZE(ar9331_1p1_xtal_40M), 2);
  88. } else if (AR_SREV_9330_12(ah)) {
  89. /* mac */
  90. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  91. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  92. ar9331_1p2_mac_core,
  93. ARRAY_SIZE(ar9331_1p2_mac_core), 2);
  94. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  95. ar9331_1p2_mac_postamble,
  96. ARRAY_SIZE(ar9331_1p2_mac_postamble), 5);
  97. /* bb */
  98. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  99. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  100. ar9331_1p2_baseband_core,
  101. ARRAY_SIZE(ar9331_1p2_baseband_core), 2);
  102. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  103. ar9331_1p2_baseband_postamble,
  104. ARRAY_SIZE(ar9331_1p2_baseband_postamble), 5);
  105. /* radio */
  106. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  107. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  108. ar9331_1p2_radio_core,
  109. ARRAY_SIZE(ar9331_1p2_radio_core), 2);
  110. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0);
  111. /* soc */
  112. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  113. ar9331_1p2_soc_preamble,
  114. ARRAY_SIZE(ar9331_1p2_soc_preamble), 2);
  115. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  116. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  117. ar9331_1p2_soc_postamble,
  118. ARRAY_SIZE(ar9331_1p2_soc_postamble), 2);
  119. /* rx/tx gain */
  120. INIT_INI_ARRAY(&ah->iniModesRxGain,
  121. ar9331_common_rx_gain_1p2,
  122. ARRAY_SIZE(ar9331_common_rx_gain_1p2), 2);
  123. INIT_INI_ARRAY(&ah->iniModesTxGain,
  124. ar9331_modes_lowest_ob_db_tx_gain_1p2,
  125. ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2),
  126. 5);
  127. /* additional clock settings */
  128. if (ah->is_clk_25mhz)
  129. INIT_INI_ARRAY(&ah->iniAdditional,
  130. ar9331_1p2_xtal_25M,
  131. ARRAY_SIZE(ar9331_1p2_xtal_25M), 2);
  132. else
  133. INIT_INI_ARRAY(&ah->iniAdditional,
  134. ar9331_1p2_xtal_40M,
  135. ARRAY_SIZE(ar9331_1p2_xtal_40M), 2);
  136. } else if (AR_SREV_9340(ah)) {
  137. /* mac */
  138. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  139. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  140. ar9340_1p0_mac_core,
  141. ARRAY_SIZE(ar9340_1p0_mac_core), 2);
  142. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  143. ar9340_1p0_mac_postamble,
  144. ARRAY_SIZE(ar9340_1p0_mac_postamble), 5);
  145. /* bb */
  146. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  147. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  148. ar9340_1p0_baseband_core,
  149. ARRAY_SIZE(ar9340_1p0_baseband_core), 2);
  150. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  151. ar9340_1p0_baseband_postamble,
  152. ARRAY_SIZE(ar9340_1p0_baseband_postamble), 5);
  153. /* radio */
  154. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  155. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  156. ar9340_1p0_radio_core,
  157. ARRAY_SIZE(ar9340_1p0_radio_core), 2);
  158. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  159. ar9340_1p0_radio_postamble,
  160. ARRAY_SIZE(ar9340_1p0_radio_postamble), 5);
  161. /* soc */
  162. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  163. ar9340_1p0_soc_preamble,
  164. ARRAY_SIZE(ar9340_1p0_soc_preamble), 2);
  165. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  166. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  167. ar9340_1p0_soc_postamble,
  168. ARRAY_SIZE(ar9340_1p0_soc_postamble), 5);
  169. /* rx/tx gain */
  170. INIT_INI_ARRAY(&ah->iniModesRxGain,
  171. ar9340Common_wo_xlna_rx_gain_table_1p0,
  172. ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0),
  173. 5);
  174. INIT_INI_ARRAY(&ah->iniModesTxGain,
  175. ar9340Modes_high_ob_db_tx_gain_table_1p0,
  176. ARRAY_SIZE(ar9340Modes_high_ob_db_tx_gain_table_1p0),
  177. 5);
  178. INIT_INI_ARRAY(&ah->iniModesFastClock,
  179. ar9340Modes_fast_clock_1p0,
  180. ARRAY_SIZE(ar9340Modes_fast_clock_1p0),
  181. 3);
  182. if (!ah->is_clk_25mhz)
  183. INIT_INI_ARRAY(&ah->iniAdditional,
  184. ar9340_1p0_radio_core_40M,
  185. ARRAY_SIZE(ar9340_1p0_radio_core_40M),
  186. 2);
  187. } else if (AR_SREV_9485_11(ah)) {
  188. /* mac */
  189. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  190. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  191. ar9485_1_1_mac_core,
  192. ARRAY_SIZE(ar9485_1_1_mac_core), 2);
  193. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  194. ar9485_1_1_mac_postamble,
  195. ARRAY_SIZE(ar9485_1_1_mac_postamble), 5);
  196. /* bb */
  197. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1,
  198. ARRAY_SIZE(ar9485_1_1), 2);
  199. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  200. ar9485_1_1_baseband_core,
  201. ARRAY_SIZE(ar9485_1_1_baseband_core), 2);
  202. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  203. ar9485_1_1_baseband_postamble,
  204. ARRAY_SIZE(ar9485_1_1_baseband_postamble), 5);
  205. /* radio */
  206. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  207. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  208. ar9485_1_1_radio_core,
  209. ARRAY_SIZE(ar9485_1_1_radio_core), 2);
  210. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  211. ar9485_1_1_radio_postamble,
  212. ARRAY_SIZE(ar9485_1_1_radio_postamble), 2);
  213. /* soc */
  214. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  215. ar9485_1_1_soc_preamble,
  216. ARRAY_SIZE(ar9485_1_1_soc_preamble), 2);
  217. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  218. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], NULL, 0, 0);
  219. /* rx/tx gain */
  220. INIT_INI_ARRAY(&ah->iniModesRxGain,
  221. ar9485Common_wo_xlna_rx_gain_1_1,
  222. ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1), 2);
  223. INIT_INI_ARRAY(&ah->iniModesTxGain,
  224. ar9485_modes_lowest_ob_db_tx_gain_1_1,
  225. ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1),
  226. 5);
  227. /* Load PCIE SERDES settings from INI */
  228. /* Awake Setting */
  229. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  230. ar9485_1_1_pcie_phy_clkreq_disable_L1,
  231. ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1),
  232. 2);
  233. /* Sleep Setting */
  234. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  235. ar9485_1_1_pcie_phy_clkreq_disable_L1,
  236. ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1),
  237. 2);
  238. } else if (AR_SREV_9462_20(ah)) {
  239. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  240. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core,
  241. ARRAY_SIZE(ar9462_2p0_mac_core), 2);
  242. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  243. ar9462_2p0_mac_postamble,
  244. ARRAY_SIZE(ar9462_2p0_mac_postamble), 5);
  245. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  246. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  247. ar9462_2p0_baseband_core,
  248. ARRAY_SIZE(ar9462_2p0_baseband_core), 2);
  249. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  250. ar9462_2p0_baseband_postamble,
  251. ARRAY_SIZE(ar9462_2p0_baseband_postamble), 5);
  252. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  253. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  254. ar9462_2p0_radio_core,
  255. ARRAY_SIZE(ar9462_2p0_radio_core), 2);
  256. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  257. ar9462_2p0_radio_postamble,
  258. ARRAY_SIZE(ar9462_2p0_radio_postamble), 5);
  259. INIT_INI_ARRAY(&ah->ini_radio_post_sys2ant,
  260. ar9462_2p0_radio_postamble_sys2ant,
  261. ARRAY_SIZE(ar9462_2p0_radio_postamble_sys2ant),
  262. 5);
  263. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  264. ar9462_2p0_soc_preamble,
  265. ARRAY_SIZE(ar9462_2p0_soc_preamble), 2);
  266. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  267. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  268. ar9462_2p0_soc_postamble,
  269. ARRAY_SIZE(ar9462_2p0_soc_postamble), 5);
  270. INIT_INI_ARRAY(&ah->iniModesRxGain,
  271. ar9462_common_rx_gain_table_2p0,
  272. ARRAY_SIZE(ar9462_common_rx_gain_table_2p0), 2);
  273. /* Awake -> Sleep Setting */
  274. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  275. PCIE_PLL_ON_CREQ_DIS_L1_2P0,
  276. ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0),
  277. 2);
  278. /* Sleep -> Awake Setting */
  279. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  280. PCIE_PLL_ON_CREQ_DIS_L1_2P0,
  281. ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0),
  282. 2);
  283. /* Fast clock modal settings */
  284. INIT_INI_ARRAY(&ah->iniModesFastClock,
  285. ar9462_modes_fast_clock_2p0,
  286. ARRAY_SIZE(ar9462_modes_fast_clock_2p0), 3);
  287. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  288. AR9462_BB_CTX_COEFJ(2p0),
  289. ARRAY_SIZE(AR9462_BB_CTX_COEFJ(2p0)), 2);
  290. INIT_INI_ARRAY(&ah->ini_japan2484, AR9462_BBC_TXIFR_COEFFJ,
  291. ARRAY_SIZE(AR9462_BBC_TXIFR_COEFFJ), 2);
  292. } else if (AR_SREV_9580(ah)) {
  293. /* mac */
  294. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  295. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  296. ar9580_1p0_mac_core,
  297. ARRAY_SIZE(ar9580_1p0_mac_core), 2);
  298. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  299. ar9580_1p0_mac_postamble,
  300. ARRAY_SIZE(ar9580_1p0_mac_postamble), 5);
  301. /* bb */
  302. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  303. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  304. ar9580_1p0_baseband_core,
  305. ARRAY_SIZE(ar9580_1p0_baseband_core), 2);
  306. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  307. ar9580_1p0_baseband_postamble,
  308. ARRAY_SIZE(ar9580_1p0_baseband_postamble), 5);
  309. /* radio */
  310. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  311. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  312. ar9580_1p0_radio_core,
  313. ARRAY_SIZE(ar9580_1p0_radio_core), 2);
  314. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  315. ar9580_1p0_radio_postamble,
  316. ARRAY_SIZE(ar9580_1p0_radio_postamble), 5);
  317. /* soc */
  318. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  319. ar9580_1p0_soc_preamble,
  320. ARRAY_SIZE(ar9580_1p0_soc_preamble), 2);
  321. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  322. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  323. ar9580_1p0_soc_postamble,
  324. ARRAY_SIZE(ar9580_1p0_soc_postamble), 5);
  325. /* rx/tx gain */
  326. INIT_INI_ARRAY(&ah->iniModesRxGain,
  327. ar9580_1p0_rx_gain_table,
  328. ARRAY_SIZE(ar9580_1p0_rx_gain_table), 2);
  329. INIT_INI_ARRAY(&ah->iniModesTxGain,
  330. ar9580_1p0_low_ob_db_tx_gain_table,
  331. ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table),
  332. 5);
  333. INIT_INI_ARRAY(&ah->iniModesFastClock,
  334. ar9580_1p0_modes_fast_clock,
  335. ARRAY_SIZE(ar9580_1p0_modes_fast_clock),
  336. 3);
  337. } else {
  338. /* mac */
  339. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  340. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  341. ar9300_2p2_mac_core,
  342. ARRAY_SIZE(ar9300_2p2_mac_core), 2);
  343. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  344. ar9300_2p2_mac_postamble,
  345. ARRAY_SIZE(ar9300_2p2_mac_postamble), 5);
  346. /* bb */
  347. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  348. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  349. ar9300_2p2_baseband_core,
  350. ARRAY_SIZE(ar9300_2p2_baseband_core), 2);
  351. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  352. ar9300_2p2_baseband_postamble,
  353. ARRAY_SIZE(ar9300_2p2_baseband_postamble), 5);
  354. /* radio */
  355. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  356. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  357. ar9300_2p2_radio_core,
  358. ARRAY_SIZE(ar9300_2p2_radio_core), 2);
  359. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  360. ar9300_2p2_radio_postamble,
  361. ARRAY_SIZE(ar9300_2p2_radio_postamble), 5);
  362. /* soc */
  363. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  364. ar9300_2p2_soc_preamble,
  365. ARRAY_SIZE(ar9300_2p2_soc_preamble), 2);
  366. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  367. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  368. ar9300_2p2_soc_postamble,
  369. ARRAY_SIZE(ar9300_2p2_soc_postamble), 5);
  370. /* rx/tx gain */
  371. INIT_INI_ARRAY(&ah->iniModesRxGain,
  372. ar9300Common_rx_gain_table_2p2,
  373. ARRAY_SIZE(ar9300Common_rx_gain_table_2p2), 2);
  374. INIT_INI_ARRAY(&ah->iniModesTxGain,
  375. ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
  376. ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
  377. 5);
  378. /* Load PCIE SERDES settings from INI */
  379. /* Awake Setting */
  380. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  381. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
  382. ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
  383. 2);
  384. /* Sleep Setting */
  385. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  386. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
  387. ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
  388. 2);
  389. /* Fast clock modal settings */
  390. INIT_INI_ARRAY(&ah->iniModesFastClock,
  391. ar9300Modes_fast_clock_2p2,
  392. ARRAY_SIZE(ar9300Modes_fast_clock_2p2),
  393. 3);
  394. }
  395. }
  396. static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
  397. {
  398. if (AR_SREV_9330_12(ah))
  399. INIT_INI_ARRAY(&ah->iniModesTxGain,
  400. ar9331_modes_lowest_ob_db_tx_gain_1p2,
  401. ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2),
  402. 5);
  403. else if (AR_SREV_9330_11(ah))
  404. INIT_INI_ARRAY(&ah->iniModesTxGain,
  405. ar9331_modes_lowest_ob_db_tx_gain_1p1,
  406. ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1),
  407. 5);
  408. else if (AR_SREV_9340(ah))
  409. INIT_INI_ARRAY(&ah->iniModesTxGain,
  410. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  411. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  412. 5);
  413. else if (AR_SREV_9485_11(ah))
  414. INIT_INI_ARRAY(&ah->iniModesTxGain,
  415. ar9485_modes_lowest_ob_db_tx_gain_1_1,
  416. ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1),
  417. 5);
  418. else if (AR_SREV_9580(ah))
  419. INIT_INI_ARRAY(&ah->iniModesTxGain,
  420. ar9580_1p0_lowest_ob_db_tx_gain_table,
  421. ARRAY_SIZE(ar9580_1p0_lowest_ob_db_tx_gain_table),
  422. 5);
  423. else if (AR_SREV_9462_20(ah))
  424. INIT_INI_ARRAY(&ah->iniModesTxGain,
  425. ar9462_modes_low_ob_db_tx_gain_table_2p0,
  426. ARRAY_SIZE(ar9462_modes_low_ob_db_tx_gain_table_2p0),
  427. 5);
  428. else
  429. INIT_INI_ARRAY(&ah->iniModesTxGain,
  430. ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
  431. ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
  432. 5);
  433. }
  434. static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
  435. {
  436. if (AR_SREV_9330_12(ah))
  437. INIT_INI_ARRAY(&ah->iniModesTxGain,
  438. ar9331_modes_high_ob_db_tx_gain_1p2,
  439. ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p2),
  440. 5);
  441. else if (AR_SREV_9330_11(ah))
  442. INIT_INI_ARRAY(&ah->iniModesTxGain,
  443. ar9331_modes_high_ob_db_tx_gain_1p1,
  444. ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p1),
  445. 5);
  446. else if (AR_SREV_9340(ah))
  447. INIT_INI_ARRAY(&ah->iniModesTxGain,
  448. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  449. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  450. 5);
  451. else if (AR_SREV_9485_11(ah))
  452. INIT_INI_ARRAY(&ah->iniModesTxGain,
  453. ar9485Modes_high_ob_db_tx_gain_1_1,
  454. ARRAY_SIZE(ar9485Modes_high_ob_db_tx_gain_1_1),
  455. 5);
  456. else if (AR_SREV_9580(ah))
  457. INIT_INI_ARRAY(&ah->iniModesTxGain,
  458. ar9580_1p0_high_ob_db_tx_gain_table,
  459. ARRAY_SIZE(ar9580_1p0_high_ob_db_tx_gain_table),
  460. 5);
  461. else if (AR_SREV_9462_20(ah))
  462. INIT_INI_ARRAY(&ah->iniModesTxGain,
  463. ar9462_modes_high_ob_db_tx_gain_table_2p0,
  464. ARRAY_SIZE(ar9462_modes_high_ob_db_tx_gain_table_2p0),
  465. 5);
  466. else
  467. INIT_INI_ARRAY(&ah->iniModesTxGain,
  468. ar9300Modes_high_ob_db_tx_gain_table_2p2,
  469. ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p2),
  470. 5);
  471. }
  472. static void ar9003_tx_gain_table_mode2(struct ath_hw *ah)
  473. {
  474. if (AR_SREV_9330_12(ah))
  475. INIT_INI_ARRAY(&ah->iniModesTxGain,
  476. ar9331_modes_low_ob_db_tx_gain_1p2,
  477. ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p2),
  478. 5);
  479. else if (AR_SREV_9330_11(ah))
  480. INIT_INI_ARRAY(&ah->iniModesTxGain,
  481. ar9331_modes_low_ob_db_tx_gain_1p1,
  482. ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p1),
  483. 5);
  484. else if (AR_SREV_9340(ah))
  485. INIT_INI_ARRAY(&ah->iniModesTxGain,
  486. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  487. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  488. 5);
  489. else if (AR_SREV_9485_11(ah))
  490. INIT_INI_ARRAY(&ah->iniModesTxGain,
  491. ar9485Modes_low_ob_db_tx_gain_1_1,
  492. ARRAY_SIZE(ar9485Modes_low_ob_db_tx_gain_1_1),
  493. 5);
  494. else if (AR_SREV_9580(ah))
  495. INIT_INI_ARRAY(&ah->iniModesTxGain,
  496. ar9580_1p0_low_ob_db_tx_gain_table,
  497. ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table),
  498. 5);
  499. else
  500. INIT_INI_ARRAY(&ah->iniModesTxGain,
  501. ar9300Modes_low_ob_db_tx_gain_table_2p2,
  502. ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p2),
  503. 5);
  504. }
  505. static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
  506. {
  507. if (AR_SREV_9330_12(ah))
  508. INIT_INI_ARRAY(&ah->iniModesTxGain,
  509. ar9331_modes_high_power_tx_gain_1p2,
  510. ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p2),
  511. 5);
  512. else if (AR_SREV_9330_11(ah))
  513. INIT_INI_ARRAY(&ah->iniModesTxGain,
  514. ar9331_modes_high_power_tx_gain_1p1,
  515. ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p1),
  516. 5);
  517. else if (AR_SREV_9340(ah))
  518. INIT_INI_ARRAY(&ah->iniModesTxGain,
  519. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  520. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  521. 5);
  522. else if (AR_SREV_9485_11(ah))
  523. INIT_INI_ARRAY(&ah->iniModesTxGain,
  524. ar9485Modes_high_power_tx_gain_1_1,
  525. ARRAY_SIZE(ar9485Modes_high_power_tx_gain_1_1),
  526. 5);
  527. else if (AR_SREV_9580(ah))
  528. INIT_INI_ARRAY(&ah->iniModesTxGain,
  529. ar9580_1p0_high_power_tx_gain_table,
  530. ARRAY_SIZE(ar9580_1p0_high_power_tx_gain_table),
  531. 5);
  532. else
  533. INIT_INI_ARRAY(&ah->iniModesTxGain,
  534. ar9300Modes_high_power_tx_gain_table_2p2,
  535. ARRAY_SIZE(ar9300Modes_high_power_tx_gain_table_2p2),
  536. 5);
  537. }
  538. static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
  539. {
  540. switch (ar9003_hw_get_tx_gain_idx(ah)) {
  541. case 0:
  542. default:
  543. ar9003_tx_gain_table_mode0(ah);
  544. break;
  545. case 1:
  546. ar9003_tx_gain_table_mode1(ah);
  547. break;
  548. case 2:
  549. ar9003_tx_gain_table_mode2(ah);
  550. break;
  551. case 3:
  552. ar9003_tx_gain_table_mode3(ah);
  553. break;
  554. }
  555. }
  556. static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
  557. {
  558. if (AR_SREV_9330_12(ah))
  559. INIT_INI_ARRAY(&ah->iniModesRxGain,
  560. ar9331_common_rx_gain_1p2,
  561. ARRAY_SIZE(ar9331_common_rx_gain_1p2),
  562. 2);
  563. else if (AR_SREV_9330_11(ah))
  564. INIT_INI_ARRAY(&ah->iniModesRxGain,
  565. ar9331_common_rx_gain_1p1,
  566. ARRAY_SIZE(ar9331_common_rx_gain_1p1),
  567. 2);
  568. else if (AR_SREV_9340(ah))
  569. INIT_INI_ARRAY(&ah->iniModesRxGain,
  570. ar9340Common_rx_gain_table_1p0,
  571. ARRAY_SIZE(ar9340Common_rx_gain_table_1p0),
  572. 2);
  573. else if (AR_SREV_9485_11(ah))
  574. INIT_INI_ARRAY(&ah->iniModesRxGain,
  575. ar9485Common_wo_xlna_rx_gain_1_1,
  576. ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1),
  577. 2);
  578. else if (AR_SREV_9580(ah))
  579. INIT_INI_ARRAY(&ah->iniModesRxGain,
  580. ar9580_1p0_rx_gain_table,
  581. ARRAY_SIZE(ar9580_1p0_rx_gain_table),
  582. 2);
  583. else if (AR_SREV_9462_20(ah))
  584. INIT_INI_ARRAY(&ah->iniModesRxGain,
  585. ar9462_common_rx_gain_table_2p0,
  586. ARRAY_SIZE(ar9462_common_rx_gain_table_2p0),
  587. 2);
  588. else
  589. INIT_INI_ARRAY(&ah->iniModesRxGain,
  590. ar9300Common_rx_gain_table_2p2,
  591. ARRAY_SIZE(ar9300Common_rx_gain_table_2p2),
  592. 2);
  593. }
  594. static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
  595. {
  596. if (AR_SREV_9330_12(ah))
  597. INIT_INI_ARRAY(&ah->iniModesRxGain,
  598. ar9331_common_wo_xlna_rx_gain_1p2,
  599. ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p2),
  600. 2);
  601. else if (AR_SREV_9330_11(ah))
  602. INIT_INI_ARRAY(&ah->iniModesRxGain,
  603. ar9331_common_wo_xlna_rx_gain_1p1,
  604. ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p1),
  605. 2);
  606. else if (AR_SREV_9340(ah))
  607. INIT_INI_ARRAY(&ah->iniModesRxGain,
  608. ar9340Common_wo_xlna_rx_gain_table_1p0,
  609. ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0),
  610. 2);
  611. else if (AR_SREV_9485_11(ah))
  612. INIT_INI_ARRAY(&ah->iniModesRxGain,
  613. ar9485Common_wo_xlna_rx_gain_1_1,
  614. ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1),
  615. 2);
  616. else if (AR_SREV_9462_20(ah))
  617. INIT_INI_ARRAY(&ah->iniModesRxGain,
  618. ar9462_common_wo_xlna_rx_gain_table_2p0,
  619. ARRAY_SIZE(ar9462_common_wo_xlna_rx_gain_table_2p0),
  620. 2);
  621. else if (AR_SREV_9580(ah))
  622. INIT_INI_ARRAY(&ah->iniModesRxGain,
  623. ar9580_1p0_wo_xlna_rx_gain_table,
  624. ARRAY_SIZE(ar9580_1p0_wo_xlna_rx_gain_table),
  625. 2);
  626. else
  627. INIT_INI_ARRAY(&ah->iniModesRxGain,
  628. ar9300Common_wo_xlna_rx_gain_table_2p2,
  629. ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p2),
  630. 2);
  631. }
  632. static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
  633. {
  634. if (AR_SREV_9462_20(ah))
  635. INIT_INI_ARRAY(&ah->iniModesRxGain,
  636. ar9462_common_mixed_rx_gain_table_2p0,
  637. ARRAY_SIZE(ar9462_common_mixed_rx_gain_table_2p0), 2);
  638. }
  639. static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
  640. {
  641. switch (ar9003_hw_get_rx_gain_idx(ah)) {
  642. case 0:
  643. default:
  644. ar9003_rx_gain_table_mode0(ah);
  645. break;
  646. case 1:
  647. ar9003_rx_gain_table_mode1(ah);
  648. break;
  649. case 2:
  650. ar9003_rx_gain_table_mode2(ah);
  651. break;
  652. }
  653. }
  654. /* set gain table pointers according to values read from the eeprom */
  655. static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
  656. {
  657. ar9003_tx_gain_table_apply(ah);
  658. ar9003_rx_gain_table_apply(ah);
  659. }
  660. /*
  661. * Helper for ASPM support.
  662. *
  663. * Disable PLL when in L0s as well as receiver clock when in L1.
  664. * This power saving option must be enabled through the SerDes.
  665. *
  666. * Programming the SerDes must go through the same 288 bit serial shift
  667. * register as the other analog registers. Hence the 9 writes.
  668. */
  669. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  670. bool power_off)
  671. {
  672. /* Nothing to do on restore for 11N */
  673. if (!power_off /* !restore */) {
  674. /* set bit 19 to allow forcing of pcie core into L1 state */
  675. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  676. /* Several PCIe massages to ensure proper behaviour */
  677. if (ah->config.pcie_waen)
  678. REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
  679. else
  680. REG_WRITE(ah, AR_WA, ah->WARegVal);
  681. }
  682. /*
  683. * Configire PCIE after Ini init. SERDES values now come from ini file
  684. * This enables PCIe low power mode.
  685. */
  686. if (ah->config.pcieSerDesWrite) {
  687. unsigned int i;
  688. struct ar5416IniArray *array;
  689. array = power_off ? &ah->iniPcieSerdes :
  690. &ah->iniPcieSerdesLowPower;
  691. for (i = 0; i < array->ia_rows; i++) {
  692. REG_WRITE(ah,
  693. INI_RA(array, i, 0),
  694. INI_RA(array, i, 1));
  695. }
  696. }
  697. }
  698. /* Sets up the AR9003 hardware familiy callbacks */
  699. void ar9003_hw_attach_ops(struct ath_hw *ah)
  700. {
  701. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  702. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  703. priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
  704. priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
  705. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  706. ar9003_hw_attach_phy_ops(ah);
  707. ar9003_hw_attach_calib_ops(ah);
  708. ar9003_hw_attach_mac_ops(ah);
  709. }