iPXE
ath5k_caps.c
Go to the documentation of this file.
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 
22 FILE_LICENCE ( MIT );
23 
24 /**************\
25 * Capabilities *
26 \**************/
27 
28 #include "ath5k.h"
29 #include "reg.h"
30 #include "base.h"
31 
32 /*
33  * Fill the capabilities struct
34  * TODO: Merge this with EEPROM code when we are done with it
35  */
37 {
38  u16 ee_header;
39 
40  /* Capabilities stored in the EEPROM */
41  ee_header = ah->ah_capabilities.cap_eeprom.ee_header;
42 
43  if (ah->ah_version == AR5K_AR5210) {
44  /*
45  * Set radio capabilities
46  * (The AR5110 only supports the middle 5GHz band)
47  */
48  ah->ah_capabilities.cap_range.range_5ghz_min = 5120;
49  ah->ah_capabilities.cap_range.range_5ghz_max = 5430;
50  ah->ah_capabilities.cap_range.range_2ghz_min = 0;
51  ah->ah_capabilities.cap_range.range_2ghz_max = 0;
52 
53  /* Set supported modes */
54  ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A;
55  ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A_TURBO;
56  } else {
57  /*
58  * XXX The tranceiver supports frequencies from 4920 to 6100GHz
59  * XXX and from 2312 to 2732GHz. There are problems with the
60  * XXX current ieee80211 implementation because the IEEE
61  * XXX channel mapping does not support negative channel
62  * XXX numbers (2312MHz is channel -19). Of course, this
63  * XXX doesn't matter because these channels are out of range
64  * XXX but some regulation domains like MKK (Japan) will
65  * XXX support frequencies somewhere around 4.8GHz.
66  */
67 
68  /*
69  * Set radio capabilities
70  */
71 
72  if (AR5K_EEPROM_HDR_11A(ee_header)) {
73  /* 4920 */
74  ah->ah_capabilities.cap_range.range_5ghz_min = 5005;
75  ah->ah_capabilities.cap_range.range_5ghz_max = 6100;
76 
77  /* Set supported modes */
78  ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A;
79  ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A_TURBO;
80  if (ah->ah_version == AR5K_AR5212)
81  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  ah->ah_capabilities.cap_mode |=
97 
98  if (AR5K_EEPROM_HDR_11G(ee_header) &&
99  ah->ah_version != AR5K_AR5211)
100  ah->ah_capabilities.cap_mode |=
102  }
103  }
104 
105  /* GPIO */
106  ah->ah_gpio_npins = AR5K_NUM_GPIO;
107 
108  /* Set number of supported TX queues */
109  ah->ah_capabilities.cap_queues.q_tx_num = 1;
110 
111  return 0;
112 }
113 
114 /* Main function used by the driver part to check caps */
116  enum ath5k_capability_type cap_type,
118 {
119  switch (cap_type) {
121  if (result) {
122  *result = 1;
123  goto yes;
124  }
125  case AR5K_CAP_VEOL:
126  goto yes;
128  if (ah->ah_version == AR5K_AR5212)
129  goto yes;
130  else
131  goto no;
132  case AR5K_CAP_BURST:
133  goto yes;
134  case AR5K_CAP_TPC:
135  goto yes;
136  case AR5K_CAP_BSSIDMASK:
137  if (ah->ah_version == AR5K_AR5212)
138  goto yes;
139  else
140  goto no;
141  case AR5K_CAP_XR:
142  if (ah->ah_version == AR5K_AR5212)
143  goto yes;
144  else
145  goto no;
146  default:
147  goto no;
148  }
149 
150 no:
151  return -EINVAL;
152 yes:
153  return 0;
154 }
uint16_t u16
Definition: stdint.h:21
int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
Definition: ath5k_caps.c:36
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define AR5K_EEPROM_HDR_11B(_v)
Definition: eeprom.h:68
static const void const void void * result
Definition: crypto.h:335
FILE_LICENCE(MIT)
ath5k_capability_type
Definition: ath5k.h:885
ath5k_hw_get_isr - Get interrupt status
Definition: ath5k.h:953
u16 capability
Capability flags.
Definition: ieee80211.h:1036
#define AR5K_EEPROM_HDR_11A(_v)
Definition: eeprom.h:67
#define AR5K_NUM_GPIO
Definition: reg.h:931
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability __unused, u32 *result)
Definition: ath5k_caps.c:115
uint8_t ah
Definition: registers.h:85
#define AR5K_EEPROM_HDR_11G(_v)
Definition: eeprom.h:69
uint32_t u32
Definition: stdint.h:23