ar9003_hw.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  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->iniAdditional,
  81. ar9331_1p1_xtal_25M,
  82. ARRAY_SIZE(ar9331_1p1_xtal_25M), 2);
  83. else
  84. INIT_INI_ARRAY(&ah->iniAdditional,
  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->iniAdditional,
  129. ar9331_1p2_xtal_25M,
  130. ARRAY_SIZE(ar9331_1p2_xtal_25M), 2);
  131. else
  132. INIT_INI_ARRAY(&ah->iniAdditional,
  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->iniModesFastClock,
  178. ar9340Modes_fast_clock_1p0,
  179. ARRAY_SIZE(ar9340Modes_fast_clock_1p0),
  180. 3);
  181. if (!ah->is_clk_25mhz)
  182. INIT_INI_ARRAY(&ah->iniAdditional,
  183. ar9340_1p0_radio_core_40M,
  184. ARRAY_SIZE(ar9340_1p0_radio_core_40M),
  185. 2);
  186. } else if (AR_SREV_9485_11(ah)) {
  187. /* mac */
  188. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  189. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  190. ar9485_1_1_mac_core,
  191. ARRAY_SIZE(ar9485_1_1_mac_core), 2);
  192. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  193. ar9485_1_1_mac_postamble,
  194. ARRAY_SIZE(ar9485_1_1_mac_postamble), 5);
  195. /* bb */
  196. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1,
  197. ARRAY_SIZE(ar9485_1_1), 2);
  198. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  199. ar9485_1_1_baseband_core,
  200. ARRAY_SIZE(ar9485_1_1_baseband_core), 2);
  201. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  202. ar9485_1_1_baseband_postamble,
  203. ARRAY_SIZE(ar9485_1_1_baseband_postamble), 5);
  204. /* radio */
  205. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  206. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  207. ar9485_1_1_radio_core,
  208. ARRAY_SIZE(ar9485_1_1_radio_core), 2);
  209. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  210. ar9485_1_1_radio_postamble,
  211. ARRAY_SIZE(ar9485_1_1_radio_postamble), 2);
  212. /* soc */
  213. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  214. ar9485_1_1_soc_preamble,
  215. ARRAY_SIZE(ar9485_1_1_soc_preamble), 2);
  216. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  217. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], NULL, 0, 0);
  218. /* rx/tx gain */
  219. INIT_INI_ARRAY(&ah->iniModesRxGain,
  220. ar9485Common_wo_xlna_rx_gain_1_1,
  221. ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1), 2);
  222. INIT_INI_ARRAY(&ah->iniModesTxGain,
  223. ar9485_modes_lowest_ob_db_tx_gain_1_1,
  224. ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1),
  225. 5);
  226. /* Load PCIE SERDES settings from INI */
  227. /* Awake Setting */
  228. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  229. ar9485_1_1_pcie_phy_clkreq_disable_L1,
  230. ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1),
  231. 2);
  232. /* Sleep Setting */
  233. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  234. ar9485_1_1_pcie_phy_clkreq_disable_L1,
  235. ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1),
  236. 2);
  237. } else if (AR_SREV_9462_20(ah)) {
  238. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  239. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core,
  240. ARRAY_SIZE(ar9462_2p0_mac_core), 2);
  241. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  242. ar9462_2p0_mac_postamble,
  243. ARRAY_SIZE(ar9462_2p0_mac_postamble), 5);
  244. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  245. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  246. ar9462_2p0_baseband_core,
  247. ARRAY_SIZE(ar9462_2p0_baseband_core), 2);
  248. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  249. ar9462_2p0_baseband_postamble,
  250. ARRAY_SIZE(ar9462_2p0_baseband_postamble), 5);
  251. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  252. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  253. ar9462_2p0_radio_core,
  254. ARRAY_SIZE(ar9462_2p0_radio_core), 2);
  255. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  256. ar9462_2p0_radio_postamble,
  257. ARRAY_SIZE(ar9462_2p0_radio_postamble), 5);
  258. INIT_INI_ARRAY(&ah->ini_radio_post_sys2ant,
  259. ar9462_2p0_radio_postamble_sys2ant,
  260. ARRAY_SIZE(ar9462_2p0_radio_postamble_sys2ant),
  261. 5);
  262. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  263. ar9462_2p0_soc_preamble,
  264. ARRAY_SIZE(ar9462_2p0_soc_preamble), 2);
  265. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  266. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  267. ar9462_2p0_soc_postamble,
  268. ARRAY_SIZE(ar9462_2p0_soc_postamble), 5);
  269. INIT_INI_ARRAY(&ah->iniModesRxGain,
  270. ar9462_common_rx_gain_table_2p0,
  271. ARRAY_SIZE(ar9462_common_rx_gain_table_2p0), 2);
  272. INIT_INI_ARRAY(&ah->ini_BTCOEX_MAX_TXPWR,
  273. ar9462_2p0_BTCOEX_MAX_TXPWR_table,
  274. ARRAY_SIZE(ar9462_2p0_BTCOEX_MAX_TXPWR_table),
  275. 2);
  276. /* Awake -> Sleep Setting */
  277. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  278. PCIE_PLL_ON_CREQ_DIS_L1_2P0,
  279. ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0),
  280. 2);
  281. /* Sleep -> Awake Setting */
  282. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  283. PCIE_PLL_ON_CREQ_DIS_L1_2P0,
  284. ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0),
  285. 2);
  286. /* Fast clock modal settings */
  287. INIT_INI_ARRAY(&ah->iniModesFastClock,
  288. ar9462_modes_fast_clock_2p0,
  289. ARRAY_SIZE(ar9462_modes_fast_clock_2p0), 3);
  290. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  291. AR9462_BB_CTX_COEFJ(2p0),
  292. ARRAY_SIZE(AR9462_BB_CTX_COEFJ(2p0)), 2);
  293. INIT_INI_ARRAY(&ah->ini_japan2484, AR9462_BBC_TXIFR_COEFFJ,
  294. ARRAY_SIZE(AR9462_BBC_TXIFR_COEFFJ), 2);
  295. } else if (AR_SREV_9580(ah)) {
  296. /* mac */
  297. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  298. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  299. ar9580_1p0_mac_core,
  300. ARRAY_SIZE(ar9580_1p0_mac_core), 2);
  301. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  302. ar9580_1p0_mac_postamble,
  303. ARRAY_SIZE(ar9580_1p0_mac_postamble), 5);
  304. /* bb */
  305. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  306. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  307. ar9580_1p0_baseband_core,
  308. ARRAY_SIZE(ar9580_1p0_baseband_core), 2);
  309. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  310. ar9580_1p0_baseband_postamble,
  311. ARRAY_SIZE(ar9580_1p0_baseband_postamble), 5);
  312. /* radio */
  313. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  314. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  315. ar9580_1p0_radio_core,
  316. ARRAY_SIZE(ar9580_1p0_radio_core), 2);
  317. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  318. ar9580_1p0_radio_postamble,
  319. ARRAY_SIZE(ar9580_1p0_radio_postamble), 5);
  320. /* soc */
  321. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  322. ar9580_1p0_soc_preamble,
  323. ARRAY_SIZE(ar9580_1p0_soc_preamble), 2);
  324. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  325. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  326. ar9580_1p0_soc_postamble,
  327. ARRAY_SIZE(ar9580_1p0_soc_postamble), 5);
  328. /* rx/tx gain */
  329. INIT_INI_ARRAY(&ah->iniModesRxGain,
  330. ar9580_1p0_rx_gain_table,
  331. ARRAY_SIZE(ar9580_1p0_rx_gain_table), 2);
  332. INIT_INI_ARRAY(&ah->iniModesTxGain,
  333. ar9580_1p0_low_ob_db_tx_gain_table,
  334. ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table),
  335. 5);
  336. INIT_INI_ARRAY(&ah->iniModesFastClock,
  337. ar9580_1p0_modes_fast_clock,
  338. ARRAY_SIZE(ar9580_1p0_modes_fast_clock),
  339. 3);
  340. } else {
  341. /* mac */
  342. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  343. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  344. ar9300_2p2_mac_core,
  345. ARRAY_SIZE(ar9300_2p2_mac_core), 2);
  346. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  347. ar9300_2p2_mac_postamble,
  348. ARRAY_SIZE(ar9300_2p2_mac_postamble), 5);
  349. /* bb */
  350. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
  351. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
  352. ar9300_2p2_baseband_core,
  353. ARRAY_SIZE(ar9300_2p2_baseband_core), 2);
  354. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  355. ar9300_2p2_baseband_postamble,
  356. ARRAY_SIZE(ar9300_2p2_baseband_postamble), 5);
  357. /* radio */
  358. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
  359. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
  360. ar9300_2p2_radio_core,
  361. ARRAY_SIZE(ar9300_2p2_radio_core), 2);
  362. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  363. ar9300_2p2_radio_postamble,
  364. ARRAY_SIZE(ar9300_2p2_radio_postamble), 5);
  365. /* soc */
  366. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  367. ar9300_2p2_soc_preamble,
  368. ARRAY_SIZE(ar9300_2p2_soc_preamble), 2);
  369. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  370. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  371. ar9300_2p2_soc_postamble,
  372. ARRAY_SIZE(ar9300_2p2_soc_postamble), 5);
  373. /* rx/tx gain */
  374. INIT_INI_ARRAY(&ah->iniModesRxGain,
  375. ar9300Common_rx_gain_table_2p2,
  376. ARRAY_SIZE(ar9300Common_rx_gain_table_2p2), 2);
  377. INIT_INI_ARRAY(&ah->iniModesTxGain,
  378. ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
  379. ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
  380. 5);
  381. /* Load PCIE SERDES settings from INI */
  382. /* Awake Setting */
  383. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  384. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
  385. ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
  386. 2);
  387. /* Sleep Setting */
  388. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  389. ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
  390. ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
  391. 2);
  392. /* Fast clock modal settings */
  393. INIT_INI_ARRAY(&ah->iniModesFastClock,
  394. ar9300Modes_fast_clock_2p2,
  395. ARRAY_SIZE(ar9300Modes_fast_clock_2p2),
  396. 3);
  397. }
  398. }
  399. static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
  400. {
  401. if (AR_SREV_9330_12(ah))
  402. INIT_INI_ARRAY(&ah->iniModesTxGain,
  403. ar9331_modes_lowest_ob_db_tx_gain_1p2,
  404. ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2),
  405. 5);
  406. else if (AR_SREV_9330_11(ah))
  407. INIT_INI_ARRAY(&ah->iniModesTxGain,
  408. ar9331_modes_lowest_ob_db_tx_gain_1p1,
  409. ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1),
  410. 5);
  411. else if (AR_SREV_9340(ah))
  412. INIT_INI_ARRAY(&ah->iniModesTxGain,
  413. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  414. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  415. 5);
  416. else if (AR_SREV_9485_11(ah))
  417. INIT_INI_ARRAY(&ah->iniModesTxGain,
  418. ar9485_modes_lowest_ob_db_tx_gain_1_1,
  419. ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1),
  420. 5);
  421. else if (AR_SREV_9580(ah))
  422. INIT_INI_ARRAY(&ah->iniModesTxGain,
  423. ar9580_1p0_lowest_ob_db_tx_gain_table,
  424. ARRAY_SIZE(ar9580_1p0_lowest_ob_db_tx_gain_table),
  425. 5);
  426. else if (AR_SREV_9462_20(ah))
  427. INIT_INI_ARRAY(&ah->iniModesTxGain,
  428. ar9462_modes_low_ob_db_tx_gain_table_2p0,
  429. ARRAY_SIZE(ar9462_modes_low_ob_db_tx_gain_table_2p0),
  430. 5);
  431. else
  432. INIT_INI_ARRAY(&ah->iniModesTxGain,
  433. ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
  434. ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
  435. 5);
  436. }
  437. static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
  438. {
  439. if (AR_SREV_9330_12(ah))
  440. INIT_INI_ARRAY(&ah->iniModesTxGain,
  441. ar9331_modes_high_ob_db_tx_gain_1p2,
  442. ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p2),
  443. 5);
  444. else if (AR_SREV_9330_11(ah))
  445. INIT_INI_ARRAY(&ah->iniModesTxGain,
  446. ar9331_modes_high_ob_db_tx_gain_1p1,
  447. ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p1),
  448. 5);
  449. else if (AR_SREV_9340(ah))
  450. INIT_INI_ARRAY(&ah->iniModesTxGain,
  451. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  452. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  453. 5);
  454. else if (AR_SREV_9485_11(ah))
  455. INIT_INI_ARRAY(&ah->iniModesTxGain,
  456. ar9485Modes_high_ob_db_tx_gain_1_1,
  457. ARRAY_SIZE(ar9485Modes_high_ob_db_tx_gain_1_1),
  458. 5);
  459. else if (AR_SREV_9580(ah))
  460. INIT_INI_ARRAY(&ah->iniModesTxGain,
  461. ar9580_1p0_high_ob_db_tx_gain_table,
  462. ARRAY_SIZE(ar9580_1p0_high_ob_db_tx_gain_table),
  463. 5);
  464. else if (AR_SREV_9462_20(ah))
  465. INIT_INI_ARRAY(&ah->iniModesTxGain,
  466. ar9462_modes_high_ob_db_tx_gain_table_2p0,
  467. ARRAY_SIZE(ar9462_modes_high_ob_db_tx_gain_table_2p0),
  468. 5);
  469. else
  470. INIT_INI_ARRAY(&ah->iniModesTxGain,
  471. ar9300Modes_high_ob_db_tx_gain_table_2p2,
  472. ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p2),
  473. 5);
  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. ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p2),
  481. 5);
  482. else if (AR_SREV_9330_11(ah))
  483. INIT_INI_ARRAY(&ah->iniModesTxGain,
  484. ar9331_modes_low_ob_db_tx_gain_1p1,
  485. ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p1),
  486. 5);
  487. else if (AR_SREV_9340(ah))
  488. INIT_INI_ARRAY(&ah->iniModesTxGain,
  489. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  490. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  491. 5);
  492. else if (AR_SREV_9485_11(ah))
  493. INIT_INI_ARRAY(&ah->iniModesTxGain,
  494. ar9485Modes_low_ob_db_tx_gain_1_1,
  495. ARRAY_SIZE(ar9485Modes_low_ob_db_tx_gain_1_1),
  496. 5);
  497. else if (AR_SREV_9580(ah))
  498. INIT_INI_ARRAY(&ah->iniModesTxGain,
  499. ar9580_1p0_low_ob_db_tx_gain_table,
  500. ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table),
  501. 5);
  502. else
  503. INIT_INI_ARRAY(&ah->iniModesTxGain,
  504. ar9300Modes_low_ob_db_tx_gain_table_2p2,
  505. ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p2),
  506. 5);
  507. }
  508. static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
  509. {
  510. if (AR_SREV_9330_12(ah))
  511. INIT_INI_ARRAY(&ah->iniModesTxGain,
  512. ar9331_modes_high_power_tx_gain_1p2,
  513. ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p2),
  514. 5);
  515. else if (AR_SREV_9330_11(ah))
  516. INIT_INI_ARRAY(&ah->iniModesTxGain,
  517. ar9331_modes_high_power_tx_gain_1p1,
  518. ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p1),
  519. 5);
  520. else if (AR_SREV_9340(ah))
  521. INIT_INI_ARRAY(&ah->iniModesTxGain,
  522. ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
  523. ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
  524. 5);
  525. else if (AR_SREV_9485_11(ah))
  526. INIT_INI_ARRAY(&ah->iniModesTxGain,
  527. ar9485Modes_high_power_tx_gain_1_1,
  528. ARRAY_SIZE(ar9485Modes_high_power_tx_gain_1_1),
  529. 5);
  530. else if (AR_SREV_9580(ah))
  531. INIT_INI_ARRAY(&ah->iniModesTxGain,
  532. ar9580_1p0_high_power_tx_gain_table,
  533. ARRAY_SIZE(ar9580_1p0_high_power_tx_gain_table),
  534. 5);
  535. else
  536. INIT_INI_ARRAY(&ah->iniModesTxGain,
  537. ar9300Modes_high_power_tx_gain_table_2p2,
  538. ARRAY_SIZE(ar9300Modes_high_power_tx_gain_table_2p2),
  539. 5);
  540. }
  541. static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
  542. {
  543. switch (ar9003_hw_get_tx_gain_idx(ah)) {
  544. case 0:
  545. default:
  546. ar9003_tx_gain_table_mode0(ah);
  547. break;
  548. case 1:
  549. ar9003_tx_gain_table_mode1(ah);
  550. break;
  551. case 2:
  552. ar9003_tx_gain_table_mode2(ah);
  553. break;
  554. case 3:
  555. ar9003_tx_gain_table_mode3(ah);
  556. break;
  557. }
  558. }
  559. static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
  560. {
  561. if (AR_SREV_9330_12(ah))
  562. INIT_INI_ARRAY(&ah->iniModesRxGain,
  563. ar9331_common_rx_gain_1p2,
  564. ARRAY_SIZE(ar9331_common_rx_gain_1p2),
  565. 2);
  566. else if (AR_SREV_9330_11(ah))
  567. INIT_INI_ARRAY(&ah->iniModesRxGain,
  568. ar9331_common_rx_gain_1p1,
  569. ARRAY_SIZE(ar9331_common_rx_gain_1p1),
  570. 2);
  571. else if (AR_SREV_9340(ah))
  572. INIT_INI_ARRAY(&ah->iniModesRxGain,
  573. ar9340Common_rx_gain_table_1p0,
  574. ARRAY_SIZE(ar9340Common_rx_gain_table_1p0),
  575. 2);
  576. else if (AR_SREV_9485_11(ah))
  577. INIT_INI_ARRAY(&ah->iniModesRxGain,
  578. ar9485Common_wo_xlna_rx_gain_1_1,
  579. ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1),
  580. 2);
  581. else if (AR_SREV_9580(ah))
  582. INIT_INI_ARRAY(&ah->iniModesRxGain,
  583. ar9580_1p0_rx_gain_table,
  584. ARRAY_SIZE(ar9580_1p0_rx_gain_table),
  585. 2);
  586. else if (AR_SREV_9462_20(ah))
  587. INIT_INI_ARRAY(&ah->iniModesRxGain,
  588. ar9462_common_rx_gain_table_2p0,
  589. ARRAY_SIZE(ar9462_common_rx_gain_table_2p0),
  590. 2);
  591. else
  592. INIT_INI_ARRAY(&ah->iniModesRxGain,
  593. ar9300Common_rx_gain_table_2p2,
  594. ARRAY_SIZE(ar9300Common_rx_gain_table_2p2),
  595. 2);
  596. }
  597. static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
  598. {
  599. if (AR_SREV_9330_12(ah))
  600. INIT_INI_ARRAY(&ah->iniModesRxGain,
  601. ar9331_common_wo_xlna_rx_gain_1p2,
  602. ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p2),
  603. 2);
  604. else if (AR_SREV_9330_11(ah))
  605. INIT_INI_ARRAY(&ah->iniModesRxGain,
  606. ar9331_common_wo_xlna_rx_gain_1p1,
  607. ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p1),
  608. 2);
  609. else if (AR_SREV_9340(ah))
  610. INIT_INI_ARRAY(&ah->iniModesRxGain,
  611. ar9340Common_wo_xlna_rx_gain_table_1p0,
  612. ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0),
  613. 2);
  614. else if (AR_SREV_9485_11(ah))
  615. INIT_INI_ARRAY(&ah->iniModesRxGain,
  616. ar9485Common_wo_xlna_rx_gain_1_1,
  617. ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1),
  618. 2);
  619. else if (AR_SREV_9462_20(ah))
  620. INIT_INI_ARRAY(&ah->iniModesRxGain,
  621. ar9462_common_wo_xlna_rx_gain_table_2p0,
  622. ARRAY_SIZE(ar9462_common_wo_xlna_rx_gain_table_2p0),
  623. 2);
  624. else if (AR_SREV_9580(ah))
  625. INIT_INI_ARRAY(&ah->iniModesRxGain,
  626. ar9580_1p0_wo_xlna_rx_gain_table,
  627. ARRAY_SIZE(ar9580_1p0_wo_xlna_rx_gain_table),
  628. 2);
  629. else
  630. INIT_INI_ARRAY(&ah->iniModesRxGain,
  631. ar9300Common_wo_xlna_rx_gain_table_2p2,
  632. ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p2),
  633. 2);
  634. }
  635. static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
  636. {
  637. if (AR_SREV_9462_20(ah))
  638. INIT_INI_ARRAY(&ah->iniModesRxGain,
  639. ar9462_common_mixed_rx_gain_table_2p0,
  640. ARRAY_SIZE(ar9462_common_mixed_rx_gain_table_2p0), 2);
  641. }
  642. static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
  643. {
  644. switch (ar9003_hw_get_rx_gain_idx(ah)) {
  645. case 0:
  646. default:
  647. ar9003_rx_gain_table_mode0(ah);
  648. break;
  649. case 1:
  650. ar9003_rx_gain_table_mode1(ah);
  651. break;
  652. case 2:
  653. ar9003_rx_gain_table_mode2(ah);
  654. break;
  655. }
  656. }
  657. /* set gain table pointers according to values read from the eeprom */
  658. static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
  659. {
  660. ar9003_tx_gain_table_apply(ah);
  661. ar9003_rx_gain_table_apply(ah);
  662. }
  663. /*
  664. * Helper for ASPM support.
  665. *
  666. * Disable PLL when in L0s as well as receiver clock when in L1.
  667. * This power saving option must be enabled through the SerDes.
  668. *
  669. * Programming the SerDes must go through the same 288 bit serial shift
  670. * register as the other analog registers. Hence the 9 writes.
  671. */
  672. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  673. bool power_off)
  674. {
  675. /* Nothing to do on restore for 11N */
  676. if (!power_off /* !restore */) {
  677. /* set bit 19 to allow forcing of pcie core into L1 state */
  678. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  679. /* Several PCIe massages to ensure proper behaviour */
  680. if (ah->config.pcie_waen)
  681. REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
  682. else
  683. REG_WRITE(ah, AR_WA, ah->WARegVal);
  684. }
  685. /*
  686. * Configire PCIE after Ini init. SERDES values now come from ini file
  687. * This enables PCIe low power mode.
  688. */
  689. if (ah->config.pcieSerDesWrite) {
  690. unsigned int i;
  691. struct ar5416IniArray *array;
  692. array = power_off ? &ah->iniPcieSerdes :
  693. &ah->iniPcieSerdesLowPower;
  694. for (i = 0; i < array->ia_rows; i++) {
  695. REG_WRITE(ah,
  696. INI_RA(array, i, 0),
  697. INI_RA(array, i, 1));
  698. }
  699. }
  700. }
  701. /* Sets up the AR9003 hardware familiy callbacks */
  702. void ar9003_hw_attach_ops(struct ath_hw *ah)
  703. {
  704. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  705. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  706. priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
  707. priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
  708. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  709. ar9003_hw_attach_phy_ops(ah);
  710. ar9003_hw_attach_calib_ops(ah);
  711. ar9003_hw_attach_mac_ops(ah);
  712. }