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 /**************\ 21 * Capabilities * 22 \**************/ 23 24 #include "ath5k.h" 25 #include "reg.h" 26 #include "debug.h" 27 #include "base.h" 28 29 /* 30 * Fill the capabilities struct 31 * TODO: Merge this with EEPROM code when we are done with it 32 */ 33 int ath5k_hw_set_capabilities(struct ath5k_hw *ah) 34 { 35 u16 ee_header; 36 37 ATH5K_TRACE(ah->ah_sc); 38 /* Capabilities stored in the EEPROM */ 39 ee_header = ah->ah_capabilities.cap_eeprom.ee_header; 40 41 if (ah->ah_version == AR5K_AR5210) { 42 /* 43 * Set radio capabilities 44 * (The AR5110 only supports the middle 5GHz band) 45 */ 46 ah->ah_capabilities.cap_range.range_5ghz_min = 5120; 47 ah->ah_capabilities.cap_range.range_5ghz_max = 5430; 48 ah->ah_capabilities.cap_range.range_2ghz_min = 0; 49 ah->ah_capabilities.cap_range.range_2ghz_max = 0; 50 51 /* Set supported modes */ 52 __set_bit(AR5K_MODE_11A, ah->ah_capabilities.cap_mode); 53 __set_bit(AR5K_MODE_11A_TURBO, ah->ah_capabilities.cap_mode); 54 } else { 55 /* 56 * XXX The tranceiver supports frequencies from 4920 to 6100GHz 57 * XXX and from 2312 to 2732GHz. There are problems with the 58 * XXX current ieee80211 implementation because the IEEE 59 * XXX channel mapping does not support negative channel 60 * XXX numbers (2312MHz is channel -19). Of course, this 61 * XXX doesn't matter because these channels are out of range 62 * XXX but some regulation domains like MKK (Japan) will 63 * XXX support frequencies somewhere around 4.8GHz. 64 */ 65 66 /* 67 * Set radio capabilities 68 */ 69 70 if (AR5K_EEPROM_HDR_11A(ee_header)) { 71 /* 4920 */ 72 ah->ah_capabilities.cap_range.range_5ghz_min = 5005; 73 ah->ah_capabilities.cap_range.range_5ghz_max = 6100; 74 75 /* Set supported modes */ 76 __set_bit(AR5K_MODE_11A, 77 ah->ah_capabilities.cap_mode); 78 __set_bit(AR5K_MODE_11A_TURBO, 79 ah->ah_capabilities.cap_mode); 80 if (ah->ah_version == AR5K_AR5212) 81 __set_bit(AR5K_MODE_11G_TURBO, 82 ah->ah_capabilities.cap_mode); 83 } 84 85 /* Enable 802.11b if a 2GHz capable radio (2111/5112) is 86 * connected */ 87 if (AR5K_EEPROM_HDR_11B(ee_header) || 88 (AR5K_EEPROM_HDR_11G(ee_header) && 89 ah->ah_version != AR5K_AR5211)) { 90 /* 2312 */ 91 ah->ah_capabilities.cap_range.range_2ghz_min = 2412; 92 ah->ah_capabilities.cap_range.range_2ghz_max = 2732; 93 94 if (AR5K_EEPROM_HDR_11B(ee_header)) 95 __set_bit(AR5K_MODE_11B, 96 ah->ah_capabilities.cap_mode); 97 98 if (AR5K_EEPROM_HDR_11G(ee_header) && 99 ah->ah_version != AR5K_AR5211) 100 __set_bit(AR5K_MODE_11G, 101 ah->ah_capabilities.cap_mode); 102 } 103 } 104 105 /* Set number of supported TX queues */ 106 if (ah->ah_version == AR5K_AR5210) 107 ah->ah_capabilities.cap_queues.q_tx_num = 108 AR5K_NUM_TX_QUEUES_NOQCU; 109 else 110 ah->ah_capabilities.cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES; 111 112 /* newer hardware has PHY error counters */ 113 if (ah->ah_mac_srev >= AR5K_SREV_AR5213A) 114 ah->ah_capabilities.cap_has_phyerr_counters = true; 115 else 116 ah->ah_capabilities.cap_has_phyerr_counters = false; 117 118 return 0; 119 } 120 121 /* Main function used by the driver part to check caps */ 122 int ath5k_hw_get_capability(struct ath5k_hw *ah, 123 enum ath5k_capability_type cap_type, 124 u32 capability, u32 *result) 125 { 126 ATH5K_TRACE(ah->ah_sc); 127 128 switch (cap_type) { 129 case AR5K_CAP_NUM_TXQUEUES: 130 if (result) { 131 if (ah->ah_version == AR5K_AR5210) 132 *result = AR5K_NUM_TX_QUEUES_NOQCU; 133 else 134 *result = AR5K_NUM_TX_QUEUES; 135 goto yes; 136 } 137 case AR5K_CAP_VEOL: 138 goto yes; 139 case AR5K_CAP_COMPRESSION: 140 if (ah->ah_version == AR5K_AR5212) 141 goto yes; 142 else 143 goto no; 144 case AR5K_CAP_BURST: 145 goto yes; 146 case AR5K_CAP_TPC: 147 goto yes; 148 case AR5K_CAP_BSSIDMASK: 149 if (ah->ah_version == AR5K_AR5212) 150 goto yes; 151 else 152 goto no; 153 case AR5K_CAP_XR: 154 if (ah->ah_version == AR5K_AR5212) 155 goto yes; 156 else 157 goto no; 158 default: 159 goto no; 160 } 161 162 no: 163 return -EINVAL; 164 yes: 165 return 0; 166 } 167 168 /* 169 * TODO: Following functions should be part of a new function 170 * set_capability 171 */ 172 173 int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, 174 u16 assoc_id) 175 { 176 ATH5K_TRACE(ah->ah_sc); 177 178 if (ah->ah_version == AR5K_AR5210) { 179 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, 180 AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA); 181 return 0; 182 } 183 184 return -EIO; 185 } 186 187 int ath5k_hw_disable_pspoll(struct ath5k_hw *ah) 188 { 189 ATH5K_TRACE(ah->ah_sc); 190 191 if (ah->ah_version == AR5K_AR5210) { 192 AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1, 193 AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA); 194 return 0; 195 } 196 197 return -EIO; 198 } 199