ar9002_hw.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /*
  2. * Copyright (c) 2008-2010 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 "ar5008_initvals.h"
  18. #include "ar9001_initvals.h"
  19. #include "ar9002_initvals.h"
  20. #include "ar9002_phy.h"
  21. /* General hardware code for the A5008/AR9001/AR9002 hadware families */
  22. static bool ar9002_hw_macversion_supported(u32 macversion)
  23. {
  24. switch (macversion) {
  25. case AR_SREV_VERSION_5416_PCI:
  26. case AR_SREV_VERSION_5416_PCIE:
  27. case AR_SREV_VERSION_9160:
  28. case AR_SREV_VERSION_9100:
  29. case AR_SREV_VERSION_9280:
  30. case AR_SREV_VERSION_9285:
  31. case AR_SREV_VERSION_9287:
  32. case AR_SREV_VERSION_9271:
  33. return true;
  34. default:
  35. break;
  36. }
  37. return false;
  38. }
  39. static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
  40. {
  41. if (AR_SREV_9271(ah)) {
  42. INIT_INI_ARRAY(&ah->iniModes, ar9271Modes_9271,
  43. ARRAY_SIZE(ar9271Modes_9271), 6);
  44. INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271,
  45. ARRAY_SIZE(ar9271Common_9271), 2);
  46. INIT_INI_ARRAY(&ah->iniCommon_normal_cck_fir_coeff_9271,
  47. ar9271Common_normal_cck_fir_coeff_9271,
  48. ARRAY_SIZE(ar9271Common_normal_cck_fir_coeff_9271), 2);
  49. INIT_INI_ARRAY(&ah->iniCommon_japan_2484_cck_fir_coeff_9271,
  50. ar9271Common_japan_2484_cck_fir_coeff_9271,
  51. ARRAY_SIZE(ar9271Common_japan_2484_cck_fir_coeff_9271), 2);
  52. INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only,
  53. ar9271Modes_9271_1_0_only,
  54. ARRAY_SIZE(ar9271Modes_9271_1_0_only), 6);
  55. INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg,
  56. ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 6);
  57. INIT_INI_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
  58. ar9271Modes_high_power_tx_gain_9271,
  59. ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 6);
  60. INIT_INI_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
  61. ar9271Modes_normal_power_tx_gain_9271,
  62. ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 6);
  63. return;
  64. }
  65. if (AR_SREV_9287_11_OR_LATER(ah)) {
  66. INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1,
  67. ARRAY_SIZE(ar9287Modes_9287_1_1), 6);
  68. INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_1,
  69. ARRAY_SIZE(ar9287Common_9287_1_1), 2);
  70. if (ah->config.pcie_clock_req)
  71. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  72. ar9287PciePhy_clkreq_off_L1_9287_1_1,
  73. ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_1), 2);
  74. else
  75. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  76. ar9287PciePhy_clkreq_always_on_L1_9287_1_1,
  77. ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_1),
  78. 2);
  79. } else if (AR_SREV_9287_10_OR_LATER(ah)) {
  80. INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_0,
  81. ARRAY_SIZE(ar9287Modes_9287_1_0), 6);
  82. INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_0,
  83. ARRAY_SIZE(ar9287Common_9287_1_0), 2);
  84. if (ah->config.pcie_clock_req)
  85. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  86. ar9287PciePhy_clkreq_off_L1_9287_1_0,
  87. ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_0), 2);
  88. else
  89. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  90. ar9287PciePhy_clkreq_always_on_L1_9287_1_0,
  91. ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_0),
  92. 2);
  93. } else if (AR_SREV_9285_12_OR_LATER(ah)) {
  94. INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2,
  95. ARRAY_SIZE(ar9285Modes_9285_1_2), 6);
  96. INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2,
  97. ARRAY_SIZE(ar9285Common_9285_1_2), 2);
  98. if (ah->config.pcie_clock_req) {
  99. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  100. ar9285PciePhy_clkreq_off_L1_9285_1_2,
  101. ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285_1_2), 2);
  102. } else {
  103. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  104. ar9285PciePhy_clkreq_always_on_L1_9285_1_2,
  105. ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285_1_2),
  106. 2);
  107. }
  108. } else if (AR_SREV_9285_10_OR_LATER(ah)) {
  109. INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285,
  110. ARRAY_SIZE(ar9285Modes_9285), 6);
  111. INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285,
  112. ARRAY_SIZE(ar9285Common_9285), 2);
  113. if (ah->config.pcie_clock_req) {
  114. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  115. ar9285PciePhy_clkreq_off_L1_9285,
  116. ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285), 2);
  117. } else {
  118. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  119. ar9285PciePhy_clkreq_always_on_L1_9285,
  120. ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285), 2);
  121. }
  122. } else if (AR_SREV_9280_20_OR_LATER(ah)) {
  123. INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2,
  124. ARRAY_SIZE(ar9280Modes_9280_2), 6);
  125. INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2,
  126. ARRAY_SIZE(ar9280Common_9280_2), 2);
  127. if (ah->config.pcie_clock_req) {
  128. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  129. ar9280PciePhy_clkreq_off_L1_9280,
  130. ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280), 2);
  131. } else {
  132. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  133. ar9280PciePhy_clkreq_always_on_L1_9280,
  134. ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2);
  135. }
  136. INIT_INI_ARRAY(&ah->iniModesAdditional,
  137. ar9280Modes_fast_clock_9280_2,
  138. ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3);
  139. } else if (AR_SREV_9280_10_OR_LATER(ah)) {
  140. INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280,
  141. ARRAY_SIZE(ar9280Modes_9280), 6);
  142. INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280,
  143. ARRAY_SIZE(ar9280Common_9280), 2);
  144. } else if (AR_SREV_9160_10_OR_LATER(ah)) {
  145. INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9160,
  146. ARRAY_SIZE(ar5416Modes_9160), 6);
  147. INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160,
  148. ARRAY_SIZE(ar5416Common_9160), 2);
  149. INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9160,
  150. ARRAY_SIZE(ar5416Bank0_9160), 2);
  151. INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9160,
  152. ARRAY_SIZE(ar5416BB_RfGain_9160), 3);
  153. INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9160,
  154. ARRAY_SIZE(ar5416Bank1_9160), 2);
  155. INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9160,
  156. ARRAY_SIZE(ar5416Bank2_9160), 2);
  157. INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9160,
  158. ARRAY_SIZE(ar5416Bank3_9160), 3);
  159. INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9160,
  160. ARRAY_SIZE(ar5416Bank6_9160), 3);
  161. INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9160,
  162. ARRAY_SIZE(ar5416Bank6TPC_9160), 3);
  163. INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9160,
  164. ARRAY_SIZE(ar5416Bank7_9160), 2);
  165. if (AR_SREV_9160_11(ah)) {
  166. INIT_INI_ARRAY(&ah->iniAddac,
  167. ar5416Addac_91601_1,
  168. ARRAY_SIZE(ar5416Addac_91601_1), 2);
  169. } else {
  170. INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160,
  171. ARRAY_SIZE(ar5416Addac_9160), 2);
  172. }
  173. } else if (AR_SREV_9100_OR_LATER(ah)) {
  174. INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100,
  175. ARRAY_SIZE(ar5416Modes_9100), 6);
  176. INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100,
  177. ARRAY_SIZE(ar5416Common_9100), 2);
  178. INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9100,
  179. ARRAY_SIZE(ar5416Bank0_9100), 2);
  180. INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9100,
  181. ARRAY_SIZE(ar5416BB_RfGain_9100), 3);
  182. INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9100,
  183. ARRAY_SIZE(ar5416Bank1_9100), 2);
  184. INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9100,
  185. ARRAY_SIZE(ar5416Bank2_9100), 2);
  186. INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9100,
  187. ARRAY_SIZE(ar5416Bank3_9100), 3);
  188. INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100,
  189. ARRAY_SIZE(ar5416Bank6_9100), 3);
  190. INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100,
  191. ARRAY_SIZE(ar5416Bank6TPC_9100), 3);
  192. INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9100,
  193. ARRAY_SIZE(ar5416Bank7_9100), 2);
  194. INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100,
  195. ARRAY_SIZE(ar5416Addac_9100), 2);
  196. } else {
  197. INIT_INI_ARRAY(&ah->iniModes, ar5416Modes,
  198. ARRAY_SIZE(ar5416Modes), 6);
  199. INIT_INI_ARRAY(&ah->iniCommon, ar5416Common,
  200. ARRAY_SIZE(ar5416Common), 2);
  201. INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0,
  202. ARRAY_SIZE(ar5416Bank0), 2);
  203. INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain,
  204. ARRAY_SIZE(ar5416BB_RfGain), 3);
  205. INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1,
  206. ARRAY_SIZE(ar5416Bank1), 2);
  207. INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2,
  208. ARRAY_SIZE(ar5416Bank2), 2);
  209. INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3,
  210. ARRAY_SIZE(ar5416Bank3), 3);
  211. INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6,
  212. ARRAY_SIZE(ar5416Bank6), 3);
  213. INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC,
  214. ARRAY_SIZE(ar5416Bank6TPC), 3);
  215. INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7,
  216. ARRAY_SIZE(ar5416Bank7), 2);
  217. INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac,
  218. ARRAY_SIZE(ar5416Addac), 2);
  219. }
  220. }
  221. /* Support for Japan ch.14 (2484) spread */
  222. void ar9002_hw_cck_chan14_spread(struct ath_hw *ah)
  223. {
  224. if (AR_SREV_9287_11_OR_LATER(ah)) {
  225. INIT_INI_ARRAY(&ah->iniCckfirNormal,
  226. ar9287Common_normal_cck_fir_coeff_92871_1,
  227. ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_92871_1),
  228. 2);
  229. INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
  230. ar9287Common_japan_2484_cck_fir_coeff_92871_1,
  231. ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_92871_1),
  232. 2);
  233. }
  234. }
  235. static void ar9280_20_hw_init_rxgain_ini(struct ath_hw *ah)
  236. {
  237. u32 rxgain_type;
  238. if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >=
  239. AR5416_EEP_MINOR_VER_17) {
  240. rxgain_type = ah->eep_ops->get_eeprom(ah, EEP_RXGAIN_TYPE);
  241. if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF)
  242. INIT_INI_ARRAY(&ah->iniModesRxGain,
  243. ar9280Modes_backoff_13db_rxgain_9280_2,
  244. ARRAY_SIZE(ar9280Modes_backoff_13db_rxgain_9280_2), 6);
  245. else if (rxgain_type == AR5416_EEP_RXGAIN_23DB_BACKOFF)
  246. INIT_INI_ARRAY(&ah->iniModesRxGain,
  247. ar9280Modes_backoff_23db_rxgain_9280_2,
  248. ARRAY_SIZE(ar9280Modes_backoff_23db_rxgain_9280_2), 6);
  249. else
  250. INIT_INI_ARRAY(&ah->iniModesRxGain,
  251. ar9280Modes_original_rxgain_9280_2,
  252. ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6);
  253. } else {
  254. INIT_INI_ARRAY(&ah->iniModesRxGain,
  255. ar9280Modes_original_rxgain_9280_2,
  256. ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6);
  257. }
  258. }
  259. static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah)
  260. {
  261. u32 txgain_type;
  262. if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >=
  263. AR5416_EEP_MINOR_VER_19) {
  264. txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE);
  265. if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER)
  266. INIT_INI_ARRAY(&ah->iniModesTxGain,
  267. ar9280Modes_high_power_tx_gain_9280_2,
  268. ARRAY_SIZE(ar9280Modes_high_power_tx_gain_9280_2), 6);
  269. else
  270. INIT_INI_ARRAY(&ah->iniModesTxGain,
  271. ar9280Modes_original_tx_gain_9280_2,
  272. ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6);
  273. } else {
  274. INIT_INI_ARRAY(&ah->iniModesTxGain,
  275. ar9280Modes_original_tx_gain_9280_2,
  276. ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6);
  277. }
  278. }
  279. static void ar9002_hw_init_mode_gain_regs(struct ath_hw *ah)
  280. {
  281. if (AR_SREV_9287_11_OR_LATER(ah))
  282. INIT_INI_ARRAY(&ah->iniModesRxGain,
  283. ar9287Modes_rx_gain_9287_1_1,
  284. ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_1), 6);
  285. else if (AR_SREV_9287_10(ah))
  286. INIT_INI_ARRAY(&ah->iniModesRxGain,
  287. ar9287Modes_rx_gain_9287_1_0,
  288. ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_0), 6);
  289. else if (AR_SREV_9280_20(ah))
  290. ar9280_20_hw_init_rxgain_ini(ah);
  291. if (AR_SREV_9287_11_OR_LATER(ah)) {
  292. INIT_INI_ARRAY(&ah->iniModesTxGain,
  293. ar9287Modes_tx_gain_9287_1_1,
  294. ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 6);
  295. } else if (AR_SREV_9287_10(ah)) {
  296. INIT_INI_ARRAY(&ah->iniModesTxGain,
  297. ar9287Modes_tx_gain_9287_1_0,
  298. ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_0), 6);
  299. } else if (AR_SREV_9280_20(ah)) {
  300. ar9280_20_hw_init_txgain_ini(ah);
  301. } else if (AR_SREV_9285_12_OR_LATER(ah)) {
  302. u32 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE);
  303. /* txgain table */
  304. if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) {
  305. if (AR_SREV_9285E_20(ah)) {
  306. INIT_INI_ARRAY(&ah->iniModesTxGain,
  307. ar9285Modes_XE2_0_high_power,
  308. ARRAY_SIZE(
  309. ar9285Modes_XE2_0_high_power), 6);
  310. } else {
  311. INIT_INI_ARRAY(&ah->iniModesTxGain,
  312. ar9285Modes_high_power_tx_gain_9285_1_2,
  313. ARRAY_SIZE(
  314. ar9285Modes_high_power_tx_gain_9285_1_2), 6);
  315. }
  316. } else {
  317. if (AR_SREV_9285E_20(ah)) {
  318. INIT_INI_ARRAY(&ah->iniModesTxGain,
  319. ar9285Modes_XE2_0_normal_power,
  320. ARRAY_SIZE(
  321. ar9285Modes_XE2_0_normal_power), 6);
  322. } else {
  323. INIT_INI_ARRAY(&ah->iniModesTxGain,
  324. ar9285Modes_original_tx_gain_9285_1_2,
  325. ARRAY_SIZE(
  326. ar9285Modes_original_tx_gain_9285_1_2), 6);
  327. }
  328. }
  329. }
  330. }
  331. /*
  332. * Helper for ASPM support.
  333. *
  334. * Disable PLL when in L0s as well as receiver clock when in L1.
  335. * This power saving option must be enabled through the SerDes.
  336. *
  337. * Programming the SerDes must go through the same 288 bit serial shift
  338. * register as the other analog registers. Hence the 9 writes.
  339. */
  340. static void ar9002_hw_configpcipowersave(struct ath_hw *ah,
  341. int restore,
  342. int power_off)
  343. {
  344. u8 i;
  345. u32 val;
  346. if (ah->is_pciexpress != true)
  347. return;
  348. /* Do not touch SerDes registers */
  349. if (ah->config.pcie_powersave_enable == 2)
  350. return;
  351. /* Nothing to do on restore for 11N */
  352. if (!restore) {
  353. if (AR_SREV_9280_20_OR_LATER(ah)) {
  354. /*
  355. * AR9280 2.0 or later chips use SerDes values from the
  356. * initvals.h initialized depending on chipset during
  357. * __ath9k_hw_init()
  358. */
  359. for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) {
  360. REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0),
  361. INI_RA(&ah->iniPcieSerdes, i, 1));
  362. }
  363. } else if (AR_SREV_9280(ah) &&
  364. (ah->hw_version.macRev == AR_SREV_REVISION_9280_10)) {
  365. REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00);
  366. REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
  367. /* RX shut off when elecidle is asserted */
  368. REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019);
  369. REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820);
  370. REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560);
  371. /* Shut off CLKREQ active in L1 */
  372. if (ah->config.pcie_clock_req)
  373. REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc);
  374. else
  375. REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd);
  376. REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
  377. REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
  378. REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007);
  379. /* Load the new settings */
  380. REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
  381. } else {
  382. ENABLE_REGWRITE_BUFFER(ah);
  383. REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
  384. REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
  385. /* RX shut off when elecidle is asserted */
  386. REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039);
  387. REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824);
  388. REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579);
  389. /*
  390. * Ignore ah->ah_config.pcie_clock_req setting for
  391. * pre-AR9280 11n
  392. */
  393. REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff);
  394. REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
  395. REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
  396. REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007);
  397. /* Load the new settings */
  398. REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
  399. REGWRITE_BUFFER_FLUSH(ah);
  400. DISABLE_REGWRITE_BUFFER(ah);
  401. }
  402. udelay(1000);
  403. }
  404. if (power_off) {
  405. /* clear bit 19 to disable L1 */
  406. REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  407. val = REG_READ(ah, AR_WA);
  408. /*
  409. * Set PCIe workaround bits
  410. * In AR9280 and AR9285, bit 14 in WA register (disable L1)
  411. * should only be set when device enters D3 and be
  412. * cleared when device comes back to D0.
  413. */
  414. if (ah->config.pcie_waen) {
  415. if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE)
  416. val |= AR_WA_D3_L1_DISABLE;
  417. } else {
  418. if (((AR_SREV_9285(ah) ||
  419. AR_SREV_9271(ah) ||
  420. AR_SREV_9287(ah)) &&
  421. (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) ||
  422. (AR_SREV_9280(ah) &&
  423. (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) {
  424. val |= AR_WA_D3_L1_DISABLE;
  425. }
  426. }
  427. if (AR_SREV_9280(ah) || AR_SREV_9285(ah) || AR_SREV_9287(ah)) {
  428. /*
  429. * Disable bit 6 and 7 before entering D3 to
  430. * prevent system hang.
  431. */
  432. val &= ~(AR_WA_BIT6 | AR_WA_BIT7);
  433. }
  434. if (AR_SREV_9285E_20(ah))
  435. val |= AR_WA_BIT23;
  436. REG_WRITE(ah, AR_WA, val);
  437. } else {
  438. if (ah->config.pcie_waen) {
  439. val = ah->config.pcie_waen;
  440. if (!power_off)
  441. val &= (~AR_WA_D3_L1_DISABLE);
  442. } else {
  443. if (AR_SREV_9285(ah) ||
  444. AR_SREV_9271(ah) ||
  445. AR_SREV_9287(ah)) {
  446. val = AR9285_WA_DEFAULT;
  447. if (!power_off)
  448. val &= (~AR_WA_D3_L1_DISABLE);
  449. }
  450. else if (AR_SREV_9280(ah)) {
  451. /*
  452. * For AR9280 chips, bit 22 of 0x4004
  453. * needs to be set.
  454. */
  455. val = AR9280_WA_DEFAULT;
  456. if (!power_off)
  457. val &= (~AR_WA_D3_L1_DISABLE);
  458. } else {
  459. val = AR_WA_DEFAULT;
  460. }
  461. }
  462. /* WAR for ASPM system hang */
  463. if (AR_SREV_9280(ah) || AR_SREV_9285(ah) || AR_SREV_9287(ah)) {
  464. val |= (AR_WA_BIT6 | AR_WA_BIT7);
  465. }
  466. if (AR_SREV_9285E_20(ah))
  467. val |= AR_WA_BIT23;
  468. REG_WRITE(ah, AR_WA, val);
  469. /* set bit 19 to allow forcing of pcie core into L1 state */
  470. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  471. }
  472. }
  473. static int ar9002_hw_get_radiorev(struct ath_hw *ah)
  474. {
  475. u32 val;
  476. int i;
  477. ENABLE_REGWRITE_BUFFER(ah);
  478. REG_WRITE(ah, AR_PHY(0x36), 0x00007058);
  479. for (i = 0; i < 8; i++)
  480. REG_WRITE(ah, AR_PHY(0x20), 0x00010000);
  481. REGWRITE_BUFFER_FLUSH(ah);
  482. DISABLE_REGWRITE_BUFFER(ah);
  483. val = (REG_READ(ah, AR_PHY(256)) >> 24) & 0xff;
  484. val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4);
  485. return ath9k_hw_reverse_bits(val, 8);
  486. }
  487. int ar9002_hw_rf_claim(struct ath_hw *ah)
  488. {
  489. u32 val;
  490. REG_WRITE(ah, AR_PHY(0), 0x00000007);
  491. val = ar9002_hw_get_radiorev(ah);
  492. switch (val & AR_RADIO_SREV_MAJOR) {
  493. case 0:
  494. val = AR_RAD5133_SREV_MAJOR;
  495. break;
  496. case AR_RAD5133_SREV_MAJOR:
  497. case AR_RAD5122_SREV_MAJOR:
  498. case AR_RAD2133_SREV_MAJOR:
  499. case AR_RAD2122_SREV_MAJOR:
  500. break;
  501. default:
  502. ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
  503. "Radio Chip Rev 0x%02X not supported\n",
  504. val & AR_RADIO_SREV_MAJOR);
  505. return -EOPNOTSUPP;
  506. }
  507. ah->hw_version.analog5GhzRev = val;
  508. return 0;
  509. }
  510. void ar9002_hw_enable_async_fifo(struct ath_hw *ah)
  511. {
  512. if (AR_SREV_9287_13_OR_LATER(ah)) {
  513. REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3,
  514. AR_MAC_PCU_ASYNC_FIFO_REG3_DATAPATH_SEL);
  515. REG_SET_BIT(ah, AR_PHY_MODE, AR_PHY_MODE_ASYNCFIFO);
  516. REG_CLR_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3,
  517. AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET);
  518. REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3,
  519. AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET);
  520. }
  521. }
  522. /*
  523. * If Async FIFO is enabled, the following counters change as MAC now runs
  524. * at 117 Mhz instead of 88/44MHz when async FIFO is disabled.
  525. *
  526. * The values below tested for ht40 2 chain.
  527. * Overwrite the delay/timeouts initialized in process ini.
  528. */
  529. void ar9002_hw_update_async_fifo(struct ath_hw *ah)
  530. {
  531. if (AR_SREV_9287_13_OR_LATER(ah)) {
  532. REG_WRITE(ah, AR_D_GBL_IFS_SIFS,
  533. AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR);
  534. REG_WRITE(ah, AR_D_GBL_IFS_SLOT,
  535. AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR);
  536. REG_WRITE(ah, AR_D_GBL_IFS_EIFS,
  537. AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR);
  538. REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR);
  539. REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR);
  540. REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
  541. AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
  542. REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
  543. AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
  544. }
  545. }
  546. /*
  547. * We don't enable WEP aggregation on mac80211 but we keep this
  548. * around for HAL unification purposes.
  549. */
  550. void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah)
  551. {
  552. if (AR_SREV_9287_13_OR_LATER(ah)) {
  553. REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
  554. AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
  555. }
  556. }
  557. /* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */
  558. void ar9002_hw_attach_ops(struct ath_hw *ah)
  559. {
  560. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  561. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  562. priv_ops->init_mode_regs = ar9002_hw_init_mode_regs;
  563. priv_ops->init_mode_gain_regs = ar9002_hw_init_mode_gain_regs;
  564. priv_ops->macversion_supported = ar9002_hw_macversion_supported;
  565. ops->config_pci_powersave = ar9002_hw_configpcipowersave;
  566. ar5008_hw_attach_phy_ops(ah);
  567. if (AR_SREV_9280_10_OR_LATER(ah))
  568. ar9002_hw_attach_phy_ops(ah);
  569. ar9002_hw_attach_calib_ops(ah);
  570. ar9002_hw_attach_mac_ops(ah);
  571. ath9k_hw_attach_ani_ops_old(ah);
  572. }