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/netdevice.h>
22 #include <linux/etherdevice.h>
23 #include <linux/ethtool.h>
24 #include <linux/workqueue.h>
25 #include <linux/mii.h>
26 #include <linux/usb.h>
27 #include <linux/usb/usbnet.h>
31 * This supports simple USB network links that don't require any special
32 * framing or hardware control operations. The protocol used here is a
33 * strict subset of CDC Ethernet, with three basic differences reflecting
34 * the goal that almost any hardware should run it:
36 * - Minimal runtime control: one interface, no altsettings, and
37 * no vendor or class specific control requests. If a device is
38 * configured, it is allowed to exchange packets with the host.
39 * Fancier models would mean not working on some hardware.
41 * - Minimal manufacturing control: no IEEE "Organizationally
42 * Unique ID" required, or an EEPROMs to store one. Each host uses
43 * one random "locally assigned" Ethernet address instead, which can
44 * of course be overridden using standard tools like "ifconfig".
45 * (With 2^46 such addresses, same-net collisions are quite rare.)
47 * - There is no additional framing data for USB. Packets are written
48 * exactly as in CDC Ethernet, starting with an Ethernet header and
49 * terminated by a short packet. However, the host will never send a
50 * zero length packet; some systems can't handle those robustly.
52 * Anything that can transmit and receive USB bulk packets can implement
53 * this protocol. That includes both smart peripherals and quite a lot
54 * of "host-to-host" USB cables (which embed two devices back-to-back).
56 * Note that although Linux may use many of those host-to-host links
57 * with this "cdc_subset" framing, that doesn't mean there may not be a
58 * better approach. Handling the "other end unplugs/replugs" scenario
59 * well tends to require chip-specific vendor requests. Also, Windows
60 * peers at the other end of host-to-host cables may expect their own
61 * framing to be used rather than this "cdc_subset" model.
64 #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX)
65 /* PDA style devices are always connected if present */
66 static int always_connected (struct usbnet *dev)
72 #ifdef CONFIG_USB_ALI_M5632
75 /*-------------------------------------------------------------------------
77 * ALi M5632 driver ... does high speed
79 * NOTE that the MS-Windows drivers for this chip use some funky and
80 * (naturally) undocumented 7-byte prefix to each packet, so this is a
81 * case where we don't currently interoperate. Also, once you unplug
82 * one end of the cable, you need to replug the other end too ... since
83 * chip docs are unavailable, there's no way to reset the relevant state
84 * short of a power cycle.
86 *-------------------------------------------------------------------------*/
88 static void m5632_recover(struct usbnet *dev)
90 struct usb_device *udev = dev->udev;
91 struct usb_interface *intf = dev->intf;
94 r = usb_lock_device_for_reset(udev, intf);
98 usb_reset_device(udev);
99 usb_unlock_device(udev);
102 static const struct driver_info ali_m5632_info = {
103 .description = "ALi M5632",
104 .flags = FLAG_POINTTOPOINT,
105 .recover = m5632_recover,
110 #ifdef CONFIG_USB_AN2720
111 #define HAVE_HARDWARE
113 /*-------------------------------------------------------------------------
115 * AnchorChips 2720 driver ... http://www.cypress.com
117 * This doesn't seem to have a way to detect whether the peer is
118 * connected, or need any reset handshaking. It's got pretty big
119 * internal buffers (handles most of a frame's worth of data).
120 * Chip data sheets don't describe any vendor control messages.
122 *-------------------------------------------------------------------------*/
124 static const struct driver_info an2720_info = {
125 .description = "AnchorChips/Cypress 2720",
126 .flags = FLAG_POINTTOPOINT,
127 // no reset available!
128 // no check_connect available!
130 .in = 2, .out = 2, // direction distinguishes these
133 #endif /* CONFIG_USB_AN2720 */
136 #ifdef CONFIG_USB_BELKIN
137 #define HAVE_HARDWARE
139 /*-------------------------------------------------------------------------
141 * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller
143 * ... also two eTEK designs, including one sold as "Advance USBNET"
145 *-------------------------------------------------------------------------*/
147 static const struct driver_info belkin_info = {
148 .description = "Belkin, eTEK, or compatible",
149 .flags = FLAG_POINTTOPOINT,
152 #endif /* CONFIG_USB_BELKIN */
156 #ifdef CONFIG_USB_EPSON2888
157 #define HAVE_HARDWARE
159 /*-------------------------------------------------------------------------
163 * This is the same idea as Linux PDAs (below) except the firmware in the
164 * device might not be Tux-powered. Epson provides reference firmware that
165 * implements this interface. Product developers can reuse or modify that
166 * code, such as by using their own product and vendor codes.
168 * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
170 *-------------------------------------------------------------------------*/
172 static const struct driver_info epson2888_info = {
173 .description = "Epson USB Device",
174 .check_connect = always_connected,
175 .flags = FLAG_POINTTOPOINT,
180 #endif /* CONFIG_USB_EPSON2888 */
183 /*-------------------------------------------------------------------------
185 * info from Jonathan McDowell <noodles@earth.li>
187 *-------------------------------------------------------------------------*/
188 #ifdef CONFIG_USB_KC2190
189 #define HAVE_HARDWARE
190 static const struct driver_info kc2190_info = {
191 .description = "KC Technology KC-190",
192 .flags = FLAG_POINTTOPOINT,
194 #endif /* CONFIG_USB_KC2190 */
197 #ifdef CONFIG_USB_ARMLINUX
198 #define HAVE_HARDWARE
200 /*-------------------------------------------------------------------------
202 * Intel's SA-1100 chip integrates basic USB support, and is used
203 * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more.
204 * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to
205 * network using minimal USB framing data.
207 * This describes the driver currently in standard ARM Linux kernels.
208 * The Zaurus uses a different driver (see later).
210 * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support
211 * and different USB endpoint numbering than the SA1100 devices. The
212 * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100
213 * so we rely on the endpoint descriptors.
215 *-------------------------------------------------------------------------*/
217 static const struct driver_info linuxdev_info = {
218 .description = "Linux Device",
219 .check_connect = always_connected,
220 .flags = FLAG_POINTTOPOINT,
223 static const struct driver_info yopy_info = {
224 .description = "Yopy",
225 .check_connect = always_connected,
226 .flags = FLAG_POINTTOPOINT,
229 static const struct driver_info blob_info = {
230 .description = "Boot Loader OBject",
231 .check_connect = always_connected,
232 .flags = FLAG_POINTTOPOINT,
235 #endif /* CONFIG_USB_ARMLINUX */
238 /*-------------------------------------------------------------------------*/
240 #ifndef HAVE_HARDWARE
241 #warning You need to configure some hardware for this driver
245 * chip vendor names won't normally be on the cables, and
246 * may not be on the device.
249 static const struct usb_device_id products [] = {
251 #ifdef CONFIG_USB_ALI_M5632
253 USB_DEVICE (0x0402, 0x5632), // ALi defaults
254 .driver_info = (unsigned long) &ali_m5632_info,
257 USB_DEVICE (0x182d,0x207c), // SiteCom CN-124
258 .driver_info = (unsigned long) &ali_m5632_info,
262 #ifdef CONFIG_USB_AN2720
264 USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults
265 .driver_info = (unsigned long) &an2720_info,
267 USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET
268 .driver_info = (unsigned long) &an2720_info,
272 #ifdef CONFIG_USB_BELKIN
274 USB_DEVICE (0x050d, 0x0004), // Belkin
275 .driver_info = (unsigned long) &belkin_info,
277 USB_DEVICE (0x056c, 0x8100), // eTEK
278 .driver_info = (unsigned long) &belkin_info,
280 USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK)
281 .driver_info = (unsigned long) &belkin_info,
285 #ifdef CONFIG_USB_EPSON2888
287 USB_DEVICE (0x0525, 0x2888), // EPSON USB client
288 .driver_info = (unsigned long) &epson2888_info,
292 #ifdef CONFIG_USB_KC2190
294 USB_DEVICE (0x050f, 0x0190), // KC-190
295 .driver_info = (unsigned long) &kc2190_info,
299 #ifdef CONFIG_USB_ARMLINUX
301 * SA-1100 using standard ARM Linux kernels, or compatible.
302 * Often used when talking to Linux PDAs (iPaq, Yopy, etc).
303 * The sa-1100 "usb-eth" driver handles the basic framing.
305 * PXA25x or PXA210 ... these use a "usb-eth" driver much like
306 * the sa1100 one, but hardware uses different endpoint numbers.
308 * Or the Linux "Ethernet" gadget on hardware that can't talk
309 * CDC Ethernet (e.g., no altsettings), in either of two modes:
310 * - acting just like the old "usb-eth" firmware, though
311 * the implementation is different
312 * - supporting RNDIS as the first/default configuration for
313 * MS-Windows interop; Linux needs to use the other config
316 // 1183 = 0x049F, both used as hex values?
317 // Compaq "Itsy" vendor/product id
318 USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible
319 .driver_info = (unsigned long) &linuxdev_info,
321 USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy"
322 .driver_info = (unsigned long) &yopy_info,
324 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
325 .driver_info = (unsigned long) &blob_info,
327 USB_DEVICE (0x1286, 0x8001), // "blob" bootloader
328 .driver_info = (unsigned long) &blob_info,
330 // Linux Ethernet/RNDIS gadget, mostly on PXA, second config
331 // e.g. Gumstix, current OpenZaurus, ... or anything else
332 // that just enables this gadget option.
333 USB_DEVICE (0x0525, 0xa4a2),
334 .driver_info = (unsigned long) &linuxdev_info,
340 MODULE_DEVICE_TABLE(usb, products);
342 /*-------------------------------------------------------------------------*/
343 static int dummy_prereset(struct usb_interface *intf)
348 static int dummy_postreset(struct usb_interface *intf)
353 static struct usb_driver cdc_subset_driver = {
354 .name = "cdc_subset",
355 .probe = usbnet_probe,
356 .suspend = usbnet_suspend,
357 .resume = usbnet_resume,
358 .pre_reset = dummy_prereset,
359 .post_reset = dummy_postreset,
360 .disconnect = usbnet_disconnect,
361 .id_table = products,
362 .disable_hub_initiated_lpm = 1,
365 module_usb_driver(cdc_subset_driver);
367 MODULE_AUTHOR("David Brownell");
368 MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links");
369 MODULE_LICENSE("GPL");