2 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 Abstract: rt2x00 generic register information.
33 ANTENNA_SW_DIVERSITY = 0,
36 ANTENNA_HW_DIVERSITY = 3,
44 LED_MODE_TXRX_ACTIVITY = 1,
45 LED_MODE_SIGNAL_STRENGTH = 2,
69 * Additional device states, these values are
70 * not strict since they are not directly passed
77 STATE_RADIO_RX_ON_LINK,
78 STATE_RADIO_RX_OFF_LINK,
94 * Cipher types for hardware encryption
103 * The following fields were added by rt61pci and rt73usb.
107 CIPHER_TKIP_NO_MIC = 7,
112 * We store the position of a register field inside a field structure,
113 * This will simplify the process of setting and reading a certain field
114 * inside the register while making sure the process remains byte order safe.
116 struct rt2x00_field8 {
121 struct rt2x00_field16 {
126 struct rt2x00_field32 {
132 * Power of two check, this will check
133 * if the mask that has been given contains
134 * and contiguous set of bits.
136 #define is_power_of_two(x) ( !((x) & ((x)-1)) )
137 #define low_bit_mask(x) ( ((x)-1) & ~(x) )
138 #define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x))
140 #define FIELD8(__mask) \
142 BUILD_BUG_ON(!(__mask) || \
143 !is_valid_mask(__mask) || \
144 (__mask) != (u8)(__mask)); \
145 (struct rt2x00_field8) { \
146 __ffs(__mask), (__mask) \
150 #define FIELD16(__mask) \
152 BUILD_BUG_ON(!(__mask) || \
153 !is_valid_mask(__mask) || \
154 (__mask) != (u16)(__mask));\
155 (struct rt2x00_field16) { \
156 __ffs(__mask), (__mask) \
160 #define FIELD32(__mask) \
162 BUILD_BUG_ON(!(__mask) || \
163 !is_valid_mask(__mask) || \
164 (__mask) != (u32)(__mask));\
165 (struct rt2x00_field32) { \
166 __ffs(__mask), (__mask) \
170 static inline void rt2x00_set_field32(u32 *reg,
171 const struct rt2x00_field32 field,
174 *reg &= ~(field.bit_mask);
175 *reg |= (value << field.bit_offset) & field.bit_mask;
178 static inline u32 rt2x00_get_field32(const u32 reg,
179 const struct rt2x00_field32 field)
181 return (reg & field.bit_mask) >> field.bit_offset;
184 static inline void rt2x00_set_field16(u16 *reg,
185 const struct rt2x00_field16 field,
188 *reg &= ~(field.bit_mask);
189 *reg |= (value << field.bit_offset) & field.bit_mask;
192 static inline u16 rt2x00_get_field16(const u16 reg,
193 const struct rt2x00_field16 field)
195 return (reg & field.bit_mask) >> field.bit_offset;
198 static inline void rt2x00_set_field8(u8 *reg,
199 const struct rt2x00_field8 field,
202 *reg &= ~(field.bit_mask);
203 *reg |= (value << field.bit_offset) & field.bit_mask;
206 static inline u8 rt2x00_get_field8(const u8 reg,
207 const struct rt2x00_field8 field)
209 return (reg & field.bit_mask) >> field.bit_offset;
212 #endif /* RT2X00REG_H */