PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 4ms app.codeStats 0ms

/drivers/net/wireless/ath/ath5k/caps.c

https://bitbucket.org/slukk/jb-tsm-kernel-4.2
C | 186 lines | 109 code | 23 blank | 54 comment | 29 complexity | afd3f203a39bb134137154f5816304bc MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  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. 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 tranceiver supports frequencies from 4920 to 6100GHz
  50. * XXX and from 2312 to 2732GHz. 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. if (AR5K_EEPROM_HDR_11B(ee_header))
  78. __set_bit(AR5K_MODE_11B, caps->cap_mode);
  79. if (AR5K_EEPROM_HDR_11G(ee_header) &&
  80. ah->ah_version != AR5K_AR5211)
  81. __set_bit(AR5K_MODE_11G, caps->cap_mode);
  82. }
  83. }
  84. if ((ah->ah_radio_5ghz_revision & 0xf0) == AR5K_SREV_RAD_2112)
  85. __clear_bit(AR5K_MODE_11A, caps->cap_mode);
  86. /* Set number of supported TX queues */
  87. if (ah->ah_version == AR5K_AR5210)
  88. caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES_NOQCU;
  89. else
  90. caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES;
  91. /* newer hardware has PHY error counters */
  92. if (ah->ah_mac_srev >= AR5K_SREV_AR5213A)
  93. caps->cap_has_phyerr_counters = true;
  94. else
  95. caps->cap_has_phyerr_counters = false;
  96. return 0;
  97. }
  98. /* Main function used by the driver part to check caps */
  99. int ath5k_hw_get_capability(struct ath5k_hw *ah,
  100. enum ath5k_capability_type cap_type,
  101. u32 capability, u32 *result)
  102. {
  103. switch (cap_type) {
  104. case AR5K_CAP_NUM_TXQUEUES:
  105. if (result) {
  106. if (ah->ah_version == AR5K_AR5210)
  107. *result = AR5K_NUM_TX_QUEUES_NOQCU;
  108. else
  109. *result = AR5K_NUM_TX_QUEUES;
  110. goto yes;
  111. }
  112. case AR5K_CAP_VEOL:
  113. goto yes;
  114. case AR5K_CAP_COMPRESSION:
  115. if (ah->ah_version == AR5K_AR5212)
  116. goto yes;
  117. else
  118. goto no;
  119. case AR5K_CAP_BURST:
  120. goto yes;
  121. case AR5K_CAP_TPC:
  122. goto yes;
  123. case AR5K_CAP_BSSIDMASK:
  124. if (ah->ah_version == AR5K_AR5212)
  125. goto yes;
  126. else
  127. goto no;
  128. case AR5K_CAP_XR:
  129. if (ah->ah_version == AR5K_AR5212)
  130. goto yes;
  131. else
  132. goto no;
  133. default:
  134. goto no;
  135. }
  136. no:
  137. return -EINVAL;
  138. yes:
  139. return 0;
  140. }
  141. /*
  142. * TODO: Following functions should be part of a new function
  143. * set_capability
  144. */
  145. int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid,
  146. u16 assoc_id)
  147. {
  148. if (ah->ah_version == AR5K_AR5210) {
  149. AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
  150. AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
  151. return 0;
  152. }
  153. return -EIO;
  154. }
  155. int ath5k_hw_disable_pspoll(struct ath5k_hw *ah)
  156. {
  157. if (ah->ah_version == AR5K_AR5210) {
  158. AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
  159. AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
  160. return 0;
  161. }
  162. return -EIO;
  163. }