[PATCH] Add smp_mb__after_clear_bit() to unlock_kiocb()
[linux-2.6.22.y-op.git] / drivers / usb / net / cdc_subset.c
blobf1730b685fd2c3e471e950e189edf03e39018a5e
1 /*
2 * Simple "CDC Subset" USB Networking Links
3 * Copyright (C) 2000-2005 by David Brownell
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 Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/config.h>
21 #ifdef CONFIG_USB_DEBUG
22 # define DEBUG
23 #endif
24 #include <linux/module.h>
25 #include <linux/kmod.h>
26 #include <linux/sched.h>
27 #include <linux/init.h>
28 #include <linux/netdevice.h>
29 #include <linux/etherdevice.h>
30 #include <linux/ethtool.h>
31 #include <linux/workqueue.h>
32 #include <linux/mii.h>
33 #include <linux/usb.h>
35 #include "usbnet.h"
39 * This supports simple USB network links that don't require any special
40 * framing or hardware control operations. The protocol used here is a
41 * strict subset of CDC Ethernet, with three basic differences reflecting
42 * the goal that almost any hardware should run it:
44 * - Minimal runtime control: one interface, no altsettings, and
45 * no vendor or class specific control requests. If a device is
46 * configured, it is allowed to exchange packets with the host.
47 * Fancier models would mean not working on some hardware.
49 * - Minimal manufacturing control: no IEEE "Organizationally
50 * Unique ID" required, or an EEPROMs to store one. Each host uses
51 * one random "locally assigned" Ethernet address instead, which can
52 * of course be overridden using standard tools like "ifconfig".
53 * (With 2^46 such addresses, same-net collisions are quite rare.)
55 * - There is no additional framing data for USB. Packets are written
56 * exactly as in CDC Ethernet, starting with an Ethernet header and
57 * terminated by a short packet. However, the host will never send a
58 * zero length packet; some systems can't handle those robustly.
60 * Anything that can transmit and receive USB bulk packets can implement
61 * this protocol. That includes both smart peripherals and quite a lot
62 * of "host-to-host" USB cables (which embed two devices back-to-back).
64 * Note that although Linux may use many of those host-to-host links
65 * with this "cdc_subset" framing, that doesn't mean there may not be a
66 * better approach. Handling the "other end unplugs/replugs" scenario
67 * well tends to require chip-specific vendor requests. Also, Windows
68 * peers at the other end of host-to-host cables may expect their own
69 * framing to be used rather than this "cdc_subset" model.
72 #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX)
73 /* PDA style devices are always connected if present */
74 static int always_connected (struct usbnet *dev)
76 return 0;
78 #endif
80 #ifdef CONFIG_USB_ALI_M5632
81 #define HAVE_HARDWARE
83 /*-------------------------------------------------------------------------
85 * ALi M5632 driver ... does high speed
87 *-------------------------------------------------------------------------*/
89 static const struct driver_info ali_m5632_info = {
90 .description = "ALi M5632",
94 #endif
97 #ifdef CONFIG_USB_AN2720
98 #define HAVE_HARDWARE
100 /*-------------------------------------------------------------------------
102 * AnchorChips 2720 driver ... http://www.cypress.com
104 * This doesn't seem to have a way to detect whether the peer is
105 * connected, or need any reset handshaking. It's got pretty big
106 * internal buffers (handles most of a frame's worth of data).
107 * Chip data sheets don't describe any vendor control messages.
109 *-------------------------------------------------------------------------*/
111 static const struct driver_info an2720_info = {
112 .description = "AnchorChips/Cypress 2720",
113 // no reset available!
114 // no check_connect available!
116 .in = 2, .out = 2, // direction distinguishes these
119 #endif /* CONFIG_USB_AN2720 */
122 #ifdef CONFIG_USB_BELKIN
123 #define HAVE_HARDWARE
125 /*-------------------------------------------------------------------------
127 * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller
129 * ... also two eTEK designs, including one sold as "Advance USBNET"
131 *-------------------------------------------------------------------------*/
133 static const struct driver_info belkin_info = {
134 .description = "Belkin, eTEK, or compatible",
137 #endif /* CONFIG_USB_BELKIN */
141 #ifdef CONFIG_USB_EPSON2888
142 #define HAVE_HARDWARE
144 /*-------------------------------------------------------------------------
146 * EPSON USB clients
148 * This is the same idea as Linux PDAs (below) except the firmware in the
149 * device might not be Tux-powered. Epson provides reference firmware that
150 * implements this interface. Product developers can reuse or modify that
151 * code, such as by using their own product and vendor codes.
153 * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
155 *-------------------------------------------------------------------------*/
157 static const struct driver_info epson2888_info = {
158 .description = "Epson USB Device",
159 .check_connect = always_connected,
161 .in = 4, .out = 3,
164 #endif /* CONFIG_USB_EPSON2888 */
167 #ifdef CONFIG_USB_KC2190
168 #define HAVE_HARDWARE
169 static const struct driver_info kc2190_info = {
170 .description = "KC Technology KC-190",
172 #endif /* CONFIG_USB_KC2190 */
175 #ifdef CONFIG_USB_ARMLINUX
176 #define HAVE_HARDWARE
178 /*-------------------------------------------------------------------------
180 * Intel's SA-1100 chip integrates basic USB support, and is used
181 * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more.
182 * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to
183 * network using minimal USB framing data.
185 * This describes the driver currently in standard ARM Linux kernels.
186 * The Zaurus uses a different driver (see later).
188 * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support
189 * and different USB endpoint numbering than the SA1100 devices. The
190 * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100
191 * so we rely on the endpoint descriptors.
193 *-------------------------------------------------------------------------*/
195 static const struct driver_info linuxdev_info = {
196 .description = "Linux Device",
197 .check_connect = always_connected,
200 static const struct driver_info yopy_info = {
201 .description = "Yopy",
202 .check_connect = always_connected,
205 static const struct driver_info blob_info = {
206 .description = "Boot Loader OBject",
207 .check_connect = always_connected,
210 #endif /* CONFIG_USB_ARMLINUX */
213 /*-------------------------------------------------------------------------*/
215 #ifndef HAVE_HARDWARE
216 #error You need to configure some hardware for this driver
217 #endif
220 * chip vendor names won't normally be on the cables, and
221 * may not be on the device.
224 static const struct usb_device_id products [] = {
226 #ifdef CONFIG_USB_ALI_M5632
228 USB_DEVICE (0x0402, 0x5632), // ALi defaults
229 .driver_info = (unsigned long) &ali_m5632_info,
231 #endif
233 #ifdef CONFIG_USB_AN2720
235 USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults
236 .driver_info = (unsigned long) &an2720_info,
237 }, {
238 USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET
239 .driver_info = (unsigned long) &an2720_info,
241 #endif
243 #ifdef CONFIG_USB_BELKIN
245 USB_DEVICE (0x050d, 0x0004), // Belkin
246 .driver_info = (unsigned long) &belkin_info,
247 }, {
248 USB_DEVICE (0x056c, 0x8100), // eTEK
249 .driver_info = (unsigned long) &belkin_info,
250 }, {
251 USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK)
252 .driver_info = (unsigned long) &belkin_info,
254 #endif
256 #ifdef CONFIG_USB_EPSON2888
258 USB_DEVICE (0x0525, 0x2888), // EPSON USB client
259 .driver_info = (unsigned long) &epson2888_info,
261 #endif
263 #ifdef CONFIG_USB_KC2190
265 USB_DEVICE (0x050f, 0x0190), // KC-190
266 .driver_info = (unsigned long) &kc2190_info,
268 #endif
270 #ifdef CONFIG_USB_ARMLINUX
272 * SA-1100 using standard ARM Linux kernels, or compatible.
273 * Often used when talking to Linux PDAs (iPaq, Yopy, etc).
274 * The sa-1100 "usb-eth" driver handles the basic framing.
276 * PXA25x or PXA210 ... these use a "usb-eth" driver much like
277 * the sa1100 one, but hardware uses different endpoint numbers.
279 * Or the Linux "Ethernet" gadget on hardware that can't talk
280 * CDC Ethernet (e.g., no altsettings), in either of two modes:
281 * - acting just like the old "usb-eth" firmware, though
282 * the implementation is different
283 * - supporting RNDIS as the first/default configuration for
284 * MS-Windows interop; Linux needs to use the other config
287 // 1183 = 0x049F, both used as hex values?
288 // Compaq "Itsy" vendor/product id
289 USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible
290 .driver_info = (unsigned long) &linuxdev_info,
291 }, {
292 USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy"
293 .driver_info = (unsigned long) &yopy_info,
294 }, {
295 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
296 .driver_info = (unsigned long) &blob_info,
297 }, {
298 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config
299 // e.g. Gumstix, current OpenZaurus, ...
300 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
301 .driver_info = (unsigned long) &linuxdev_info,
303 #endif
305 { }, // END
307 MODULE_DEVICE_TABLE(usb, products);
309 /*-------------------------------------------------------------------------*/
311 static struct usb_driver cdc_subset_driver = {
312 .owner = THIS_MODULE,
313 .name = "cdc_subset",
314 .probe = usbnet_probe,
315 .suspend = usbnet_suspend,
316 .resume = usbnet_resume,
317 .disconnect = usbnet_disconnect,
318 .id_table = products,
321 static int __init cdc_subset_init(void)
323 return usb_register(&cdc_subset_driver);
325 module_init(cdc_subset_init);
327 static void __exit cdc_subset_exit(void)
329 usb_deregister(&cdc_subset_driver);
331 module_exit(cdc_subset_exit);
333 MODULE_AUTHOR("David Brownell");
334 MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links");
335 MODULE_LICENSE("GPL");