caps.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
  3. * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
  4. * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
  5. *
  6. * Permission to use, copy, modify, and distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. *
  18. */
  19. /**************\
  20. * Capabilities *
  21. \**************/
  22. #include "ath5k.h"
  23. #include "reg.h"
  24. #include "debug.h"
  25. #include "../regd.h"
  26. /*
  27. * Fill the capabilities struct
  28. * TODO: Merge this with EEPROM code when we are done with it
  29. */
  30. int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
  31. {
  32. struct ath5k_capabilities *caps = &ah->ah_capabilities;
  33. u16 ee_header;
  34. /* Capabilities stored in the EEPROM */
  35. ee_header = caps->cap_eeprom.ee_header;
  36. if (ah->ah_version == AR5K_AR5210) {
  37. /*
  38. * Set radio capabilities
  39. * (The AR5110 only supports the middle 5GHz band)
  40. */
  41. caps->cap_range.range_5ghz_min = 5120;
  42. caps->cap_range.range_5ghz_max = 5430;
  43. caps->cap_range.range_2ghz_min = 0;
  44. caps->cap_range.range_2ghz_max = 0;
  45. /* Set supported modes */
  46. __set_bit(AR5K_MODE_11A, caps->cap_mode);
  47. } else {
  48. /*
  49. * XXX The transceiver supports frequencies from 4920 to 6100MHz
  50. * XXX and from 2312 to 2732MHz. There are problems with the
  51. * XXX current ieee80211 implementation because the IEEE
  52. * XXX channel mapping does not support negative channel
  53. * XXX numbers (2312MHz is channel -19). Of course, this
  54. * XXX doesn't matter because these channels are out of the
  55. * XXX legal range.
  56. */
  57. /*
  58. * Set radio capabilities
  59. */
  60. if (AR5K_EEPROM_HDR_11A(ee_header)) {
  61. if (ath_is_49ghz_allowed(caps->cap_eeprom.ee_regdomain))
  62. caps->cap_range.range_5ghz_min = 4920;
  63. else
  64. caps->cap_range.range_5ghz_min = 5005;
  65. caps->cap_range.range_5ghz_max = 6100;
  66. /* Set supported modes */
  67. __set_bit(AR5K_MODE_11A, caps->cap_mode);
  68. }
  69. /* Enable 802.11b if a 2GHz capable radio (2111/5112) is
  70. * connected */
  71. if (AR5K_EEPROM_HDR_11B(ee_header) ||
  72. (AR5K_EEPROM_HDR_11G(ee_header) &&
  73. ah->ah_version != AR5K_AR5211)) {
  74. /* 2312 */
  75. caps->cap_range.range_2ghz_min = 2412;
  76. caps->cap_range.range_2ghz_max = 2732;
  77. /* Override 2GHz modes on SoCs that need it
  78. * NOTE: cap_needs_2GHz_ovr gets set from
  79. * ath_ahb_probe */
  80. if (!caps->cap_needs_2GHz_ovr) {
  81. if (AR5K_EEPROM_HDR_11B(ee_header))
  82. __set_bit(AR5K_MODE_11B,
  83. caps->cap_mode);
  84. if (AR5K_EEPROM_HDR_11G(ee_header) &&
  85. ah->ah_version != AR5K_AR5211)
  86. __set_bit(AR5K_MODE_11G,
  87. caps->cap_mode);
  88. }
  89. }
  90. }
  91. if ((ah->ah_radio_5ghz_revision & 0xf0) == AR5K_SREV_RAD_2112)
  92. __clear_bit(AR5K_MODE_11A, caps->cap_mode);
  93. /* Set number of supported TX queues */
  94. if (ah->ah_version == AR5K_AR5210)
  95. caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES_NOQCU;
  96. else
  97. caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES;
  98. /* Newer hardware has PHY error counters */
  99. if (ah->ah_mac_srev >= AR5K_SREV_AR5213A)
  100. caps->cap_has_phyerr_counters = true;
  101. else
  102. caps->cap_has_phyerr_counters = false;
  103. /* MACs since AR5212 have MRR support */
  104. if (ah->ah_version == AR5K_AR5212)
  105. caps->cap_has_mrr_support = true;
  106. else
  107. caps->cap_has_mrr_support = false;
  108. return 0;
  109. }
  110. /*
  111. * TODO: Following functions should be part of a new function
  112. * set_capability
  113. */
  114. int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid,
  115. u16 assoc_id)
  116. {
  117. if (ah->ah_version == AR5K_AR5210) {
  118. AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
  119. AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
  120. return 0;
  121. }
  122. return -EIO;
  123. }
  124. int ath5k_hw_disable_pspoll(struct ath5k_hw *ah)
  125. {
  126. if (ah->ah_version == AR5K_AR5210) {
  127. AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
  128. AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
  129. return 0;
  130. }
  131. return -EIO;
  132. }