blob: f77e8a703c5cbcd7212751509828db9efe46f74f [file] [log] [blame]
Nick Kossifidisc6e387a2008-08-29 22:45:39 +03001/*
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 */
33int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
34{
Bruno Randolf20a90492011-01-25 13:15:28 +090035 struct ath5k_capabilities *caps = &ah->ah_capabilities;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030036 u16 ee_header;
37
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030038 /* Capabilities stored in the EEPROM */
Bruno Randolf20a90492011-01-25 13:15:28 +090039 ee_header = caps->cap_eeprom.ee_header;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030040
41 if (ah->ah_version == AR5K_AR5210) {
42 /*
43 * Set radio capabilities
44 * (The AR5110 only supports the middle 5GHz band)
45 */
Bruno Randolf20a90492011-01-25 13:15:28 +090046 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;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030050
51 /* Set supported modes */
Bruno Randolf20a90492011-01-25 13:15:28 +090052 __set_bit(AR5K_MODE_11A, caps->cap_mode);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030053 } else {
54 /*
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
Bruno Randolfead3dcf2011-01-25 13:15:38 +090060 * XXX doesn't matter because these channels are out of the
61 * XXX legal range.
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030062 */
63
64 /*
65 * Set radio capabilities
66 */
67
68 if (AR5K_EEPROM_HDR_11A(ee_header)) {
Bruno Randolfead3dcf2011-01-25 13:15:38 +090069 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;
Bruno Randolf20a90492011-01-25 13:15:28 +090073 caps->cap_range.range_5ghz_max = 6100;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030074
75 /* Set supported modes */
Bruno Randolf20a90492011-01-25 13:15:28 +090076 __set_bit(AR5K_MODE_11A, caps->cap_mode);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030077 }
78
79 /* Enable 802.11b if a 2GHz capable radio (2111/5112) is
80 * connected */
81 if (AR5K_EEPROM_HDR_11B(ee_header) ||
Helmut Schaa81094882009-01-12 13:04:06 +010082 (AR5K_EEPROM_HDR_11G(ee_header) &&
83 ah->ah_version != AR5K_AR5211)) {
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030084 /* 2312 */
Bruno Randolf20a90492011-01-25 13:15:28 +090085 caps->cap_range.range_2ghz_min = 2412;
86 caps->cap_range.range_2ghz_max = 2732;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030087
88 if (AR5K_EEPROM_HDR_11B(ee_header))
Bruno Randolf20a90492011-01-25 13:15:28 +090089 __set_bit(AR5K_MODE_11B, caps->cap_mode);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030090
Helmut Schaa81094882009-01-12 13:04:06 +010091 if (AR5K_EEPROM_HDR_11G(ee_header) &&
92 ah->ah_version != AR5K_AR5211)
Bruno Randolf20a90492011-01-25 13:15:28 +090093 __set_bit(AR5K_MODE_11G, caps->cap_mode);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030094 }
95 }
96
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030097 /* Set number of supported TX queues */
98 if (ah->ah_version == AR5K_AR5210)
Bruno Randolf20a90492011-01-25 13:15:28 +090099 caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES_NOQCU;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300100 else
Bruno Randolf20a90492011-01-25 13:15:28 +0900101 caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300102
Bruno Randolfa8c944f2010-03-25 14:49:47 +0900103 /* newer hardware has PHY error counters */
104 if (ah->ah_mac_srev >= AR5K_SREV_AR5213A)
Bruno Randolf20a90492011-01-25 13:15:28 +0900105 caps->cap_has_phyerr_counters = true;
Bruno Randolfa8c944f2010-03-25 14:49:47 +0900106 else
Bruno Randolf20a90492011-01-25 13:15:28 +0900107 caps->cap_has_phyerr_counters = false;
Bruno Randolfa8c944f2010-03-25 14:49:47 +0900108
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300109 return 0;
110}
111
112/* Main function used by the driver part to check caps */
113int ath5k_hw_get_capability(struct ath5k_hw *ah,
114 enum ath5k_capability_type cap_type,
115 u32 capability, u32 *result)
116{
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300117 switch (cap_type) {
118 case AR5K_CAP_NUM_TXQUEUES:
119 if (result) {
120 if (ah->ah_version == AR5K_AR5210)
121 *result = AR5K_NUM_TX_QUEUES_NOQCU;
122 else
123 *result = AR5K_NUM_TX_QUEUES;
124 goto yes;
125 }
126 case AR5K_CAP_VEOL:
127 goto yes;
128 case AR5K_CAP_COMPRESSION:
129 if (ah->ah_version == AR5K_AR5212)
130 goto yes;
131 else
132 goto no;
133 case AR5K_CAP_BURST:
134 goto yes;
135 case AR5K_CAP_TPC:
136 goto yes;
137 case AR5K_CAP_BSSIDMASK:
138 if (ah->ah_version == AR5K_AR5212)
139 goto yes;
140 else
141 goto no;
142 case AR5K_CAP_XR:
143 if (ah->ah_version == AR5K_AR5212)
144 goto yes;
145 else
146 goto no;
147 default:
148 goto no;
149 }
150
151no:
152 return -EINVAL;
153yes:
154 return 0;
155}
156
157/*
158 * TODO: Following functions should be part of a new function
159 * set_capability
160 */
161
162int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid,
163 u16 assoc_id)
164{
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300165 if (ah->ah_version == AR5K_AR5210) {
166 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
167 AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
168 return 0;
169 }
170
171 return -EIO;
172}
173
174int ath5k_hw_disable_pspoll(struct ath5k_hw *ah)
175{
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300176 if (ah->ah_version == AR5K_AR5210) {
177 AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
178 AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
179 return 0;
180 }
181
182 return -EIO;
183}