iwlwifi: A-MPDU Tx activation by load measures
[linux-2.6/btrfs-unstable.git] / drivers / net / wireless / rt2x00 / rt2x00usb.h
blobe40df4050cd07ba116a2f86e94784bb6db76afcc
1 /*
2 Copyright (C) 2004 - 2007 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.
22 Module: rt2x00usb
23 Abstract: Data structures for the rt2x00usb module.
26 #ifndef RT2X00USB_H
27 #define RT2X00USB_H
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)
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.
45 #define REGISTER_BUSY_COUNT 5
46 #define REGISTER_BUSY_DELAY 100
47 #define REGISTER_TIMEOUT 500
48 #define REGISTER_TIMEOUT_FIRMWARE 1000
51 * Cache size
53 #define CSR_CACHE_SIZE 8
54 #define CSR_CACHE_SIZE_FIRMWARE 64
57 * USB request types.
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 * USB vendor commands.
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
77 * Device modes offset
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 */
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.
94 int rt2x00usb_vendor_request(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 const int timeout);
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.
110 int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
111 const u8 request, const u8 requesttype,
112 const u16 offset, void *buffer,
113 const u16 buffer_length, const int timeout);
116 * A version of rt2x00usb_vendor_request_buff which must be called
117 * if the usb_cache_mutex is already held. */
118 int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev,
119 const u8 request, const u8 requesttype,
120 const u16 offset, void *buffer,
121 const u16 buffer_length, const int timeout);
124 * Simple wrapper around rt2x00usb_vendor_request to write a single
125 * command to the device. Since we don't use the buffer argument we
126 * don't have to worry about kmalloc here.
128 static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev *rt2x00dev,
129 const u8 request,
130 const u16 offset,
131 const u16 value,
132 const int timeout)
134 return rt2x00usb_vendor_request(rt2x00dev, request,
135 USB_VENDOR_REQUEST_OUT, offset,
136 value, NULL, 0, timeout);
140 * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
141 * from the device. Note that the eeprom argument _must_ be allocated using
142 * kmalloc for correct handling inside the kernel USB layer.
144 static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
145 __le16 *eeprom, const u16 lenght)
147 int timeout = REGISTER_TIMEOUT * (lenght / sizeof(u16));
149 return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
150 USB_VENDOR_REQUEST_IN, 0x0000,
151 0x0000, eeprom, lenght, timeout);
155 * Radio handlers
157 void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
160 * TX data handlers.
162 int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
163 struct data_ring *ring, struct sk_buff *skb,
164 struct ieee80211_tx_control *control);
167 * Device initialization handlers.
169 void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev,
170 struct data_entry *entry);
171 void rt2x00usb_init_txentry(struct rt2x00_dev *rt2x00dev,
172 struct data_entry *entry);
173 int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev);
174 void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev);
177 * USB driver handlers.
179 int rt2x00usb_probe(struct usb_interface *usb_intf,
180 const struct usb_device_id *id);
181 void rt2x00usb_disconnect(struct usb_interface *usb_intf);
182 #ifdef CONFIG_PM
183 int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state);
184 int rt2x00usb_resume(struct usb_interface *usb_intf);
185 #else
186 #define rt2x00usb_suspend NULL
187 #define rt2x00usb_resume NULL
188 #endif /* CONFIG_PM */
190 #endif /* RT2X00USB_H */