15b2fc499SJeff Garzik /* 25b2fc499SJeff Garzik * Simple "CDC Subset" USB Networking Links 35b2fc499SJeff Garzik * Copyright (C) 2000-2005 by David Brownell 45b2fc499SJeff Garzik * 55b2fc499SJeff Garzik * This program is free software; you can redistribute it and/or modify 65b2fc499SJeff Garzik * it under the terms of the GNU General Public License as published by 75b2fc499SJeff Garzik * the Free Software Foundation; either version 2 of the License, or 85b2fc499SJeff Garzik * (at your option) any later version. 95b2fc499SJeff Garzik * 105b2fc499SJeff Garzik * This program is distributed in the hope that it will be useful, 115b2fc499SJeff Garzik * but WITHOUT ANY WARRANTY; without even the implied warranty of 125b2fc499SJeff Garzik * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 135b2fc499SJeff Garzik * GNU General Public License for more details. 145b2fc499SJeff Garzik * 155b2fc499SJeff Garzik * You should have received a copy of the GNU General Public License 165b2fc499SJeff Garzik * along with this program; if not, write to the Free Software 175b2fc499SJeff Garzik * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 185b2fc499SJeff Garzik */ 195b2fc499SJeff Garzik 205b2fc499SJeff Garzik #include <linux/module.h> 215b2fc499SJeff Garzik #include <linux/kmod.h> 225b2fc499SJeff Garzik #include <linux/init.h> 235b2fc499SJeff Garzik #include <linux/netdevice.h> 245b2fc499SJeff Garzik #include <linux/etherdevice.h> 255b2fc499SJeff Garzik #include <linux/ethtool.h> 265b2fc499SJeff Garzik #include <linux/workqueue.h> 275b2fc499SJeff Garzik #include <linux/mii.h> 285b2fc499SJeff Garzik #include <linux/usb.h> 293692e94fSJussi Kivilinna #include <linux/usb/usbnet.h> 305b2fc499SJeff Garzik 315b2fc499SJeff Garzik 325b2fc499SJeff Garzik /* 335b2fc499SJeff Garzik * This supports simple USB network links that don't require any special 345b2fc499SJeff Garzik * framing or hardware control operations. The protocol used here is a 355b2fc499SJeff Garzik * strict subset of CDC Ethernet, with three basic differences reflecting 365b2fc499SJeff Garzik * the goal that almost any hardware should run it: 375b2fc499SJeff Garzik * 385b2fc499SJeff Garzik * - Minimal runtime control: one interface, no altsettings, and 395b2fc499SJeff Garzik * no vendor or class specific control requests. If a device is 405b2fc499SJeff Garzik * configured, it is allowed to exchange packets with the host. 415b2fc499SJeff Garzik * Fancier models would mean not working on some hardware. 425b2fc499SJeff Garzik * 435b2fc499SJeff Garzik * - Minimal manufacturing control: no IEEE "Organizationally 445b2fc499SJeff Garzik * Unique ID" required, or an EEPROMs to store one. Each host uses 455b2fc499SJeff Garzik * one random "locally assigned" Ethernet address instead, which can 465b2fc499SJeff Garzik * of course be overridden using standard tools like "ifconfig". 475b2fc499SJeff Garzik * (With 2^46 such addresses, same-net collisions are quite rare.) 485b2fc499SJeff Garzik * 495b2fc499SJeff Garzik * - There is no additional framing data for USB. Packets are written 505b2fc499SJeff Garzik * exactly as in CDC Ethernet, starting with an Ethernet header and 515b2fc499SJeff Garzik * terminated by a short packet. However, the host will never send a 525b2fc499SJeff Garzik * zero length packet; some systems can't handle those robustly. 535b2fc499SJeff Garzik * 545b2fc499SJeff Garzik * Anything that can transmit and receive USB bulk packets can implement 555b2fc499SJeff Garzik * this protocol. That includes both smart peripherals and quite a lot 565b2fc499SJeff Garzik * of "host-to-host" USB cables (which embed two devices back-to-back). 575b2fc499SJeff Garzik * 585b2fc499SJeff Garzik * Note that although Linux may use many of those host-to-host links 595b2fc499SJeff Garzik * with this "cdc_subset" framing, that doesn't mean there may not be a 605b2fc499SJeff Garzik * better approach. Handling the "other end unplugs/replugs" scenario 615b2fc499SJeff Garzik * well tends to require chip-specific vendor requests. Also, Windows 625b2fc499SJeff Garzik * peers at the other end of host-to-host cables may expect their own 635b2fc499SJeff Garzik * framing to be used rather than this "cdc_subset" model. 645b2fc499SJeff Garzik */ 655b2fc499SJeff Garzik 665b2fc499SJeff Garzik #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) 675b2fc499SJeff Garzik /* PDA style devices are always connected if present */ 685b2fc499SJeff Garzik static int always_connected (struct usbnet *dev) 695b2fc499SJeff Garzik { 705b2fc499SJeff Garzik return 0; 715b2fc499SJeff Garzik } 725b2fc499SJeff Garzik #endif 735b2fc499SJeff Garzik 745b2fc499SJeff Garzik #ifdef CONFIG_USB_ALI_M5632 755b2fc499SJeff Garzik #define HAVE_HARDWARE 765b2fc499SJeff Garzik 775b2fc499SJeff Garzik /*------------------------------------------------------------------------- 785b2fc499SJeff Garzik * 795b2fc499SJeff Garzik * ALi M5632 driver ... does high speed 805b2fc499SJeff Garzik * 815b2fc499SJeff Garzik * NOTE that the MS-Windows drivers for this chip use some funky and 825b2fc499SJeff Garzik * (naturally) undocumented 7-byte prefix to each packet, so this is a 835b2fc499SJeff Garzik * case where we don't currently interoperate. Also, once you unplug 845b2fc499SJeff Garzik * one end of the cable, you need to replug the other end too ... since 855b2fc499SJeff Garzik * chip docs are unavailable, there's no way to reset the relevant state 865b2fc499SJeff Garzik * short of a power cycle. 875b2fc499SJeff Garzik * 885b2fc499SJeff Garzik *-------------------------------------------------------------------------*/ 895b2fc499SJeff Garzik 905b2fc499SJeff Garzik static const struct driver_info ali_m5632_info = { 915b2fc499SJeff Garzik .description = "ALi M5632", 92c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 935b2fc499SJeff Garzik }; 945b2fc499SJeff Garzik 955b2fc499SJeff Garzik #endif 965b2fc499SJeff Garzik 975b2fc499SJeff Garzik 985b2fc499SJeff Garzik #ifdef CONFIG_USB_AN2720 995b2fc499SJeff Garzik #define HAVE_HARDWARE 1005b2fc499SJeff Garzik 1015b2fc499SJeff Garzik /*------------------------------------------------------------------------- 1025b2fc499SJeff Garzik * 1035b2fc499SJeff Garzik * AnchorChips 2720 driver ... http://www.cypress.com 1045b2fc499SJeff Garzik * 1055b2fc499SJeff Garzik * This doesn't seem to have a way to detect whether the peer is 1065b2fc499SJeff Garzik * connected, or need any reset handshaking. It's got pretty big 1075b2fc499SJeff Garzik * internal buffers (handles most of a frame's worth of data). 1085b2fc499SJeff Garzik * Chip data sheets don't describe any vendor control messages. 1095b2fc499SJeff Garzik * 1105b2fc499SJeff Garzik *-------------------------------------------------------------------------*/ 1115b2fc499SJeff Garzik 1125b2fc499SJeff Garzik static const struct driver_info an2720_info = { 1135b2fc499SJeff Garzik .description = "AnchorChips/Cypress 2720", 114c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 1155b2fc499SJeff Garzik // no reset available! 1165b2fc499SJeff Garzik // no check_connect available! 1175b2fc499SJeff Garzik 1185b2fc499SJeff Garzik .in = 2, .out = 2, // direction distinguishes these 1195b2fc499SJeff Garzik }; 1205b2fc499SJeff Garzik 1215b2fc499SJeff Garzik #endif /* CONFIG_USB_AN2720 */ 1225b2fc499SJeff Garzik 1235b2fc499SJeff Garzik 1245b2fc499SJeff Garzik #ifdef CONFIG_USB_BELKIN 1255b2fc499SJeff Garzik #define HAVE_HARDWARE 1265b2fc499SJeff Garzik 1275b2fc499SJeff Garzik /*------------------------------------------------------------------------- 1285b2fc499SJeff Garzik * 1295b2fc499SJeff Garzik * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller 1305b2fc499SJeff Garzik * 1315b2fc499SJeff Garzik * ... also two eTEK designs, including one sold as "Advance USBNET" 1325b2fc499SJeff Garzik * 1335b2fc499SJeff Garzik *-------------------------------------------------------------------------*/ 1345b2fc499SJeff Garzik 1355b2fc499SJeff Garzik static const struct driver_info belkin_info = { 1365b2fc499SJeff Garzik .description = "Belkin, eTEK, or compatible", 137c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 1385b2fc499SJeff Garzik }; 1395b2fc499SJeff Garzik 1405b2fc499SJeff Garzik #endif /* CONFIG_USB_BELKIN */ 1415b2fc499SJeff Garzik 1425b2fc499SJeff Garzik 1435b2fc499SJeff Garzik 1445b2fc499SJeff Garzik #ifdef CONFIG_USB_EPSON2888 1455b2fc499SJeff Garzik #define HAVE_HARDWARE 1465b2fc499SJeff Garzik 1475b2fc499SJeff Garzik /*------------------------------------------------------------------------- 1485b2fc499SJeff Garzik * 1495b2fc499SJeff Garzik * EPSON USB clients 1505b2fc499SJeff Garzik * 1515b2fc499SJeff Garzik * This is the same idea as Linux PDAs (below) except the firmware in the 1525b2fc499SJeff Garzik * device might not be Tux-powered. Epson provides reference firmware that 1535b2fc499SJeff Garzik * implements this interface. Product developers can reuse or modify that 1545b2fc499SJeff Garzik * code, such as by using their own product and vendor codes. 1555b2fc499SJeff Garzik * 1565b2fc499SJeff Garzik * Support was from Juro Bystricky <bystricky.juro@erd.epson.com> 1575b2fc499SJeff Garzik * 1585b2fc499SJeff Garzik *-------------------------------------------------------------------------*/ 1595b2fc499SJeff Garzik 1605b2fc499SJeff Garzik static const struct driver_info epson2888_info = { 1615b2fc499SJeff Garzik .description = "Epson USB Device", 1625b2fc499SJeff Garzik .check_connect = always_connected, 163c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 1645b2fc499SJeff Garzik 1655b2fc499SJeff Garzik .in = 4, .out = 3, 1665b2fc499SJeff Garzik }; 1675b2fc499SJeff Garzik 1685b2fc499SJeff Garzik #endif /* CONFIG_USB_EPSON2888 */ 1695b2fc499SJeff Garzik 1705b2fc499SJeff Garzik 1715b2fc499SJeff Garzik /*------------------------------------------------------------------------- 1725b2fc499SJeff Garzik * 1735b2fc499SJeff Garzik * info from Jonathan McDowell <noodles@earth.li> 1745b2fc499SJeff Garzik * 1755b2fc499SJeff Garzik *-------------------------------------------------------------------------*/ 1765b2fc499SJeff Garzik #ifdef CONFIG_USB_KC2190 1775b2fc499SJeff Garzik #define HAVE_HARDWARE 1785b2fc499SJeff Garzik static const struct driver_info kc2190_info = { 1795b2fc499SJeff Garzik .description = "KC Technology KC-190", 180c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 1815b2fc499SJeff Garzik }; 1825b2fc499SJeff Garzik #endif /* CONFIG_USB_KC2190 */ 1835b2fc499SJeff Garzik 1845b2fc499SJeff Garzik 1855b2fc499SJeff Garzik #ifdef CONFIG_USB_ARMLINUX 1865b2fc499SJeff Garzik #define HAVE_HARDWARE 1875b2fc499SJeff Garzik 1885b2fc499SJeff Garzik /*------------------------------------------------------------------------- 1895b2fc499SJeff Garzik * 1905b2fc499SJeff Garzik * Intel's SA-1100 chip integrates basic USB support, and is used 1915b2fc499SJeff Garzik * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. 1925b2fc499SJeff Garzik * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to 1935b2fc499SJeff Garzik * network using minimal USB framing data. 1945b2fc499SJeff Garzik * 1955b2fc499SJeff Garzik * This describes the driver currently in standard ARM Linux kernels. 1965b2fc499SJeff Garzik * The Zaurus uses a different driver (see later). 1975b2fc499SJeff Garzik * 1985b2fc499SJeff Garzik * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support 1995b2fc499SJeff Garzik * and different USB endpoint numbering than the SA1100 devices. The 2005b2fc499SJeff Garzik * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 2015b2fc499SJeff Garzik * so we rely on the endpoint descriptors. 2025b2fc499SJeff Garzik * 2035b2fc499SJeff Garzik *-------------------------------------------------------------------------*/ 2045b2fc499SJeff Garzik 2055b2fc499SJeff Garzik static const struct driver_info linuxdev_info = { 2065b2fc499SJeff Garzik .description = "Linux Device", 2075b2fc499SJeff Garzik .check_connect = always_connected, 208c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 2095b2fc499SJeff Garzik }; 2105b2fc499SJeff Garzik 2115b2fc499SJeff Garzik static const struct driver_info yopy_info = { 2125b2fc499SJeff Garzik .description = "Yopy", 2135b2fc499SJeff Garzik .check_connect = always_connected, 214c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 2155b2fc499SJeff Garzik }; 2165b2fc499SJeff Garzik 2175b2fc499SJeff Garzik static const struct driver_info blob_info = { 2185b2fc499SJeff Garzik .description = "Boot Loader OBject", 2195b2fc499SJeff Garzik .check_connect = always_connected, 220c261344dSArnd Bergmann .flags = FLAG_POINTTOPOINT, 2215b2fc499SJeff Garzik }; 2225b2fc499SJeff Garzik 2235b2fc499SJeff Garzik #endif /* CONFIG_USB_ARMLINUX */ 2245b2fc499SJeff Garzik 2255b2fc499SJeff Garzik 2265b2fc499SJeff Garzik /*-------------------------------------------------------------------------*/ 2275b2fc499SJeff Garzik 2285b2fc499SJeff Garzik #ifndef HAVE_HARDWARE 229f82b9878SIngo Molnar #warning You need to configure some hardware for this driver 2305b2fc499SJeff Garzik #endif 2315b2fc499SJeff Garzik 2325b2fc499SJeff Garzik /* 2335b2fc499SJeff Garzik * chip vendor names won't normally be on the cables, and 2345b2fc499SJeff Garzik * may not be on the device. 2355b2fc499SJeff Garzik */ 2365b2fc499SJeff Garzik 2375b2fc499SJeff Garzik static const struct usb_device_id products [] = { 2385b2fc499SJeff Garzik 2395b2fc499SJeff Garzik #ifdef CONFIG_USB_ALI_M5632 2405b2fc499SJeff Garzik { 2415b2fc499SJeff Garzik USB_DEVICE (0x0402, 0x5632), // ALi defaults 2425b2fc499SJeff Garzik .driver_info = (unsigned long) &ali_m5632_info, 2435b2fc499SJeff Garzik }, 2445b2fc499SJeff Garzik { 2455b2fc499SJeff Garzik USB_DEVICE (0x182d,0x207c), // SiteCom CN-124 2465b2fc499SJeff Garzik .driver_info = (unsigned long) &ali_m5632_info, 2475b2fc499SJeff Garzik }, 2485b2fc499SJeff Garzik #endif 2495b2fc499SJeff Garzik 2505b2fc499SJeff Garzik #ifdef CONFIG_USB_AN2720 2515b2fc499SJeff Garzik { 2525b2fc499SJeff Garzik USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults 2535b2fc499SJeff Garzik .driver_info = (unsigned long) &an2720_info, 2545b2fc499SJeff Garzik }, { 2555b2fc499SJeff Garzik USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET 2565b2fc499SJeff Garzik .driver_info = (unsigned long) &an2720_info, 2575b2fc499SJeff Garzik }, 2585b2fc499SJeff Garzik #endif 2595b2fc499SJeff Garzik 2605b2fc499SJeff Garzik #ifdef CONFIG_USB_BELKIN 2615b2fc499SJeff Garzik { 2625b2fc499SJeff Garzik USB_DEVICE (0x050d, 0x0004), // Belkin 2635b2fc499SJeff Garzik .driver_info = (unsigned long) &belkin_info, 2645b2fc499SJeff Garzik }, { 2655b2fc499SJeff Garzik USB_DEVICE (0x056c, 0x8100), // eTEK 2665b2fc499SJeff Garzik .driver_info = (unsigned long) &belkin_info, 2675b2fc499SJeff Garzik }, { 2685b2fc499SJeff Garzik USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) 2695b2fc499SJeff Garzik .driver_info = (unsigned long) &belkin_info, 2705b2fc499SJeff Garzik }, 2715b2fc499SJeff Garzik #endif 2725b2fc499SJeff Garzik 2735b2fc499SJeff Garzik #ifdef CONFIG_USB_EPSON2888 2745b2fc499SJeff Garzik { 2755b2fc499SJeff Garzik USB_DEVICE (0x0525, 0x2888), // EPSON USB client 2765b2fc499SJeff Garzik .driver_info = (unsigned long) &epson2888_info, 2775b2fc499SJeff Garzik }, 2785b2fc499SJeff Garzik #endif 2795b2fc499SJeff Garzik 2805b2fc499SJeff Garzik #ifdef CONFIG_USB_KC2190 2815b2fc499SJeff Garzik { 2825b2fc499SJeff Garzik USB_DEVICE (0x050f, 0x0190), // KC-190 2835b2fc499SJeff Garzik .driver_info = (unsigned long) &kc2190_info, 2845b2fc499SJeff Garzik }, 2855b2fc499SJeff Garzik #endif 2865b2fc499SJeff Garzik 2875b2fc499SJeff Garzik #ifdef CONFIG_USB_ARMLINUX 2885b2fc499SJeff Garzik /* 2895b2fc499SJeff Garzik * SA-1100 using standard ARM Linux kernels, or compatible. 2905b2fc499SJeff Garzik * Often used when talking to Linux PDAs (iPaq, Yopy, etc). 2915b2fc499SJeff Garzik * The sa-1100 "usb-eth" driver handles the basic framing. 2925b2fc499SJeff Garzik * 2935b2fc499SJeff Garzik * PXA25x or PXA210 ... these use a "usb-eth" driver much like 2945b2fc499SJeff Garzik * the sa1100 one, but hardware uses different endpoint numbers. 2955b2fc499SJeff Garzik * 2965b2fc499SJeff Garzik * Or the Linux "Ethernet" gadget on hardware that can't talk 2975b2fc499SJeff Garzik * CDC Ethernet (e.g., no altsettings), in either of two modes: 2985b2fc499SJeff Garzik * - acting just like the old "usb-eth" firmware, though 2995b2fc499SJeff Garzik * the implementation is different 3005b2fc499SJeff Garzik * - supporting RNDIS as the first/default configuration for 3015b2fc499SJeff Garzik * MS-Windows interop; Linux needs to use the other config 3025b2fc499SJeff Garzik */ 3035b2fc499SJeff Garzik { 3045b2fc499SJeff Garzik // 1183 = 0x049F, both used as hex values? 3055b2fc499SJeff Garzik // Compaq "Itsy" vendor/product id 3065b2fc499SJeff Garzik USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible 3075b2fc499SJeff Garzik .driver_info = (unsigned long) &linuxdev_info, 3085b2fc499SJeff Garzik }, { 3095b2fc499SJeff Garzik USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" 3105b2fc499SJeff Garzik .driver_info = (unsigned long) &yopy_info, 3115b2fc499SJeff Garzik }, { 3125b2fc499SJeff Garzik USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader 3135b2fc499SJeff Garzik .driver_info = (unsigned long) &blob_info, 3145b2fc499SJeff Garzik }, { 315d4f01a77Sjing xiang USB_DEVICE (0x1286, 0x8001), // "blob" bootloader 316d4f01a77Sjing xiang .driver_info = (unsigned long) &blob_info, 317d4f01a77Sjing xiang }, { 3186be83252SDavid Brownell // Linux Ethernet/RNDIS gadget, mostly on PXA, second config 3196be83252SDavid Brownell // e.g. Gumstix, current OpenZaurus, ... or anything else 3206be83252SDavid Brownell // that just enables this gadget option. 3216be83252SDavid Brownell USB_DEVICE (0x0525, 0xa4a2), 3225b2fc499SJeff Garzik .driver_info = (unsigned long) &linuxdev_info, 3235b2fc499SJeff Garzik }, 3245b2fc499SJeff Garzik #endif 3255b2fc499SJeff Garzik 3265b2fc499SJeff Garzik { }, // END 3275b2fc499SJeff Garzik }; 3285b2fc499SJeff Garzik MODULE_DEVICE_TABLE(usb, products); 3295b2fc499SJeff Garzik 3305b2fc499SJeff Garzik /*-------------------------------------------------------------------------*/ 3315b2fc499SJeff Garzik 3325b2fc499SJeff Garzik static struct usb_driver cdc_subset_driver = { 3335b2fc499SJeff Garzik .name = "cdc_subset", 3345b2fc499SJeff Garzik .probe = usbnet_probe, 3355b2fc499SJeff Garzik .suspend = usbnet_suspend, 3365b2fc499SJeff Garzik .resume = usbnet_resume, 3375b2fc499SJeff Garzik .disconnect = usbnet_disconnect, 3385b2fc499SJeff Garzik .id_table = products, 3395b2fc499SJeff Garzik }; 3405b2fc499SJeff Garzik 341d632eb1bSGreg Kroah-Hartman module_usb_driver(cdc_subset_driver); 3425b2fc499SJeff Garzik 3435b2fc499SJeff Garzik MODULE_AUTHOR("David Brownell"); 3445b2fc499SJeff Garzik MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); 3455b2fc499SJeff Garzik MODULE_LICENSE("GPL"); 346