diff options
Diffstat (limited to 'drivers/usb/net/cdc_subset.c')
-rw-r--r-- | drivers/usb/net/cdc_subset.c | 335 |
1 files changed, 335 insertions, 0 deletions
diff --git a/drivers/usb/net/cdc_subset.c b/drivers/usb/net/cdc_subset.c new file mode 100644 index 000000000000..f1730b685fd2 --- /dev/null +++ b/drivers/usb/net/cdc_subset.c | |||
@@ -0,0 +1,335 @@ | |||
1 | /* | ||
2 | * Simple "CDC Subset" USB Networking Links | ||
3 | * Copyright (C) 2000-2005 by David Brownell | ||
4 | * | ||
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. | ||
9 | * | ||
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. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/config.h> | ||
21 | #ifdef CONFIG_USB_DEBUG | ||
22 | # define DEBUG | ||
23 | #endif | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/kmod.h> | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/netdevice.h> | ||
29 | #include <linux/etherdevice.h> | ||
30 | #include <linux/ethtool.h> | ||
31 | #include <linux/workqueue.h> | ||
32 | #include <linux/mii.h> | ||
33 | #include <linux/usb.h> | ||
34 | |||
35 | #include "usbnet.h" | ||
36 | |||
37 | |||
38 | /* | ||
39 | * This supports simple USB network links that don't require any special | ||
40 | * framing or hardware control operations. The protocol used here is a | ||
41 | * strict subset of CDC Ethernet, with three basic differences reflecting | ||
42 | * the goal that almost any hardware should run it: | ||
43 | * | ||
44 | * - Minimal runtime control: one interface, no altsettings, and | ||
45 | * no vendor or class specific control requests. If a device is | ||
46 | * configured, it is allowed to exchange packets with the host. | ||
47 | * Fancier models would mean not working on some hardware. | ||
48 | * | ||
49 | * - Minimal manufacturing control: no IEEE "Organizationally | ||
50 | * Unique ID" required, or an EEPROMs to store one. Each host uses | ||
51 | * one random "locally assigned" Ethernet address instead, which can | ||
52 | * of course be overridden using standard tools like "ifconfig". | ||
53 | * (With 2^46 such addresses, same-net collisions are quite rare.) | ||
54 | * | ||
55 | * - There is no additional framing data for USB. Packets are written | ||
56 | * exactly as in CDC Ethernet, starting with an Ethernet header and | ||
57 | * terminated by a short packet. However, the host will never send a | ||
58 | * zero length packet; some systems can't handle those robustly. | ||
59 | * | ||
60 | * Anything that can transmit and receive USB bulk packets can implement | ||
61 | * this protocol. That includes both smart peripherals and quite a lot | ||
62 | * of "host-to-host" USB cables (which embed two devices back-to-back). | ||
63 | * | ||
64 | * Note that although Linux may use many of those host-to-host links | ||
65 | * with this "cdc_subset" framing, that doesn't mean there may not be a | ||
66 | * better approach. Handling the "other end unplugs/replugs" scenario | ||
67 | * well tends to require chip-specific vendor requests. Also, Windows | ||
68 | * peers at the other end of host-to-host cables may expect their own | ||
69 | * framing to be used rather than this "cdc_subset" model. | ||
70 | */ | ||
71 | |||
72 | #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) | ||
73 | /* PDA style devices are always connected if present */ | ||
74 | static int always_connected (struct usbnet *dev) | ||
75 | { | ||
76 | return 0; | ||
77 | } | ||
78 | #endif | ||
79 | |||
80 | #ifdef CONFIG_USB_ALI_M5632 | ||
81 | #define HAVE_HARDWARE | ||
82 | |||
83 | /*------------------------------------------------------------------------- | ||
84 | * | ||
85 | * ALi M5632 driver ... does high speed | ||
86 | * | ||
87 | *-------------------------------------------------------------------------*/ | ||
88 | |||
89 | static const struct driver_info ali_m5632_info = { | ||
90 | .description = "ALi M5632", | ||
91 | }; | ||
92 | |||
93 | |||
94 | #endif | ||
95 | |||
96 | |||
97 | #ifdef CONFIG_USB_AN2720 | ||
98 | #define HAVE_HARDWARE | ||
99 | |||
100 | /*------------------------------------------------------------------------- | ||
101 | * | ||
102 | * AnchorChips 2720 driver ... http://www.cypress.com | ||
103 | * | ||
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. | ||
108 | * | ||
109 | *-------------------------------------------------------------------------*/ | ||
110 | |||
111 | static const struct driver_info an2720_info = { | ||
112 | .description = "AnchorChips/Cypress 2720", | ||
113 | // no reset available! | ||
114 | // no check_connect available! | ||
115 | |||
116 | .in = 2, .out = 2, // direction distinguishes these | ||
117 | }; | ||
118 | |||
119 | #endif /* CONFIG_USB_AN2720 */ | ||
120 | |||
121 | |||
122 | #ifdef CONFIG_USB_BELKIN | ||
123 | #define HAVE_HARDWARE | ||
124 | |||
125 | /*------------------------------------------------------------------------- | ||
126 | * | ||
127 | * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller | ||
128 | * | ||
129 | * ... also two eTEK designs, including one sold as "Advance USBNET" | ||
130 | * | ||
131 | *-------------------------------------------------------------------------*/ | ||
132 | |||
133 | static const struct driver_info belkin_info = { | ||
134 | .description = "Belkin, eTEK, or compatible", | ||
135 | }; | ||
136 | |||
137 | #endif /* CONFIG_USB_BELKIN */ | ||
138 | |||
139 | |||
140 | |||
141 | #ifdef CONFIG_USB_EPSON2888 | ||
142 | #define HAVE_HARDWARE | ||
143 | |||
144 | /*------------------------------------------------------------------------- | ||
145 | * | ||
146 | * EPSON USB clients | ||
147 | * | ||
148 | * This is the same idea as Linux PDAs (below) except the firmware in the | ||
149 | * device might not be Tux-powered. Epson provides reference firmware that | ||
150 | * implements this interface. Product developers can reuse or modify that | ||
151 | * code, such as by using their own product and vendor codes. | ||
152 | * | ||
153 | * Support was from Juro Bystricky <bystricky.juro@erd.epson.com> | ||
154 | * | ||
155 | *-------------------------------------------------------------------------*/ | ||
156 | |||
157 | static const struct driver_info epson2888_info = { | ||
158 | .description = "Epson USB Device", | ||
159 | .check_connect = always_connected, | ||
160 | |||
161 | .in = 4, .out = 3, | ||
162 | }; | ||
163 | |||
164 | #endif /* CONFIG_USB_EPSON2888 */ | ||
165 | |||
166 | |||
167 | #ifdef CONFIG_USB_KC2190 | ||
168 | #define HAVE_HARDWARE | ||
169 | static const struct driver_info kc2190_info = { | ||
170 | .description = "KC Technology KC-190", | ||
171 | }; | ||
172 | #endif /* CONFIG_USB_KC2190 */ | ||
173 | |||
174 | |||
175 | #ifdef CONFIG_USB_ARMLINUX | ||
176 | #define HAVE_HARDWARE | ||
177 | |||
178 | /*------------------------------------------------------------------------- | ||
179 | * | ||
180 | * Intel's SA-1100 chip integrates basic USB support, and is used | ||
181 | * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. | ||
182 | * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to | ||
183 | * network using minimal USB framing data. | ||
184 | * | ||
185 | * This describes the driver currently in standard ARM Linux kernels. | ||
186 | * The Zaurus uses a different driver (see later). | ||
187 | * | ||
188 | * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support | ||
189 | * and different USB endpoint numbering than the SA1100 devices. The | ||
190 | * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 | ||
191 | * so we rely on the endpoint descriptors. | ||
192 | * | ||
193 | *-------------------------------------------------------------------------*/ | ||
194 | |||
195 | static const struct driver_info linuxdev_info = { | ||
196 | .description = "Linux Device", | ||
197 | .check_connect = always_connected, | ||
198 | }; | ||
199 | |||
200 | static const struct driver_info yopy_info = { | ||
201 | .description = "Yopy", | ||
202 | .check_connect = always_connected, | ||
203 | }; | ||
204 | |||
205 | static const struct driver_info blob_info = { | ||
206 | .description = "Boot Loader OBject", | ||
207 | .check_connect = always_connected, | ||
208 | }; | ||
209 | |||
210 | #endif /* CONFIG_USB_ARMLINUX */ | ||
211 | |||
212 | |||
213 | /*-------------------------------------------------------------------------*/ | ||
214 | |||
215 | #ifndef HAVE_HARDWARE | ||
216 | #error You need to configure some hardware for this driver | ||
217 | #endif | ||
218 | |||
219 | /* | ||
220 | * chip vendor names won't normally be on the cables, and | ||
221 | * may not be on the device. | ||
222 | */ | ||
223 | |||
224 | static const struct usb_device_id products [] = { | ||
225 | |||
226 | #ifdef CONFIG_USB_ALI_M5632 | ||
227 | { | ||
228 | USB_DEVICE (0x0402, 0x5632), // ALi defaults | ||
229 | .driver_info = (unsigned long) &ali_m5632_info, | ||
230 | }, | ||
231 | #endif | ||
232 | |||
233 | #ifdef CONFIG_USB_AN2720 | ||
234 | { | ||
235 | USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults | ||
236 | .driver_info = (unsigned long) &an2720_info, | ||
237 | }, { | ||
238 | USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET | ||
239 | .driver_info = (unsigned long) &an2720_info, | ||
240 | }, | ||
241 | #endif | ||
242 | |||
243 | #ifdef CONFIG_USB_BELKIN | ||
244 | { | ||
245 | USB_DEVICE (0x050d, 0x0004), // Belkin | ||
246 | .driver_info = (unsigned long) &belkin_info, | ||
247 | }, { | ||
248 | USB_DEVICE (0x056c, 0x8100), // eTEK | ||
249 | .driver_info = (unsigned long) &belkin_info, | ||
250 | }, { | ||
251 | USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) | ||
252 | .driver_info = (unsigned long) &belkin_info, | ||
253 | }, | ||
254 | #endif | ||
255 | |||
256 | #ifdef CONFIG_USB_EPSON2888 | ||
257 | { | ||
258 | USB_DEVICE (0x0525, 0x2888), // EPSON USB client | ||
259 | .driver_info = (unsigned long) &epson2888_info, | ||
260 | }, | ||
261 | #endif | ||
262 | |||
263 | #ifdef CONFIG_USB_KC2190 | ||
264 | { | ||
265 | USB_DEVICE (0x050f, 0x0190), // KC-190 | ||
266 | .driver_info = (unsigned long) &kc2190_info, | ||
267 | }, | ||
268 | #endif | ||
269 | |||
270 | #ifdef CONFIG_USB_ARMLINUX | ||
271 | /* | ||
272 | * SA-1100 using standard ARM Linux kernels, or compatible. | ||
273 | * Often used when talking to Linux PDAs (iPaq, Yopy, etc). | ||
274 | * The sa-1100 "usb-eth" driver handles the basic framing. | ||
275 | * | ||
276 | * PXA25x or PXA210 ... these use a "usb-eth" driver much like | ||
277 | * the sa1100 one, but hardware uses different endpoint numbers. | ||
278 | * | ||
279 | * Or the Linux "Ethernet" gadget on hardware that can't talk | ||
280 | * CDC Ethernet (e.g., no altsettings), in either of two modes: | ||
281 | * - acting just like the old "usb-eth" firmware, though | ||
282 | * the implementation is different | ||
283 | * - supporting RNDIS as the first/default configuration for | ||
284 | * MS-Windows interop; Linux needs to use the other config | ||
285 | */ | ||
286 | { | ||
287 | // 1183 = 0x049F, both used as hex values? | ||
288 | // Compaq "Itsy" vendor/product id | ||
289 | USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible | ||
290 | .driver_info = (unsigned long) &linuxdev_info, | ||
291 | }, { | ||
292 | USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" | ||
293 | .driver_info = (unsigned long) &yopy_info, | ||
294 | }, { | ||
295 | USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader | ||
296 | .driver_info = (unsigned long) &blob_info, | ||
297 | }, { | ||
298 | // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config | ||
299 | // e.g. Gumstix, current OpenZaurus, ... | ||
300 | USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), | ||
301 | .driver_info = (unsigned long) &linuxdev_info, | ||
302 | }, | ||
303 | #endif | ||
304 | |||
305 | { }, // END | ||
306 | }; | ||
307 | MODULE_DEVICE_TABLE(usb, products); | ||
308 | |||
309 | /*-------------------------------------------------------------------------*/ | ||
310 | |||
311 | static struct usb_driver cdc_subset_driver = { | ||
312 | .owner = THIS_MODULE, | ||
313 | .name = "cdc_subset", | ||
314 | .probe = usbnet_probe, | ||
315 | .suspend = usbnet_suspend, | ||
316 | .resume = usbnet_resume, | ||
317 | .disconnect = usbnet_disconnect, | ||
318 | .id_table = products, | ||
319 | }; | ||
320 | |||
321 | static int __init cdc_subset_init(void) | ||
322 | { | ||
323 | return usb_register(&cdc_subset_driver); | ||
324 | } | ||
325 | module_init(cdc_subset_init); | ||
326 | |||
327 | static void __exit cdc_subset_exit(void) | ||
328 | { | ||
329 | usb_deregister(&cdc_subset_driver); | ||
330 | } | ||
331 | module_exit(cdc_subset_exit); | ||
332 | |||
333 | MODULE_AUTHOR("David Brownell"); | ||
334 | MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); | ||
335 | MODULE_LICENSE("GPL"); | ||