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