aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00usb.h
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-02-03 09:54:11 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:37:00 -0500
commit3b640f21af4b6b36b546fecbd3fe5109981360da (patch)
tree5fce049b149283f8864d60b5b265a12b08827b3f /drivers/net/wireless/rt2x00/rt2x00usb.h
parenta9450b70a755abf093600035ef5361c53343fe9a (diff)
rt2x00: Enable LED class support for rt2500usb/rt73usb
Add kerneldoc for vendor request functions in rt2x00usb. Add asynchroneous vendor request function in rt2x00usb. With the availability of the asynchroneuous vendor request we can now enable LED class support for rt2500usb and rt73usb. Since LED handling is not important, it doesn't really matter if a register call fails (This solution is better then no LED class support at all). Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00usb.h')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.h129
1 files changed, 95 insertions, 34 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
index af606638e227..275b089a2a4d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.h
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -60,34 +60,47 @@
60#define USB_VENDOR_REQUEST_IN ( USB_DIR_IN | USB_VENDOR_REQUEST ) 60#define USB_VENDOR_REQUEST_IN ( USB_DIR_IN | USB_VENDOR_REQUEST )
61#define USB_VENDOR_REQUEST_OUT ( USB_DIR_OUT | USB_VENDOR_REQUEST ) 61#define USB_VENDOR_REQUEST_OUT ( USB_DIR_OUT | USB_VENDOR_REQUEST )
62 62
63/* 63/**
64 * USB vendor commands. 64 * enum rt2x00usb_vendor_request: USB vendor commands.
65 */ 65 */
66#define USB_DEVICE_MODE 0x01 66enum rt2x00usb_vendor_request {
67#define USB_SINGLE_WRITE 0x02 67 USB_DEVICE_MODE = 1,
68#define USB_SINGLE_READ 0x03 68 USB_SINGLE_WRITE = 2,
69#define USB_MULTI_WRITE 0x06 69 USB_SINGLE_READ = 3,
70#define USB_MULTI_READ 0x07 70 USB_MULTI_WRITE = 6,
71#define USB_EEPROM_WRITE 0x08 71 USB_MULTI_READ = 7,
72#define USB_EEPROM_READ 0x09 72 USB_EEPROM_WRITE = 8,
73#define USB_LED_CONTROL 0x0a /* RT73USB */ 73 USB_EEPROM_READ = 9,
74#define USB_RX_CONTROL 0x0c 74 USB_LED_CONTROL = 10, /* RT73USB */
75 USB_RX_CONTROL = 12,
76};
75 77
76/* 78/**
77 * Device modes offset 79 * enum rt2x00usb_mode_offset: Device modes offset.
78 */ 80 */
79#define USB_MODE_RESET 0x01 81enum rt2x00usb_mode_offset {
80#define USB_MODE_UNPLUG 0x02 82 USB_MODE_RESET = 1,
81#define USB_MODE_FUNCTION 0x03 83 USB_MODE_UNPLUG = 2,
82#define USB_MODE_TEST 0x04 84 USB_MODE_FUNCTION = 3,
83#define USB_MODE_SLEEP 0x07 /* RT73USB */ 85 USB_MODE_TEST = 4,
84#define USB_MODE_FIRMWARE 0x08 /* RT73USB */ 86 USB_MODE_SLEEP = 7, /* RT73USB */
85#define USB_MODE_WAKEUP 0x09 /* RT73USB */ 87 USB_MODE_FIRMWARE = 8, /* RT73USB */
88 USB_MODE_WAKEUP = 9, /* RT73USB */
89};
86 90
87/* 91/**
88 * Used to read/write from/to the device. 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
101 *
89 * This is the main function to communicate with the device, 102 * This is the main function to communicate with the device,
90 * the buffer argument _must_ either be NULL or point to 103 * the &buffer argument _must_ either be NULL or point to
91 * a buffer allocated by kmalloc. Failure to do so can lead 104 * a buffer allocated by kmalloc. Failure to do so can lead
92 * to unexpected behavior depending on the architecture. 105 * to unexpected behavior depending on the architecture.
93 */ 106 */
@@ -97,13 +110,21 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
97 void *buffer, const u16 buffer_length, 110 void *buffer, const u16 buffer_length,
98 const int timeout); 111 const int timeout);
99 112
100/* 113/**
101 * Used to read/write from/to the device. 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
122 *
102 * This function will use a previously with kmalloc allocated cache 123 * This function will use a previously with kmalloc allocated cache
103 * to communicate with the device. The contents of the buffer pointer 124 * to communicate with the device. The contents of the buffer pointer
104 * will be copied to this cache when writing, or read from the cache 125 * will be copied to this cache when writing, or read from the cache
105 * when reading. 126 * when reading.
106 * Buffers send to rt2x00usb_vendor_request _must_ be allocated with 127 * Buffers send to &rt2x00usb_vendor_request _must_ be allocated with
107 * kmalloc. Hence the reason for using a previously allocated cache 128 * kmalloc. Hence the reason for using a previously allocated cache
108 * which has been allocated properly. 129 * which has been allocated properly.
109 */ 130 */
@@ -112,15 +133,32 @@ int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
112 const u16 offset, void *buffer, 133 const u16 offset, void *buffer,
113 const u16 buffer_length, const int timeout); 134 const u16 buffer_length, const int timeout);
114 135
115/* 136/**
116 * A version of rt2x00usb_vendor_request_buff which must be called 137 * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
117 * if the usb_cache_mutex is already held. */ 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
145 *
146 * A version of &rt2x00usb_vendor_request_buff which must be called
147 * if the usb_cache_mutex is already held.
148 */
118int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev, 149int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev,
119 const u8 request, const u8 requesttype, 150 const u8 request, const u8 requesttype,
120 const u16 offset, void *buffer, 151 const u16 offset, void *buffer,
121 const u16 buffer_length, const int timeout); 152 const u16 buffer_length, const int timeout);
122 153
123/* 154/**
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
161 *
124 * Simple wrapper around rt2x00usb_vendor_request to write a single 162 * Simple wrapper around rt2x00usb_vendor_request to write a single
125 * command to the device. Since we don't use the buffer argument we 163 * command to the device. Since we don't use the buffer argument we
126 * don't have to worry about kmalloc here. 164 * don't have to worry about kmalloc here.
@@ -136,7 +174,12 @@ static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev *rt2x00dev,
136 value, NULL, 0, timeout); 174 value, NULL, 0, timeout);
137} 175}
138 176
139/* 177/**
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
182 *
140 * Simple wrapper around rt2x00usb_vendor_request to read the eeprom 183 * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
141 * from the device. Note that the eeprom argument _must_ be allocated using 184 * from the device. Note that the eeprom argument _must_ be allocated using
142 * kmalloc for correct handling inside the kernel USB layer. 185 * kmalloc for correct handling inside the kernel USB layer.
@@ -147,10 +190,28 @@ static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
147 int timeout = REGISTER_TIMEOUT * (lenght / sizeof(u16)); 190 int timeout = REGISTER_TIMEOUT * (lenght / sizeof(u16));
148 191
149 return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ, 192 return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
150 USB_VENDOR_REQUEST_IN, 0x0000, 193 USB_VENDOR_REQUEST_IN, 0, 0,
151 0x0000, eeprom, lenght, timeout); 194 eeprom, lenght, timeout);
152} 195}
153 196
197/**
198 * rt2x00usb_vendor_request_async - Send register command to device (async)
199 * @rt2x00dev: Pointer to &struct rt2x00_dev
200 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
201 * @offset: Register offset to perform action on
202 * @value: Value to write to device
203 *
204 * Asynchroneous version of &rt2x00usb_vendor_request this is required
205 * for some routines where the driver cannot sleep because it is in
206 * irq context. Note that with this function the driver will not be
207 * notified on failure or timeout of the command. It will only be notified
208 * if the start of the command succeeded or not. This means it should not be
209 * used when the command must succeed.
210 */
211int rt2x00usb_vendor_request_async(struct rt2x00_dev *rt2x00dev,
212 const u8 request, const u16 offset,
213 const u16 value);
214
154/* 215/*
155 * Radio handlers 216 * Radio handlers
156 */ 217 */