You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ath5k_caps.c 4.2KB

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. * Lightly modified for iPXE, July 2009, by Joshua Oreman <oremanj@rwcr.net>.
  7. *
  8. * Permission to use, copy, modify, and distribute this software for any
  9. * purpose with or without fee is hereby granted, provided that the above
  10. * copyright notice and this permission notice appear in all copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. *
  20. */
  21. FILE_LICENCE ( MIT );
  22. /**************\
  23. * Capabilities *
  24. \**************/
  25. #include "ath5k.h"
  26. #include "reg.h"
  27. #include "base.h"
  28. /*
  29. * Fill the capabilities struct
  30. * TODO: Merge this with EEPROM code when we are done with it
  31. */
  32. int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
  33. {
  34. u16 ee_header;
  35. /* Capabilities stored in the EEPROM */
  36. ee_header = ah->ah_capabilities.cap_eeprom.ee_header;
  37. if (ah->ah_version == AR5K_AR5210) {
  38. /*
  39. * Set radio capabilities
  40. * (The AR5110 only supports the middle 5GHz band)
  41. */
  42. ah->ah_capabilities.cap_range.range_5ghz_min = 5120;
  43. ah->ah_capabilities.cap_range.range_5ghz_max = 5430;
  44. ah->ah_capabilities.cap_range.range_2ghz_min = 0;
  45. ah->ah_capabilities.cap_range.range_2ghz_max = 0;
  46. /* Set supported modes */
  47. ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A;
  48. ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A_TURBO;
  49. } else {
  50. /*
  51. * XXX The tranceiver supports frequencies from 4920 to 6100GHz
  52. * XXX and from 2312 to 2732GHz. There are problems with the
  53. * XXX current ieee80211 implementation because the IEEE
  54. * XXX channel mapping does not support negative channel
  55. * XXX numbers (2312MHz is channel -19). Of course, this
  56. * XXX doesn't matter because these channels are out of range
  57. * XXX but some regulation domains like MKK (Japan) will
  58. * XXX support frequencies somewhere around 4.8GHz.
  59. */
  60. /*
  61. * Set radio capabilities
  62. */
  63. if (AR5K_EEPROM_HDR_11A(ee_header)) {
  64. /* 4920 */
  65. ah->ah_capabilities.cap_range.range_5ghz_min = 5005;
  66. ah->ah_capabilities.cap_range.range_5ghz_max = 6100;
  67. /* Set supported modes */
  68. ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A;
  69. ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A_TURBO;
  70. if (ah->ah_version == AR5K_AR5212)
  71. ah->ah_capabilities.cap_mode |=
  72. AR5K_MODE_BIT_11G_TURBO;
  73. }
  74. /* Enable 802.11b if a 2GHz capable radio (2111/5112) is
  75. * connected */
  76. if (AR5K_EEPROM_HDR_11B(ee_header) ||
  77. (AR5K_EEPROM_HDR_11G(ee_header) &&
  78. ah->ah_version != AR5K_AR5211)) {
  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. ah->ah_capabilities.cap_mode |=
  84. AR5K_MODE_BIT_11B;
  85. if (AR5K_EEPROM_HDR_11G(ee_header) &&
  86. ah->ah_version != AR5K_AR5211)
  87. ah->ah_capabilities.cap_mode |=
  88. AR5K_MODE_BIT_11G;
  89. }
  90. }
  91. /* GPIO */
  92. ah->ah_gpio_npins = AR5K_NUM_GPIO;
  93. /* Set number of supported TX queues */
  94. ah->ah_capabilities.cap_queues.q_tx_num = 1;
  95. return 0;
  96. }
  97. /* Main function used by the driver part to check caps */
  98. int ath5k_hw_get_capability(struct ath5k_hw *ah,
  99. enum ath5k_capability_type cap_type,
  100. u32 capability __unused, u32 *result)
  101. {
  102. switch (cap_type) {
  103. case AR5K_CAP_NUM_TXQUEUES:
  104. if (result) {
  105. *result = 1;
  106. goto yes;
  107. }
  108. case AR5K_CAP_VEOL:
  109. goto yes;
  110. case AR5K_CAP_COMPRESSION:
  111. if (ah->ah_version == AR5K_AR5212)
  112. goto yes;
  113. else
  114. goto no;
  115. case AR5K_CAP_BURST:
  116. goto yes;
  117. case AR5K_CAP_TPC:
  118. goto yes;
  119. case AR5K_CAP_BSSIDMASK:
  120. if (ah->ah_version == AR5K_AR5212)
  121. goto yes;
  122. else
  123. goto no;
  124. case AR5K_CAP_XR:
  125. if (ah->ah_version == AR5K_AR5212)
  126. goto yes;
  127. else
  128. goto no;
  129. default:
  130. goto no;
  131. }
  132. no:
  133. return -EINVAL;
  134. yes:
  135. return 0;
  136. }