ar9003_hw.c 21 KB

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