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