ar9003_hw.c 24 KB

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