caps.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 "base.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. u16 ee_header;
  33. ATH5K_TRACE(ah->ah_sc);
  34. /* Capabilities stored in the EEPROM */
  35. ee_header = ah->ah_capabilities.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. ah->ah_capabilities.cap_range.range_5ghz_min = 5120;
  42. ah->ah_capabilities.cap_range.range_5ghz_max = 5430;
  43. ah->ah_capabilities.cap_range.range_2ghz_min = 0;
  44. ah->ah_capabilities.cap_range.range_2ghz_max = 0;
  45. /* Set supported modes */
  46. __set_bit(AR5K_MODE_11A, ah->ah_capabilities.cap_mode);
  47. __set_bit(AR5K_MODE_11A_TURBO, ah->ah_capabilities.cap_mode);
  48. } else {
  49. /*
  50. * XXX The tranceiver supports frequencies from 4920 to 6100GHz
  51. * XXX and from 2312 to 2732GHz. There are problems with the
  52. * XXX current ieee80211 implementation because the IEEE
  53. * XXX channel mapping does not support negative channel
  54. * XXX numbers (2312MHz is channel -19). Of course, this
  55. * XXX doesn't matter because these channels are out of range
  56. * XXX but some regulation domains like MKK (Japan) will
  57. * XXX support frequencies somewhere around 4.8GHz.
  58. */
  59. /*
  60. * Set radio capabilities
  61. */
  62. if (AR5K_EEPROM_HDR_11A(ee_header)) {
  63. /* 4920 */
  64. ah->ah_capabilities.cap_range.range_5ghz_min = 5005;
  65. ah->ah_capabilities.cap_range.range_5ghz_max = 6100;
  66. /* Set supported modes */
  67. __set_bit(AR5K_MODE_11A,
  68. ah->ah_capabilities.cap_mode);
  69. __set_bit(AR5K_MODE_11A_TURBO,
  70. ah->ah_capabilities.cap_mode);
  71. if (ah->ah_version == AR5K_AR5212)
  72. __set_bit(AR5K_MODE_11G_TURBO,
  73. ah->ah_capabilities.cap_mode);
  74. }
  75. /* Enable 802.11b if a 2GHz capable radio (2111/5112) is
  76. * connected */
  77. if (AR5K_EEPROM_HDR_11B(ee_header) ||
  78. AR5K_EEPROM_HDR_11G(ee_header)) {
  79. /* 2312 */
  80. ah->ah_capabilities.cap_range.range_2ghz_min = 2412;
  81. ah->ah_capabilities.cap_range.range_2ghz_max = 2732;
  82. if (AR5K_EEPROM_HDR_11B(ee_header))
  83. __set_bit(AR5K_MODE_11B,
  84. ah->ah_capabilities.cap_mode);
  85. if (AR5K_EEPROM_HDR_11G(ee_header))
  86. __set_bit(AR5K_MODE_11G,
  87. ah->ah_capabilities.cap_mode);
  88. }
  89. }
  90. /* GPIO */
  91. ah->ah_gpio_npins = AR5K_NUM_GPIO;
  92. /* Set number of supported TX queues */
  93. if (ah->ah_version == AR5K_AR5210)
  94. ah->ah_capabilities.cap_queues.q_tx_num =
  95. AR5K_NUM_TX_QUEUES_NOQCU;
  96. else
  97. ah->ah_capabilities.cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES;
  98. return 0;
  99. }
  100. /* Main function used by the driver part to check caps */
  101. int ath5k_hw_get_capability(struct ath5k_hw *ah,
  102. enum ath5k_capability_type cap_type,
  103. u32 capability, u32 *result)
  104. {
  105. ATH5K_TRACE(ah->ah_sc);
  106. switch (cap_type) {
  107. case AR5K_CAP_NUM_TXQUEUES:
  108. if (result) {
  109. if (ah->ah_version == AR5K_AR5210)
  110. *result = AR5K_NUM_TX_QUEUES_NOQCU;
  111. else
  112. *result = AR5K_NUM_TX_QUEUES;
  113. goto yes;
  114. }
  115. case AR5K_CAP_VEOL:
  116. goto yes;
  117. case AR5K_CAP_COMPRESSION:
  118. if (ah->ah_version == AR5K_AR5212)
  119. goto yes;
  120. else
  121. goto no;
  122. case AR5K_CAP_BURST:
  123. goto yes;
  124. case AR5K_CAP_TPC:
  125. goto yes;
  126. case AR5K_CAP_BSSIDMASK:
  127. if (ah->ah_version == AR5K_AR5212)
  128. goto yes;
  129. else
  130. goto no;
  131. case AR5K_CAP_XR:
  132. if (ah->ah_version == AR5K_AR5212)
  133. goto yes;
  134. else
  135. goto no;
  136. default:
  137. goto no;
  138. }
  139. no:
  140. return -EINVAL;
  141. yes:
  142. return 0;
  143. }
  144. /*
  145. * TODO: Following functions should be part of a new function
  146. * set_capability
  147. */
  148. int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid,
  149. u16 assoc_id)
  150. {
  151. ATH5K_TRACE(ah->ah_sc);
  152. if (ah->ah_version == AR5K_AR5210) {
  153. AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
  154. AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
  155. return 0;
  156. }
  157. return -EIO;
  158. }
  159. int ath5k_hw_disable_pspoll(struct ath5k_hw *ah)
  160. {
  161. ATH5K_TRACE(ah->ah_sc);
  162. if (ah->ah_version == AR5K_AR5210) {
  163. AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
  164. AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
  165. return 0;
  166. }
  167. return -EIO;
  168. }