]>
Commit | Line | Data |
---|---|---|
38bde1d4 DB |
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 | ||
38bde1d4 DB |
20 | #include <linux/module.h> |
21 | #include <linux/kmod.h> | |
38bde1d4 DB |
22 | #include <linux/init.h> |
23 | #include <linux/netdevice.h> | |
24 | #include <linux/etherdevice.h> | |
25 | #include <linux/ethtool.h> | |
26 | #include <linux/workqueue.h> | |
27 | #include <linux/mii.h> | |
28 | #include <linux/usb.h> | |
3692e94f | 29 | #include <linux/usb/usbnet.h> |
38bde1d4 DB |
30 | |
31 | ||
32 | /* | |
33 | * This supports simple USB network links that don't require any special | |
34 | * framing or hardware control operations. The protocol used here is a | |
35 | * strict subset of CDC Ethernet, with three basic differences reflecting | |
36 | * the goal that almost any hardware should run it: | |
37 | * | |
38 | * - Minimal runtime control: one interface, no altsettings, and | |
39 | * no vendor or class specific control requests. If a device is | |
40 | * configured, it is allowed to exchange packets with the host. | |
41 | * Fancier models would mean not working on some hardware. | |
42 | * | |
43 | * - Minimal manufacturing control: no IEEE "Organizationally | |
44 | * Unique ID" required, or an EEPROMs to store one. Each host uses | |
45 | * one random "locally assigned" Ethernet address instead, which can | |
46 | * of course be overridden using standard tools like "ifconfig". | |
47 | * (With 2^46 such addresses, same-net collisions are quite rare.) | |
48 | * | |
49 | * - There is no additional framing data for USB. Packets are written | |
50 | * exactly as in CDC Ethernet, starting with an Ethernet header and | |
51 | * terminated by a short packet. However, the host will never send a | |
52 | * zero length packet; some systems can't handle those robustly. | |
53 | * | |
54 | * Anything that can transmit and receive USB bulk packets can implement | |
55 | * this protocol. That includes both smart peripherals and quite a lot | |
56 | * of "host-to-host" USB cables (which embed two devices back-to-back). | |
57 | * | |
58 | * Note that although Linux may use many of those host-to-host links | |
59 | * with this "cdc_subset" framing, that doesn't mean there may not be a | |
60 | * better approach. Handling the "other end unplugs/replugs" scenario | |
61 | * well tends to require chip-specific vendor requests. Also, Windows | |
62 | * peers at the other end of host-to-host cables may expect their own | |
63 | * framing to be used rather than this "cdc_subset" model. | |
64 | */ | |
65 | ||
66 | #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) | |
67 | /* PDA style devices are always connected if present */ | |
68 | static int always_connected (struct usbnet *dev) | |
69 | { | |
70 | return 0; | |
71 | } | |
72 | #endif | |
73 | ||
74 | #ifdef CONFIG_USB_ALI_M5632 | |
75 | #define HAVE_HARDWARE | |
76 | ||
77 | /*------------------------------------------------------------------------- | |
78 | * | |
79 | * ALi M5632 driver ... does high speed | |
80 | * | |
6e91f527 DB |
81 | * NOTE that the MS-Windows drivers for this chip use some funky and |
82 | * (naturally) undocumented 7-byte prefix to each packet, so this is a | |
83 | * case where we don't currently interoperate. Also, once you unplug | |
84 | * one end of the cable, you need to replug the other end too ... since | |
85 | * chip docs are unavailable, there's no way to reset the relevant state | |
86 | * short of a power cycle. | |
87 | * | |
38bde1d4 DB |
88 | *-------------------------------------------------------------------------*/ |
89 | ||
90 | static const struct driver_info ali_m5632_info = { | |
91 | .description = "ALi M5632", | |
92 | }; | |
93 | ||
38bde1d4 DB |
94 | #endif |
95 | ||
96 | \f | |
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 | \f | |
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 | \f | |
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 | \f | |
691895c6 DB |
167 | /*------------------------------------------------------------------------- |
168 | * | |
169 | * info from Jonathan McDowell <noodles@earth.li> | |
170 | * | |
171 | *-------------------------------------------------------------------------*/ | |
38bde1d4 DB |
172 | #ifdef CONFIG_USB_KC2190 |
173 | #define HAVE_HARDWARE | |
174 | static const struct driver_info kc2190_info = { | |
175 | .description = "KC Technology KC-190", | |
176 | }; | |
177 | #endif /* CONFIG_USB_KC2190 */ | |
178 | ||
179 | \f | |
180 | #ifdef CONFIG_USB_ARMLINUX | |
181 | #define HAVE_HARDWARE | |
182 | ||
183 | /*------------------------------------------------------------------------- | |
184 | * | |
185 | * Intel's SA-1100 chip integrates basic USB support, and is used | |
186 | * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. | |
187 | * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to | |
188 | * network using minimal USB framing data. | |
189 | * | |
190 | * This describes the driver currently in standard ARM Linux kernels. | |
191 | * The Zaurus uses a different driver (see later). | |
192 | * | |
193 | * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support | |
194 | * and different USB endpoint numbering than the SA1100 devices. The | |
195 | * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 | |
196 | * so we rely on the endpoint descriptors. | |
197 | * | |
198 | *-------------------------------------------------------------------------*/ | |
199 | ||
200 | static const struct driver_info linuxdev_info = { | |
201 | .description = "Linux Device", | |
202 | .check_connect = always_connected, | |
203 | }; | |
204 | ||
205 | static const struct driver_info yopy_info = { | |
206 | .description = "Yopy", | |
207 | .check_connect = always_connected, | |
208 | }; | |
209 | ||
210 | static const struct driver_info blob_info = { | |
211 | .description = "Boot Loader OBject", | |
212 | .check_connect = always_connected, | |
213 | }; | |
214 | ||
215 | #endif /* CONFIG_USB_ARMLINUX */ | |
216 | ||
217 | \f | |
218 | /*-------------------------------------------------------------------------*/ | |
219 | ||
220 | #ifndef HAVE_HARDWARE | |
f82b9878 | 221 | #warning You need to configure some hardware for this driver |
38bde1d4 DB |
222 | #endif |
223 | ||
224 | /* | |
225 | * chip vendor names won't normally be on the cables, and | |
226 | * may not be on the device. | |
227 | */ | |
228 | ||
229 | static const struct usb_device_id products [] = { | |
230 | ||
231 | #ifdef CONFIG_USB_ALI_M5632 | |
232 | { | |
233 | USB_DEVICE (0x0402, 0x5632), // ALi defaults | |
234 | .driver_info = (unsigned long) &ali_m5632_info, | |
235 | }, | |
6e91f527 DB |
236 | { |
237 | USB_DEVICE (0x182d,0x207c), // SiteCom CN-124 | |
238 | .driver_info = (unsigned long) &ali_m5632_info, | |
239 | }, | |
38bde1d4 DB |
240 | #endif |
241 | ||
242 | #ifdef CONFIG_USB_AN2720 | |
243 | { | |
244 | USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults | |
245 | .driver_info = (unsigned long) &an2720_info, | |
246 | }, { | |
247 | USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET | |
248 | .driver_info = (unsigned long) &an2720_info, | |
249 | }, | |
250 | #endif | |
251 | ||
252 | #ifdef CONFIG_USB_BELKIN | |
253 | { | |
254 | USB_DEVICE (0x050d, 0x0004), // Belkin | |
255 | .driver_info = (unsigned long) &belkin_info, | |
256 | }, { | |
257 | USB_DEVICE (0x056c, 0x8100), // eTEK | |
258 | .driver_info = (unsigned long) &belkin_info, | |
259 | }, { | |
260 | USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) | |
261 | .driver_info = (unsigned long) &belkin_info, | |
262 | }, | |
263 | #endif | |
264 | ||
265 | #ifdef CONFIG_USB_EPSON2888 | |
266 | { | |
267 | USB_DEVICE (0x0525, 0x2888), // EPSON USB client | |
268 | .driver_info = (unsigned long) &epson2888_info, | |
269 | }, | |
270 | #endif | |
271 | ||
272 | #ifdef CONFIG_USB_KC2190 | |
273 | { | |
274 | USB_DEVICE (0x050f, 0x0190), // KC-190 | |
275 | .driver_info = (unsigned long) &kc2190_info, | |
276 | }, | |
277 | #endif | |
278 | ||
279 | #ifdef CONFIG_USB_ARMLINUX | |
280 | /* | |
281 | * SA-1100 using standard ARM Linux kernels, or compatible. | |
282 | * Often used when talking to Linux PDAs (iPaq, Yopy, etc). | |
283 | * The sa-1100 "usb-eth" driver handles the basic framing. | |
284 | * | |
285 | * PXA25x or PXA210 ... these use a "usb-eth" driver much like | |
286 | * the sa1100 one, but hardware uses different endpoint numbers. | |
287 | * | |
288 | * Or the Linux "Ethernet" gadget on hardware that can't talk | |
289 | * CDC Ethernet (e.g., no altsettings), in either of two modes: | |
290 | * - acting just like the old "usb-eth" firmware, though | |
291 | * the implementation is different | |
292 | * - supporting RNDIS as the first/default configuration for | |
293 | * MS-Windows interop; Linux needs to use the other config | |
294 | */ | |
295 | { | |
296 | // 1183 = 0x049F, both used as hex values? | |
297 | // Compaq "Itsy" vendor/product id | |
298 | USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible | |
299 | .driver_info = (unsigned long) &linuxdev_info, | |
300 | }, { | |
301 | USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" | |
302 | .driver_info = (unsigned long) &yopy_info, | |
303 | }, { | |
304 | USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader | |
305 | .driver_info = (unsigned long) &blob_info, | |
d4f01a77 | 306 | }, { |
307 | USB_DEVICE (0x1286, 0x8001), // "blob" bootloader | |
308 | .driver_info = (unsigned long) &blob_info, | |
38bde1d4 DB |
309 | }, { |
310 | // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config | |
311 | // e.g. Gumstix, current OpenZaurus, ... | |
312 | USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), | |
313 | .driver_info = (unsigned long) &linuxdev_info, | |
314 | }, | |
315 | #endif | |
316 | ||
317 | { }, // END | |
318 | }; | |
319 | MODULE_DEVICE_TABLE(usb, products); | |
320 | ||
321 | /*-------------------------------------------------------------------------*/ | |
322 | ||
323 | static struct usb_driver cdc_subset_driver = { | |
38bde1d4 DB |
324 | .name = "cdc_subset", |
325 | .probe = usbnet_probe, | |
326 | .suspend = usbnet_suspend, | |
327 | .resume = usbnet_resume, | |
328 | .disconnect = usbnet_disconnect, | |
329 | .id_table = products, | |
330 | }; | |
331 | ||
332 | static int __init cdc_subset_init(void) | |
333 | { | |
6e91f527 | 334 | return usb_register(&cdc_subset_driver); |
38bde1d4 DB |
335 | } |
336 | module_init(cdc_subset_init); | |
337 | ||
338 | static void __exit cdc_subset_exit(void) | |
339 | { | |
6e91f527 | 340 | usb_deregister(&cdc_subset_driver); |
38bde1d4 DB |
341 | } |
342 | module_exit(cdc_subset_exit); | |
343 | ||
344 | MODULE_AUTHOR("David Brownell"); | |
345 | MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); | |
346 | MODULE_LICENSE("GPL"); |