⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdc_subset.c

📁 omap3 linux 2.6 用nocc去除了冗余代码
💻 C
字号:
/* * Simple "CDC Subset" USB Networking Links * Copyright (C) 2000-2005 by David Brownell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include <linux/module.h>#include <linux/kmod.h>#include <linux/init.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/ethtool.h>#include <linux/workqueue.h>#include <linux/mii.h>#include <linux/usb.h>#include "usbnet.h"/* * This supports simple USB network links that don't require any special * framing or hardware control operations.  The protocol used here is a * strict subset of CDC Ethernet, with three basic differences reflecting * the goal that almost any hardware should run it: * *  - Minimal runtime control:  one interface, no altsettings, and *    no vendor or class specific control requests.  If a device is *    configured, it is allowed to exchange packets with the host. *    Fancier models would mean not working on some hardware. * *  - Minimal manufacturing control:  no IEEE "Organizationally *    Unique ID" required, or an EEPROMs to store one.  Each host uses *    one random "locally assigned" Ethernet address instead, which can *    of course be overridden using standard tools like "ifconfig". *    (With 2^46 such addresses, same-net collisions are quite rare.) * *  - There is no additional framing data for USB.  Packets are written *    exactly as in CDC Ethernet, starting with an Ethernet header and *    terminated by a short packet.  However, the host will never send a *    zero length packet; some systems can't handle those robustly. * * Anything that can transmit and receive USB bulk packets can implement * this protocol.  That includes both smart peripherals and quite a lot * of "host-to-host" USB cables (which embed two devices back-to-back). * * Note that although Linux may use many of those host-to-host links * with this "cdc_subset" framing, that doesn't mean there may not be a * better approach.  Handling the "other end unplugs/replugs" scenario * well tends to require chip-specific vendor requests.  Also, Windows * peers at the other end of host-to-host cables may expect their own * framing to be used rather than this "cdc_subset" model. *//* PDA style devices are always connected if present */static int always_connected (struct usbnet *dev){	return 0;}#define	HAVE_HARDWARE/*------------------------------------------------------------------------- * * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller * * ... also two eTEK designs, including one sold as "Advance USBNET" * *-------------------------------------------------------------------------*/static const struct driver_info	belkin_info = {	.description =	"Belkin, eTEK, or compatible",};/*------------------------------------------------------------------------- * * info from Jonathan McDowell <noodles@earth.li> * *-------------------------------------------------------------------------*/#define	HAVE_HARDWARE/*------------------------------------------------------------------------- * * Intel's SA-1100 chip integrates basic USB support, and is used * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to * network using minimal USB framing data. * * This describes the driver currently in standard ARM Linux kernels. * The Zaurus uses a different driver (see later). * * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support * and different USB endpoint numbering than the SA1100 devices.  The * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 * so we rely on the endpoint descriptors. * *-------------------------------------------------------------------------*/static const struct driver_info	linuxdev_info = {	.description =	"Linux Device",	.check_connect = always_connected,};static const struct driver_info	yopy_info = {	.description =	"Yopy",	.check_connect = always_connected,};static const struct driver_info	blob_info = {	.description =	"Boot Loader OBject",	.check_connect = always_connected,};/*-------------------------------------------------------------------------*//* * chip vendor names won't normally be on the cables, and * may not be on the device. */static const struct usb_device_id	products [] = {{	USB_DEVICE (0x050d, 0x0004),	// Belkin	.driver_info =	(unsigned long) &belkin_info,}, {	USB_DEVICE (0x056c, 0x8100),	// eTEK	.driver_info =	(unsigned long) &belkin_info,}, {	USB_DEVICE (0x0525, 0x9901),	// Advance USBNET (eTEK)	.driver_info =	(unsigned long) &belkin_info,},/* * SA-1100 using standard ARM Linux kernels, or compatible. * Often used when talking to Linux PDAs (iPaq, Yopy, etc). * The sa-1100 "usb-eth" driver handles the basic framing. * * PXA25x or PXA210 ...  these use a "usb-eth" driver much like * the sa1100 one, but hardware uses different endpoint numbers. * * Or the Linux "Ethernet" gadget on hardware that can't talk * CDC Ethernet (e.g., no altsettings), in either of two modes: *  - acting just like the old "usb-eth" firmware, though *    the implementation is different *  - supporting RNDIS as the first/default configuration for *    MS-Windows interop; Linux needs to use the other config */{	// 1183 = 0x049F, both used as hex values?	// Compaq "Itsy" vendor/product id	USB_DEVICE (0x049F, 0x505A),	// usb-eth, or compatible	.driver_info =	(unsigned long) &linuxdev_info,}, {	USB_DEVICE (0x0E7E, 0x1001),	// G.Mate "Yopy"	.driver_info =	(unsigned long) &yopy_info,}, {	USB_DEVICE (0x8086, 0x07d3),	// "blob" bootloader	.driver_info =	(unsigned long) &blob_info,}, {	// Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config	// e.g. Gumstix, current OpenZaurus, ...	USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),	.driver_info =	(unsigned long) &linuxdev_info,},	{ },		// END};MODULE_DEVICE_TABLE(usb, products);/*-------------------------------------------------------------------------*/static struct usb_driver cdc_subset_driver = {	.name =		"cdc_subset",	.probe =	usbnet_probe,	.suspend =	usbnet_suspend,	.resume =	usbnet_resume,	.disconnect =	usbnet_disconnect,	.id_table =	products,};static int __init cdc_subset_init(void){	return usb_register(&cdc_subset_driver);}module_init(cdc_subset_init);static void __exit cdc_subset_exit(void){	usb_deregister(&cdc_subset_driver);}module_exit(cdc_subset_exit);MODULE_AUTHOR("David Brownell");MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links");MODULE_LICENSE("GPL");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -