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: Data structures for the rt2x00usb module.
30 * This variable should be used with the
31 * usb_driver structure initialization.
33 #define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops)
37 * Some registers require multiple attempts before success,
38 * in those cases REGISTER_BUSY_COUNT attempts should be
39 * taken with a REGISTER_BUSY_DELAY interval.
40 * For USB vendor requests we need to pass a timeout
41 * time in ms, for this we use the REGISTER_TIMEOUT,
42 * however when loading firmware a higher value is
43 * required. In that case we use the REGISTER_TIMEOUT_FIRMWARE.
45 #define REGISTER_BUSY_COUNT 5
46 #define REGISTER_BUSY_DELAY 100
47 #define REGISTER_TIMEOUT 500
48 #define REGISTER_TIMEOUT_FIRMWARE 1000
53 #define CSR_CACHE_SIZE 8
54 #define CSR_CACHE_SIZE_FIRMWARE 64
59 #define USB_VENDOR_REQUEST ( USB_TYPE_VENDOR | USB_RECIP_DEVICE )
60 #define USB_VENDOR_REQUEST_IN ( USB_DIR_IN | USB_VENDOR_REQUEST )
61 #define USB_VENDOR_REQUEST_OUT ( USB_DIR_OUT | USB_VENDOR_REQUEST )
64 * enum rt2x00usb_vendor_request: USB vendor commands.
66 enum rt2x00usb_vendor_request
{
74 USB_LED_CONTROL
= 10, /* RT73USB */
79 * enum rt2x00usb_mode_offset: Device modes offset.
81 enum rt2x00usb_mode_offset
{
84 USB_MODE_FUNCTION
= 3,
86 USB_MODE_SLEEP
= 7, /* RT73USB */
87 USB_MODE_FIRMWARE
= 8, /* RT73USB */
88 USB_MODE_WAKEUP
= 9, /* RT73USB */
92 * rt2x00usb_vendor_request - Send register command to device
93 * @rt2x00dev: Pointer to &struct rt2x00_dev
94 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
95 * @requesttype: Request type &USB_VENDOR_REQUEST_*
96 * @offset: Register offset to perform action on
97 * @value: Value to write to device
98 * @buffer: Buffer where information will be read/written to by device
99 * @buffer_length: Size of &buffer
100 * @timeout: Operation timeout
102 * This is the main function to communicate with the device,
103 * the &buffer argument _must_ either be NULL or point to
104 * a buffer allocated by kmalloc. Failure to do so can lead
105 * to unexpected behavior depending on the architecture.
107 int rt2x00usb_vendor_request(struct rt2x00_dev
*rt2x00dev
,
108 const u8 request
, const u8 requesttype
,
109 const u16 offset
, const u16 value
,
110 void *buffer
, const u16 buffer_length
,
114 * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
115 * @rt2x00dev: Pointer to &struct rt2x00_dev
116 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
117 * @requesttype: Request type &USB_VENDOR_REQUEST_*
118 * @offset: Register offset to perform action on
119 * @buffer: Buffer where information will be read/written to by device
120 * @buffer_length: Size of &buffer
121 * @timeout: Operation timeout
123 * This function will use a previously with kmalloc allocated cache
124 * to communicate with the device. The contents of the buffer pointer
125 * will be copied to this cache when writing, or read from the cache
127 * Buffers send to &rt2x00usb_vendor_request _must_ be allocated with
128 * kmalloc. Hence the reason for using a previously allocated cache
129 * which has been allocated properly.
131 int rt2x00usb_vendor_request_buff(struct rt2x00_dev
*rt2x00dev
,
132 const u8 request
, const u8 requesttype
,
133 const u16 offset
, void *buffer
,
134 const u16 buffer_length
, const int timeout
);
137 * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
138 * @rt2x00dev: Pointer to &struct rt2x00_dev
139 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
140 * @requesttype: Request type &USB_VENDOR_REQUEST_*
141 * @offset: Register offset to perform action on
142 * @buffer: Buffer where information will be read/written to by device
143 * @buffer_length: Size of &buffer
144 * @timeout: Operation timeout
146 * A version of &rt2x00usb_vendor_request_buff which must be called
147 * if the usb_cache_mutex is already held.
149 int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev
*rt2x00dev
,
150 const u8 request
, const u8 requesttype
,
151 const u16 offset
, void *buffer
,
152 const u16 buffer_length
, const int timeout
);
155 * rt2x00usb_vendor_request_sw - Send single register command to device
156 * @rt2x00dev: Pointer to &struct rt2x00_dev
157 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
158 * @offset: Register offset to perform action on
159 * @value: Value to write to device
160 * @timeout: Operation timeout
162 * Simple wrapper around rt2x00usb_vendor_request to write a single
163 * command to the device. Since we don't use the buffer argument we
164 * don't have to worry about kmalloc here.
166 static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev
*rt2x00dev
,
172 return rt2x00usb_vendor_request(rt2x00dev
, request
,
173 USB_VENDOR_REQUEST_OUT
, offset
,
174 value
, NULL
, 0, timeout
);
178 * rt2x00usb_eeprom_read - Read eeprom from device
179 * @rt2x00dev: Pointer to &struct rt2x00_dev
180 * @eeprom: Pointer to eeprom array to store the information in
181 * @length: Number of bytes to read from the eeprom
183 * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
184 * from the device. Note that the eeprom argument _must_ be allocated using
185 * kmalloc for correct handling inside the kernel USB layer.
187 static inline int rt2x00usb_eeprom_read(struct rt2x00_dev
*rt2x00dev
,
188 __le16
*eeprom
, const u16 lenght
)
190 int timeout
= REGISTER_TIMEOUT
* (lenght
/ sizeof(u16
));
192 return rt2x00usb_vendor_request(rt2x00dev
, USB_EEPROM_READ
,
193 USB_VENDOR_REQUEST_IN
, 0, 0,
194 eeprom
, lenght
, timeout
);
200 void rt2x00usb_disable_radio(struct rt2x00_dev
*rt2x00dev
);
205 int rt2x00usb_write_tx_data(struct rt2x00_dev
*rt2x00dev
,
206 struct data_queue
*queue
, struct sk_buff
*skb
,
207 struct ieee80211_tx_control
*control
);
210 * struct queue_entry_priv_usb_rx: Per RX entry USB specific information
212 * @urb: Urb structure used for device communication.
214 struct queue_entry_priv_usb_rx
{
219 * struct queue_entry_priv_usb_tx: Per TX entry USB specific information
221 * @urb: Urb structure used for device communication.
222 * @control: mac80211 control structure used to transmit data.
224 struct queue_entry_priv_usb_tx
{
227 struct ieee80211_tx_control control
;
231 * struct queue_entry_priv_usb_tx: Per TX entry USB specific information
233 * The first section should match &struct queue_entry_priv_usb_tx exactly.
234 * rt2500usb can use this structure to send a guardian byte when working
237 * @urb: Urb structure used for device communication.
238 * @control: mac80211 control structure used to transmit data.
239 * @guardian_data: Set to 0, used for sending the guardian data.
240 * @guardian_urb: Urb structure used to send the guardian data.
242 struct queue_entry_priv_usb_bcn
{
245 struct ieee80211_tx_control control
;
247 unsigned int guardian_data
;
248 struct urb
*guardian_urb
;
252 * Device initialization handlers.
254 void rt2x00usb_init_rxentry(struct rt2x00_dev
*rt2x00dev
,
255 struct queue_entry
*entry
);
256 void rt2x00usb_init_txentry(struct rt2x00_dev
*rt2x00dev
,
257 struct queue_entry
*entry
);
258 int rt2x00usb_initialize(struct rt2x00_dev
*rt2x00dev
);
259 void rt2x00usb_uninitialize(struct rt2x00_dev
*rt2x00dev
);
262 * USB driver handlers.
264 int rt2x00usb_probe(struct usb_interface
*usb_intf
,
265 const struct usb_device_id
*id
);
266 void rt2x00usb_disconnect(struct usb_interface
*usb_intf
);
268 int rt2x00usb_suspend(struct usb_interface
*usb_intf
, pm_message_t state
);
269 int rt2x00usb_resume(struct usb_interface
*usb_intf
);
271 #define rt2x00usb_suspend NULL
272 #define rt2x00usb_resume NULL
273 #endif /* CONFIG_PM */
275 #endif /* RT2X00USB_H */