diff options
Diffstat (limited to 'packages/linux/files/linux-2.4-usb-gadget.patch')
| -rw-r--r-- | packages/linux/files/linux-2.4-usb-gadget.patch | 29506 |
1 files changed, 0 insertions, 29506 deletions
diff --git a/packages/linux/files/linux-2.4-usb-gadget.patch b/packages/linux/files/linux-2.4-usb-gadget.patch deleted file mode 100644 index 0864ee98f5..0000000000 --- a/packages/linux/files/linux-2.4-usb-gadget.patch +++ /dev/null @@ -1,29506 +0,0 @@ -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/Documentation/Configure.help kernel/Documentation/Configure.help ---- /tmp/kernel/Documentation/Configure.help 2005-04-22 17:52:12.265476882 +0200 -+++ kernel/Documentation/Configure.help 2005-04-22 17:57:15.940717930 +0200 -@@ -23701,6 +23701,163 @@ - brave people. System crashes and other bad things are likely to occur if - you use this driver. If in doubt, select N. - -+CONFIG_USB_GADGET -+ USB is a master/slave protocol, organized with one master -+ host (such as a PC) controlling up to 127 peripheral devices. -+ The USB hardware is asymmetric, which makes it easier to set up: -+ you can't connect two "to-the-host" connectors to each other. -+ -+ Linux can run in the host, or in the peripheral. In both cases -+ you need a low level bus controller driver, and some software -+ talking to it. Peripheral controllers are often discrete silicon, -+ or are integrated with the CPU in a microcontroller. The more -+ familiar host side controllers have names like like "EHCI", "OHCI", -+ or "UHCI", and are usually integrated into southbridges on PC -+ motherboards. -+ -+ Enable this configuration option if you want to run Linux inside -+ a USB peripheral device. Configure one hardware driver for your -+ peripheral/device side bus controller, and a "gadget driver" for -+ your peripheral protocol. (If you use modular gadget drivers, -+ you may configure more than one.) -+ -+ If in doubt, say "N" and don't enable these drivers; most people -+ don't have this kind of hardware (except maybe inside Linux PDAs). -+ -+CONFIG_USB_GADGET_NET2280 -+ NetChip 2280 is a PCI based USB peripheral controller which -+ supports both full and high speed USB 2.0 data transfers. -+ -+ It has six configurable endpoints, as well as endpoint zero -+ (for control transfers) and several endpoints with dedicated -+ functions. -+ -+ Say "y" to link the driver statically, or "m" to build a -+ dynamically linked module called "net2280" and force all -+ gadget drivers to also be dynamically linked. -+ -+CONFIG_USB_GADGET_GOKU -+ The Toshiba TC86C001 is a PCI device which includes controllers -+ for full speed USB devices, IDE, I2C, SIO, plus a USB host (OHCI). -+ -+ The device controller has three configurable (bulk or interrupt) -+ endpoints, plus endpoint zero (for control transfers). -+ -+ Say "y" to link the driver statically, or "m" to build a -+ dynamically linked module called "goku_udc" and force all -+ gadget drivers to also be dynamically linked. -+ -+CONFIG_USB_GADGET_PXA2XX -+ Intel's PXA 2xx series XScale ARM-5TE processors include -+ an integrated full speed USB 1.1 device controller. -+ -+ It has fifteen fixed-function endpoints, as well as endpoint -+ zero (for control transfers). -+ -+ Say "y" to link the driver statically, or "m" to build a -+ dynamically linked module called "pxa2xx_udc" and force all -+ gadget drivers to also be dynamically linked. -+ -+CONFIG_USB_GADGET_SUPERH -+ Some Renesas SuperH processors (SH7705, SH7727...) include an -+ integrated high speed USB 1.1 device controller. -+ -+ It has three fixed-function endpoints, as well as endpoint zero (for -+ control transfers). -+ -+ Say "y" to link the driver statically, or "m" to build a -+ dynamically linked module called "superh_udc" and force all -+ gadget drivers to also be dynamically linked. -+ -+CONFIG_USB_ZERO -+ Gadget Zero is a two-configuration device. It either sinks and -+ sources bulk data; or it loops back a configurable number of -+ transfers. It also implements control requests, for "chapter 9" -+ conformance. The driver needs only two bulk-capable endpoints, so -+ it can work on top of most device-side usb controllers. It's -+ useful for testing, and is also a working example showing how -+ USB "gadget drivers" can be written. -+ -+ Make this be the first driver you try using on top of any new -+ USB peripheral controller driver. Then you can use host-side -+ test software, like the "usbtest" driver, to put your hardware -+ and its driver through a basic set of functional tests. -+ -+ Gadget Zero also works with the host-side "usb-skeleton" driver, -+ and with many kinds of host-side test software. You may need -+ to tweak product and vendor IDs before host software knows about -+ this device, and arrange to select an appropriate configuration. -+ -+ Say "y" to link the driver statically, or "m" to build a -+ dynamically linked module called "g_zero". -+ -+CONFIG_USB_ETH -+ This driver implements Ethernet style communication, in either -+ of two ways: -+ -+ - The "Communication Device Class" (CDC) Ethernet Control Model. -+ That protocol is often avoided with pure Ethernet adapters, in -+ favor of simpler vendor-specific hardware, but is widely -+ supported by firmware for smart network devices. -+ -+ - On hardware can't implement that protocol, a simpler approach -+ is used, placing fewer demands on USB. -+ -+ Within the USB device, this gadget driver exposes a network device -+ "usbX", where X depends on what other networking devices you have. -+ Treat it like a two-node Ethernet link: host, and gadget. -+ -+ The Linux-USB host-side "usbnet" driver interoperates with this -+ driver, so that deep I/O queues can be supported. On 2.4 kernels, -+ use "CDCEther" instead, if you're using the CDC option. That CDC -+ mode should also interoperate with standard CDC Ethernet class -+ drivers on other host operating systems. -+ -+ Say "y" to link the driver statically, or "m" to build a -+ dynamically linked module called "g_ether". -+ -+CONFIG_USB_ETH_RNDIS -+ Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, -+ and Microsoft provides redistributable binary RNDIS drivers for -+ older versions of Windows. -+ -+ If you say "y" here, the Ethernet gadget driver will try to provide -+ a second device configuration, supporting RNDIS to talk to such -+ Microsoft USB hosts. -+ -+CONFIG_USB_FILE_STORAGE -+ The File-backed Storage Gadget acts as a USB Mass Storage -+ disk drive. As its storage repository it can use a regular -+ file or a block device (in much the same way as the "loop" -+ device driver), specified as a module parameter. -+ -+CONFIG_USB_FILE_STORAGE_TEST -+ Say "y" to generate the larger testing version of the -+ File-backed Storage Gadget, useful for probing the -+ behavior of USB Mass Storage hosts. Not needed for -+ normal operation. -+ -+CONFIG_USB_ETH_RNDIS -+ Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, -+ and Microsoft provides redistributable binary RNDIS drivers for -+ older versions of Windows. -+ -+ If you say "y" here, the Ethernet gadget driver will try to provide -+ a second device configuration, supporting RNDIS to talk to such -+ Microsoft USB hosts. -+ -+CONFIG_USB_FILE_STORAGE -+ The File-backed Storage Gadget acts as a USB Mass Storage -+ disk drive. As its storage repository it can use a regular -+ file or a block device (in much the same way as the "loop" -+ device driver), specified as a module parameter. -+ -+CONFIG_USB_FILE_STORAGE_TEST -+ Say "y" to generate the larger testing version of the -+ File-backed Storage Gadget, useful for probing the -+ behavior of USB Mass Storage hosts. Not needed for -+ normal operation. -+ - Winbond W83977AF IrDA Device Driver - CONFIG_WINBOND_FIR - Say Y here if you want to build IrDA support for the Winbond -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/Makefile kernel/Makefile ---- /tmp/kernel/Makefile 2005-04-22 17:52:12.362461090 +0200 -+++ kernel/Makefile 2005-04-22 17:53:19.374549284 +0200 -@@ -196,6 +196,7 @@ - DRIVERS-$(CONFIG_HAMRADIO) += drivers/net/hamradio/hamradio.o - DRIVERS-$(CONFIG_TC) += drivers/tc/tc.a - DRIVERS-$(CONFIG_USB) += drivers/usb/usbdrv.o -+DRIVERS-$(CONFIG_USB_GADGET) += drivers/usb/gadget/built-in.o - DRIVERS-$(CONFIG_LAB) += drivers/bootldr/labmod.o - DRIVERS-$(CONFIG_INPUT) += drivers/input/inputdrv.o - DRIVERS-$(CONFIG_I2O) += drivers/message/i2o/i2o.o -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/drivers/Makefile kernel/drivers/Makefile ---- /tmp/kernel/drivers/Makefile 2005-04-22 17:52:12.728401503 +0200 -+++ kernel/drivers/Makefile 2005-04-22 17:53:19.523525026 +0200 -@@ -27,6 +27,7 @@ - subdir-$(CONFIG_MAC) += macintosh - subdir-$(CONFIG_PPC) += macintosh - subdir-$(CONFIG_USB) += usb -+subdir-$(CONFIG_USB_GADGET) += usb/gadget - subdir-$(CONFIG_INPUT) += input - subdir-$(CONFIG_PHONE) += telephony - subdir-$(CONFIG_SGI) += sgi -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/drivers/usb/Config.in kernel/drivers/usb/Config.in ---- /tmp/kernel/drivers/usb/Config.in 2005-04-22 17:52:20.663109467 +0200 -+++ kernel/drivers/usb/Config.in 2005-04-22 17:53:19.376548959 +0200 -@@ -120,4 +120,7 @@ - dep_tristate ' USB Auerswald ISDN support (EXPERIMENTAL)' CONFIG_USB_AUERSWALD $CONFIG_USB $CONFIG_EXPERIMENTAL - dep_tristate ' Tieman Voyager USB Braille display support (EXPERIMENTAL)' CONFIG_USB_BRLVGER $CONFIG_USB $CONFIG_EXPERIMENTAL - fi -+ -+source drivers/usb/gadget/Config.in -+ - endmenu -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/drivers/usb/gadget/Config.in kernel/drivers/usb/gadget/Config.in ---- /tmp/kernel/drivers/usb/gadget/Config.in 1970-01-01 01:00:00.000000000 +0100 -+++ kernel/drivers/usb/gadget/Config.in 2005-04-22 17:53:19.403544563 +0200 -@@ -0,0 +1,128 @@ -+# -+# USB device-side configuration -+# for 2.4 kbuild, drivers/usb/gadget/Config.in -+# -+# Long term, this likely doesn't all belong in one directory -+# Plan to split it up eventually. -+# -+mainmenu_option next_comment -+comment 'Support for USB gadgets' -+ -+tristate 'Support for USB Gadgets' CONFIG_USB_GADGET -+if [ "$CONFIG_USB_GADGET" = "y" -o "$CONFIG_USB_GADGET" = "m" ]; then -+ -+ # -+ # really want _exactly one_ device controller driver at a time, -+ # since they control compile options for gadget drivers. -+ # -+ choice 'USB Peripheral Controller Driver' "\ -+ Intel-PXA2xx/IXP4xx CONFIG_USB_GADGET_PXA2XX \ -+ National-N9603/N9604 CONFIG_USB_GADGET_N9604 \ -+ NetChip-2280 CONFIG_USB_GADGET_NET2280 \ -+ Renesas-SH7705/7727 CONFIG_USB_GADGET_SUPERH \ -+ Toshiba-TC86C001(Goku-S) CONFIG_USB_GADGET_GOKU \ -+ " NetChip-2280 -+ -+ define_tristate CONFIG_USB_GADGET_CONTROLLER n -+ -+ if [ "$CONFIG_ARCH_PXA" = "y" -o "$CONFIG_ARCH_IXP425" = "y" ] ; then -+ if [ "$CONFIG_USB_GADGET_PXA2XX" = "y" ] ; then -+ define_tristate CONFIG_USB_PXA2XX $CONFIG_USB_GADGET -+ define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_PXA2XX -+ fi -+ fi -+ if [ "$CONFIG_PCI" = "y" -a "$CONFIG_USB_GADGET_NET2280" = "y" ] ; then -+ define_tristate CONFIG_USB_NET2280 $CONFIG_USB_GADGET -+ define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_NET2280 -+ fi -+ if [ "$CONFIG_SUPERH" = "y" -a "$CONFIG_USB_GADGET_SUPERH" = "y" ] ; then -+ define_tristate CONFIG_USB_SUPERH $CONFIG_USB_GADGET -+ define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_SUPERH -+ fi -+ if [ "$CONFIG_PCI" = "y" -a "$CONFIG_USB_GADGET_GOKU" = "y" ] ; then -+ define_tristate CONFIG_USB_GOKU $CONFIG_USB_GADGET -+ define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_GOKU -+ fi -+ if [ "$CONFIG_USB_GADGET_N9604" = "y" ] ; then -+ define_tristate CONFIG_USB_N9604 $CONFIG_USB_GADGET -+ define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_N9604 -+ fi -+ -+ # or any other controller that supports high speed transfers ... -+ define_bool CONFIG_USB_GADGET_DUALSPEED $CONFIG_USB_GADGET_NET2280 -+ -+ if [ "$CONFIG_USB_GADGET_CONTROLLER" = "y" -o "$CONFIG_USB_GADGET_CONTROLLER" = "m" ] ; then -+ -+ # -+ # no reason not to enable more than one gadget driver module, but -+ # for static linking that would make no sense since the usb model -+ # has exactly one of these upstream connections and only one -+ # lowest-level driver can control it. -+ # -+ # gadget drivers are compiled to work on specific hardware, since -+ # -+ # (a) gadget driver need hardware-specific configuration, like what -+ # endpoint names and numbers to use, maxpacket sizes, etc -+ # -+ # (b) specific hardware features like iso endpoints may be required -+ # -+ comment 'USB Gadget Drivers' -+ -+ # FIXME when drivers all use #ifdef CONFIG_USB_GADGET_* tests, -+ # just remove all this driver-specific define_bool logic -+ -+ dep_tristate ' Gadget Zero (DEVELOPMENT)' CONFIG_USB_ZERO $CONFIG_USB_GADGET_CONTROLLER -+ dep_tristate ' Ethernet Gadget (EXPERIMENTAL)' CONFIG_USB_ETH $CONFIG_USB_GADGET_CONTROLLER $CONFIG_NET -+ if [ "$CONFIG_USB_ETH" = "y" -o "$CONFIG_USB_ETH" = "m" ] ; then -+ bool ' RNDIS support (EXPERIMENTAL)' CONFIG_USB_ETH_RNDIS -+ fi -+ dep_tristate ' Gadget Filesystem API (EXPERIMENTAL)' CONFIG_USB_GADGETFS $CONFIG_USB_GADGET_CONTROLLER -+ dep_tristate ' File-backed Storage Gadget (DEVELOPMENT)' CONFIG_USB_FILE_STORAGE $CONFIG_USB_GADGET_CONTROLLER -+ dep_mbool ' File-backed Storage Gadget test mode' CONFIG_USB_FILE_STORAGE_TEST $CONFIG_USB_FILE_STORAGE -+ dep_tristate ' Serial Gadget (EXPERIMENTAL)' CONFIG_USB_G_SERIAL $CONFIG_USB_GADGET_CONTROLLER -+ -+ -+ # enforce the "only one statically linked gadget driver" rule -+ -+ if [ "$CONFIG_USB_ZERO" = "y" ]; then -+ # zero = y -+ define_tristate CONFIG_USB_ETH n -+ define_tristate CONFIG_USB_GADGETFS n -+ define_tristate CONFIG_USB_FILE_STORAGE n -+ define_tristate CONFIG_USB_G_SERIAL n -+ fi -+ -+ if [ "$CONFIG_USB_ETH" = "y" ]; then -+ define_tristate CONFIG_USB_ZERO n -+ # eth = y -+ define_tristate CONFIG_USB_GADGETFS n -+ define_tristate CONFIG_USB_FILE_STORAGE n -+ define_tristate CONFIG_USB_G_SERIAL n -+ fi -+ -+ if [ "$CONFIG_USB_GADGETFS" = "y" ]; then -+ define_tristate CONFIG_USB_ZERO n -+ define_tristate CONFIG_USB_ETH n -+ # gadgetfs = y -+ define_tristate CONFIG_USB_FILE_STORAGE n -+ define_tristate CONFIG_USB_G_SERIAL n -+ fi -+ -+ if [ "$CONFIG_USB_FILE_STORAGE" = "y" ]; then -+ define_tristate CONFIG_USB_ZERO n -+ define_tristate CONFIG_USB_ETH n -+ define_tristate CONFIG_USB_GADGETFS n -+ # file_storage = y -+ define_tristate CONFIG_USB_G_SERIAL n -+ fi -+ -+ if [ "$CONFIG_USB_G_SERIAL" = "y" ]; then -+ define_tristate CONFIG_USB_ZERO n -+ define_tristate CONFIG_USB_ETH n -+ define_tristate CONFIG_USB_GADGETFS n -+ define_tristate CONFIG_USB_FILE_STORAGE n -+ # g_serial = y -+ fi -+ fi -+fi -+endmenu -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/drivers/usb/gadget/Makefile kernel/drivers/usb/gadget/Makefile ---- /tmp/kernel/drivers/usb/gadget/Makefile 1970-01-01 01:00:00.000000000 +0100 -+++ kernel/drivers/usb/gadget/Makefile 2005-04-22 17:53:19.405544237 +0200 -@@ -0,0 +1,58 @@ -+# -+# Makefile for USB peripheral controller and gadget drivers -+# for kbuild 2.4 -+# -+ -+# for static linking -+O_TARGET := built-in.o -+ -+list-multi := g_zero.o g_ether.o gadgetfs.o g_file_storage.o g_serial.o -+ -+obj-$(CONFIG_USB_NET2280) += net2280.o -+obj-$(CONFIG_USB_PXA2XX) += pxa2xx_udc.o -+obj-$(CONFIG_USB_GOKU) += goku_udc.o -+obj-$(CONFIG_USB_SUPERH) += superh_udc.o -+obj-$(CONFIG_USB_N9604) += n9604.o -+ -+# only one of these may be statically linked ... -+controller-$(CONFIG_USB_NET2280) += net2280.o -+controller-$(CONFIG_USB_PXA2XX) += pxa2xx_udc.o -+controller-$(CONFIG_USB_GOKU) += goku_udc.o -+controller-$(CONFIG_USB_SUPERH) += superh_udc.o -+controller-$(CONFIG_USB_N9604) += n9604.o -+ -+# ... and only one of these, too; kbuild/kconfig don't help though. -+g_zero-objs := zero.o usbstring.o config.o epautoconf.o -+obj-$(CONFIG_USB_ZERO) += g_zero.o -+ -+g_ether-objs := ether.o usbstring.o config.o epautoconf.o -+obj-$(CONFIG_USB_ETH) += g_ether.o -+ -+ifeq ($(CONFIG_USB_ETH_RNDIS),y) -+ g_ether-objs += rndis.o -+endif -+ -+gadgetfs-objs := inode.o usbstring.o -+obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o -+ -+g_file_storage-objs := file_storage.o usbstring.o config.o \ -+ epautoconf.o -+obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o -+ -+g_serial-objs := gserial.o usbstring.o epautoconf.o -+obj-$(CONFIG_USB_G_SERIAL) += g_serial.o -+ -+export-objs := $(controller-y) $(controller-m) -+ -+include $(TOPDIR)/Rules.make -+ -+g_zero.o: $(g_zero-objs) -+ $(LD) -r -o $@ $(g_zero-objs) -+g_ether.o: $(g_ether-objs) -+ $(LD) -r -o $@ $(g_ether-objs) -+gadgetfs.o: $(gadgetfs-objs) -+ $(LD) -r -o $@ $(gadgetfs-objs) -+g_file_storage.o: $(g_file_storage-objs) -+ $(LD) -r -o $@ $(g_file_storage-objs) -+g_serial.o: $(g_serial-objs) -+ $(LD) -r -o $@ $(g_serial-objs) -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/drivers/usb/gadget/config.c kernel/drivers/usb/gadget/config.c ---- /tmp/kernel/drivers/usb/gadget/config.c 1970-01-01 01:00:00.000000000 +0100 -+++ kernel/drivers/usb/gadget/config.c 2005-04-22 17:53:19.408543749 +0200 -@@ -0,0 +1,116 @@ -+/* -+ * usb/gadget/config.c -- simplify building config descriptors -+ * -+ * Copyright (C) 2003 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/errno.h> -+#include <linux/kernel.h> -+#include <linux/list.h> -+#include <linux/string.h> -+#include <asm/byteorder.h> -+ -+#include <linux/usb_ch9.h> -+ -+ -+/** -+ * usb_descriptor_fillbuf - fill buffer with descriptors -+ * @buf: Buffer to be filled -+ * @buflen: Size of buf -+ * @src: Array of descriptor pointers, terminated by null pointer. -+ * -+ * Copies descriptors into the buffer, returning the length or a -+ * negative error code if they can't all be copied. Useful when -+ * assembling descriptors for an associated set of interfaces used -+ * as part of configuring a composite device; or in other cases where -+ * sets of descriptors need to be marshaled. -+ */ -+int -+usb_descriptor_fillbuf(void *buf, unsigned buflen, -+ const struct usb_descriptor_header **src) -+{ -+ u8 *dest = buf; -+ -+ if (!src) -+ return -EINVAL; -+ -+ /* fill buffer from src[] until null descriptor ptr */ -+ for (; 0 != *src; src++) { -+ unsigned len = (*src)->bLength; -+ -+ if (len > buflen) -+ return -EINVAL; -+ memcpy(dest, *src, len); -+ buflen -= len; -+ dest += len; -+ } -+ return dest - (u8 *)buf; -+} -+ -+ -+/** -+ * usb_gadget_config_buf - builts a complete configuration descriptor -+ * @config: Header for the descriptor, including characteristics such -+ * as power requirements and number of interfaces. -+ * @desc: Null-terminated vector of pointers to the descriptors (interface, -+ * endpoint, etc) defining all functions in this device configuration. -+ * @buf: Buffer for the resulting configuration descriptor. -+ * @length: Length of buffer. If this is not big enough to hold the -+ * entire configuration descriptor, an error code will be returned. -+ * -+ * This copies descriptors into the response buffer, building a descriptor -+ * for that configuration. It returns the buffer length or a negative -+ * status code. The config.wTotalLength field is set to match the length -+ * of the result, but other descriptor fields (including power usage and -+ * interface count) must be set by the caller. -+ * -+ * Gadget drivers could use this when constructing a config descriptor -+ * in response to USB_REQ_GET_DESCRIPTOR. They will need to patch the -+ * resulting bDescriptorType value if USB_DT_OTHER_SPEED_CONFIG is needed. -+ */ -+int usb_gadget_config_buf( -+ const struct usb_config_descriptor *config, -+ void *buf, -+ unsigned length, -+ const struct usb_descriptor_header **desc -+) -+{ -+ struct usb_config_descriptor *cp = buf; -+ int len; -+ -+ /* config descriptor first */ -+ if (length < USB_DT_CONFIG_SIZE || !desc) -+ return -EINVAL; -+ *cp = *config; -+ -+ /* then interface/endpoint/class/vendor/... */ -+ len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8*)buf, -+ length - USB_DT_CONFIG_SIZE, desc); -+ if (len < 0) -+ return len; -+ len += USB_DT_CONFIG_SIZE; -+ if (len > 0xffff) -+ return -EINVAL; -+ -+ /* patch up the config descriptor */ -+ cp->bLength = USB_DT_CONFIG_SIZE; -+ cp->bDescriptorType = USB_DT_CONFIG; -+ cp->wTotalLength = cpu_to_le16(len); -+ cp->bmAttributes |= USB_CONFIG_ATT_ONE; -+ return len; -+} -+ -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/drivers/usb/gadget/epautoconf.c kernel/drivers/usb/gadget/epautoconf.c ---- /tmp/kernel/drivers/usb/gadget/epautoconf.c 1970-01-01 01:00:00.000000000 +0100 -+++ kernel/drivers/usb/gadget/epautoconf.c 2005-04-22 17:53:19.410543423 +0200 -@@ -0,0 +1,311 @@ -+/* -+ * epautoconf.c -- endpoint autoconfiguration for usb gadget drivers -+ * -+ * Copyright (C) 2004 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/kernel.h> -+#include <linux/init.h> -+#include <linux/types.h> -+#include <linux/list.h> -+#include <linux/errno.h> -+#include <linux/ctype.h> -+#include <linux/string.h> -+#include <linux/usb_ch9.h> -+#include <linux/usb_gadget.h> -+ -+#include <asm/byteorder.h> -+ -+#include "gadget_chips.h" -+ -+ -+/* we must assign addresses for configurable endpoints (like net2280) */ -+static __initdata unsigned epnum; -+ -+// #define MANY_ENDPOINTS -+#ifdef MANY_ENDPOINTS -+/* more than 15 configurable endpoints */ -+static __initdata unsigned in_epnum; -+#endif -+ -+ -+/* -+ * This should work with endpoints from controller drivers sharing the -+ * same endpoint naming convention. By example: -+ * -+ * - ep1, ep2, ... address is fixed, not direction or type -+ * - ep1in, ep2out, ... address and direction are fixed, not type -+ * - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction -+ * - ep1in-bulk, ep2out-iso, ... all three are fixed -+ * - ep-* ... no functionality restrictions -+ * -+ * Type suffixes are "-bulk", "-iso", or "-int". Numbers are decimal. -+ * Less common restrictions are implied by gadget_is_*(). -+ * -+ * NOTE: each endpoint is unidirectional, as specified by its USB -+ * descriptor; and isn't specific to a configuration or altsetting. -+ */ -+static int __init -+ep_matches ( -+ struct usb_gadget *gadget, -+ struct usb_ep *ep, -+ struct usb_endpoint_descriptor *desc -+) -+{ -+ u8 type; -+ const char *tmp; -+ u16 max; -+ -+ /* endpoint already claimed? */ -+ if (0 != ep->driver_data) -+ return 0; -+ -+ /* only support ep0 for portable CONTROL traffic */ -+ type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; -+ if (USB_ENDPOINT_XFER_CONTROL == type) -+ return 0; -+ -+ /* some other naming convention */ -+ if ('e' != ep->name[0]) -+ return 0; -+ -+ /* type-restriction: "-iso", "-bulk", or "-int". -+ * direction-restriction: "in", "out". -+ */ -+ if ('-' != ep->name[2]) { -+ tmp = strrchr (ep->name, '-'); -+ if (tmp) { -+ switch (type) { -+ case USB_ENDPOINT_XFER_INT: -+ /* bulk endpoints handle interrupt transfers, -+ * except the toggle-quirky iso-synch kind -+ */ -+ if ('s' == tmp[2]) // == "-iso" -+ return 0; -+ /* for now, avoid PXA "interrupt-in"; -+ * it's documented as never using DATA1. -+ */ -+ if (gadget_is_pxa (gadget) -+ && 'i' == tmp [1]) -+ return 0; -+ break; -+ case USB_ENDPOINT_XFER_BULK: -+ if ('b' != tmp[1]) // != "-bulk" -+ return 0; -+ break; -+ case USB_ENDPOINT_XFER_ISOC: -+ if ('s' != tmp[2]) // != "-iso" -+ return 0; -+ } -+ } else { -+ tmp = ep->name + strlen (ep->name); -+ } -+ -+ /* direction-restriction: "..in-..", "out-.." */ -+ tmp--; -+ if (!isdigit (*tmp)) { -+ if (desc->bEndpointAddress & USB_DIR_IN) { -+ if ('n' != *tmp) -+ return 0; -+ } else { -+ if ('t' != *tmp) -+ return 0; -+ } -+ } -+ } -+ -+ /* endpoint maxpacket size is an input parameter, except for bulk -+ * where it's an output parameter representing the full speed limit. -+ * the usb spec fixes high speed bulk maxpacket at 512 bytes. -+ */ -+ max = 0x7ff & le16_to_cpup (&desc->wMaxPacketSize); -+ switch (type) { -+ case USB_ENDPOINT_XFER_INT: -+ /* INT: limit 64 bytes full speed, 1024 high speed */ -+ if (!gadget->is_dualspeed && max > 64) -+ return 0; -+ /* FALLTHROUGH */ -+ -+ case USB_ENDPOINT_XFER_ISOC: -+ /* ISO: limit 1023 bytes full speed, 1024 high speed */ -+ if (ep->maxpacket < max) -+ return 0; -+ if (!gadget->is_dualspeed && max > 1023) -+ return 0; -+ -+ /* BOTH: "high bandwidth" works only at high speed */ -+ if ((desc->wMaxPacketSize & __constant_cpu_to_le16(3<<11))) { -+ if (!gadget->is_dualspeed) -+ return 0; -+ /* configure your hardware with enough buffering!! */ -+ } -+ break; -+ } -+ -+ /* MATCH!! */ -+ -+ /* report address */ -+ if (isdigit (ep->name [2])) { -+ u8 num = simple_strtol (&ep->name [2], NULL, 10); -+ desc->bEndpointAddress |= num; -+#ifdef MANY_ENDPOINTS -+ } else if (desc->bEndpointAddress & USB_DIR_IN) { -+ if (++in_epnum > 15) -+ return 0; -+ desc->bEndpointAddress = USB_DIR_IN | in_epnum; -+#endif -+ } else { -+ if (++epnum > 15) -+ return 0; -+ desc->bEndpointAddress |= epnum; -+ } -+ -+ /* report (variable) full speed bulk maxpacket */ -+ if (USB_ENDPOINT_XFER_BULK == type) { -+ int size = ep->maxpacket; -+ -+ /* min() doesn't work on bitfields with gcc-3.5 */ -+ if (size > 64) -+ size = 64; -+ desc->wMaxPacketSize = cpu_to_le16(size); -+ } -+ return 1; -+} -+ -+static struct usb_ep * __init -+find_ep (struct usb_gadget *gadget, const char *name) -+{ -+ struct usb_ep *ep; -+ -+ list_for_each_entry (ep, &gadget->ep_list, ep_list) { -+ if (0 == strcmp (ep->name, name)) -+ return ep; -+ } -+ return NULL; -+} -+ -+/** -+ * usb_ep_autoconfig - choose an endpoint matching the descriptor -+ * @gadget: The device to which the endpoint must belong. -+ * @desc: Endpoint descriptor, with endpoint direction and transfer mode -+ * initialized. For periodic transfers, the maximum packet -+ * size must also be initialized. This is modified on success. -+ * -+ * By choosing an endpoint to use with the specified descriptor, this -+ * routine simplifies writing gadget drivers that work with multiple -+ * USB device controllers. The endpoint would be passed later to -+ * usb_ep_enable(), along with some descriptor. -+ * -+ * That second descriptor won't always be the same as the first one. -+ * For example, isochronous endpoints can be autoconfigured for high -+ * bandwidth, and then used in several lower bandwidth altsettings. -+ * Also, high and full speed descriptors will be different. -+ * -+ * Be sure to examine and test the results of autoconfiguration on your -+ * hardware. This code may not make the best choices about how to use the -+ * USB controller, and it can't know all the restrictions that may apply. -+ * Some combinations of driver and hardware won't be able to autoconfigure. -+ * -+ * On success, this returns an un-claimed usb_ep, and modifies the endpoint -+ * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value -+ * is initialized as if the endpoint were used at full speed. To prevent -+ * the endpoint from being returned by a later autoconfig call, claim it -+ * by assigning ep->driver_data to some non-null value. -+ * -+ * On failure, this returns a null endpoint descriptor. -+ */ -+struct usb_ep * __init usb_ep_autoconfig ( -+ struct usb_gadget *gadget, -+ struct usb_endpoint_descriptor *desc -+) -+{ -+ struct usb_ep *ep; -+ u8 type; -+ -+ type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; -+ -+ /* First, apply chip-specific "best usage" knowledge. -+ * This might make a good usb_gadget_ops hook ... -+ */ -+ if (gadget_is_net2280 (gadget) && type == USB_ENDPOINT_XFER_INT) { -+ /* ep-e, ep-f are PIO with only 64 byte fifos */ -+ ep = find_ep (gadget, "ep-e"); -+ if (ep && ep_matches (gadget, ep, desc)) -+ return ep; -+ ep = find_ep (gadget, "ep-f"); -+ if (ep && ep_matches (gadget, ep, desc)) -+ return ep; -+ -+ } else if (gadget_is_goku (gadget)) { -+ if (USB_ENDPOINT_XFER_INT == type) { -+ /* single buffering is enough */ -+ ep = find_ep (gadget, "ep3-bulk"); -+ if (ep && ep_matches (gadget, ep, desc)) -+ return ep; -+ } else if (USB_ENDPOINT_XFER_BULK == type -+ && (USB_DIR_IN & desc->bEndpointAddress)) { -+ /* DMA may be available */ -+ ep = find_ep (gadget, "ep2-bulk"); -+ if (ep && ep_matches (gadget, ep, desc)) -+ return ep; -+ } -+ -+ } else if (gadget_is_sh (gadget) && USB_ENDPOINT_XFER_INT == type) { -+ /* single buffering is enough; maybe 8 byte fifo is too */ -+ ep = find_ep (gadget, "ep3in-bulk"); -+ if (ep && ep_matches (gadget, ep, desc)) -+ return ep; -+ -+ } else if (gadget_is_mq11xx (gadget) && USB_ENDPOINT_XFER_INT == type) { -+ ep = find_ep (gadget, "ep1-bulk"); -+ if (ep && ep_matches (gadget, ep, desc)) -+ return ep; -+ } -+ -+ /* Second, look at endpoints until an unclaimed one looks usable */ -+ list_for_each_entry (ep, &gadget->ep_list, ep_list) { -+ if (ep_matches (gadget, ep, desc)) -+ return ep; -+ } -+ -+ /* Fail */ -+ return NULL; -+} -+ -+/** -+ * usb_ep_autoconfig_reset - reset endpoint autoconfig state -+ * @gadget: device for which autoconfig state will be reset -+ * -+ * Use this for devices where one configuration may need to assign -+ * endpoint resources very differently from the next one. It clears -+ * state such as ep->driver_data and the record of assigned endpoints -+ * used by usb_ep_autoconfig(). -+ */ -+void __init usb_ep_autoconfig_reset (struct usb_gadget *gadget) -+{ -+ struct usb_ep *ep; -+ -+ list_for_each_entry (ep, &gadget->ep_list, ep_list) { -+ ep->driver_data = NULL; -+ } -+#ifdef MANY_ENDPOINTS -+ in_epnum = 0; -+#endif -+ epnum = 0; -+} -+ -diff -x '*~' -x '.*' -r -N -u /tmp/kernel/drivers/usb/gadget/ether.c kernel/drivers/usb/gadget/ether.c ---- /tmp/kernel/drivers/usb/gadget/ether.c 1970-01-01 01:00:00.000000000 +0100 -+++ kernel/drivers/usb/gadget/ether.c 2005-04-22 18:01:31.044861540 +0200 -@@ -0,0 +1,2734 @@ -+/* -+ * ether.c -- Ethernet gadget driver, with CDC and non-CDC options -+ * -+ * Copyright (C) 2003-2005 David Brownell -+ * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger -+ * -+ * 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 -+ */ -+ -+ -+// #define DEBUG 1 -+// #define VERBOSE -+ -+#include <linux/config.h> -+#include <linux/module.h> -+#include <linux/kernel.h> -+#include <linux/delay.h> -+#include <linux/ioport.h> -+#include <linux/sched.h> -+#include <linux/slab.h> -+#include <linux/smp_lock.h> -+#include <linux/errno.h> -+#include <linux/init.h> -+#include <linux/timer.h> -+#include <linux/list.h> -+#include <linux/interrupt.h> -+#include <linux/uts.h> -+#include <linux/version.h> -+#include <linux/moduleparam.h> -+#include <linux/ctype.h> -+ -+#include <asm/byteorder.h> -+#include <asm/io.h> -+#include <asm/irq.h> -+#include <asm/system.h> -+#include <asm/uaccess.h> -+#include <asm/unaligned.h> -+ -+#include <linux/usb_ch9.h> -+#include <linux/usb_cdc.h> -+#include <linux/usb_gadget.h> -+ -+#include <linux/random.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+ -+#include "gadget_chips.h" -+ -+/*-------------------------------------------------------------------------*/ -+ -+/* -+ * Ethernet gadget driver -- with CDC and non-CDC options -+ * Builds on hardware support for a full duplex link. -+ * -+ * CDC Ethernet is the standard USB solution for sending Ethernet frames -+ * using USB. Real hardware tends to use the same framing protocol but look -+ * different for control features. This driver strongly prefers to use -+ * this USB-IF standard as its open-systems interoperability solution; -+ * most host side USB stacks (except from Microsoft) support it. -+ * -+ * There's some hardware that can't talk CDC. We make that hardware -+ * implement a "minimalist" vendor-agnostic CDC core: same framing, but -+ * link-level setup only requires activating the configuration. -+ * Linux supports it, but other host operating systems may not. -+ * (This is a subset of CDC Ethernet.) -+ * -+ * A third option is also in use. Rather than CDC Ethernet, or something -+ * simpler, Microsoft pushes their own approach: RNDIS. The published -+ * RNDIS specs are ambiguous and appear to be incomplete, and are also -+ * needlessly complex. -+ */ -+ -+#define DRIVER_DESC "Ethernet Gadget" -+#define DRIVER_VERSION "Equinox 2004" -+ -+static const char shortname [] = "ether"; -+static const char driver_desc [] = DRIVER_DESC; -+ -+#define RX_EXTRA 20 /* guard against rx overflows */ -+ -+#ifdef CONFIG_USB_ETH_RNDIS -+#include "rndis.h" -+#else -+#define rndis_init() 0 -+#define rndis_exit() do{}while(0) -+#endif -+ -+/* 2.6-compat */ -+#ifndef container_of -+#define container_of list_entry -+#endif -+ -+/** PO: really needed? */ -+#include <linux/tqueue.h> -+#define work_struct tq_struct -+#define INIT_WORK INIT_TQUEUE -+#define schedule_work schedule_task -+#define flush_scheduled_work flush_scheduled_tasks -+ -+static void random_ether_addr (u8 *addr) -+{ -+ get_random_bytes (addr, ETH_ALEN); -+ addr [0] &= 0xfe; // clear multicast bit -+ addr [0] |= 0x02; // set local assignment bit (IEEE802) -+} -+ -+/* CDC and RNDIS support the same host-chosen outgoing packet filters. */ -+#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ -+ |USB_CDC_PACKET_TYPE_DIRECTED) -+ -+ -+/*-------------------------------------------------------------------------*/ -+ -+struct eth_dev { -+ spinlock_t lock; -+ struct usb_gadget *gadget; -+ struct usb_request *req; /* for control responses */ -+ struct usb_request *stat_req; /* for cdc & rndis status */ -+ -+ u8 config; -+ struct usb_ep *in_ep, *out_ep, *status_ep; -+ const struct usb_endpoint_descriptor -+ *in, *out, *status; -+ struct list_head tx_reqs, rx_reqs; -+ -+ struct net_device *net; -+ struct net_device_stats stats; -+ atomic_t tx_qlen; -+ -+ struct work_struct work; -+ unsigned zlp:1; -+ unsigned cdc:1; -+ unsigned rndis:1; -+ unsigned suspended:1; -+ u16 cdc_filter; -+ unsigned long todo; -+#define WORK_RX_MEMORY 0 -+ int rndis_config; -+ u8 host_mac [ETH_ALEN]; -+}; -+ -+/* This version autoconfigures as much as possible at run-time. -+ * -+ * It also ASSUMES a self-powered device, without remote wakeup, -+ * although remote wakeup support would make sense. -+ */ -+static const char *EP_IN_NAME; -+static const char *EP_OUT_NAME; -+static const char *EP_STATUS_NAME; -+ -+/*-------------------------------------------------------------------------*/ -+ -+/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! -+ * Instead: allocate your own, using normal USB-IF procedures. |
