aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00usb.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00usb.h')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.h180
1 files changed, 180 insertions, 0 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
new file mode 100644
index 000000000000..d4113e5158f0
--- /dev/null
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -0,0 +1,180 @@
1/*
2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
4
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.
9
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.
14
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.
19 */
20
21/*
22 Module: rt2x00usb
23 Abstract: Data structures for the rt2x00usb module.
24 */
25
26#ifndef RT2X00USB_H
27#define RT2X00USB_H
28
29/*
30 * This variable should be used with the
31 * usb_driver structure initialization.
32 */
33#define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops)
34
35/*
36 * Register defines.
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.
44 */
45#define REGISTER_BUSY_COUNT 5
46#define REGISTER_BUSY_DELAY 100
47#define REGISTER_TIMEOUT 20
48#define REGISTER_TIMEOUT_FIRMWARE 1000
49
50/*
51 * Cache size
52 */
53#define CSR_CACHE_SIZE 8
54#define CSR_CACHE_SIZE_FIRMWARE 64
55
56/*
57 * USB request types.
58 */
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 )
62
63/*
64 * USB vendor commands.
65 */
66#define USB_DEVICE_MODE 0x01
67#define USB_SINGLE_WRITE 0x02
68#define USB_SINGLE_READ 0x03
69#define USB_MULTI_WRITE 0x06
70#define USB_MULTI_READ 0x07
71#define USB_EEPROM_WRITE 0x08
72#define USB_EEPROM_READ 0x09
73#define USB_LED_CONTROL 0x0a /* RT73USB */
74#define USB_RX_CONTROL 0x0c
75
76/*
77 * Device modes offset
78 */
79#define USB_MODE_RESET 0x01
80#define USB_MODE_UNPLUG 0x02
81#define USB_MODE_FUNCTION 0x03
82#define USB_MODE_TEST 0x04
83#define USB_MODE_SLEEP 0x07 /* RT73USB */
84#define USB_MODE_FIRMWARE 0x08 /* RT73USB */
85#define USB_MODE_WAKEUP 0x09 /* RT73USB */
86
87/*
88 * Used to read/write from/to the device.
89 * This is the main function to communicate with the device,
90 * the buffer argument _must_ either be NULL or point to
91 * a buffer allocated by kmalloc. Failure to do so can lead
92 * to unexpected behavior depending on the architecture.
93 */
94int rt2x00usb_vendor_request(const struct rt2x00_dev *rt2x00dev,
95 const u8 request, const u8 requesttype,
96 const u16 offset, const u16 value,
97 void *buffer, const u16 buffer_length,
98 u16 timeout);
99
100/*
101 * Used to read/write from/to the device.
102 * This function will use a previously with kmalloc allocated cache
103 * 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
105 * when reading.
106 * Buffers send to rt2x00usb_vendor_request _must_ be allocated with
107 * kmalloc. Hence the reason for using a previously allocated cache
108 * which has been allocated properly.
109 */
110int rt2x00usb_vendor_request_buff(const struct rt2x00_dev *rt2x00dev,
111 const u8 request, const u8 requesttype,
112 const u16 offset, void *buffer,
113 const u16 buffer_length, u16 timeout);
114
115/*
116 * Simple wrapper around rt2x00usb_vendor_request to write a single
117 * command to the device. Since we don't use the buffer argument we
118 * don't have to worry about kmalloc here.
119 */
120static inline int rt2x00usb_vendor_request_sw(const struct rt2x00_dev
121 *rt2x00dev,
122 const u8 request,
123 const u16 offset,
124 const u16 value,
125 int timeout)
126{
127 return rt2x00usb_vendor_request(rt2x00dev, request,
128 USB_VENDOR_REQUEST_OUT, offset,
129 value, NULL, 0, timeout);
130}
131
132/*
133 * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
134 * from the device. Note that the eeprom argument _must_ be allocated using
135 * kmalloc for correct handling inside the kernel USB layer.
136 */
137static inline int rt2x00usb_eeprom_read(const struct rt2x00_dev *rt2x00dev,
138 __le16 *eeprom, const u16 lenght)
139{
140 int timeout = REGISTER_TIMEOUT * (lenght / sizeof(u16));
141
142 return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
143 USB_VENDOR_REQUEST_IN, 0x0000,
144 0x0000, eeprom, lenght, timeout);
145}
146
147/*
148 * Radio handlers
149 */
150void rt2x00usb_enable_radio(struct rt2x00_dev *rt2x00dev);
151void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
152
153/*
154 * TX data handlers.
155 */
156int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
157 struct data_ring *ring, struct sk_buff *skb,
158 struct ieee80211_tx_control *control);
159
160/*
161 * Device initialization handlers.
162 */
163int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev);
164void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev);
165
166/*
167 * USB driver handlers.
168 */
169int rt2x00usb_probe(struct usb_interface *usb_intf,
170 const struct usb_device_id *id);
171void rt2x00usb_disconnect(struct usb_interface *usb_intf);
172#ifdef CONFIG_PM
173int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state);
174int rt2x00usb_resume(struct usb_interface *usb_intf);
175#else
176#define rt2x00usb_suspend NULL
177#define rt2x00usb_resume NULL
178#endif /* CONFIG_PM */
179
180#endif /* RT2X00USB_H */