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
51 * REGISTER_TIMEOUT16 - Determine the timeout for 16bit register access
52 * @__datalen: Data length
54 #define REGISTER_TIMEOUT16(__datalen) \
55 ( REGISTER_TIMEOUT * ((__datalen) / sizeof(u16)) )
58 * REGISTER_TIMEOUT32 - Determine the timeout for 32bit register access
59 * @__datalen: Data length
61 #define REGISTER_TIMEOUT32(__datalen) \
62 ( REGISTER_TIMEOUT * ((__datalen) / sizeof(u32)) )
67 #define CSR_CACHE_SIZE 8
68 #define CSR_CACHE_SIZE_FIRMWARE 64
73 #define USB_VENDOR_REQUEST ( USB_TYPE_VENDOR | USB_RECIP_DEVICE )
74 #define USB_VENDOR_REQUEST_IN ( USB_DIR_IN | USB_VENDOR_REQUEST )
75 #define USB_VENDOR_REQUEST_OUT ( USB_DIR_OUT | USB_VENDOR_REQUEST )
78 * enum rt2x00usb_vendor_request: USB vendor commands.
80 enum rt2x00usb_vendor_request
{
88 USB_LED_CONTROL
= 10, /* RT73USB */
93 * enum rt2x00usb_mode_offset: Device modes offset.
95 enum rt2x00usb_mode_offset
{
98 USB_MODE_FUNCTION
= 3,
100 USB_MODE_SLEEP
= 7, /* RT73USB */
101 USB_MODE_FIRMWARE
= 8, /* RT73USB */
102 USB_MODE_WAKEUP
= 9, /* RT73USB */
106 * rt2x00usb_vendor_request - Send register command to device
107 * @rt2x00dev: Pointer to &struct rt2x00_dev
108 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
109 * @requesttype: Request type &USB_VENDOR_REQUEST_*
110 * @offset: Register offset to perform action on
111 * @value: Value to write to device
112 * @buffer: Buffer where information will be read/written to by device
113 * @buffer_length: Size of &buffer
114 * @timeout: Operation timeout
116 * This is the main function to communicate with the device,
117 * the &buffer argument _must_ either be NULL or point to
118 * a buffer allocated by kmalloc. Failure to do so can lead
119 * to unexpected behavior depending on the architecture.
121 int rt2x00usb_vendor_request(struct rt2x00_dev
*rt2x00dev
,
122 const u8 request
, const u8 requesttype
,
123 const u16 offset
, const u16 value
,
124 void *buffer
, const u16 buffer_length
,
128 * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
129 * @rt2x00dev: Pointer to &struct rt2x00_dev
130 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
131 * @requesttype: Request type &USB_VENDOR_REQUEST_*
132 * @offset: Register offset to perform action on
133 * @buffer: Buffer where information will be read/written to by device
134 * @buffer_length: Size of &buffer
135 * @timeout: Operation timeout
137 * This function will use a previously with kmalloc allocated cache
138 * to communicate with the device. The contents of the buffer pointer
139 * will be copied to this cache when writing, or read from the cache
141 * Buffers send to &rt2x00usb_vendor_request _must_ be allocated with
142 * kmalloc. Hence the reason for using a previously allocated cache
143 * which has been allocated properly.
145 int rt2x00usb_vendor_request_buff(struct rt2x00_dev
*rt2x00dev
,
146 const u8 request
, const u8 requesttype
,
147 const u16 offset
, void *buffer
,
148 const u16 buffer_length
, const int timeout
);
151 * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
152 * @rt2x00dev: Pointer to &struct rt2x00_dev
153 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
154 * @requesttype: Request type &USB_VENDOR_REQUEST_*
155 * @offset: Register offset to perform action on
156 * @buffer: Buffer where information will be read/written to by device
157 * @buffer_length: Size of &buffer
158 * @timeout: Operation timeout
160 * A version of &rt2x00usb_vendor_request_buff which must be called
161 * if the usb_cache_mutex is already held.
163 int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev
*rt2x00dev
,
164 const u8 request
, const u8 requesttype
,
165 const u16 offset
, void *buffer
,
166 const u16 buffer_length
, const int timeout
);
169 * rt2x00usb_vendor_request_sw - Send single register command to device
170 * @rt2x00dev: Pointer to &struct rt2x00_dev
171 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
172 * @offset: Register offset to perform action on
173 * @value: Value to write to device
174 * @timeout: Operation timeout
176 * Simple wrapper around rt2x00usb_vendor_request to write a single
177 * command to the device. Since we don't use the buffer argument we
178 * don't have to worry about kmalloc here.
180 static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev
*rt2x00dev
,
186 return rt2x00usb_vendor_request(rt2x00dev
, request
,
187 USB_VENDOR_REQUEST_OUT
, offset
,
188 value
, NULL
, 0, timeout
);
192 * rt2x00usb_eeprom_read - Read eeprom from device
193 * @rt2x00dev: Pointer to &struct rt2x00_dev
194 * @eeprom: Pointer to eeprom array to store the information in
195 * @length: Number of bytes to read from the eeprom
197 * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
198 * from the device. Note that the eeprom argument _must_ be allocated using
199 * kmalloc for correct handling inside the kernel USB layer.
201 static inline int rt2x00usb_eeprom_read(struct rt2x00_dev
*rt2x00dev
,
202 __le16
*eeprom
, const u16 length
)
204 return rt2x00usb_vendor_request(rt2x00dev
, USB_EEPROM_READ
,
205 USB_VENDOR_REQUEST_IN
, 0, 0,
207 REGISTER_TIMEOUT16(length
));
213 void rt2x00usb_disable_radio(struct rt2x00_dev
*rt2x00dev
);
218 int rt2x00usb_write_tx_data(struct rt2x00_dev
*rt2x00dev
,
219 struct data_queue
*queue
, struct sk_buff
*skb
);
222 * struct queue_entry_priv_usb: Per entry USB specific information
224 * @urb: Urb structure used for device communication.
226 struct queue_entry_priv_usb
{
231 * struct queue_entry_priv_usb_bcn: Per TX entry USB specific information
233 * The first section should match &struct queue_entry_priv_usb exactly.
234 * rt2500usb can use this structure to send a guardian byte when working
237 * @urb: Urb structure used for device communication.
238 * @guardian_data: Set to 0, used for sending the guardian data.
239 * @guardian_urb: Urb structure used to send the guardian data.
241 struct queue_entry_priv_usb_bcn
{
244 unsigned int guardian_data
;
245 struct urb
*guardian_urb
;
249 * Device initialization handlers.
251 void rt2x00usb_init_rxentry(struct rt2x00_dev
*rt2x00dev
,
252 struct queue_entry
*entry
);
253 void rt2x00usb_init_txentry(struct rt2x00_dev
*rt2x00dev
,
254 struct queue_entry
*entry
);
255 int rt2x00usb_initialize(struct rt2x00_dev
*rt2x00dev
);
256 void rt2x00usb_uninitialize(struct rt2x00_dev
*rt2x00dev
);
259 * USB driver handlers.
261 int rt2x00usb_probe(struct usb_interface
*usb_intf
,
262 const struct usb_device_id
*id
);
263 void rt2x00usb_disconnect(struct usb_interface
*usb_intf
);
265 int rt2x00usb_suspend(struct usb_interface
*usb_intf
, pm_message_t state
);
266 int rt2x00usb_resume(struct usb_interface
*usb_intf
);
268 #define rt2x00usb_suspend NULL
269 #define rt2x00usb_resume NULL
270 #endif /* CONFIG_PM */
272 #endif /* RT2X00USB_H */
This page took 0.035872 seconds and 5 git commands to generate.