ar9003_hw.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 "ar9003_initvals.h"
  18. /* General hardware code for the AR9003 hadware family */
  19. static bool ar9003_hw_macversion_supported(u32 macversion)
  20. {
  21. switch (macversion) {
  22. case AR_SREV_VERSION_9300:
  23. return true;
  24. default:
  25. break;
  26. }
  27. return false;
  28. }
  29. /* AR9003 2.0 - new INI format (pre, core, post arrays per subsystem) */
  30. static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
  31. {
  32. /* mac */
  33. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
  34. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
  35. ar9300_2p0_mac_core,
  36. ARRAY_SIZE(ar9300_2p0_mac_core), 2);
  37. INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
  38. ar9300_2p0_mac_postamble,
  39. ARRAY_SIZE(ar9300_2p0_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. ar9300_2p0_baseband_core,
  44. ARRAY_SIZE(ar9300_2p0_baseband_core), 2);
  45. INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
  46. ar9300_2p0_baseband_postamble,
  47. ARRAY_SIZE(ar9300_2p0_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. ar9300_2p0_radio_core,
  52. ARRAY_SIZE(ar9300_2p0_radio_core), 2);
  53. INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
  54. ar9300_2p0_radio_postamble,
  55. ARRAY_SIZE(ar9300_2p0_radio_postamble), 5);
  56. /* soc */
  57. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
  58. ar9300_2p0_soc_preamble,
  59. ARRAY_SIZE(ar9300_2p0_soc_preamble), 2);
  60. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
  61. INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
  62. ar9300_2p0_soc_postamble,
  63. ARRAY_SIZE(ar9300_2p0_soc_postamble), 5);
  64. /* rx/tx gain */
  65. INIT_INI_ARRAY(&ah->iniModesRxGain,
  66. ar9300Common_rx_gain_table_2p0,
  67. ARRAY_SIZE(ar9300Common_rx_gain_table_2p0), 2);
  68. INIT_INI_ARRAY(&ah->iniModesTxGain,
  69. ar9300Modes_lowest_ob_db_tx_gain_table_2p0,
  70. ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p0),
  71. 5);
  72. /* Load PCIE SERDES settings from INI */
  73. /* Awake Setting */
  74. INIT_INI_ARRAY(&ah->iniPcieSerdes,
  75. ar9300PciePhy_pll_on_clkreq_disable_L1_2p0,
  76. ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p0),
  77. 2);
  78. /* Sleep Setting */
  79. INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
  80. ar9300PciePhy_clkreq_enable_L1_2p0,
  81. ARRAY_SIZE(ar9300PciePhy_clkreq_enable_L1_2p0),
  82. 2);
  83. /* Fast clock modal settings */
  84. INIT_INI_ARRAY(&ah->iniModesAdditional,
  85. ar9300Modes_fast_clock_2p0,
  86. ARRAY_SIZE(ar9300Modes_fast_clock_2p0),
  87. 3);
  88. }
  89. /*
  90. * Helper for ASPM support.
  91. *
  92. * Disable PLL when in L0s as well as receiver clock when in L1.
  93. * This power saving option must be enabled through the SerDes.
  94. *
  95. * Programming the SerDes must go through the same 288 bit serial shift
  96. * register as the other analog registers. Hence the 9 writes.
  97. */
  98. static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
  99. int restore,
  100. int power_off)
  101. {
  102. if (ah->is_pciexpress != true)
  103. return;
  104. /* Do not touch SerDes registers */
  105. if (ah->config.pcie_powersave_enable == 2)
  106. return;
  107. /* Nothing to do on restore for 11N */
  108. if (!restore) {
  109. /* set bit 19 to allow forcing of pcie core into L1 state */
  110. REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
  111. /* Several PCIe massages to ensure proper behaviour */
  112. if (ah->config.pcie_waen)
  113. REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
  114. }
  115. }
  116. /* Sets up the AR9003 hardware familiy callbacks */
  117. void ar9003_hw_attach_ops(struct ath_hw *ah)
  118. {
  119. struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
  120. struct ath_hw_ops *ops = ath9k_hw_ops(ah);
  121. priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
  122. priv_ops->macversion_supported = ar9003_hw_macversion_supported;
  123. ops->config_pci_powersave = ar9003_hw_configpcipowersave;
  124. ar9003_hw_attach_phy_ops(ah);
  125. ar9003_hw_attach_calib_ops(ah);
  126. ar9003_hw_attach_mac_ops(ah);
  127. }