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, see <http://www.gnu.org/licenses/>.
19 #include <linux/module.h>
20 #include <linux/kmod.h>
21 #include <linux/init.h>
22 #include <linux/netdevice.h>
23 #include <linux/etherdevice.h>
24 #include <linux/ethtool.h>
25 #include <linux/workqueue.h>
26 #include <linux/mii.h>
27 #include <linux/usb.h>
28 #include <linux/usb/usbnet.h>
32 * This supports simple USB network links that don't require any special
33 * framing or hardware control operations. The protocol used here is a
34 * strict subset of CDC Ethernet, with three basic differences reflecting
35 * the goal that almost any hardware should run it:
37 * - Minimal runtime control: one interface, no altsettings, and
38 * no vendor or class specific control requests. If a device is
39 * configured, it is allowed to exchange packets with the host.
40 * Fancier models would mean not working on some hardware.
42 * - Minimal manufacturing control: no IEEE "Organizationally
43 * Unique ID" required, or an EEPROMs to store one. Each host uses
44 * one random "locally assigned" Ethernet address instead, which can
45 * of course be overridden using standard tools like "ifconfig".
46 * (With 2^46 such addresses, same-net collisions are quite rare.)
48 * - There is no additional framing data for USB. Packets are written
49 * exactly as in CDC Ethernet, starting with an Ethernet header and
50 * terminated by a short packet. However, the host will never send a
51 * zero length packet; some systems can't handle those robustly.
53 * Anything that can transmit and receive USB bulk packets can implement
54 * this protocol. That includes both smart peripherals and quite a lot
55 * of "host-to-host" USB cables (which embed two devices back-to-back).
57 * Note that although Linux may use many of those host-to-host links
58 * with this "cdc_subset" framing, that doesn't mean there may not be a
59 * better approach. Handling the "other end unplugs/replugs" scenario
60 * well tends to require chip-specific vendor requests. Also, Windows
61 * peers at the other end of host-to-host cables may expect their own
62 * framing to be used rather than this "cdc_subset" model.
65 #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX)
66 /* PDA style devices are always connected if present */
67 static int always_connected (struct usbnet *dev)
73 #ifdef CONFIG_USB_ALI_M5632
76 /*-------------------------------------------------------------------------
78 * ALi M5632 driver ... does high speed
80 * NOTE that the MS-Windows drivers for this chip use some funky and
81 * (naturally) undocumented 7-byte prefix to each packet, so this is a
82 * case where we don't currently interoperate. Also, once you unplug
83 * one end of the cable, you need to replug the other end too ... since
84 * chip docs are unavailable, there's no way to reset the relevant state
85 * short of a power cycle.
87 *-------------------------------------------------------------------------*/
89 static const struct driver_info ali_m5632_info = {
90 .description = "ALi M5632",
91 .flags = FLAG_POINTTOPOINT,
97 #ifdef CONFIG_USB_AN2720
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 .flags = FLAG_POINTTOPOINT,
114 // no reset available!
115 // no check_connect available!
117 .in = 2, .out = 2, // direction distinguishes these
120 #endif /* CONFIG_USB_AN2720 */
123 #ifdef CONFIG_USB_BELKIN
124 #define HAVE_HARDWARE
126 /*-------------------------------------------------------------------------
128 * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller
130 * ... also two eTEK designs, including one sold as "Advance USBNET"
132 *-------------------------------------------------------------------------*/
134 static const struct driver_info belkin_info = {
135 .description = "Belkin, eTEK, or compatible",
136 .flags = FLAG_POINTTOPOINT,
139 #endif /* CONFIG_USB_BELKIN */
143 #ifdef CONFIG_USB_EPSON2888
144 #define HAVE_HARDWARE
146 /*-------------------------------------------------------------------------
150 * This is the same idea as Linux PDAs (below) except the firmware in the
151 * device might not be Tux-powered. Epson provides reference firmware that
152 * implements this interface. Product developers can reuse or modify that
153 * code, such as by using their own product and vendor codes.
155 * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
157 *-------------------------------------------------------------------------*/
159 static const struct driver_info epson2888_info = {
160 .description = "Epson USB Device",
161 .check_connect = always_connected,
162 .flags = FLAG_POINTTOPOINT,
167 #endif /* CONFIG_USB_EPSON2888 */
170 /*-------------------------------------------------------------------------
172 * info from Jonathan McDowell <noodles@earth.li>
174 *-------------------------------------------------------------------------*/
175 #ifdef CONFIG_USB_KC2190
176 #define HAVE_HARDWARE
177 static const struct driver_info kc2190_info = {
178 .description = "KC Technology KC-190",
179 .flags = FLAG_POINTTOPOINT,
181 #endif /* CONFIG_USB_KC2190 */
184 #ifdef CONFIG_USB_ARMLINUX
185 #define HAVE_HARDWARE
187 /*-------------------------------------------------------------------------
189 * Intel's SA-1100 chip integrates basic USB support, and is used
190 * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more.
191 * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to
192 * network using minimal USB framing data.
194 * This describes the driver currently in standard ARM Linux kernels.
195 * The Zaurus uses a different driver (see later).
197 * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support
198 * and different USB endpoint numbering than the SA1100 devices. The
199 * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100
200 * so we rely on the endpoint descriptors.
202 *-------------------------------------------------------------------------*/
204 static const struct driver_info linuxdev_info = {
205 .description = "Linux Device",
206 .check_connect = always_connected,
207 .flags = FLAG_POINTTOPOINT,
210 static const struct driver_info yopy_info = {
211 .description = "Yopy",
212 .check_connect = always_connected,
213 .flags = FLAG_POINTTOPOINT,
216 static const struct driver_info blob_info = {
217 .description = "Boot Loader OBject",
218 .check_connect = always_connected,
219 .flags = FLAG_POINTTOPOINT,
222 #endif /* CONFIG_USB_ARMLINUX */
225 /*-------------------------------------------------------------------------*/
227 #ifndef HAVE_HARDWARE
228 #warning You need to configure some hardware for this driver
232 * chip vendor names won't normally be on the cables, and
233 * may not be on the device.
236 static const struct usb_device_id products [] = {
238 #ifdef CONFIG_USB_ALI_M5632
240 USB_DEVICE (0x0402, 0x5632), // ALi defaults
241 .driver_info = (unsigned long) &ali_m5632_info,
244 USB_DEVICE (0x182d,0x207c), // SiteCom CN-124
245 .driver_info = (unsigned long) &ali_m5632_info,
249 #ifdef CONFIG_USB_AN2720
251 USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults
252 .driver_info = (unsigned long) &an2720_info,
254 USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET
255 .driver_info = (unsigned long) &an2720_info,
259 #ifdef CONFIG_USB_BELKIN
261 USB_DEVICE (0x050d, 0x0004), // Belkin
262 .driver_info = (unsigned long) &belkin_info,
264 USB_DEVICE (0x056c, 0x8100), // eTEK
265 .driver_info = (unsigned long) &belkin_info,
267 USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK)
268 .driver_info = (unsigned long) &belkin_info,
272 #ifdef CONFIG_USB_EPSON2888
274 USB_DEVICE (0x0525, 0x2888), // EPSON USB client
275 .driver_info = (unsigned long) &epson2888_info,
279 #ifdef CONFIG_USB_KC2190
281 USB_DEVICE (0x050f, 0x0190), // KC-190
282 .driver_info = (unsigned long) &kc2190_info,
286 #ifdef CONFIG_USB_ARMLINUX
288 * SA-1100 using standard ARM Linux kernels, or compatible.
289 * Often used when talking to Linux PDAs (iPaq, Yopy, etc).
290 * The sa-1100 "usb-eth" driver handles the basic framing.
292 * PXA25x or PXA210 ... these use a "usb-eth" driver much like
293 * the sa1100 one, but hardware uses different endpoint numbers.
295 * Or the Linux "Ethernet" gadget on hardware that can't talk
296 * CDC Ethernet (e.g., no altsettings), in either of two modes:
297 * - acting just like the old "usb-eth" firmware, though
298 * the implementation is different
299 * - supporting RNDIS as the first/default configuration for
300 * MS-Windows interop; Linux needs to use the other config
303 // 1183 = 0x049F, both used as hex values?
304 // Compaq "Itsy" vendor/product id
305 USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible
306 .driver_info = (unsigned long) &linuxdev_info,
308 USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy"
309 .driver_info = (unsigned long) &yopy_info,
311 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
312 .driver_info = (unsigned long) &blob_info,
314 USB_DEVICE (0x1286, 0x8001), // "blob" bootloader
315 .driver_info = (unsigned long) &blob_info,
317 // Linux Ethernet/RNDIS gadget, mostly on PXA, second config
318 // e.g. Gumstix, current OpenZaurus, ... or anything else
319 // that just enables this gadget option.
320 USB_DEVICE (0x0525, 0xa4a2),
321 .driver_info = (unsigned long) &linuxdev_info,
327 MODULE_DEVICE_TABLE(usb, products);
329 /*-------------------------------------------------------------------------*/
331 static struct usb_driver cdc_subset_driver = {
332 .name = "cdc_subset",
333 .probe = usbnet_probe,
334 .suspend = usbnet_suspend,
335 .resume = usbnet_resume,
336 .disconnect = usbnet_disconnect,
337 .id_table = products,
338 .disable_hub_initiated_lpm = 1,
341 module_usb_driver(cdc_subset_driver);
343 MODULE_AUTHOR("David Brownell");
344 MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links");
345 MODULE_LICENSE("GPL");