myri10ge: match number of save_state and restore
[linux-2.6/zen-sources.git] / drivers / usb / net / cdc_subset.c
blobe2fae85851a3e654117f61308866ad888654d150
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/module.h>
21 #include <linux/kmod.h>
22 #include <linux/sched.h>
23 #include <linux/init.h>
24 #include <linux/netdevice.h>
25 #include <linux/etherdevice.h>
26 #include <linux/ethtool.h>
27 #include <linux/workqueue.h>
28 #include <linux/mii.h>
29 #include <linux/usb.h>
31 #include "usbnet.h"
35 * This supports simple USB network links that don't require any special
36 * framing or hardware control operations. The protocol used here is a
37 * strict subset of CDC Ethernet, with three basic differences reflecting
38 * the goal that almost any hardware should run it:
40 * - Minimal runtime control: one interface, no altsettings, and
41 * no vendor or class specific control requests. If a device is
42 * configured, it is allowed to exchange packets with the host.
43 * Fancier models would mean not working on some hardware.
45 * - Minimal manufacturing control: no IEEE "Organizationally
46 * Unique ID" required, or an EEPROMs to store one. Each host uses
47 * one random "locally assigned" Ethernet address instead, which can
48 * of course be overridden using standard tools like "ifconfig".
49 * (With 2^46 such addresses, same-net collisions are quite rare.)
51 * - There is no additional framing data for USB. Packets are written
52 * exactly as in CDC Ethernet, starting with an Ethernet header and
53 * terminated by a short packet. However, the host will never send a
54 * zero length packet; some systems can't handle those robustly.
56 * Anything that can transmit and receive USB bulk packets can implement
57 * this protocol. That includes both smart peripherals and quite a lot
58 * of "host-to-host" USB cables (which embed two devices back-to-back).
60 * Note that although Linux may use many of those host-to-host links
61 * with this "cdc_subset" framing, that doesn't mean there may not be a
62 * better approach. Handling the "other end unplugs/replugs" scenario
63 * well tends to require chip-specific vendor requests. Also, Windows
64 * peers at the other end of host-to-host cables may expect their own
65 * framing to be used rather than this "cdc_subset" model.
68 #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX)
69 /* PDA style devices are always connected if present */
70 static int always_connected (struct usbnet *dev)
72 return 0;
74 #endif
76 #ifdef CONFIG_USB_ALI_M5632
77 #define HAVE_HARDWARE
79 /*-------------------------------------------------------------------------
81 * ALi M5632 driver ... does high speed
83 *-------------------------------------------------------------------------*/
85 static const struct driver_info ali_m5632_info = {
86 .description = "ALi M5632",
90 #endif
93 #ifdef CONFIG_USB_AN2720
94 #define HAVE_HARDWARE
96 /*-------------------------------------------------------------------------
98 * AnchorChips 2720 driver ... http://www.cypress.com
100 * This doesn't seem to have a way to detect whether the peer is
101 * connected, or need any reset handshaking. It's got pretty big
102 * internal buffers (handles most of a frame's worth of data).
103 * Chip data sheets don't describe any vendor control messages.
105 *-------------------------------------------------------------------------*/
107 static const struct driver_info an2720_info = {
108 .description = "AnchorChips/Cypress 2720",
109 // no reset available!
110 // no check_connect available!
112 .in = 2, .out = 2, // direction distinguishes these
115 #endif /* CONFIG_USB_AN2720 */
118 #ifdef CONFIG_USB_BELKIN
119 #define HAVE_HARDWARE
121 /*-------------------------------------------------------------------------
123 * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller
125 * ... also two eTEK designs, including one sold as "Advance USBNET"
127 *-------------------------------------------------------------------------*/
129 static const struct driver_info belkin_info = {
130 .description = "Belkin, eTEK, or compatible",
133 #endif /* CONFIG_USB_BELKIN */
137 #ifdef CONFIG_USB_EPSON2888
138 #define HAVE_HARDWARE
140 /*-------------------------------------------------------------------------
142 * EPSON USB clients
144 * This is the same idea as Linux PDAs (below) except the firmware in the
145 * device might not be Tux-powered. Epson provides reference firmware that
146 * implements this interface. Product developers can reuse or modify that
147 * code, such as by using their own product and vendor codes.
149 * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
151 *-------------------------------------------------------------------------*/
153 static const struct driver_info epson2888_info = {
154 .description = "Epson USB Device",
155 .check_connect = always_connected,
157 .in = 4, .out = 3,
160 #endif /* CONFIG_USB_EPSON2888 */
163 #ifdef CONFIG_USB_KC2190
164 #define HAVE_HARDWARE
165 static const struct driver_info kc2190_info = {
166 .description = "KC Technology KC-190",
168 #endif /* CONFIG_USB_KC2190 */
171 #ifdef CONFIG_USB_ARMLINUX
172 #define HAVE_HARDWARE
174 /*-------------------------------------------------------------------------
176 * Intel's SA-1100 chip integrates basic USB support, and is used
177 * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more.
178 * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to
179 * network using minimal USB framing data.
181 * This describes the driver currently in standard ARM Linux kernels.
182 * The Zaurus uses a different driver (see later).
184 * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support
185 * and different USB endpoint numbering than the SA1100 devices. The
186 * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100
187 * so we rely on the endpoint descriptors.
189 *-------------------------------------------------------------------------*/
191 static const struct driver_info linuxdev_info = {
192 .description = "Linux Device",
193 .check_connect = always_connected,
196 static const struct driver_info yopy_info = {
197 .description = "Yopy",
198 .check_connect = always_connected,
201 static const struct driver_info blob_info = {
202 .description = "Boot Loader OBject",
203 .check_connect = always_connected,
206 #endif /* CONFIG_USB_ARMLINUX */
209 /*-------------------------------------------------------------------------*/
211 #ifndef HAVE_HARDWARE
212 #error You need to configure some hardware for this driver
213 #endif
216 * chip vendor names won't normally be on the cables, and
217 * may not be on the device.
220 static const struct usb_device_id products [] = {
222 #ifdef CONFIG_USB_ALI_M5632
224 USB_DEVICE (0x0402, 0x5632), // ALi defaults
225 .driver_info = (unsigned long) &ali_m5632_info,
227 #endif
229 #ifdef CONFIG_USB_AN2720
231 USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults
232 .driver_info = (unsigned long) &an2720_info,
233 }, {
234 USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET
235 .driver_info = (unsigned long) &an2720_info,
237 #endif
239 #ifdef CONFIG_USB_BELKIN
241 USB_DEVICE (0x050d, 0x0004), // Belkin
242 .driver_info = (unsigned long) &belkin_info,
243 }, {
244 USB_DEVICE (0x056c, 0x8100), // eTEK
245 .driver_info = (unsigned long) &belkin_info,
246 }, {
247 USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK)
248 .driver_info = (unsigned long) &belkin_info,
250 #endif
252 #ifdef CONFIG_USB_EPSON2888
254 USB_DEVICE (0x0525, 0x2888), // EPSON USB client
255 .driver_info = (unsigned long) &epson2888_info,
257 #endif
259 #ifdef CONFIG_USB_KC2190
261 USB_DEVICE (0x050f, 0x0190), // KC-190
262 .driver_info = (unsigned long) &kc2190_info,
264 #endif
266 #ifdef CONFIG_USB_ARMLINUX
268 * SA-1100 using standard ARM Linux kernels, or compatible.
269 * Often used when talking to Linux PDAs (iPaq, Yopy, etc).
270 * The sa-1100 "usb-eth" driver handles the basic framing.
272 * PXA25x or PXA210 ... these use a "usb-eth" driver much like
273 * the sa1100 one, but hardware uses different endpoint numbers.
275 * Or the Linux "Ethernet" gadget on hardware that can't talk
276 * CDC Ethernet (e.g., no altsettings), in either of two modes:
277 * - acting just like the old "usb-eth" firmware, though
278 * the implementation is different
279 * - supporting RNDIS as the first/default configuration for
280 * MS-Windows interop; Linux needs to use the other config
283 // 1183 = 0x049F, both used as hex values?
284 // Compaq "Itsy" vendor/product id
285 USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible
286 .driver_info = (unsigned long) &linuxdev_info,
287 }, {
288 USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy"
289 .driver_info = (unsigned long) &yopy_info,
290 }, {
291 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
292 .driver_info = (unsigned long) &blob_info,
293 }, {
294 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config
295 // e.g. Gumstix, current OpenZaurus, ...
296 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
297 .driver_info = (unsigned long) &linuxdev_info,
299 #endif
301 { }, // END
303 MODULE_DEVICE_TABLE(usb, products);
305 /*-------------------------------------------------------------------------*/
307 static struct usb_driver cdc_subset_driver = {
308 .name = "cdc_subset",
309 .probe = usbnet_probe,
310 .suspend = usbnet_suspend,
311 .resume = usbnet_resume,
312 .disconnect = usbnet_disconnect,
313 .id_table = products,
316 static int __init cdc_subset_init(void)
318 return usb_register(&cdc_subset_driver);
320 module_init(cdc_subset_init);
322 static void __exit cdc_subset_exit(void)
324 usb_deregister(&cdc_subset_driver);
326 module_exit(cdc_subset_exit);
328 MODULE_AUTHOR("David Brownell");
329 MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links");
330 MODULE_LICENSE("GPL");