ar9003_hw.c 24 KB

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