Add rt2x00-mac80211 snapshot (#1916)
[openwrt/svn-archive/archive.git] / package / rt2x00 / src / rt2x00usb.h
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 Supported chipsets: rt2570, rt2571W & rt2671.
25 */
26
27 #ifndef RT2X00USB_H
28 #define RT2X00USB_H
29
30 /*
31 * This variable should be used with the
32 * usb_driver structure initialization.
33 */
34 #define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops)
35
36 /*
37 * Register defines.
38 * When register access attempts should be repeated
39 * only REGISTER_BUSY_COUNT attempts with a delay
40 * of REGISTER_BUSY_DELAY us should be taken.
41 * For USB vendor requests we need to pass a timeout
42 * time in ms, for this we use the REGISTER_TIMEOUT,
43 * however when loading firmware a higher value is
44 * required. For that we use the REGISTER_TIMEOUT_FIRMWARE.
45 */
46 #define REGISTER_BUSY_COUNT 5
47 #define REGISTER_BUSY_DELAY 100
48 #define REGISTER_TIMEOUT 20
49 #define REGISTER_TIMEOUT_FIRMWARE 1000
50
51 /*
52 * USB request types.
53 */
54 #define USB_VENDOR_REQUEST ( USB_TYPE_VENDOR | USB_RECIP_DEVICE )
55 #define USB_VENDOR_REQUEST_IN ( USB_DIR_IN | USB_VENDOR_REQUEST )
56 #define USB_VENDOR_REQUEST_OUT ( USB_DIR_OUT | USB_VENDOR_REQUEST )
57
58 /*
59 * USB vendor commands.
60 */
61 #define USB_DEVICE_MODE 0x01
62 #define USB_SINGLE_WRITE 0x02
63 #define USB_SINGLE_READ 0x03
64 #define USB_MULTI_WRITE 0x06
65 #define USB_MULTI_READ 0x07
66 #define USB_EEPROM_WRITE 0x08
67 #define USB_EEPROM_READ 0x09
68 #define USB_LED_CONTROL 0x0a /* RT73USB */
69 #define USB_RX_CONTROL 0x0c
70
71 /*
72 * Device modes offset
73 */
74 #define USB_MODE_RESET 0x01
75 #define USB_MODE_UNPLUG 0x02
76 #define USB_MODE_FUNCTION 0x03
77 #define USB_MODE_TEST 0x04
78 #define USB_MODE_SLEEP 0x07 /* RT73USB */
79 #define USB_MODE_FIRMWARE 0x08 /* RT73USB */
80 #define USB_MODE_WAKEUP 0x09 /* RT73USB */
81
82 /*
83 * USB devices need an additional Beacon (guardian beacon) to be generated.
84 */
85 #undef BEACON_ENTRIES
86 #define BEACON_ENTRIES 2
87
88 /*
89 * Interfacing with the HW.
90 */
91 int rt2x00usb_vendor_request(const struct rt2x00_dev *rt2x00dev,
92 const u8 request, const u8 type, const u16 offset,
93 u32 value, void *buffer, const u16 buffer_length, const u16 timeout);
94
95 /*
96 * Radio handlers
97 */
98 void rt2x00usb_enable_radio(struct rt2x00_dev *rt2x00dev);
99 void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
100
101 /*
102 * Beacon handlers.
103 */
104 int rt2x00usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
105 struct ieee80211_tx_control *control);
106 void rt2x00usb_beacondone(struct urb *urb);
107
108 /*
109 * TX data handlers.
110 */
111 int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
112 struct data_ring *ring, struct sk_buff *skb,
113 struct ieee80211_tx_control *control);
114
115 /*
116 * Device initialization handlers.
117 */
118 int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev);
119 void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev);
120
121 /*
122 * USB driver handlers.
123 */
124 int rt2x00usb_probe(struct usb_interface *usb_intf,
125 const struct usb_device_id *id);
126 void rt2x00usb_disconnect(struct usb_interface *usb_intf);
127 #ifdef CONFIG_PM
128 int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state);
129 int rt2x00usb_resume(struct usb_interface *usb_intf);
130 #endif /* CONFIG_PM */
131
132 #endif /* RT2X00USB_H */