xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/ralink/rt2x00/rt2x00usb.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun 	Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
4*4882a593Smuzhiyun 	<http://rt2x00.serialmonkey.com>
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun /*
9*4882a593Smuzhiyun 	Module: rt2x00usb
10*4882a593Smuzhiyun 	Abstract: Data structures for the rt2x00usb module.
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #ifndef RT2X00USB_H
14*4882a593Smuzhiyun #define RT2X00USB_H
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #include <linux/usb.h>
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #define to_usb_device_intf(d) \
19*4882a593Smuzhiyun ({ \
20*4882a593Smuzhiyun 	struct usb_interface *intf = to_usb_interface(d); \
21*4882a593Smuzhiyun 	interface_to_usbdev(intf); \
22*4882a593Smuzhiyun })
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun  * For USB vendor requests we need to pass a timeout time in ms, for this we
26*4882a593Smuzhiyun  * use the REGISTER_TIMEOUT, however when loading firmware or read EEPROM
27*4882a593Smuzhiyun  * a higher value is required. In that case we use the REGISTER_TIMEOUT_FIRMWARE
28*4882a593Smuzhiyun  * and EEPROM_TIMEOUT.
29*4882a593Smuzhiyun  */
30*4882a593Smuzhiyun #define REGISTER_TIMEOUT		100
31*4882a593Smuzhiyun #define REGISTER_TIMEOUT_FIRMWARE	1000
32*4882a593Smuzhiyun #define EEPROM_TIMEOUT			2000
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun /*
35*4882a593Smuzhiyun  * Cache size
36*4882a593Smuzhiyun  */
37*4882a593Smuzhiyun #define CSR_CACHE_SIZE			64
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun /*
40*4882a593Smuzhiyun  * USB request types.
41*4882a593Smuzhiyun  */
42*4882a593Smuzhiyun #define USB_VENDOR_REQUEST	( USB_TYPE_VENDOR | USB_RECIP_DEVICE )
43*4882a593Smuzhiyun #define USB_VENDOR_REQUEST_IN	( USB_DIR_IN | USB_VENDOR_REQUEST )
44*4882a593Smuzhiyun #define USB_VENDOR_REQUEST_OUT	( USB_DIR_OUT | USB_VENDOR_REQUEST )
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun /**
47*4882a593Smuzhiyun  * enum rt2x00usb_vendor_request: USB vendor commands.
48*4882a593Smuzhiyun  */
49*4882a593Smuzhiyun enum rt2x00usb_vendor_request {
50*4882a593Smuzhiyun 	USB_DEVICE_MODE = 1,
51*4882a593Smuzhiyun 	USB_SINGLE_WRITE = 2,
52*4882a593Smuzhiyun 	USB_SINGLE_READ = 3,
53*4882a593Smuzhiyun 	USB_MULTI_WRITE = 6,
54*4882a593Smuzhiyun 	USB_MULTI_READ = 7,
55*4882a593Smuzhiyun 	USB_EEPROM_WRITE = 8,
56*4882a593Smuzhiyun 	USB_EEPROM_READ = 9,
57*4882a593Smuzhiyun 	USB_LED_CONTROL = 10, /* RT73USB */
58*4882a593Smuzhiyun 	USB_RX_CONTROL = 12,
59*4882a593Smuzhiyun };
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /**
62*4882a593Smuzhiyun  * enum rt2x00usb_mode_offset: Device modes offset.
63*4882a593Smuzhiyun  */
64*4882a593Smuzhiyun enum rt2x00usb_mode_offset {
65*4882a593Smuzhiyun 	USB_MODE_RESET = 1,
66*4882a593Smuzhiyun 	USB_MODE_UNPLUG = 2,
67*4882a593Smuzhiyun 	USB_MODE_FUNCTION = 3,
68*4882a593Smuzhiyun 	USB_MODE_TEST = 4,
69*4882a593Smuzhiyun 	USB_MODE_SLEEP = 7,	/* RT73USB */
70*4882a593Smuzhiyun 	USB_MODE_FIRMWARE = 8,	/* RT73USB */
71*4882a593Smuzhiyun 	USB_MODE_WAKEUP = 9,	/* RT73USB */
72*4882a593Smuzhiyun 	USB_MODE_AUTORUN = 17, /* RT2800USB */
73*4882a593Smuzhiyun };
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun /**
76*4882a593Smuzhiyun  * rt2x00usb_vendor_request - Send register command to device
77*4882a593Smuzhiyun  * @rt2x00dev: Pointer to &struct rt2x00_dev
78*4882a593Smuzhiyun  * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
79*4882a593Smuzhiyun  * @requesttype: Request type &USB_VENDOR_REQUEST_*
80*4882a593Smuzhiyun  * @offset: Register offset to perform action on
81*4882a593Smuzhiyun  * @value: Value to write to device
82*4882a593Smuzhiyun  * @buffer: Buffer where information will be read/written to by device
83*4882a593Smuzhiyun  * @buffer_length: Size of &buffer
84*4882a593Smuzhiyun  * @timeout: Operation timeout
85*4882a593Smuzhiyun  *
86*4882a593Smuzhiyun  * This is the main function to communicate with the device,
87*4882a593Smuzhiyun  * the &buffer argument _must_ either be NULL or point to
88*4882a593Smuzhiyun  * a buffer allocated by kmalloc. Failure to do so can lead
89*4882a593Smuzhiyun  * to unexpected behavior depending on the architecture.
90*4882a593Smuzhiyun  */
91*4882a593Smuzhiyun int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
92*4882a593Smuzhiyun 			     const u8 request, const u8 requesttype,
93*4882a593Smuzhiyun 			     const u16 offset, const u16 value,
94*4882a593Smuzhiyun 			     void *buffer, const u16 buffer_length,
95*4882a593Smuzhiyun 			     const int timeout);
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun /**
98*4882a593Smuzhiyun  * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
99*4882a593Smuzhiyun  * @rt2x00dev: Pointer to &struct rt2x00_dev
100*4882a593Smuzhiyun  * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
101*4882a593Smuzhiyun  * @requesttype: Request type &USB_VENDOR_REQUEST_*
102*4882a593Smuzhiyun  * @offset: Register offset to perform action on
103*4882a593Smuzhiyun  * @buffer: Buffer where information will be read/written to by device
104*4882a593Smuzhiyun  * @buffer_length: Size of &buffer
105*4882a593Smuzhiyun  *
106*4882a593Smuzhiyun  * This function will use a previously with kmalloc allocated cache
107*4882a593Smuzhiyun  * to communicate with the device. The contents of the buffer pointer
108*4882a593Smuzhiyun  * will be copied to this cache when writing, or read from the cache
109*4882a593Smuzhiyun  * when reading.
110*4882a593Smuzhiyun  * Buffers send to &rt2x00usb_vendor_request _must_ be allocated with
111*4882a593Smuzhiyun  * kmalloc. Hence the reason for using a previously allocated cache
112*4882a593Smuzhiyun  * which has been allocated properly.
113*4882a593Smuzhiyun  */
114*4882a593Smuzhiyun int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
115*4882a593Smuzhiyun 				  const u8 request, const u8 requesttype,
116*4882a593Smuzhiyun 				  const u16 offset, void *buffer,
117*4882a593Smuzhiyun 				  const u16 buffer_length);
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun /**
120*4882a593Smuzhiyun  * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
121*4882a593Smuzhiyun  * @rt2x00dev: Pointer to &struct rt2x00_dev
122*4882a593Smuzhiyun  * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
123*4882a593Smuzhiyun  * @requesttype: Request type &USB_VENDOR_REQUEST_*
124*4882a593Smuzhiyun  * @offset: Register offset to perform action on
125*4882a593Smuzhiyun  * @buffer: Buffer where information will be read/written to by device
126*4882a593Smuzhiyun  * @buffer_length: Size of &buffer
127*4882a593Smuzhiyun  * @timeout: Operation timeout
128*4882a593Smuzhiyun  *
129*4882a593Smuzhiyun  * A version of &rt2x00usb_vendor_request_buff which must be called
130*4882a593Smuzhiyun  * if the usb_cache_mutex is already held.
131*4882a593Smuzhiyun  */
132*4882a593Smuzhiyun int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev,
133*4882a593Smuzhiyun 				   const u8 request, const u8 requesttype,
134*4882a593Smuzhiyun 				   const u16 offset, void *buffer,
135*4882a593Smuzhiyun 				   const u16 buffer_length, const int timeout);
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun /**
138*4882a593Smuzhiyun  * rt2x00usb_vendor_request_sw - Send single register command to device
139*4882a593Smuzhiyun  * @rt2x00dev: Pointer to &struct rt2x00_dev
140*4882a593Smuzhiyun  * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
141*4882a593Smuzhiyun  * @offset: Register offset to perform action on
142*4882a593Smuzhiyun  * @value: Value to write to device
143*4882a593Smuzhiyun  * @timeout: Operation timeout
144*4882a593Smuzhiyun  *
145*4882a593Smuzhiyun  * Simple wrapper around rt2x00usb_vendor_request to write a single
146*4882a593Smuzhiyun  * command to the device. Since we don't use the buffer argument we
147*4882a593Smuzhiyun  * don't have to worry about kmalloc here.
148*4882a593Smuzhiyun  */
rt2x00usb_vendor_request_sw(struct rt2x00_dev * rt2x00dev,const u8 request,const u16 offset,const u16 value,const int timeout)149*4882a593Smuzhiyun static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev *rt2x00dev,
150*4882a593Smuzhiyun 					      const u8 request,
151*4882a593Smuzhiyun 					      const u16 offset,
152*4882a593Smuzhiyun 					      const u16 value,
153*4882a593Smuzhiyun 					      const int timeout)
154*4882a593Smuzhiyun {
155*4882a593Smuzhiyun 	return rt2x00usb_vendor_request(rt2x00dev, request,
156*4882a593Smuzhiyun 					USB_VENDOR_REQUEST_OUT, offset,
157*4882a593Smuzhiyun 					value, NULL, 0, timeout);
158*4882a593Smuzhiyun }
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun /**
161*4882a593Smuzhiyun  * rt2x00usb_eeprom_read - Read eeprom from device
162*4882a593Smuzhiyun  * @rt2x00dev: Pointer to &struct rt2x00_dev
163*4882a593Smuzhiyun  * @eeprom: Pointer to eeprom array to store the information in
164*4882a593Smuzhiyun  * @length: Number of bytes to read from the eeprom
165*4882a593Smuzhiyun  *
166*4882a593Smuzhiyun  * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
167*4882a593Smuzhiyun  * from the device. Note that the eeprom argument _must_ be allocated using
168*4882a593Smuzhiyun  * kmalloc for correct handling inside the kernel USB layer.
169*4882a593Smuzhiyun  */
rt2x00usb_eeprom_read(struct rt2x00_dev * rt2x00dev,__le16 * eeprom,const u16 length)170*4882a593Smuzhiyun static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
171*4882a593Smuzhiyun 					__le16 *eeprom, const u16 length)
172*4882a593Smuzhiyun {
173*4882a593Smuzhiyun 	return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
174*4882a593Smuzhiyun 					USB_VENDOR_REQUEST_IN, 0, 0,
175*4882a593Smuzhiyun 					eeprom, length, EEPROM_TIMEOUT);
176*4882a593Smuzhiyun }
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun /**
179*4882a593Smuzhiyun  * rt2x00usb_register_read - Read 32bit register word
180*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
181*4882a593Smuzhiyun  * @offset: Register offset
182*4882a593Smuzhiyun  *
183*4882a593Smuzhiyun  * This function is a simple wrapper for 32bit register access
184*4882a593Smuzhiyun  * through rt2x00usb_vendor_request_buff().
185*4882a593Smuzhiyun  */
rt2x00usb_register_read(struct rt2x00_dev * rt2x00dev,const unsigned int offset)186*4882a593Smuzhiyun static inline u32 rt2x00usb_register_read(struct rt2x00_dev *rt2x00dev,
187*4882a593Smuzhiyun 					  const unsigned int offset)
188*4882a593Smuzhiyun {
189*4882a593Smuzhiyun 	__le32 reg = 0;
190*4882a593Smuzhiyun 	rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
191*4882a593Smuzhiyun 				      USB_VENDOR_REQUEST_IN, offset,
192*4882a593Smuzhiyun 				      &reg, sizeof(reg));
193*4882a593Smuzhiyun 	return le32_to_cpu(reg);
194*4882a593Smuzhiyun }
195*4882a593Smuzhiyun 
196*4882a593Smuzhiyun /**
197*4882a593Smuzhiyun  * rt2x00usb_register_read_lock - Read 32bit register word
198*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
199*4882a593Smuzhiyun  * @offset: Register offset
200*4882a593Smuzhiyun  *
201*4882a593Smuzhiyun  * This function is a simple wrapper for 32bit register access
202*4882a593Smuzhiyun  * through rt2x00usb_vendor_req_buff_lock().
203*4882a593Smuzhiyun  */
rt2x00usb_register_read_lock(struct rt2x00_dev * rt2x00dev,const unsigned int offset)204*4882a593Smuzhiyun static inline u32 rt2x00usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
205*4882a593Smuzhiyun 					       const unsigned int offset)
206*4882a593Smuzhiyun {
207*4882a593Smuzhiyun 	__le32 reg = 0;
208*4882a593Smuzhiyun 	rt2x00usb_vendor_req_buff_lock(rt2x00dev, USB_MULTI_READ,
209*4882a593Smuzhiyun 				       USB_VENDOR_REQUEST_IN, offset,
210*4882a593Smuzhiyun 				       &reg, sizeof(reg), REGISTER_TIMEOUT);
211*4882a593Smuzhiyun 	return le32_to_cpu(reg);
212*4882a593Smuzhiyun }
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun /**
215*4882a593Smuzhiyun  * rt2x00usb_register_multiread - Read 32bit register words
216*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
217*4882a593Smuzhiyun  * @offset: Register offset
218*4882a593Smuzhiyun  * @value: Pointer to where register contents should be stored
219*4882a593Smuzhiyun  * @length: Length of the data
220*4882a593Smuzhiyun  *
221*4882a593Smuzhiyun  * This function is a simple wrapper for 32bit register access
222*4882a593Smuzhiyun  * through rt2x00usb_vendor_request_buff().
223*4882a593Smuzhiyun  */
rt2x00usb_register_multiread(struct rt2x00_dev * rt2x00dev,const unsigned int offset,void * value,const u32 length)224*4882a593Smuzhiyun static inline void rt2x00usb_register_multiread(struct rt2x00_dev *rt2x00dev,
225*4882a593Smuzhiyun 						const unsigned int offset,
226*4882a593Smuzhiyun 						void *value, const u32 length)
227*4882a593Smuzhiyun {
228*4882a593Smuzhiyun 	rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
229*4882a593Smuzhiyun 				      USB_VENDOR_REQUEST_IN, offset,
230*4882a593Smuzhiyun 				      value, length);
231*4882a593Smuzhiyun }
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun /**
234*4882a593Smuzhiyun  * rt2x00usb_register_write - Write 32bit register word
235*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
236*4882a593Smuzhiyun  * @offset: Register offset
237*4882a593Smuzhiyun  * @value: Data which should be written
238*4882a593Smuzhiyun  *
239*4882a593Smuzhiyun  * This function is a simple wrapper for 32bit register access
240*4882a593Smuzhiyun  * through rt2x00usb_vendor_request_buff().
241*4882a593Smuzhiyun  */
rt2x00usb_register_write(struct rt2x00_dev * rt2x00dev,const unsigned int offset,u32 value)242*4882a593Smuzhiyun static inline void rt2x00usb_register_write(struct rt2x00_dev *rt2x00dev,
243*4882a593Smuzhiyun 					    const unsigned int offset,
244*4882a593Smuzhiyun 					    u32 value)
245*4882a593Smuzhiyun {
246*4882a593Smuzhiyun 	__le32 reg = cpu_to_le32(value);
247*4882a593Smuzhiyun 	rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
248*4882a593Smuzhiyun 				      USB_VENDOR_REQUEST_OUT, offset,
249*4882a593Smuzhiyun 				      &reg, sizeof(reg));
250*4882a593Smuzhiyun }
251*4882a593Smuzhiyun 
252*4882a593Smuzhiyun /**
253*4882a593Smuzhiyun  * rt2x00usb_register_write_lock - Write 32bit register word
254*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
255*4882a593Smuzhiyun  * @offset: Register offset
256*4882a593Smuzhiyun  * @value: Data which should be written
257*4882a593Smuzhiyun  *
258*4882a593Smuzhiyun  * This function is a simple wrapper for 32bit register access
259*4882a593Smuzhiyun  * through rt2x00usb_vendor_req_buff_lock().
260*4882a593Smuzhiyun  */
rt2x00usb_register_write_lock(struct rt2x00_dev * rt2x00dev,const unsigned int offset,u32 value)261*4882a593Smuzhiyun static inline void rt2x00usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
262*4882a593Smuzhiyun 						 const unsigned int offset,
263*4882a593Smuzhiyun 						 u32 value)
264*4882a593Smuzhiyun {
265*4882a593Smuzhiyun 	__le32 reg = cpu_to_le32(value);
266*4882a593Smuzhiyun 	rt2x00usb_vendor_req_buff_lock(rt2x00dev, USB_MULTI_WRITE,
267*4882a593Smuzhiyun 				       USB_VENDOR_REQUEST_OUT, offset,
268*4882a593Smuzhiyun 				       &reg, sizeof(reg), REGISTER_TIMEOUT);
269*4882a593Smuzhiyun }
270*4882a593Smuzhiyun 
271*4882a593Smuzhiyun /**
272*4882a593Smuzhiyun  * rt2x00usb_register_multiwrite - Write 32bit register words
273*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
274*4882a593Smuzhiyun  * @offset: Register offset
275*4882a593Smuzhiyun  * @value: Data which should be written
276*4882a593Smuzhiyun  * @length: Length of the data
277*4882a593Smuzhiyun  *
278*4882a593Smuzhiyun  * This function is a simple wrapper for 32bit register access
279*4882a593Smuzhiyun  * through rt2x00usb_vendor_request_buff().
280*4882a593Smuzhiyun  */
rt2x00usb_register_multiwrite(struct rt2x00_dev * rt2x00dev,const unsigned int offset,const void * value,const u32 length)281*4882a593Smuzhiyun static inline void rt2x00usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
282*4882a593Smuzhiyun 						 const unsigned int offset,
283*4882a593Smuzhiyun 						 const void *value,
284*4882a593Smuzhiyun 						 const u32 length)
285*4882a593Smuzhiyun {
286*4882a593Smuzhiyun 	rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
287*4882a593Smuzhiyun 				      USB_VENDOR_REQUEST_OUT, offset,
288*4882a593Smuzhiyun 				      (void *)value, length);
289*4882a593Smuzhiyun }
290*4882a593Smuzhiyun 
291*4882a593Smuzhiyun /**
292*4882a593Smuzhiyun  * rt2x00usb_regbusy_read - Read from register with busy check
293*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
294*4882a593Smuzhiyun  * @offset: Register offset
295*4882a593Smuzhiyun  * @field: Field to check if register is busy
296*4882a593Smuzhiyun  * @reg: Pointer to where register contents should be stored
297*4882a593Smuzhiyun  *
298*4882a593Smuzhiyun  * This function will read the given register, and checks if the
299*4882a593Smuzhiyun  * register is busy. If it is, it will sleep for a couple of
300*4882a593Smuzhiyun  * microseconds before reading the register again. If the register
301*4882a593Smuzhiyun  * is not read after a certain timeout, this function will return
302*4882a593Smuzhiyun  * FALSE.
303*4882a593Smuzhiyun  */
304*4882a593Smuzhiyun int rt2x00usb_regbusy_read(struct rt2x00_dev *rt2x00dev,
305*4882a593Smuzhiyun 			   const unsigned int offset,
306*4882a593Smuzhiyun 			   const struct rt2x00_field32 field,
307*4882a593Smuzhiyun 			   u32 *reg);
308*4882a593Smuzhiyun 
309*4882a593Smuzhiyun /**
310*4882a593Smuzhiyun  * rt2x00usb_register_read_async - Asynchronously read 32bit register word
311*4882a593Smuzhiyun  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
312*4882a593Smuzhiyun  * @offset: Register offset
313*4882a593Smuzhiyun  * @callback: Functon to call when read completes.
314*4882a593Smuzhiyun  *
315*4882a593Smuzhiyun  * Submit a control URB to read a 32bit register. This safe to
316*4882a593Smuzhiyun  * be called from atomic context.  The callback will be called
317*4882a593Smuzhiyun  * when the URB completes. Otherwise the function is similar
318*4882a593Smuzhiyun  * to rt2x00usb_register_read().
319*4882a593Smuzhiyun  * When the callback function returns false, the memory will be cleaned up,
320*4882a593Smuzhiyun  * when it returns true, the urb will be fired again.
321*4882a593Smuzhiyun  */
322*4882a593Smuzhiyun void rt2x00usb_register_read_async(struct rt2x00_dev *rt2x00dev,
323*4882a593Smuzhiyun 				   const unsigned int offset,
324*4882a593Smuzhiyun 				   bool (*callback)(struct rt2x00_dev*, int, u32));
325*4882a593Smuzhiyun 
326*4882a593Smuzhiyun /*
327*4882a593Smuzhiyun  * Radio handlers
328*4882a593Smuzhiyun  */
329*4882a593Smuzhiyun void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
330*4882a593Smuzhiyun 
331*4882a593Smuzhiyun /**
332*4882a593Smuzhiyun  * struct queue_entry_priv_usb: Per entry USB specific information
333*4882a593Smuzhiyun  *
334*4882a593Smuzhiyun  * @urb: Urb structure used for device communication.
335*4882a593Smuzhiyun  */
336*4882a593Smuzhiyun struct queue_entry_priv_usb {
337*4882a593Smuzhiyun 	struct urb *urb;
338*4882a593Smuzhiyun };
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun /**
341*4882a593Smuzhiyun  * struct queue_entry_priv_usb_bcn: Per TX entry USB specific information
342*4882a593Smuzhiyun  *
343*4882a593Smuzhiyun  * The first section should match &struct queue_entry_priv_usb exactly.
344*4882a593Smuzhiyun  * rt2500usb can use this structure to send a guardian byte when working
345*4882a593Smuzhiyun  * with beacons.
346*4882a593Smuzhiyun  *
347*4882a593Smuzhiyun  * @urb: Urb structure used for device communication.
348*4882a593Smuzhiyun  * @guardian_data: Set to 0, used for sending the guardian data.
349*4882a593Smuzhiyun  * @guardian_urb: Urb structure used to send the guardian data.
350*4882a593Smuzhiyun  */
351*4882a593Smuzhiyun struct queue_entry_priv_usb_bcn {
352*4882a593Smuzhiyun 	struct urb *urb;
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun 	unsigned int guardian_data;
355*4882a593Smuzhiyun 	struct urb *guardian_urb;
356*4882a593Smuzhiyun };
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun /**
359*4882a593Smuzhiyun  * rt2x00usb_kick_queue - Kick data queue
360*4882a593Smuzhiyun  * @queue: Data queue to kick
361*4882a593Smuzhiyun  *
362*4882a593Smuzhiyun  * This will walk through all entries of the queue and push all pending
363*4882a593Smuzhiyun  * frames to the hardware as a single burst.
364*4882a593Smuzhiyun  */
365*4882a593Smuzhiyun void rt2x00usb_kick_queue(struct data_queue *queue);
366*4882a593Smuzhiyun 
367*4882a593Smuzhiyun /**
368*4882a593Smuzhiyun  * rt2x00usb_flush_queue - Flush data queue
369*4882a593Smuzhiyun  * @queue: Data queue to stop
370*4882a593Smuzhiyun  * @drop: True to drop all pending frames.
371*4882a593Smuzhiyun  *
372*4882a593Smuzhiyun  * This will walk through all entries of the queue and will optionally
373*4882a593Smuzhiyun  * kill all URB's which were send to the device, or at least wait until
374*4882a593Smuzhiyun  * they have been returned from the device..
375*4882a593Smuzhiyun  */
376*4882a593Smuzhiyun void rt2x00usb_flush_queue(struct data_queue *queue, bool drop);
377*4882a593Smuzhiyun 
378*4882a593Smuzhiyun /**
379*4882a593Smuzhiyun  * rt2x00usb_watchdog - Watchdog for USB communication
380*4882a593Smuzhiyun  * @rt2x00dev: Pointer to &struct rt2x00_dev
381*4882a593Smuzhiyun  *
382*4882a593Smuzhiyun  * Check the health of the USB communication and determine
383*4882a593Smuzhiyun  * if timeouts have occurred. If this is the case, this function
384*4882a593Smuzhiyun  * will reset all communication to restore functionality again.
385*4882a593Smuzhiyun  */
386*4882a593Smuzhiyun void rt2x00usb_watchdog(struct rt2x00_dev *rt2x00dev);
387*4882a593Smuzhiyun 
388*4882a593Smuzhiyun /*
389*4882a593Smuzhiyun  * Device initialization handlers.
390*4882a593Smuzhiyun  */
391*4882a593Smuzhiyun void rt2x00usb_clear_entry(struct queue_entry *entry);
392*4882a593Smuzhiyun int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev);
393*4882a593Smuzhiyun void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev);
394*4882a593Smuzhiyun 
395*4882a593Smuzhiyun /*
396*4882a593Smuzhiyun  * USB driver handlers.
397*4882a593Smuzhiyun  */
398*4882a593Smuzhiyun int rt2x00usb_probe(struct usb_interface *usb_intf,
399*4882a593Smuzhiyun 		    const struct rt2x00_ops *ops);
400*4882a593Smuzhiyun void rt2x00usb_disconnect(struct usb_interface *usb_intf);
401*4882a593Smuzhiyun #ifdef CONFIG_PM
402*4882a593Smuzhiyun int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state);
403*4882a593Smuzhiyun int rt2x00usb_resume(struct usb_interface *usb_intf);
404*4882a593Smuzhiyun #else
405*4882a593Smuzhiyun #define rt2x00usb_suspend	NULL
406*4882a593Smuzhiyun #define rt2x00usb_resume	NULL
407*4882a593Smuzhiyun #endif /* CONFIG_PM */
408*4882a593Smuzhiyun 
409*4882a593Smuzhiyun #endif /* RT2X00USB_H */
410