2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* zero.c -- Gadget Zero, for USB development
|
|
|
|
*
|
2008-06-20 01:18:27 +00:00
|
|
|
* Copyright (C) 2003-2008 David Brownell
|
|
|
|
* Copyright (C) 2008 by Nokia Corporation
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2007-08-02 19:20:05 +00:00
|
|
|
* 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.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gadget Zero only needs two bulk endpoints, and is an example of how you
|
|
|
|
* can write a hardware-agnostic gadget driver running inside a USB device.
|
2008-04-19 01:47:54 +00:00
|
|
|
* Some hardware details are visible, but don't affect most of the driver.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Use it with the Linux host/master side "usbtest" driver to get a basic
|
|
|
|
* functional test of your device-side usb stack, or with "usb-skeleton".
|
|
|
|
*
|
|
|
|
* It supports two similar configurations. One sinks whatever the usb host
|
|
|
|
* writes, and in return sources zeroes. The other loops whatever the host
|
2008-06-20 01:18:27 +00:00
|
|
|
* writes back, so the host can read it.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Many drivers will only have one configuration, letting them be much
|
|
|
|
* simpler if they also don't support high speed operation (like this
|
|
|
|
* driver does).
|
2007-08-02 19:20:05 +00:00
|
|
|
*
|
|
|
|
* Why is *this* driver using two configurations, rather than setting up
|
|
|
|
* two interfaces with different functions? To help verify that multiple
|
|
|
|
* configuration infrastucture is working correctly; also, so that it can
|
|
|
|
* work with low capability USB controllers without four bulk endpoints.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
/*
|
|
|
|
* driver assumes self-powered hardware, and
|
|
|
|
* has no way for users to trigger remote wakeup.
|
|
|
|
*/
|
|
|
|
|
2007-08-02 19:20:05 +00:00
|
|
|
/* #define VERBOSE_DEBUG */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/device.h>
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
#include "g_zero.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "gadget_chips.h"
|
|
|
|
|
|
|
|
|
2008-08-19 00:41:31 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kbuild is not very cooperative with respect to linking separately
|
|
|
|
* compiled library objects into one module. So for now we won't use
|
|
|
|
* separate compilation ... ensuring init/exit sections work to shrink
|
|
|
|
* the runtime footprint, and giving us at least some parts of what
|
|
|
|
* a "gcc --combine ... part1.c part2.c part3.c ... " build would.
|
|
|
|
*/
|
|
|
|
#include "f_sourcesink.c"
|
|
|
|
#include "f_loopback.c"
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
2012-09-10 13:01:53 +00:00
|
|
|
USB_GADGET_COMPOSITE_OPTIONS();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
#define DRIVER_VERSION "Cinco de Mayo 2008"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-04-19 01:47:54 +00:00
|
|
|
static const char longname[] = "Gadget Zero";
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-04-16 21:19:06 +00:00
|
|
|
unsigned buflen = 4096; /* only used for bulk endpoints */
|
2008-06-20 01:18:27 +00:00
|
|
|
module_param(buflen, uint, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Normally the "loopback" configuration is second (index 1) so
|
|
|
|
* it's not the default. Here's where to change that order, to
|
2008-06-20 01:18:27 +00:00
|
|
|
* work better with hosts where config changes are problematic or
|
|
|
|
* controllers (like original superh) that only support one config.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2012-01-12 23:02:20 +00:00
|
|
|
static bool loopdefault = 0;
|
2008-04-19 01:47:54 +00:00
|
|
|
module_param(loopdefault, bool, S_IRUGO|S_IWUSR);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* Thanks to NetChip Technologies for donating this product ID.
|
|
|
|
*
|
|
|
|
* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
|
|
|
|
* Instead: allocate your own, using normal USB-IF procedures.
|
|
|
|
*/
|
|
|
|
#ifndef CONFIG_USB_ZERO_HNPTEST
|
|
|
|
#define DRIVER_VENDOR_NUM 0x0525 /* NetChip */
|
|
|
|
#define DRIVER_PRODUCT_NUM 0xa4a0 /* Linux-USB "Gadget Zero" */
|
2009-03-19 21:16:09 +00:00
|
|
|
#define DEFAULT_AUTORESUME 0
|
2005-04-16 22:20:36 +00:00
|
|
|
#else
|
|
|
|
#define DRIVER_VENDOR_NUM 0x1a0a /* OTG test device IDs */
|
|
|
|
#define DRIVER_PRODUCT_NUM 0xbadd
|
2009-03-19 21:16:09 +00:00
|
|
|
#define DEFAULT_AUTORESUME 5
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-19 21:16:09 +00:00
|
|
|
/* If the optional "autoresume" mode is enabled, it provides good
|
|
|
|
* functional coverage for the "USBCV" test harness from USB-IF.
|
|
|
|
* It's always set if OTG mode is enabled.
|
|
|
|
*/
|
|
|
|
unsigned autoresume = DEFAULT_AUTORESUME;
|
|
|
|
module_param(autoresume, uint, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup");
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2008-04-19 01:47:54 +00:00
|
|
|
static struct usb_device_descriptor device_desc = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.bLength = sizeof device_desc,
|
|
|
|
.bDescriptorType = USB_DT_DEVICE,
|
|
|
|
|
2009-02-11 22:11:36 +00:00
|
|
|
.bcdUSB = cpu_to_le16(0x0200),
|
2005-04-16 22:20:36 +00:00
|
|
|
.bDeviceClass = USB_CLASS_VENDOR_SPEC,
|
|
|
|
|
2009-02-11 22:11:36 +00:00
|
|
|
.idVendor = cpu_to_le16(DRIVER_VENDOR_NUM),
|
|
|
|
.idProduct = cpu_to_le16(DRIVER_PRODUCT_NUM),
|
2005-04-16 22:20:36 +00:00
|
|
|
.bNumConfigurations = 2,
|
|
|
|
};
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
#ifdef CONFIG_USB_OTG
|
2008-04-19 01:47:54 +00:00
|
|
|
static struct usb_otg_descriptor otg_descriptor = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.bLength = sizeof otg_descriptor,
|
|
|
|
.bDescriptorType = USB_DT_OTG,
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
/* REVISIT SRP-only hardware is possible, although
|
|
|
|
* it would not be called "OTG" ...
|
|
|
|
*/
|
|
|
|
.bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
const struct usb_descriptor_header *otg_desc[] = {
|
2005-04-16 22:20:36 +00:00
|
|
|
(struct usb_descriptor_header *) &otg_descriptor,
|
|
|
|
NULL,
|
|
|
|
};
|
2008-06-20 01:18:27 +00:00
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
/* string IDs are assigned dynamically */
|
2007-08-02 19:20:05 +00:00
|
|
|
/* default serial number takes at least two packets */
|
|
|
|
static char serial[] = "0123456789.0123456789.0123456789";
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-12-23 20:09:58 +00:00
|
|
|
#define USB_GZERO_SS_DESC (USB_GADGET_FIRST_AVAIL_IDX + 0)
|
2012-12-23 20:09:59 +00:00
|
|
|
#define USB_GZERO_LB_DESC (USB_GADGET_FIRST_AVAIL_IDX + 1)
|
2012-12-23 20:09:58 +00:00
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
static struct usb_string strings_dev[] = {
|
2012-09-10 13:01:58 +00:00
|
|
|
[USB_GADGET_MANUFACTURER_IDX].s = "",
|
2012-09-06 18:11:21 +00:00
|
|
|
[USB_GADGET_PRODUCT_IDX].s = longname,
|
|
|
|
[USB_GADGET_SERIAL_IDX].s = serial,
|
2012-12-23 20:09:58 +00:00
|
|
|
[USB_GZERO_SS_DESC].s = "source and sink data",
|
2012-12-23 20:09:59 +00:00
|
|
|
[USB_GZERO_LB_DESC].s = "loop input to output",
|
2005-04-16 22:20:36 +00:00
|
|
|
{ } /* end of list */
|
|
|
|
};
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
static struct usb_gadget_strings stringtab_dev = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.language = 0x0409, /* en-us */
|
2008-06-20 01:18:27 +00:00
|
|
|
.strings = strings_dev,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
static struct usb_gadget_strings *dev_strings[] = {
|
|
|
|
&stringtab_dev,
|
|
|
|
NULL,
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2012-04-16 21:19:06 +00:00
|
|
|
struct usb_request *alloc_ep_req(struct usb_ep *ep, int len)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct usb_request *req;
|
|
|
|
|
2008-04-19 01:47:54 +00:00
|
|
|
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (req) {
|
2012-04-16 21:19:06 +00:00
|
|
|
if (len)
|
|
|
|
req->length = len;
|
|
|
|
else
|
|
|
|
req->length = buflen;
|
|
|
|
req->buf = kmalloc(req->length, GFP_ATOMIC);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!req->buf) {
|
2008-04-19 01:47:54 +00:00
|
|
|
usb_ep_free_request(ep, req);
|
2005-04-16 22:20:36 +00:00
|
|
|
req = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
void free_ep_req(struct usb_ep *ep, struct usb_request *req)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-07-01 18:04:54 +00:00
|
|
|
kfree(req->buf);
|
2008-04-19 01:47:54 +00:00
|
|
|
usb_ep_free_request(ep, req);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-06-20 01:18:27 +00:00
|
|
|
int value;
|
|
|
|
|
|
|
|
if (ep->driver_data) {
|
|
|
|
value = usb_ep_disable(ep);
|
|
|
|
if (value < 0)
|
|
|
|
DBG(cdev, "disable %s --> %d\n",
|
|
|
|
ep->name, value);
|
|
|
|
ep->driver_data = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
void disable_endpoints(struct usb_composite_dev *cdev,
|
2012-04-16 21:19:06 +00:00
|
|
|
struct usb_ep *in, struct usb_ep *out,
|
|
|
|
struct usb_ep *iso_in, struct usb_ep *iso_out)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-06-20 01:18:27 +00:00
|
|
|
disable_ep(cdev, in);
|
|
|
|
disable_ep(cdev, out);
|
2012-04-16 21:19:06 +00:00
|
|
|
if (iso_in)
|
|
|
|
disable_ep(cdev, iso_in);
|
|
|
|
if (iso_out)
|
|
|
|
disable_ep(cdev, iso_out);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2009-03-19 21:16:09 +00:00
|
|
|
static struct timer_list autoresume_timer;
|
|
|
|
|
|
|
|
static void zero_autoresume(unsigned long _c)
|
|
|
|
{
|
|
|
|
struct usb_composite_dev *cdev = (void *)_c;
|
|
|
|
struct usb_gadget *g = cdev->gadget;
|
|
|
|
|
|
|
|
/* unconfigured devices can't issue wakeups */
|
|
|
|
if (!cdev->config)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Normally the host would be woken up for something
|
|
|
|
* more significant than just a timer firing; likely
|
|
|
|
* because of some direct user request.
|
|
|
|
*/
|
|
|
|
if (g->speed != USB_SPEED_UNKNOWN) {
|
|
|
|
int status = usb_gadget_wakeup(g);
|
|
|
|
INFO(cdev, "%s --> %d\n", __func__, status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zero_suspend(struct usb_composite_dev *cdev)
|
|
|
|
{
|
|
|
|
if (cdev->gadget->speed == USB_SPEED_UNKNOWN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (autoresume) {
|
|
|
|
mod_timer(&autoresume_timer, jiffies + (HZ * autoresume));
|
|
|
|
DBG(cdev, "suspend, wakeup in %d seconds\n", autoresume);
|
|
|
|
} else
|
|
|
|
DBG(cdev, "%s\n", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zero_resume(struct usb_composite_dev *cdev)
|
|
|
|
{
|
|
|
|
DBG(cdev, "%s\n", __func__);
|
|
|
|
del_timer(&autoresume_timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2012-12-23 20:09:59 +00:00
|
|
|
static struct usb_configuration loopback_driver = {
|
|
|
|
.label = "loopback",
|
|
|
|
.strings = loopback_strings,
|
|
|
|
.bConfigurationValue = 2,
|
|
|
|
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
|
|
|
|
/* .iConfiguration = DYNAMIC */
|
|
|
|
};
|
|
|
|
|
2012-12-23 20:09:58 +00:00
|
|
|
static struct usb_configuration sourcesink_driver = {
|
|
|
|
.label = "source/sink",
|
|
|
|
.strings = sourcesink_strings,
|
|
|
|
.setup = ss_config_setup,
|
|
|
|
.bConfigurationValue = 3,
|
|
|
|
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
|
|
|
|
/* .iConfiguration = DYNAMIC */
|
|
|
|
};
|
|
|
|
|
2010-08-12 15:43:52 +00:00
|
|
|
static int __init zero_bind(struct usb_composite_dev *cdev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-09-06 18:11:16 +00:00
|
|
|
int status;
|
2005-07-13 22:18:30 +00:00
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
/* Allocate string descriptor numbers ... note that string
|
|
|
|
* contents can be overridden by the composite_dev glue.
|
2005-07-13 22:18:30 +00:00
|
|
|
*/
|
2012-09-06 18:11:16 +00:00
|
|
|
status = usb_string_ids_tab(cdev, strings_dev);
|
|
|
|
if (status < 0)
|
|
|
|
return status;
|
|
|
|
|
2012-09-06 18:11:21 +00:00
|
|
|
device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
|
|
|
|
device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
|
|
|
|
device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id;
|
2008-06-20 01:18:27 +00:00
|
|
|
|
2009-03-19 21:16:09 +00:00
|
|
|
setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev);
|
|
|
|
|
2012-12-23 20:09:58 +00:00
|
|
|
sourcesink_driver.iConfiguration = strings_dev[USB_GZERO_SS_DESC].id;
|
2012-12-23 20:09:59 +00:00
|
|
|
loopback_driver.iConfiguration = strings_dev[USB_GZERO_LB_DESC].id;
|
|
|
|
|
2012-12-23 20:09:58 +00:00
|
|
|
/* support autoresume for remote wakeup testing */
|
|
|
|
sourcesink_driver.bmAttributes &= ~USB_CONFIG_ATT_WAKEUP;
|
2012-12-23 20:09:59 +00:00
|
|
|
loopback_driver.bmAttributes &= ~USB_CONFIG_ATT_WAKEUP;
|
2012-12-23 20:09:58 +00:00
|
|
|
sourcesink_driver.descriptors = NULL;
|
2012-12-23 20:09:59 +00:00
|
|
|
loopback_driver.descriptors = NULL;
|
|
|
|
if (autoresume) {
|
2012-12-23 20:09:58 +00:00
|
|
|
sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
|
2012-12-23 20:09:59 +00:00
|
|
|
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
|
|
|
|
}
|
2012-12-23 20:09:58 +00:00
|
|
|
|
|
|
|
/* support OTG systems */
|
|
|
|
if (gadget_is_otg(cdev->gadget)) {
|
|
|
|
sourcesink_driver.descriptors = otg_desc;
|
|
|
|
sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
|
2012-12-23 20:09:59 +00:00
|
|
|
loopback_driver.descriptors = otg_desc;
|
|
|
|
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
|
2012-12-23 20:09:58 +00:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
/* Register primary, then secondary configuration. Note that
|
|
|
|
* SH3 only allows one config...
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2008-06-20 01:18:27 +00:00
|
|
|
if (loopdefault) {
|
2012-12-23 20:09:59 +00:00
|
|
|
usb_add_config(cdev, &loopback_driver, loopback_bind_config);
|
2012-12-23 20:09:58 +00:00
|
|
|
usb_add_config(cdev, &sourcesink_driver,
|
|
|
|
sourcesink_bind_config);
|
2008-06-20 01:18:27 +00:00
|
|
|
} else {
|
2012-12-23 20:09:58 +00:00
|
|
|
usb_add_config(cdev, &sourcesink_driver,
|
|
|
|
sourcesink_bind_config);
|
2012-12-23 20:09:59 +00:00
|
|
|
usb_add_config(cdev, &loopback_driver, loopback_bind_config);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 13:01:53 +00:00
|
|
|
usb_composite_overwrite_options(cdev, &coverwrite);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-06-20 01:18:27 +00:00
|
|
|
INFO(cdev, "%s, version: " DRIVER_VERSION "\n", longname);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-19 21:16:09 +00:00
|
|
|
static int zero_unbind(struct usb_composite_dev *cdev)
|
|
|
|
{
|
|
|
|
del_timer_sync(&autoresume_timer);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-06 18:11:03 +00:00
|
|
|
static __refdata struct usb_composite_driver zero_driver = {
|
2008-06-20 01:18:27 +00:00
|
|
|
.name = "zero",
|
|
|
|
.dev = &device_desc,
|
|
|
|
.strings = dev_strings,
|
2011-07-03 14:29:31 +00:00
|
|
|
.max_speed = USB_SPEED_SUPER,
|
2012-09-06 18:11:04 +00:00
|
|
|
.bind = zero_bind,
|
2009-03-19 21:16:09 +00:00
|
|
|
.unbind = zero_unbind,
|
|
|
|
.suspend = zero_suspend,
|
|
|
|
.resume = zero_resume,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2007-08-02 19:20:05 +00:00
|
|
|
MODULE_AUTHOR("David Brownell");
|
|
|
|
MODULE_LICENSE("GPL");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-04-19 01:47:54 +00:00
|
|
|
static int __init init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-09-06 18:11:04 +00:00
|
|
|
return usb_composite_probe(&zero_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-04-19 01:47:54 +00:00
|
|
|
module_init(init);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-04-19 01:47:54 +00:00
|
|
|
static void __exit cleanup(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-06-20 01:18:27 +00:00
|
|
|
usb_composite_unregister(&zero_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-04-19 01:47:54 +00:00
|
|
|
module_exit(cleanup);
|