OpenCores
URL https://opencores.org/ocsvn/test_project/test_project/trunk

Subversion Repositories test_project

[/] [test_project/] [trunk/] [linux_sd_driver/] [drivers/] [net/] [usb/] [cdc_subset.c] - Blame information for rev 62

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 62 marcus.erl
/*
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
 * NOTE that the MS-Windows drivers for this chip use some funky and
83
 * (naturally) undocumented 7-byte prefix to each packet, so this is a
84
 * case where we don't currently interoperate.  Also, once you unplug
85
 * one end of the cable, you need to replug the other end too ... since
86
 * chip docs are unavailable, there's no way to reset the relevant state
87
 * short of a power cycle.
88
 *
89
 *-------------------------------------------------------------------------*/
90
 
91
static const struct driver_info ali_m5632_info = {
92
        .description =  "ALi M5632",
93
};
94
 
95
#endif
96
 
97
 
98
#ifdef  CONFIG_USB_AN2720
99
#define HAVE_HARDWARE
100
 
101
/*-------------------------------------------------------------------------
102
 *
103
 * AnchorChips 2720 driver ... http://www.cypress.com
104
 *
105
 * This doesn't seem to have a way to detect whether the peer is
106
 * connected, or need any reset handshaking.  It's got pretty big
107
 * internal buffers (handles most of a frame's worth of data).
108
 * Chip data sheets don't describe any vendor control messages.
109
 *
110
 *-------------------------------------------------------------------------*/
111
 
112
static const struct driver_info an2720_info = {
113
        .description =  "AnchorChips/Cypress 2720",
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
 
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",
136
};
137
 
138
#endif  /* CONFIG_USB_BELKIN */
139
 
140
 
141
 
142
#ifdef  CONFIG_USB_EPSON2888
143
#define HAVE_HARDWARE
144
 
145
/*-------------------------------------------------------------------------
146
 *
147
 * EPSON USB clients
148
 *
149
 * This is the same idea as Linux PDAs (below) except the firmware in the
150
 * device might not be Tux-powered.  Epson provides reference firmware that
151
 * implements this interface.  Product developers can reuse or modify that
152
 * code, such as by using their own product and vendor codes.
153
 *
154
 * Support was from Juro Bystricky <bystricky.juro@erd.epson.com>
155
 *
156
 *-------------------------------------------------------------------------*/
157
 
158
static const struct driver_info epson2888_info = {
159
        .description =  "Epson USB Device",
160
        .check_connect = always_connected,
161
 
162
        .in = 4, .out = 3,
163
};
164
 
165
#endif  /* CONFIG_USB_EPSON2888 */
166
 
167
 
168
/*-------------------------------------------------------------------------
169
 *
170
 * info from Jonathan McDowell <noodles@earth.li>
171
 *
172
 *-------------------------------------------------------------------------*/
173
#ifdef CONFIG_USB_KC2190
174
#define HAVE_HARDWARE
175
static const struct driver_info kc2190_info = {
176
        .description =  "KC Technology KC-190",
177
};
178
#endif /* CONFIG_USB_KC2190 */
179
 
180
 
181
#ifdef  CONFIG_USB_ARMLINUX
182
#define HAVE_HARDWARE
183
 
184
/*-------------------------------------------------------------------------
185
 *
186
 * Intel's SA-1100 chip integrates basic USB support, and is used
187
 * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more.
188
 * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to
189
 * network using minimal USB framing data.
190
 *
191
 * This describes the driver currently in standard ARM Linux kernels.
192
 * The Zaurus uses a different driver (see later).
193
 *
194
 * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support
195
 * and different USB endpoint numbering than the SA1100 devices.  The
196
 * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100
197
 * so we rely on the endpoint descriptors.
198
 *
199
 *-------------------------------------------------------------------------*/
200
 
201
static const struct driver_info linuxdev_info = {
202
        .description =  "Linux Device",
203
        .check_connect = always_connected,
204
};
205
 
206
static const struct driver_info yopy_info = {
207
        .description =  "Yopy",
208
        .check_connect = always_connected,
209
};
210
 
211
static const struct driver_info blob_info = {
212
        .description =  "Boot Loader OBject",
213
        .check_connect = always_connected,
214
};
215
 
216
#endif  /* CONFIG_USB_ARMLINUX */
217
 
218
 
219
/*-------------------------------------------------------------------------*/
220
 
221
#ifndef HAVE_HARDWARE
222
#error You need to configure some hardware for this driver
223
#endif
224
 
225
/*
226
 * chip vendor names won't normally be on the cables, and
227
 * may not be on the device.
228
 */
229
 
230
static const struct usb_device_id       products [] = {
231
 
232
#ifdef  CONFIG_USB_ALI_M5632
233
{
234
        USB_DEVICE (0x0402, 0x5632),    // ALi defaults
235
        .driver_info =  (unsigned long) &ali_m5632_info,
236
},
237
{
238
        USB_DEVICE (0x182d,0x207c),     // SiteCom CN-124
239
        .driver_info =  (unsigned long) &ali_m5632_info,
240
},
241
#endif
242
 
243
#ifdef  CONFIG_USB_AN2720
244
{
245
        USB_DEVICE (0x0547, 0x2720),    // AnchorChips defaults
246
        .driver_info =  (unsigned long) &an2720_info,
247
}, {
248
        USB_DEVICE (0x0547, 0x2727),    // Xircom PGUNET
249
        .driver_info =  (unsigned long) &an2720_info,
250
},
251
#endif
252
 
253
#ifdef  CONFIG_USB_BELKIN
254
{
255
        USB_DEVICE (0x050d, 0x0004),    // Belkin
256
        .driver_info =  (unsigned long) &belkin_info,
257
}, {
258
        USB_DEVICE (0x056c, 0x8100),    // eTEK
259
        .driver_info =  (unsigned long) &belkin_info,
260
}, {
261
        USB_DEVICE (0x0525, 0x9901),    // Advance USBNET (eTEK)
262
        .driver_info =  (unsigned long) &belkin_info,
263
},
264
#endif
265
 
266
#ifdef  CONFIG_USB_EPSON2888
267
{
268
        USB_DEVICE (0x0525, 0x2888),    // EPSON USB client
269
        .driver_info    = (unsigned long) &epson2888_info,
270
},
271
#endif
272
 
273
#ifdef CONFIG_USB_KC2190
274
{
275
        USB_DEVICE (0x050f, 0x0190),    // KC-190
276
        .driver_info =  (unsigned long) &kc2190_info,
277
},
278
#endif
279
 
280
#ifdef  CONFIG_USB_ARMLINUX
281
/*
282
 * SA-1100 using standard ARM Linux kernels, or compatible.
283
 * Often used when talking to Linux PDAs (iPaq, Yopy, etc).
284
 * The sa-1100 "usb-eth" driver handles the basic framing.
285
 *
286
 * PXA25x or PXA210 ...  these use a "usb-eth" driver much like
287
 * the sa1100 one, but hardware uses different endpoint numbers.
288
 *
289
 * Or the Linux "Ethernet" gadget on hardware that can't talk
290
 * CDC Ethernet (e.g., no altsettings), in either of two modes:
291
 *  - acting just like the old "usb-eth" firmware, though
292
 *    the implementation is different
293
 *  - supporting RNDIS as the first/default configuration for
294
 *    MS-Windows interop; Linux needs to use the other config
295
 */
296
{
297
        // 1183 = 0x049F, both used as hex values?
298
        // Compaq "Itsy" vendor/product id
299
        USB_DEVICE (0x049F, 0x505A),    // usb-eth, or compatible
300
        .driver_info =  (unsigned long) &linuxdev_info,
301
}, {
302
        USB_DEVICE (0x0E7E, 0x1001),    // G.Mate "Yopy"
303
        .driver_info =  (unsigned long) &yopy_info,
304
}, {
305
        USB_DEVICE (0x8086, 0x07d3),    // "blob" bootloader
306
        .driver_info =  (unsigned long) &blob_info,
307
}, {
308
        USB_DEVICE (0x1286, 0x8001),    // "blob" bootloader
309
        .driver_info =  (unsigned long) &blob_info,
310
}, {
311
        // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config
312
        // e.g. Gumstix, current OpenZaurus, ...
313
        USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
314
        .driver_info =  (unsigned long) &linuxdev_info,
315
},
316
#endif
317
 
318
        { },            // END
319
};
320
MODULE_DEVICE_TABLE(usb, products);
321
 
322
/*-------------------------------------------------------------------------*/
323
 
324
static struct usb_driver cdc_subset_driver = {
325
        .name =         "cdc_subset",
326
        .probe =        usbnet_probe,
327
        .suspend =      usbnet_suspend,
328
        .resume =       usbnet_resume,
329
        .disconnect =   usbnet_disconnect,
330
        .id_table =     products,
331
};
332
 
333
static int __init cdc_subset_init(void)
334
{
335
        return usb_register(&cdc_subset_driver);
336
}
337
module_init(cdc_subset_init);
338
 
339
static void __exit cdc_subset_exit(void)
340
{
341
        usb_deregister(&cdc_subset_driver);
342
}
343
module_exit(cdc_subset_exit);
344
 
345
MODULE_AUTHOR("David Brownell");
346
MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links");
347
MODULE_LICENSE("GPL");

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.