Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
zd_usb.h
Go to the documentation of this file.
1 /* ZD1211 USB-WLAN driver for Linux
2  *
3  * Copyright (C) 2005-2007 Ulrich Kunitz <[email protected]>
4  * Copyright (C) 2006-2007 Daniel Drake <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef _ZD_USB_H
22 #define _ZD_USB_H
23 
24 #include <linux/completion.h>
25 #include <linux/netdevice.h>
26 #include <linux/spinlock.h>
27 #include <linux/skbuff.h>
28 #include <linux/usb.h>
29 
30 #include "zd_def.h"
31 
32 #define ZD_USB_TX_HIGH 5
33 #define ZD_USB_TX_LOW 2
34 
35 #define ZD_TX_TIMEOUT (HZ * 5)
36 #define ZD_TX_WATCHDOG_INTERVAL round_jiffies_relative(HZ)
37 #define ZD_RX_IDLE_INTERVAL round_jiffies_relative(30 * HZ)
38 
39 enum devicetype {
43 };
44 
45 enum endpoints {
46  EP_CTRL = 0,
49  EP_INT_IN = 3,
51 };
52 
53 enum {
54  USB_MAX_TRANSFER_SIZE = 4096, /* bytes */
55  /* FIXME: The original driver uses this value. We have to check,
56  * whether the MAX_TRANSFER_SIZE is sufficient and this needs only be
57  * used if one combined frame is split over two USB transactions.
58  */
59  USB_MAX_RX_SIZE = 4800, /* bytes */
68 };
69 
75  USB_REQ_EEPROM_START = 0x0128, /* ? request is a byte */
77  USB_REQ_EEPROM_END = 0x0228, /* ? request is a byte */
81 };
82 
86 } __packed;
87 
88 struct reg_data {
91 } __packed;
92 
95  struct reg_data reg_writes[0];
96 } __packed;
97 
98 enum {
99  RF_IF_LE = 0x02,
100  RF_CLK = 0x04,
101  RF_DATA = 0x08,
102 };
103 
107  /* 1: 3683a */
108  /* 2: other (default) */
110  /* RF2595: 24 */
112  /* (ZD_CR203 & ~(RF_IF_LE | RF_CLK | RF_DATA)) | (bit ? RF_DATA : 0) */
113 } __packed;
114 
115 /* USB interrupt */
116 
118  USB_INT_TYPE = 0x01,
121 };
122 
125 };
126 
128  u8 type; /* must always be 1 */
130 } __packed;
131 
132 struct usb_int_regs {
134  struct reg_data regs[0];
135 } __packed;
136 
143 } __packed;
144 
148  unsigned int req_count;
149  /* Stores the USB int structure and contains the USB address of the
150  * first requested register before request.
151  */
153  int length;
155 };
156 
157 struct zd_ioreq16 {
160 };
161 
162 struct zd_ioreq32 {
165 };
166 
170  struct urb *urb;
171  void *buffer;
173  int interval;
176 };
177 
178 static inline struct usb_int_regs *get_read_regs(struct zd_usb_interrupt *intr)
179 {
180  return (struct usb_int_regs *)intr->read_regs.buffer;
181 }
182 
183 #define RX_URBS_COUNT 5
184 
185 struct zd_usb_rx {
191  unsigned int fragment_length;
192  unsigned int usb_packet_size;
193  struct urb **urbs;
195 };
196 
206 struct zd_usb_tx {
211  struct usb_anchor submitted;
214 };
215 
216 /* Contains the usb parts. The structure doesn't require a lock because intf
217  * will not be changed after initialization.
218  */
219 struct zd_usb {
221  struct zd_usb_rx rx;
222  struct zd_usb_tx tx;
224  struct usb_anchor submitted_cmds;
227  u8 req_buf[64]; /* zd_usb_iowrite16v needs 62 bytes */
229 };
230 
231 #define zd_usb_dev(usb) (&usb->intf->dev)
232 
233 static inline struct usb_device *zd_usb_to_usbdev(struct zd_usb *usb)
234 {
235  return interface_to_usbdev(usb->intf);
236 }
237 
238 static inline struct ieee80211_hw *zd_intf_to_hw(struct usb_interface *intf)
239 {
240  return usb_get_intfdata(intf);
241 }
242 
243 static inline struct ieee80211_hw *zd_usb_to_hw(struct zd_usb *usb)
244 {
245  return zd_intf_to_hw(usb->intf);
246 }
247 
248 void zd_usb_init(struct zd_usb *usb, struct ieee80211_hw *hw,
249  struct usb_interface *intf);
250 int zd_usb_init_hw(struct zd_usb *usb);
251 void zd_usb_clear(struct zd_usb *usb);
252 
253 int zd_usb_scnprint_id(struct zd_usb *usb, char *buffer, size_t size);
254 
255 void zd_tx_watchdog_enable(struct zd_usb *usb);
256 void zd_tx_watchdog_disable(struct zd_usb *usb);
257 
258 int zd_usb_enable_int(struct zd_usb *usb);
259 void zd_usb_disable_int(struct zd_usb *usb);
260 
261 int zd_usb_enable_rx(struct zd_usb *usb);
262 void zd_usb_disable_rx(struct zd_usb *usb);
263 
265 
266 void zd_usb_enable_tx(struct zd_usb *usb);
267 void zd_usb_disable_tx(struct zd_usb *usb);
268 
269 int zd_usb_tx(struct zd_usb *usb, struct sk_buff *skb);
270 
271 int zd_usb_ioread16v(struct zd_usb *usb, u16 *values,
272  const zd_addr_t *addresses, unsigned int count);
273 
274 static inline int zd_usb_ioread16(struct zd_usb *usb, u16 *value,
275  const zd_addr_t addr)
276 {
277  return zd_usb_ioread16v(usb, value, &addr, 1);
278 }
279 
281 int zd_usb_iowrite16v_async_end(struct zd_usb *usb, unsigned int timeout);
282 int zd_usb_iowrite16v_async(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
283  unsigned int count);
284 int zd_usb_iowrite16v(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
285  unsigned int count);
286 
287 int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits);
288 
289 int zd_usb_read_fw(struct zd_usb *usb, zd_addr_t addr, u8 *data, u16 len);
290 
291 extern struct workqueue_struct *zd_workqueue;
292 
293 #endif /* _ZD_USB_H */