Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Tento commit je obsažen v:
389
drivers/usb/gadget/Kconfig
Normální soubor
389
drivers/usb/gadget/Kconfig
Normální soubor
@@ -0,0 +1,389 @@
|
||||
#
|
||||
# USB Gadget support on a system involves
|
||||
# (a) a peripheral controller, and
|
||||
# (b) the gadget driver using it.
|
||||
#
|
||||
# NOTE: Gadget support ** DOES NOT ** depend on host-side CONFIG_USB !!
|
||||
#
|
||||
# - Host systems (like PCs) need CONFIG_USB (with "A" jacks).
|
||||
# - Peripherals (like PDAs) need CONFIG_USB_GADGET (with "B" jacks).
|
||||
# - Some systems have both kinds of of controller.
|
||||
#
|
||||
# With help from a special transceiver and a "Mini-AB" jack, systems with
|
||||
# both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG).
|
||||
#
|
||||
menu "USB Gadget Support"
|
||||
|
||||
config USB_GADGET
|
||||
tristate "Support for USB Gadgets"
|
||||
help
|
||||
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 a "to-the-host" connector to a peripheral.
|
||||
|
||||
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).
|
||||
|
||||
For more information, see <http://www.linux-usb.org/gadget> and
|
||||
the kernel DocBook documentation for this API.
|
||||
|
||||
config USB_GADGET_DEBUG_FILES
|
||||
boolean "Debugging information files"
|
||||
depends on USB_GADGET && PROC_FS
|
||||
help
|
||||
Some of the drivers in the "gadget" framework can expose
|
||||
debugging information in files such as /proc/driver/udc
|
||||
(for a peripheral controller). The information in these
|
||||
files may help when you're troubleshooting or bringing up a
|
||||
driver on a new board. Enable these files by choosing "Y"
|
||||
here. If in doubt, or to conserve kernel memory, say "N".
|
||||
|
||||
#
|
||||
# USB Peripheral Controller Support
|
||||
#
|
||||
choice
|
||||
prompt "USB Peripheral Controller"
|
||||
depends on USB_GADGET
|
||||
help
|
||||
A USB device uses a controller to talk to its host.
|
||||
Systems should have only one such upstream link.
|
||||
Many controller drivers are platform-specific; these
|
||||
often need board-specific hooks.
|
||||
|
||||
config USB_GADGET_NET2280
|
||||
boolean "NetChip 2280"
|
||||
depends on PCI
|
||||
select USB_GADGET_DUALSPEED
|
||||
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.
|
||||
|
||||
config USB_NET2280
|
||||
tristate
|
||||
depends on USB_GADGET_NET2280
|
||||
default USB_GADGET
|
||||
|
||||
config USB_GADGET_PXA2XX
|
||||
boolean "PXA 25x or IXP 4xx"
|
||||
depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX
|
||||
help
|
||||
Intel's PXA 25x series XScale ARM-5TE processors include
|
||||
an integrated full speed USB 1.1 device controller. The
|
||||
controller in the IXP 4xx series is register-compatible.
|
||||
|
||||
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_PXA2XX
|
||||
tristate
|
||||
depends on USB_GADGET_PXA2XX
|
||||
default USB_GADGET
|
||||
|
||||
# if there's only one gadget driver, using only two bulk endpoints,
|
||||
# don't waste memory for the other endpoints
|
||||
config USB_PXA2XX_SMALL
|
||||
depends on USB_GADGET_PXA2XX
|
||||
bool
|
||||
default n if USB_ETH_RNDIS
|
||||
default y if USB_ZERO
|
||||
default y if USB_ETH
|
||||
default y if USB_G_SERIAL
|
||||
|
||||
config USB_GADGET_GOKU
|
||||
boolean "Toshiba TC86C001 'Goku-S'"
|
||||
depends on PCI
|
||||
help
|
||||
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 to force all
|
||||
gadget drivers to also be dynamically linked.
|
||||
|
||||
config USB_GOKU
|
||||
tristate
|
||||
depends on USB_GADGET_GOKU
|
||||
default USB_GADGET
|
||||
|
||||
|
||||
config USB_GADGET_LH7A40X
|
||||
boolean "LH7A40X"
|
||||
depends on ARCH_LH7A40X
|
||||
help
|
||||
This driver provides USB Device Controller driver for LH7A40x
|
||||
|
||||
config USB_LH7A40X
|
||||
tristate
|
||||
depends on USB_GADGET_LH7A40X
|
||||
default USB_GADGET
|
||||
|
||||
|
||||
config USB_GADGET_OMAP
|
||||
boolean "OMAP USB Device Controller"
|
||||
depends on ARCH_OMAP
|
||||
select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
|
||||
help
|
||||
Many Texas Instruments OMAP processors have flexible full
|
||||
speed USB device controllers, with support for up to 30
|
||||
endpoints (plus endpoint zero). This driver supports the
|
||||
controller in the OMAP 1611, and should work with controllers
|
||||
in other OMAP processors too, given minor tweaks.
|
||||
|
||||
Say "y" to link the driver statically, or "m" to build a
|
||||
dynamically linked module called "omap_udc" and force all
|
||||
gadget drivers to also be dynamically linked.
|
||||
|
||||
config USB_OMAP
|
||||
tristate
|
||||
depends on USB_GADGET_OMAP
|
||||
default USB_GADGET
|
||||
|
||||
config USB_OTG
|
||||
boolean "OTG Support"
|
||||
depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD
|
||||
help
|
||||
The most notable feature of USB OTG is support for a
|
||||
"Dual-Role" device, which can act as either a device
|
||||
or a host. The initial role choice can be changed
|
||||
later, when two dual-role devices talk to each other.
|
||||
|
||||
Select this only if your OMAP board has a Mini-AB connector.
|
||||
|
||||
|
||||
config USB_GADGET_DUMMY_HCD
|
||||
boolean "Dummy HCD (DEVELOPMENT)"
|
||||
depends on USB && EXPERIMENTAL
|
||||
select USB_GADGET_DUALSPEED
|
||||
help
|
||||
This host controller driver emulates USB, looping all data transfer
|
||||
requests back to a USB "gadget driver" in the same host. The host
|
||||
side is the master; the gadget side is the slave. Gadget drivers
|
||||
can be high, full, or low speed; and they have access to endpoints
|
||||
like those from NET2280, PXA2xx, or SA1100 hardware.
|
||||
|
||||
This may help in some stages of creating a driver to embed in a
|
||||
Linux device, since it lets you debug several parts of the gadget
|
||||
driver without its hardware or drivers being involved.
|
||||
|
||||
Since such a gadget side driver needs to interoperate with a host
|
||||
side Linux-USB device driver, this may help to debug both sides
|
||||
of a USB protocol stack.
|
||||
|
||||
Say "y" to link the driver statically, or "m" to build a
|
||||
dynamically linked module called "dummy_hcd" and force all
|
||||
gadget drivers to also be dynamically linked.
|
||||
|
||||
config USB_DUMMY_HCD
|
||||
tristate
|
||||
depends on USB_GADGET_DUMMY_HCD
|
||||
default USB_GADGET
|
||||
|
||||
# NOTE: Please keep dummy_hcd LAST so that "real hardware" appears
|
||||
# first and will be selected by default.
|
||||
|
||||
endchoice
|
||||
|
||||
config USB_GADGET_DUALSPEED
|
||||
bool
|
||||
depends on USB_GADGET
|
||||
default n
|
||||
help
|
||||
Means that gadget drivers should include extra descriptors
|
||||
and code to handle dual-speed controllers.
|
||||
|
||||
#
|
||||
# USB Gadget Drivers
|
||||
#
|
||||
choice
|
||||
tristate "USB Gadget Drivers"
|
||||
depends on USB_GADGET
|
||||
default USB_ETH
|
||||
help
|
||||
A Linux "Gadget Driver" talks to the USB Peripheral Controller
|
||||
driver through the abstract "gadget" API. Some other operating
|
||||
systems call these "client" drivers, of which "class drivers"
|
||||
are a subset (implementing a USB device class specification).
|
||||
A gadget driver implements one or more USB functions using
|
||||
the peripheral hardware.
|
||||
|
||||
Gadget drivers are hardware-neutral, or "platform independent",
|
||||
except that they sometimes must understand quirks or limitations
|
||||
of the particular controllers they work with. For example, when
|
||||
a controller doesn't support alternate configurations or provide
|
||||
enough of the right types of endpoints, the gadget driver might
|
||||
not be able work with that controller, or might need to implement
|
||||
a less common variant of a device class protocol.
|
||||
|
||||
# this first set of drivers all depend on bulk-capable hardware.
|
||||
|
||||
config USB_ZERO
|
||||
tristate "Gadget Zero (DEVELOPMENT)"
|
||||
depends on EXPERIMENTAL
|
||||
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_HNPTEST
|
||||
boolean "HNP Test Device"
|
||||
depends on USB_ZERO && USB_OTG
|
||||
help
|
||||
You can configure this device to enumerate using the device
|
||||
identifiers of the USB-OTG test device. That means that when
|
||||
this gadget connects to another OTG device, with this one using
|
||||
the "B-Peripheral" role, that device will use HNP to let this
|
||||
one serve as the USB host instead (in the "B-Host" role).
|
||||
|
||||
config USB_ETH
|
||||
tristate "Ethernet Gadget (with CDC Ethernet support)"
|
||||
depends on NET
|
||||
help
|
||||
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 simple CDC subset
|
||||
is used, placing fewer demands on USB.
|
||||
|
||||
RNDIS support is a third option, more demanding than that subset.
|
||||
|
||||
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
|
||||
bool "RNDIS support (EXPERIMENTAL)"
|
||||
depends on USB_ETH && EXPERIMENTAL
|
||||
default y
|
||||
help
|
||||
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.
|
||||
|
||||
To make MS-Windows work with this, use Documentation/usb/linux.inf
|
||||
as the "driver info file". For versions of MS-Windows older than
|
||||
XP, you'll need to download drivers from Microsoft's website; a URL
|
||||
is given in comments found in that info file.
|
||||
|
||||
config USB_GADGETFS
|
||||
tristate "Gadget Filesystem (EXPERIMENTAL)"
|
||||
depends on EXPERIMENTAL
|
||||
help
|
||||
This driver provides a filesystem based API that lets user mode
|
||||
programs implement a single-configuration USB device, including
|
||||
endpoint I/O and control requests that don't relate to enumeration.
|
||||
All endpoints, transfer speeds, and transfer types supported by
|
||||
the hardware are available, through read() and write() calls.
|
||||
|
||||
Say "y" to link the driver statically, or "m" to build a
|
||||
dynamically linked module called "gadgetfs".
|
||||
|
||||
config USB_FILE_STORAGE
|
||||
tristate "File-backed Storage Gadget"
|
||||
help
|
||||
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.
|
||||
|
||||
Say "y" to link the driver statically, or "m" to build a
|
||||
dynamically linked module called "g_file_storage".
|
||||
|
||||
config USB_FILE_STORAGE_TEST
|
||||
bool "File-backed Storage Gadget testing version"
|
||||
depends on USB_FILE_STORAGE
|
||||
default n
|
||||
help
|
||||
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_G_SERIAL
|
||||
tristate "Serial Gadget (with CDC ACM support)"
|
||||
help
|
||||
The Serial Gadget talks to the Linux-USB generic serial driver.
|
||||
This driver supports a CDC-ACM module option, which can be used
|
||||
to interoperate with MS-Windows hosts or with the Linux-USB
|
||||
"cdc-acm" driver.
|
||||
|
||||
Say "y" to link the driver statically, or "m" to build a
|
||||
dynamically linked module called "g_serial".
|
||||
|
||||
For more information, see Documentation/usb/gadget_serial.txt
|
||||
which includes instructions and a "driver info file" needed to
|
||||
make MS-Windows work with this driver.
|
||||
|
||||
|
||||
# put drivers that need isochronous transfer support (for audio
|
||||
# or video class gadget drivers), or specific hardware, here.
|
||||
|
||||
# - none yet
|
||||
|
||||
endchoice
|
||||
|
||||
endmenu
|
30
drivers/usb/gadget/Makefile
Normální soubor
30
drivers/usb/gadget/Makefile
Normální soubor
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# USB peripheral controller drivers
|
||||
#
|
||||
obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o
|
||||
obj-$(CONFIG_USB_NET2280) += net2280.o
|
||||
obj-$(CONFIG_USB_PXA2XX) += pxa2xx_udc.o
|
||||
obj-$(CONFIG_USB_GOKU) += goku_udc.o
|
||||
obj-$(CONFIG_USB_OMAP) += omap_udc.o
|
||||
obj-$(CONFIG_USB_LH7A40X) += lh7a40x_udc.o
|
||||
|
||||
#
|
||||
# USB gadget drivers
|
||||
#
|
||||
g_zero-objs := zero.o usbstring.o config.o epautoconf.o
|
||||
g_ether-objs := ether.o usbstring.o config.o epautoconf.o
|
||||
g_serial-objs := serial.o usbstring.o config.o epautoconf.o
|
||||
gadgetfs-objs := inode.o
|
||||
g_file_storage-objs := file_storage.o usbstring.o config.o \
|
||||
epautoconf.o
|
||||
|
||||
ifeq ($(CONFIG_USB_ETH_RNDIS),y)
|
||||
g_ether-objs += rndis.o
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_USB_ZERO) += g_zero.o
|
||||
obj-$(CONFIG_USB_ETH) += g_ether.o
|
||||
obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
|
||||
obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o
|
||||
obj-$(CONFIG_USB_G_SERIAL) += g_serial.o
|
||||
|
117
drivers/usb/gadget/config.c
Normální soubor
117
drivers/usb/gadget/config.c
Normální soubor
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 <linux/device.h>
|
||||
|
||||
#include <linux/usb_ch9.h>
|
||||
#include <linux/usb_gadget.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;
|
||||
}
|
||||
|
1793
drivers/usb/gadget/dummy_hcd.c
Normální soubor
1793
drivers/usb/gadget/dummy_hcd.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
310
drivers/usb/gadget/epautoconf.c
Normální soubor
310
drivers/usb/gadget/epautoconf.c
Normální soubor
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* 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/device.h>
|
||||
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <linux/usb_ch9.h>
|
||||
#include <linux/usb_gadget.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;
|
||||
}
|
||||
|
2660
drivers/usb/gadget/ether.c
Normální soubor
2660
drivers/usb/gadget/ether.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
4139
drivers/usb/gadget/file_storage.c
Normální soubor
4139
drivers/usb/gadget/file_storage.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
92
drivers/usb/gadget/gadget_chips.h
Normální soubor
92
drivers/usb/gadget/gadget_chips.h
Normální soubor
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* USB device controllers have lots of quirks. Use these macros in
|
||||
* gadget drivers or other code that needs to deal with them, and which
|
||||
* autoconfigures instead of using early binding to the hardware.
|
||||
*
|
||||
* This could eventually work like the ARM mach_is_*() stuff, driven by
|
||||
* some config file that gets updated as new hardware is supported.
|
||||
*
|
||||
* NOTE: some of these controller drivers may not be available yet.
|
||||
*/
|
||||
#ifdef CONFIG_USB_GADGET_NET2280
|
||||
#define gadget_is_net2280(g) !strcmp("net2280", (g)->name)
|
||||
#else
|
||||
#define gadget_is_net2280(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_DUMMY_HCD
|
||||
#define gadget_is_dummy(g) !strcmp("dummy_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_dummy(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_PXA2XX
|
||||
#define gadget_is_pxa(g) !strcmp("pxa2xx_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_pxa(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_GOKU
|
||||
#define gadget_is_goku(g) !strcmp("goku_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_goku(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_SUPERH
|
||||
#define gadget_is_sh(g) !strcmp("sh_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_sh(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_SA1100
|
||||
#define gadget_is_sa1100(g) !strcmp("sa1100_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_sa1100(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_LH7A40X
|
||||
#define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_lh7a40x(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_MQ11XX
|
||||
#define gadget_is_mq11xx(g) !strcmp("mq11xx_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_mq11xx(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_OMAP
|
||||
#define gadget_is_omap(g) !strcmp("omap_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_omap(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_N9604
|
||||
#define gadget_is_n9604(g) !strcmp("n9604_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_n9604(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_PXA27X
|
||||
#define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_pxa27x(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_S3C2410
|
||||
#define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_s3c2410(g) 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_GADGET_AT91
|
||||
#define gadget_is_at91(g) !strcmp("at91_udc", (g)->name)
|
||||
#else
|
||||
#define gadget_is_at91(g) 0
|
||||
#endif
|
||||
|
||||
// CONFIG_USB_GADGET_SX2
|
||||
// CONFIG_USB_GADGET_AU1X00
|
||||
// ...
|
||||
|
1984
drivers/usb/gadget/goku_udc.c
Normální soubor
1984
drivers/usb/gadget/goku_udc.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
290
drivers/usb/gadget/goku_udc.h
Normální soubor
290
drivers/usb/gadget/goku_udc.h
Normální soubor
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* Toshiba TC86C001 ("Goku-S") USB Device Controller driver
|
||||
*
|
||||
* Copyright (C) 2000-2002 Lineo
|
||||
* by Stuart Lynne, Tom Rushworth, and Bruce Balden
|
||||
* Copyright (C) 2002 Toshiba Corporation
|
||||
* Copyright (C) 2003 MontaVista Software (source@mvista.com)
|
||||
*
|
||||
* This file is licensed under the terms of the GNU General Public
|
||||
* License version 2. This program is licensed "as is" without any
|
||||
* warranty of any kind, whether express or implied.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PCI BAR 0 points to these registers.
|
||||
*/
|
||||
struct goku_udc_regs {
|
||||
/* irq management */
|
||||
u32 int_status; /* 0x000 */
|
||||
u32 int_enable;
|
||||
#define INT_SUSPEND 0x00001 /* or resume */
|
||||
#define INT_USBRESET 0x00002
|
||||
#define INT_ENDPOINT0 0x00004
|
||||
#define INT_SETUP 0x00008
|
||||
#define INT_STATUS 0x00010
|
||||
#define INT_STATUSNAK 0x00020
|
||||
#define INT_EPxDATASET(n) (0x00020 << (n)) /* 0 < n < 4 */
|
||||
# define INT_EP1DATASET 0x00040
|
||||
# define INT_EP2DATASET 0x00080
|
||||
# define INT_EP3DATASET 0x00100
|
||||
#define INT_EPnNAK(n) (0x00100 < (n)) /* 0 < n < 4 */
|
||||
# define INT_EP1NAK 0x00200
|
||||
# define INT_EP2NAK 0x00400
|
||||
# define INT_EP3NAK 0x00800
|
||||
#define INT_SOF 0x01000
|
||||
#define INT_ERR 0x02000
|
||||
#define INT_MSTWRSET 0x04000
|
||||
#define INT_MSTWREND 0x08000
|
||||
#define INT_MSTWRTMOUT 0x10000
|
||||
#define INT_MSTRDEND 0x20000
|
||||
#define INT_SYSERROR 0x40000
|
||||
#define INT_PWRDETECT 0x80000
|
||||
|
||||
#define INT_DEVWIDE (INT_PWRDETECT|INT_SYSERROR/*|INT_ERR*/|INT_USBRESET|INT_SUSPEND)
|
||||
#define INT_EP0 (INT_SETUP|INT_ENDPOINT0/*|INT_STATUS*/|INT_STATUSNAK)
|
||||
|
||||
u32 dma_master;
|
||||
#define MST_EOPB_DIS 0x0800
|
||||
#define MST_EOPB_ENA 0x0400
|
||||
#define MST_TIMEOUT_DIS 0x0200
|
||||
#define MST_TIMEOUT_ENA 0x0100
|
||||
#define MST_RD_EOPB 0x0080 /* write-only */
|
||||
#define MST_RD_RESET 0x0040
|
||||
#define MST_WR_RESET 0x0020
|
||||
#define MST_RD_ENA 0x0004 /* 1:start, 0:ignore */
|
||||
#define MST_WR_ENA 0x0002 /* 1:start, 0:ignore */
|
||||
#define MST_CONNECTION 0x0001 /* 0 for ep1out/ep2in */
|
||||
|
||||
#define MST_R_BITS (MST_EOPB_DIS|MST_EOPB_ENA \
|
||||
|MST_RD_ENA|MST_RD_RESET)
|
||||
#define MST_W_BITS (MST_TIMEOUT_DIS|MST_TIMEOUT_ENA \
|
||||
|MST_WR_ENA|MST_WR_RESET)
|
||||
#define MST_RW_BITS (MST_R_BITS|MST_W_BITS \
|
||||
|MST_CONNECTION)
|
||||
|
||||
/* these values assume (dma_master & MST_CONNECTION) == 0 */
|
||||
#define UDC_MSTWR_ENDPOINT 1
|
||||
#define UDC_MSTRD_ENDPOINT 2
|
||||
|
||||
/* dma master write */
|
||||
u32 out_dma_start;
|
||||
u32 out_dma_end;
|
||||
u32 out_dma_current;
|
||||
|
||||
/* dma master read */
|
||||
u32 in_dma_start;
|
||||
u32 in_dma_end;
|
||||
u32 in_dma_current;
|
||||
|
||||
u32 power_detect;
|
||||
#define PW_DETECT 0x04
|
||||
#define PW_RESETB 0x02
|
||||
#define PW_PULLUP 0x01
|
||||
|
||||
u8 _reserved0 [0x1d8];
|
||||
|
||||
/* endpoint registers */
|
||||
u32 ep_fifo [4]; /* 0x200 */
|
||||
u8 _reserved1 [0x10];
|
||||
u32 ep_mode [4]; /* only 1-3 valid */
|
||||
u8 _reserved2 [0x10];
|
||||
|
||||
u32 ep_status [4];
|
||||
#define EPxSTATUS_TOGGLE 0x40
|
||||
#define EPxSTATUS_SUSPEND 0x20
|
||||
#define EPxSTATUS_EP_MASK (0x07<<2)
|
||||
# define EPxSTATUS_EP_READY (0<<2)
|
||||
# define EPxSTATUS_EP_DATAIN (1<<2)
|
||||
# define EPxSTATUS_EP_FULL (2<<2)
|
||||
# define EPxSTATUS_EP_TX_ERR (3<<2)
|
||||
# define EPxSTATUS_EP_RX_ERR (4<<2)
|
||||
# define EPxSTATUS_EP_BUSY (5<<2)
|
||||
# define EPxSTATUS_EP_STALL (6<<2)
|
||||
# define EPxSTATUS_EP_INVALID (7<<2)
|
||||
#define EPxSTATUS_FIFO_DISABLE 0x02
|
||||
#define EPxSTATUS_STAGE_ERROR 0x01
|
||||
|
||||
u8 _reserved3 [0x10];
|
||||
u32 EPxSizeLA[4];
|
||||
#define PACKET_ACTIVE (1<<7)
|
||||
#define DATASIZE 0x7f
|
||||
u8 _reserved3a [0x10];
|
||||
u32 EPxSizeLB[4]; /* only 1,2 valid */
|
||||
u8 _reserved3b [0x10];
|
||||
u32 EPxSizeHA[4]; /* only 1-3 valid */
|
||||
u8 _reserved3c [0x10];
|
||||
u32 EPxSizeHB[4]; /* only 1,2 valid */
|
||||
u8 _reserved4[0x30];
|
||||
|
||||
/* SETUP packet contents */
|
||||
u32 bRequestType; /* 0x300 */
|
||||
u32 bRequest;
|
||||
u32 wValueL;
|
||||
u32 wValueH;
|
||||
u32 wIndexL;
|
||||
u32 wIndexH;
|
||||
u32 wLengthL;
|
||||
u32 wLengthH;
|
||||
|
||||
/* command interaction/handshaking */
|
||||
u32 SetupRecv; /* 0x320 */
|
||||
u32 CurrConfig;
|
||||
u32 StdRequest;
|
||||
u32 Request;
|
||||
u32 DataSet;
|
||||
#define DATASET_A(epnum) (1<<(2*(epnum)))
|
||||
#define DATASET_B(epnum) (2<<(2*(epnum)))
|
||||
#define DATASET_AB(epnum) (3<<(2*(epnum)))
|
||||
u8 _reserved5[4];
|
||||
|
||||
u32 UsbState;
|
||||
#define USBSTATE_CONFIGURED 0x04
|
||||
#define USBSTATE_ADDRESSED 0x02
|
||||
#define USBSTATE_DEFAULT 0x01
|
||||
|
||||
u32 EOP;
|
||||
|
||||
u32 Command; /* 0x340 */
|
||||
#define COMMAND_SETDATA0 2
|
||||
#define COMMAND_RESET 3
|
||||
#define COMMAND_STALL 4
|
||||
#define COMMAND_INVALID 5
|
||||
#define COMMAND_FIFO_DISABLE 7
|
||||
#define COMMAND_FIFO_ENABLE 8
|
||||
#define COMMAND_INIT_DESCRIPTOR 9
|
||||
#define COMMAND_FIFO_CLEAR 10 /* also stall */
|
||||
#define COMMAND_STALL_CLEAR 11
|
||||
#define COMMAND_EP(n) ((n) << 4)
|
||||
|
||||
u32 EPxSingle;
|
||||
u8 _reserved6[4];
|
||||
u32 EPxBCS;
|
||||
u8 _reserved7[8];
|
||||
u32 IntControl;
|
||||
#define ICONTROL_STATUSNAK 1
|
||||
u8 _reserved8[4];
|
||||
|
||||
u32 reqmode; // 0x360 standard request mode, low 8 bits
|
||||
#define G_REQMODE_SET_INTF (1<<7)
|
||||
#define G_REQMODE_GET_INTF (1<<6)
|
||||
#define G_REQMODE_SET_CONF (1<<5)
|
||||
#define G_REQMODE_GET_CONF (1<<4)
|
||||
#define G_REQMODE_GET_DESC (1<<3)
|
||||
#define G_REQMODE_SET_FEAT (1<<2)
|
||||
#define G_REQMODE_CLEAR_FEAT (1<<1)
|
||||
#define G_REQMODE_GET_STATUS (1<<0)
|
||||
|
||||
u32 ReqMode;
|
||||
u8 _reserved9[0x18];
|
||||
u32 PortStatus; /* 0x380 */
|
||||
u8 _reserved10[8];
|
||||
u32 address;
|
||||
u32 buff_test;
|
||||
u8 _reserved11[4];
|
||||
u32 UsbReady;
|
||||
u8 _reserved12[4];
|
||||
u32 SetDescStall; /* 0x3a0 */
|
||||
u8 _reserved13[0x45c];
|
||||
|
||||
/* hardware could handle limited GET_DESCRIPTOR duties */
|
||||
#define DESC_LEN 0x80
|
||||
u32 descriptors[DESC_LEN]; /* 0x800 */
|
||||
u8 _reserved14[0x600];
|
||||
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define MAX_FIFO_SIZE 64
|
||||
#define MAX_EP0_SIZE 8 /* ep0 fifo is bigger, though */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* DRIVER DATA STRUCTURES and UTILITIES */
|
||||
|
||||
struct goku_ep {
|
||||
struct usb_ep ep;
|
||||
struct goku_udc *dev;
|
||||
unsigned long irqs;
|
||||
|
||||
unsigned num:8,
|
||||
dma:1,
|
||||
is_in:1,
|
||||
stopped:1;
|
||||
|
||||
/* analogous to a host-side qh */
|
||||
struct list_head queue;
|
||||
const struct usb_endpoint_descriptor *desc;
|
||||
|
||||
u32 __iomem *reg_fifo;
|
||||
u32 __iomem *reg_mode;
|
||||
u32 __iomem *reg_status;
|
||||
};
|
||||
|
||||
struct goku_request {
|
||||
struct usb_request req;
|
||||
struct list_head queue;
|
||||
|
||||
unsigned mapped:1;
|
||||
};
|
||||
|
||||
enum ep0state {
|
||||
EP0_DISCONNECT, /* no host */
|
||||
EP0_IDLE, /* between STATUS ack and SETUP report */
|
||||
EP0_IN, EP0_OUT, /* data stage */
|
||||
EP0_STATUS, /* status stage */
|
||||
EP0_STALL, /* data or status stages */
|
||||
EP0_SUSPEND, /* usb suspend */
|
||||
};
|
||||
|
||||
struct goku_udc {
|
||||
/* each pci device provides one gadget, several endpoints */
|
||||
struct usb_gadget gadget;
|
||||
spinlock_t lock;
|
||||
struct goku_ep ep[4];
|
||||
struct usb_gadget_driver *driver;
|
||||
|
||||
enum ep0state ep0state;
|
||||
unsigned got_irq:1,
|
||||
got_region:1,
|
||||
req_config:1,
|
||||
configured:1,
|
||||
enabled:1;
|
||||
|
||||
/* pci state used to access those endpoints */
|
||||
struct pci_dev *pdev;
|
||||
struct goku_udc_regs __iomem *regs;
|
||||
u32 int_enable;
|
||||
|
||||
/* statistics... */
|
||||
unsigned long irqs;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#define xprintk(dev,level,fmt,args...) \
|
||||
printk(level "%s %s: " fmt , driver_name , \
|
||||
pci_name(dev->pdev) , ## args)
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_DEBUG , fmt , ## args)
|
||||
#else
|
||||
#define DBG(dev,fmt,args...) \
|
||||
do { } while (0)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#ifdef VERBOSE
|
||||
#define VDBG DBG
|
||||
#else
|
||||
#define VDBG(dev,fmt,args...) \
|
||||
do { } while (0)
|
||||
#endif /* VERBOSE */
|
||||
|
||||
#define ERROR(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_ERR , fmt , ## args)
|
||||
#define WARN(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_WARNING , fmt , ## args)
|
||||
#define INFO(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_INFO , fmt , ## args)
|
||||
|
2110
drivers/usb/gadget/inode.c
Normální soubor
2110
drivers/usb/gadget/inode.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
2167
drivers/usb/gadget/lh7a40x_udc.c
Normální soubor
2167
drivers/usb/gadget/lh7a40x_udc.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
261
drivers/usb/gadget/lh7a40x_udc.h
Normální soubor
261
drivers/usb/gadget/lh7a40x_udc.h
Normální soubor
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* linux/drivers/usb/gadget/lh7a40x_udc.h
|
||||
* Sharp LH7A40x on-chip full speed USB device controllers
|
||||
*
|
||||
* Copyright (C) 2004 Mikko Lahteenmaki, Nordic ID
|
||||
* Copyright (C) 2004 Bo Henriksen, Nordic ID
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LH7A40X_H_
|
||||
#define __LH7A40X_H_
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/dma.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/irq.h>
|
||||
#include <asm/system.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include <asm/hardware.h>
|
||||
|
||||
#include <linux/usb_ch9.h>
|
||||
#include <linux/usb_gadget.h>
|
||||
|
||||
/*
|
||||
* Memory map
|
||||
*/
|
||||
|
||||
#define USB_FA 0x80000200 // function address register
|
||||
#define USB_PM 0x80000204 // power management register
|
||||
|
||||
#define USB_IN_INT 0x80000208 // IN interrupt register bank (EP0-EP3)
|
||||
#define USB_OUT_INT 0x80000210 // OUT interrupt register bank (EP2)
|
||||
#define USB_INT 0x80000218 // interrupt register bank
|
||||
|
||||
#define USB_IN_INT_EN 0x8000021C // IN interrupt enable register bank
|
||||
#define USB_OUT_INT_EN 0x80000224 // OUT interrupt enable register bank
|
||||
#define USB_INT_EN 0x8000022C // USB interrupt enable register bank
|
||||
|
||||
#define USB_FRM_NUM1 0x80000230 // Frame number1 register
|
||||
#define USB_FRM_NUM2 0x80000234 // Frame number2 register
|
||||
#define USB_INDEX 0x80000238 // index register
|
||||
|
||||
#define USB_IN_MAXP 0x80000240 // IN MAXP register
|
||||
#define USB_IN_CSR1 0x80000244 // IN CSR1 register/EP0 CSR register
|
||||
#define USB_EP0_CSR 0x80000244 // IN CSR1 register/EP0 CSR register
|
||||
#define USB_IN_CSR2 0x80000248 // IN CSR2 register
|
||||
#define USB_OUT_MAXP 0x8000024C // OUT MAXP register
|
||||
|
||||
#define USB_OUT_CSR1 0x80000250 // OUT CSR1 register
|
||||
#define USB_OUT_CSR2 0x80000254 // OUT CSR2 register
|
||||
#define USB_OUT_FIFO_WC1 0x80000258 // OUT FIFO write count1 register
|
||||
#define USB_OUT_FIFO_WC2 0x8000025C // OUT FIFO write count2 register
|
||||
|
||||
#define USB_RESET 0x8000044C // USB reset register
|
||||
|
||||
#define USB_EP0_FIFO 0x80000280
|
||||
#define USB_EP1_FIFO 0x80000284
|
||||
#define USB_EP2_FIFO 0x80000288
|
||||
#define USB_EP3_FIFO 0x8000028c
|
||||
|
||||
/*
|
||||
* USB reset register
|
||||
*/
|
||||
#define USB_RESET_APB (1<<1) //resets USB APB control side WRITE
|
||||
#define USB_RESET_IO (1<<0) //resets USB IO side WRITE
|
||||
|
||||
/*
|
||||
* USB function address register
|
||||
*/
|
||||
#define USB_FA_ADDR_UPDATE (1<<7)
|
||||
#define USB_FA_FUNCTION_ADDR (0x7F)
|
||||
|
||||
/*
|
||||
* Power Management register
|
||||
*/
|
||||
#define PM_USB_DCP (1<<5)
|
||||
#define PM_USB_ENABLE (1<<4)
|
||||
#define PM_USB_RESET (1<<3)
|
||||
#define PM_UC_RESUME (1<<2)
|
||||
#define PM_SUSPEND_MODE (1<<1)
|
||||
#define PM_ENABLE_SUSPEND (1<<0)
|
||||
|
||||
/*
|
||||
* IN interrupt register
|
||||
*/
|
||||
#define USB_IN_INT_EP3 (1<<3)
|
||||
#define USB_IN_INT_EP1 (1<<1)
|
||||
#define USB_IN_INT_EP0 (1<<0)
|
||||
|
||||
/*
|
||||
* OUT interrupt register
|
||||
*/
|
||||
#define USB_OUT_INT_EP2 (1<<2)
|
||||
|
||||
/*
|
||||
* USB interrupt register
|
||||
*/
|
||||
#define USB_INT_RESET_INT (1<<2)
|
||||
#define USB_INT_RESUME_INT (1<<1)
|
||||
#define USB_INT_SUSPEND_INT (1<<0)
|
||||
|
||||
/*
|
||||
* USB interrupt enable register
|
||||
*/
|
||||
#define USB_INT_EN_USB_RESET_INTER (1<<2)
|
||||
#define USB_INT_EN_RESUME_INTER (1<<1)
|
||||
#define USB_INT_EN_SUSPEND_INTER (1<<0)
|
||||
|
||||
/*
|
||||
* INCSR1 register
|
||||
*/
|
||||
#define USB_IN_CSR1_CLR_DATA_TOGGLE (1<<6)
|
||||
#define USB_IN_CSR1_SENT_STALL (1<<5)
|
||||
#define USB_IN_CSR1_SEND_STALL (1<<4)
|
||||
#define USB_IN_CSR1_FIFO_FLUSH (1<<3)
|
||||
#define USB_IN_CSR1_FIFO_NOT_EMPTY (1<<1)
|
||||
#define USB_IN_CSR1_IN_PKT_RDY (1<<0)
|
||||
|
||||
/*
|
||||
* INCSR2 register
|
||||
*/
|
||||
#define USB_IN_CSR2_AUTO_SET (1<<7)
|
||||
#define USB_IN_CSR2_USB_DMA_EN (1<<4)
|
||||
|
||||
/*
|
||||
* OUT CSR1 register
|
||||
*/
|
||||
#define USB_OUT_CSR1_CLR_DATA_REG (1<<7)
|
||||
#define USB_OUT_CSR1_SENT_STALL (1<<6)
|
||||
#define USB_OUT_CSR1_SEND_STALL (1<<5)
|
||||
#define USB_OUT_CSR1_FIFO_FLUSH (1<<4)
|
||||
#define USB_OUT_CSR1_FIFO_FULL (1<<1)
|
||||
#define USB_OUT_CSR1_OUT_PKT_RDY (1<<0)
|
||||
|
||||
/*
|
||||
* OUT CSR2 register
|
||||
*/
|
||||
#define USB_OUT_CSR2_AUTO_CLR (1<<7)
|
||||
#define USB_OUT_CSR2_USB_DMA_EN (1<<4)
|
||||
|
||||
/*
|
||||
* EP0 CSR
|
||||
*/
|
||||
#define EP0_CLR_SETUP_END (1<<7) /* Clear "Setup Ends" Bit (w) */
|
||||
#define EP0_CLR_OUT (1<<6) /* Clear "Out packet ready" Bit (w) */
|
||||
#define EP0_SEND_STALL (1<<5) /* Send STALL Handshake (rw) */
|
||||
#define EP0_SETUP_END (1<<4) /* Setup Ends (r) */
|
||||
|
||||
#define EP0_DATA_END (1<<3) /* Data end (rw) */
|
||||
#define EP0_SENT_STALL (1<<2) /* Sent Stall Handshake (r) */
|
||||
#define EP0_IN_PKT_RDY (1<<1) /* In packet ready (rw) */
|
||||
#define EP0_OUT_PKT_RDY (1<<0) /* Out packet ready (r) */
|
||||
|
||||
/* general CSR */
|
||||
#define OUT_PKT_RDY (1<<0)
|
||||
#define IN_PKT_RDY (1<<0)
|
||||
|
||||
/*
|
||||
* IN/OUT MAXP register
|
||||
*/
|
||||
#define USB_OUT_MAXP_MAXP (0xF)
|
||||
#define USB_IN_MAXP_MAXP (0xF)
|
||||
|
||||
// Max packet size
|
||||
//#define EP0_PACKETSIZE 0x10
|
||||
#define EP0_PACKETSIZE 0x8
|
||||
#define EP0_MAXPACKETSIZE 0x10
|
||||
|
||||
#define UDC_MAX_ENDPOINTS 4
|
||||
|
||||
#define WAIT_FOR_SETUP 0
|
||||
#define DATA_STATE_XMIT 1
|
||||
#define DATA_STATE_NEED_ZLP 2
|
||||
#define WAIT_FOR_OUT_STATUS 3
|
||||
#define DATA_STATE_RECV 4
|
||||
|
||||
/* ********************************************************************************************* */
|
||||
/* IO
|
||||
*/
|
||||
|
||||
typedef enum ep_type {
|
||||
ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt
|
||||
} ep_type_t;
|
||||
|
||||
struct lh7a40x_ep {
|
||||
struct usb_ep ep;
|
||||
struct lh7a40x_udc *dev;
|
||||
|
||||
const struct usb_endpoint_descriptor *desc;
|
||||
struct list_head queue;
|
||||
unsigned long pio_irqs;
|
||||
|
||||
u8 stopped;
|
||||
u8 bEndpointAddress;
|
||||
u8 bmAttributes;
|
||||
|
||||
ep_type_t ep_type;
|
||||
u32 fifo;
|
||||
u32 csr1;
|
||||
u32 csr2;
|
||||
};
|
||||
|
||||
struct lh7a40x_request {
|
||||
struct usb_request req;
|
||||
struct list_head queue;
|
||||
};
|
||||
|
||||
struct lh7a40x_udc {
|
||||
struct usb_gadget gadget;
|
||||
struct usb_gadget_driver *driver;
|
||||
struct device *dev;
|
||||
spinlock_t lock;
|
||||
|
||||
int ep0state;
|
||||
struct lh7a40x_ep ep[UDC_MAX_ENDPOINTS];
|
||||
|
||||
unsigned char usb_address;
|
||||
|
||||
unsigned req_pending:1, req_std:1, req_config:1;
|
||||
};
|
||||
|
||||
extern struct lh7a40x_udc *the_controller;
|
||||
|
||||
#define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN)==USB_DIR_IN)
|
||||
#define ep_index(EP) ((EP)->bEndpointAddress&0xF)
|
||||
#define ep_maxpacket(EP) ((EP)->ep.maxpacket)
|
||||
|
||||
#endif
|
217
drivers/usb/gadget/ndis.h
Normální soubor
217
drivers/usb/gadget/ndis.h
Normální soubor
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* ndis.h
|
||||
*
|
||||
* ntddndis.h modified by Benedikt Spranger <b.spranger@pengutronix.de>
|
||||
*
|
||||
* Thanks to the cygwin development team,
|
||||
* espacially to Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NDIS_H
|
||||
#define _LINUX_NDIS_H
|
||||
|
||||
|
||||
#define NDIS_STATUS_MULTICAST_FULL 0xC0010009
|
||||
#define NDIS_STATUS_MULTICAST_EXISTS 0xC001000A
|
||||
#define NDIS_STATUS_MULTICAST_NOT_FOUND 0xC001000B
|
||||
|
||||
enum NDIS_DEVICE_POWER_STATE {
|
||||
NdisDeviceStateUnspecified = 0,
|
||||
NdisDeviceStateD0,
|
||||
NdisDeviceStateD1,
|
||||
NdisDeviceStateD2,
|
||||
NdisDeviceStateD3,
|
||||
NdisDeviceStateMaximum
|
||||
};
|
||||
|
||||
struct NDIS_PM_WAKE_UP_CAPABILITIES {
|
||||
enum NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp;
|
||||
enum NDIS_DEVICE_POWER_STATE MinPatternWakeUp;
|
||||
enum NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp;
|
||||
};
|
||||
|
||||
/* NDIS_PNP_CAPABILITIES.Flags constants */
|
||||
#define NDIS_DEVICE_WAKE_UP_ENABLE 0x00000001
|
||||
#define NDIS_DEVICE_WAKE_ON_PATTERN_MATCH_ENABLE 0x00000002
|
||||
#define NDIS_DEVICE_WAKE_ON_MAGIC_PACKET_ENABLE 0x00000004
|
||||
|
||||
struct NDIS_PNP_CAPABILITIES {
|
||||
u32 Flags;
|
||||
struct NDIS_PM_WAKE_UP_CAPABILITIES WakeUpCapabilities;
|
||||
};
|
||||
|
||||
struct NDIS_PM_PACKET_PATTERN {
|
||||
u32 Priority;
|
||||
u32 Reserved;
|
||||
u32 MaskSize;
|
||||
u32 PatternOffset;
|
||||
u32 PatternSize;
|
||||
u32 PatternFlags;
|
||||
};
|
||||
|
||||
|
||||
/* Required Object IDs (OIDs) */
|
||||
#define OID_GEN_SUPPORTED_LIST 0x00010101
|
||||
#define OID_GEN_HARDWARE_STATUS 0x00010102
|
||||
#define OID_GEN_MEDIA_SUPPORTED 0x00010103
|
||||
#define OID_GEN_MEDIA_IN_USE 0x00010104
|
||||
#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105
|
||||
#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
|
||||
#define OID_GEN_LINK_SPEED 0x00010107
|
||||
#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108
|
||||
#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109
|
||||
#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
|
||||
#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
|
||||
#define OID_GEN_VENDOR_ID 0x0001010C
|
||||
#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D
|
||||
#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
|
||||
#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F
|
||||
#define OID_GEN_DRIVER_VERSION 0x00010110
|
||||
#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
|
||||
#define OID_GEN_PROTOCOL_OPTIONS 0x00010112
|
||||
#define OID_GEN_MAC_OPTIONS 0x00010113
|
||||
#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
|
||||
#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115
|
||||
#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
|
||||
#define OID_GEN_SUPPORTED_GUIDS 0x00010117
|
||||
#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118
|
||||
#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119
|
||||
#define OID_GEN_MACHINE_NAME 0x0001021A
|
||||
#define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B
|
||||
#define OID_GEN_VLAN_ID 0x0001021C
|
||||
|
||||
/* Optional OIDs */
|
||||
#define OID_GEN_MEDIA_CAPABILITIES 0x00010201
|
||||
#define OID_GEN_PHYSICAL_MEDIUM 0x00010202
|
||||
|
||||
/* Required statistics OIDs */
|
||||
#define OID_GEN_XMIT_OK 0x00020101
|
||||
#define OID_GEN_RCV_OK 0x00020102
|
||||
#define OID_GEN_XMIT_ERROR 0x00020103
|
||||
#define OID_GEN_RCV_ERROR 0x00020104
|
||||
#define OID_GEN_RCV_NO_BUFFER 0x00020105
|
||||
|
||||
/* Optional statistics OIDs */
|
||||
#define OID_GEN_DIRECTED_BYTES_XMIT 0x00020201
|
||||
#define OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202
|
||||
#define OID_GEN_MULTICAST_BYTES_XMIT 0x00020203
|
||||
#define OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204
|
||||
#define OID_GEN_BROADCAST_BYTES_XMIT 0x00020205
|
||||
#define OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206
|
||||
#define OID_GEN_DIRECTED_BYTES_RCV 0x00020207
|
||||
#define OID_GEN_DIRECTED_FRAMES_RCV 0x00020208
|
||||
#define OID_GEN_MULTICAST_BYTES_RCV 0x00020209
|
||||
#define OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A
|
||||
#define OID_GEN_BROADCAST_BYTES_RCV 0x0002020B
|
||||
#define OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C
|
||||
#define OID_GEN_RCV_CRC_ERROR 0x0002020D
|
||||
#define OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E
|
||||
#define OID_GEN_GET_TIME_CAPS 0x0002020F
|
||||
#define OID_GEN_GET_NETCARD_TIME 0x00020210
|
||||
#define OID_GEN_NETCARD_LOAD 0x00020211
|
||||
#define OID_GEN_DEVICE_PROFILE 0x00020212
|
||||
#define OID_GEN_INIT_TIME_MS 0x00020213
|
||||
#define OID_GEN_RESET_COUNTS 0x00020214
|
||||
#define OID_GEN_MEDIA_SENSE_COUNTS 0x00020215
|
||||
#define OID_GEN_FRIENDLY_NAME 0x00020216
|
||||
#define OID_GEN_MINIPORT_INFO 0x00020217
|
||||
#define OID_GEN_RESET_VERIFY_PARAMETERS 0x00020218
|
||||
|
||||
/* IEEE 802.3 (Ethernet) OIDs */
|
||||
#define NDIS_802_3_MAC_OPTION_PRIORITY 0x00000001
|
||||
|
||||
#define OID_802_3_PERMANENT_ADDRESS 0x01010101
|
||||
#define OID_802_3_CURRENT_ADDRESS 0x01010102
|
||||
#define OID_802_3_MULTICAST_LIST 0x01010103
|
||||
#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104
|
||||
#define OID_802_3_MAC_OPTIONS 0x01010105
|
||||
#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101
|
||||
#define OID_802_3_XMIT_ONE_COLLISION 0x01020102
|
||||
#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103
|
||||
#define OID_802_3_XMIT_DEFERRED 0x01020201
|
||||
#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202
|
||||
#define OID_802_3_RCV_OVERRUN 0x01020203
|
||||
#define OID_802_3_XMIT_UNDERRUN 0x01020204
|
||||
#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205
|
||||
#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206
|
||||
#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207
|
||||
|
||||
/* OID_GEN_MINIPORT_INFO constants */
|
||||
#define NDIS_MINIPORT_BUS_MASTER 0x00000001
|
||||
#define NDIS_MINIPORT_WDM_DRIVER 0x00000002
|
||||
#define NDIS_MINIPORT_SG_LIST 0x00000004
|
||||
#define NDIS_MINIPORT_SUPPORTS_MEDIA_QUERY 0x00000008
|
||||
#define NDIS_MINIPORT_INDICATES_PACKETS 0x00000010
|
||||
#define NDIS_MINIPORT_IGNORE_PACKET_QUEUE 0x00000020
|
||||
#define NDIS_MINIPORT_IGNORE_REQUEST_QUEUE 0x00000040
|
||||
#define NDIS_MINIPORT_IGNORE_TOKEN_RING_ERRORS 0x00000080
|
||||
#define NDIS_MINIPORT_INTERMEDIATE_DRIVER 0x00000100
|
||||
#define NDIS_MINIPORT_IS_NDIS_5 0x00000200
|
||||
#define NDIS_MINIPORT_IS_CO 0x00000400
|
||||
#define NDIS_MINIPORT_DESERIALIZE 0x00000800
|
||||
#define NDIS_MINIPORT_REQUIRES_MEDIA_POLLING 0x00001000
|
||||
#define NDIS_MINIPORT_SUPPORTS_MEDIA_SENSE 0x00002000
|
||||
#define NDIS_MINIPORT_NETBOOT_CARD 0x00004000
|
||||
#define NDIS_MINIPORT_PM_SUPPORTED 0x00008000
|
||||
#define NDIS_MINIPORT_SUPPORTS_MAC_ADDRESS_OVERWRITE 0x00010000
|
||||
#define NDIS_MINIPORT_USES_SAFE_BUFFER_APIS 0x00020000
|
||||
#define NDIS_MINIPORT_HIDDEN 0x00040000
|
||||
#define NDIS_MINIPORT_SWENUM 0x00080000
|
||||
#define NDIS_MINIPORT_SURPRISE_REMOVE_OK 0x00100000
|
||||
#define NDIS_MINIPORT_NO_HALT_ON_SUSPEND 0x00200000
|
||||
#define NDIS_MINIPORT_HARDWARE_DEVICE 0x00400000
|
||||
#define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS 0x00800000
|
||||
#define NDIS_MINIPORT_64BITS_DMA 0x01000000
|
||||
|
||||
#define NDIS_MEDIUM_802_3 0x00000000
|
||||
#define NDIS_MEDIUM_802_5 0x00000001
|
||||
#define NDIS_MEDIUM_FDDI 0x00000002
|
||||
#define NDIS_MEDIUM_WAN 0x00000003
|
||||
#define NDIS_MEDIUM_LOCAL_TALK 0x00000004
|
||||
#define NDIS_MEDIUM_DIX 0x00000005
|
||||
#define NDIS_MEDIUM_ARCENT_RAW 0x00000006
|
||||
#define NDIS_MEDIUM_ARCENT_878_2 0x00000007
|
||||
#define NDIS_MEDIUM_ATM 0x00000008
|
||||
#define NDIS_MEDIUM_WIRELESS_LAN 0x00000009
|
||||
#define NDIS_MEDIUM_IRDA 0x0000000A
|
||||
#define NDIS_MEDIUM_BPC 0x0000000B
|
||||
#define NDIS_MEDIUM_CO_WAN 0x0000000C
|
||||
#define NDIS_MEDIUM_1394 0x0000000D
|
||||
|
||||
#define NDIS_PACKET_TYPE_DIRECTED 0x00000001
|
||||
#define NDIS_PACKET_TYPE_MULTICAST 0x00000002
|
||||
#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
|
||||
#define NDIS_PACKET_TYPE_BROADCAST 0x00000008
|
||||
#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
|
||||
#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
|
||||
#define NDIS_PACKET_TYPE_SMT 0x00000040
|
||||
#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
|
||||
#define NDIS_PACKET_TYPE_GROUP 0x00000100
|
||||
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
|
||||
#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
|
||||
#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
|
||||
|
||||
#define NDIS_MEDIA_STATE_CONNECTED 0x00000000
|
||||
#define NDIS_MEDIA_STATE_DISCONNECTED 0x00000001
|
||||
|
||||
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001
|
||||
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002
|
||||
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND 0x00000004
|
||||
#define NDIS_MAC_OPTION_NO_LOOPBACK 0x00000008
|
||||
#define NDIS_MAC_OPTION_FULL_DUPLEX 0x00000010
|
||||
#define NDIS_MAC_OPTION_EOTX_INDICATION 0x00000020
|
||||
#define NDIS_MAC_OPTION_8021P_PRIORITY 0x00000040
|
||||
#define NDIS_MAC_OPTION_RESERVED 0x80000000
|
||||
|
||||
#endif /* _LINUX_NDIS_H */
|
2967
drivers/usb/gadget/net2280.c
Normální soubor
2967
drivers/usb/gadget/net2280.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
728
drivers/usb/gadget/net2280.h
Normální soubor
728
drivers/usb/gadget/net2280.h
Normální soubor
@@ -0,0 +1,728 @@
|
||||
/*
|
||||
* NetChip 2280 high/full speed USB device controller.
|
||||
* Unlike many such controllers, this one talks PCI.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* NET2280 MEMORY MAPPED REGISTERS
|
||||
*
|
||||
* The register layout came from the chip documentation, and the bit
|
||||
* number definitions were extracted from chip specification.
|
||||
*
|
||||
* Use the shift operator ('<<') to build bit masks, with readl/writel
|
||||
* to access the registers through PCI.
|
||||
*/
|
||||
|
||||
/* main registers, BAR0 + 0x0000 */
|
||||
struct net2280_regs {
|
||||
// offset 0x0000
|
||||
u32 devinit;
|
||||
#define LOCAL_CLOCK_FREQUENCY 8
|
||||
#define FORCE_PCI_RESET 7
|
||||
#define PCI_ID 6
|
||||
#define PCI_ENABLE 5
|
||||
#define FIFO_SOFT_RESET 4
|
||||
#define CFG_SOFT_RESET 3
|
||||
#define PCI_SOFT_RESET 2
|
||||
#define USB_SOFT_RESET 1
|
||||
#define M8051_RESET 0
|
||||
u32 eectl;
|
||||
#define EEPROM_ADDRESS_WIDTH 23
|
||||
#define EEPROM_CHIP_SELECT_ACTIVE 22
|
||||
#define EEPROM_PRESENT 21
|
||||
#define EEPROM_VALID 20
|
||||
#define EEPROM_BUSY 19
|
||||
#define EEPROM_CHIP_SELECT_ENABLE 18
|
||||
#define EEPROM_BYTE_READ_START 17
|
||||
#define EEPROM_BYTE_WRITE_START 16
|
||||
#define EEPROM_READ_DATA 8
|
||||
#define EEPROM_WRITE_DATA 0
|
||||
u32 eeclkfreq;
|
||||
u32 _unused0;
|
||||
// offset 0x0010
|
||||
|
||||
u32 pciirqenb0; /* interrupt PCI master ... */
|
||||
#define SETUP_PACKET_INTERRUPT_ENABLE 7
|
||||
#define ENDPOINT_F_INTERRUPT_ENABLE 6
|
||||
#define ENDPOINT_E_INTERRUPT_ENABLE 5
|
||||
#define ENDPOINT_D_INTERRUPT_ENABLE 4
|
||||
#define ENDPOINT_C_INTERRUPT_ENABLE 3
|
||||
#define ENDPOINT_B_INTERRUPT_ENABLE 2
|
||||
#define ENDPOINT_A_INTERRUPT_ENABLE 1
|
||||
#define ENDPOINT_0_INTERRUPT_ENABLE 0
|
||||
u32 pciirqenb1;
|
||||
#define PCI_INTERRUPT_ENABLE 31
|
||||
#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
|
||||
#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
|
||||
#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
|
||||
#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
|
||||
#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
|
||||
#define PCI_TARGET_ABORT_ASSERTED_INTERRUPT_ENABLE 18
|
||||
#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
|
||||
#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
|
||||
#define GPIO_INTERRUPT_ENABLE 13
|
||||
#define DMA_D_INTERRUPT_ENABLE 12
|
||||
#define DMA_C_INTERRUPT_ENABLE 11
|
||||
#define DMA_B_INTERRUPT_ENABLE 10
|
||||
#define DMA_A_INTERRUPT_ENABLE 9
|
||||
#define EEPROM_DONE_INTERRUPT_ENABLE 8
|
||||
#define VBUS_INTERRUPT_ENABLE 7
|
||||
#define CONTROL_STATUS_INTERRUPT_ENABLE 6
|
||||
#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
|
||||
#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
|
||||
#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
|
||||
#define RESUME_INTERRUPT_ENABLE 1
|
||||
#define SOF_INTERRUPT_ENABLE 0
|
||||
u32 cpu_irqenb0; /* ... or onboard 8051 */
|
||||
#define SETUP_PACKET_INTERRUPT_ENABLE 7
|
||||
#define ENDPOINT_F_INTERRUPT_ENABLE 6
|
||||
#define ENDPOINT_E_INTERRUPT_ENABLE 5
|
||||
#define ENDPOINT_D_INTERRUPT_ENABLE 4
|
||||
#define ENDPOINT_C_INTERRUPT_ENABLE 3
|
||||
#define ENDPOINT_B_INTERRUPT_ENABLE 2
|
||||
#define ENDPOINT_A_INTERRUPT_ENABLE 1
|
||||
#define ENDPOINT_0_INTERRUPT_ENABLE 0
|
||||
u32 cpu_irqenb1;
|
||||
#define CPU_INTERRUPT_ENABLE 31
|
||||
#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
|
||||
#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
|
||||
#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
|
||||
#define PCI_INTA_INTERRUPT_ENABLE 24
|
||||
#define PCI_PME_INTERRUPT_ENABLE 23
|
||||
#define PCI_SERR_INTERRUPT_ENABLE 22
|
||||
#define PCI_PERR_INTERRUPT_ENABLE 21
|
||||
#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
|
||||
#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
|
||||
#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
|
||||
#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
|
||||
#define GPIO_INTERRUPT_ENABLE 13
|
||||
#define DMA_D_INTERRUPT_ENABLE 12
|
||||
#define DMA_C_INTERRUPT_ENABLE 11
|
||||
#define DMA_B_INTERRUPT_ENABLE 10
|
||||
#define DMA_A_INTERRUPT_ENABLE 9
|
||||
#define EEPROM_DONE_INTERRUPT_ENABLE 8
|
||||
#define VBUS_INTERRUPT_ENABLE 7
|
||||
#define CONTROL_STATUS_INTERRUPT_ENABLE 6
|
||||
#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
|
||||
#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
|
||||
#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
|
||||
#define RESUME_INTERRUPT_ENABLE 1
|
||||
#define SOF_INTERRUPT_ENABLE 0
|
||||
|
||||
// offset 0x0020
|
||||
u32 _unused1;
|
||||
u32 usbirqenb1;
|
||||
#define USB_INTERRUPT_ENABLE 31
|
||||
#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
|
||||
#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
|
||||
#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
|
||||
#define PCI_INTA_INTERRUPT_ENABLE 24
|
||||
#define PCI_PME_INTERRUPT_ENABLE 23
|
||||
#define PCI_SERR_INTERRUPT_ENABLE 22
|
||||
#define PCI_PERR_INTERRUPT_ENABLE 21
|
||||
#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
|
||||
#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
|
||||
#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
|
||||
#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
|
||||
#define GPIO_INTERRUPT_ENABLE 13
|
||||
#define DMA_D_INTERRUPT_ENABLE 12
|
||||
#define DMA_C_INTERRUPT_ENABLE 11
|
||||
#define DMA_B_INTERRUPT_ENABLE 10
|
||||
#define DMA_A_INTERRUPT_ENABLE 9
|
||||
#define EEPROM_DONE_INTERRUPT_ENABLE 8
|
||||
#define VBUS_INTERRUPT_ENABLE 7
|
||||
#define CONTROL_STATUS_INTERRUPT_ENABLE 6
|
||||
#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
|
||||
#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
|
||||
#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
|
||||
#define RESUME_INTERRUPT_ENABLE 1
|
||||
#define SOF_INTERRUPT_ENABLE 0
|
||||
u32 irqstat0;
|
||||
#define INTA_ASSERTED 12
|
||||
#define SETUP_PACKET_INTERRUPT 7
|
||||
#define ENDPOINT_F_INTERRUPT 6
|
||||
#define ENDPOINT_E_INTERRUPT 5
|
||||
#define ENDPOINT_D_INTERRUPT 4
|
||||
#define ENDPOINT_C_INTERRUPT 3
|
||||
#define ENDPOINT_B_INTERRUPT 2
|
||||
#define ENDPOINT_A_INTERRUPT 1
|
||||
#define ENDPOINT_0_INTERRUPT 0
|
||||
u32 irqstat1;
|
||||
#define POWER_STATE_CHANGE_INTERRUPT 27
|
||||
#define PCI_ARBITER_TIMEOUT_INTERRUPT 26
|
||||
#define PCI_PARITY_ERROR_INTERRUPT 25
|
||||
#define PCI_INTA_INTERRUPT 24
|
||||
#define PCI_PME_INTERRUPT 23
|
||||
#define PCI_SERR_INTERRUPT 22
|
||||
#define PCI_PERR_INTERRUPT 21
|
||||
#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT 20
|
||||
#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT 19
|
||||
#define PCI_RETRY_ABORT_INTERRUPT 17
|
||||
#define PCI_MASTER_CYCLE_DONE_INTERRUPT 16
|
||||
#define GPIO_INTERRUPT 13
|
||||
#define DMA_D_INTERRUPT 12
|
||||
#define DMA_C_INTERRUPT 11
|
||||
#define DMA_B_INTERRUPT 10
|
||||
#define DMA_A_INTERRUPT 9
|
||||
#define EEPROM_DONE_INTERRUPT 8
|
||||
#define VBUS_INTERRUPT 7
|
||||
#define CONTROL_STATUS_INTERRUPT 6
|
||||
#define ROOT_PORT_RESET_INTERRUPT 4
|
||||
#define SUSPEND_REQUEST_INTERRUPT 3
|
||||
#define SUSPEND_REQUEST_CHANGE_INTERRUPT 2
|
||||
#define RESUME_INTERRUPT 1
|
||||
#define SOF_INTERRUPT 0
|
||||
// offset 0x0030
|
||||
u32 idxaddr;
|
||||
u32 idxdata;
|
||||
u32 fifoctl;
|
||||
#define PCI_BASE2_RANGE 16
|
||||
#define IGNORE_FIFO_AVAILABILITY 3
|
||||
#define PCI_BASE2_SELECT 2
|
||||
#define FIFO_CONFIGURATION_SELECT 0
|
||||
u32 _unused2;
|
||||
// offset 0x0040
|
||||
u32 memaddr;
|
||||
#define START 28
|
||||
#define DIRECTION 27
|
||||
#define FIFO_DIAGNOSTIC_SELECT 24
|
||||
#define MEMORY_ADDRESS 0
|
||||
u32 memdata0;
|
||||
u32 memdata1;
|
||||
u32 _unused3;
|
||||
// offset 0x0050
|
||||
u32 gpioctl;
|
||||
#define GPIO3_LED_SELECT 12
|
||||
#define GPIO3_INTERRUPT_ENABLE 11
|
||||
#define GPIO2_INTERRUPT_ENABLE 10
|
||||
#define GPIO1_INTERRUPT_ENABLE 9
|
||||
#define GPIO0_INTERRUPT_ENABLE 8
|
||||
#define GPIO3_OUTPUT_ENABLE 7
|
||||
#define GPIO2_OUTPUT_ENABLE 6
|
||||
#define GPIO1_OUTPUT_ENABLE 5
|
||||
#define GPIO0_OUTPUT_ENABLE 4
|
||||
#define GPIO3_DATA 3
|
||||
#define GPIO2_DATA 2
|
||||
#define GPIO1_DATA 1
|
||||
#define GPIO0_DATA 0
|
||||
u32 gpiostat;
|
||||
#define GPIO3_INTERRUPT 3
|
||||
#define GPIO2_INTERRUPT 2
|
||||
#define GPIO1_INTERRUPT 1
|
||||
#define GPIO0_INTERRUPT 0
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* usb control, BAR0 + 0x0080 */
|
||||
struct net2280_usb_regs {
|
||||
// offset 0x0080
|
||||
u32 stdrsp;
|
||||
#define STALL_UNSUPPORTED_REQUESTS 31
|
||||
#define SET_TEST_MODE 16
|
||||
#define GET_OTHER_SPEED_CONFIGURATION 15
|
||||
#define GET_DEVICE_QUALIFIER 14
|
||||
#define SET_ADDRESS 13
|
||||
#define ENDPOINT_SET_CLEAR_HALT 12
|
||||
#define DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP 11
|
||||
#define GET_STRING_DESCRIPTOR_2 10
|
||||
#define GET_STRING_DESCRIPTOR_1 9
|
||||
#define GET_STRING_DESCRIPTOR_0 8
|
||||
#define GET_SET_INTERFACE 6
|
||||
#define GET_SET_CONFIGURATION 5
|
||||
#define GET_CONFIGURATION_DESCRIPTOR 4
|
||||
#define GET_DEVICE_DESCRIPTOR 3
|
||||
#define GET_ENDPOINT_STATUS 2
|
||||
#define GET_INTERFACE_STATUS 1
|
||||
#define GET_DEVICE_STATUS 0
|
||||
u32 prodvendid;
|
||||
#define PRODUCT_ID 16
|
||||
#define VENDOR_ID 0
|
||||
u32 relnum;
|
||||
u32 usbctl;
|
||||
#define SERIAL_NUMBER_INDEX 16
|
||||
#define PRODUCT_ID_STRING_ENABLE 13
|
||||
#define VENDOR_ID_STRING_ENABLE 12
|
||||
#define USB_ROOT_PORT_WAKEUP_ENABLE 11
|
||||
#define VBUS_PIN 10
|
||||
#define TIMED_DISCONNECT 9
|
||||
#define SUSPEND_IMMEDIATELY 7
|
||||
#define SELF_POWERED_USB_DEVICE 6
|
||||
#define REMOTE_WAKEUP_SUPPORT 5
|
||||
#define PME_POLARITY 4
|
||||
#define USB_DETECT_ENABLE 3
|
||||
#define PME_WAKEUP_ENABLE 2
|
||||
#define DEVICE_REMOTE_WAKEUP_ENABLE 1
|
||||
#define SELF_POWERED_STATUS 0
|
||||
// offset 0x0090
|
||||
u32 usbstat;
|
||||
#define HIGH_SPEED 7
|
||||
#define FULL_SPEED 6
|
||||
#define GENERATE_RESUME 5
|
||||
#define GENERATE_DEVICE_REMOTE_WAKEUP 4
|
||||
u32 xcvrdiag;
|
||||
#define FORCE_HIGH_SPEED_MODE 31
|
||||
#define FORCE_FULL_SPEED_MODE 30
|
||||
#define USB_TEST_MODE 24
|
||||
#define LINE_STATE 16
|
||||
#define TRANSCEIVER_OPERATION_MODE 2
|
||||
#define TRANSCEIVER_SELECT 1
|
||||
#define TERMINATION_SELECT 0
|
||||
u32 setup0123;
|
||||
u32 setup4567;
|
||||
// offset 0x0090
|
||||
u32 _unused0;
|
||||
u32 ouraddr;
|
||||
#define FORCE_IMMEDIATE 7
|
||||
#define OUR_USB_ADDRESS 0
|
||||
u32 ourconfig;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* pci control, BAR0 + 0x0100 */
|
||||
struct net2280_pci_regs {
|
||||
// offset 0x0100
|
||||
u32 pcimstctl;
|
||||
#define PCI_ARBITER_PARK_SELECT 13
|
||||
#define PCI_MULTI LEVEL_ARBITER 12
|
||||
#define PCI_RETRY_ABORT_ENABLE 11
|
||||
#define DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE 10
|
||||
#define DMA_READ_MULTIPLE_ENABLE 9
|
||||
#define DMA_READ_LINE_ENABLE 8
|
||||
#define PCI_MASTER_COMMAND_SELECT 6
|
||||
#define MEM_READ_OR_WRITE 0
|
||||
#define IO_READ_OR_WRITE 1
|
||||
#define CFG_READ_OR_WRITE 2
|
||||
#define PCI_MASTER_START 5
|
||||
#define PCI_MASTER_READ_WRITE 4
|
||||
#define PCI_MASTER_WRITE 0
|
||||
#define PCI_MASTER_READ 1
|
||||
#define PCI_MASTER_BYTE_WRITE_ENABLES 0
|
||||
u32 pcimstaddr;
|
||||
u32 pcimstdata;
|
||||
u32 pcimststat;
|
||||
#define PCI_ARBITER_CLEAR 2
|
||||
#define PCI_EXTERNAL_ARBITER 1
|
||||
#define PCI_HOST_MODE 0
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* dma control, BAR0 + 0x0180 ... array of four structs like this,
|
||||
* for channels 0..3. see also struct net2280_dma: descriptor
|
||||
* that can be loaded into some of these registers.
|
||||
*/
|
||||
struct net2280_dma_regs { /* [11.7] */
|
||||
// offset 0x0180, 0x01a0, 0x01c0, 0x01e0,
|
||||
u32 dmactl;
|
||||
#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25
|
||||
#define DMA_CLEAR_COUNT_ENABLE 21
|
||||
#define DESCRIPTOR_POLLING_RATE 19
|
||||
#define POLL_CONTINUOUS 0
|
||||
#define POLL_1_USEC 1
|
||||
#define POLL_100_USEC 2
|
||||
#define POLL_1_MSEC 3
|
||||
#define DMA_VALID_BIT_POLLING_ENABLE 18
|
||||
#define DMA_VALID_BIT_ENABLE 17
|
||||
#define DMA_SCATTER_GATHER_ENABLE 16
|
||||
#define DMA_OUT_AUTO_START_ENABLE 4
|
||||
#define DMA_PREEMPT_ENABLE 3
|
||||
#define DMA_FIFO_VALIDATE 2
|
||||
#define DMA_ENABLE 1
|
||||
#define DMA_ADDRESS_HOLD 0
|
||||
u32 dmastat;
|
||||
#define DMA_SCATTER_GATHER_DONE_INTERRUPT 25
|
||||
#define DMA_TRANSACTION_DONE_INTERRUPT 24
|
||||
#define DMA_ABORT 1
|
||||
#define DMA_START 0
|
||||
u32 _unused0 [2];
|
||||
// offset 0x0190, 0x01b0, 0x01d0, 0x01f0,
|
||||
u32 dmacount;
|
||||
#define VALID_BIT 31
|
||||
#define DMA_DIRECTION 30
|
||||
#define DMA_DONE_INTERRUPT_ENABLE 29
|
||||
#define END_OF_CHAIN 28
|
||||
#define DMA_BYTE_COUNT_MASK ((1<<24)-1)
|
||||
#define DMA_BYTE_COUNT 0
|
||||
u32 dmaaddr;
|
||||
u32 dmadesc;
|
||||
u32 _unused1;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* dedicated endpoint registers, BAR0 + 0x0200 */
|
||||
|
||||
struct net2280_dep_regs { /* [11.8] */
|
||||
// offset 0x0200, 0x0210, 0x220, 0x230, 0x240
|
||||
u32 dep_cfg;
|
||||
// offset 0x0204, 0x0214, 0x224, 0x234, 0x244
|
||||
u32 dep_rsp;
|
||||
u32 _unused [2];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs
|
||||
* like this, for ep0 then the configurable endpoints A..F
|
||||
* ep0 reserved for control; E and F have only 64 bytes of fifo
|
||||
*/
|
||||
struct net2280_ep_regs { /* [11.9] */
|
||||
// offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0
|
||||
u32 ep_cfg;
|
||||
#define ENDPOINT_BYTE_COUNT 16
|
||||
#define ENDPOINT_ENABLE 10
|
||||
#define ENDPOINT_TYPE 8
|
||||
#define ENDPOINT_DIRECTION 7
|
||||
#define ENDPOINT_NUMBER 0
|
||||
u32 ep_rsp;
|
||||
#define SET_NAK_OUT_PACKETS 15
|
||||
#define SET_EP_HIDE_STATUS_PHASE 14
|
||||
#define SET_EP_FORCE_CRC_ERROR 13
|
||||
#define SET_INTERRUPT_MODE 12
|
||||
#define SET_CONTROL_STATUS_PHASE_HANDSHAKE 11
|
||||
#define SET_NAK_OUT_PACKETS_MODE 10
|
||||
#define SET_ENDPOINT_TOGGLE 9
|
||||
#define SET_ENDPOINT_HALT 8
|
||||
#define CLEAR_NAK_OUT_PACKETS 7
|
||||
#define CLEAR_EP_HIDE_STATUS_PHASE 6
|
||||
#define CLEAR_EP_FORCE_CRC_ERROR 5
|
||||
#define CLEAR_INTERRUPT_MODE 4
|
||||
#define CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE 3
|
||||
#define CLEAR_NAK_OUT_PACKETS_MODE 2
|
||||
#define CLEAR_ENDPOINT_TOGGLE 1
|
||||
#define CLEAR_ENDPOINT_HALT 0
|
||||
u32 ep_irqenb;
|
||||
#define SHORT_PACKET_OUT_DONE_INTERRUPT_ENABLE 6
|
||||
#define SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE 5
|
||||
#define DATA_PACKET_RECEIVED_INTERRUPT_ENABLE 3
|
||||
#define DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE 2
|
||||
#define DATA_OUT_PING_TOKEN_INTERRUPT_ENABLE 1
|
||||
#define DATA_IN_TOKEN_INTERRUPT_ENABLE 0
|
||||
u32 ep_stat;
|
||||
#define FIFO_VALID_COUNT 24
|
||||
#define HIGH_BANDWIDTH_OUT_TRANSACTION_PID 22
|
||||
#define TIMEOUT 21
|
||||
#define USB_STALL_SENT 20
|
||||
#define USB_IN_NAK_SENT 19
|
||||
#define USB_IN_ACK_RCVD 18
|
||||
#define USB_OUT_PING_NAK_SENT 17
|
||||
#define USB_OUT_ACK_SENT 16
|
||||
#define FIFO_OVERFLOW 13
|
||||
#define FIFO_UNDERFLOW 12
|
||||
#define FIFO_FULL 11
|
||||
#define FIFO_EMPTY 10
|
||||
#define FIFO_FLUSH 9
|
||||
#define SHORT_PACKET_OUT_DONE_INTERRUPT 6
|
||||
#define SHORT_PACKET_TRANSFERRED_INTERRUPT 5
|
||||
#define NAK_OUT_PACKETS 4
|
||||
#define DATA_PACKET_RECEIVED_INTERRUPT 3
|
||||
#define DATA_PACKET_TRANSMITTED_INTERRUPT 2
|
||||
#define DATA_OUT_PING_TOKEN_INTERRUPT 1
|
||||
#define DATA_IN_TOKEN_INTERRUPT 0
|
||||
// offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0
|
||||
u32 ep_avail;
|
||||
u32 ep_data;
|
||||
u32 _unused0 [2];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/* indexed registers [11.10] are accessed indirectly
|
||||
* caller must own the device lock.
|
||||
*/
|
||||
|
||||
static inline u32
|
||||
get_idx_reg (struct net2280_regs __iomem *regs, u32 index)
|
||||
{
|
||||
writel (index, ®s->idxaddr);
|
||||
/* NOTE: synchs device/cpu memory views */
|
||||
return readl (®s->idxdata);
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_idx_reg (struct net2280_regs __iomem *regs, u32 index, u32 value)
|
||||
{
|
||||
writel (index, ®s->idxaddr);
|
||||
writel (value, ®s->idxdata);
|
||||
/* posted, may not be visible yet */
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
|
||||
#define REG_DIAG 0x0
|
||||
#define RETRY_COUNTER 16
|
||||
#define FORCE_PCI_SERR 11
|
||||
#define FORCE_PCI_INTERRUPT 10
|
||||
#define FORCE_USB_INTERRUPT 9
|
||||
#define FORCE_CPU_INTERRUPT 8
|
||||
#define ILLEGAL_BYTE_ENABLES 5
|
||||
#define FAST_TIMES 4
|
||||
#define FORCE_RECEIVE_ERROR 2
|
||||
#define FORCE_TRANSMIT_CRC_ERROR 0
|
||||
#define REG_FRAME 0x02 /* from last sof */
|
||||
#define REG_CHIPREV 0x03 /* in bcd */
|
||||
#define REG_HS_NAK_RATE 0x0a /* NAK per N uframes */
|
||||
|
||||
#define CHIPREV_1 0x0100
|
||||
#define CHIPREV_1A 0x0110
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/* ep a-f highspeed and fullspeed maxpacket, addresses
|
||||
* computed from ep->num
|
||||
*/
|
||||
#define REG_EP_MAXPKT(dev,num) (((num) + 1) * 0x10 + \
|
||||
(((dev)->gadget.speed == USB_SPEED_HIGH) ? 0 : 1))
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* [8.3] for scatter/gather i/o
|
||||
* use struct net2280_dma_regs bitfields
|
||||
*/
|
||||
struct net2280_dma {
|
||||
__le32 dmacount;
|
||||
__le32 dmaaddr; /* the buffer */
|
||||
__le32 dmadesc; /* next dma descriptor */
|
||||
__le32 _reserved;
|
||||
} __attribute__ ((aligned (16)));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* DRIVER DATA STRUCTURES and UTILITIES */
|
||||
|
||||
struct net2280_ep {
|
||||
struct usb_ep ep;
|
||||
struct net2280_ep_regs __iomem *regs;
|
||||
struct net2280_dma_regs __iomem *dma;
|
||||
struct net2280_dma *dummy;
|
||||
dma_addr_t td_dma; /* of dummy */
|
||||
struct net2280 *dev;
|
||||
unsigned long irqs;
|
||||
|
||||
/* analogous to a host-side qh */
|
||||
struct list_head queue;
|
||||
const struct usb_endpoint_descriptor *desc;
|
||||
unsigned num : 8,
|
||||
fifo_size : 12,
|
||||
in_fifo_validate : 1,
|
||||
out_overflow : 1,
|
||||
stopped : 1,
|
||||
is_in : 1,
|
||||
is_iso : 1;
|
||||
};
|
||||
|
||||
static inline void allow_status (struct net2280_ep *ep)
|
||||
{
|
||||
/* ep0 only */
|
||||
writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
|
||||
| (1 << CLEAR_NAK_OUT_PACKETS)
|
||||
| (1 << CLEAR_NAK_OUT_PACKETS_MODE)
|
||||
, &ep->regs->ep_rsp);
|
||||
ep->stopped = 1;
|
||||
}
|
||||
|
||||
/* count (<= 4) bytes in the next fifo write will be valid */
|
||||
static inline void set_fifo_bytecount (struct net2280_ep *ep, unsigned count)
|
||||
{
|
||||
writeb (count, 2 + (u8 __iomem *) &ep->regs->ep_cfg);
|
||||
}
|
||||
|
||||
struct net2280_request {
|
||||
struct usb_request req;
|
||||
struct net2280_dma *td;
|
||||
dma_addr_t td_dma;
|
||||
struct list_head queue;
|
||||
unsigned mapped : 1,
|
||||
valid : 1;
|
||||
};
|
||||
|
||||
struct net2280 {
|
||||
/* each pci device provides one gadget, several endpoints */
|
||||
struct usb_gadget gadget;
|
||||
spinlock_t lock;
|
||||
struct net2280_ep ep [7];
|
||||
struct usb_gadget_driver *driver;
|
||||
unsigned enabled : 1,
|
||||
protocol_stall : 1,
|
||||
softconnect : 1,
|
||||
got_irq : 1,
|
||||
region : 1;
|
||||
u16 chiprev;
|
||||
|
||||
/* pci state used to access those endpoints */
|
||||
struct pci_dev *pdev;
|
||||
struct net2280_regs __iomem *regs;
|
||||
struct net2280_usb_regs __iomem *usb;
|
||||
struct net2280_pci_regs __iomem *pci;
|
||||
struct net2280_dma_regs __iomem *dma;
|
||||
struct net2280_dep_regs __iomem *dep;
|
||||
struct net2280_ep_regs __iomem *epregs;
|
||||
|
||||
struct pci_pool *requests;
|
||||
// statistics...
|
||||
};
|
||||
|
||||
static inline void set_halt (struct net2280_ep *ep)
|
||||
{
|
||||
/* ep0 and bulk/intr endpoints */
|
||||
writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
|
||||
/* set NAK_OUT for erratum 0114 */
|
||||
| ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS)
|
||||
| (1 << SET_ENDPOINT_HALT)
|
||||
, &ep->regs->ep_rsp);
|
||||
}
|
||||
|
||||
static inline void clear_halt (struct net2280_ep *ep)
|
||||
{
|
||||
/* ep0 and bulk/intr endpoints */
|
||||
writel ( (1 << CLEAR_ENDPOINT_HALT)
|
||||
| (1 << CLEAR_ENDPOINT_TOGGLE)
|
||||
/* unless the gadget driver left a short packet in the
|
||||
* fifo, this reverses the erratum 0114 workaround.
|
||||
*/
|
||||
| ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS)
|
||||
, &ep->regs->ep_rsp);
|
||||
}
|
||||
|
||||
#ifdef USE_RDK_LEDS
|
||||
|
||||
static inline void net2280_led_init (struct net2280 *dev)
|
||||
{
|
||||
/* LED3 (green) is on during USB activity. note erratum 0113. */
|
||||
writel ((1 << GPIO3_LED_SELECT)
|
||||
| (1 << GPIO3_OUTPUT_ENABLE)
|
||||
| (1 << GPIO2_OUTPUT_ENABLE)
|
||||
| (1 << GPIO1_OUTPUT_ENABLE)
|
||||
| (1 << GPIO0_OUTPUT_ENABLE)
|
||||
, &dev->regs->gpioctl);
|
||||
}
|
||||
|
||||
/* indicate speed with bi-color LED 0/1 */
|
||||
static inline
|
||||
void net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed)
|
||||
{
|
||||
u32 val = readl (&dev->regs->gpioctl);
|
||||
switch (speed) {
|
||||
case USB_SPEED_HIGH: /* green */
|
||||
val &= ~(1 << GPIO0_DATA);
|
||||
val |= (1 << GPIO1_DATA);
|
||||
break;
|
||||
case USB_SPEED_FULL: /* red */
|
||||
val &= ~(1 << GPIO1_DATA);
|
||||
val |= (1 << GPIO0_DATA);
|
||||
break;
|
||||
default: /* (off/black) */
|
||||
val &= ~((1 << GPIO1_DATA) | (1 << GPIO0_DATA));
|
||||
break;
|
||||
}
|
||||
writel (val, &dev->regs->gpioctl);
|
||||
}
|
||||
|
||||
/* indicate power with LED 2 */
|
||||
static inline void net2280_led_active (struct net2280 *dev, int is_active)
|
||||
{
|
||||
u32 val = readl (&dev->regs->gpioctl);
|
||||
|
||||
// FIXME this LED never seems to turn on.
|
||||
if (is_active)
|
||||
val |= GPIO2_DATA;
|
||||
else
|
||||
val &= ~GPIO2_DATA;
|
||||
writel (val, &dev->regs->gpioctl);
|
||||
}
|
||||
static inline void net2280_led_shutdown (struct net2280 *dev)
|
||||
{
|
||||
/* turn off all four GPIO*_DATA bits */
|
||||
writel (readl (&dev->regs->gpioctl) & ~0x0f,
|
||||
&dev->regs->gpioctl);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define net2280_led_init(dev) do { } while (0)
|
||||
#define net2280_led_speed(dev, speed) do { } while (0)
|
||||
#define net2280_led_shutdown(dev) do { } while (0)
|
||||
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#define xprintk(dev,level,fmt,args...) \
|
||||
printk(level "%s %s: " fmt , driver_name , \
|
||||
pci_name(dev->pdev) , ## args)
|
||||
|
||||
#ifdef DEBUG
|
||||
#undef DEBUG
|
||||
#define DEBUG(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_DEBUG , fmt , ## args)
|
||||
#else
|
||||
#define DEBUG(dev,fmt,args...) \
|
||||
do { } while (0)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#ifdef VERBOSE
|
||||
#define VDEBUG DEBUG
|
||||
#else
|
||||
#define VDEBUG(dev,fmt,args...) \
|
||||
do { } while (0)
|
||||
#endif /* VERBOSE */
|
||||
|
||||
#define ERROR(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_ERR , fmt , ## args)
|
||||
#define WARN(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_WARNING , fmt , ## args)
|
||||
#define INFO(dev,fmt,args...) \
|
||||
xprintk(dev , KERN_INFO , fmt , ## args)
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
static inline void start_out_naking (struct net2280_ep *ep)
|
||||
{
|
||||
/* NOTE: hardware races lurk here, and PING protocol issues */
|
||||
writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
|
||||
/* synch with device */
|
||||
readl (&ep->regs->ep_rsp);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static inline void assert_out_naking (struct net2280_ep *ep, const char *where)
|
||||
{
|
||||
u32 tmp = readl (&ep->regs->ep_stat);
|
||||
|
||||
if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) {
|
||||
DEBUG (ep->dev, "%s %s %08x !NAK\n",
|
||||
ep->ep.name, where, tmp);
|
||||
writel ((1 << SET_NAK_OUT_PACKETS),
|
||||
&ep->regs->ep_rsp);
|
||||
}
|
||||
}
|
||||
#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep,__FUNCTION__)
|
||||
#else
|
||||
#define ASSERT_OUT_NAKING(ep) do {} while (0)
|
||||
#endif
|
||||
|
||||
static inline void stop_out_naking (struct net2280_ep *ep)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
tmp = readl (&ep->regs->ep_stat);
|
||||
if ((tmp & (1 << NAK_OUT_PACKETS)) != 0)
|
||||
writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
2872
drivers/usb/gadget/omap_udc.c
Normální soubor
2872
drivers/usb/gadget/omap_udc.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
208
drivers/usb/gadget/omap_udc.h
Normální soubor
208
drivers/usb/gadget/omap_udc.h
Normální soubor
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* omap_udc.h -- for omap 3.2 udc, with OTG support
|
||||
*
|
||||
* 2004 (C) Texas Instruments, Inc.
|
||||
* 2004 (C) David Brownell
|
||||
*/
|
||||
|
||||
/*
|
||||
* USB device/endpoint management registers
|
||||
*/
|
||||
#define UDC_REG(offset) __REG16(UDC_BASE + (offset))
|
||||
|
||||
#define UDC_REV_REG UDC_REG(0x0) /* Revision */
|
||||
#define UDC_EP_NUM_REG UDC_REG(0x4) /* Which endpoint */
|
||||
# define UDC_SETUP_SEL (1 << 6)
|
||||
# define UDC_EP_SEL (1 << 5)
|
||||
# define UDC_EP_DIR (1 << 4)
|
||||
/* low 4 bits for endpoint number */
|
||||
#define UDC_DATA_REG UDC_REG(0x08) /* Endpoint FIFO */
|
||||
#define UDC_CTRL_REG UDC_REG(0x0C) /* Endpoint control */
|
||||
# define UDC_CLR_HALT (1 << 7)
|
||||
# define UDC_SET_HALT (1 << 6)
|
||||
# define UDC_SET_FIFO_EN (1 << 2)
|
||||
# define UDC_CLR_EP (1 << 1)
|
||||
# define UDC_RESET_EP (1 << 0)
|
||||
#define UDC_STAT_FLG_REG UDC_REG(0x10) /* Endpoint status */
|
||||
# define UDC_NO_RXPACKET (1 << 15)
|
||||
# define UDC_MISS_IN (1 << 14)
|
||||
# define UDC_DATA_FLUSH (1 << 13)
|
||||
# define UDC_ISO_ERR (1 << 12)
|
||||
# define UDC_ISO_FIFO_EMPTY (1 << 9)
|
||||
# define UDC_ISO_FIFO_FULL (1 << 8)
|
||||
# define UDC_EP_HALTED (1 << 6)
|
||||
# define UDC_STALL (1 << 5)
|
||||
# define UDC_NAK (1 << 4)
|
||||
# define UDC_ACK (1 << 3)
|
||||
# define UDC_FIFO_EN (1 << 2)
|
||||
# define UDC_NON_ISO_FIFO_EMPTY (1 << 1)
|
||||
# define UDC_NON_ISO_FIFO_FULL (1 << 0)
|
||||
#define UDC_RXFSTAT_REG UDC_REG(0x14) /* OUT bytecount */
|
||||
#define UDC_SYSCON1_REG UDC_REG(0x18) /* System config 1 */
|
||||
# define UDC_CFG_LOCK (1 << 8)
|
||||
# define UDC_DATA_ENDIAN (1 << 7)
|
||||
# define UDC_DMA_ENDIAN (1 << 6)
|
||||
# define UDC_NAK_EN (1 << 4)
|
||||
# define UDC_AUTODECODE_DIS (1 << 3)
|
||||
# define UDC_SELF_PWR (1 << 2)
|
||||
# define UDC_SOFF_DIS (1 << 1)
|
||||
# define UDC_PULLUP_EN (1 << 0)
|
||||
#define UDC_SYSCON2_REG UDC_REG(0x1C) /* System config 2 */
|
||||
# define UDC_RMT_WKP (1 << 6)
|
||||
# define UDC_STALL_CMD (1 << 5)
|
||||
# define UDC_DEV_CFG (1 << 3)
|
||||
# define UDC_CLR_CFG (1 << 2)
|
||||
#define UDC_DEVSTAT_REG UDC_REG(0x20) /* Device status */
|
||||
# define UDC_B_HNP_ENABLE (1 << 9)
|
||||
# define UDC_A_HNP_SUPPORT (1 << 8)
|
||||
# define UDC_A_ALT_HNP_SUPPORT (1 << 7)
|
||||
# define UDC_R_WK_OK (1 << 6)
|
||||
# define UDC_USB_RESET (1 << 5)
|
||||
# define UDC_SUS (1 << 4)
|
||||
# define UDC_CFG (1 << 3)
|
||||
# define UDC_ADD (1 << 2)
|
||||
# define UDC_DEF (1 << 1)
|
||||
# define UDC_ATT (1 << 0)
|
||||
#define UDC_SOF_REG UDC_REG(0x24) /* Start of frame */
|
||||
# define UDC_FT_LOCK (1 << 12)
|
||||
# define UDC_TS_OK (1 << 11)
|
||||
# define UDC_TS 0x03ff
|
||||
#define UDC_IRQ_EN_REG UDC_REG(0x28) /* Interrupt enable */
|
||||
# define UDC_SOF_IE (1 << 7)
|
||||
# define UDC_EPN_RX_IE (1 << 5)
|
||||
# define UDC_EPN_TX_IE (1 << 4)
|
||||
# define UDC_DS_CHG_IE (1 << 3)
|
||||
# define UDC_EP0_IE (1 << 0)
|
||||
#define UDC_DMA_IRQ_EN_REG UDC_REG(0x2C) /* DMA irq enable */
|
||||
/* rx/tx dma channels numbered 1-3 not 0-2 */
|
||||
# define UDC_TX_DONE_IE(n) (1 << (4 * (n) - 2))
|
||||
# define UDC_RX_CNT_IE(n) (1 << (4 * (n) - 3))
|
||||
# define UDC_RX_EOT_IE(n) (1 << (4 * (n) - 4))
|
||||
#define UDC_IRQ_SRC_REG UDC_REG(0x30) /* Interrupt source */
|
||||
# define UDC_TXN_DONE (1 << 10)
|
||||
# define UDC_RXN_CNT (1 << 9)
|
||||
# define UDC_RXN_EOT (1 << 8)
|
||||
# define UDC_SOF (1 << 7)
|
||||
# define UDC_EPN_RX (1 << 5)
|
||||
# define UDC_EPN_TX (1 << 4)
|
||||
# define UDC_DS_CHG (1 << 3)
|
||||
# define UDC_SETUP (1 << 2)
|
||||
# define UDC_EP0_RX (1 << 1)
|
||||
# define UDC_EP0_TX (1 << 0)
|
||||
# define UDC_IRQ_SRC_MASK 0x7bf
|
||||
#define UDC_EPN_STAT_REG UDC_REG(0x34) /* EP irq status */
|
||||
#define UDC_DMAN_STAT_REG UDC_REG(0x38) /* DMA irq status */
|
||||
# define UDC_DMA_RX_SB (1 << 12)
|
||||
# define UDC_DMA_RX_SRC(x) (((x)>>8) & 0xf)
|
||||
# define UDC_DMA_TX_SRC(x) (((x)>>0) & 0xf)
|
||||
|
||||
|
||||
/* DMA configuration registers: up to three channels in each direction. */
|
||||
#define UDC_RXDMA_CFG_REG UDC_REG(0x40) /* 3 eps for RX DMA */
|
||||
#define UDC_TXDMA_CFG_REG UDC_REG(0x44) /* 3 eps for TX DMA */
|
||||
#define UDC_DATA_DMA_REG UDC_REG(0x48) /* rx/tx fifo addr */
|
||||
|
||||
/* rx/tx dma control, numbering channels 1-3 not 0-2 */
|
||||
#define UDC_TXDMA_REG(chan) UDC_REG(0x50 - 4 + 4 * (chan))
|
||||
# define UDC_TXN_EOT (1 << 15) /* bytes vs packets */
|
||||
# define UDC_TXN_START (1 << 14) /* start transfer */
|
||||
# define UDC_TXN_TSC 0x03ff /* units in xfer */
|
||||
#define UDC_RXDMA_REG(chan) UDC_REG(0x60 - 4 + 4 * (chan))
|
||||
# define UDC_RXN_STOP (1 << 15) /* enable EOT irq */
|
||||
# define UDC_RXN_TC 0x00ff /* packets in xfer */
|
||||
|
||||
|
||||
/*
|
||||
* Endpoint configuration registers (used before CFG_LOCK is set)
|
||||
* UDC_EP_TX_REG(0) is unused
|
||||
*/
|
||||
#define UDC_EP_RX_REG(endpoint) UDC_REG(0x80 + (endpoint)*4)
|
||||
# define UDC_EPN_RX_VALID (1 << 15)
|
||||
# define UDC_EPN_RX_DB (1 << 14)
|
||||
/* buffer size in bits 13, 12 */
|
||||
# define UDC_EPN_RX_ISO (1 << 11)
|
||||
/* buffer pointer in low 11 bits */
|
||||
#define UDC_EP_TX_REG(endpoint) UDC_REG(0xc0 + (endpoint)*4)
|
||||
/* same bitfields as in RX_REG */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
struct omap_req {
|
||||
struct usb_request req;
|
||||
struct list_head queue;
|
||||
unsigned dma_bytes;
|
||||
unsigned mapped:1;
|
||||
};
|
||||
|
||||
struct omap_ep {
|
||||
struct usb_ep ep;
|
||||
struct list_head queue;
|
||||
unsigned long irqs;
|
||||
struct list_head iso;
|
||||
const struct usb_endpoint_descriptor *desc;
|
||||
char name[14];
|
||||
u16 maxpacket;
|
||||
u8 bEndpointAddress;
|
||||
u8 bmAttributes;
|
||||
unsigned double_buf:1;
|
||||
unsigned stopped:1;
|
||||
unsigned fnf:1;
|
||||
unsigned has_dma:1;
|
||||
u8 ackwait;
|
||||
u8 dma_channel;
|
||||
u16 dma_counter;
|
||||
int lch;
|
||||
struct omap_udc *udc;
|
||||
struct timer_list timer;
|
||||
};
|
||||
|
||||
struct omap_udc {
|
||||
struct usb_gadget gadget;
|
||||
struct usb_gadget_driver *driver;
|
||||
spinlock_t lock;
|
||||
struct omap_ep ep[32];
|
||||
u16 devstat;
|
||||
struct otg_transceiver *transceiver;
|
||||
struct list_head iso;
|
||||
unsigned softconnect:1;
|
||||
unsigned vbus_active:1;
|
||||
unsigned ep0_pending:1;
|
||||
unsigned ep0_in:1;
|
||||
unsigned ep0_set_config:1;
|
||||
unsigned ep0_reset_config:1;
|
||||
unsigned ep0_setup:1;
|
||||
|
||||
struct completion *done;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(stuff...) printk(KERN_DEBUG "udc: " stuff)
|
||||
#else
|
||||
#define DBG(stuff...) do{}while(0)
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
# define VDBG DBG
|
||||
#else
|
||||
# define VDBG(stuff...) do{}while(0)
|
||||
#endif
|
||||
|
||||
#define ERR(stuff...) printk(KERN_ERR "udc: " stuff)
|
||||
#define WARN(stuff...) printk(KERN_WARNING "udc: " stuff)
|
||||
#define INFO(stuff...) printk(KERN_INFO "udc: " stuff)
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#define MOD_CONF_CTRL_0_REG __REG32(MOD_CONF_CTRL_0)
|
||||
#define VBUS_W2FC_1510 (1 << 17) /* 0 gpio0, 1 dvdd2 pin */
|
||||
|
||||
#define FUNC_MUX_CTRL_0_REG __REG32(FUNC_MUX_CTRL_0)
|
||||
#define VBUS_CTRL_1510 (1 << 19) /* 1 connected (software) */
|
||||
#define VBUS_MODE_1510 (1 << 18) /* 0 hardware, 1 software */
|
||||
|
||||
#define HMC_1510 ((MOD_CONF_CTRL_0_REG >> 1) & 0x3f)
|
||||
#define HMC_1610 (OTG_SYSCON_2_REG & 0x3f)
|
||||
#define HMC (cpu_is_omap15xx() ? HMC_1510 : HMC_1610)
|
||||
|
2648
drivers/usb/gadget/pxa2xx_udc.c
Normální soubor
2648
drivers/usb/gadget/pxa2xx_udc.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
320
drivers/usb/gadget/pxa2xx_udc.h
Normální soubor
320
drivers/usb/gadget/pxa2xx_udc.h
Normální soubor
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* linux/drivers/usb/gadget/pxa2xx_udc.h
|
||||
* Intel PXA2xx on-chip full speed USB device controller
|
||||
*
|
||||
* Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_GADGET_PXA2XX_H
|
||||
#define __LINUX_USB_GADGET_PXA2XX_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* pxa2xx has this (move to include/asm-arm/arch-pxa/pxa-regs.h) */
|
||||
#define UFNRH_SIR (1 << 7) /* SOF interrupt request */
|
||||
#define UFNRH_SIM (1 << 6) /* SOF interrupt mask */
|
||||
#define UFNRH_IPE14 (1 << 5) /* ISO packet error, ep14 */
|
||||
#define UFNRH_IPE9 (1 << 4) /* ISO packet error, ep9 */
|
||||
#define UFNRH_IPE4 (1 << 3) /* ISO packet error, ep4 */
|
||||
|
||||
/* pxa255 has this (move to include/asm-arm/arch-pxa/pxa-regs.h) */
|
||||
#define UDCCFR UDC_RES2 /* UDC Control Function Register */
|
||||
#define UDCCFR_AREN (1 << 7) /* ACK response enable (now) */
|
||||
#define UDCCFR_ACM (1 << 2) /* ACK control mode (wait for AREN) */
|
||||
|
||||
/* latest pxa255 errata define new "must be one" bits in UDCCFR */
|
||||
#define UDCCFR_MB1 (0xff & ~(UDCCFR_AREN|UDCCFR_ACM))
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
struct pxa2xx_udc;
|
||||
|
||||
struct pxa2xx_ep {
|
||||
struct usb_ep ep;
|
||||
struct pxa2xx_udc *dev;
|
||||
|
||||
const struct usb_endpoint_descriptor *desc;
|
||||
struct list_head queue;
|
||||
unsigned long pio_irqs;
|
||||
unsigned long dma_irqs;
|
||||
short dma;
|
||||
|
||||
unsigned short fifo_size;
|
||||
u8 bEndpointAddress;
|
||||
u8 bmAttributes;
|
||||
|
||||
unsigned stopped : 1;
|
||||
unsigned dma_fixup : 1;
|
||||
|
||||
/* UDCCS = UDC Control/Status for this EP
|
||||
* UBCR = UDC Byte Count Remaining (contents of OUT fifo)
|
||||
* UDDR = UDC Endpoint Data Register (the fifo)
|
||||
* DRCM = DMA Request Channel Map
|
||||
*/
|
||||
volatile u32 *reg_udccs;
|
||||
volatile u32 *reg_ubcr;
|
||||
volatile u32 *reg_uddr;
|
||||
#ifdef USE_DMA
|
||||
volatile u32 *reg_drcmr;
|
||||
#define drcmr(n) .reg_drcmr = & DRCMR ## n ,
|
||||
#else
|
||||
#define drcmr(n)
|
||||
#endif
|
||||
};
|
||||
|
||||
struct pxa2xx_request {
|
||||
struct usb_request req;
|
||||
struct list_head queue;
|
||||
};
|
||||
|
||||
enum ep0_state {
|
||||
EP0_IDLE,
|
||||
EP0_IN_DATA_PHASE,
|
||||
EP0_OUT_DATA_PHASE,
|
||||
EP0_END_XFER,
|
||||
EP0_STALL,
|
||||
};
|
||||
|
||||
#define EP0_FIFO_SIZE ((unsigned)16)
|
||||
#define BULK_FIFO_SIZE ((unsigned)64)
|
||||
#define ISO_FIFO_SIZE ((unsigned)256)
|
||||
#define INT_FIFO_SIZE ((unsigned)8)
|
||||
|
||||
struct udc_stats {
|
||||
struct ep0stats {
|
||||
unsigned long ops;
|
||||
unsigned long bytes;
|
||||
} read, write;
|
||||
unsigned long irqs;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_USB_PXA2XX_SMALL
|
||||
/* when memory's tight, SMALL config saves code+data. */
|
||||
#undef USE_DMA
|
||||
#define PXA_UDC_NUM_ENDPOINTS 3
|
||||
#endif
|
||||
|
||||
#ifndef PXA_UDC_NUM_ENDPOINTS
|
||||
#define PXA_UDC_NUM_ENDPOINTS 16
|
||||
#endif
|
||||
|
||||
struct pxa2xx_udc {
|
||||
struct usb_gadget gadget;
|
||||
struct usb_gadget_driver *driver;
|
||||
|
||||
enum ep0_state ep0state;
|
||||
struct udc_stats stats;
|
||||
unsigned got_irq : 1,
|
||||
vbus : 1,
|
||||
pullup : 1,
|
||||
has_cfr : 1,
|
||||
req_pending : 1,
|
||||
req_std : 1,
|
||||
req_config : 1;
|
||||
|
||||
#define start_watchdog(dev) mod_timer(&dev->timer, jiffies + (HZ/200))
|
||||
struct timer_list timer;
|
||||
|
||||
struct device *dev;
|
||||
struct pxa2xx_udc_mach_info *mach;
|
||||
u64 dma_mask;
|
||||
struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS];
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef CONFIG_ARCH_LUBBOCK
|
||||
#include <asm/arch/lubbock.h>
|
||||
/* lubbock can also report usb connect/disconnect irqs */
|
||||
|
||||
#ifdef DEBUG
|
||||
#define HEX_DISPLAY(n) if (machine_is_lubbock()) { LUB_HEXLED = (n); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* LEDs are only for debug */
|
||||
#ifndef HEX_DISPLAY
|
||||
#define HEX_DISPLAY(n) do {} while(0)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <asm/leds.h>
|
||||
|
||||
#define LED_CONNECTED_ON leds_event(led_green_on)
|
||||
#define LED_CONNECTED_OFF do { \
|
||||
leds_event(led_green_off); \
|
||||
HEX_DISPLAY(0); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef LED_CONNECTED_ON
|
||||
#define LED_CONNECTED_ON do {} while(0)
|
||||
#define LED_CONNECTED_OFF do {} while(0)
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
static struct pxa2xx_udc *the_controller;
|
||||
|
||||
/* one GPIO should be used to detect host disconnect */
|
||||
static inline int is_usb_connected(void)
|
||||
{
|
||||
if (!the_controller->mach->udc_is_connected)
|
||||
return 1;
|
||||
return the_controller->mach->udc_is_connected();
|
||||
}
|
||||
|
||||
/* one GPIO should force the host to see this device (or not) */
|
||||
static inline void make_usb_disappear(void)
|
||||
{
|
||||
if (!the_controller->mach->udc_command)
|
||||
return;
|
||||
the_controller->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
|
||||
}
|
||||
|
||||
static inline void let_usb_appear(void)
|
||||
{
|
||||
if (!the_controller->mach->udc_command)
|
||||
return;
|
||||
the_controller->mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Debugging support vanishes in non-debug builds. DBG_NORMAL should be
|
||||
* mostly silent during normal use/testing, with no timing side-effects.
|
||||
*/
|
||||
#define DBG_NORMAL 1 /* error paths, device state transitions */
|
||||
#define DBG_VERBOSE 2 /* add some success path trace info */
|
||||
#define DBG_NOISY 3 /* ... even more: request level */
|
||||
#define DBG_VERY_NOISY 4 /* ... even more: packet level */
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static const char *state_name[] = {
|
||||
"EP0_IDLE",
|
||||
"EP0_IN_DATA_PHASE", "EP0_OUT_DATA_PHASE",
|
||||
"EP0_END_XFER", "EP0_STALL"
|
||||
};
|
||||
|
||||
#define DMSG(stuff...) printk(KERN_DEBUG "udc: " stuff)
|
||||
|
||||
#ifdef VERBOSE
|
||||
# define UDC_DEBUG DBG_VERBOSE
|
||||
#else
|
||||
# define UDC_DEBUG DBG_NORMAL
|
||||
#endif
|
||||
|
||||
static void __attribute__ ((__unused__))
|
||||
dump_udccr(const char *label)
|
||||
{
|
||||
u32 udccr = UDCCR;
|
||||
DMSG("%s %02X =%s%s%s%s%s%s%s%s\n",
|
||||
label, udccr,
|
||||
(udccr & UDCCR_REM) ? " rem" : "",
|
||||
(udccr & UDCCR_RSTIR) ? " rstir" : "",
|
||||
(udccr & UDCCR_SRM) ? " srm" : "",
|
||||
(udccr & UDCCR_SUSIR) ? " susir" : "",
|
||||
(udccr & UDCCR_RESIR) ? " resir" : "",
|
||||
(udccr & UDCCR_RSM) ? " rsm" : "",
|
||||
(udccr & UDCCR_UDA) ? " uda" : "",
|
||||
(udccr & UDCCR_UDE) ? " ude" : "");
|
||||
}
|
||||
|
||||
static void __attribute__ ((__unused__))
|
||||
dump_udccs0(const char *label)
|
||||
{
|
||||
u32 udccs0 = UDCCS0;
|
||||
|
||||
DMSG("%s %s %02X =%s%s%s%s%s%s%s%s\n",
|
||||
label, state_name[the_controller->ep0state], udccs0,
|
||||
(udccs0 & UDCCS0_SA) ? " sa" : "",
|
||||
(udccs0 & UDCCS0_RNE) ? " rne" : "",
|
||||
(udccs0 & UDCCS0_FST) ? " fst" : "",
|
||||
(udccs0 & UDCCS0_SST) ? " sst" : "",
|
||||
(udccs0 & UDCCS0_DRWF) ? " dwrf" : "",
|
||||
(udccs0 & UDCCS0_FTF) ? " ftf" : "",
|
||||
(udccs0 & UDCCS0_IPR) ? " ipr" : "",
|
||||
(udccs0 & UDCCS0_OPR) ? " opr" : "");
|
||||
}
|
||||
|
||||
static void __attribute__ ((__unused__))
|
||||
dump_state(struct pxa2xx_udc *dev)
|
||||
{
|
||||
u32 tmp;
|
||||
unsigned i;
|
||||
|
||||
DMSG("%s %s, uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n",
|
||||
is_usb_connected() ? "host " : "disconnected",
|
||||
state_name[dev->ep0state],
|
||||
UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL);
|
||||
dump_udccr("udccr");
|
||||
if (dev->has_cfr) {
|
||||
tmp = UDCCFR;
|
||||
DMSG("udccfr %02X =%s%s\n", tmp,
|
||||
(tmp & UDCCFR_AREN) ? " aren" : "",
|
||||
(tmp & UDCCFR_ACM) ? " acm" : "");
|
||||
}
|
||||
|
||||
if (!dev->driver) {
|
||||
DMSG("no gadget driver bound\n");
|
||||
return;
|
||||
} else
|
||||
DMSG("ep0 driver '%s'\n", dev->driver->driver.name);
|
||||
|
||||
if (!is_usb_connected())
|
||||
return;
|
||||
|
||||
dump_udccs0 ("udccs0");
|
||||
DMSG("ep0 IN %lu/%lu, OUT %lu/%lu\n",
|
||||
dev->stats.write.bytes, dev->stats.write.ops,
|
||||
dev->stats.read.bytes, dev->stats.read.ops);
|
||||
|
||||
for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) {
|
||||
if (dev->ep [i].desc == 0)
|
||||
continue;
|
||||
DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define DMSG(stuff...) do{}while(0)
|
||||
|
||||
#define dump_udccr(x) do{}while(0)
|
||||
#define dump_udccs0(x) do{}while(0)
|
||||
#define dump_state(x) do{}while(0)
|
||||
|
||||
#define UDC_DEBUG ((unsigned)0)
|
||||
|
||||
#endif
|
||||
|
||||
#define DBG(lvl, stuff...) do{if ((lvl) <= UDC_DEBUG) DMSG(stuff);}while(0)
|
||||
|
||||
#define WARN(stuff...) printk(KERN_WARNING "udc: " stuff)
|
||||
#define INFO(stuff...) printk(KERN_INFO "udc: " stuff)
|
||||
|
||||
|
||||
#endif /* __LINUX_USB_GADGET_PXA2XX_H */
|
1428
drivers/usb/gadget/rndis.c
Normální soubor
1428
drivers/usb/gadget/rndis.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
348
drivers/usb/gadget/rndis.h
Normální soubor
348
drivers/usb/gadget/rndis.h
Normální soubor
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
* RNDIS Definitions for Remote NDIS
|
||||
*
|
||||
* Version: $Id: rndis.h,v 1.15 2004/03/25 21:33:46 robert Exp $
|
||||
*
|
||||
* Authors: Benedikt Spranger, Pengutronix
|
||||
* Robert Schwebel, Pengutronix
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This software was originally developed in conformance with
|
||||
* Microsoft's Remote NDIS Specification License Agreement.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_RNDIS_H
|
||||
#define _LINUX_RNDIS_H
|
||||
|
||||
#include "ndis.h"
|
||||
|
||||
#define RNDIS_MAXIMUM_FRAME_SIZE 1518
|
||||
#define RNDIS_MAX_TOTAL_SIZE 1558
|
||||
|
||||
/* Remote NDIS Versions */
|
||||
#define RNDIS_MAJOR_VERSION 1
|
||||
#define RNDIS_MINOR_VERSION 0
|
||||
|
||||
/* Status Values */
|
||||
#define RNDIS_STATUS_SUCCESS 0x00000000U /* Success */
|
||||
#define RNDIS_STATUS_FAILURE 0xC0000001U /* Unspecified error */
|
||||
#define RNDIS_STATUS_INVALID_DATA 0xC0010015U /* Invalid data */
|
||||
#define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBU /* Unsupported request */
|
||||
#define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BU /* Device connected */
|
||||
#define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CU /* Device disconnected */
|
||||
/* For all not specified status messages:
|
||||
* RNDIS_STATUS_Xxx -> NDIS_STATUS_Xxx
|
||||
*/
|
||||
|
||||
/* Message Set for Connectionless (802.3) Devices */
|
||||
#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002U /* Initialize device */
|
||||
#define REMOTE_NDIS_HALT_MSG 0x00000003U
|
||||
#define REMOTE_NDIS_QUERY_MSG 0x00000004U
|
||||
#define REMOTE_NDIS_SET_MSG 0x00000005U
|
||||
#define REMOTE_NDIS_RESET_MSG 0x00000006U
|
||||
#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007U
|
||||
#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008U
|
||||
|
||||
/* Message completion */
|
||||
#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002U
|
||||
#define REMOTE_NDIS_QUERY_CMPLT 0x80000004U
|
||||
#define REMOTE_NDIS_SET_CMPLT 0x80000005U
|
||||
#define REMOTE_NDIS_RESET_CMPLT 0x80000006U
|
||||
#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008U
|
||||
|
||||
/* Device Flags */
|
||||
#define RNDIS_DF_CONNECTIONLESS 0x00000001U
|
||||
#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002U
|
||||
|
||||
#define RNDIS_MEDIUM_802_3 0x00000000U
|
||||
|
||||
/* from drivers/net/sk98lin/h/skgepnmi.h */
|
||||
#define OID_PNP_CAPABILITIES 0xFD010100
|
||||
#define OID_PNP_SET_POWER 0xFD010101
|
||||
#define OID_PNP_QUERY_POWER 0xFD010102
|
||||
#define OID_PNP_ADD_WAKE_UP_PATTERN 0xFD010103
|
||||
#define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
|
||||
#define OID_PNP_ENABLE_WAKE_UP 0xFD010106
|
||||
|
||||
|
||||
/* supported OIDs */
|
||||
static const u32 oid_supported_list [] =
|
||||
{
|
||||
/* the general stuff */
|
||||
OID_GEN_SUPPORTED_LIST,
|
||||
OID_GEN_HARDWARE_STATUS,
|
||||
OID_GEN_MEDIA_SUPPORTED,
|
||||
OID_GEN_MEDIA_IN_USE,
|
||||
OID_GEN_MAXIMUM_FRAME_SIZE,
|
||||
OID_GEN_LINK_SPEED,
|
||||
OID_GEN_TRANSMIT_BLOCK_SIZE,
|
||||
OID_GEN_RECEIVE_BLOCK_SIZE,
|
||||
OID_GEN_VENDOR_ID,
|
||||
OID_GEN_VENDOR_DESCRIPTION,
|
||||
OID_GEN_VENDOR_DRIVER_VERSION,
|
||||
OID_GEN_CURRENT_PACKET_FILTER,
|
||||
OID_GEN_MAXIMUM_TOTAL_SIZE,
|
||||
OID_GEN_MEDIA_CONNECT_STATUS,
|
||||
OID_GEN_PHYSICAL_MEDIUM,
|
||||
#if 0
|
||||
OID_GEN_RNDIS_CONFIG_PARAMETER,
|
||||
#endif
|
||||
|
||||
/* the statistical stuff */
|
||||
OID_GEN_XMIT_OK,
|
||||
OID_GEN_RCV_OK,
|
||||
OID_GEN_XMIT_ERROR,
|
||||
OID_GEN_RCV_ERROR,
|
||||
OID_GEN_RCV_NO_BUFFER,
|
||||
#ifdef RNDIS_OPTIONAL_STATS
|
||||
OID_GEN_DIRECTED_BYTES_XMIT,
|
||||
OID_GEN_DIRECTED_FRAMES_XMIT,
|
||||
OID_GEN_MULTICAST_BYTES_XMIT,
|
||||
OID_GEN_MULTICAST_FRAMES_XMIT,
|
||||
OID_GEN_BROADCAST_BYTES_XMIT,
|
||||
OID_GEN_BROADCAST_FRAMES_XMIT,
|
||||
OID_GEN_DIRECTED_BYTES_RCV,
|
||||
OID_GEN_DIRECTED_FRAMES_RCV,
|
||||
OID_GEN_MULTICAST_BYTES_RCV,
|
||||
OID_GEN_MULTICAST_FRAMES_RCV,
|
||||
OID_GEN_BROADCAST_BYTES_RCV,
|
||||
OID_GEN_BROADCAST_FRAMES_RCV,
|
||||
OID_GEN_RCV_CRC_ERROR,
|
||||
OID_GEN_TRANSMIT_QUEUE_LENGTH,
|
||||
#endif /* RNDIS_OPTIONAL_STATS */
|
||||
|
||||
/* mandatory 802.3 */
|
||||
/* the general stuff */
|
||||
OID_802_3_PERMANENT_ADDRESS,
|
||||
OID_802_3_CURRENT_ADDRESS,
|
||||
OID_802_3_MULTICAST_LIST,
|
||||
OID_802_3_MAC_OPTIONS,
|
||||
OID_802_3_MAXIMUM_LIST_SIZE,
|
||||
|
||||
/* the statistical stuff */
|
||||
OID_802_3_RCV_ERROR_ALIGNMENT,
|
||||
OID_802_3_XMIT_ONE_COLLISION,
|
||||
OID_802_3_XMIT_MORE_COLLISIONS,
|
||||
#ifdef RNDIS_OPTIONAL_STATS
|
||||
OID_802_3_XMIT_DEFERRED,
|
||||
OID_802_3_XMIT_MAX_COLLISIONS,
|
||||
OID_802_3_RCV_OVERRUN,
|
||||
OID_802_3_XMIT_UNDERRUN,
|
||||
OID_802_3_XMIT_HEARTBEAT_FAILURE,
|
||||
OID_802_3_XMIT_TIMES_CRS_LOST,
|
||||
OID_802_3_XMIT_LATE_COLLISIONS,
|
||||
#endif /* RNDIS_OPTIONAL_STATS */
|
||||
|
||||
#ifdef RNDIS_PM
|
||||
/* PM and wakeup are mandatory for USB: */
|
||||
|
||||
/* power management */
|
||||
OID_PNP_CAPABILITIES,
|
||||
OID_PNP_QUERY_POWER,
|
||||
OID_PNP_SET_POWER,
|
||||
|
||||
/* wake up host */
|
||||
OID_PNP_ENABLE_WAKE_UP,
|
||||
OID_PNP_ADD_WAKE_UP_PATTERN,
|
||||
OID_PNP_REMOVE_WAKE_UP_PATTERN,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
typedef struct rndis_init_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
__le32 MajorVersion;
|
||||
__le32 MinorVersion;
|
||||
__le32 MaxTransferSize;
|
||||
} rndis_init_msg_type;
|
||||
|
||||
typedef struct rndis_init_cmplt_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
__le32 Status;
|
||||
__le32 MajorVersion;
|
||||
__le32 MinorVersion;
|
||||
__le32 DeviceFlags;
|
||||
__le32 Medium;
|
||||
__le32 MaxPacketsPerTransfer;
|
||||
__le32 MaxTransferSize;
|
||||
__le32 PacketAlignmentFactor;
|
||||
__le32 AFListOffset;
|
||||
__le32 AFListSize;
|
||||
} rndis_init_cmplt_type;
|
||||
|
||||
typedef struct rndis_halt_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
} rndis_halt_msg_type;
|
||||
|
||||
typedef struct rndis_query_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
__le32 OID;
|
||||
__le32 InformationBufferLength;
|
||||
__le32 InformationBufferOffset;
|
||||
__le32 DeviceVcHandle;
|
||||
} rndis_query_msg_type;
|
||||
|
||||
typedef struct rndis_query_cmplt_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
__le32 Status;
|
||||
__le32 InformationBufferLength;
|
||||
__le32 InformationBufferOffset;
|
||||
} rndis_query_cmplt_type;
|
||||
|
||||
typedef struct rndis_set_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
__le32 OID;
|
||||
__le32 InformationBufferLength;
|
||||
__le32 InformationBufferOffset;
|
||||
__le32 DeviceVcHandle;
|
||||
} rndis_set_msg_type;
|
||||
|
||||
typedef struct rndis_set_cmplt_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
__le32 Status;
|
||||
} rndis_set_cmplt_type;
|
||||
|
||||
typedef struct rndis_reset_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 Reserved;
|
||||
} rndis_reset_msg_type;
|
||||
|
||||
typedef struct rndis_reset_cmplt_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 Status;
|
||||
__le32 AddressingReset;
|
||||
} rndis_reset_cmplt_type;
|
||||
|
||||
typedef struct rndis_indicate_status_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 Status;
|
||||
__le32 StatusBufferLength;
|
||||
__le32 StatusBufferOffset;
|
||||
} rndis_indicate_status_msg_type;
|
||||
|
||||
typedef struct rndis_keepalive_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
} rndis_keepalive_msg_type;
|
||||
|
||||
typedef struct rndis_keepalive_cmplt_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 RequestID;
|
||||
__le32 Status;
|
||||
} rndis_keepalive_cmplt_type;
|
||||
|
||||
struct rndis_packet_msg_type
|
||||
{
|
||||
__le32 MessageType;
|
||||
__le32 MessageLength;
|
||||
__le32 DataOffset;
|
||||
__le32 DataLength;
|
||||
__le32 OOBDataOffset;
|
||||
__le32 OOBDataLength;
|
||||
__le32 NumOOBDataElements;
|
||||
__le32 PerPacketInfoOffset;
|
||||
__le32 PerPacketInfoLength;
|
||||
__le32 VcHandle;
|
||||
__le32 Reserved;
|
||||
};
|
||||
|
||||
struct rndis_config_parameter
|
||||
{
|
||||
__le32 ParameterNameOffset;
|
||||
__le32 ParameterNameLength;
|
||||
__le32 ParameterType;
|
||||
__le32 ParameterValueOffset;
|
||||
__le32 ParameterValueLength;
|
||||
};
|
||||
|
||||
/* implementation specific */
|
||||
enum rndis_state
|
||||
{
|
||||
RNDIS_UNINITIALIZED,
|
||||
RNDIS_INITIALIZED,
|
||||
RNDIS_DATA_INITIALIZED,
|
||||
};
|
||||
|
||||
typedef struct rndis_resp_t
|
||||
{
|
||||
struct list_head list;
|
||||
u8 *buf;
|
||||
u32 length;
|
||||
int send;
|
||||
} rndis_resp_t;
|
||||
|
||||
typedef struct rndis_params
|
||||
{
|
||||
u8 confignr;
|
||||
int used;
|
||||
enum rndis_state state;
|
||||
u32 filter;
|
||||
u32 medium;
|
||||
u32 speed;
|
||||
u32 media_state;
|
||||
const u8 *host_mac;
|
||||
struct net_device *dev;
|
||||
struct net_device_stats *stats;
|
||||
u32 vendorID;
|
||||
const char *vendorDescr;
|
||||
int (*ack) (struct net_device *);
|
||||
struct list_head resp_queue;
|
||||
} rndis_params;
|
||||
|
||||
/* RNDIS Message parser and other useless functions */
|
||||
int rndis_msg_parser (u8 configNr, u8 *buf);
|
||||
int rndis_register (int (*rndis_control_ack) (struct net_device *));
|
||||
void rndis_deregister (int configNr);
|
||||
int rndis_set_param_dev (u8 configNr, struct net_device *dev,
|
||||
struct net_device_stats *stats);
|
||||
int rndis_set_param_vendor (u8 configNr, u32 vendorID,
|
||||
const char *vendorDescr);
|
||||
int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed);
|
||||
void rndis_add_hdr (struct sk_buff *skb);
|
||||
int rndis_rm_hdr (u8 *buf, u32 *length);
|
||||
u8 *rndis_get_next_response (int configNr, u32 *length);
|
||||
void rndis_free_response (int configNr, u8 *buf);
|
||||
|
||||
int rndis_signal_connect (int configNr);
|
||||
int rndis_signal_disconnect (int configNr);
|
||||
int rndis_state (int configNr);
|
||||
extern void rndis_set_host_mac (int configNr, const u8 *addr);
|
||||
|
||||
int __init rndis_init (void);
|
||||
void rndis_exit (void);
|
||||
|
||||
#endif /* _LINUX_RNDIS_H */
|
2436
drivers/usb/gadget/serial.c
Normální soubor
2436
drivers/usb/gadget/serial.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
136
drivers/usb/gadget/usbstring.c
Normální soubor
136
drivers/usb/gadget/usbstring.c
Normální soubor
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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/init.h>
|
||||
|
||||
#include <linux/usb_ch9.h>
|
||||
#include <linux/usb_gadget.h>
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
|
||||
static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
|
||||
{
|
||||
int count = 0;
|
||||
u8 c;
|
||||
u16 uchar;
|
||||
|
||||
/* this insists on correct encodings, though not minimal ones.
|
||||
* BUT it currently rejects legit 4-byte UTF-8 code points,
|
||||
* which need surrogate pairs. (Unicode 3.1 can use them.)
|
||||
*/
|
||||
while (len != 0 && (c = (u8) *s++) != 0) {
|
||||
if (unlikely(c & 0x80)) {
|
||||
// 2-byte sequence:
|
||||
// 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
|
||||
if ((c & 0xe0) == 0xc0) {
|
||||
uchar = (c & 0x1f) << 6;
|
||||
|
||||
c = (u8) *s++;
|
||||
if ((c & 0xc0) != 0xc0)
|
||||
goto fail;
|
||||
c &= 0x3f;
|
||||
uchar |= c;
|
||||
|
||||
// 3-byte sequence (most CJKV characters):
|
||||
// zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx
|
||||
} else if ((c & 0xf0) == 0xe0) {
|
||||
uchar = (c & 0x0f) << 12;
|
||||
|
||||
c = (u8) *s++;
|
||||
if ((c & 0xc0) != 0xc0)
|
||||
goto fail;
|
||||
c &= 0x3f;
|
||||
uchar |= c << 6;
|
||||
|
||||
c = (u8) *s++;
|
||||
if ((c & 0xc0) != 0xc0)
|
||||
goto fail;
|
||||
c &= 0x3f;
|
||||
uchar |= c;
|
||||
|
||||
/* no bogus surrogates */
|
||||
if (0xd800 <= uchar && uchar <= 0xdfff)
|
||||
goto fail;
|
||||
|
||||
// 4-byte sequence (surrogate pairs, currently rare):
|
||||
// 11101110wwwwzzzzyy + 110111yyyyxxxxxx
|
||||
// = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
|
||||
// (uuuuu = wwww + 1)
|
||||
// FIXME accept the surrogate code points (only)
|
||||
|
||||
} else
|
||||
goto fail;
|
||||
} else
|
||||
uchar = c;
|
||||
put_unaligned (cpu_to_le16 (uchar), cp++);
|
||||
count++;
|
||||
len--;
|
||||
}
|
||||
return count;
|
||||
fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* usb_gadget_get_string - fill out a string descriptor
|
||||
* @table: of c strings encoded using UTF-8
|
||||
* @id: string id, from low byte of wValue in get string descriptor
|
||||
* @buf: at least 256 bytes
|
||||
*
|
||||
* Finds the UTF-8 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 probably
|
||||
* "switch (wIndex) { ... }" in your ep0 string descriptor logic,
|
||||
* using this routine after choosing which set of UTF-8 strings to use.
|
||||
* Note that US-ASCII is a strict subset of UTF-8; any string bytes with
|
||||
* the eighth bit set will be multibyte UTF-8 characters, not ISO-8859/1
|
||||
* characters (which are also widely used in C strings).
|
||||
*/
|
||||
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));
|
||||
memset (buf + 2, 0, 2 * len); /* zero all the bytes */
|
||||
len = utf8_to_utf16le(s->s, (__le16 *)&buf[2], len);
|
||||
if (len < 0)
|
||||
return -EINVAL;
|
||||
buf [0] = (len + 1) * 2;
|
||||
buf [1] = USB_DT_STRING;
|
||||
return buf [0];
|
||||
}
|
||||
|
1357
drivers/usb/gadget/zero.c
Normální soubor
1357
drivers/usb/gadget/zero.c
Normální soubor
Rozdílový obsah nebyl zobrazen, protože je příliš veliký
Načíst rozdílové porovnání
Odkázat v novém úkolu
Zablokovat Uživatele