![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 /* 0003 * Simple "CDC Subset" USB Networking Links 0004 * Copyright (C) 2000-2005 by David Brownell 0005 */ 0006 0007 #include <linux/module.h> 0008 #include <linux/kmod.h> 0009 #include <linux/netdevice.h> 0010 #include <linux/etherdevice.h> 0011 #include <linux/ethtool.h> 0012 #include <linux/workqueue.h> 0013 #include <linux/mii.h> 0014 #include <linux/usb.h> 0015 #include <linux/usb/usbnet.h> 0016 0017 0018 /* 0019 * This supports simple USB network links that don't require any special 0020 * framing or hardware control operations. The protocol used here is a 0021 * strict subset of CDC Ethernet, with three basic differences reflecting 0022 * the goal that almost any hardware should run it: 0023 * 0024 * - Minimal runtime control: one interface, no altsettings, and 0025 * no vendor or class specific control requests. If a device is 0026 * configured, it is allowed to exchange packets with the host. 0027 * Fancier models would mean not working on some hardware. 0028 * 0029 * - Minimal manufacturing control: no IEEE "Organizationally 0030 * Unique ID" required, or an EEPROMs to store one. Each host uses 0031 * one random "locally assigned" Ethernet address instead, which can 0032 * of course be overridden using standard tools like "ifconfig". 0033 * (With 2^46 such addresses, same-net collisions are quite rare.) 0034 * 0035 * - There is no additional framing data for USB. Packets are written 0036 * exactly as in CDC Ethernet, starting with an Ethernet header and 0037 * terminated by a short packet. However, the host will never send a 0038 * zero length packet; some systems can't handle those robustly. 0039 * 0040 * Anything that can transmit and receive USB bulk packets can implement 0041 * this protocol. That includes both smart peripherals and quite a lot 0042 * of "host-to-host" USB cables (which embed two devices back-to-back). 0043 * 0044 * Note that although Linux may use many of those host-to-host links 0045 * with this "cdc_subset" framing, that doesn't mean there may not be a 0046 * better approach. Handling the "other end unplugs/replugs" scenario 0047 * well tends to require chip-specific vendor requests. Also, Windows 0048 * peers at the other end of host-to-host cables may expect their own 0049 * framing to be used rather than this "cdc_subset" model. 0050 */ 0051 0052 #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) 0053 /* PDA style devices are always connected if present */ 0054 static int always_connected (struct usbnet *dev) 0055 { 0056 return 0; 0057 } 0058 #endif 0059 0060 #ifdef CONFIG_USB_ALI_M5632 0061 #define HAVE_HARDWARE 0062 0063 /*------------------------------------------------------------------------- 0064 * 0065 * ALi M5632 driver ... does high speed 0066 * 0067 * NOTE that the MS-Windows drivers for this chip use some funky and 0068 * (naturally) undocumented 7-byte prefix to each packet, so this is a 0069 * case where we don't currently interoperate. Also, once you unplug 0070 * one end of the cable, you need to replug the other end too ... since 0071 * chip docs are unavailable, there's no way to reset the relevant state 0072 * short of a power cycle. 0073 * 0074 *-------------------------------------------------------------------------*/ 0075 0076 static void m5632_recover(struct usbnet *dev) 0077 { 0078 struct usb_device *udev = dev->udev; 0079 struct usb_interface *intf = dev->intf; 0080 int r; 0081 0082 r = usb_lock_device_for_reset(udev, intf); 0083 if (r < 0) 0084 return; 0085 0086 usb_reset_device(udev); 0087 usb_unlock_device(udev); 0088 } 0089 0090 static const struct driver_info ali_m5632_info = { 0091 .description = "ALi M5632", 0092 .flags = FLAG_POINTTOPOINT, 0093 .recover = m5632_recover, 0094 }; 0095 0096 #endif 0097 0098 #ifdef CONFIG_USB_AN2720 0099 #define HAVE_HARDWARE 0100 0101 /*------------------------------------------------------------------------- 0102 * 0103 * AnchorChips 2720 driver ... http://www.cypress.com 0104 * 0105 * This doesn't seem to have a way to detect whether the peer is 0106 * connected, or need any reset handshaking. It's got pretty big 0107 * internal buffers (handles most of a frame's worth of data). 0108 * Chip data sheets don't describe any vendor control messages. 0109 * 0110 *-------------------------------------------------------------------------*/ 0111 0112 static const struct driver_info an2720_info = { 0113 .description = "AnchorChips/Cypress 2720", 0114 .flags = FLAG_POINTTOPOINT, 0115 // no reset available! 0116 // no check_connect available! 0117 0118 .in = 2, .out = 2, // direction distinguishes these 0119 }; 0120 0121 #endif /* CONFIG_USB_AN2720 */ 0122 0123 0124 #ifdef CONFIG_USB_BELKIN 0125 #define HAVE_HARDWARE 0126 0127 /*------------------------------------------------------------------------- 0128 * 0129 * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller 0130 * 0131 * ... also two eTEK designs, including one sold as "Advance USBNET" 0132 * 0133 *-------------------------------------------------------------------------*/ 0134 0135 static const struct driver_info belkin_info = { 0136 .description = "Belkin, eTEK, or compatible", 0137 .flags = FLAG_POINTTOPOINT, 0138 }; 0139 0140 #endif /* CONFIG_USB_BELKIN */ 0141 0142 0143 0144 #ifdef CONFIG_USB_EPSON2888 0145 #define HAVE_HARDWARE 0146 0147 /*------------------------------------------------------------------------- 0148 * 0149 * EPSON USB clients 0150 * 0151 * This is the same idea as Linux PDAs (below) except the firmware in the 0152 * device might not be Tux-powered. Epson provides reference firmware that 0153 * implements this interface. Product developers can reuse or modify that 0154 * code, such as by using their own product and vendor codes. 0155 * 0156 * Support was from Juro Bystricky <bystricky.juro@erd.epson.com> 0157 * 0158 *-------------------------------------------------------------------------*/ 0159 0160 static const struct driver_info epson2888_info = { 0161 .description = "Epson USB Device", 0162 .check_connect = always_connected, 0163 .flags = FLAG_POINTTOPOINT, 0164 0165 .in = 4, .out = 3, 0166 }; 0167 0168 #endif /* CONFIG_USB_EPSON2888 */ 0169 0170 0171 /*------------------------------------------------------------------------- 0172 * 0173 * info from Jonathan McDowell <noodles@earth.li> 0174 * 0175 *-------------------------------------------------------------------------*/ 0176 #ifdef CONFIG_USB_KC2190 0177 #define HAVE_HARDWARE 0178 static const struct driver_info kc2190_info = { 0179 .description = "KC Technology KC-190", 0180 .flags = FLAG_POINTTOPOINT, 0181 }; 0182 #endif /* CONFIG_USB_KC2190 */ 0183 0184 0185 #ifdef CONFIG_USB_ARMLINUX 0186 #define HAVE_HARDWARE 0187 0188 /*------------------------------------------------------------------------- 0189 * 0190 * Intel's SA-1100 chip integrates basic USB support, and is used 0191 * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. 0192 * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to 0193 * network using minimal USB framing data. 0194 * 0195 * This describes the driver currently in standard ARM Linux kernels. 0196 * The Zaurus uses a different driver (see later). 0197 * 0198 * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support 0199 * and different USB endpoint numbering than the SA1100 devices. The 0200 * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 0201 * so we rely on the endpoint descriptors. 0202 * 0203 *-------------------------------------------------------------------------*/ 0204 0205 static const struct driver_info linuxdev_info = { 0206 .description = "Linux Device", 0207 .check_connect = always_connected, 0208 .flags = FLAG_POINTTOPOINT, 0209 }; 0210 0211 static const struct driver_info yopy_info = { 0212 .description = "Yopy", 0213 .check_connect = always_connected, 0214 .flags = FLAG_POINTTOPOINT, 0215 }; 0216 0217 static const struct driver_info blob_info = { 0218 .description = "Boot Loader OBject", 0219 .check_connect = always_connected, 0220 .flags = FLAG_POINTTOPOINT, 0221 }; 0222 0223 #endif /* CONFIG_USB_ARMLINUX */ 0224 0225 0226 /*-------------------------------------------------------------------------*/ 0227 0228 #ifndef HAVE_HARDWARE 0229 #warning You need to configure some hardware for this driver 0230 #endif 0231 0232 /* 0233 * chip vendor names won't normally be on the cables, and 0234 * may not be on the device. 0235 */ 0236 0237 static const struct usb_device_id products [] = { 0238 0239 #ifdef CONFIG_USB_ALI_M5632 0240 { 0241 USB_DEVICE (0x0402, 0x5632), // ALi defaults 0242 .driver_info = (unsigned long) &ali_m5632_info, 0243 }, 0244 { 0245 USB_DEVICE (0x182d,0x207c), // SiteCom CN-124 0246 .driver_info = (unsigned long) &ali_m5632_info, 0247 }, 0248 #endif 0249 0250 #ifdef CONFIG_USB_AN2720 0251 { 0252 USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults 0253 .driver_info = (unsigned long) &an2720_info, 0254 }, { 0255 USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET 0256 .driver_info = (unsigned long) &an2720_info, 0257 }, 0258 #endif 0259 0260 #ifdef CONFIG_USB_BELKIN 0261 { 0262 USB_DEVICE (0x050d, 0x0004), // Belkin 0263 .driver_info = (unsigned long) &belkin_info, 0264 }, { 0265 USB_DEVICE (0x056c, 0x8100), // eTEK 0266 .driver_info = (unsigned long) &belkin_info, 0267 }, { 0268 USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) 0269 .driver_info = (unsigned long) &belkin_info, 0270 }, 0271 #endif 0272 0273 #ifdef CONFIG_USB_EPSON2888 0274 { 0275 USB_DEVICE (0x0525, 0x2888), // EPSON USB client 0276 .driver_info = (unsigned long) &epson2888_info, 0277 }, 0278 #endif 0279 0280 #ifdef CONFIG_USB_KC2190 0281 { 0282 USB_DEVICE (0x050f, 0x0190), // KC-190 0283 .driver_info = (unsigned long) &kc2190_info, 0284 }, 0285 #endif 0286 0287 #ifdef CONFIG_USB_ARMLINUX 0288 /* 0289 * SA-1100 using standard ARM Linux kernels, or compatible. 0290 * Often used when talking to Linux PDAs (iPaq, Yopy, etc). 0291 * The sa-1100 "usb-eth" driver handles the basic framing. 0292 * 0293 * PXA25x or PXA210 ... these use a "usb-eth" driver much like 0294 * the sa1100 one, but hardware uses different endpoint numbers. 0295 * 0296 * Or the Linux "Ethernet" gadget on hardware that can't talk 0297 * CDC Ethernet (e.g., no altsettings), in either of two modes: 0298 * - acting just like the old "usb-eth" firmware, though 0299 * the implementation is different 0300 * - supporting RNDIS as the first/default configuration for 0301 * MS-Windows interop; Linux needs to use the other config 0302 */ 0303 { 0304 // 1183 = 0x049F, both used as hex values? 0305 // Compaq "Itsy" vendor/product id 0306 USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible 0307 .driver_info = (unsigned long) &linuxdev_info, 0308 }, { 0309 USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" 0310 .driver_info = (unsigned long) &yopy_info, 0311 }, { 0312 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader 0313 .driver_info = (unsigned long) &blob_info, 0314 }, { 0315 USB_DEVICE (0x1286, 0x8001), // "blob" bootloader 0316 .driver_info = (unsigned long) &blob_info, 0317 }, { 0318 // Linux Ethernet/RNDIS gadget, mostly on PXA, second config 0319 // e.g. Gumstix, current OpenZaurus, ... or anything else 0320 // that just enables this gadget option. 0321 USB_DEVICE (0x0525, 0xa4a2), 0322 .driver_info = (unsigned long) &linuxdev_info, 0323 }, 0324 #endif 0325 0326 { }, // END 0327 }; 0328 MODULE_DEVICE_TABLE(usb, products); 0329 0330 /*-------------------------------------------------------------------------*/ 0331 static int dummy_prereset(struct usb_interface *intf) 0332 { 0333 return 0; 0334 } 0335 0336 static int dummy_postreset(struct usb_interface *intf) 0337 { 0338 return 0; 0339 } 0340 0341 static struct usb_driver cdc_subset_driver = { 0342 .name = "cdc_subset", 0343 .probe = usbnet_probe, 0344 .suspend = usbnet_suspend, 0345 .resume = usbnet_resume, 0346 .pre_reset = dummy_prereset, 0347 .post_reset = dummy_postreset, 0348 .disconnect = usbnet_disconnect, 0349 .id_table = products, 0350 .disable_hub_initiated_lpm = 1, 0351 }; 0352 0353 module_usb_driver(cdc_subset_driver); 0354 0355 MODULE_AUTHOR("David Brownell"); 0356 MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); 0357 MODULE_LICENSE("GPL");
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |