ar9003_hw.c 18 KB

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