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
23FILE_SECBOOT ( FORBIDDEN );
24
25/**************\
26* Capabilities *
27\**************/
28
29#include "ath5k.h"
30#include "reg.h"
31#include "base.h"
32
33/*
34 * Fill the capabilities struct
35 * TODO: Merge this with EEPROM code when we are done with it
36 */
38{
39 u16 ee_header;
40
41 /* Capabilities stored in the EEPROM */
42 ee_header = ah->ah_capabilities.cap_eeprom.ee_header;
43
44 if (ah->ah_version == AR5K_AR5210) {
45 /*
46 * Set radio capabilities
47 * (The AR5110 only supports the middle 5GHz band)
48 */
49 ah->ah_capabilities.cap_range.range_5ghz_min = 5120;
50 ah->ah_capabilities.cap_range.range_5ghz_max = 5430;
51 ah->ah_capabilities.cap_range.range_2ghz_min = 0;
52 ah->ah_capabilities.cap_range.range_2ghz_max = 0;
53
54 /* Set supported modes */
55 ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A;
56 ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A_TURBO;
57 } else {
58 /*
59 * XXX The tranceiver supports frequencies from 4920 to 6100GHz
60 * XXX and from 2312 to 2732GHz. There are problems with the
61 * XXX current ieee80211 implementation because the IEEE
62 * XXX channel mapping does not support negative channel
63 * XXX numbers (2312MHz is channel -19). Of course, this
64 * XXX doesn't matter because these channels are out of range
65 * XXX but some regulation domains like MKK (Japan) will
66 * XXX support frequencies somewhere around 4.8GHz.
67 */
68
69 /*
70 * Set radio capabilities
71 */
72
73 if (AR5K_EEPROM_HDR_11A(ee_header)) {
74 /* 4920 */
75 ah->ah_capabilities.cap_range.range_5ghz_min = 5005;
76 ah->ah_capabilities.cap_range.range_5ghz_max = 6100;
77
78 /* Set supported modes */
79 ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A;
80 ah->ah_capabilities.cap_mode |= AR5K_MODE_BIT_11A_TURBO;
81 if (ah->ah_version == AR5K_AR5212)
82 ah->ah_capabilities.cap_mode |=
84 }
85
86 /* Enable 802.11b if a 2GHz capable radio (2111/5112) is
87 * connected */
88 if (AR5K_EEPROM_HDR_11B(ee_header) ||
89 (AR5K_EEPROM_HDR_11G(ee_header) &&
90 ah->ah_version != AR5K_AR5211)) {
91 /* 2312 */
92 ah->ah_capabilities.cap_range.range_2ghz_min = 2412;
93 ah->ah_capabilities.cap_range.range_2ghz_max = 2732;
94
95 if (AR5K_EEPROM_HDR_11B(ee_header))
96 ah->ah_capabilities.cap_mode |=
98
99 if (AR5K_EEPROM_HDR_11G(ee_header) &&
100 ah->ah_version != AR5K_AR5211)
101 ah->ah_capabilities.cap_mode |=
103 }
104 }
105
106 /* GPIO */
107 ah->ah_gpio_npins = AR5K_NUM_GPIO;
108
109 /* Set number of supported TX queues */
110 ah->ah_capabilities.cap_queues.q_tx_num = 1;
111
112 return 0;
113}
114
115/* Main function used by the driver part to check caps */
117 enum ath5k_capability_type cap_type,
119{
120 switch (cap_type) {
122 if (result) {
123 *result = 1;
124 goto yes;
125 }
126 case AR5K_CAP_VEOL:
127 goto yes;
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;
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}
uint16_t result
Definition hyperv.h:33
#define AR5K_EEPROM_HDR_11G(_v)
Definition eeprom.h:71
#define AR5K_EEPROM_HDR_11B(_v)
Definition eeprom.h:70
#define AR5K_EEPROM_HDR_11A(_v)
Definition eeprom.h:69
#define AR5K_NUM_GPIO
Definition reg.h:928
@ AR5K_AR5210
Definition ath5k.h:256
@ AR5K_AR5212
Definition ath5k.h:258
@ AR5K_AR5211
Definition ath5k.h:257
ath5k_capability_type
Definition ath5k.h:887
@ AR5K_CAP_XR
Definition ath5k.h:903
@ AR5K_CAP_NUM_TXQUEUES
Definition ath5k.h:893
@ AR5K_CAP_BURST
Definition ath5k.h:896
@ AR5K_CAP_VEOL
Definition ath5k.h:894
@ AR5K_CAP_BSSIDMASK
Definition ath5k.h:900
@ AR5K_CAP_COMPRESSION
Definition ath5k.h:895
@ AR5K_CAP_TPC
Definition ath5k.h:899
@ AR5K_MODE_BIT_11A_TURBO
Definition ath5k.h:404
@ AR5K_MODE_BIT_11B
Definition ath5k.h:405
@ AR5K_MODE_BIT_11G_TURBO
Definition ath5k.h:407
@ AR5K_MODE_BIT_11G
Definition ath5k.h:406
@ AR5K_MODE_BIT_11A
Definition ath5k.h:403
int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability __unused, u32 *result)
Definition ath5k_caps.c:116
int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
Definition ath5k_caps.c:37
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define EINVAL
Invalid argument.
Definition errno.h:429
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
u16 capability
Capability flags.
Definition ieee80211.h:7
uint8_t ah
Definition registers.h:1
ath5k_hw_get_isr - Get interrupt status
Definition ath5k.h:955
#define u16
Definition vga.h:20
#define u32
Definition vga.h:21