Revert "gma500: Fix dependencies"
[zen-stable.git] / drivers / net / wireless / ath / ath5k / caps.c
blob7dd88e1c3ff8c083ab87eeaaaa1b86b4a5988364
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>
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.
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.
20 /**************\
21 * Capabilities *
22 \**************/
24 #include "ath5k.h"
25 #include "reg.h"
26 #include "debug.h"
27 #include "base.h"
30 * Fill the capabilities struct
31 * TODO: Merge this with EEPROM code when we are done with it
33 int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
35 struct ath5k_capabilities *caps = &ah->ah_capabilities;
36 u16 ee_header;
38 /* Capabilities stored in the EEPROM */
39 ee_header = caps->cap_eeprom.ee_header;
41 if (ah->ah_version == AR5K_AR5210) {
43 * Set radio capabilities
44 * (The AR5110 only supports the middle 5GHz band)
46 caps->cap_range.range_5ghz_min = 5120;
47 caps->cap_range.range_5ghz_max = 5430;
48 caps->cap_range.range_2ghz_min = 0;
49 caps->cap_range.range_2ghz_max = 0;
51 /* Set supported modes */
52 __set_bit(AR5K_MODE_11A, caps->cap_mode);
53 } else {
55 * XXX The tranceiver supports frequencies from 4920 to 6100GHz
56 * XXX and from 2312 to 2732GHz. There are problems with the
57 * XXX current ieee80211 implementation because the IEEE
58 * XXX channel mapping does not support negative channel
59 * XXX numbers (2312MHz is channel -19). Of course, this
60 * XXX doesn't matter because these channels are out of the
61 * XXX legal range.
65 * Set radio capabilities
68 if (AR5K_EEPROM_HDR_11A(ee_header)) {
69 if (ath_is_49ghz_allowed(caps->cap_eeprom.ee_regdomain))
70 caps->cap_range.range_5ghz_min = 4920;
71 else
72 caps->cap_range.range_5ghz_min = 5005;
73 caps->cap_range.range_5ghz_max = 6100;
75 /* Set supported modes */
76 __set_bit(AR5K_MODE_11A, caps->cap_mode);
79 /* Enable 802.11b if a 2GHz capable radio (2111/5112) is
80 * connected */
81 if (AR5K_EEPROM_HDR_11B(ee_header) ||
82 (AR5K_EEPROM_HDR_11G(ee_header) &&
83 ah->ah_version != AR5K_AR5211)) {
84 /* 2312 */
85 caps->cap_range.range_2ghz_min = 2412;
86 caps->cap_range.range_2ghz_max = 2732;
88 if (AR5K_EEPROM_HDR_11B(ee_header))
89 __set_bit(AR5K_MODE_11B, caps->cap_mode);
91 if (AR5K_EEPROM_HDR_11G(ee_header) &&
92 ah->ah_version != AR5K_AR5211)
93 __set_bit(AR5K_MODE_11G, caps->cap_mode);
97 if ((ah->ah_radio_5ghz_revision & 0xf0) == AR5K_SREV_RAD_2112)
98 __clear_bit(AR5K_MODE_11A, caps->cap_mode);
100 /* Set number of supported TX queues */
101 if (ah->ah_version == AR5K_AR5210)
102 caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES_NOQCU;
103 else
104 caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES;
106 /* newer hardware has PHY error counters */
107 if (ah->ah_mac_srev >= AR5K_SREV_AR5213A)
108 caps->cap_has_phyerr_counters = true;
109 else
110 caps->cap_has_phyerr_counters = false;
112 return 0;
115 /* Main function used by the driver part to check caps */
116 int ath5k_hw_get_capability(struct ath5k_hw *ah,
117 enum ath5k_capability_type cap_type,
118 u32 capability, u32 *result)
120 switch (cap_type) {
121 case AR5K_CAP_NUM_TXQUEUES:
122 if (result) {
123 if (ah->ah_version == AR5K_AR5210)
124 *result = AR5K_NUM_TX_QUEUES_NOQCU;
125 else
126 *result = AR5K_NUM_TX_QUEUES;
127 goto yes;
129 case AR5K_CAP_VEOL:
130 goto yes;
131 case AR5K_CAP_COMPRESSION:
132 if (ah->ah_version == AR5K_AR5212)
133 goto yes;
134 else
135 goto no;
136 case AR5K_CAP_BURST:
137 goto yes;
138 case AR5K_CAP_TPC:
139 goto yes;
140 case AR5K_CAP_BSSIDMASK:
141 if (ah->ah_version == AR5K_AR5212)
142 goto yes;
143 else
144 goto no;
145 case AR5K_CAP_XR:
146 if (ah->ah_version == AR5K_AR5212)
147 goto yes;
148 else
149 goto no;
150 default:
151 goto no;
155 return -EINVAL;
156 yes:
157 return 0;
161 * TODO: Following functions should be part of a new function
162 * set_capability
165 int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid,
166 u16 assoc_id)
168 if (ah->ah_version == AR5K_AR5210) {
169 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
170 AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
171 return 0;
174 return -EIO;
177 int ath5k_hw_disable_pspoll(struct ath5k_hw *ah)
179 if (ah->ah_version == AR5K_AR5210) {
180 AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
181 AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
182 return 0;
185 return -EIO;