mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-16 22:10:24 +00:00
usb: gadget: patches for v3.6 merge window
This is quite a big pull request and contains patches all over the place. omap_udc is now a bit cleaner after removing omap2 support, fixing some checkpatch.pl warnings and errors, switching over to generic map/unmap routines and preventing a NULL pointer de-reference. s3c-hsotg has been switched over to devm_* API, got some locking fixes and improvements and it also got an implementation for the pullup() method. the mass storage gadgets changed default value of the removable parameter, dropped some unused options and made "file" and "ro" module_parameters read-only in some cases. ffs function got support for HID descriptor. Some UDCs have been converted to clk_prepare_enable() and clk_disable_unprepare(). Marvell now got support for its USB3 controller in mainline after introducing its mv_u3d_core.c driver. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAABAgAGBQJP8VZeAAoJEIaOsuA1yqREu0YP/jSrITte+Za8HMfvV1/eVNtz eVd+dhx82WnfPUmDHPsC+1IzCFlOIufFsqK/lWaNxVkUaL154lL85TPbxVPggNXA zvEldifaDahDax2B5MRP8hQKpp8rNrik/ePSPv1Lts5HsfPT2aUOYIcNAPlqdaPs 4x4VejujirUGIgo1swocDOHu2nB9PTqnhtLUgLGaZcAMQtT5z/ao5NGeSugbc7sS jvci0WKWzjxxPT77ZrcyaOrCmzTCR4yK0DZGFNsyVmY9ATTwSr/By0AgQdm36t6f xdqjGib+Y2C+6xW35suLo1N+3qErClNuvJtvXlQ5VUpa70dsZTFu8KiCv+td7KA1 9mNeovoAiuWKSgDevqJ8g4mND/LFcrGLyKR2dkyA2NNVANgJpPY3y3sjSXV8USt5 pLGolz3XFQsUejIvrmcsHKIXNrCgJChQeaBvM13dmwhw2SWPcW0OSQnw+kPOQm8W ByqmwSPIYxGKyd0UIcbqjlV5OXI1FcWIDSlTXbQZBId7YfVYqIuMizVvbZ8yE1pG RTSuyo/khG4OwVKIQoxYboNYBE2MM32L8G6Hh2ataiw1M0rjIvCh6180xENKQ2I1 iK54ViWctzNx7OC5JozUS+9i5KafRPdbxNHMUPGQQXpcCtb6Q4fmeGTyFYuIfTFK hRzP4o0SpAu7V+CoZ1Zz =hbE6 -----END PGP SIGNATURE----- Merge tag 'gadget-for-v3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next usb: gadget: patches for v3.6 merge window This is quite a big pull request and contains patches all over the place. omap_udc is now a bit cleaner after removing omap2 support, fixing some checkpatch.pl warnings and errors, switching over to generic map/unmap routines and preventing a NULL pointer de-reference. s3c-hsotg has been switched over to devm_* API, got some locking fixes and improvements and it also got an implementation for the pullup() method. the mass storage gadgets changed default value of the removable parameter, dropped some unused options and made "file" and "ro" module_parameters read-only in some cases. ffs function got support for HID descriptor. Some UDCs have been converted to clk_prepare_enable() and clk_disable_unprepare(). Marvell now got support for its USB3 controller in mainline after introducing its mv_u3d_core.c driver.
This commit is contained in:
commit
94ff447cf2
226
Documentation/usb/mass-storage.txt
Normal file
226
Documentation/usb/mass-storage.txt
Normal file
@ -0,0 +1,226 @@
|
||||
* Overview
|
||||
|
||||
Mass Storage Gadget (or MSG) acts as a USB Mass Storage device,
|
||||
appearing to the host as a disk or a CD-ROM drive. It supports
|
||||
multiple logical units (LUNs). Backing storage for each LUN is
|
||||
provided by a regular file or a block device, access can be limited
|
||||
to read-only, and gadget can indicate that it is removable and/or
|
||||
CD-ROM (the latter implies read-only access).
|
||||
|
||||
Its requirements are modest; only a bulk-in and a bulk-out endpoint
|
||||
are needed. The memory requirement amounts to two 16K buffers.
|
||||
Support is included for full-speed, high-speed and SuperSpeed
|
||||
operation.
|
||||
|
||||
Note that the driver is slightly non-portable in that it assumes
|
||||
a single memory/DMA buffer will be useable for bulk-in and bulk-out
|
||||
endpoints. With most device controllers this is not an issue, but
|
||||
there may be some with hardware restrictions that prevent a buffer
|
||||
from being used by more than one endpoint.
|
||||
|
||||
This document describes how to use the gadget from user space, its
|
||||
relation to mass storage function (or MSF) and different gadgets
|
||||
using it, and how it differs from File Storage Gadget (or FSG). It
|
||||
will talk only briefly about how to use MSF within composite
|
||||
gadgets.
|
||||
|
||||
* Module parameters
|
||||
|
||||
The mass storage gadget accepts the following mass storage specific
|
||||
module parameters:
|
||||
|
||||
- file=filename[,filename...]
|
||||
|
||||
This parameter lists paths to files or block devices used for
|
||||
backing storage for each logical unit. There may be at most
|
||||
FSG_MAX_LUNS (8) LUNs set. If more files are specified, they will
|
||||
be silently ignored. See also “luns” parameter.
|
||||
|
||||
*BEWARE* that if a file is used as a backing storage, it may not
|
||||
be modified by any other process. This is because the host
|
||||
assumes the data does not change without its knowledge. It may be
|
||||
read, but (if the logical unit is writable) due to buffering on
|
||||
the host side, the contents are not well defined.
|
||||
|
||||
The size of the logical unit will be rounded down to a full
|
||||
logical block. The logical block size is 2048 bytes for LUNs
|
||||
simulating CD-ROM, block size of the device if the backing file is
|
||||
a block device, or 512 bytes otherwise.
|
||||
|
||||
- removable=b[,b...]
|
||||
|
||||
This parameter specifies whether each logical unit should be
|
||||
removable. “b” here is either “y”, “Y” or “1” for true or “n”,
|
||||
“N” or “0” for false.
|
||||
|
||||
If this option is set for a logical unit, gadget will accept an
|
||||
“eject” SCSI request (Start/Stop Unit). When it is sent, the
|
||||
backing file will be closed to simulate ejection and the logical
|
||||
unit will not be mountable by the host until a new backing file is
|
||||
specified by userspace on the device (see “sysfs entries”
|
||||
section).
|
||||
|
||||
If a logical unit is not removable (the default), a backing file
|
||||
must be specified for it with the “file” parameter as the module
|
||||
is loaded. The same applies if the module is built in, no
|
||||
exceptions.
|
||||
|
||||
The default value of the flag is false, *HOWEVER* it used to be
|
||||
true. This has been changed to better match File Storage Gadget
|
||||
and because it seems like a saner default after all. Thus to
|
||||
maintain compatibility with older kernels, it's best to specify
|
||||
the default values. Also, if one relied on old default, explicit
|
||||
“n” needs to be specified now.
|
||||
|
||||
Note that “removable” means the logical unit's media can be
|
||||
ejected or removed (as is true for a CD-ROM drive or a card
|
||||
reader). It does *not* mean that the entire gadget can be
|
||||
unplugged from the host; the proper term for that is
|
||||
“hot-unpluggable”.
|
||||
|
||||
- cdrom=b[,b...]
|
||||
|
||||
This parameter specifies whether each logical unit should simulate
|
||||
CD-ROM. The default is false.
|
||||
|
||||
- ro=b[,b...]
|
||||
|
||||
This parameter specifies whether each logical unit should be
|
||||
reported as read only. This will prevent host from modifying the
|
||||
backing files.
|
||||
|
||||
Note that if this flag for given logical unit is false but the
|
||||
backing file could not be opened in read/write mode, the gadget
|
||||
will fall back to read only mode anyway.
|
||||
|
||||
The default value for non-CD-ROM logical units is false; for
|
||||
logical units simulating CD-ROM it is forced to true.
|
||||
|
||||
- nofua=b[,b...]
|
||||
|
||||
This parameter specifies whether FUA flag should be ignored in SCSI
|
||||
Write10 and Write12 commands sent to given logical units.
|
||||
|
||||
MS Windows mounts removable storage in “Removal optimised mode” by
|
||||
default. All the writes to the media are synchronous, which is
|
||||
achieved by setting the FUA (Force Unit Access) bit in SCSI
|
||||
Write(10,12) commands. This forces each write to wait until the
|
||||
data has actually been written out and prevents I/O requests
|
||||
aggregation in block layer dramatically decreasing performance.
|
||||
|
||||
Note that this may mean that if the device is powered from USB and
|
||||
the user unplugs the device without unmounting it first (which at
|
||||
least some Windows users do), the data may be lost.
|
||||
|
||||
The default value is false.
|
||||
|
||||
- luns=N
|
||||
|
||||
This parameter specifies number of logical units the gadget will
|
||||
have. It is limited by FSG_MAX_LUNS (8) and higher value will be
|
||||
capped.
|
||||
|
||||
If this parameter is provided, and the number of files specified
|
||||
in “file” argument is greater then the value of “luns”, all excess
|
||||
files will be ignored.
|
||||
|
||||
If this parameter is not present, the number of logical units will
|
||||
be deduced from the number of files specified in the “file”
|
||||
parameter. If the file parameter is missing as well, one is
|
||||
assumed.
|
||||
|
||||
- stall=b
|
||||
|
||||
Specifies whether the gadget is allowed to halt bulk endpoints.
|
||||
The default is determined according to the type of USB device
|
||||
controller, but usually true.
|
||||
|
||||
In addition to the above, the gadget also accepts the following
|
||||
parameters defined by the composite framework (they are common to
|
||||
all composite gadgets so just a quick listing):
|
||||
|
||||
- idVendor -- USB Vendor ID (16 bit integer)
|
||||
- idProduct -- USB Product ID (16 bit integer)
|
||||
- bcdDevice -- USB Device version (BCD) (16 bit integer)
|
||||
- iManufacturer -- USB Manufacturer string (string)
|
||||
- iProduct -- USB Product string (string)
|
||||
- iSerialNumber -- SerialNumber string (sting)
|
||||
|
||||
* sysfs entries
|
||||
|
||||
For each logical unit, the gadget creates a directory in the sysfs
|
||||
hierarchy. Inside of it the following three files are created:
|
||||
|
||||
- file
|
||||
|
||||
When read it returns the path to the backing file for the given
|
||||
logical unit. If there is no backing file (possible only if the
|
||||
logical unit is removable), the content is empty.
|
||||
|
||||
When written into, it changes the backing file for given logical
|
||||
unit. This change can be performed even if given logical unit is
|
||||
not specified as removable (but that may look strange to the
|
||||
host). It may fail, however, if host disallowed medium removal
|
||||
with the Prevent-Allow Medium Removal SCSI command.
|
||||
|
||||
- ro
|
||||
|
||||
Reflects the state of ro flag for the given logical unit. It can
|
||||
be read any time, and written to when there is no backing file
|
||||
open for given logical unit.
|
||||
|
||||
- nofua
|
||||
|
||||
Reflects the state of nofua flag for given logical unit. It can
|
||||
be read and written.
|
||||
|
||||
Other then those, as usual, the values of module parameters can be
|
||||
read from /sys/module/g_mass_storage/parameters/* files.
|
||||
|
||||
* Other gadgets using mass storage function
|
||||
|
||||
The Mass Storage Gadget uses the Mass Storage Function to handle
|
||||
mass storage protocol. As a composite function, MSF may be used by
|
||||
other gadgets as well (eg. g_multi and acm_ms).
|
||||
|
||||
All of the information in previous sections are valid for other
|
||||
gadgets using MSF, except that support for mass storage related
|
||||
module parameters may be missing, or the parameters may have
|
||||
a prefix. To figure out whether any of this is true one needs to
|
||||
consult the gadget's documentation or its source code.
|
||||
|
||||
For examples of how to include mass storage function in gadgets, one
|
||||
may take a look at mass_storage.c, acm_ms.c and multi.c (sorted by
|
||||
complexity).
|
||||
|
||||
* Relation to file storage gadget
|
||||
|
||||
The Mass Storage Function and thus the Mass Storage Gadget has been
|
||||
based on the File Storage Gadget. The difference between the two is
|
||||
that MSG is a composite gadget (ie. uses the composite framework)
|
||||
while file storage gadget is a traditional gadget. From userspace
|
||||
point of view this distinction does not really matter, but from
|
||||
kernel hacker's point of view, this means that (i) MSG does not
|
||||
duplicate code needed for handling basic USB protocol commands and
|
||||
(ii) MSF can be used in any other composite gadget.
|
||||
|
||||
Because of that, File Storage Gadget has been deprecated and
|
||||
scheduled to be removed in Linux 3.8. All users need to transition
|
||||
to the Mass Storage Gadget by that time. The two gadgets behave
|
||||
mostly the same from the outside except:
|
||||
|
||||
1. In FSG the “removable” and “cdrom” module parameters set the flag
|
||||
for all logical units whereas in MSG they accept a list of y/n
|
||||
values for each logical unit. If one uses only a single logical
|
||||
unit this does not matter, but if there are more, the y/n value
|
||||
needs to be repeated for each logical unit.
|
||||
|
||||
2. FSG's “serial”, “vendor”, “product” and “release” module
|
||||
parameters are handled in MSG by the composite layer's parameters
|
||||
named respectively: “iSerialnumber”, “idVendor”, “idProduct” and
|
||||
“bcdDevice”.
|
||||
|
||||
3. MSG does not support FSG's test mode, thus “transport”,
|
||||
“protocol” and “buflen” FSG's module parameters are not
|
||||
supported. MSG always uses SCSI protocol with bulk only
|
||||
transport mode and 16 KiB buffers.
|
@ -414,7 +414,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
|
||||
|
||||
params.param0 = DWC3_DEPCFG_EP_TYPE(usb_endpoint_type(desc))
|
||||
| DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc))
|
||||
| DWC3_DEPCFG_BURST_SIZE(dep->endpoint.maxburst);
|
||||
| DWC3_DEPCFG_BURST_SIZE(dep->endpoint.maxburst - 1);
|
||||
|
||||
params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN
|
||||
| DWC3_DEPCFG_XFER_NOT_READY_EN;
|
||||
|
@ -321,6 +321,15 @@ config USB_MV_UDC
|
||||
USB2.0 OTG controller, which can be configured as high speed or
|
||||
full speed USB peripheral.
|
||||
|
||||
config USB_MV_U3D
|
||||
tristate "MARVELL PXA2128 USB 3.0 controller"
|
||||
depends on CPU_MMP3
|
||||
select USB_GADGET_DUALSPEED
|
||||
select USB_GADGET_SUPERSPEED
|
||||
help
|
||||
MARVELL PXA2128 Processor series include a super speed USB3.0 device
|
||||
controller, which support super speed USB peripheral.
|
||||
|
||||
#
|
||||
# Controllers available in both integrated and discrete versions
|
||||
#
|
||||
|
@ -29,6 +29,7 @@ obj-$(CONFIG_USB_EG20T) += pch_udc.o
|
||||
obj-$(CONFIG_USB_MV_UDC) += mv_udc.o
|
||||
mv_udc-y := mv_udc_core.o
|
||||
obj-$(CONFIG_USB_FUSB300) += fusb300_udc.o
|
||||
obj-$(CONFIG_USB_MV_U3D) += mv_u3d_core.o
|
||||
|
||||
#
|
||||
# USB gadget drivers
|
||||
|
@ -235,6 +235,7 @@ static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
|
||||
static struct usb_composite_driver acm_ms_driver = {
|
||||
.name = "g_acm_ms",
|
||||
.dev = &device_desc,
|
||||
.max_speed = USB_SPEED_SUPER,
|
||||
.strings = dev_strings,
|
||||
.unbind = __exit_p(acm_ms_unbind),
|
||||
};
|
||||
|
@ -1634,6 +1634,7 @@ static int at91_start(struct usb_gadget *gadget,
|
||||
udc = container_of(gadget, struct at91_udc, gadget);
|
||||
udc->driver = driver;
|
||||
udc->gadget.dev.driver = &driver->driver;
|
||||
udc->gadget.dev.of_node = udc->pdev->dev.of_node;
|
||||
dev_set_drvdata(&udc->gadget.dev, &driver->driver);
|
||||
udc->enabled = 1;
|
||||
udc->selfpowered = 1;
|
||||
|
@ -117,6 +117,7 @@ int config_ep_by_speed(struct usb_gadget *g,
|
||||
struct usb_function *f,
|
||||
struct usb_ep *_ep)
|
||||
{
|
||||
struct usb_composite_dev *cdev = get_gadget_data(g);
|
||||
struct usb_endpoint_descriptor *chosen_desc = NULL;
|
||||
struct usb_descriptor_header **speed_desc = NULL;
|
||||
|
||||
@ -180,10 +181,12 @@ ep_found:
|
||||
_ep->mult = comp_desc->bmAttributes & 0x3;
|
||||
case USB_ENDPOINT_XFER_BULK:
|
||||
case USB_ENDPOINT_XFER_INT:
|
||||
_ep->maxburst = comp_desc->bMaxBurst;
|
||||
_ep->maxburst = comp_desc->bMaxBurst + 1;
|
||||
break;
|
||||
default:
|
||||
/* Do nothing for control endpoints */
|
||||
if (comp_desc->bMaxBurst != 0)
|
||||
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
|
||||
_ep->maxburst = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/hid.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
#include <linux/usb/composite.h>
|
||||
@ -1671,6 +1672,12 @@ static int __must_check ffs_do_desc(char *data, unsigned len,
|
||||
}
|
||||
break;
|
||||
|
||||
case HID_DT_HID:
|
||||
pr_vdebug("hid descriptor\n");
|
||||
if (length != sizeof(struct hid_descriptor))
|
||||
goto inv_length;
|
||||
break;
|
||||
|
||||
case USB_DT_OTG:
|
||||
if (length != sizeof(struct usb_otg_descriptor))
|
||||
goto inv_length;
|
||||
|
@ -26,6 +26,12 @@ static struct class *hidg_class;
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/* HID gadget struct */
|
||||
|
||||
struct f_hidg_req_list {
|
||||
struct usb_request *req;
|
||||
unsigned int pos;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
struct f_hidg {
|
||||
/* configuration */
|
||||
unsigned char bInterfaceSubClass;
|
||||
@ -35,10 +41,10 @@ struct f_hidg {
|
||||
unsigned short report_length;
|
||||
|
||||
/* recv report */
|
||||
char *set_report_buff;
|
||||
unsigned short set_report_length;
|
||||
struct list_head completed_out_req;
|
||||
spinlock_t spinlock;
|
||||
wait_queue_head_t read_queue;
|
||||
unsigned int qlen;
|
||||
|
||||
/* send report */
|
||||
struct mutex lock;
|
||||
@ -49,7 +55,9 @@ struct f_hidg {
|
||||
int minor;
|
||||
struct cdev cdev;
|
||||
struct usb_function func;
|
||||
|
||||
struct usb_ep *in_ep;
|
||||
struct usb_ep *out_ep;
|
||||
};
|
||||
|
||||
static inline struct f_hidg *func_to_hidg(struct usb_function *f)
|
||||
@ -65,7 +73,7 @@ static struct usb_interface_descriptor hidg_interface_desc = {
|
||||
.bDescriptorType = USB_DT_INTERFACE,
|
||||
/* .bInterfaceNumber = DYNAMIC */
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 1,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = USB_CLASS_HID,
|
||||
/* .bInterfaceSubClass = DYNAMIC */
|
||||
/* .bInterfaceProtocol = DYNAMIC */
|
||||
@ -96,10 +104,23 @@ static struct usb_endpoint_descriptor hidg_hs_in_ep_desc = {
|
||||
*/
|
||||
};
|
||||
|
||||
static struct usb_endpoint_descriptor hidg_hs_out_ep_desc = {
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = USB_DIR_OUT,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_INT,
|
||||
/*.wMaxPacketSize = DYNAMIC */
|
||||
.bInterval = 4, /* FIXME: Add this field in the
|
||||
* HID gadget configuration?
|
||||
* (struct hidg_func_descriptor)
|
||||
*/
|
||||
};
|
||||
|
||||
static struct usb_descriptor_header *hidg_hs_descriptors[] = {
|
||||
(struct usb_descriptor_header *)&hidg_interface_desc,
|
||||
(struct usb_descriptor_header *)&hidg_desc,
|
||||
(struct usb_descriptor_header *)&hidg_hs_in_ep_desc,
|
||||
(struct usb_descriptor_header *)&hidg_hs_out_ep_desc,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@ -117,10 +138,23 @@ static struct usb_endpoint_descriptor hidg_fs_in_ep_desc = {
|
||||
*/
|
||||
};
|
||||
|
||||
static struct usb_endpoint_descriptor hidg_fs_out_ep_desc = {
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = USB_DIR_OUT,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_INT,
|
||||
/*.wMaxPacketSize = DYNAMIC */
|
||||
.bInterval = 10, /* FIXME: Add this field in the
|
||||
* HID gadget configuration?
|
||||
* (struct hidg_func_descriptor)
|
||||
*/
|
||||
};
|
||||
|
||||
static struct usb_descriptor_header *hidg_fs_descriptors[] = {
|
||||
(struct usb_descriptor_header *)&hidg_interface_desc,
|
||||
(struct usb_descriptor_header *)&hidg_desc,
|
||||
(struct usb_descriptor_header *)&hidg_fs_in_ep_desc,
|
||||
(struct usb_descriptor_header *)&hidg_fs_out_ep_desc,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@ -130,9 +164,11 @@ static struct usb_descriptor_header *hidg_fs_descriptors[] = {
|
||||
static ssize_t f_hidg_read(struct file *file, char __user *buffer,
|
||||
size_t count, loff_t *ptr)
|
||||
{
|
||||
struct f_hidg *hidg = file->private_data;
|
||||
char *tmp_buff = NULL;
|
||||
unsigned long flags;
|
||||
struct f_hidg *hidg = file->private_data;
|
||||
struct f_hidg_req_list *list;
|
||||
struct usb_request *req;
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
@ -142,8 +178,9 @@ static ssize_t f_hidg_read(struct file *file, char __user *buffer,
|
||||
|
||||
spin_lock_irqsave(&hidg->spinlock, flags);
|
||||
|
||||
#define READ_COND (hidg->set_report_buff != NULL)
|
||||
#define READ_COND (!list_empty(&hidg->completed_out_req))
|
||||
|
||||
/* wait for at least one buffer to complete */
|
||||
while (!READ_COND) {
|
||||
spin_unlock_irqrestore(&hidg->spinlock, flags);
|
||||
if (file->f_flags & O_NONBLOCK)
|
||||
@ -155,19 +192,34 @@ static ssize_t f_hidg_read(struct file *file, char __user *buffer,
|
||||
spin_lock_irqsave(&hidg->spinlock, flags);
|
||||
}
|
||||
|
||||
|
||||
count = min_t(unsigned, count, hidg->set_report_length);
|
||||
tmp_buff = hidg->set_report_buff;
|
||||
hidg->set_report_buff = NULL;
|
||||
|
||||
/* pick the first one */
|
||||
list = list_first_entry(&hidg->completed_out_req,
|
||||
struct f_hidg_req_list, list);
|
||||
req = list->req;
|
||||
count = min_t(unsigned int, count, req->actual - list->pos);
|
||||
spin_unlock_irqrestore(&hidg->spinlock, flags);
|
||||
|
||||
if (tmp_buff != NULL) {
|
||||
/* copy to user outside spinlock */
|
||||
count -= copy_to_user(buffer, tmp_buff, count);
|
||||
kfree(tmp_buff);
|
||||
} else
|
||||
count = -ENOMEM;
|
||||
/* copy to user outside spinlock */
|
||||
count -= copy_to_user(buffer, req->buf + list->pos, count);
|
||||
list->pos += count;
|
||||
|
||||
/*
|
||||
* if this request is completely handled and transfered to
|
||||
* userspace, remove its entry from the list and requeue it
|
||||
* again. Otherwise, we will revisit it again upon the next
|
||||
* call, taking into account its current read position.
|
||||
*/
|
||||
if (list->pos == req->actual) {
|
||||
spin_lock_irqsave(&hidg->spinlock, flags);
|
||||
list_del(&list->list);
|
||||
kfree(list);
|
||||
spin_unlock_irqrestore(&hidg->spinlock, flags);
|
||||
|
||||
req->length = hidg->report_length;
|
||||
ret = usb_ep_queue(hidg->out_ep, req, GFP_KERNEL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@ -282,28 +334,37 @@ static int f_hidg_open(struct inode *inode, struct file *fd)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/* usb_function */
|
||||
|
||||
static struct usb_request *hidg_alloc_ep_req(struct usb_ep *ep, unsigned length)
|
||||
{
|
||||
struct usb_request *req;
|
||||
|
||||
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
|
||||
if (req) {
|
||||
req->length = length;
|
||||
req->buf = kmalloc(length, GFP_ATOMIC);
|
||||
if (!req->buf) {
|
||||
usb_ep_free_request(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
return req;
|
||||
}
|
||||
|
||||
static void hidg_set_report_complete(struct usb_ep *ep, struct usb_request *req)
|
||||
{
|
||||
struct f_hidg *hidg = (struct f_hidg *)req->context;
|
||||
struct f_hidg *hidg = (struct f_hidg *) req->context;
|
||||
struct f_hidg_req_list *req_list;
|
||||
unsigned long flags;
|
||||
|
||||
if (req->status != 0 || req->buf == NULL || req->actual == 0) {
|
||||
ERROR(hidg->func.config->cdev, "%s FAILED\n", __func__);
|
||||
req_list = kzalloc(sizeof(*req_list), GFP_ATOMIC);
|
||||
if (!req_list)
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock(&hidg->spinlock);
|
||||
req_list->req = req;
|
||||
|
||||
hidg->set_report_buff = krealloc(hidg->set_report_buff,
|
||||
req->actual, GFP_ATOMIC);
|
||||
|
||||
if (hidg->set_report_buff == NULL) {
|
||||
spin_unlock(&hidg->spinlock);
|
||||
return;
|
||||
}
|
||||
hidg->set_report_length = req->actual;
|
||||
memcpy(hidg->set_report_buff, req->buf, req->actual);
|
||||
|
||||
spin_unlock(&hidg->spinlock);
|
||||
spin_lock_irqsave(&hidg->spinlock, flags);
|
||||
list_add_tail(&req_list->list, &hidg->completed_out_req);
|
||||
spin_unlock_irqrestore(&hidg->spinlock, flags);
|
||||
|
||||
wake_up(&hidg->read_queue);
|
||||
}
|
||||
@ -344,9 +405,7 @@ static int hidg_setup(struct usb_function *f,
|
||||
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
|
||||
| HID_REQ_SET_REPORT):
|
||||
VDBG(cdev, "set_report | wLenght=%d\n", ctrl->wLength);
|
||||
req->context = hidg;
|
||||
req->complete = hidg_set_report_complete;
|
||||
goto respond;
|
||||
goto stall;
|
||||
break;
|
||||
|
||||
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
|
||||
@ -403,16 +462,25 @@ respond:
|
||||
static void hidg_disable(struct usb_function *f)
|
||||
{
|
||||
struct f_hidg *hidg = func_to_hidg(f);
|
||||
struct f_hidg_req_list *list, *next;
|
||||
|
||||
usb_ep_disable(hidg->in_ep);
|
||||
hidg->in_ep->driver_data = NULL;
|
||||
|
||||
usb_ep_disable(hidg->out_ep);
|
||||
hidg->out_ep->driver_data = NULL;
|
||||
|
||||
list_for_each_entry_safe(list, next, &hidg->completed_out_req, list) {
|
||||
list_del(&list->list);
|
||||
kfree(list);
|
||||
}
|
||||
}
|
||||
|
||||
static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
|
||||
{
|
||||
struct usb_composite_dev *cdev = f->config->cdev;
|
||||
struct f_hidg *hidg = func_to_hidg(f);
|
||||
int status = 0;
|
||||
int i, status = 0;
|
||||
|
||||
VDBG(cdev, "hidg_set_alt intf:%d alt:%d\n", intf, alt);
|
||||
|
||||
@ -429,11 +497,55 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
|
||||
}
|
||||
status = usb_ep_enable(hidg->in_ep);
|
||||
if (status < 0) {
|
||||
ERROR(cdev, "Enable endpoint FAILED!\n");
|
||||
ERROR(cdev, "Enable IN endpoint FAILED!\n");
|
||||
goto fail;
|
||||
}
|
||||
hidg->in_ep->driver_data = hidg;
|
||||
}
|
||||
|
||||
|
||||
if (hidg->out_ep != NULL) {
|
||||
/* restart endpoint */
|
||||
if (hidg->out_ep->driver_data != NULL)
|
||||
usb_ep_disable(hidg->out_ep);
|
||||
|
||||
status = config_ep_by_speed(f->config->cdev->gadget, f,
|
||||
hidg->out_ep);
|
||||
if (status) {
|
||||
ERROR(cdev, "config_ep_by_speed FAILED!\n");
|
||||
goto fail;
|
||||
}
|
||||
status = usb_ep_enable(hidg->out_ep);
|
||||
if (status < 0) {
|
||||
ERROR(cdev, "Enable IN endpoint FAILED!\n");
|
||||
goto fail;
|
||||
}
|
||||
hidg->out_ep->driver_data = hidg;
|
||||
|
||||
/*
|
||||
* allocate a bunch of read buffers and queue them all at once.
|
||||
*/
|
||||
for (i = 0; i < hidg->qlen && status == 0; i++) {
|
||||
struct usb_request *req =
|
||||
hidg_alloc_ep_req(hidg->out_ep,
|
||||
hidg->report_length);
|
||||
if (req) {
|
||||
req->complete = hidg_set_report_complete;
|
||||
req->context = hidg;
|
||||
status = usb_ep_queue(hidg->out_ep, req,
|
||||
GFP_ATOMIC);
|
||||
if (status)
|
||||
ERROR(cdev, "%s queue req --> %d\n",
|
||||
hidg->out_ep->name, status);
|
||||
} else {
|
||||
usb_ep_disable(hidg->out_ep);
|
||||
hidg->out_ep->driver_data = NULL;
|
||||
status = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fail:
|
||||
return status;
|
||||
}
|
||||
@ -470,13 +582,18 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
ep->driver_data = c->cdev; /* claim */
|
||||
hidg->in_ep = ep;
|
||||
|
||||
ep = usb_ep_autoconfig(c->cdev->gadget, &hidg_fs_out_ep_desc);
|
||||
if (!ep)
|
||||
goto fail;
|
||||
ep->driver_data = c->cdev; /* claim */
|
||||
hidg->out_ep = ep;
|
||||
|
||||
/* preallocate request and buffer */
|
||||
status = -ENOMEM;
|
||||
hidg->req = usb_ep_alloc_request(hidg->in_ep, GFP_KERNEL);
|
||||
if (!hidg->req)
|
||||
goto fail;
|
||||
|
||||
|
||||
hidg->req->buf = kmalloc(hidg->report_length, GFP_KERNEL);
|
||||
if (!hidg->req->buf)
|
||||
goto fail;
|
||||
@ -486,12 +603,12 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
|
||||
hidg_hs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
|
||||
hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
|
||||
hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
|
||||
hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
|
||||
hidg_desc.desc[0].bDescriptorType = HID_DT_REPORT;
|
||||
hidg_desc.desc[0].wDescriptorLength =
|
||||
cpu_to_le16(hidg->report_desc_length);
|
||||
|
||||
hidg->set_report_buff = NULL;
|
||||
|
||||
/* copy descriptors */
|
||||
f->descriptors = usb_copy_descriptors(hidg_fs_descriptors);
|
||||
if (!f->descriptors)
|
||||
@ -500,6 +617,8 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
if (gadget_is_dualspeed(c->cdev->gadget)) {
|
||||
hidg_hs_in_ep_desc.bEndpointAddress =
|
||||
hidg_fs_in_ep_desc.bEndpointAddress;
|
||||
hidg_hs_out_ep_desc.bEndpointAddress =
|
||||
hidg_fs_out_ep_desc.bEndpointAddress;
|
||||
f->hs_descriptors = usb_copy_descriptors(hidg_hs_descriptors);
|
||||
if (!f->hs_descriptors)
|
||||
goto fail;
|
||||
@ -509,6 +628,7 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
spin_lock_init(&hidg->spinlock);
|
||||
init_waitqueue_head(&hidg->write_queue);
|
||||
init_waitqueue_head(&hidg->read_queue);
|
||||
INIT_LIST_HEAD(&hidg->completed_out_req);
|
||||
|
||||
/* create char device */
|
||||
cdev_init(&hidg->cdev, &f_hidg_fops);
|
||||
@ -553,7 +673,6 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f)
|
||||
usb_free_descriptors(f->descriptors);
|
||||
|
||||
kfree(hidg->report_desc);
|
||||
kfree(hidg->set_report_buff);
|
||||
kfree(hidg);
|
||||
}
|
||||
|
||||
@ -624,6 +743,9 @@ int __init hidg_bind_config(struct usb_configuration *c,
|
||||
hidg->func.disable = hidg_disable;
|
||||
hidg->func.setup = hidg_setup;
|
||||
|
||||
/* this could me made configurable at some point */
|
||||
hidg->qlen = 4;
|
||||
|
||||
status = usb_add_function(c, &hidg->func);
|
||||
if (status)
|
||||
kfree(hidg);
|
||||
|
@ -44,12 +44,12 @@
|
||||
* function for a USB device, it also illustrates a technique of
|
||||
* double-buffering for increased throughput.
|
||||
*
|
||||
* Function supports multiple logical units (LUNs). Backing storage
|
||||
* for each LUN is provided by a regular file or a block device.
|
||||
* Access for each LUN can be limited to read-only. Moreover, the
|
||||
* function can indicate that LUN is removable and/or CD-ROM. (The
|
||||
* later implies read-only access.)
|
||||
*
|
||||
* For more information about MSF and in particular its module
|
||||
* parameters and sysfs interface read the
|
||||
* <Documentation/usb/mass-storage.txt> file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MSF is configured by specifying a fsg_config structure. It has the
|
||||
* following fields:
|
||||
*
|
||||
@ -75,25 +75,6 @@
|
||||
* ->nofua Flag specifying that FUA flag in SCSI WRITE(10,12)
|
||||
* commands for this LUN shall be ignored.
|
||||
*
|
||||
* lun_name_format A printf-like format for names of the LUN
|
||||
* devices. This determines how the
|
||||
* directory in sysfs will be named.
|
||||
* Unless you are using several MSFs in
|
||||
* a single gadget (as opposed to single
|
||||
* MSF in many configurations) you may
|
||||
* leave it as NULL (in which case
|
||||
* "lun%d" will be used). In the format
|
||||
* you can use "%d" to index LUNs for
|
||||
* MSF's with more than one LUN. (Beware
|
||||
* that there is only one integer given
|
||||
* as an argument for the format and
|
||||
* specifying invalid format may cause
|
||||
* unspecified behaviour.)
|
||||
* thread_name Name of the kernel thread process used by the
|
||||
* MSF. You can safely set it to NULL
|
||||
* (in which case default "file-storage"
|
||||
* will be used).
|
||||
*
|
||||
* vendor_name
|
||||
* product_name
|
||||
* release Information used as a reply to INQUIRY
|
||||
@ -114,62 +95,6 @@
|
||||
* data track and no audio tracks; hence there need be only one
|
||||
* backing file per LUN.
|
||||
*
|
||||
*
|
||||
* MSF includes support for module parameters. If gadget using it
|
||||
* decides to use it, the following module parameters will be
|
||||
* available:
|
||||
*
|
||||
* file=filename[,filename...]
|
||||
* Names of the files or block devices used for
|
||||
* backing storage.
|
||||
* ro=b[,b...] Default false, boolean for read-only access.
|
||||
* removable=b[,b...]
|
||||
* Default true, boolean for removable media.
|
||||
* cdrom=b[,b...] Default false, boolean for whether to emulate
|
||||
* a CD-ROM drive.
|
||||
* nofua=b[,b...] Default false, booleans for ignore FUA flag
|
||||
* in SCSI WRITE(10,12) commands
|
||||
* luns=N Default N = number of filenames, number of
|
||||
* LUNs to support.
|
||||
* stall Default determined according to the type of
|
||||
* USB device controller (usually true),
|
||||
* boolean to permit the driver to halt
|
||||
* bulk endpoints.
|
||||
*
|
||||
* The module parameters may be prefixed with some string. You need
|
||||
* to consult gadget's documentation or source to verify whether it is
|
||||
* using those module parameters and if it does what are the prefixes
|
||||
* (look for FSG_MODULE_PARAMETERS() macro usage, what's inside it is
|
||||
* the prefix).
|
||||
*
|
||||
*
|
||||
* Requirements are modest; only a bulk-in and a bulk-out endpoint are
|
||||
* needed. The memory requirement amounts to two 16K buffers, size
|
||||
* configurable by a parameter. Support is included for both
|
||||
* full-speed and high-speed operation.
|
||||
*
|
||||
* Note that the driver is slightly non-portable in that it assumes a
|
||||
* single memory/DMA buffer will be useable for bulk-in, bulk-out, and
|
||||
* interrupt-in endpoints. With most device controllers this isn't an
|
||||
* issue, but there may be some with hardware restrictions that prevent
|
||||
* a buffer from being used by more than one endpoint.
|
||||
*
|
||||
*
|
||||
* The pathnames of the backing files and the ro settings are
|
||||
* available in the attribute files "file" and "ro" in the lun<n> (or
|
||||
* to be more precise in a directory which name comes from
|
||||
* "lun_name_format" option!) subdirectory of the gadget's sysfs
|
||||
* directory. If the "removable" option is set, writing to these
|
||||
* files will simulate ejecting/loading the medium (writing an empty
|
||||
* line means eject) and adjusting a write-enable tab. Changes to the
|
||||
* ro setting are not allowed when the medium is loaded or if CD-ROM
|
||||
* emulation is being used.
|
||||
*
|
||||
* When a LUN receive an "eject" SCSI request (Start/Stop Unit),
|
||||
* if the LUN is removable, the backing file is released to simulate
|
||||
* ejection.
|
||||
*
|
||||
*
|
||||
* This function is heavily based on "File-backed Storage Gadget" by
|
||||
* Alan Stern which in turn is heavily based on "Gadget Zero" by David
|
||||
* Brownell. The driver's SCSI command interface was based on the
|
||||
@ -211,7 +136,7 @@
|
||||
* In normal operation the main thread is started during the gadget's
|
||||
* fsg_bind() callback and stopped during fsg_unbind(). But it can
|
||||
* also exit when it receives a signal, and there's no point leaving
|
||||
* the gadget running when the thread is dead. At of this moment, MSF
|
||||
* the gadget running when the thread is dead. As of this moment, MSF
|
||||
* provides no way to deregister the gadget when thread dies -- maybe
|
||||
* a callback functions is needed.
|
||||
*
|
||||
@ -417,9 +342,6 @@ struct fsg_config {
|
||||
char nofua;
|
||||
} luns[FSG_MAX_LUNS];
|
||||
|
||||
const char *lun_name_format;
|
||||
const char *thread_name;
|
||||
|
||||
/* Callback functions. */
|
||||
const struct fsg_operations *ops;
|
||||
/* Gadget's private data. */
|
||||
@ -2687,11 +2609,15 @@ static int fsg_main_thread(void *common_)
|
||||
|
||||
/*************************** DEVICE ATTRIBUTES ***************************/
|
||||
|
||||
/* Write permission is checked per LUN in store_*() functions. */
|
||||
static DEVICE_ATTR(ro, 0644, fsg_show_ro, fsg_store_ro);
|
||||
static DEVICE_ATTR(nofua, 0644, fsg_show_nofua, fsg_store_nofua);
|
||||
static DEVICE_ATTR(file, 0644, fsg_show_file, fsg_store_file);
|
||||
|
||||
static struct device_attribute dev_attr_ro_cdrom =
|
||||
__ATTR(ro, 0444, fsg_show_ro, NULL);
|
||||
static struct device_attribute dev_attr_file_nonremovable =
|
||||
__ATTR(file, 0444, fsg_show_file, NULL);
|
||||
|
||||
|
||||
/****************************** FSG COMMON ******************************/
|
||||
|
||||
@ -2792,11 +2718,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
|
||||
curlun->dev.parent = &gadget->dev;
|
||||
/* curlun->dev.driver = &fsg_driver.driver; XXX */
|
||||
dev_set_drvdata(&curlun->dev, &common->filesem);
|
||||
dev_set_name(&curlun->dev,
|
||||
cfg->lun_name_format
|
||||
? cfg->lun_name_format
|
||||
: "lun%d",
|
||||
i);
|
||||
dev_set_name(&curlun->dev, "lun%d", i);
|
||||
|
||||
rc = device_register(&curlun->dev);
|
||||
if (rc) {
|
||||
@ -2806,10 +2728,16 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
|
||||
goto error_release;
|
||||
}
|
||||
|
||||
rc = device_create_file(&curlun->dev, &dev_attr_ro);
|
||||
rc = device_create_file(&curlun->dev,
|
||||
curlun->cdrom
|
||||
? &dev_attr_ro_cdrom
|
||||
: &dev_attr_ro);
|
||||
if (rc)
|
||||
goto error_luns;
|
||||
rc = device_create_file(&curlun->dev, &dev_attr_file);
|
||||
rc = device_create_file(&curlun->dev,
|
||||
curlun->removable
|
||||
? &dev_attr_file
|
||||
: &dev_attr_file_nonremovable);
|
||||
if (rc)
|
||||
goto error_luns;
|
||||
rc = device_create_file(&curlun->dev, &dev_attr_nofua);
|
||||
@ -2878,8 +2806,7 @@ buffhds_first_it:
|
||||
|
||||
/* Tell the thread to start working */
|
||||
common->thread_task =
|
||||
kthread_create(fsg_main_thread, common,
|
||||
cfg->thread_name ?: "file-storage");
|
||||
kthread_create(fsg_main_thread, common, "file-storage");
|
||||
if (IS_ERR(common->thread_task)) {
|
||||
rc = PTR_ERR(common->thread_task);
|
||||
goto error_release;
|
||||
@ -2945,8 +2872,14 @@ static void fsg_common_release(struct kref *ref)
|
||||
/* In error recovery common->nluns may be zero. */
|
||||
for (; i; --i, ++lun) {
|
||||
device_remove_file(&lun->dev, &dev_attr_nofua);
|
||||
device_remove_file(&lun->dev, &dev_attr_ro);
|
||||
device_remove_file(&lun->dev, &dev_attr_file);
|
||||
device_remove_file(&lun->dev,
|
||||
lun->cdrom
|
||||
? &dev_attr_ro_cdrom
|
||||
: &dev_attr_ro);
|
||||
device_remove_file(&lun->dev,
|
||||
lun->removable
|
||||
? &dev_attr_file
|
||||
: &dev_attr_file_nonremovable);
|
||||
fsg_lun_close(lun);
|
||||
device_unregister(&lun->dev);
|
||||
}
|
||||
@ -3167,8 +3100,7 @@ fsg_config_from_params(struct fsg_config *cfg,
|
||||
for (i = 0, lun = cfg->luns; i < cfg->nluns; ++i, ++lun) {
|
||||
lun->ro = !!params->ro[i];
|
||||
lun->cdrom = !!params->cdrom[i];
|
||||
lun->removable = /* Removable by default */
|
||||
params->removable_count <= i || params->removable[i];
|
||||
lun->removable = !!params->removable[i];
|
||||
lun->filename =
|
||||
params->file_count > i && params->file[i][0]
|
||||
? params->file[i]
|
||||
@ -3176,8 +3108,6 @@ fsg_config_from_params(struct fsg_config *cfg,
|
||||
}
|
||||
|
||||
/* Let MSF use defaults */
|
||||
cfg->lun_name_format = 0;
|
||||
cfg->thread_name = 0;
|
||||
cfg->vendor_name = 0;
|
||||
cfg->product_name = 0;
|
||||
cfg->release = 0xffff;
|
||||
@ -3203,4 +3133,3 @@ fsg_common_from_params(struct fsg_common *common,
|
||||
fsg_config_from_params(&cfg, params);
|
||||
return fsg_common_init(common, cdev, &cfg);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,25 @@
|
||||
|
||||
unsigned int uvc_gadget_trace_param;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* module parameters specific to the Video streaming endpoint */
|
||||
static unsigned streaming_interval = 1;
|
||||
module_param(streaming_interval, uint, S_IRUGO|S_IWUSR);
|
||||
MODULE_PARM_DESC(streaming_interval, "1 - 16");
|
||||
|
||||
static unsigned streaming_maxpacket = 1024;
|
||||
module_param(streaming_maxpacket, uint, S_IRUGO|S_IWUSR);
|
||||
MODULE_PARM_DESC(streaming_maxpacket, "0 - 1023 (fs), 0 - 1024 (hs/ss)");
|
||||
|
||||
static unsigned streaming_mult;
|
||||
module_param(streaming_mult, uint, S_IRUGO|S_IWUSR);
|
||||
MODULE_PARM_DESC(streaming_mult, "0 - 2 (hs/ss only)");
|
||||
|
||||
static unsigned streaming_maxburst;
|
||||
module_param(streaming_maxburst, uint, S_IRUGO|S_IWUSR);
|
||||
MODULE_PARM_DESC(streaming_maxburst, "0 - 15 (ss only)");
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Function descriptors
|
||||
*/
|
||||
@ -59,6 +78,8 @@ static struct usb_gadget_strings *uvc_function_strings[] = {
|
||||
#define UVC_INTF_VIDEO_CONTROL 0
|
||||
#define UVC_INTF_VIDEO_STREAMING 1
|
||||
|
||||
#define STATUS_BYTECOUNT 16 /* 16 bytes status */
|
||||
|
||||
static struct usb_interface_assoc_descriptor uvc_iad __initdata = {
|
||||
.bLength = sizeof(uvc_iad),
|
||||
.bDescriptorType = USB_DT_INTERFACE_ASSOCIATION,
|
||||
@ -82,12 +103,12 @@ static struct usb_interface_descriptor uvc_control_intf __initdata = {
|
||||
.iInterface = 0,
|
||||
};
|
||||
|
||||
static struct usb_endpoint_descriptor uvc_control_ep __initdata = {
|
||||
static struct usb_endpoint_descriptor uvc_fs_control_ep __initdata = {
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = USB_DIR_IN,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_INT,
|
||||
.wMaxPacketSize = cpu_to_le16(16),
|
||||
.wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
|
||||
.bInterval = 8,
|
||||
};
|
||||
|
||||
@ -95,7 +116,7 @@ static struct uvc_control_endpoint_descriptor uvc_control_cs_ep __initdata = {
|
||||
.bLength = UVC_DT_CONTROL_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_CS_ENDPOINT,
|
||||
.bDescriptorSubType = UVC_EP_INTERRUPT,
|
||||
.wMaxTransferSize = cpu_to_le16(16),
|
||||
.wMaxTransferSize = cpu_to_le16(STATUS_BYTECOUNT),
|
||||
};
|
||||
|
||||
static struct usb_interface_descriptor uvc_streaming_intf_alt0 __initdata = {
|
||||
@ -122,7 +143,7 @@ static struct usb_interface_descriptor uvc_streaming_intf_alt1 __initdata = {
|
||||
.iInterface = 0,
|
||||
};
|
||||
|
||||
static struct usb_endpoint_descriptor uvc_streaming_ep = {
|
||||
static struct usb_endpoint_descriptor uvc_fs_streaming_ep = {
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = USB_DIR_IN,
|
||||
@ -131,15 +152,72 @@ static struct usb_endpoint_descriptor uvc_streaming_ep = {
|
||||
.bInterval = 1,
|
||||
};
|
||||
|
||||
static struct usb_endpoint_descriptor uvc_hs_streaming_ep = {
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
.bEndpointAddress = USB_DIR_IN,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_ISOC,
|
||||
.wMaxPacketSize = cpu_to_le16(1024),
|
||||
.bInterval = 1,
|
||||
};
|
||||
|
||||
/* super speed support */
|
||||
static struct usb_endpoint_descriptor uvc_ss_control_ep __initdata = {
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
|
||||
.bEndpointAddress = USB_DIR_IN,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_INT,
|
||||
.wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
|
||||
.bInterval = 8,
|
||||
};
|
||||
|
||||
static struct usb_ss_ep_comp_descriptor uvc_ss_control_comp __initdata = {
|
||||
.bLength = sizeof uvc_ss_control_comp,
|
||||
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
|
||||
|
||||
/* the following 3 values can be tweaked if necessary */
|
||||
/* .bMaxBurst = 0, */
|
||||
/* .bmAttributes = 0, */
|
||||
.wBytesPerInterval = cpu_to_le16(STATUS_BYTECOUNT),
|
||||
};
|
||||
|
||||
static struct usb_endpoint_descriptor uvc_ss_streaming_ep __initdata = {
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
|
||||
.bEndpointAddress = USB_DIR_IN,
|
||||
.bmAttributes = USB_ENDPOINT_XFER_ISOC,
|
||||
.wMaxPacketSize = cpu_to_le16(1024),
|
||||
.bInterval = 4,
|
||||
};
|
||||
|
||||
static struct usb_ss_ep_comp_descriptor uvc_ss_streaming_comp = {
|
||||
.bLength = sizeof uvc_ss_streaming_comp,
|
||||
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
|
||||
|
||||
/* the following 3 values can be tweaked if necessary */
|
||||
.bMaxBurst = 0,
|
||||
.bmAttributes = 0,
|
||||
.wBytesPerInterval = cpu_to_le16(1024),
|
||||
};
|
||||
|
||||
static const struct usb_descriptor_header * const uvc_fs_streaming[] = {
|
||||
(struct usb_descriptor_header *) &uvc_streaming_intf_alt1,
|
||||
(struct usb_descriptor_header *) &uvc_streaming_ep,
|
||||
(struct usb_descriptor_header *) &uvc_fs_streaming_ep,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct usb_descriptor_header * const uvc_hs_streaming[] = {
|
||||
(struct usb_descriptor_header *) &uvc_streaming_intf_alt1,
|
||||
(struct usb_descriptor_header *) &uvc_streaming_ep,
|
||||
(struct usb_descriptor_header *) &uvc_hs_streaming_ep,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct usb_descriptor_header * const uvc_ss_streaming[] = {
|
||||
(struct usb_descriptor_header *) &uvc_streaming_intf_alt1,
|
||||
(struct usb_descriptor_header *) &uvc_ss_streaming_ep,
|
||||
(struct usb_descriptor_header *) &uvc_ss_streaming_comp,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@ -215,6 +293,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
|
||||
struct uvc_device *uvc = to_uvc(f);
|
||||
struct v4l2_event v4l2_event;
|
||||
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
|
||||
int ret;
|
||||
|
||||
INFO(f->config->cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt);
|
||||
|
||||
@ -262,7 +341,10 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
|
||||
return 0;
|
||||
|
||||
if (uvc->video.ep) {
|
||||
uvc->video.ep->desc = &uvc_streaming_ep;
|
||||
ret = config_ep_by_speed(f->config->cdev->gadget,
|
||||
&(uvc->func), uvc->video.ep);
|
||||
if (ret)
|
||||
return ret;
|
||||
usb_ep_enable(uvc->video.ep);
|
||||
}
|
||||
|
||||
@ -368,9 +450,11 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
|
||||
{
|
||||
struct uvc_input_header_descriptor *uvc_streaming_header;
|
||||
struct uvc_header_descriptor *uvc_control_header;
|
||||
const struct uvc_descriptor_header * const *uvc_control_desc;
|
||||
const struct uvc_descriptor_header * const *uvc_streaming_cls;
|
||||
const struct usb_descriptor_header * const *uvc_streaming_std;
|
||||
const struct usb_descriptor_header * const *src;
|
||||
static struct usb_endpoint_descriptor *uvc_control_ep;
|
||||
struct usb_descriptor_header **dst;
|
||||
struct usb_descriptor_header **hdr;
|
||||
unsigned int control_size;
|
||||
@ -379,10 +463,29 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
|
||||
unsigned int bytes;
|
||||
void *mem;
|
||||
|
||||
uvc_streaming_cls = (speed == USB_SPEED_FULL)
|
||||
? uvc->desc.fs_streaming : uvc->desc.hs_streaming;
|
||||
uvc_streaming_std = (speed == USB_SPEED_FULL)
|
||||
? uvc_fs_streaming : uvc_hs_streaming;
|
||||
switch (speed) {
|
||||
case USB_SPEED_SUPER:
|
||||
uvc_control_desc = uvc->desc.ss_control;
|
||||
uvc_streaming_cls = uvc->desc.ss_streaming;
|
||||
uvc_streaming_std = uvc_ss_streaming;
|
||||
uvc_control_ep = &uvc_ss_control_ep;
|
||||
break;
|
||||
|
||||
case USB_SPEED_HIGH:
|
||||
uvc_control_desc = uvc->desc.fs_control;
|
||||
uvc_streaming_cls = uvc->desc.hs_streaming;
|
||||
uvc_streaming_std = uvc_hs_streaming;
|
||||
uvc_control_ep = &uvc_fs_control_ep;
|
||||
break;
|
||||
|
||||
case USB_SPEED_FULL:
|
||||
default:
|
||||
uvc_control_desc = uvc->desc.fs_control;
|
||||
uvc_streaming_cls = uvc->desc.fs_streaming;
|
||||
uvc_streaming_std = uvc_fs_streaming;
|
||||
uvc_control_ep = &uvc_fs_control_ep;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Descriptors layout
|
||||
*
|
||||
@ -400,16 +503,24 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
|
||||
control_size = 0;
|
||||
streaming_size = 0;
|
||||
bytes = uvc_iad.bLength + uvc_control_intf.bLength
|
||||
+ uvc_control_ep.bLength + uvc_control_cs_ep.bLength
|
||||
+ uvc_control_ep->bLength + uvc_control_cs_ep.bLength
|
||||
+ uvc_streaming_intf_alt0.bLength;
|
||||
n_desc = 5;
|
||||
|
||||
for (src = (const struct usb_descriptor_header**)uvc->desc.control; *src; ++src) {
|
||||
if (speed == USB_SPEED_SUPER) {
|
||||
bytes += uvc_ss_control_comp.bLength;
|
||||
n_desc = 6;
|
||||
} else {
|
||||
n_desc = 5;
|
||||
}
|
||||
|
||||
for (src = (const struct usb_descriptor_header **)uvc_control_desc;
|
||||
*src; ++src) {
|
||||
control_size += (*src)->bLength;
|
||||
bytes += (*src)->bLength;
|
||||
n_desc++;
|
||||
}
|
||||
for (src = (const struct usb_descriptor_header**)uvc_streaming_cls; *src; ++src) {
|
||||
for (src = (const struct usb_descriptor_header **)uvc_streaming_cls;
|
||||
*src; ++src) {
|
||||
streaming_size += (*src)->bLength;
|
||||
bytes += (*src)->bLength;
|
||||
n_desc++;
|
||||
@ -433,12 +544,15 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
|
||||
|
||||
uvc_control_header = mem;
|
||||
UVC_COPY_DESCRIPTORS(mem, dst,
|
||||
(const struct usb_descriptor_header**)uvc->desc.control);
|
||||
(const struct usb_descriptor_header **)uvc_control_desc);
|
||||
uvc_control_header->wTotalLength = cpu_to_le16(control_size);
|
||||
uvc_control_header->bInCollection = 1;
|
||||
uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf;
|
||||
|
||||
UVC_COPY_DESCRIPTOR(mem, dst, &uvc_control_ep);
|
||||
UVC_COPY_DESCRIPTOR(mem, dst, uvc_control_ep);
|
||||
if (speed == USB_SPEED_SUPER)
|
||||
UVC_COPY_DESCRIPTOR(mem, dst, &uvc_ss_control_comp);
|
||||
|
||||
UVC_COPY_DESCRIPTOR(mem, dst, &uvc_control_cs_ep);
|
||||
UVC_COPY_DESCRIPTOR(mem, dst, &uvc_streaming_intf_alt0);
|
||||
|
||||
@ -446,7 +560,8 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
|
||||
UVC_COPY_DESCRIPTORS(mem, dst,
|
||||
(const struct usb_descriptor_header**)uvc_streaming_cls);
|
||||
uvc_streaming_header->wTotalLength = cpu_to_le16(streaming_size);
|
||||
uvc_streaming_header->bEndpointAddress = uvc_streaming_ep.bEndpointAddress;
|
||||
uvc_streaming_header->bEndpointAddress =
|
||||
uvc_fs_streaming_ep.bEndpointAddress;
|
||||
|
||||
UVC_COPY_DESCRIPTORS(mem, dst, uvc_streaming_std);
|
||||
|
||||
@ -482,6 +597,7 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
|
||||
|
||||
kfree(f->descriptors);
|
||||
kfree(f->hs_descriptors);
|
||||
kfree(f->ss_descriptors);
|
||||
|
||||
kfree(uvc);
|
||||
}
|
||||
@ -496,8 +612,26 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
|
||||
INFO(cdev, "uvc_function_bind\n");
|
||||
|
||||
/* sanity check the streaming endpoint module parameters */
|
||||
if (streaming_interval < 1)
|
||||
streaming_interval = 1;
|
||||
if (streaming_interval > 16)
|
||||
streaming_interval = 16;
|
||||
if (streaming_mult > 2)
|
||||
streaming_mult = 2;
|
||||
if (streaming_maxburst > 15)
|
||||
streaming_maxburst = 15;
|
||||
|
||||
/*
|
||||
* fill in the FS video streaming specific descriptors from the
|
||||
* module parameters
|
||||
*/
|
||||
uvc_fs_streaming_ep.wMaxPacketSize = streaming_maxpacket > 1023 ?
|
||||
1023 : streaming_maxpacket;
|
||||
uvc_fs_streaming_ep.bInterval = streaming_interval;
|
||||
|
||||
/* Allocate endpoints. */
|
||||
ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
|
||||
ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_control_ep);
|
||||
if (!ep) {
|
||||
INFO(cdev, "Unable to allocate control EP\n");
|
||||
goto error;
|
||||
@ -505,7 +639,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
uvc->control_ep = ep;
|
||||
ep->driver_data = uvc;
|
||||
|
||||
ep = usb_ep_autoconfig(cdev->gadget, &uvc_streaming_ep);
|
||||
ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep);
|
||||
if (!ep) {
|
||||
INFO(cdev, "Unable to allocate streaming EP\n");
|
||||
goto error;
|
||||
@ -526,9 +660,52 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
uvc_streaming_intf_alt1.bInterfaceNumber = ret;
|
||||
uvc->streaming_intf = ret;
|
||||
|
||||
/* Copy descriptors. */
|
||||
/* sanity check the streaming endpoint module parameters */
|
||||
if (streaming_maxpacket > 1024)
|
||||
streaming_maxpacket = 1024;
|
||||
|
||||
/* Copy descriptors for FS. */
|
||||
f->descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL);
|
||||
f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH);
|
||||
|
||||
/* support high speed hardware */
|
||||
if (gadget_is_dualspeed(cdev->gadget)) {
|
||||
/*
|
||||
* Fill in the HS descriptors from the module parameters for the
|
||||
* Video Streaming endpoint.
|
||||
* NOTE: We assume that the user knows what they are doing and
|
||||
* won't give parameters that their UDC doesn't support.
|
||||
*/
|
||||
uvc_hs_streaming_ep.wMaxPacketSize = streaming_maxpacket;
|
||||
uvc_hs_streaming_ep.wMaxPacketSize |= streaming_mult << 11;
|
||||
uvc_hs_streaming_ep.bInterval = streaming_interval;
|
||||
uvc_hs_streaming_ep.bEndpointAddress =
|
||||
uvc_fs_streaming_ep.bEndpointAddress;
|
||||
|
||||
/* Copy descriptors. */
|
||||
f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH);
|
||||
}
|
||||
|
||||
/* support super speed hardware */
|
||||
if (gadget_is_superspeed(c->cdev->gadget)) {
|
||||
/*
|
||||
* Fill in the SS descriptors from the module parameters for the
|
||||
* Video Streaming endpoint.
|
||||
* NOTE: We assume that the user knows what they are doing and
|
||||
* won't give parameters that their UDC doesn't support.
|
||||
*/
|
||||
uvc_ss_streaming_ep.wMaxPacketSize = streaming_maxpacket;
|
||||
uvc_ss_streaming_ep.bInterval = streaming_interval;
|
||||
uvc_ss_streaming_comp.bmAttributes = streaming_mult;
|
||||
uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst;
|
||||
uvc_ss_streaming_comp.wBytesPerInterval =
|
||||
streaming_maxpacket * (streaming_mult + 1) *
|
||||
(streaming_maxburst + 1);
|
||||
uvc_ss_streaming_ep.bEndpointAddress =
|
||||
uvc_fs_streaming_ep.bEndpointAddress;
|
||||
|
||||
/* Copy descriptors. */
|
||||
f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER);
|
||||
}
|
||||
|
||||
/* Preallocate control endpoint request. */
|
||||
uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
|
||||
@ -583,9 +760,11 @@ error:
|
||||
*/
|
||||
int __init
|
||||
uvc_bind_config(struct usb_configuration *c,
|
||||
const struct uvc_descriptor_header * const *control,
|
||||
const struct uvc_descriptor_header * const *fs_control,
|
||||
const struct uvc_descriptor_header * const *ss_control,
|
||||
const struct uvc_descriptor_header * const *fs_streaming,
|
||||
const struct uvc_descriptor_header * const *hs_streaming)
|
||||
const struct uvc_descriptor_header * const *hs_streaming,
|
||||
const struct uvc_descriptor_header * const *ss_streaming)
|
||||
{
|
||||
struct uvc_device *uvc;
|
||||
int ret = 0;
|
||||
@ -603,38 +782,54 @@ uvc_bind_config(struct usb_configuration *c,
|
||||
uvc->state = UVC_STATE_DISCONNECTED;
|
||||
|
||||
/* Validate the descriptors. */
|
||||
if (control == NULL || control[0] == NULL ||
|
||||
control[0]->bDescriptorSubType != UVC_VC_HEADER)
|
||||
if (fs_control == NULL || fs_control[0] == NULL ||
|
||||
fs_control[0]->bDescriptorSubType != UVC_VC_HEADER)
|
||||
goto error;
|
||||
|
||||
if (ss_control == NULL || ss_control[0] == NULL ||
|
||||
ss_control[0]->bDescriptorSubType != UVC_VC_HEADER)
|
||||
goto error;
|
||||
|
||||
if (fs_streaming == NULL || fs_streaming[0] == NULL ||
|
||||
fs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
|
||||
fs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
|
||||
goto error;
|
||||
|
||||
if (hs_streaming == NULL || hs_streaming[0] == NULL ||
|
||||
hs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
|
||||
hs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
|
||||
goto error;
|
||||
|
||||
uvc->desc.control = control;
|
||||
if (ss_streaming == NULL || ss_streaming[0] == NULL ||
|
||||
ss_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
|
||||
goto error;
|
||||
|
||||
uvc->desc.fs_control = fs_control;
|
||||
uvc->desc.ss_control = ss_control;
|
||||
uvc->desc.fs_streaming = fs_streaming;
|
||||
uvc->desc.hs_streaming = hs_streaming;
|
||||
uvc->desc.ss_streaming = ss_streaming;
|
||||
|
||||
/* Allocate string descriptor numbers. */
|
||||
if ((ret = usb_string_id(c->cdev)) < 0)
|
||||
goto error;
|
||||
uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = ret;
|
||||
uvc_iad.iFunction = ret;
|
||||
/* maybe allocate device-global string IDs, and patch descriptors */
|
||||
if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) {
|
||||
/* Allocate string descriptor numbers. */
|
||||
ret = usb_string_id(c->cdev);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = ret;
|
||||
uvc_iad.iFunction = ret;
|
||||
|
||||
if ((ret = usb_string_id(c->cdev)) < 0)
|
||||
goto error;
|
||||
uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = ret;
|
||||
uvc_control_intf.iInterface = ret;
|
||||
ret = usb_string_id(c->cdev);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = ret;
|
||||
uvc_control_intf.iInterface = ret;
|
||||
|
||||
if ((ret = usb_string_id(c->cdev)) < 0)
|
||||
goto error;
|
||||
uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id = ret;
|
||||
uvc_streaming_intf_alt0.iInterface = ret;
|
||||
uvc_streaming_intf_alt1.iInterface = ret;
|
||||
ret = usb_string_id(c->cdev);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id = ret;
|
||||
uvc_streaming_intf_alt0.iInterface = ret;
|
||||
uvc_streaming_intf_alt1.iInterface = ret;
|
||||
}
|
||||
|
||||
/* Register the function. */
|
||||
uvc->func.name = "uvc";
|
||||
|
@ -17,9 +17,11 @@
|
||||
#include <linux/usb/video.h>
|
||||
|
||||
extern int uvc_bind_config(struct usb_configuration *c,
|
||||
const struct uvc_descriptor_header * const *control,
|
||||
const struct uvc_descriptor_header * const *fs_streaming,
|
||||
const struct uvc_descriptor_header * const *hs_streaming);
|
||||
const struct uvc_descriptor_header * const *fs_control,
|
||||
const struct uvc_descriptor_header * const *hs_control,
|
||||
const struct uvc_descriptor_header * const *fs_streaming,
|
||||
const struct uvc_descriptor_header * const *hs_streaming,
|
||||
const struct uvc_descriptor_header * const *ss_streaming);
|
||||
|
||||
#endif /* _F_UVC_H_ */
|
||||
|
||||
|
@ -21,7 +21,8 @@
|
||||
#include <mach/hardware.h>
|
||||
|
||||
static struct clk *mxc_ahb_clk;
|
||||
static struct clk *mxc_usb_clk;
|
||||
static struct clk *mxc_per_clk;
|
||||
static struct clk *mxc_ipg_clk;
|
||||
|
||||
/* workaround ENGcm09152 for i.MX35 */
|
||||
#define USBPHYCTRL_OTGBASE_OFFSET 0x608
|
||||
@ -35,28 +36,31 @@ int fsl_udc_clk_init(struct platform_device *pdev)
|
||||
|
||||
pdata = pdev->dev.platform_data;
|
||||
|
||||
if (!cpu_is_mx35() && !cpu_is_mx25()) {
|
||||
mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb");
|
||||
if (IS_ERR(mxc_ahb_clk))
|
||||
return PTR_ERR(mxc_ahb_clk);
|
||||
|
||||
ret = clk_enable(mxc_ahb_clk);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n");
|
||||
goto eenahb;
|
||||
}
|
||||
mxc_ipg_clk = devm_clk_get(&pdev->dev, "ipg");
|
||||
if (IS_ERR(mxc_ipg_clk)) {
|
||||
dev_err(&pdev->dev, "clk_get(\"ipg\") failed\n");
|
||||
return PTR_ERR(mxc_ipg_clk);
|
||||
}
|
||||
|
||||
mxc_ahb_clk = devm_clk_get(&pdev->dev, "ahb");
|
||||
if (IS_ERR(mxc_ahb_clk)) {
|
||||
dev_err(&pdev->dev, "clk_get(\"ahb\") failed\n");
|
||||
return PTR_ERR(mxc_ahb_clk);
|
||||
}
|
||||
|
||||
mxc_per_clk = devm_clk_get(&pdev->dev, "per");
|
||||
if (IS_ERR(mxc_per_clk)) {
|
||||
dev_err(&pdev->dev, "clk_get(\"per\") failed\n");
|
||||
return PTR_ERR(mxc_per_clk);
|
||||
}
|
||||
|
||||
clk_prepare_enable(mxc_ipg_clk);
|
||||
clk_prepare_enable(mxc_ahb_clk);
|
||||
clk_prepare_enable(mxc_per_clk);
|
||||
|
||||
/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */
|
||||
mxc_usb_clk = clk_get(&pdev->dev, "usb");
|
||||
if (IS_ERR(mxc_usb_clk)) {
|
||||
dev_err(&pdev->dev, "clk_get(\"usb\") failed\n");
|
||||
ret = PTR_ERR(mxc_usb_clk);
|
||||
goto egusb;
|
||||
}
|
||||
|
||||
if (!cpu_is_mx51()) {
|
||||
freq = clk_get_rate(mxc_usb_clk);
|
||||
freq = clk_get_rate(mxc_per_clk);
|
||||
if (pdata->phy_mode != FSL_USB2_PHY_ULPI &&
|
||||
(freq < 59999000 || freq > 60001000)) {
|
||||
dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq);
|
||||
@ -65,24 +69,13 @@ int fsl_udc_clk_init(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
ret = clk_enable(mxc_usb_clk);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "clk_enable(\"usb_clk\") failed\n");
|
||||
goto eenusb;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
eenusb:
|
||||
eclkrate:
|
||||
clk_put(mxc_usb_clk);
|
||||
mxc_usb_clk = NULL;
|
||||
egusb:
|
||||
if (!cpu_is_mx35())
|
||||
clk_disable(mxc_ahb_clk);
|
||||
eenahb:
|
||||
if (!cpu_is_mx35())
|
||||
clk_put(mxc_ahb_clk);
|
||||
clk_disable_unprepare(mxc_ipg_clk);
|
||||
clk_disable_unprepare(mxc_ahb_clk);
|
||||
clk_disable_unprepare(mxc_per_clk);
|
||||
mxc_per_clk = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -104,20 +97,15 @@ void fsl_udc_clk_finalize(struct platform_device *pdev)
|
||||
|
||||
/* ULPI transceivers don't need usbpll */
|
||||
if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
|
||||
clk_disable(mxc_usb_clk);
|
||||
clk_put(mxc_usb_clk);
|
||||
mxc_usb_clk = NULL;
|
||||
clk_disable_unprepare(mxc_per_clk);
|
||||
mxc_per_clk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void fsl_udc_clk_release(void)
|
||||
{
|
||||
if (mxc_usb_clk) {
|
||||
clk_disable(mxc_usb_clk);
|
||||
clk_put(mxc_usb_clk);
|
||||
}
|
||||
if (!cpu_is_mx35()) {
|
||||
clk_disable(mxc_ahb_clk);
|
||||
clk_put(mxc_ahb_clk);
|
||||
}
|
||||
if (mxc_per_clk)
|
||||
clk_disable_unprepare(mxc_per_clk);
|
||||
clk_disable_unprepare(mxc_ahb_clk);
|
||||
clk_disable_unprepare(mxc_ipg_clk);
|
||||
}
|
||||
|
@ -2560,6 +2560,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
|
||||
dev_set_name(&udc_controller->gadget.dev, "gadget");
|
||||
udc_controller->gadget.dev.release = fsl_udc_release;
|
||||
udc_controller->gadget.dev.parent = &pdev->dev;
|
||||
udc_controller->gadget.dev.of_node = pdev->dev.of_node;
|
||||
ret = device_register(&udc_controller->gadget.dev);
|
||||
if (ret < 0)
|
||||
goto err_free_irq;
|
||||
|
@ -1432,7 +1432,7 @@ static int __init imx_udc_probe(struct platform_device *pdev)
|
||||
dev_err(&pdev->dev, "can't get USB clock\n");
|
||||
goto fail2;
|
||||
}
|
||||
clk_enable(clk);
|
||||
clk_prepare_enable(clk);
|
||||
|
||||
if (clk_get_rate(clk) != 48000000) {
|
||||
D_INI(&pdev->dev,
|
||||
@ -1496,7 +1496,7 @@ fail4:
|
||||
free_irq(imx_usb->usbd_int[i], imx_usb);
|
||||
fail3:
|
||||
clk_put(clk);
|
||||
clk_disable(clk);
|
||||
clk_disable_unprepare(clk);
|
||||
fail2:
|
||||
iounmap(base);
|
||||
fail1:
|
||||
@ -1521,7 +1521,7 @@ static int __exit imx_udc_remove(struct platform_device *pdev)
|
||||
free_irq(imx_usb->usbd_int[i], imx_usb);
|
||||
|
||||
clk_put(imx_usb->clk);
|
||||
clk_disable(imx_usb->clk);
|
||||
clk_disable_unprepare(imx_usb->clk);
|
||||
iounmap(imx_usb->base);
|
||||
|
||||
release_mem_region(imx_usb->res->start, resource_size(imx_usb->res));
|
||||
|
@ -165,6 +165,7 @@ struct lpc32xx_udc {
|
||||
int udp_irq[4];
|
||||
struct clk *usb_pll_clk;
|
||||
struct clk *usb_slv_clk;
|
||||
struct clk *usb_otg_clk;
|
||||
|
||||
/* DMA support */
|
||||
u32 *udca_v_base;
|
||||
@ -227,33 +228,15 @@ static inline struct lpc32xx_udc *to_udc(struct usb_gadget *g)
|
||||
#define UDCA_BUFF_SIZE (128)
|
||||
|
||||
/* TODO: When the clock framework is introduced in LPC32xx, IO_ADDRESS will
|
||||
* be replaced with an inremap()ed pointer, see USB_OTG_CLK_CTRL()
|
||||
* be replaced with an inremap()ed pointer
|
||||
* */
|
||||
#define USB_CTRL IO_ADDRESS(LPC32XX_CLK_PM_BASE + 0x64)
|
||||
#define USB_CLOCK_MASK (AHB_M_CLOCK_ON | OTG_CLOCK_ON | \
|
||||
DEV_CLOCK_ON | I2C_CLOCK_ON)
|
||||
|
||||
/* USB_CTRL bit defines */
|
||||
#define USB_SLAVE_HCLK_EN (1 << 24)
|
||||
#define USB_HOST_NEED_CLK_EN (1 << 21)
|
||||
#define USB_DEV_NEED_CLK_EN (1 << 22)
|
||||
|
||||
#define USB_OTG_CLK_CTRL(udc) ((udc)->udp_baseaddr + 0xFF4)
|
||||
#define USB_OTG_CLK_STAT(udc) ((udc)->udp_baseaddr + 0xFF8)
|
||||
|
||||
/* USB_OTG_CLK_CTRL bit defines */
|
||||
#define AHB_M_CLOCK_ON (1 << 4)
|
||||
#define OTG_CLOCK_ON (1 << 3)
|
||||
#define I2C_CLOCK_ON (1 << 2)
|
||||
#define DEV_CLOCK_ON (1 << 1)
|
||||
#define HOST_CLOCK_ON (1 << 0)
|
||||
|
||||
#define USB_OTG_STAT_CONTROL(udc) (udc->udp_baseaddr + 0x110)
|
||||
|
||||
/* USB_OTG_STAT_CONTROL bit defines */
|
||||
#define TRANSPARENT_I2C_EN (1 << 7)
|
||||
#define HOST_EN (1 << 0)
|
||||
|
||||
/**********************************************************************
|
||||
* USB device controller register offsets
|
||||
**********************************************************************/
|
||||
@ -677,7 +660,7 @@ static void isp1301_udc_configure(struct lpc32xx_udc *udc)
|
||||
ISP1301_I2C_INTERRUPT_RISING, INT_VBUS_VLD);
|
||||
|
||||
/* Enable usb_need_clk clock after transceiver is initialized */
|
||||
writel((readl(USB_CTRL) | (1 << 22)), USB_CTRL);
|
||||
writel((readl(USB_CTRL) | USB_DEV_NEED_CLK_EN), USB_CTRL);
|
||||
|
||||
dev_info(udc->dev, "ISP1301 Vendor ID : 0x%04x\n",
|
||||
i2c_smbus_read_word_data(udc->isp1301_i2c_client, 0x00));
|
||||
@ -1010,11 +993,8 @@ static void udc_dd_free(struct lpc32xx_udc *udc, struct lpc32xx_usbd_dd_gad *dd)
|
||||
/* Enables or disables most of the USB system clocks when low power mode is
|
||||
* needed. Clocks are typically started on a connection event, and disabled
|
||||
* when a cable is disconnected */
|
||||
#define OTGOFF_CLK_MASK (AHB_M_CLOCK_ON | I2C_CLOCK_ON)
|
||||
static void udc_clk_set(struct lpc32xx_udc *udc, int enable)
|
||||
{
|
||||
int to = 1000;
|
||||
|
||||
if (enable != 0) {
|
||||
if (udc->clocked)
|
||||
return;
|
||||
@ -1028,14 +1008,7 @@ static void udc_clk_set(struct lpc32xx_udc *udc, int enable)
|
||||
writel(readl(USB_CTRL) | USB_DEV_NEED_CLK_EN,
|
||||
USB_CTRL);
|
||||
|
||||
/* Set to enable all needed USB OTG clocks */
|
||||
writel(USB_CLOCK_MASK, USB_OTG_CLK_CTRL(udc));
|
||||
|
||||
while (((readl(USB_OTG_CLK_STAT(udc)) & USB_CLOCK_MASK) !=
|
||||
USB_CLOCK_MASK) && (to > 0))
|
||||
to--;
|
||||
if (!to)
|
||||
dev_dbg(udc->dev, "Cannot enable USB OTG clocking\n");
|
||||
clk_enable(udc->usb_otg_clk);
|
||||
} else {
|
||||
if (!udc->clocked)
|
||||
return;
|
||||
@ -1047,19 +1020,11 @@ static void udc_clk_set(struct lpc32xx_udc *udc, int enable)
|
||||
/* 48MHz PLL dpwn */
|
||||
clk_disable(udc->usb_pll_clk);
|
||||
|
||||
/* Enable the USB device clock */
|
||||
/* Disable the USB device clock */
|
||||
writel(readl(USB_CTRL) & ~USB_DEV_NEED_CLK_EN,
|
||||
USB_CTRL);
|
||||
|
||||
/* Set to enable all needed USB OTG clocks */
|
||||
writel(OTGOFF_CLK_MASK, USB_OTG_CLK_CTRL(udc));
|
||||
|
||||
while (((readl(USB_OTG_CLK_STAT(udc)) &
|
||||
OTGOFF_CLK_MASK) !=
|
||||
OTGOFF_CLK_MASK) && (to > 0))
|
||||
to--;
|
||||
if (!to)
|
||||
dev_dbg(udc->dev, "Cannot disable USB OTG clocking\n");
|
||||
clk_disable(udc->usb_otg_clk);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3041,6 +3006,7 @@ static int lpc32xx_start(struct usb_gadget_driver *driver,
|
||||
|
||||
udc->driver = driver;
|
||||
udc->gadget.dev.driver = &driver->driver;
|
||||
udc->gadget.dev.of_node = udc->dev->of_node;
|
||||
udc->enabled = 1;
|
||||
udc->selfpowered = 1;
|
||||
udc->vbus = 0;
|
||||
@ -3239,6 +3205,12 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev)
|
||||
retval = PTR_ERR(udc->usb_slv_clk);
|
||||
goto usb_clk_get_fail;
|
||||
}
|
||||
udc->usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg");
|
||||
if (IS_ERR(udc->usb_otg_clk)) {
|
||||
dev_err(udc->dev, "failed to acquire USB otg clock\n");
|
||||
retval = PTR_ERR(udc->usb_slv_clk);
|
||||
goto usb_otg_clk_get_fail;
|
||||
}
|
||||
|
||||
/* Setup PLL clock to 48MHz */
|
||||
retval = clk_enable(udc->usb_pll_clk);
|
||||
@ -3262,15 +3234,12 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev)
|
||||
goto usb_clk_enable_fail;
|
||||
}
|
||||
|
||||
/* Set to enable all needed USB OTG clocks */
|
||||
writel(USB_CLOCK_MASK, USB_OTG_CLK_CTRL(udc));
|
||||
|
||||
i = 1000;
|
||||
while (((readl(USB_OTG_CLK_STAT(udc)) & USB_CLOCK_MASK) !=
|
||||
USB_CLOCK_MASK) && (i > 0))
|
||||
i--;
|
||||
if (!i)
|
||||
dev_dbg(udc->dev, "USB OTG clocks not correctly enabled\n");
|
||||
/* Enable USB OTG clock */
|
||||
retval = clk_enable(udc->usb_otg_clk);
|
||||
if (retval < 0) {
|
||||
dev_err(udc->dev, "failed to start USB otg clock\n");
|
||||
goto usb_otg_clk_enable_fail;
|
||||
}
|
||||
|
||||
/* Setup deferred workqueue data */
|
||||
udc->poweron = udc->pullup = 0;
|
||||
@ -3390,12 +3359,16 @@ dma_alloc_fail:
|
||||
dma_free_coherent(&pdev->dev, UDCA_BUFF_SIZE,
|
||||
udc->udca_v_base, udc->udca_p_base);
|
||||
i2c_fail:
|
||||
clk_disable(udc->usb_otg_clk);
|
||||
usb_otg_clk_enable_fail:
|
||||
clk_disable(udc->usb_slv_clk);
|
||||
usb_clk_enable_fail:
|
||||
pll_set_fail:
|
||||
clk_disable(udc->usb_pll_clk);
|
||||
pll_enable_fail:
|
||||
clk_put(udc->usb_slv_clk);
|
||||
usb_otg_clk_get_fail:
|
||||
clk_put(udc->usb_otg_clk);
|
||||
usb_clk_get_fail:
|
||||
clk_put(udc->usb_pll_clk);
|
||||
pll_get_fail:
|
||||
@ -3433,6 +3406,8 @@ static int __devexit lpc32xx_udc_remove(struct platform_device *pdev)
|
||||
|
||||
device_unregister(&udc->gadget.dev);
|
||||
|
||||
clk_disable(udc->usb_otg_clk);
|
||||
clk_put(udc->usb_otg_clk);
|
||||
clk_disable(udc->usb_slv_clk);
|
||||
clk_put(udc->usb_slv_clk);
|
||||
clk_disable(udc->usb_pll_clk);
|
||||
@ -3446,7 +3421,6 @@ static int __devexit lpc32xx_udc_remove(struct platform_device *pdev)
|
||||
#ifdef CONFIG_PM
|
||||
static int lpc32xx_udc_suspend(struct platform_device *pdev, pm_message_t mesg)
|
||||
{
|
||||
int to = 1000;
|
||||
struct lpc32xx_udc *udc = platform_get_drvdata(pdev);
|
||||
|
||||
if (udc->clocked) {
|
||||
@ -3461,15 +3435,6 @@ static int lpc32xx_udc_suspend(struct platform_device *pdev, pm_message_t mesg)
|
||||
on resume */
|
||||
udc->clocked = 1;
|
||||
|
||||
/* Kill OTG and I2C clocks */
|
||||
writel(0, USB_OTG_CLK_CTRL(udc));
|
||||
while (((readl(USB_OTG_CLK_STAT(udc)) & OTGOFF_CLK_MASK) !=
|
||||
OTGOFF_CLK_MASK) && (to > 0))
|
||||
to--;
|
||||
if (!to)
|
||||
dev_dbg(udc->dev,
|
||||
"USB OTG clocks not correctly enabled\n");
|
||||
|
||||
/* Kill global USB clock */
|
||||
clk_disable(udc->usb_slv_clk);
|
||||
}
|
||||
|
320
drivers/usb/gadget/mv_u3d.h
Normal file
320
drivers/usb/gadget/mv_u3d.h
Normal file
@ -0,0 +1,320 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Marvell International Ltd. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef __MV_U3D_H
|
||||
#define __MV_U3D_H
|
||||
|
||||
#define MV_U3D_EP_CONTEXT_ALIGNMENT 32
|
||||
#define MV_U3D_TRB_ALIGNMENT 16
|
||||
#define MV_U3D_DMA_BOUNDARY 4096
|
||||
#define MV_U3D_EP0_MAX_PKT_SIZE 512
|
||||
|
||||
/* ep0 transfer state */
|
||||
#define MV_U3D_WAIT_FOR_SETUP 0
|
||||
#define MV_U3D_DATA_STATE_XMIT 1
|
||||
#define MV_U3D_DATA_STATE_NEED_ZLP 2
|
||||
#define MV_U3D_WAIT_FOR_OUT_STATUS 3
|
||||
#define MV_U3D_DATA_STATE_RECV 4
|
||||
#define MV_U3D_STATUS_STAGE 5
|
||||
|
||||
#define MV_U3D_EP_MAX_LENGTH_TRANSFER 0x10000
|
||||
|
||||
/* USB3 Interrupt Status */
|
||||
#define MV_U3D_USBINT_SETUP 0x00000001
|
||||
#define MV_U3D_USBINT_RX_COMPLETE 0x00000002
|
||||
#define MV_U3D_USBINT_TX_COMPLETE 0x00000004
|
||||
#define MV_U3D_USBINT_UNDER_RUN 0x00000008
|
||||
#define MV_U3D_USBINT_RXDESC_ERR 0x00000010
|
||||
#define MV_U3D_USBINT_TXDESC_ERR 0x00000020
|
||||
#define MV_U3D_USBINT_RX_TRB_COMPLETE 0x00000040
|
||||
#define MV_U3D_USBINT_TX_TRB_COMPLETE 0x00000080
|
||||
#define MV_U3D_USBINT_VBUS_VALID 0x00010000
|
||||
#define MV_U3D_USBINT_STORAGE_CMD_FULL 0x00020000
|
||||
#define MV_U3D_USBINT_LINK_CHG 0x01000000
|
||||
|
||||
/* USB3 Interrupt Enable */
|
||||
#define MV_U3D_INTR_ENABLE_SETUP 0x00000001
|
||||
#define MV_U3D_INTR_ENABLE_RX_COMPLETE 0x00000002
|
||||
#define MV_U3D_INTR_ENABLE_TX_COMPLETE 0x00000004
|
||||
#define MV_U3D_INTR_ENABLE_UNDER_RUN 0x00000008
|
||||
#define MV_U3D_INTR_ENABLE_RXDESC_ERR 0x00000010
|
||||
#define MV_U3D_INTR_ENABLE_TXDESC_ERR 0x00000020
|
||||
#define MV_U3D_INTR_ENABLE_RX_TRB_COMPLETE 0x00000040
|
||||
#define MV_U3D_INTR_ENABLE_TX_TRB_COMPLETE 0x00000080
|
||||
#define MV_U3D_INTR_ENABLE_RX_BUFFER_ERR 0x00000100
|
||||
#define MV_U3D_INTR_ENABLE_VBUS_VALID 0x00010000
|
||||
#define MV_U3D_INTR_ENABLE_STORAGE_CMD_FULL 0x00020000
|
||||
#define MV_U3D_INTR_ENABLE_LINK_CHG 0x01000000
|
||||
#define MV_U3D_INTR_ENABLE_PRIME_STATUS 0x02000000
|
||||
|
||||
/* USB3 Link Change */
|
||||
#define MV_U3D_LINK_CHANGE_LINK_UP 0x00000001
|
||||
#define MV_U3D_LINK_CHANGE_SUSPEND 0x00000002
|
||||
#define MV_U3D_LINK_CHANGE_RESUME 0x00000004
|
||||
#define MV_U3D_LINK_CHANGE_WRESET 0x00000008
|
||||
#define MV_U3D_LINK_CHANGE_HRESET 0x00000010
|
||||
#define MV_U3D_LINK_CHANGE_VBUS_INVALID 0x00000020
|
||||
#define MV_U3D_LINK_CHANGE_INACT 0x00000040
|
||||
#define MV_U3D_LINK_CHANGE_DISABLE_AFTER_U0 0x00000080
|
||||
#define MV_U3D_LINK_CHANGE_U1 0x00000100
|
||||
#define MV_U3D_LINK_CHANGE_U2 0x00000200
|
||||
#define MV_U3D_LINK_CHANGE_U3 0x00000400
|
||||
|
||||
/* bridge setting */
|
||||
#define MV_U3D_BRIDGE_SETTING_VBUS_VALID (1 << 16)
|
||||
|
||||
/* Command Register Bit Masks */
|
||||
#define MV_U3D_CMD_RUN_STOP 0x00000001
|
||||
#define MV_U3D_CMD_CTRL_RESET 0x00000002
|
||||
|
||||
/* ep control register */
|
||||
#define MV_U3D_EPXCR_EP_TYPE_CONTROL 0
|
||||
#define MV_U3D_EPXCR_EP_TYPE_ISOC 1
|
||||
#define MV_U3D_EPXCR_EP_TYPE_BULK 2
|
||||
#define MV_U3D_EPXCR_EP_TYPE_INT 3
|
||||
#define MV_U3D_EPXCR_EP_ENABLE_SHIFT 4
|
||||
#define MV_U3D_EPXCR_MAX_BURST_SIZE_SHIFT 12
|
||||
#define MV_U3D_EPXCR_MAX_PACKET_SIZE_SHIFT 16
|
||||
#define MV_U3D_USB_BULK_BURST_OUT 6
|
||||
#define MV_U3D_USB_BULK_BURST_IN 14
|
||||
|
||||
#define MV_U3D_EPXCR_EP_FLUSH (1 << 7)
|
||||
#define MV_U3D_EPXCR_EP_HALT (1 << 1)
|
||||
#define MV_U3D_EPXCR_EP_INIT (1)
|
||||
|
||||
/* TX/RX Status Register */
|
||||
#define MV_U3D_XFERSTATUS_COMPLETE_SHIFT 24
|
||||
#define MV_U3D_COMPLETE_INVALID 0
|
||||
#define MV_U3D_COMPLETE_SUCCESS 1
|
||||
#define MV_U3D_COMPLETE_BUFF_ERR 2
|
||||
#define MV_U3D_COMPLETE_SHORT_PACKET 3
|
||||
#define MV_U3D_COMPLETE_TRB_ERR 5
|
||||
#define MV_U3D_XFERSTATUS_TRB_LENGTH_MASK (0xFFFFFF)
|
||||
|
||||
#define MV_U3D_USB_LINK_BYPASS_VBUS 0x8
|
||||
|
||||
#define MV_U3D_LTSSM_PHY_INIT_DONE 0x80000000
|
||||
#define MV_U3D_LTSSM_NEVER_GO_COMPLIANCE 0x40000000
|
||||
|
||||
#define MV_U3D_USB3_OP_REGS_OFFSET 0x100
|
||||
#define MV_U3D_USB3_PHY_OFFSET 0xB800
|
||||
|
||||
#define DCS_ENABLE 0x1
|
||||
|
||||
/* timeout */
|
||||
#define MV_U3D_RESET_TIMEOUT 10000
|
||||
#define MV_U3D_FLUSH_TIMEOUT 100000
|
||||
#define MV_U3D_OWN_TIMEOUT 10000
|
||||
#define LOOPS_USEC_SHIFT 4
|
||||
#define LOOPS_USEC (1 << LOOPS_USEC_SHIFT)
|
||||
#define LOOPS(timeout) ((timeout) >> LOOPS_USEC_SHIFT)
|
||||
|
||||
/* ep direction */
|
||||
#define MV_U3D_EP_DIR_IN 1
|
||||
#define MV_U3D_EP_DIR_OUT 0
|
||||
#define mv_u3d_ep_dir(ep) (((ep)->ep_num == 0) ? \
|
||||
((ep)->u3d->ep0_dir) : ((ep)->direction))
|
||||
|
||||
/* usb capability registers */
|
||||
struct mv_u3d_cap_regs {
|
||||
u32 rsvd[5];
|
||||
u32 dboff; /* doorbell register offset */
|
||||
u32 rtsoff; /* runtime register offset */
|
||||
u32 vuoff; /* vendor unique register offset */
|
||||
};
|
||||
|
||||
/* operation registers */
|
||||
struct mv_u3d_op_regs {
|
||||
u32 usbcmd; /* Command register */
|
||||
u32 rsvd1[11];
|
||||
u32 dcbaapl; /* Device Context Base Address low register */
|
||||
u32 dcbaaph; /* Device Context Base Address high register */
|
||||
u32 rsvd2[243];
|
||||
u32 portsc; /* port status and control register*/
|
||||
u32 portlinkinfo; /* port link info register*/
|
||||
u32 rsvd3[9917];
|
||||
u32 doorbell; /* doorbell register */
|
||||
};
|
||||
|
||||
/* control enpoint enable registers */
|
||||
struct epxcr {
|
||||
u32 epxoutcr0; /* ep out control 0 register */
|
||||
u32 epxoutcr1; /* ep out control 1 register */
|
||||
u32 epxincr0; /* ep in control 0 register */
|
||||
u32 epxincr1; /* ep in control 1 register */
|
||||
};
|
||||
|
||||
/* transfer status registers */
|
||||
struct xferstatus {
|
||||
u32 curdeqlo; /* current TRB pointer low */
|
||||
u32 curdeqhi; /* current TRB pointer high */
|
||||
u32 statuslo; /* transfer status low */
|
||||
u32 statushi; /* transfer status high */
|
||||
};
|
||||
|
||||
/* vendor unique control registers */
|
||||
struct mv_u3d_vuc_regs {
|
||||
u32 ctrlepenable; /* control endpoint enable register */
|
||||
u32 setuplock; /* setup lock register */
|
||||
u32 endcomplete; /* endpoint transfer complete register */
|
||||
u32 intrcause; /* interrupt cause register */
|
||||
u32 intrenable; /* interrupt enable register */
|
||||
u32 trbcomplete; /* TRB complete register */
|
||||
u32 linkchange; /* link change register */
|
||||
u32 rsvd1[5];
|
||||
u32 trbunderrun; /* TRB underrun register */
|
||||
u32 rsvd2[43];
|
||||
u32 bridgesetting; /* bridge setting register */
|
||||
u32 rsvd3[7];
|
||||
struct xferstatus txst[16]; /* TX status register */
|
||||
struct xferstatus rxst[16]; /* RX status register */
|
||||
u32 ltssm; /* LTSSM control register */
|
||||
u32 pipe; /* PIPE control register */
|
||||
u32 linkcr0; /* link control 0 register */
|
||||
u32 linkcr1; /* link control 1 register */
|
||||
u32 rsvd6[60];
|
||||
u32 mib0; /* MIB0 counter register */
|
||||
u32 usblink; /* usb link control register */
|
||||
u32 ltssmstate; /* LTSSM state register */
|
||||
u32 linkerrorcause; /* link error cause register */
|
||||
u32 rsvd7[60];
|
||||
u32 devaddrtiebrkr; /* device address and tie breaker */
|
||||
u32 itpinfo0; /* ITP info 0 register */
|
||||
u32 itpinfo1; /* ITP info 1 register */
|
||||
u32 rsvd8[61];
|
||||
struct epxcr epcr[16]; /* ep control register */
|
||||
u32 rsvd9[64];
|
||||
u32 phyaddr; /* PHY address register */
|
||||
u32 phydata; /* PHY data register */
|
||||
};
|
||||
|
||||
/* Endpoint context structure */
|
||||
struct mv_u3d_ep_context {
|
||||
u32 rsvd0;
|
||||
u32 rsvd1;
|
||||
u32 trb_addr_lo; /* TRB address low 32 bit */
|
||||
u32 trb_addr_hi; /* TRB address high 32 bit */
|
||||
u32 rsvd2;
|
||||
u32 rsvd3;
|
||||
struct usb_ctrlrequest setup_buffer; /* setup data buffer */
|
||||
};
|
||||
|
||||
/* TRB control data structure */
|
||||
struct mv_u3d_trb_ctrl {
|
||||
u32 own:1; /* owner of TRB */
|
||||
u32 rsvd1:3;
|
||||
u32 chain:1; /* associate this TRB with the
|
||||
next TRB on the Ring */
|
||||
u32 ioc:1; /* interrupt on complete */
|
||||
u32 rsvd2:4;
|
||||
u32 type:6; /* TRB type */
|
||||
#define TYPE_NORMAL 1
|
||||
#define TYPE_DATA 3
|
||||
#define TYPE_LINK 6
|
||||
u32 dir:1; /* Working at data stage of control endpoint
|
||||
operation. 0 is OUT and 1 is IN. */
|
||||
u32 rsvd3:15;
|
||||
};
|
||||
|
||||
/* TRB data structure
|
||||
* For multiple TRB, all the TRBs' physical address should be continuous.
|
||||
*/
|
||||
struct mv_u3d_trb_hw {
|
||||
u32 buf_addr_lo; /* data buffer address low 32 bit */
|
||||
u32 buf_addr_hi; /* data buffer address high 32 bit */
|
||||
u32 trb_len; /* transfer length */
|
||||
struct mv_u3d_trb_ctrl ctrl; /* TRB control data */
|
||||
};
|
||||
|
||||
/* TRB structure */
|
||||
struct mv_u3d_trb {
|
||||
struct mv_u3d_trb_hw *trb_hw; /* point to the trb_hw structure */
|
||||
dma_addr_t trb_dma; /* dma address for this trb_hw */
|
||||
struct list_head trb_list; /* trb list */
|
||||
};
|
||||
|
||||
/* device data structure */
|
||||
struct mv_u3d {
|
||||
struct usb_gadget gadget;
|
||||
struct usb_gadget_driver *driver;
|
||||
spinlock_t lock; /* device lock */
|
||||
struct completion *done;
|
||||
struct device *dev;
|
||||
int irq;
|
||||
|
||||
/* usb controller registers */
|
||||
struct mv_u3d_cap_regs __iomem *cap_regs;
|
||||
struct mv_u3d_op_regs __iomem *op_regs;
|
||||
struct mv_u3d_vuc_regs __iomem *vuc_regs;
|
||||
void __iomem *phy_regs;
|
||||
|
||||
unsigned int max_eps;
|
||||
struct mv_u3d_ep_context *ep_context;
|
||||
size_t ep_context_size;
|
||||
dma_addr_t ep_context_dma;
|
||||
|
||||
struct dma_pool *trb_pool; /* for TRB data structure */
|
||||
struct mv_u3d_ep *eps;
|
||||
|
||||
struct mv_u3d_req *status_req; /* ep0 status request */
|
||||
struct usb_ctrlrequest local_setup_buff; /* store setup data*/
|
||||
|
||||
unsigned int resume_state; /* USB state to resume */
|
||||
unsigned int usb_state; /* USB current state */
|
||||
unsigned int ep0_state; /* Endpoint zero state */
|
||||
unsigned int ep0_dir;
|
||||
|
||||
unsigned int dev_addr; /* device address */
|
||||
|
||||
unsigned int errors;
|
||||
|
||||
unsigned softconnect:1;
|
||||
unsigned vbus_active:1; /* vbus is active or not */
|
||||
unsigned remote_wakeup:1; /* support remote wakeup */
|
||||
unsigned clock_gating:1; /* clock gating or not */
|
||||
unsigned active:1; /* udc is active or not */
|
||||
unsigned vbus_valid_detect:1; /* udc vbus detection */
|
||||
|
||||
struct mv_usb_addon_irq *vbus;
|
||||
unsigned int power;
|
||||
|
||||
struct clk *clk;
|
||||
};
|
||||
|
||||
/* endpoint data structure */
|
||||
struct mv_u3d_ep {
|
||||
struct usb_ep ep;
|
||||
struct mv_u3d *u3d;
|
||||
struct list_head queue; /* ep request queued hardware */
|
||||
struct list_head req_list; /* list of ep request */
|
||||
struct mv_u3d_ep_context *ep_context; /* ep context */
|
||||
u32 direction;
|
||||
char name[14];
|
||||
u32 processing; /* there is ep request
|
||||
queued on haredware */
|
||||
spinlock_t req_lock; /* ep lock */
|
||||
unsigned wedge:1;
|
||||
unsigned enabled:1;
|
||||
unsigned ep_type:2;
|
||||
unsigned ep_num:8;
|
||||
};
|
||||
|
||||
/* request data structure */
|
||||
struct mv_u3d_req {
|
||||
struct usb_request req;
|
||||
struct mv_u3d_ep *ep;
|
||||
struct list_head queue; /* ep requst queued on hardware */
|
||||
struct list_head list; /* ep request list */
|
||||
struct list_head trb_list; /* trb list of a request */
|
||||
|
||||
struct mv_u3d_trb *trb_head; /* point to first trb of a request */
|
||||
unsigned trb_count; /* TRB number in the chain */
|
||||
unsigned chain; /* TRB chain or not */
|
||||
};
|
||||
|
||||
#endif
|
2098
drivers/usb/gadget/mv_u3d_core.c
Normal file
2098
drivers/usb/gadget/mv_u3d_core.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -36,9 +36,9 @@
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/prefetch.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/irq.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include <asm/mach-types.h>
|
||||
@ -59,11 +59,6 @@
|
||||
#define DRIVER_DESC "OMAP UDC driver"
|
||||
#define DRIVER_VERSION "4 October 2004"
|
||||
|
||||
#define DMA_ADDR_INVALID (~(dma_addr_t)0)
|
||||
|
||||
#define OMAP2_DMA_CH(ch) (((ch) - 1) << 1)
|
||||
#define OMAP24XX_DMA(name, ch) (OMAP24XX_DMA_##name + OMAP2_DMA_CH(ch))
|
||||
|
||||
/*
|
||||
* The OMAP UDC needs _very_ early endpoint setup: before enabling the
|
||||
* D+ pullup to allow enumeration. That's too early for the gadget
|
||||
@ -87,14 +82,14 @@
|
||||
#ifdef USE_ISO
|
||||
static unsigned fifo_mode = 3;
|
||||
#else
|
||||
static unsigned fifo_mode = 0;
|
||||
static unsigned fifo_mode;
|
||||
#endif
|
||||
|
||||
/* "modprobe omap_udc fifo_mode=42", or else as a kernel
|
||||
* boot parameter "omap_udc:fifo_mode=42"
|
||||
*/
|
||||
module_param (fifo_mode, uint, 0);
|
||||
MODULE_PARM_DESC (fifo_mode, "endpoint configuration");
|
||||
module_param(fifo_mode, uint, 0);
|
||||
MODULE_PARM_DESC(fifo_mode, "endpoint configuration");
|
||||
|
||||
#ifdef USE_DMA
|
||||
static bool use_dma = 1;
|
||||
@ -102,8 +97,8 @@ static bool use_dma = 1;
|
||||
/* "modprobe omap_udc use_dma=y", or else as a kernel
|
||||
* boot parameter "omap_udc:use_dma=y"
|
||||
*/
|
||||
module_param (use_dma, bool, 0);
|
||||
MODULE_PARM_DESC (use_dma, "enable/disable DMA");
|
||||
module_param(use_dma, bool, 0);
|
||||
MODULE_PARM_DESC(use_dma, "enable/disable DMA");
|
||||
#else /* !USE_DMA */
|
||||
|
||||
/* save a bit of code */
|
||||
@ -111,8 +106,8 @@ MODULE_PARM_DESC (use_dma, "enable/disable DMA");
|
||||
#endif /* !USE_DMA */
|
||||
|
||||
|
||||
static const char driver_name [] = "omap_udc";
|
||||
static const char driver_desc [] = DRIVER_DESC;
|
||||
static const char driver_name[] = "omap_udc";
|
||||
static const char driver_desc[] = DRIVER_DESC;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
@ -250,7 +245,7 @@ static int omap_ep_disable(struct usb_ep *_ep)
|
||||
|
||||
spin_lock_irqsave(&ep->udc->lock, flags);
|
||||
ep->ep.desc = NULL;
|
||||
nuke (ep, -ESHUTDOWN);
|
||||
nuke(ep, -ESHUTDOWN);
|
||||
ep->ep.maxpacket = ep->maxpacket;
|
||||
ep->has_dma = 0;
|
||||
omap_writew(UDC_SET_HALT, UDC_CTRL);
|
||||
@ -271,10 +266,11 @@ omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
|
||||
struct omap_req *req;
|
||||
|
||||
req = kzalloc(sizeof(*req), gfp_flags);
|
||||
if (req) {
|
||||
req->req.dma = DMA_ADDR_INVALID;
|
||||
INIT_LIST_HEAD (&req->queue);
|
||||
}
|
||||
if (!req)
|
||||
return NULL;
|
||||
|
||||
INIT_LIST_HEAD(&req->queue);
|
||||
|
||||
return &req->req;
|
||||
}
|
||||
|
||||
@ -283,8 +279,7 @@ omap_free_request(struct usb_ep *ep, struct usb_request *_req)
|
||||
{
|
||||
struct omap_req *req = container_of(_req, struct omap_req, req);
|
||||
|
||||
if (_req)
|
||||
kfree (req);
|
||||
kfree(req);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -292,6 +287,7 @@ omap_free_request(struct usb_ep *ep, struct usb_request *_req)
|
||||
static void
|
||||
done(struct omap_ep *ep, struct omap_req *req, int status)
|
||||
{
|
||||
struct omap_udc *udc = ep->udc;
|
||||
unsigned stopped = ep->stopped;
|
||||
|
||||
list_del_init(&req->queue);
|
||||
@ -301,22 +297,9 @@ done(struct omap_ep *ep, struct omap_req *req, int status)
|
||||
else
|
||||
status = req->req.status;
|
||||
|
||||
if (use_dma && ep->has_dma) {
|
||||
if (req->mapped) {
|
||||
dma_unmap_single(ep->udc->gadget.dev.parent,
|
||||
req->req.dma, req->req.length,
|
||||
(ep->bEndpointAddress & USB_DIR_IN)
|
||||
? DMA_TO_DEVICE
|
||||
: DMA_FROM_DEVICE);
|
||||
req->req.dma = DMA_ADDR_INVALID;
|
||||
req->mapped = 0;
|
||||
} else
|
||||
dma_sync_single_for_cpu(ep->udc->gadget.dev.parent,
|
||||
req->req.dma, req->req.length,
|
||||
(ep->bEndpointAddress & USB_DIR_IN)
|
||||
? DMA_TO_DEVICE
|
||||
: DMA_FROM_DEVICE);
|
||||
}
|
||||
if (use_dma && ep->has_dma)
|
||||
usb_gadget_unmap_request(&udc->gadget, &req->req,
|
||||
(ep->bEndpointAddress & USB_DIR_IN));
|
||||
|
||||
#ifndef USB_TRACE
|
||||
if (status && status != -ESHUTDOWN)
|
||||
@ -364,10 +347,10 @@ write_packet(u8 *buf, struct omap_req *req, unsigned max)
|
||||
return len;
|
||||
}
|
||||
|
||||
// FIXME change r/w fifo calling convention
|
||||
/* FIXME change r/w fifo calling convention */
|
||||
|
||||
|
||||
// return: 0 = still running, 1 = completed, negative = errno
|
||||
/* return: 0 = still running, 1 = completed, negative = errno */
|
||||
static int write_fifo(struct omap_ep *ep, struct omap_req *req)
|
||||
{
|
||||
u8 *buf;
|
||||
@ -429,7 +412,7 @@ read_packet(u8 *buf, struct omap_req *req, unsigned avail)
|
||||
return len;
|
||||
}
|
||||
|
||||
// return: 0 = still running, 1 = queue empty, negative = errno
|
||||
/* return: 0 = still running, 1 = queue empty, negative = errno */
|
||||
static int read_fifo(struct omap_ep *ep, struct omap_req *req)
|
||||
{
|
||||
u8 *buf;
|
||||
@ -536,12 +519,8 @@ static void next_in_dma(struct omap_ep *ep, struct omap_req *req)
|
||||
: OMAP_DMA_SYNC_ELEMENT;
|
||||
int dma_trigger = 0;
|
||||
|
||||
if (cpu_is_omap24xx())
|
||||
dma_trigger = OMAP24XX_DMA(USB_W2FC_TX0, ep->dma_channel);
|
||||
|
||||
/* measure length in either bytes or packets */
|
||||
if ((cpu_is_omap16xx() && length <= UDC_TXN_TSC)
|
||||
|| (cpu_is_omap24xx() && length < ep->maxpacket)
|
||||
|| (cpu_is_omap15xx() && length < ep->maxpacket)) {
|
||||
txdma_ctrl = UDC_TXN_EOT | length;
|
||||
omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8,
|
||||
@ -600,28 +579,14 @@ static void next_out_dma(struct omap_ep *ep, struct omap_req *req)
|
||||
int dma_trigger = 0;
|
||||
u16 w;
|
||||
|
||||
if (cpu_is_omap24xx())
|
||||
dma_trigger = OMAP24XX_DMA(USB_W2FC_RX0, ep->dma_channel);
|
||||
|
||||
/* NOTE: we filtered out "short reads" before, so we know
|
||||
* the buffer has only whole numbers of packets.
|
||||
* except MODE SELECT(6) sent the 24 bytes data in OMAP24XX DMA mode
|
||||
*/
|
||||
if (cpu_is_omap24xx() && packets < ep->maxpacket) {
|
||||
omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8,
|
||||
packets, 1, OMAP_DMA_SYNC_ELEMENT,
|
||||
dma_trigger, 0);
|
||||
req->dma_bytes = packets;
|
||||
} else {
|
||||
/* set up this DMA transfer, enable the fifo, start */
|
||||
packets /= ep->ep.maxpacket;
|
||||
packets = min(packets, (unsigned)UDC_RXN_TC + 1);
|
||||
req->dma_bytes = packets * ep->ep.maxpacket;
|
||||
omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16,
|
||||
ep->ep.maxpacket >> 1, packets,
|
||||
OMAP_DMA_SYNC_ELEMENT,
|
||||
dma_trigger, 0);
|
||||
}
|
||||
/* set up this DMA transfer, enable the fifo, start */
|
||||
packets /= ep->ep.maxpacket;
|
||||
packets = min(packets, (unsigned)UDC_RXN_TC + 1);
|
||||
req->dma_bytes = packets * ep->ep.maxpacket;
|
||||
omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16,
|
||||
ep->ep.maxpacket >> 1, packets,
|
||||
OMAP_DMA_SYNC_ELEMENT,
|
||||
dma_trigger, 0);
|
||||
omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF,
|
||||
OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual,
|
||||
0, 0);
|
||||
@ -683,7 +648,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src)
|
||||
}
|
||||
omap_writew(UDC_TXN_DONE, UDC_IRQ_SRC);
|
||||
|
||||
if (!list_empty (&ep->queue)) {
|
||||
if (!list_empty(&ep->queue)) {
|
||||
req = container_of(ep->queue.next,
|
||||
struct omap_req, queue);
|
||||
next_in_dma(ep, req);
|
||||
@ -702,7 +667,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src)
|
||||
}
|
||||
omap_writew(UDC_RXN_EOT, UDC_IRQ_SRC);
|
||||
|
||||
if (!list_empty (&ep->queue)) {
|
||||
if (!list_empty(&ep->queue)) {
|
||||
req = container_of(ep->queue.next,
|
||||
struct omap_req, queue);
|
||||
next_out_dma(ep, req);
|
||||
@ -760,10 +725,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel)
|
||||
ep->dma_channel = channel;
|
||||
|
||||
if (is_in) {
|
||||
if (cpu_is_omap24xx())
|
||||
dma_channel = OMAP24XX_DMA(USB_W2FC_TX0, channel);
|
||||
else
|
||||
dma_channel = OMAP_DMA_USB_W2FC_TX0 - 1 + channel;
|
||||
dma_channel = OMAP_DMA_USB_W2FC_TX0 - 1 + channel;
|
||||
status = omap_request_dma(dma_channel,
|
||||
ep->ep.name, dma_error, ep, &ep->lch);
|
||||
if (status == 0) {
|
||||
@ -780,11 +742,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel)
|
||||
0, 0);
|
||||
}
|
||||
} else {
|
||||
if (cpu_is_omap24xx())
|
||||
dma_channel = OMAP24XX_DMA(USB_W2FC_RX0, channel);
|
||||
else
|
||||
dma_channel = OMAP_DMA_USB_W2FC_RX0 - 1 + channel;
|
||||
|
||||
dma_channel = OMAP_DMA_USB_W2FC_RX0 - 1 + channel;
|
||||
status = omap_request_dma(dma_channel,
|
||||
ep->ep.name, dma_error, ep, &ep->lch);
|
||||
if (status == 0) {
|
||||
@ -808,7 +766,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel)
|
||||
omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ);
|
||||
|
||||
/* channel type P: hw synch (fifo) */
|
||||
if (cpu_class_is_omap1() && !cpu_is_omap15xx())
|
||||
if (!cpu_is_omap15xx())
|
||||
omap_set_dma_channel_mode(ep->lch, OMAP_DMA_LCH_P);
|
||||
}
|
||||
|
||||
@ -928,13 +886,11 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||
|
||||
/* this isn't bogus, but OMAP DMA isn't the only hardware to
|
||||
* have a hard time with partial packet reads... reject it.
|
||||
* Except OMAP2 can handle the small packets.
|
||||
*/
|
||||
if (use_dma
|
||||
&& ep->has_dma
|
||||
&& ep->bEndpointAddress != 0
|
||||
&& (ep->bEndpointAddress & USB_DIR_IN) == 0
|
||||
&& !cpu_class_is_omap2()
|
||||
&& (req->req.length % ep->ep.maxpacket) != 0) {
|
||||
DBG("%s, no partial packet OUT reads\n", __func__);
|
||||
return -EMSGSIZE;
|
||||
@ -944,26 +900,9 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||
if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN)
|
||||
return -ESHUTDOWN;
|
||||
|
||||
if (use_dma && ep->has_dma) {
|
||||
if (req->req.dma == DMA_ADDR_INVALID) {
|
||||
req->req.dma = dma_map_single(
|
||||
ep->udc->gadget.dev.parent,
|
||||
req->req.buf,
|
||||
req->req.length,
|
||||
(ep->bEndpointAddress & USB_DIR_IN)
|
||||
? DMA_TO_DEVICE
|
||||
: DMA_FROM_DEVICE);
|
||||
req->mapped = 1;
|
||||
} else {
|
||||
dma_sync_single_for_device(
|
||||
ep->udc->gadget.dev.parent,
|
||||
req->req.dma, req->req.length,
|
||||
(ep->bEndpointAddress & USB_DIR_IN)
|
||||
? DMA_TO_DEVICE
|
||||
: DMA_FROM_DEVICE);
|
||||
req->mapped = 0;
|
||||
}
|
||||
}
|
||||
if (use_dma && ep->has_dma)
|
||||
usb_gadget_map_request(&udc->gadget, &req->req,
|
||||
(ep->bEndpointAddress & USB_DIR_IN));
|
||||
|
||||
VDBG("%s queue req %p, len %d buf %p\n",
|
||||
ep->ep.name, _req, _req->length, _req->buf);
|
||||
@ -984,7 +923,7 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||
int is_in;
|
||||
|
||||
if (ep->bEndpointAddress == 0) {
|
||||
if (!udc->ep0_pending || !list_empty (&ep->queue)) {
|
||||
if (!udc->ep0_pending || !list_empty(&ep->queue)) {
|
||||
spin_unlock_irqrestore(&udc->lock, flags);
|
||||
return -EL2HLT;
|
||||
}
|
||||
@ -1011,7 +950,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||
* always an IN ... even for IN transfers,
|
||||
* a weird case which seem to stall OMAP.
|
||||
*/
|
||||
omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM);
|
||||
omap_writew(UDC_EP_SEL | UDC_EP_DIR,
|
||||
UDC_EP_NUM);
|
||||
omap_writew(UDC_CLR_EP, UDC_CTRL);
|
||||
omap_writew(UDC_SET_FIFO_EN, UDC_CTRL);
|
||||
omap_writew(UDC_EP_DIR, UDC_EP_NUM);
|
||||
@ -1023,7 +963,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||
|
||||
/* non-empty DATA stage */
|
||||
} else if (is_in) {
|
||||
omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM);
|
||||
omap_writew(UDC_EP_SEL | UDC_EP_DIR,
|
||||
UDC_EP_NUM);
|
||||
} else {
|
||||
if (udc->ep0_setup)
|
||||
goto irq_wait;
|
||||
@ -1071,7 +1012,7 @@ static int omap_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
|
||||
spin_lock_irqsave(&ep->udc->lock, flags);
|
||||
|
||||
/* make sure it's actually queued on this endpoint */
|
||||
list_for_each_entry (req, &ep->queue, queue) {
|
||||
list_for_each_entry(req, &ep->queue, queue) {
|
||||
if (&req->req == _req)
|
||||
break;
|
||||
}
|
||||
@ -1178,8 +1119,8 @@ static struct usb_ep_ops omap_ep_ops = {
|
||||
.dequeue = omap_ep_dequeue,
|
||||
|
||||
.set_halt = omap_ep_set_halt,
|
||||
// fifo_status ... report bytes in fifo
|
||||
// fifo_flush ... flush fifo
|
||||
/* fifo_status ... report bytes in fifo */
|
||||
/* fifo_flush ... flush fifo */
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -1409,7 +1350,7 @@ static void udc_quiesce(struct omap_udc *udc)
|
||||
|
||||
udc->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
nuke(&udc->ep[0], -ESHUTDOWN);
|
||||
list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list)
|
||||
list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list)
|
||||
nuke(ep, -ESHUTDOWN);
|
||||
}
|
||||
|
||||
@ -1525,7 +1466,8 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src)
|
||||
/* read next OUT packet of request, maybe
|
||||
* reactiviting the fifo; stall on errors.
|
||||
*/
|
||||
if (!req || (stat = read_fifo(ep0, req)) < 0) {
|
||||
stat = read_fifo(ep0, req);
|
||||
if (!req || stat < 0) {
|
||||
omap_writew(UDC_STALL_CMD, UDC_SYSCON2);
|
||||
udc->ep0_pending = 0;
|
||||
stat = 0;
|
||||
@ -1658,7 +1600,7 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src)
|
||||
/* this has rude side-effects (aborts) and
|
||||
* can't really work if DMA-IN is active
|
||||
*/
|
||||
DBG("%s host set_halt, NYET \n", ep->name);
|
||||
DBG("%s host set_halt, NYET\n", ep->name);
|
||||
goto do_stall;
|
||||
}
|
||||
use_ep(ep, 0);
|
||||
@ -1749,7 +1691,7 @@ delegate:
|
||||
*/
|
||||
udc->ep0_setup = 1;
|
||||
spin_unlock(&udc->lock);
|
||||
status = udc->driver->setup (&udc->gadget, &u.r);
|
||||
status = udc->driver->setup(&udc->gadget, &u.r);
|
||||
spin_lock(&udc->lock);
|
||||
udc->ep0_setup = 0;
|
||||
}
|
||||
@ -1794,7 +1736,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
|
||||
VDBG("connect\n");
|
||||
if (!udc->transceiver)
|
||||
pullup_enable(udc);
|
||||
// if (driver->connect) call it
|
||||
/* if (driver->connect) call it */
|
||||
} else if (udc->gadget.speed != USB_SPEED_UNKNOWN) {
|
||||
udc->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
if (!udc->transceiver)
|
||||
@ -1826,7 +1768,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
|
||||
}
|
||||
if (change & UDC_SUS) {
|
||||
if (udc->gadget.speed != USB_SPEED_UNKNOWN) {
|
||||
// FIXME tell isp1301 to suspend/resume (?)
|
||||
/* FIXME tell isp1301 to suspend/resume (?) */
|
||||
if (devstat & UDC_SUS) {
|
||||
VDBG("suspend\n");
|
||||
update_otg(udc);
|
||||
@ -2029,7 +1971,7 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev)
|
||||
spin_lock_irqsave(&udc->lock, flags);
|
||||
|
||||
/* handle all non-DMA ISO transfers */
|
||||
list_for_each_entry (ep, &udc->iso, iso) {
|
||||
list_for_each_entry(ep, &udc->iso, iso) {
|
||||
u16 stat;
|
||||
struct omap_req *req;
|
||||
|
||||
@ -2088,15 +2030,11 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev)
|
||||
|
||||
static inline int machine_without_vbus_sense(void)
|
||||
{
|
||||
return (machine_is_omap_innovator()
|
||||
return machine_is_omap_innovator()
|
||||
|| machine_is_omap_osk()
|
||||
|| machine_is_omap_apollon()
|
||||
#ifndef CONFIG_MACH_OMAP_H4_OTG
|
||||
|| machine_is_omap_h4()
|
||||
#endif
|
||||
|| machine_is_sx1()
|
||||
|| cpu_is_omap7xx() /* No known omap7xx boards with vbus sense */
|
||||
);
|
||||
/* No known omap7xx boards with vbus sense */
|
||||
|| cpu_is_omap7xx();
|
||||
}
|
||||
|
||||
static int omap_udc_start(struct usb_gadget_driver *driver,
|
||||
@ -2110,7 +2048,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
|
||||
if (!udc)
|
||||
return -ENODEV;
|
||||
if (!driver
|
||||
// FIXME if otg, check: driver->is_otg
|
||||
/* FIXME if otg, check: driver->is_otg */
|
||||
|| driver->max_speed < USB_SPEED_FULL
|
||||
|| !bind || !driver->setup)
|
||||
return -EINVAL;
|
||||
@ -2122,7 +2060,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
|
||||
}
|
||||
|
||||
/* reset state */
|
||||
list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list) {
|
||||
list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) {
|
||||
ep->irqs = 0;
|
||||
if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC)
|
||||
continue;
|
||||
@ -2160,7 +2098,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
|
||||
if (status < 0) {
|
||||
ERR("can't bind to transceiver\n");
|
||||
if (driver->unbind) {
|
||||
driver->unbind (&udc->gadget);
|
||||
driver->unbind(&udc->gadget);
|
||||
udc->gadget.dev.driver = NULL;
|
||||
udc->driver = NULL;
|
||||
}
|
||||
@ -2168,9 +2106,9 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
|
||||
}
|
||||
} else {
|
||||
if (can_pullup(udc))
|
||||
pullup_enable (udc);
|
||||
pullup_enable(udc);
|
||||
else
|
||||
pullup_disable (udc);
|
||||
pullup_disable(udc);
|
||||
}
|
||||
|
||||
/* boards that don't have VBUS sensing can't autogate 48MHz;
|
||||
@ -2229,7 +2167,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver)
|
||||
static const char proc_filename[] = "driver/udc";
|
||||
|
||||
#define FOURBITS "%s%s%s%s"
|
||||
#define EIGHTBITS FOURBITS FOURBITS
|
||||
#define EIGHTBITS "%s%s%s%s%s%s%s%s"
|
||||
|
||||
static void proc_ep_show(struct seq_file *s, struct omap_ep *ep)
|
||||
{
|
||||
@ -2251,12 +2189,21 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep)
|
||||
"\n%s %s%s%sirqs %ld stat %04x " EIGHTBITS FOURBITS "%s\n",
|
||||
ep->name, buf,
|
||||
ep->double_buf ? "dbuf " : "",
|
||||
({char *s; switch(ep->ackwait){
|
||||
case 0: s = ""; break;
|
||||
case 1: s = "(ackw) "; break;
|
||||
case 2: s = "(ackw2) "; break;
|
||||
default: s = "(?) "; break;
|
||||
} s;}),
|
||||
({ char *s;
|
||||
switch (ep->ackwait) {
|
||||
case 0:
|
||||
s = "";
|
||||
break;
|
||||
case 1:
|
||||
s = "(ackw) ";
|
||||
break;
|
||||
case 2:
|
||||
s = "(ackw2) ";
|
||||
break;
|
||||
default:
|
||||
s = "(?) ";
|
||||
break;
|
||||
} s; }),
|
||||
ep->irqs, stat_flg,
|
||||
(stat_flg & UDC_NO_RXPACKET) ? "no_rxpacket " : "",
|
||||
(stat_flg & UDC_MISS_IN) ? "miss_in " : "",
|
||||
@ -2272,10 +2219,10 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep)
|
||||
(stat_flg & UDC_NON_ISO_FIFO_EMPTY) ? "fifo_empty " : "",
|
||||
(stat_flg & UDC_NON_ISO_FIFO_FULL) ? "fifo_full " : "");
|
||||
|
||||
if (list_empty (&ep->queue))
|
||||
if (list_empty(&ep->queue))
|
||||
seq_printf(s, "\t(queue empty)\n");
|
||||
else
|
||||
list_for_each_entry (req, &ep->queue, queue) {
|
||||
list_for_each_entry(req, &ep->queue, queue) {
|
||||
unsigned length = req->req.actual;
|
||||
|
||||
if (use_dma && buf[0]) {
|
||||
@ -2293,11 +2240,16 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep)
|
||||
static char *trx_mode(unsigned m, int enabled)
|
||||
{
|
||||
switch (m) {
|
||||
case 0: return enabled ? "*6wire" : "unused";
|
||||
case 1: return "4wire";
|
||||
case 2: return "3wire";
|
||||
case 3: return "6wire";
|
||||
default: return "unknown";
|
||||
case 0:
|
||||
return enabled ? "*6wire" : "unused";
|
||||
case 1:
|
||||
return "4wire";
|
||||
case 2:
|
||||
return "3wire";
|
||||
case 3:
|
||||
return "6wire";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
@ -2307,12 +2259,9 @@ static int proc_otg_show(struct seq_file *s)
|
||||
u32 trans = 0;
|
||||
char *ctrl_name = "(UNKNOWN)";
|
||||
|
||||
/* XXX This needs major revision for OMAP2+ */
|
||||
tmp = omap_readl(OTG_REV);
|
||||
if (cpu_class_is_omap1()) {
|
||||
ctrl_name = "tranceiver_ctrl";
|
||||
trans = omap_readw(USB_TRANSCEIVER_CTRL);
|
||||
}
|
||||
ctrl_name = "tranceiver_ctrl";
|
||||
trans = omap_readw(USB_TRANSCEIVER_CTRL);
|
||||
seq_printf(s, "\nOTG rev %d.%d, %s %05x\n",
|
||||
tmp >> 4, tmp & 0xf, ctrl_name, trans);
|
||||
tmp = omap_readw(OTG_SYSCON_1);
|
||||
@ -2332,7 +2281,7 @@ static int proc_otg_show(struct seq_file *s)
|
||||
" b_ase_brst=%d hmc=%d\n", tmp,
|
||||
(tmp & OTG_EN) ? " otg_en" : "",
|
||||
(tmp & USBX_SYNCHRO) ? " synchro" : "",
|
||||
// much more SRP stuff
|
||||
/* much more SRP stuff */
|
||||
(tmp & SRP_DATA) ? " srp_data" : "",
|
||||
(tmp & SRP_VBUS) ? " srp_vbus" : "",
|
||||
(tmp & OTG_PADEN) ? " otg_paden" : "",
|
||||
@ -2399,14 +2348,12 @@ static int proc_udc_show(struct seq_file *s, void *_)
|
||||
HMC,
|
||||
udc->transceiver
|
||||
? udc->transceiver->label
|
||||
: ((cpu_is_omap1710() || cpu_is_omap24xx())
|
||||
: (cpu_is_omap1710()
|
||||
? "external" : "(none)"));
|
||||
if (cpu_class_is_omap1()) {
|
||||
seq_printf(s, "ULPD control %04x req %04x status %04x\n",
|
||||
omap_readw(ULPD_CLOCK_CTRL),
|
||||
omap_readw(ULPD_SOFT_REQ),
|
||||
omap_readw(ULPD_STATUS_REQ));
|
||||
}
|
||||
seq_printf(s, "ULPD control %04x req %04x status %04x\n",
|
||||
omap_readw(ULPD_CLOCK_CTRL),
|
||||
omap_readw(ULPD_SOFT_REQ),
|
||||
omap_readw(ULPD_STATUS_REQ));
|
||||
|
||||
/* OTG controller registers */
|
||||
if (!cpu_is_omap15xx())
|
||||
@ -2422,7 +2369,7 @@ static int proc_udc_show(struct seq_file *s, void *_)
|
||||
(tmp & UDC_SELF_PWR) ? " self_pwr" : "",
|
||||
(tmp & UDC_SOFF_DIS) ? " soff_dis" : "",
|
||||
(tmp & UDC_PULLUP_EN) ? " PULLUP" : "");
|
||||
// syscon2 is write-only
|
||||
/* syscon2 is write-only */
|
||||
|
||||
/* UDC controller registers */
|
||||
if (!(tmp & UDC_PULLUP_EN)) {
|
||||
@ -2506,7 +2453,7 @@ static int proc_udc_show(struct seq_file *s, void *_)
|
||||
if (tmp & UDC_ATT) {
|
||||
proc_ep_show(s, &udc->ep[0]);
|
||||
if (tmp & UDC_ADD) {
|
||||
list_for_each_entry (ep, &udc->gadget.ep_list,
|
||||
list_for_each_entry(ep, &udc->gadget.ep_list,
|
||||
ep.ep_list) {
|
||||
if (ep->ep.desc)
|
||||
proc_ep_show(s, ep);
|
||||
@ -2557,7 +2504,7 @@ static inline void remove_proc_file(void) {}
|
||||
* UDC_SYSCON_1.CFG_LOCK is set can now work. We won't use that
|
||||
* capability yet though.
|
||||
*/
|
||||
static unsigned __init
|
||||
static unsigned __devinit
|
||||
omap_ep_setup(char *name, u8 addr, u8 type,
|
||||
unsigned buf, unsigned maxp, int dbuf)
|
||||
{
|
||||
@ -2575,14 +2522,29 @@ omap_ep_setup(char *name, u8 addr, u8 type,
|
||||
/* chip setup ... bit values are same for IN, OUT */
|
||||
if (type == USB_ENDPOINT_XFER_ISOC) {
|
||||
switch (maxp) {
|
||||
case 8: epn_rxtx = 0 << 12; break;
|
||||
case 16: epn_rxtx = 1 << 12; break;
|
||||
case 32: epn_rxtx = 2 << 12; break;
|
||||
case 64: epn_rxtx = 3 << 12; break;
|
||||
case 128: epn_rxtx = 4 << 12; break;
|
||||
case 256: epn_rxtx = 5 << 12; break;
|
||||
case 512: epn_rxtx = 6 << 12; break;
|
||||
default: BUG();
|
||||
case 8:
|
||||
epn_rxtx = 0 << 12;
|
||||
break;
|
||||
case 16:
|
||||
epn_rxtx = 1 << 12;
|
||||
break;
|
||||
case 32:
|
||||
epn_rxtx = 2 << 12;
|
||||
break;
|
||||
case 64:
|
||||
epn_rxtx = 3 << 12;
|
||||
break;
|
||||
case 128:
|
||||
epn_rxtx = 4 << 12;
|
||||
break;
|
||||
case 256:
|
||||
epn_rxtx = 5 << 12;
|
||||
break;
|
||||
case 512:
|
||||
epn_rxtx = 6 << 12;
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
epn_rxtx |= UDC_EPN_RX_ISO;
|
||||
dbuf = 1;
|
||||
@ -2591,15 +2553,24 @@ omap_ep_setup(char *name, u8 addr, u8 type,
|
||||
* and ignored for PIO-IN on newer chips
|
||||
* (for more reliable behavior)
|
||||
*/
|
||||
if (!use_dma || cpu_is_omap15xx() || cpu_is_omap24xx())
|
||||
if (!use_dma || cpu_is_omap15xx())
|
||||
dbuf = 0;
|
||||
|
||||
switch (maxp) {
|
||||
case 8: epn_rxtx = 0 << 12; break;
|
||||
case 16: epn_rxtx = 1 << 12; break;
|
||||
case 32: epn_rxtx = 2 << 12; break;
|
||||
case 64: epn_rxtx = 3 << 12; break;
|
||||
default: BUG();
|
||||
case 8:
|
||||
epn_rxtx = 0 << 12;
|
||||
break;
|
||||
case 16:
|
||||
epn_rxtx = 1 << 12;
|
||||
break;
|
||||
case 32:
|
||||
epn_rxtx = 2 << 12;
|
||||
break;
|
||||
case 64:
|
||||
epn_rxtx = 3 << 12;
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
if (dbuf && addr)
|
||||
epn_rxtx |= UDC_EPN_RX_DB;
|
||||
@ -2639,7 +2610,7 @@ omap_ep_setup(char *name, u8 addr, u8 type,
|
||||
ep->ep.name = ep->name;
|
||||
ep->ep.ops = &omap_ep_ops;
|
||||
ep->ep.maxpacket = ep->maxpacket = maxp;
|
||||
list_add_tail (&ep->ep.ep_list, &udc->gadget.ep_list);
|
||||
list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@ -2647,11 +2618,11 @@ omap_ep_setup(char *name, u8 addr, u8 type,
|
||||
static void omap_udc_release(struct device *dev)
|
||||
{
|
||||
complete(udc->done);
|
||||
kfree (udc);
|
||||
kfree(udc);
|
||||
udc = NULL;
|
||||
}
|
||||
|
||||
static int __init
|
||||
static int __devinit
|
||||
omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
|
||||
{
|
||||
unsigned tmp, buf;
|
||||
@ -2665,13 +2636,13 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
|
||||
omap_writew(0, UDC_TXDMA_CFG);
|
||||
|
||||
/* UDC_PULLUP_EN gates the chip clock */
|
||||
// OTG_SYSCON_1 |= DEV_IDLE_EN;
|
||||
/* OTG_SYSCON_1 |= DEV_IDLE_EN; */
|
||||
|
||||
udc = kzalloc(sizeof(*udc), GFP_KERNEL);
|
||||
if (!udc)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init (&udc->lock);
|
||||
spin_lock_init(&udc->lock);
|
||||
|
||||
udc->gadget.ops = &omap_gadget_ops;
|
||||
udc->gadget.ep0 = &udc->ep[0].ep;
|
||||
@ -2701,13 +2672,13 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
|
||||
omap_writew(0, UDC_EP_TX(tmp));
|
||||
}
|
||||
|
||||
#define OMAP_BULK_EP(name,addr) \
|
||||
#define OMAP_BULK_EP(name, addr) \
|
||||
buf = omap_ep_setup(name "-bulk", addr, \
|
||||
USB_ENDPOINT_XFER_BULK, buf, 64, 1);
|
||||
#define OMAP_INT_EP(name,addr, maxp) \
|
||||
#define OMAP_INT_EP(name, addr, maxp) \
|
||||
buf = omap_ep_setup(name "-int", addr, \
|
||||
USB_ENDPOINT_XFER_INT, buf, maxp, 0);
|
||||
#define OMAP_ISO_EP(name,addr, maxp) \
|
||||
#define OMAP_ISO_EP(name, addr, maxp) \
|
||||
buf = omap_ep_setup(name "-iso", addr, \
|
||||
USB_ENDPOINT_XFER_ISOC, buf, maxp, 1);
|
||||
|
||||
@ -2788,15 +2759,18 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init omap_udc_probe(struct platform_device *pdev)
|
||||
static int __devinit omap_udc_probe(struct platform_device *pdev)
|
||||
{
|
||||
int status = -ENODEV;
|
||||
int hmc;
|
||||
struct usb_phy *xceiv = NULL;
|
||||
const char *type = NULL;
|
||||
struct omap_usb_config *config = pdev->dev.platform_data;
|
||||
struct clk *dc_clk;
|
||||
struct clk *hhc_clk;
|
||||
struct clk *dc_clk = NULL;
|
||||
struct clk *hhc_clk = NULL;
|
||||
|
||||
if (cpu_is_omap7xx())
|
||||
use_dma = 0;
|
||||
|
||||
/* NOTE: "knows" the order of the resources! */
|
||||
if (!request_mem_region(pdev->resource[0].start,
|
||||
@ -2816,16 +2790,6 @@ static int __init omap_udc_probe(struct platform_device *pdev)
|
||||
udelay(100);
|
||||
}
|
||||
|
||||
if (cpu_is_omap24xx()) {
|
||||
dc_clk = clk_get(&pdev->dev, "usb_fck");
|
||||
hhc_clk = clk_get(&pdev->dev, "usb_l4_ick");
|
||||
BUG_ON(IS_ERR(dc_clk) || IS_ERR(hhc_clk));
|
||||
/* can't use omap_udc_enable_clock yet */
|
||||
clk_enable(dc_clk);
|
||||
clk_enable(hhc_clk);
|
||||
udelay(100);
|
||||
}
|
||||
|
||||
if (cpu_is_omap7xx()) {
|
||||
dc_clk = clk_get(&pdev->dev, "usb_dc_ck");
|
||||
hhc_clk = clk_get(&pdev->dev, "l3_ocpi_ck");
|
||||
@ -2875,14 +2839,6 @@ static int __init omap_udc_probe(struct platform_device *pdev)
|
||||
|
||||
hmc = HMC_1610;
|
||||
|
||||
if (cpu_is_omap24xx()) {
|
||||
/* this could be transceiverless in one of the
|
||||
* "we don't need to know" modes.
|
||||
*/
|
||||
type = "external";
|
||||
goto known;
|
||||
}
|
||||
|
||||
switch (hmc) {
|
||||
case 0: /* POWERUP DEFAULT == 0 */
|
||||
case 4:
|
||||
@ -2921,16 +2877,16 @@ bad_on_1710:
|
||||
goto cleanup0;
|
||||
}
|
||||
}
|
||||
known:
|
||||
|
||||
INFO("hmc mode %d, %s transceiver\n", hmc, type);
|
||||
|
||||
/* a "gadget" abstracts/virtualizes the controller */
|
||||
status = omap_udc_setup(pdev, xceiv);
|
||||
if (status) {
|
||||
if (status)
|
||||
goto cleanup0;
|
||||
}
|
||||
|
||||
xceiv = NULL;
|
||||
// "udc" is now valid
|
||||
/* "udc" is now valid */
|
||||
pullup_disable(udc);
|
||||
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
|
||||
udc->gadget.is_otg = (config->otg != 0);
|
||||
@ -2944,7 +2900,7 @@ known:
|
||||
|
||||
/* USB general purpose IRQ: ep0, state changes, dma, etc */
|
||||
status = request_irq(pdev->resource[1].start, omap_udc_irq,
|
||||
IRQF_SAMPLE_RANDOM, driver_name, udc);
|
||||
0, driver_name, udc);
|
||||
if (status != 0) {
|
||||
ERR("can't get irq %d, err %d\n",
|
||||
(int) pdev->resource[1].start, status);
|
||||
@ -2953,7 +2909,7 @@ known:
|
||||
|
||||
/* USB "non-iso" IRQ (PIO for all but ep0) */
|
||||
status = request_irq(pdev->resource[2].start, omap_udc_pio_irq,
|
||||
IRQF_SAMPLE_RANDOM, "omap_udc pio", udc);
|
||||
0, "omap_udc pio", udc);
|
||||
if (status != 0) {
|
||||
ERR("can't get irq %d, err %d\n",
|
||||
(int) pdev->resource[2].start, status);
|
||||
@ -2975,16 +2931,6 @@ known:
|
||||
clk_disable(dc_clk);
|
||||
}
|
||||
|
||||
if (cpu_is_omap24xx()) {
|
||||
udc->dc_clk = dc_clk;
|
||||
udc->hhc_clk = hhc_clk;
|
||||
/* FIXME OMAP2 don't release hhc & dc clock */
|
||||
#if 0
|
||||
clk_disable(hhc_clk);
|
||||
clk_disable(dc_clk);
|
||||
#endif
|
||||
}
|
||||
|
||||
create_proc_file();
|
||||
status = device_add(&udc->gadget.dev);
|
||||
if (status)
|
||||
@ -3006,14 +2952,14 @@ cleanup2:
|
||||
free_irq(pdev->resource[1].start, udc);
|
||||
|
||||
cleanup1:
|
||||
kfree (udc);
|
||||
kfree(udc);
|
||||
udc = NULL;
|
||||
|
||||
cleanup0:
|
||||
if (xceiv)
|
||||
usb_put_transceiver(xceiv);
|
||||
|
||||
if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) {
|
||||
if (cpu_is_omap16xx() || cpu_is_omap7xx()) {
|
||||
clk_disable(hhc_clk);
|
||||
clk_disable(dc_clk);
|
||||
clk_put(hhc_clk);
|
||||
@ -3026,7 +2972,7 @@ cleanup0:
|
||||
return status;
|
||||
}
|
||||
|
||||
static int __exit omap_udc_remove(struct platform_device *pdev)
|
||||
static int __devexit omap_udc_remove(struct platform_device *pdev)
|
||||
{
|
||||
DECLARE_COMPLETION_ONSTACK(done);
|
||||
|
||||
@ -3111,7 +3057,8 @@ static int omap_udc_resume(struct platform_device *dev)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
static struct platform_driver udc_driver = {
|
||||
.remove = __exit_p(omap_udc_remove),
|
||||
.probe = omap_udc_probe,
|
||||
.remove = __devexit_p(omap_udc_remove),
|
||||
.suspend = omap_udc_suspend,
|
||||
.resume = omap_udc_resume,
|
||||
.driver = {
|
||||
@ -3120,27 +3067,7 @@ static struct platform_driver udc_driver = {
|
||||
},
|
||||
};
|
||||
|
||||
static int __init udc_init(void)
|
||||
{
|
||||
/* Disable DMA for omap7xx -- it doesn't work right. */
|
||||
if (cpu_is_omap7xx())
|
||||
use_dma = 0;
|
||||
|
||||
INFO("%s, version: " DRIVER_VERSION
|
||||
#ifdef USE_ISO
|
||||
" (iso)"
|
||||
#endif
|
||||
"%s\n", driver_desc,
|
||||
use_dma ? " (dma)" : "");
|
||||
return platform_driver_probe(&udc_driver, omap_udc_probe);
|
||||
}
|
||||
module_init(udc_init);
|
||||
|
||||
static void __exit udc_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&udc_driver);
|
||||
}
|
||||
module_exit(udc_exit);
|
||||
module_platform_driver(udc_driver);
|
||||
|
||||
MODULE_DESCRIPTION(DRIVER_DESC);
|
||||
MODULE_LICENSE("GPL");
|
||||
|
@ -2208,7 +2208,7 @@ static void pch_udc_complete_receiver(struct pch_udc_ep *ep)
|
||||
return;
|
||||
}
|
||||
if ((td->status & PCH_UDC_BUFF_STS) == PCH_UDC_BS_DMA_DONE)
|
||||
if (td->status | PCH_UDC_DMA_LAST) {
|
||||
if (td->status & PCH_UDC_DMA_LAST) {
|
||||
count = td->status & PCH_UDC_RXTX_BYTES;
|
||||
break;
|
||||
}
|
||||
|
@ -112,7 +112,6 @@ struct s3c_hsotg_ep {
|
||||
struct s3c_hsotg_req *req;
|
||||
struct dentry *debugfs;
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
unsigned long total_data;
|
||||
unsigned int size_loaded;
|
||||
@ -136,7 +135,6 @@ struct s3c_hsotg_ep {
|
||||
* @driver: USB gadget driver
|
||||
* @plat: The platform specific configuration data.
|
||||
* @regs: The memory area mapped for accessing registers.
|
||||
* @regs_res: The resource that was allocated when claiming register space.
|
||||
* @irq: The IRQ number we are using
|
||||
* @supplies: Definition of USB power supplies
|
||||
* @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
|
||||
@ -157,8 +155,9 @@ struct s3c_hsotg {
|
||||
struct usb_gadget_driver *driver;
|
||||
struct s3c_hsotg_plat *plat;
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
void __iomem *regs;
|
||||
struct resource *regs_res;
|
||||
int irq;
|
||||
struct clk *clk;
|
||||
|
||||
@ -896,7 +895,6 @@ static int s3c_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req,
|
||||
struct s3c_hsotg_req *hs_req = our_req(req);
|
||||
struct s3c_hsotg_ep *hs_ep = our_ep(ep);
|
||||
struct s3c_hsotg *hs = hs_ep->parent;
|
||||
unsigned long irqflags;
|
||||
bool first;
|
||||
|
||||
dev_dbg(hs->dev, "%s: req %p: %d@%p, noi=%d, zero=%d, snok=%d\n",
|
||||
@ -915,19 +913,30 @@ static int s3c_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&hs_ep->lock, irqflags);
|
||||
|
||||
first = list_empty(&hs_ep->queue);
|
||||
list_add_tail(&hs_req->queue, &hs_ep->queue);
|
||||
|
||||
if (first)
|
||||
s3c_hsotg_start_req(hs, hs_ep, hs_req, false);
|
||||
|
||||
spin_unlock_irqrestore(&hs_ep->lock, irqflags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s3c_hsotg_ep_queue_lock(struct usb_ep *ep, struct usb_request *req,
|
||||
gfp_t gfp_flags)
|
||||
{
|
||||
struct s3c_hsotg_ep *hs_ep = our_ep(ep);
|
||||
struct s3c_hsotg *hs = hs_ep->parent;
|
||||
unsigned long flags = 0;
|
||||
int ret = 0;
|
||||
|
||||
spin_lock_irqsave(&hs->lock, flags);
|
||||
ret = s3c_hsotg_ep_queue(ep, req, gfp_flags);
|
||||
spin_unlock_irqrestore(&hs->lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void s3c_hsotg_ep_free_request(struct usb_ep *ep,
|
||||
struct usb_request *req)
|
||||
{
|
||||
@ -1383,9 +1392,9 @@ static void s3c_hsotg_complete_request(struct s3c_hsotg *hsotg,
|
||||
*/
|
||||
|
||||
if (hs_req->req.complete) {
|
||||
spin_unlock(&hs_ep->lock);
|
||||
spin_unlock(&hsotg->lock);
|
||||
hs_req->req.complete(&hs_ep->ep, &hs_req->req);
|
||||
spin_lock(&hs_ep->lock);
|
||||
spin_lock(&hsotg->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1403,28 +1412,6 @@ static void s3c_hsotg_complete_request(struct s3c_hsotg *hsotg,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* s3c_hsotg_complete_request_lock - complete a request given to us (locked)
|
||||
* @hsotg: The device state.
|
||||
* @hs_ep: The endpoint the request was on.
|
||||
* @hs_req: The request to complete.
|
||||
* @result: The result code (0 => Ok, otherwise errno)
|
||||
*
|
||||
* See s3c_hsotg_complete_request(), but called with the endpoint's
|
||||
* lock held.
|
||||
*/
|
||||
static void s3c_hsotg_complete_request_lock(struct s3c_hsotg *hsotg,
|
||||
struct s3c_hsotg_ep *hs_ep,
|
||||
struct s3c_hsotg_req *hs_req,
|
||||
int result)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&hs_ep->lock, flags);
|
||||
s3c_hsotg_complete_request(hsotg, hs_ep, hs_req, result);
|
||||
spin_unlock_irqrestore(&hs_ep->lock, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* s3c_hsotg_rx_data - receive data from the FIFO for an endpoint
|
||||
* @hsotg: The device state.
|
||||
@ -1444,6 +1431,7 @@ static void s3c_hsotg_rx_data(struct s3c_hsotg *hsotg, int ep_idx, int size)
|
||||
int max_req;
|
||||
int read_ptr;
|
||||
|
||||
|
||||
if (!hs_req) {
|
||||
u32 epctl = readl(hsotg->regs + DOEPCTL(ep_idx));
|
||||
int ptr;
|
||||
@ -1459,8 +1447,6 @@ static void s3c_hsotg_rx_data(struct s3c_hsotg *hsotg, int ep_idx, int size)
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock(&hs_ep->lock);
|
||||
|
||||
to_read = size;
|
||||
read_ptr = hs_req->req.actual;
|
||||
max_req = hs_req->req.length - read_ptr;
|
||||
@ -1487,8 +1473,6 @@ static void s3c_hsotg_rx_data(struct s3c_hsotg *hsotg, int ep_idx, int size)
|
||||
* alignment of the data.
|
||||
*/
|
||||
readsl(fifo, hs_req->req.buf + read_ptr, to_read);
|
||||
|
||||
spin_unlock(&hs_ep->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1609,7 +1593,7 @@ static void s3c_hsotg_handle_outdone(struct s3c_hsotg *hsotg,
|
||||
s3c_hsotg_send_zlp(hsotg, hs_req);
|
||||
}
|
||||
|
||||
s3c_hsotg_complete_request_lock(hsotg, hs_ep, hs_req, result);
|
||||
s3c_hsotg_complete_request(hsotg, hs_ep, hs_req, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1864,7 +1848,7 @@ static void s3c_hsotg_complete_in(struct s3c_hsotg *hsotg,
|
||||
/* Finish ZLP handling for IN EP0 transactions */
|
||||
if (hsotg->eps[0].sent_zlp) {
|
||||
dev_dbg(hsotg->dev, "zlp packet received\n");
|
||||
s3c_hsotg_complete_request_lock(hsotg, hs_ep, hs_req, 0);
|
||||
s3c_hsotg_complete_request(hsotg, hs_ep, hs_req, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1915,7 +1899,7 @@ static void s3c_hsotg_complete_in(struct s3c_hsotg *hsotg,
|
||||
dev_dbg(hsotg->dev, "%s trying more for req...\n", __func__);
|
||||
s3c_hsotg_start_req(hsotg, hs_ep, hs_req, true);
|
||||
} else
|
||||
s3c_hsotg_complete_request_lock(hsotg, hs_ep, hs_req, 0);
|
||||
s3c_hsotg_complete_request(hsotg, hs_ep, hs_req, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2123,9 +2107,6 @@ static void kill_all_requests(struct s3c_hsotg *hsotg,
|
||||
int result, bool force)
|
||||
{
|
||||
struct s3c_hsotg_req *req, *treq;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&ep->lock, flags);
|
||||
|
||||
list_for_each_entry_safe(req, treq, &ep->queue, queue) {
|
||||
/*
|
||||
@ -2139,14 +2120,15 @@ static void kill_all_requests(struct s3c_hsotg *hsotg,
|
||||
s3c_hsotg_complete_request(hsotg, ep, req,
|
||||
result);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&ep->lock, flags);
|
||||
}
|
||||
|
||||
#define call_gadget(_hs, _entry) \
|
||||
if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \
|
||||
(_hs)->driver && (_hs)->driver->_entry) \
|
||||
(_hs)->driver->_entry(&(_hs)->gadget);
|
||||
(_hs)->driver && (_hs)->driver->_entry) { \
|
||||
spin_unlock(&_hs->lock); \
|
||||
(_hs)->driver->_entry(&(_hs)->gadget); \
|
||||
spin_lock(&_hs->lock); \
|
||||
}
|
||||
|
||||
/**
|
||||
* s3c_hsotg_disconnect - disconnect service
|
||||
@ -2388,6 +2370,7 @@ static irqreturn_t s3c_hsotg_irq(int irq, void *pw)
|
||||
u32 gintsts;
|
||||
u32 gintmsk;
|
||||
|
||||
spin_lock(&hsotg->lock);
|
||||
irq_retry:
|
||||
gintsts = readl(hsotg->regs + GINTSTS);
|
||||
gintmsk = readl(hsotg->regs + GINTMSK);
|
||||
@ -2557,6 +2540,8 @@ irq_retry:
|
||||
if (gintsts & IRQ_RETRY_MASK && --retry_count > 0)
|
||||
goto irq_retry;
|
||||
|
||||
spin_unlock(&hsotg->lock);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@ -2604,7 +2589,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
|
||||
dev_dbg(hsotg->dev, "%s: read DxEPCTL=0x%08x from 0x%08x\n",
|
||||
__func__, epctrl, epctrl_reg);
|
||||
|
||||
spin_lock_irqsave(&hs_ep->lock, flags);
|
||||
spin_lock_irqsave(&hsotg->lock, flags);
|
||||
|
||||
epctrl &= ~(DxEPCTL_EPType_MASK | DxEPCTL_MPS_MASK);
|
||||
epctrl |= DxEPCTL_MPS(mps);
|
||||
@ -2683,7 +2668,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
|
||||
s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1);
|
||||
|
||||
out:
|
||||
spin_unlock_irqrestore(&hs_ep->lock, flags);
|
||||
spin_unlock_irqrestore(&hsotg->lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2710,10 +2695,10 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep)
|
||||
|
||||
epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index);
|
||||
|
||||
spin_lock_irqsave(&hsotg->lock, flags);
|
||||
/* terminate all requests with shutdown */
|
||||
kill_all_requests(hsotg, hs_ep, -ESHUTDOWN, false);
|
||||
|
||||
spin_lock_irqsave(&hs_ep->lock, flags);
|
||||
|
||||
ctrl = readl(hsotg->regs + epctrl_reg);
|
||||
ctrl &= ~DxEPCTL_EPEna;
|
||||
@ -2726,7 +2711,7 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep)
|
||||
/* disable endpoint interrupts */
|
||||
s3c_hsotg_ctrl_epint(hsotg, hs_ep->index, hs_ep->dir_in, 0);
|
||||
|
||||
spin_unlock_irqrestore(&hs_ep->lock, flags);
|
||||
spin_unlock_irqrestore(&hsotg->lock, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2761,15 +2746,15 @@ static int s3c_hsotg_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
|
||||
|
||||
dev_info(hs->dev, "ep_dequeue(%p,%p)\n", ep, req);
|
||||
|
||||
spin_lock_irqsave(&hs_ep->lock, flags);
|
||||
spin_lock_irqsave(&hs->lock, flags);
|
||||
|
||||
if (!on_list(hs_ep, hs_req)) {
|
||||
spin_unlock_irqrestore(&hs_ep->lock, flags);
|
||||
spin_unlock_irqrestore(&hs->lock, flags);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
s3c_hsotg_complete_request(hs, hs_ep, hs_req, -ECONNRESET);
|
||||
spin_unlock_irqrestore(&hs_ep->lock, flags);
|
||||
spin_unlock_irqrestore(&hs->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2784,15 +2769,12 @@ static int s3c_hsotg_ep_sethalt(struct usb_ep *ep, int value)
|
||||
struct s3c_hsotg_ep *hs_ep = our_ep(ep);
|
||||
struct s3c_hsotg *hs = hs_ep->parent;
|
||||
int index = hs_ep->index;
|
||||
unsigned long irqflags;
|
||||
u32 epreg;
|
||||
u32 epctl;
|
||||
u32 xfertype;
|
||||
|
||||
dev_info(hs->dev, "%s(ep %p %s, %d)\n", __func__, ep, ep->name, value);
|
||||
|
||||
spin_lock_irqsave(&hs_ep->lock, irqflags);
|
||||
|
||||
/* write both IN and OUT control registers */
|
||||
|
||||
epreg = DIEPCTL(index);
|
||||
@ -2827,19 +2809,36 @@ static int s3c_hsotg_ep_sethalt(struct usb_ep *ep, int value)
|
||||
|
||||
writel(epctl, hs->regs + epreg);
|
||||
|
||||
spin_unlock_irqrestore(&hs_ep->lock, irqflags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* s3c_hsotg_ep_sethalt_lock - set halt on a given endpoint with lock held
|
||||
* @ep: The endpoint to set halt.
|
||||
* @value: Set or unset the halt.
|
||||
*/
|
||||
static int s3c_hsotg_ep_sethalt_lock(struct usb_ep *ep, int value)
|
||||
{
|
||||
struct s3c_hsotg_ep *hs_ep = our_ep(ep);
|
||||
struct s3c_hsotg *hs = hs_ep->parent;
|
||||
unsigned long flags = 0;
|
||||
int ret = 0;
|
||||
|
||||
spin_lock_irqsave(&hs->lock, flags);
|
||||
ret = s3c_hsotg_ep_sethalt(ep, value);
|
||||
spin_unlock_irqrestore(&hs->lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct usb_ep_ops s3c_hsotg_ep_ops = {
|
||||
.enable = s3c_hsotg_ep_enable,
|
||||
.disable = s3c_hsotg_ep_disable,
|
||||
.alloc_request = s3c_hsotg_ep_alloc_request,
|
||||
.free_request = s3c_hsotg_ep_free_request,
|
||||
.queue = s3c_hsotg_ep_queue,
|
||||
.queue = s3c_hsotg_ep_queue_lock,
|
||||
.dequeue = s3c_hsotg_ep_dequeue,
|
||||
.set_halt = s3c_hsotg_ep_sethalt,
|
||||
.set_halt = s3c_hsotg_ep_sethalt_lock,
|
||||
/* note, don't believe we have any call for the fifo routines */
|
||||
};
|
||||
|
||||
@ -2954,6 +2953,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
|
||||
driver->driver.bus = NULL;
|
||||
hsotg->driver = driver;
|
||||
hsotg->gadget.dev.driver = &driver->driver;
|
||||
hsotg->gadget.dev.of_node = hsotg->dev->of_node;
|
||||
hsotg->gadget.dev.dma_mask = hsotg->dev->dma_mask;
|
||||
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
|
||||
@ -2964,9 +2964,6 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
|
||||
goto err;
|
||||
}
|
||||
|
||||
s3c_hsotg_phy_enable(hsotg);
|
||||
|
||||
s3c_hsotg_core_init(hsotg);
|
||||
hsotg->last_rst = jiffies;
|
||||
dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name);
|
||||
return 0;
|
||||
@ -2988,6 +2985,7 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
|
||||
struct usb_gadget_driver *driver)
|
||||
{
|
||||
struct s3c_hsotg *hsotg = to_hsotg(gadget);
|
||||
unsigned long flags = 0;
|
||||
int ep;
|
||||
|
||||
if (!hsotg)
|
||||
@ -3000,6 +2998,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
|
||||
for (ep = 0; ep < hsotg->num_of_eps; ep++)
|
||||
s3c_hsotg_ep_disable(&hsotg->eps[ep].ep);
|
||||
|
||||
spin_lock_irqsave(&hsotg->lock, flags);
|
||||
|
||||
s3c_hsotg_phy_disable(hsotg);
|
||||
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
|
||||
|
||||
@ -3007,6 +3007,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
|
||||
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
hsotg->gadget.dev.driver = NULL;
|
||||
|
||||
spin_unlock_irqrestore(&hsotg->lock, flags);
|
||||
|
||||
dev_info(hsotg->dev, "unregistered gadget driver '%s'\n",
|
||||
driver->driver.name);
|
||||
|
||||
@ -3024,10 +3026,40 @@ static int s3c_hsotg_gadget_getframe(struct usb_gadget *gadget)
|
||||
return s3c_hsotg_read_frameno(to_hsotg(gadget));
|
||||
}
|
||||
|
||||
/**
|
||||
* s3c_hsotg_pullup - connect/disconnect the USB PHY
|
||||
* @gadget: The usb gadget state
|
||||
* @is_on: Current state of the USB PHY
|
||||
*
|
||||
* Connect/Disconnect the USB PHY pullup
|
||||
*/
|
||||
static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on)
|
||||
{
|
||||
struct s3c_hsotg *hsotg = to_hsotg(gadget);
|
||||
unsigned long flags = 0;
|
||||
|
||||
dev_dbg(hsotg->dev, "%s: is_in: %d\n", __func__, is_on);
|
||||
|
||||
spin_lock_irqsave(&hsotg->lock, flags);
|
||||
if (is_on) {
|
||||
s3c_hsotg_phy_enable(hsotg);
|
||||
s3c_hsotg_core_init(hsotg);
|
||||
} else {
|
||||
s3c_hsotg_disconnect(hsotg);
|
||||
s3c_hsotg_phy_disable(hsotg);
|
||||
}
|
||||
|
||||
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
spin_unlock_irqrestore(&hsotg->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct usb_gadget_ops s3c_hsotg_gadget_ops = {
|
||||
.get_frame = s3c_hsotg_gadget_getframe,
|
||||
.udc_start = s3c_hsotg_udc_start,
|
||||
.udc_stop = s3c_hsotg_udc_stop,
|
||||
.pullup = s3c_hsotg_pullup,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -3063,8 +3095,6 @@ static void __devinit s3c_hsotg_initep(struct s3c_hsotg *hsotg,
|
||||
INIT_LIST_HEAD(&hs_ep->queue);
|
||||
INIT_LIST_HEAD(&hs_ep->ep.ep_list);
|
||||
|
||||
spin_lock_init(&hs_ep->lock);
|
||||
|
||||
/* add to the list of endpoints known by the gadget driver */
|
||||
if (epnum)
|
||||
list_add_tail(&hs_ep->ep.ep_list, &hsotg->gadget.ep_list);
|
||||
@ -3342,7 +3372,7 @@ static int ep_show(struct seq_file *seq, void *v)
|
||||
seq_printf(seq, "request list (%p,%p):\n",
|
||||
ep->queue.next, ep->queue.prev);
|
||||
|
||||
spin_lock_irqsave(&ep->lock, flags);
|
||||
spin_lock_irqsave(&hsotg->lock, flags);
|
||||
|
||||
list_for_each_entry(req, &ep->queue, queue) {
|
||||
if (--show_limit < 0) {
|
||||
@ -3357,7 +3387,7 @@ static int ep_show(struct seq_file *seq, void *v)
|
||||
req->req.actual, req->req.status);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&ep->lock, flags);
|
||||
spin_unlock_irqrestore(&hsotg->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -3477,7 +3507,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hsotg = kzalloc(sizeof(struct s3c_hsotg), GFP_KERNEL);
|
||||
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
|
||||
if (!hsotg) {
|
||||
dev_err(dev, "cannot get memory\n");
|
||||
return -ENOMEM;
|
||||
@ -3489,46 +3519,35 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
|
||||
hsotg->clk = clk_get(&pdev->dev, "otg");
|
||||
if (IS_ERR(hsotg->clk)) {
|
||||
dev_err(dev, "cannot get otg clock\n");
|
||||
ret = PTR_ERR(hsotg->clk);
|
||||
goto err_mem;
|
||||
return PTR_ERR(hsotg->clk);
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, hsotg);
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res) {
|
||||
dev_err(dev, "cannot find register resource 0\n");
|
||||
ret = -EINVAL;
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
hsotg->regs_res = request_mem_region(res->start, resource_size(res),
|
||||
dev_name(dev));
|
||||
if (!hsotg->regs_res) {
|
||||
dev_err(dev, "cannot reserve registers\n");
|
||||
ret = -ENOENT;
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
hsotg->regs = ioremap(res->start, resource_size(res));
|
||||
hsotg->regs = devm_request_and_ioremap(&pdev->dev, res);
|
||||
if (!hsotg->regs) {
|
||||
dev_err(dev, "cannot map registers\n");
|
||||
ret = -ENXIO;
|
||||
goto err_regs_res;
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
ret = platform_get_irq(pdev, 0);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "cannot find IRQ\n");
|
||||
goto err_regs;
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
spin_lock_init(&hsotg->lock);
|
||||
|
||||
hsotg->irq = ret;
|
||||
|
||||
ret = request_irq(ret, s3c_hsotg_irq, 0, dev_name(dev), hsotg);
|
||||
ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
|
||||
dev_name(dev), hsotg);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "cannot claim IRQ\n");
|
||||
goto err_regs;
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq);
|
||||
@ -3558,7 +3577,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
|
||||
hsotg->supplies);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to request supplies: %d\n", ret);
|
||||
goto err_irq;
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
|
||||
@ -3642,19 +3661,11 @@ err_ep_mem:
|
||||
err_supplies:
|
||||
s3c_hsotg_phy_disable(hsotg);
|
||||
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
|
||||
err_irq:
|
||||
free_irq(hsotg->irq, hsotg);
|
||||
err_regs:
|
||||
iounmap(hsotg->regs);
|
||||
|
||||
err_regs_res:
|
||||
release_resource(hsotg->regs_res);
|
||||
kfree(hsotg->regs_res);
|
||||
err_clk:
|
||||
clk_disable_unprepare(hsotg->clk);
|
||||
clk_put(hsotg->clk);
|
||||
err_mem:
|
||||
kfree(hsotg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3675,12 +3686,6 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
|
||||
usb_gadget_unregister_driver(hsotg->driver);
|
||||
}
|
||||
|
||||
free_irq(hsotg->irq, hsotg);
|
||||
iounmap(hsotg->regs);
|
||||
|
||||
release_resource(hsotg->regs_res);
|
||||
kfree(hsotg->regs_res);
|
||||
|
||||
s3c_hsotg_phy_disable(hsotg);
|
||||
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
|
||||
|
||||
|
@ -37,12 +37,6 @@
|
||||
* When FSG_NO_OTG is defined fsg_otg_desc won't be defined.
|
||||
*/
|
||||
|
||||
/*
|
||||
* When FSG_BUFFHD_STATIC_BUFFER is defined when this file is included
|
||||
* the fsg_buffhd structure's buf field will be an array of FSG_BUFLEN
|
||||
* characters rather then a pointer to void.
|
||||
*/
|
||||
|
||||
/*
|
||||
* When USB_GADGET_DEBUG_FILES is defined the module param num_buffers
|
||||
* sets the number of pipeline buffers (length of the fsg_buffhd array).
|
||||
@ -260,11 +254,7 @@ enum fsg_buffer_state {
|
||||
};
|
||||
|
||||
struct fsg_buffhd {
|
||||
#ifdef FSG_BUFFHD_STATIC_BUFFER
|
||||
char buf[FSG_BUFLEN];
|
||||
#else
|
||||
void *buf;
|
||||
#endif
|
||||
enum fsg_buffer_state state;
|
||||
struct fsg_buffhd *next;
|
||||
|
||||
@ -627,6 +617,16 @@ static struct usb_gadget_strings fsg_stringtab = {
|
||||
* the caller must own fsg->filesem for writing.
|
||||
*/
|
||||
|
||||
static void fsg_lun_close(struct fsg_lun *curlun)
|
||||
{
|
||||
if (curlun->filp) {
|
||||
LDBG(curlun, "close backing file\n");
|
||||
fput(curlun->filp);
|
||||
curlun->filp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
|
||||
{
|
||||
int ro;
|
||||
@ -636,6 +636,8 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
|
||||
loff_t size;
|
||||
loff_t num_sectors;
|
||||
loff_t min_sectors;
|
||||
unsigned int blkbits;
|
||||
unsigned int blksize;
|
||||
|
||||
/* R/W if we can, R/O if we must */
|
||||
ro = curlun->initially_ro;
|
||||
@ -680,17 +682,17 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
|
||||
}
|
||||
|
||||
if (curlun->cdrom) {
|
||||
curlun->blksize = 2048;
|
||||
curlun->blkbits = 11;
|
||||
blksize = 2048;
|
||||
blkbits = 11;
|
||||
} else if (inode->i_bdev) {
|
||||
curlun->blksize = bdev_logical_block_size(inode->i_bdev);
|
||||
curlun->blkbits = blksize_bits(curlun->blksize);
|
||||
blksize = bdev_logical_block_size(inode->i_bdev);
|
||||
blkbits = blksize_bits(blksize);
|
||||
} else {
|
||||
curlun->blksize = 512;
|
||||
curlun->blkbits = 9;
|
||||
blksize = 512;
|
||||
blkbits = 9;
|
||||
}
|
||||
|
||||
num_sectors = size >> curlun->blkbits; /* File size in logic-block-size blocks */
|
||||
num_sectors = size >> blkbits; /* File size in logic-block-size blocks */
|
||||
min_sectors = 1;
|
||||
if (curlun->cdrom) {
|
||||
min_sectors = 300; /* Smallest track is 300 frames */
|
||||
@ -707,7 +709,12 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fsg_lun_is_open(curlun))
|
||||
fsg_lun_close(curlun);
|
||||
|
||||
get_file(filp);
|
||||
curlun->blksize = blksize;
|
||||
curlun->blkbits = blkbits;
|
||||
curlun->ro = ro;
|
||||
curlun->filp = filp;
|
||||
curlun->file_length = size;
|
||||
@ -721,16 +728,6 @@ out:
|
||||
}
|
||||
|
||||
|
||||
static void fsg_lun_close(struct fsg_lun *curlun)
|
||||
{
|
||||
if (curlun->filp) {
|
||||
LDBG(curlun, "close backing file\n");
|
||||
fput(curlun->filp);
|
||||
curlun->filp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
@ -881,19 +878,17 @@ static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr,
|
||||
if (count > 0 && buf[count-1] == '\n')
|
||||
((char *) buf)[count-1] = 0; /* Ugh! */
|
||||
|
||||
/* Eject current medium */
|
||||
down_write(filesem);
|
||||
if (fsg_lun_is_open(curlun)) {
|
||||
fsg_lun_close(curlun);
|
||||
curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
|
||||
}
|
||||
|
||||
/* Load new medium */
|
||||
down_write(filesem);
|
||||
if (count > 0 && buf[0]) {
|
||||
/* fsg_lun_open() will close existing file if any. */
|
||||
rc = fsg_lun_open(curlun, buf);
|
||||
if (rc == 0)
|
||||
curlun->unit_attention_data =
|
||||
SS_NOT_READY_TO_READY_TRANSITION;
|
||||
} else if (fsg_lun_is_open(curlun)) {
|
||||
fsg_lun_close(curlun);
|
||||
curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
|
||||
}
|
||||
up_write(filesem);
|
||||
return (rc < 0 ? rc : count);
|
||||
|
@ -798,12 +798,6 @@ int gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
|
||||
|
||||
SET_ETHTOOL_OPS(net, &ops);
|
||||
|
||||
/* two kinds of host-initiated state changes:
|
||||
* - iff DATA transfer is active, carrier is "on"
|
||||
* - tx queueing enabled if open *and* carrier is "on"
|
||||
*/
|
||||
netif_carrier_off(net);
|
||||
|
||||
dev->gadget = g;
|
||||
SET_NETDEV_DEV(net, &g->dev);
|
||||
SET_NETDEV_DEVTYPE(net, &gadget_type);
|
||||
@ -817,6 +811,12 @@ int gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
|
||||
INFO(dev, "HOST MAC %pM\n", dev->host_mac);
|
||||
|
||||
the_dev = dev;
|
||||
|
||||
/* two kinds of host-initiated state changes:
|
||||
* - iff DATA transfer is active, carrier is "on"
|
||||
* - tx queueing enabled if open *and* carrier is "on"
|
||||
*/
|
||||
netif_carrier_off(net);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -153,9 +153,11 @@ struct uvc_device
|
||||
|
||||
/* Descriptors */
|
||||
struct {
|
||||
const struct uvc_descriptor_header * const *control;
|
||||
const struct uvc_descriptor_header * const *fs_control;
|
||||
const struct uvc_descriptor_header * const *ss_control;
|
||||
const struct uvc_descriptor_header * const *fs_streaming;
|
||||
const struct uvc_descriptor_header * const *hs_streaming;
|
||||
const struct uvc_descriptor_header * const *ss_streaming;
|
||||
} desc;
|
||||
|
||||
unsigned int control_intf;
|
||||
|
@ -272,7 +272,15 @@ static const struct uvc_color_matching_descriptor uvc_color_matching = {
|
||||
.bMatrixCoefficients = 4,
|
||||
};
|
||||
|
||||
static const struct uvc_descriptor_header * const uvc_control_cls[] = {
|
||||
static const struct uvc_descriptor_header * const uvc_fs_control_cls[] = {
|
||||
(const struct uvc_descriptor_header *) &uvc_control_header,
|
||||
(const struct uvc_descriptor_header *) &uvc_camera_terminal,
|
||||
(const struct uvc_descriptor_header *) &uvc_processing,
|
||||
(const struct uvc_descriptor_header *) &uvc_output_terminal,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct uvc_descriptor_header * const uvc_ss_control_cls[] = {
|
||||
(const struct uvc_descriptor_header *) &uvc_control_header,
|
||||
(const struct uvc_descriptor_header *) &uvc_camera_terminal,
|
||||
(const struct uvc_descriptor_header *) &uvc_processing,
|
||||
@ -304,6 +312,18 @@ static const struct uvc_descriptor_header * const uvc_hs_streaming_cls[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct uvc_descriptor_header * const uvc_ss_streaming_cls[] = {
|
||||
(const struct uvc_descriptor_header *) &uvc_input_header,
|
||||
(const struct uvc_descriptor_header *) &uvc_format_yuv,
|
||||
(const struct uvc_descriptor_header *) &uvc_frame_yuv_360p,
|
||||
(const struct uvc_descriptor_header *) &uvc_frame_yuv_720p,
|
||||
(const struct uvc_descriptor_header *) &uvc_format_mjpg,
|
||||
(const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p,
|
||||
(const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p,
|
||||
(const struct uvc_descriptor_header *) &uvc_color_matching,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* USB configuration
|
||||
*/
|
||||
@ -311,8 +331,9 @@ static const struct uvc_descriptor_header * const uvc_hs_streaming_cls[] = {
|
||||
static int __init
|
||||
webcam_config_bind(struct usb_configuration *c)
|
||||
{
|
||||
return uvc_bind_config(c, uvc_control_cls, uvc_fs_streaming_cls,
|
||||
uvc_hs_streaming_cls);
|
||||
return uvc_bind_config(c, uvc_fs_control_cls, uvc_ss_control_cls,
|
||||
uvc_fs_streaming_cls, uvc_hs_streaming_cls,
|
||||
uvc_ss_streaming_cls);
|
||||
}
|
||||
|
||||
static struct usb_configuration webcam_config_driver = {
|
||||
@ -373,7 +394,7 @@ static struct usb_composite_driver webcam_driver = {
|
||||
.name = "g_webcam",
|
||||
.dev = &webcam_device_descriptor,
|
||||
.strings = webcam_device_strings,
|
||||
.max_speed = USB_SPEED_HIGH,
|
||||
.max_speed = USB_SPEED_SUPER,
|
||||
.unbind = webcam_unbind,
|
||||
};
|
||||
|
||||
|
@ -1811,7 +1811,7 @@ static int imx21_remove(struct platform_device *pdev)
|
||||
usb_remove_hcd(hcd);
|
||||
|
||||
if (res != NULL) {
|
||||
clk_disable(imx21->clk);
|
||||
clk_disable_unprepare(imx21->clk);
|
||||
clk_put(imx21->clk);
|
||||
iounmap(imx21->regs);
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
@ -1884,7 +1884,7 @@ static int imx21_probe(struct platform_device *pdev)
|
||||
ret = clk_set_rate(imx21->clk, clk_round_rate(imx21->clk, 48000000));
|
||||
if (ret)
|
||||
goto failed_clock_set;
|
||||
ret = clk_enable(imx21->clk);
|
||||
ret = clk_prepare_enable(imx21->clk);
|
||||
if (ret)
|
||||
goto failed_clock_enable;
|
||||
|
||||
@ -1900,7 +1900,7 @@ static int imx21_probe(struct platform_device *pdev)
|
||||
return 0;
|
||||
|
||||
failed_add_hcd:
|
||||
clk_disable(imx21->clk);
|
||||
clk_disable_unprepare(imx21->clk);
|
||||
failed_clock_enable:
|
||||
failed_clock_set:
|
||||
clk_put(imx21->clk);
|
||||
|
Loading…
Reference in New Issue
Block a user