Linux 2.6.17.7
[linux/fpc-iii.git] / drivers / usb / net / cdc_subset.c
blobec801e8bb1bba093142449e956393e29f67bfe86
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 #include <linux/module.h>
22 #include <linux/kmod.h>
23 #include <linux/sched.h>
24 #include <linux/init.h>
25 #include <linux/netdevice.h>
26 #include <linux/etherdevice.h>
27 #include <linux/ethtool.h>
28 #include <linux/workqueue.h>
29 #include <linux/mii.h>
30 #include <linux/usb.h>
32 #include "usbnet.h"
36 * This supports simple USB network links that don't require any special
37 * framing or hardware control operations. The protocol used here is a
38 * strict subset of CDC Ethernet, with three basic differences reflecting
39 * the goal that almost any hardware should run it:
41 * - Minimal runtime control: one interface, no altsettings, and
42 * no vendor or class specific control requests. If a device is
43 * configured, it is allowed to exchange packets with the host.
44 * Fancier models would mean not working on some hardware.
46 * - Minimal manufacturing control: no IEEE "Organizationally
47 * Unique ID" required, or an EEPROMs to store one. Each host uses
48 * one random "locally assigned" Ethernet address instead, which can
49 * of course be overridden using standard tools like "ifconfig".
50 * (With 2^46 such addresses, same-net collisions are quite rare.)
52 * - There is no additional framing data for USB. Packets are written
53 * exactly as in CDC Ethernet, starting with an Ethernet header and
54 * terminated by a short packet. However, the host will never send a
55 * zero length packet; some systems can't handle those robustly.
57 * Anything that can transmit and receive USB bulk packets can implement
58 * this protocol. That includes both smart peripherals and quite a lot
59 * of "host-to-host" USB cables (which embed two devices back-to-back).
61 * Note that although Linux may use many of those host-to-host links
62 * with this "cdc_subset" framing, that doesn't mean there may not be a
63 * better approach. Handling the "other end unplugs/replugs" scenario
64 * well tends to require chip-specific vendor requests. Also, Windows
65 * peers at the other end of host-to-host cables may expect their own
66 * framing to be used rather than this "cdc_subset" model.
69 #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX)
70 /* PDA style devices are always connected if present */
71 static int always_connected (struct usbnet *dev)
73 return 0;
75 #endif
77 #ifdef CONFIG_USB_ALI_M5632
78 #define HAVE_HARDWARE
80 /*-------------------------------------------------------------------------
82 * ALi M5632 driver ... does high speed
84 *-------------------------------------------------------------------------*/
86 static const struct driver_info ali_m5632_info = {
87 .description = "ALi M5632",
91 #endif
94 #ifdef CONFIG_USB_AN2720
95 #define HAVE_HARDWARE
97 /*-------------------------------------------------------------------------
99 * AnchorChips 2720 driver ... http://www.cypress.com
101 * This doesn't seem to have a way to detect whether the peer is
102 * connected, or need any reset handshaking. It's got pretty big
103 * internal buffers (handles most of a frame's worth of data).
104 * Chip data sheets don't describe any vendor control messages.
106 *-------------------------------------------------------------------------*/
108 static const struct driver_info an2720_info = {
109 .description = "AnchorChips/Cypress 2720",
110 // no reset available!
111 // no check_connect available!
113 .in = 2, .out = 2, // direction distinguishes these
116 #endif /* CONFIG_USB_AN2720 */
119 #ifdef CONFIG_USB_BELKIN
120 #define HAVE_HARDWARE
122 /*-------------------------------------------------------------------------
124 * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller
126 * ... also two eTEK designs, including one sold as "Advance USBNET"
128 *-------------------------------------------------------------------------*/
130 static const struct driver_info belkin_info = {
131 .description = "Belkin, eTEK, or compatible",
134 #endif /* CONFIG_USB_BELKIN */
138 #ifdef CONFIG_USB_EPSON2888
139 #define HAVE_HARDWARE
141 /*-------------------------------------------------------------------------
143 * EPSON USB clients
145 * This is the same idea as Linux PDAs (below) except the firmware in the
146 * device might not be Tux-powered. Epson provides reference firmware that
147 * implements this interface. Product developers can reuse or modify that
148 * code, such as by using their own product and vendor codes.
150 * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
152 *-------------------------------------------------------------------------*/
154 static const struct driver_info epson2888_info = {
155 .description = "Epson USB Device",
156 .check_connect = always_connected,
158 .in = 4, .out = 3,
161 #endif /* CONFIG_USB_EPSON2888 */
164 #ifdef CONFIG_USB_KC2190
165 #define HAVE_HARDWARE
166 static const struct driver_info kc2190_info = {
167 .description = "KC Technology KC-190",
169 #endif /* CONFIG_USB_KC2190 */
172 #ifdef CONFIG_USB_ARMLINUX
173 #define HAVE_HARDWARE
175 /*-------------------------------------------------------------------------
177 * Intel's SA-1100 chip integrates basic USB support, and is used
178 * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more.
179 * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to
180 * network using minimal USB framing data.
182 * This describes the driver currently in standard ARM Linux kernels.
183 * The Zaurus uses a different driver (see later).
185 * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support
186 * and different USB endpoint numbering than the SA1100 devices. The
187 * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100
188 * so we rely on the endpoint descriptors.
190 *-------------------------------------------------------------------------*/
192 static const struct driver_info linuxdev_info = {
193 .description = "Linux Device",
194 .check_connect = always_connected,
197 static const struct driver_info yopy_info = {
198 .description = "Yopy",
199 .check_connect = always_connected,
202 static const struct driver_info blob_info = {
203 .description = "Boot Loader OBject",
204 .check_connect = always_connected,
207 #endif /* CONFIG_USB_ARMLINUX */
210 /*-------------------------------------------------------------------------*/
212 #ifndef HAVE_HARDWARE
213 #error You need to configure some hardware for this driver
214 #endif
217 * chip vendor names won't normally be on the cables, and
218 * may not be on the device.
221 static const struct usb_device_id products [] = {
223 #ifdef CONFIG_USB_ALI_M5632
225 USB_DEVICE (0x0402, 0x5632), // ALi defaults
226 .driver_info = (unsigned long) &ali_m5632_info,
228 #endif
230 #ifdef CONFIG_USB_AN2720
232 USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults
233 .driver_info = (unsigned long) &an2720_info,
234 }, {
235 USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET
236 .driver_info = (unsigned long) &an2720_info,
238 #endif
240 #ifdef CONFIG_USB_BELKIN
242 USB_DEVICE (0x050d, 0x0004), // Belkin
243 .driver_info = (unsigned long) &belkin_info,
244 }, {
245 USB_DEVICE (0x056c, 0x8100), // eTEK
246 .driver_info = (unsigned long) &belkin_info,
247 }, {
248 USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK)
249 .driver_info = (unsigned long) &belkin_info,
251 #endif
253 #ifdef CONFIG_USB_EPSON2888
255 USB_DEVICE (0x0525, 0x2888), // EPSON USB client
256 .driver_info = (unsigned long) &epson2888_info,
258 #endif
260 #ifdef CONFIG_USB_KC2190
262 USB_DEVICE (0x050f, 0x0190), // KC-190
263 .driver_info = (unsigned long) &kc2190_info,
265 #endif
267 #ifdef CONFIG_USB_ARMLINUX
269 * SA-1100 using standard ARM Linux kernels, or compatible.
270 * Often used when talking to Linux PDAs (iPaq, Yopy, etc).
271 * The sa-1100 "usb-eth" driver handles the basic framing.
273 * PXA25x or PXA210 ... these use a "usb-eth" driver much like
274 * the sa1100 one, but hardware uses different endpoint numbers.
276 * Or the Linux "Ethernet" gadget on hardware that can't talk
277 * CDC Ethernet (e.g., no altsettings), in either of two modes:
278 * - acting just like the old "usb-eth" firmware, though
279 * the implementation is different
280 * - supporting RNDIS as the first/default configuration for
281 * MS-Windows interop; Linux needs to use the other config
284 // 1183 = 0x049F, both used as hex values?
285 // Compaq "Itsy" vendor/product id
286 USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible
287 .driver_info = (unsigned long) &linuxdev_info,
288 }, {
289 USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy"
290 .driver_info = (unsigned long) &yopy_info,
291 }, {
292 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
293 .driver_info = (unsigned long) &blob_info,
294 }, {
295 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config
296 // e.g. Gumstix, current OpenZaurus, ...
297 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
298 .driver_info = (unsigned long) &linuxdev_info,
300 #endif
302 { }, // END
304 MODULE_DEVICE_TABLE(usb, products);
306 /*-------------------------------------------------------------------------*/
308 static struct usb_driver cdc_subset_driver = {
309 .name = "cdc_subset",
310 .probe = usbnet_probe,
311 .suspend = usbnet_suspend,
312 .resume = usbnet_resume,
313 .disconnect = usbnet_disconnect,
314 .id_table = products,
317 static int __init cdc_subset_init(void)
319 return usb_register(&cdc_subset_driver);
321 module_init(cdc_subset_init);
323 static void __exit cdc_subset_exit(void)
325 usb_deregister(&cdc_subset_driver);
327 module_exit(cdc_subset_exit);
329 MODULE_AUTHOR("David Brownell");
330 MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links");
331 MODULE_LICENSE("GPL");