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