diff options
author | David Brownell <david-b@pacbell.net> | 2005-08-31 12:54:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-08 19:28:33 -0400 |
commit | 090ffa9d0e904e1ed0f86c84dcf20684a8ac1a5a (patch) | |
tree | ccbe0623e934d69d3c51e99138a5720ef9e7f823 /drivers/usb/net/usbnet.c | |
parent | 64e049102d3de3e61409cb6019403a9e689dfda6 (diff) |
[PATCH] USB: usbnet (9/9) module for pl2301/2302 cables
This wraps up the conversion of the "usbnet" driver structure, by
moving the Prolific PL-2201/2302 minidriver to a module of its own.
It also includes some minor cleanups to the remaining "usbnet" file,
notably removing that long changelog at the top.
Minor historical note: Linux 2.2 first called the driver for
this hardware "plusb".
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/net/usbnet.c')
-rw-r--r-- | drivers/usb/net/usbnet.c | 214 |
1 files changed, 12 insertions, 202 deletions
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 6c78a42affaa..6c460918d54f 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * USB Networking Links | 2 | * USB Network driver infrastructure |
3 | * Copyright (C) 2000-2005 by David Brownell | 3 | * Copyright (C) 2000-2005 by David Brownell |
4 | * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> | 4 | * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> |
5 | * | 5 | * |
@@ -20,96 +20,15 @@ | |||
20 | 20 | ||
21 | /* | 21 | /* |
22 | * This is a generic "USB networking" framework that works with several | 22 | * This is a generic "USB networking" framework that works with several |
23 | * kinds of full and high speed networking devices: | 23 | * kinds of full and high speed networking devices: host-to-host cables, |
24 | * smart usb peripherals, and actual Ethernet adapters. | ||
24 | * | 25 | * |
25 | * + USB host-to-host "network cables", used for IP-over-USB links. | 26 | * These devices usually differ in terms of control protocols (if they |
26 | * These are often used for Laplink style connectivity products. | 27 | * even have one!) and sometimes they define new framing to wrap or batch |
27 | * - AnchorChip 2720 | 28 | * Ethernet packets. Otherwise, they talk to USB pretty much the same, |
28 | * - Belkin, eTEK (interops with Win32 drivers) | 29 | * so interface (un)binding, endpoint I/O queues, fault handling, and other |
29 | * - GeneSys GL620USB-A | 30 | * issues can usefully be addressed by this framework. |
30 | * - NetChip 1080 (interoperates with NetChip Win32 drivers) | 31 | */ |
31 | * - Prolific PL-2301/2302 (replaces "plusb" driver) | ||
32 | * - KC Technology KC2190 | ||
33 | * | ||
34 | * + Smart USB devices can support such links directly, using Internet | ||
35 | * standard protocols instead of proprietary host-to-device links. | ||
36 | * - Linux PDAs like iPaq, Yopy, and Zaurus | ||
37 | * - The BLOB boot loader (for diskless booting) | ||
38 | * - Linux "gadgets", perhaps using PXA-2xx or Net2280 controllers | ||
39 | * - Devices using EPSON's sample USB firmware | ||
40 | * - CDC-Ethernet class devices, such as many cable modems | ||
41 | * | ||
42 | * + Adapters to networks such as Ethernet. | ||
43 | * - AX8817X based USB 2.0 products | ||
44 | * | ||
45 | * Links to these devices can be bridged using Linux Ethernet bridging. | ||
46 | * With minor exceptions, these all use similar USB framing for network | ||
47 | * traffic, but need different protocols for control traffic. | ||
48 | * | ||
49 | * USB devices can implement their side of this protocol at the cost | ||
50 | * of two bulk endpoints; it's not restricted to "cable" applications. | ||
51 | * See the SA1110, Zaurus, or EPSON device/client support in this driver; | ||
52 | * slave/target drivers such as "usb-eth" (on most SA-1100 PDAs) or | ||
53 | * "g_ether" (in the Linux "gadget" framework) implement that behavior | ||
54 | * within devices. | ||
55 | * | ||
56 | * | ||
57 | * CHANGELOG: | ||
58 | * | ||
59 | * 13-sep-2000 experimental, new | ||
60 | * 10-oct-2000 usb_device_id table created. | ||
61 | * 28-oct-2000 misc fixes; mostly, discard more TTL-mangled rx packets. | ||
62 | * 01-nov-2000 usb_device_id table and probing api update by | ||
63 | * Adam J. Richter <adam@yggdrasil.com>. | ||
64 | * 18-dec-2000 (db) tx watchdog, "net1080" renaming to "usbnet", device_info | ||
65 | * and prolific support, isolate net1080-specific bits, cleanup. | ||
66 | * fix unlink_urbs oops in D3 PM resume code path. | ||
67 | * | ||
68 | * 02-feb-2001 (db) fix tx skb sharing, packet length, match_flags, ... | ||
69 | * 08-feb-2001 stubbed in "linuxdev", maybe the SA-1100 folk can use it; | ||
70 | * AnchorChips 2720 support (from spec) for testing; | ||
71 | * fix bit-ordering problem with ethernet multicast addr | ||
72 | * 19-feb-2001 Support for clearing halt conditions. SA1100 UDC support | ||
73 | * updates. Oleg Drokin (green@iXcelerator.com) | ||
74 | * 25-mar-2001 More SA-1100 updates, including workaround for ip problem | ||
75 | * expecting cleared skb->cb and framing change to match latest | ||
76 | * handhelds.org version (Oleg). Enable device IDs from the | ||
77 | * Win32 Belkin driver; other cleanups (db). | ||
78 | * 16-jul-2001 Bugfixes for uhci oops-on-unplug, Belkin support, various | ||
79 | * cleanups for problems not yet seen in the field. (db) | ||
80 | * 17-oct-2001 Handle "Advance USBNET" product, like Belkin/eTEK devices, | ||
81 | * from Ioannis Mavroukakis <i.mavroukakis@btinternet.com>; | ||
82 | * rx unlinks somehow weren't async; minor cleanup. | ||
83 | * 03-nov-2001 Merged GeneSys driver; original code from Jiun-Jie Huang | ||
84 | * <huangjj@genesyslogic.com.tw>, updated by Stanislav Brabec | ||
85 | * <utx@penguin.cz>. Made framing options (NetChip/GeneSys) | ||
86 | * tie mostly to (sub)driver info. Workaround some PL-2302 | ||
87 | * chips that seem to reject SET_INTERFACE requests. | ||
88 | * | ||
89 | * 06-apr-2002 Added ethtool support, based on a patch from Brad Hards. | ||
90 | * Level of diagnostics is more configurable; they use device | ||
91 | * location (usb_device->devpath) instead of address (2.5). | ||
92 | * For tx_fixup, memflags can't be NOIO. | ||
93 | * 07-may-2002 Generalize/cleanup keventd support, handling rx stalls (mostly | ||
94 | * for USB 2.0 TTs) and memory shortages (potential) too. (db) | ||
95 | * Use "locally assigned" IEEE802 address space. (Brad Hards) | ||
96 | * 18-oct-2002 Support for Zaurus (Pavel Machek), related cleanup (db). | ||
97 | * 14-dec-2002 Remove Zaurus-private crc32 code (Pavel); 2.5 oops fix, | ||
98 | * cleanups and stubbed PXA-250 support (db), fix for framing | ||
99 | * issues on Z, net1080, and gl620a (Toby Milne) | ||
100 | * | ||
101 | * 31-mar-2003 Use endpoint descriptors: high speed support, simpler sa1100 | ||
102 | * vs pxa25x, and CDC Ethernet. Throttle down log floods on | ||
103 | * disconnect; other cleanups. (db) Flush net1080 fifos | ||
104 | * after several sequential framing errors. (Johannes Erdfelt) | ||
105 | * 22-aug-2003 AX8817X support (Dave Hollis). | ||
106 | * | ||
107 | * 14-jun-2004 Trivial patch for AX8817X based Buffalo LUA-U2-KTX in Japan | ||
108 | * (Neil Bortnak) | ||
109 | * 03-nov-2004 Trivial patch for KC2190 (KC-190) chip. (Jonathan McDowell) | ||
110 | * | ||
111 | * 01-feb-2005 AX88772 support (Phil Chang & Dave Hollis) | ||
112 | *-------------------------------------------------------------------------*/ | ||
113 | 32 | ||
114 | // #define DEBUG // error path messages, extra info | 33 | // #define DEBUG // error path messages, extra info |
115 | // #define VERBOSE // more; success messages | 34 | // #define VERBOSE // more; success messages |
@@ -302,77 +221,6 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) | |||
302 | EXPORT_SYMBOL_GPL(usbnet_skb_return); | 221 | EXPORT_SYMBOL_GPL(usbnet_skb_return); |
303 | 222 | ||
304 | 223 | ||
305 | #ifdef CONFIG_USB_PL2301 | ||
306 | #define HAVE_HARDWARE | ||
307 | |||
308 | /*------------------------------------------------------------------------- | ||
309 | * | ||
310 | * Prolific PL-2301/PL-2302 driver ... http://www.prolifictech.com | ||
311 | * | ||
312 | * The protocol and handshaking used here should be bug-compatible | ||
313 | * with the Linux 2.2 "plusb" driver, by Deti Fliegl. | ||
314 | * | ||
315 | *-------------------------------------------------------------------------*/ | ||
316 | |||
317 | /* | ||
318 | * Bits 0-4 can be used for software handshaking; they're set from | ||
319 | * one end, cleared from the other, "read" with the interrupt byte. | ||
320 | */ | ||
321 | #define PL_S_EN (1<<7) /* (feature only) suspend enable */ | ||
322 | /* reserved bit -- rx ready (6) ? */ | ||
323 | #define PL_TX_READY (1<<5) /* (interrupt only) transmit ready */ | ||
324 | #define PL_RESET_OUT (1<<4) /* reset output pipe */ | ||
325 | #define PL_RESET_IN (1<<3) /* reset input pipe */ | ||
326 | #define PL_TX_C (1<<2) /* transmission complete */ | ||
327 | #define PL_TX_REQ (1<<1) /* transmission received */ | ||
328 | #define PL_PEER_E (1<<0) /* peer exists */ | ||
329 | |||
330 | static inline int | ||
331 | pl_vendor_req (struct usbnet *dev, u8 req, u8 val, u8 index) | ||
332 | { | ||
333 | return usb_control_msg (dev->udev, | ||
334 | usb_rcvctrlpipe (dev->udev, 0), | ||
335 | req, | ||
336 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
337 | val, index, | ||
338 | NULL, 0, | ||
339 | USB_CTRL_GET_TIMEOUT); | ||
340 | } | ||
341 | |||
342 | static inline int | ||
343 | pl_clear_QuickLink_features (struct usbnet *dev, int val) | ||
344 | { | ||
345 | return pl_vendor_req (dev, 1, (u8) val, 0); | ||
346 | } | ||
347 | |||
348 | static inline int | ||
349 | pl_set_QuickLink_features (struct usbnet *dev, int val) | ||
350 | { | ||
351 | return pl_vendor_req (dev, 3, (u8) val, 0); | ||
352 | } | ||
353 | |||
354 | /*-------------------------------------------------------------------------*/ | ||
355 | |||
356 | static int pl_reset (struct usbnet *dev) | ||
357 | { | ||
358 | /* some units seem to need this reset, others reject it utterly. | ||
359 | * FIXME be more like "naplink" or windows drivers. | ||
360 | */ | ||
361 | (void) pl_set_QuickLink_features (dev, | ||
362 | PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E); | ||
363 | return 0; | ||
364 | } | ||
365 | |||
366 | static const struct driver_info prolific_info = { | ||
367 | .description = "Prolific PL-2301/PL-2302", | ||
368 | .flags = FLAG_NO_SETINT, | ||
369 | /* some PL-2302 versions seem to fail usb_set_interface() */ | ||
370 | .reset = pl_reset, | ||
371 | }; | ||
372 | |||
373 | #endif /* CONFIG_USB_PL2301 */ | ||
374 | |||
375 | |||
376 | /*------------------------------------------------------------------------- | 224 | /*------------------------------------------------------------------------- |
377 | * | 225 | * |
378 | * Network Device Driver (peer link to "Host Device", from USB host) | 226 | * Network Device Driver (peer link to "Host Device", from USB host) |
@@ -1356,60 +1204,22 @@ EXPORT_SYMBOL_GPL(usbnet_resume); | |||
1356 | 1204 | ||
1357 | /*-------------------------------------------------------------------------*/ | 1205 | /*-------------------------------------------------------------------------*/ |
1358 | 1206 | ||
1359 | #ifndef HAVE_HARDWARE | ||
1360 | #error You need to configure some hardware for this driver | ||
1361 | #endif | ||
1362 | |||
1363 | /* | ||
1364 | * chip vendor names won't normally be on the cables, and | ||
1365 | * may not be on the device. | ||
1366 | */ | ||
1367 | |||
1368 | static const struct usb_device_id products [] = { | ||
1369 | |||
1370 | #ifdef CONFIG_USB_PL2301 | ||
1371 | { | ||
1372 | USB_DEVICE (0x067b, 0x0000), // PL-2301 | ||
1373 | .driver_info = (unsigned long) &prolific_info, | ||
1374 | }, { | ||
1375 | USB_DEVICE (0x067b, 0x0001), // PL-2302 | ||
1376 | .driver_info = (unsigned long) &prolific_info, | ||
1377 | }, | ||
1378 | #endif | ||
1379 | { }, // END | ||
1380 | }; | ||
1381 | MODULE_DEVICE_TABLE (usb, products); | ||
1382 | |||
1383 | static struct usb_driver usbnet_driver = { | ||
1384 | .owner = THIS_MODULE, | ||
1385 | .name = driver_name, | ||
1386 | .id_table = products, | ||
1387 | .probe = usbnet_probe, | ||
1388 | .disconnect = usbnet_disconnect, | ||
1389 | .suspend = usbnet_suspend, | ||
1390 | .resume = usbnet_resume, | ||
1391 | }; | ||
1392 | |||
1393 | /*-------------------------------------------------------------------------*/ | ||
1394 | |||
1395 | static int __init usbnet_init(void) | 1207 | static int __init usbnet_init(void) |
1396 | { | 1208 | { |
1397 | // compiler should optimize these out | 1209 | /* compiler should optimize this out */ |
1398 | BUG_ON (sizeof (((struct sk_buff *)0)->cb) | 1210 | BUG_ON (sizeof (((struct sk_buff *)0)->cb) |
1399 | < sizeof (struct skb_data)); | 1211 | < sizeof (struct skb_data)); |
1400 | 1212 | ||
1401 | random_ether_addr(node_id); | 1213 | random_ether_addr(node_id); |
1402 | 1214 | return 0; | |
1403 | return usb_register(&usbnet_driver); | ||
1404 | } | 1215 | } |
1405 | module_init(usbnet_init); | 1216 | module_init(usbnet_init); |
1406 | 1217 | ||
1407 | static void __exit usbnet_exit(void) | 1218 | static void __exit usbnet_exit(void) |
1408 | { | 1219 | { |
1409 | usb_deregister(&usbnet_driver); | ||
1410 | } | 1220 | } |
1411 | module_exit(usbnet_exit); | 1221 | module_exit(usbnet_exit); |
1412 | 1222 | ||
1413 | MODULE_AUTHOR("David Brownell"); | 1223 | MODULE_AUTHOR("David Brownell"); |
1414 | MODULE_DESCRIPTION("USB Host-to-Host Link Drivers (numerous vendors)"); | 1224 | MODULE_DESCRIPTION("USB network driver framework"); |
1415 | MODULE_LICENSE("GPL"); | 1225 | MODULE_LICENSE("GPL"); |