Commit 056010ff authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge greg@desk:linux/BK/gadget-2.5

into kroah.com:/home/greg/linux/BK/gadget-2.5
parents b36c92e7 e3b7d740
...@@ -91,5 +91,7 @@ source "drivers/usb/serial/Kconfig" ...@@ -91,5 +91,7 @@ source "drivers/usb/serial/Kconfig"
source "drivers/usb/misc/Kconfig" source "drivers/usb/misc/Kconfig"
source "drivers/usb/gadget/Kconfig"
endmenu endmenu
...@@ -58,3 +58,7 @@ obj-$(CONFIG_USB_SPEEDTOUCH) += misc/ ...@@ -58,3 +58,7 @@ obj-$(CONFIG_USB_SPEEDTOUCH) += misc/
obj-$(CONFIG_USB_TEST) += misc/ obj-$(CONFIG_USB_TEST) += misc/
obj-$(CONFIG_USB_TIGL) += misc/ obj-$(CONFIG_USB_TIGL) += misc/
obj-$(CONFIG_USB_USS720) += misc/ obj-$(CONFIG_USB_USS720) += misc/
obj-$(CONFIG_USB_NET2280) += gadget/
obj-$(CONFIG_USB_ZERO) += gadget/
obj-$(CONFIG_USB_ETH) += gadget/
#
# USB Gadget support on a system involves
# (a) a peripheral controller, and
# (b) the gadget driver using it.
#
# for 2.5 kbuild, drivers/usb/gadget/Kconfig
# source this at the end of drivers/usb/Kconfig
#
menuconfig USB_GADGET
tristate "Support for USB Gadgets"
depends on EXPERIMENTAL
help
USB is a master/slave protocol, organized with 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).
#
# USB Peripheral Controller Support
#
# FIXME convert to tristate choice when "choice" behaves as specified
#
comment "USB Peripheral Controller Support"
depends on USB_GADGET
config USB_NET2280
tristate "NetChip 2280 USB Peripheral Controller"
depends on PCI && USB_GADGET
help
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.
#
# USB Gadget Drivers
#
# FIXME only one of these may be statically linked; choice/endchoice.
#
comment "USB Gadget Drivers"
depends on USB_GADGET
# FIXME want better dependency/config approach for drivers. with only
# two knobs to tweak (driver y/m/n, and a hardware symbol) there's no
# good excuse for Kconfig to cause such trouble here. there are clear
# bugs (coredumps, multiple choices enabled, and more) in its (boolean)
# "choice" logic too ...
config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
depends on USB_GADGET && (USB_DUMMY_HCD || USB_NET2280 || USB_PXA250 || USB_SA1100)
help
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_ZERO_NET2280
bool
# for now, treat the "dummy" hcd as if it were a net2280
depends on USB_ZERO && (USB_NET2280 || USB_DUMMY_HCD)
default y
config USB_ZERO_PXA250
bool
depends on USB_ZERO && USB_PXA250
default y
config USB_ZERO_SA1100
bool
depends on USB_ZERO && USB_SA1100
default y
config USB_ETH
tristate "Ethernet Gadget"
depends on USB_GADGET && (USB_DUMMY_HCD || USB_NET2280 || USB_PXA250 || USB_SA1100)
help
This driver implements 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.
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.) Deep queues are especially important with
high speed devices. It 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_NET2280
bool
# for now, treat the "dummy" hcd as if it were a net2280
depends on USB_ETH && (USB_NET2280 || USB_DUMMY_HCD)
default y
config USB_ETH_PXA250
bool
depends on USB_ETH && USB_PXA250
default y
config USB_ETH_SA1100
bool
depends on USB_ETH && USB_SA1100
default y
# endmenuconfig
#
# USB peripheral controller drivers
#
obj-$(CONFIG_USB_NET2280) += net2280.o
#
# USB gadget drivers
#
g_zero-objs := zero.o usbstring.o
g_ether-objs := ether.o usbstring.o
obj-$(CONFIG_USB_ZERO) += g_zero.o
obj-$(CONFIG_USB_ETH) += g_ether.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2003 David Brownell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*/
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/string.h>
#include <linux/device.h>
#include <linux/usb_ch9.h>
#include <linux/usb_gadget.h>
/**
* usb_gadget_get_string - fill out a string descriptor
* @table: of c strings using iso latin/1 characters
* @id: string id, from low byte of wValue in get string descriptor
* @buf: at least 256 bytes
*
* Finds the iso latin/1 string matching the ID, and converts it into a
* string descriptor in utf16-le.
* Returns length of descriptor (always even) or negative errno
*
* If your driver needs stings in multiple languages, you'll need to
* to use some alternate solution for languages where the ISO 8859/1
* (latin/1) character set can't be used. For example, they can't be
* used with Chinese (Big5, GB2312, etc), Japanese, Korean, or many other
* languages. You'd likely "switch (wIndex) { ... }" in your ep0
* string descriptor logic, using this routine in cases where "western
* european" characters suffice for the strings being returned.
*/
int
usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf)
{
struct usb_string *s;
int len;
/* descriptor 0 has the language id */
if (id == 0) {
buf [0] = 4;
buf [1] = USB_DT_STRING;
buf [2] = (u8) table->language;
buf [3] = (u8) (table->language >> 8);
return 4;
}
for (s = table->strings; s && s->s; s++)
if (s->id == id)
break;
/* unrecognized: stall. */
if (!s || !s->s)
return -EINVAL;
/* string descriptors have length, tag, then UTF16-LE text */
len = min ((size_t) 126, strlen (s->s));
buf [0] = (len + 1) * 2;
buf [1] = USB_DT_STRING;
memset (buf + 2, 0, 2 * len); /* zero all the high bytes */
while (len) {
buf [2 * len] = s->s [len - 1];
len--;
}
return buf [0];
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment