summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorRodrigo Vivi <rodrigo.vivi@intel.com>2022-12-30 04:09:09 -0500
committerRodrigo Vivi <rodrigo.vivi@intel.com>2022-12-30 04:18:36 -0500
commitb501d4dc83aa3940189b68045cadc8b3eac73988 (patch)
treee5310a4fafd59505c3db86bb05baf964cb8da944 /drivers/usb/gadget
parent4071d98b296a5bc5fd4b15ec651bd05800ec9510 (diff)
parent1b929c02afd37871d5afb9d498426f83432e71c2 (diff)
Merge drm/drm-next into drm-intel-gt-next
Sync after v6.2-rc1 landed in drm-next. We need to get some dependencies in place before we can merge the fixes series from Gwan-gyeong and Chris. References: https://lore.kernel.org/all/Y6x5JCDnh2rvh4lA@intel.com/ Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/configfs.c3
-rw-r--r--drivers/usb/gadget/function/f_ecm.c22
-rw-r--r--drivers/usb/gadget/function/f_hid.c60
-rw-r--r--drivers/usb/gadget/function/f_mass_storage.c3
-rw-r--r--drivers/usb/gadget/function/f_printer.c9
-rw-r--r--drivers/usb/gadget/function/f_uvc.c20
-rw-r--r--drivers/usb/gadget/function/storage_common.c9
-rw-r--r--drivers/usb/gadget/function/u_ether.c4
-rw-r--r--drivers/usb/gadget/function/u_serial.c3
-rw-r--r--drivers/usb/gadget/function/uvc_configfs.c12
-rw-r--r--drivers/usb/gadget/function/uvc_queue.c8
-rw-r--r--drivers/usb/gadget/function/uvc_v4l2.c72
-rw-r--r--drivers/usb/gadget/function/uvc_video.c25
-rw-r--r--drivers/usb/gadget/legacy/serial.c3
-rw-r--r--drivers/usb/gadget/legacy/webcam.c4
-rw-r--r--drivers/usb/gadget/udc/Kconfig15
-rw-r--r--drivers/usb/gadget/udc/Makefile1
-rw-r--r--drivers/usb/gadget/udc/aspeed-vhub/core.c2
-rw-r--r--drivers/usb/gadget/udc/aspeed-vhub/dev.c1
-rw-r--r--drivers/usb/gadget/udc/aspeed-vhub/epn.c16
-rw-r--r--drivers/usb/gadget/udc/at91_udc.c5
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_udc.c1
-rw-r--r--drivers/usb/gadget/udc/core.c16
-rw-r--r--drivers/usb/gadget/udc/fotg210-udc.c1224
-rw-r--r--drivers/usb/gadget/udc/fotg210.h249
-rw-r--r--drivers/usb/gadget/udc/m66592-udc.c2
26 files changed, 150 insertions, 1639 deletions
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 3a6b4926193e..96121d1c8df4 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -3,6 +3,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/device.h>
+#include <linux/kstrtox.h>
#include <linux/nls.h>
#include <linux/usb/composite.h>
#include <linux/usb/gadget_configfs.h>
@@ -800,7 +801,7 @@ static ssize_t os_desc_use_store(struct config_item *item, const char *page,
bool use;
mutex_lock(&gi->lock);
- ret = strtobool(page, &use);
+ ret = kstrtobool(page, &use);
if (!ret) {
gi->use_os_desc = use;
ret = len;
diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
index ffe2486fce71..a7ab30e603e2 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -685,7 +685,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
struct usb_composite_dev *cdev = c->cdev;
struct f_ecm *ecm = func_to_ecm(f);
struct usb_string *us;
- int status;
+ int status = 0;
struct usb_ep *ep;
struct f_ecm_opts *ecm_opts;
@@ -695,23 +695,19 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
ecm_opts = container_of(f->fi, struct f_ecm_opts, func_inst);
- /*
- * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
- * configurations are bound in sequence with list_for_each_entry,
- * in each configuration its functions are bound in sequence
- * with list_for_each_entry, so we assume no race condition
- * with regard to ecm_opts->bound access
- */
+ mutex_lock(&ecm_opts->lock);
+
+ gether_set_gadget(ecm_opts->net, cdev->gadget);
+
if (!ecm_opts->bound) {
- mutex_lock(&ecm_opts->lock);
- gether_set_gadget(ecm_opts->net, cdev->gadget);
status = gether_register_netdev(ecm_opts->net);
- mutex_unlock(&ecm_opts->lock);
- if (status)
- return status;
ecm_opts->bound = true;
}
+ mutex_unlock(&ecm_opts->lock);
+ if (status)
+ return status;
+
ecm_string_defs[1].s = ecm->ethaddr;
us = usb_gstrings_attach(cdev, ecm_strings,
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index ca0a7d9eaa34..a8da3b4a2855 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -71,7 +71,7 @@ struct f_hidg {
wait_queue_head_t write_queue;
struct usb_request *req;
- int minor;
+ struct device dev;
struct cdev cdev;
struct usb_function func;
@@ -84,6 +84,14 @@ static inline struct f_hidg *func_to_hidg(struct usb_function *f)
return container_of(f, struct f_hidg, func);
}
+static void hidg_release(struct device *dev)
+{
+ struct f_hidg *hidg = container_of(dev, struct f_hidg, dev);
+
+ kfree(hidg->set_report_buf);
+ kfree(hidg);
+}
+
/*-------------------------------------------------------------------------*/
/* Static descriptors */
@@ -904,9 +912,7 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
struct usb_ep *ep;
struct f_hidg *hidg = func_to_hidg(f);
struct usb_string *us;
- struct device *device;
int status;
- dev_t dev;
/* maybe allocate device-global string IDs, and patch descriptors */
us = usb_gstrings_attach(c->cdev, ct_func_strings,
@@ -999,21 +1005,11 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
/* create char device */
cdev_init(&hidg->cdev, &f_hidg_fops);
- dev = MKDEV(major, hidg->minor);
- status = cdev_add(&hidg->cdev, dev, 1);
+ status = cdev_device_add(&hidg->cdev, &hidg->dev);
if (status)
goto fail_free_descs;
- device = device_create(hidg_class, NULL, dev, NULL,
- "%s%d", "hidg", hidg->minor);
- if (IS_ERR(device)) {
- status = PTR_ERR(device);
- goto del;
- }
-
return 0;
-del:
- cdev_del(&hidg->cdev);
fail_free_descs:
usb_free_all_descriptors(f);
fail:
@@ -1244,9 +1240,7 @@ static void hidg_free(struct usb_function *f)
hidg = func_to_hidg(f);
opts = container_of(f->fi, struct f_hid_opts, func_inst);
- kfree(hidg->report_desc);
- kfree(hidg->set_report_buf);
- kfree(hidg);
+ put_device(&hidg->dev);
mutex_lock(&opts->lock);
--opts->refcnt;
mutex_unlock(&opts->lock);
@@ -1256,8 +1250,7 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f)
{
struct f_hidg *hidg = func_to_hidg(f);
- device_destroy(hidg_class, MKDEV(major, hidg->minor));
- cdev_del(&hidg->cdev);
+ cdev_device_del(&hidg->cdev, &hidg->dev);
usb_free_all_descriptors(f);
}
@@ -1266,6 +1259,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
{
struct f_hidg *hidg;
struct f_hid_opts *opts;
+ int ret;
/* allocate and initialize one new instance */
hidg = kzalloc(sizeof(*hidg), GFP_KERNEL);
@@ -1275,25 +1269,31 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
opts = container_of(fi, struct f_hid_opts, func_inst);
mutex_lock(&opts->lock);
- ++opts->refcnt;
- hidg->minor = opts->minor;
+ device_initialize(&hidg->dev);
+ hidg->dev.release = hidg_release;
+ hidg->dev.class = hidg_class;
+ hidg->dev.devt = MKDEV(major, opts->minor);
+ ret = dev_set_name(&hidg->dev, "hidg%d", opts->minor);
+ if (ret)
+ goto err_unlock;
+
hidg->bInterfaceSubClass = opts->subclass;
hidg->bInterfaceProtocol = opts->protocol;
hidg->report_length = opts->report_length;
hidg->report_desc_length = opts->report_desc_length;
if (opts->report_desc) {
- hidg->report_desc = kmemdup(opts->report_desc,
- opts->report_desc_length,
- GFP_KERNEL);
+ hidg->report_desc = devm_kmemdup(&hidg->dev, opts->report_desc,
+ opts->report_desc_length,
+ GFP_KERNEL);
if (!hidg->report_desc) {
- kfree(hidg);
- mutex_unlock(&opts->lock);
- return ERR_PTR(-ENOMEM);
+ ret = -ENOMEM;
+ goto err_put_device;
}
}
hidg->use_out_ep = !opts->no_out_endpoint;
+ ++opts->refcnt;
mutex_unlock(&opts->lock);
hidg->func.name = "hid";
@@ -1308,6 +1308,12 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
hidg->qlen = 4;
return &hidg->func;
+
+err_put_device:
+ put_device(&hidg->dev);
+err_unlock:
+ mutex_unlock(&opts->lock);
+ return ERR_PTR(ret);
}
DECLARE_USB_FUNCTION_INIT(hid, hidg_alloc_inst, hidg_alloc);
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 3abf7f586e2a..3a30feb47073 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -176,6 +176,7 @@
#include <linux/fcntl.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/kstrtox.h>
#include <linux/kthread.h>
#include <linux/sched/signal.h>
#include <linux/limits.h>
@@ -3387,7 +3388,7 @@ static ssize_t fsg_opts_stall_store(struct config_item *item, const char *page,
return -EBUSY;
}
- ret = strtobool(page, &stall);
+ ret = kstrtobool(page, &stall);
if (!ret) {
opts->common->can_stall = stall;
ret = len;
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index a881c69b1f2b..4903d761a872 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -364,7 +364,7 @@ printer_open(struct inode *inode, struct file *fd)
spin_unlock_irqrestore(&dev->lock, flags);
kref_get(&dev->kref);
- DBG(dev, "printer_open returned %x\n", ret);
+
return ret;
}
@@ -382,7 +382,6 @@ printer_close(struct inode *inode, struct file *fd)
spin_unlock_irqrestore(&dev->lock, flags);
kref_put(&dev->kref, printer_dev_free);
- DBG(dev, "printer_close\n");
return 0;
}
@@ -848,8 +847,6 @@ static void printer_reset_interface(struct printer_dev *dev)
if (dev->interface < 0)
return;
- DBG(dev, "%s\n", __func__);
-
if (dev->in_ep->desc)
usb_ep_disable(dev->in_ep);
@@ -887,8 +884,6 @@ static void printer_soft_reset(struct printer_dev *dev)
{
struct usb_request *req;
- INFO(dev, "Received Printer Reset Request\n");
-
if (usb_ep_disable(dev->in_ep))
DBG(dev, "Failed to disable USB in_ep\n");
if (usb_ep_disable(dev->out_ep))
@@ -1185,8 +1180,6 @@ static void printer_func_disable(struct usb_function *f)
{
struct printer_dev *dev = func_to_printer(f);
- DBG(dev, "%s\n", __func__);
-
printer_reset_interface(dev);
}
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 6e196e06181e..32f2c1645467 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -39,9 +39,6 @@ MODULE_PARM_DESC(trace, "Trace level bitmask");
/* string IDs are assigned dynamically */
-#define UVC_STRING_CONTROL_IDX 0
-#define UVC_STRING_STREAMING_IDX 1
-
static struct usb_string uvc_en_us_strings[] = {
/* [UVC_STRING_CONTROL_IDX].s = DYNAMIC, */
[UVC_STRING_STREAMING_IDX].s = "Video Streaming",
@@ -216,8 +213,9 @@ uvc_function_ep0_complete(struct usb_ep *ep, struct usb_request *req)
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_DATA;
- uvc_event->data.length = req->actual;
- memcpy(&uvc_event->data.data, req->buf, req->actual);
+ uvc_event->data.length = min_t(unsigned int, req->actual,
+ sizeof(uvc_event->data.data));
+ memcpy(&uvc_event->data.data, req->buf, uvc_event->data.length);
v4l2_event_queue(&uvc->vdev, &v4l2_event);
}
}
@@ -228,6 +226,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
struct uvc_device *uvc = to_uvc(f);
struct v4l2_event v4l2_event;
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
+ unsigned int interface = le16_to_cpu(ctrl->wIndex) & 0xff;
+ struct usb_ctrlrequest *mctrl;
if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) {
uvcg_info(f, "invalid request type\n");
@@ -248,6 +248,16 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_SETUP;
memcpy(&uvc_event->req, ctrl, sizeof(uvc_event->req));
+
+ /* check for the interface number, fixup the interface number in
+ * the ctrl request so the userspace doesn't have to bother with
+ * offset and configfs parsing
+ */
+ mctrl = &uvc_event->req;
+ mctrl->wIndex &= ~cpu_to_le16(0xff);
+ if (interface == uvc->streaming_intf)
+ mctrl->wIndex = cpu_to_le16(UVC_STRING_STREAMING_IDX);
+
v4l2_event_queue(&uvc->vdev, &v4l2_event);
return 0;
diff --git a/drivers/usb/gadget/function/storage_common.c b/drivers/usb/gadget/function/storage_common.c
index 208c6a92780a..2a4163b0f6fe 100644
--- a/drivers/usb/gadget/function/storage_common.c
+++ b/drivers/usb/gadget/function/storage_common.c
@@ -23,6 +23,7 @@
#include <linux/blkdev.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/kstrtox.h>
#include <linux/usb/composite.h>
#include "storage_common.h"
@@ -396,7 +397,7 @@ ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem,
ssize_t rc;
bool ro;
- rc = strtobool(buf, &ro);
+ rc = kstrtobool(buf, &ro);
if (rc)
return rc;
@@ -419,7 +420,7 @@ ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count)
bool nofua;
int ret;
- ret = strtobool(buf, &nofua);
+ ret = kstrtobool(buf, &nofua);
if (ret)
return ret;
@@ -470,7 +471,7 @@ ssize_t fsg_store_cdrom(struct fsg_lun *curlun, struct rw_semaphore *filesem,
bool cdrom;
int ret;
- ret = strtobool(buf, &cdrom);
+ ret = kstrtobool(buf, &cdrom);
if (ret)
return ret;
@@ -493,7 +494,7 @@ ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf,
bool removable;
int ret;
- ret = strtobool(buf, &removable);
+ ret = kstrtobool(buf, &removable);
if (ret)
return ret;
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index e06022873df1..8f12f3f8f6ee 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -798,7 +798,6 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
net->max_mtu = GETHER_MAX_MTU_SIZE;
dev->gadget = g;
- SET_NETDEV_DEV(net, &g->dev);
SET_NETDEV_DEVTYPE(net, &gadget_type);
status = register_netdev(net);
@@ -873,8 +872,6 @@ int gether_register_netdev(struct net_device *net)
struct usb_gadget *g;
int status;
- if (!net->dev.parent)
- return -EINVAL;
dev = netdev_priv(net);
g = dev->gadget;
@@ -905,7 +902,6 @@ void gether_set_gadget(struct net_device *net, struct usb_gadget *g)
dev = netdev_priv(net);
dev->gadget = g;
- SET_NETDEV_DEV(net, &g->dev);
}
EXPORT_SYMBOL_GPL(gether_set_gadget);
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 7538279f9817..840626e064e1 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -24,6 +24,7 @@
#include <linux/export.h>
#include <linux/module.h>
#include <linux/console.h>
+#include <linux/kstrtox.h>
#include <linux/kthread.h>
#include <linux/workqueue.h>
#include <linux/kfifo.h>
@@ -1070,7 +1071,7 @@ ssize_t gserial_set_console(unsigned char port_num, const char *page, size_t cou
bool enable;
int ret;
- ret = strtobool(page, &enable);
+ ret = kstrtobool(page, &enable);
if (ret)
return ret;
diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
index 4303a3283ba0..76cb60d13049 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -1512,7 +1512,7 @@ UVCG_UNCOMPRESSED_ATTR(b_bits_per_pixel, bBitsPerPixel, 8);
UVCG_UNCOMPRESSED_ATTR(b_default_frame_index, bDefaultFrameIndex, 8);
UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_x, bAspectRatioX, 8);
UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_y, bAspectRatioY, 8);
-UVCG_UNCOMPRESSED_ATTR_RO(bm_interface_flags, bmInterfaceFlags, 8);
+UVCG_UNCOMPRESSED_ATTR_RO(bm_interlace_flags, bmInterlaceFlags, 8);
#undef UVCG_UNCOMPRESSED_ATTR
#undef UVCG_UNCOMPRESSED_ATTR_RO
@@ -1541,7 +1541,7 @@ static struct configfs_attribute *uvcg_uncompressed_attrs[] = {
&uvcg_uncompressed_attr_b_default_frame_index,
&uvcg_uncompressed_attr_b_aspect_ratio_x,
&uvcg_uncompressed_attr_b_aspect_ratio_y,
- &uvcg_uncompressed_attr_bm_interface_flags,
+ &uvcg_uncompressed_attr_bm_interlace_flags,
&uvcg_uncompressed_attr_bma_controls,
NULL,
};
@@ -1574,7 +1574,7 @@ static struct config_group *uvcg_uncompressed_make(struct config_group *group,
h->desc.bDefaultFrameIndex = 1;
h->desc.bAspectRatioX = 0;
h->desc.bAspectRatioY = 0;
- h->desc.bmInterfaceFlags = 0;
+ h->desc.bmInterlaceFlags = 0;
h->desc.bCopyProtect = 0;
INIT_LIST_HEAD(&h->fmt.frames);
@@ -1700,7 +1700,7 @@ UVCG_MJPEG_ATTR(b_default_frame_index, bDefaultFrameIndex, 8);
UVCG_MJPEG_ATTR_RO(bm_flags, bmFlags, 8);
UVCG_MJPEG_ATTR_RO(b_aspect_ratio_x, bAspectRatioX, 8);
UVCG_MJPEG_ATTR_RO(b_aspect_ratio_y, bAspectRatioY, 8);
-UVCG_MJPEG_ATTR_RO(bm_interface_flags, bmInterfaceFlags, 8);
+UVCG_MJPEG_ATTR_RO(bm_interlace_flags, bmInterlaceFlags, 8);
#undef UVCG_MJPEG_ATTR
#undef UVCG_MJPEG_ATTR_RO
@@ -1728,7 +1728,7 @@ static struct configfs_attribute *uvcg_mjpeg_attrs[] = {
&uvcg_mjpeg_attr_bm_flags,
&uvcg_mjpeg_attr_b_aspect_ratio_x,
&uvcg_mjpeg_attr_b_aspect_ratio_y,
- &uvcg_mjpeg_attr_bm_interface_flags,
+ &uvcg_mjpeg_attr_bm_interlace_flags,
&uvcg_mjpeg_attr_bma_controls,
NULL,
};
@@ -1755,7 +1755,7 @@ static struct config_group *uvcg_mjpeg_make(struct config_group *group,
h->desc.bDefaultFrameIndex = 1;
h->desc.bAspectRatioX = 0;
h->desc.bAspectRatioY = 0;
- h->desc.bmInterfaceFlags = 0;
+ h->desc.bmInterlaceFlags = 0;
h->desc.bCopyProtect = 0;
INIT_LIST_HEAD(&h->fmt.frames);
diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
index ec500ee499ee..0aa3d7e1f3cc 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -304,6 +304,7 @@ int uvcg_queue_enable(struct uvc_video_queue *queue, int enable)
queue->sequence = 0;
queue->buf_used = 0;
+ queue->flags &= ~UVC_QUEUE_DROP_INCOMPLETE;
} else {
ret = vb2_streamoff(&queue->queue, queue->queue.type);
if (ret < 0)
@@ -329,10 +330,11 @@ int uvcg_queue_enable(struct uvc_video_queue *queue, int enable)
void uvcg_complete_buffer(struct uvc_video_queue *queue,
struct uvc_buffer *buf)
{
- if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) &&
- buf->length != buf->bytesused) {
- buf->state = UVC_BUF_STATE_QUEUED;
+ if (queue->flags & UVC_QUEUE_DROP_INCOMPLETE) {
+ queue->flags &= ~UVC_QUEUE_DROP_INCOMPLETE;
+ buf->state = UVC_BUF_STATE_ERROR;
vb2_set_plane_payload(&buf->buf.vb2_buf, 0, 0);
+ vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_ERROR);
return;
}
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index c4ed48d6b8a4..a189b08bba80 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -199,16 +199,6 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data)
* V4L2 ioctls
*/
-struct uvc_format {
- u8 bpp;
- u32 fcc;
-};
-
-static struct uvc_format uvc_formats[] = {
- { 16, V4L2_PIX_FMT_YUYV },
- { 0, V4L2_PIX_FMT_MJPEG },
-};
-
static int
uvc_v4l2_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
{
@@ -243,47 +233,6 @@ uvc_v4l2_get_format(struct file *file, void *fh, struct v4l2_format *fmt)
}
static int
-uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
-{
- struct video_device *vdev = video_devdata(file);
- struct uvc_device *uvc = video_get_drvdata(vdev);
- struct uvc_video *video = &uvc->video;
- struct uvc_format *format;
- unsigned int imagesize;
- unsigned int bpl;
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(uvc_formats); ++i) {
- format = &uvc_formats[i];
- if (format->fcc == fmt->fmt.pix.pixelformat)
- break;
- }
-
- if (i == ARRAY_SIZE(uvc_formats)) {
- uvcg_info(&uvc->func, "Unsupported format 0x%08x.\n",
- fmt->fmt.pix.pixelformat);
- return -EINVAL;
- }
-
- bpl = format->bpp * fmt->fmt.pix.width / 8;
- imagesize = bpl ? bpl * fmt->fmt.pix.height : fmt->fmt.pix.sizeimage;
-
- video->fcc = format->fcc;
- video->bpp = format->bpp;
- video->width = fmt->fmt.pix.width;
- video->height = fmt->fmt.pix.height;
- video->imagesize = imagesize;
-
- fmt->fmt.pix.field = V4L2_FIELD_NONE;
- fmt->fmt.pix.bytesperline = bpl;
- fmt->fmt.pix.sizeimage = imagesize;
- fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
- fmt->fmt.pix.priv = 0;
-
- return 0;
-}
-
-static int
uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
{
struct video_device *vdev = video_devdata(file);
@@ -324,6 +273,27 @@ uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
}
static int
+uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
+{
+ struct video_device *vdev = video_devdata(file);
+ struct uvc_device *uvc = video_get_drvdata(vdev);
+ struct uvc_video *video = &uvc->video;
+ int ret;
+
+ ret = uvc_v4l2_try_format(file, fh, fmt);
+ if (ret)
+ return ret;
+
+ video->fcc = fmt->fmt.pix.pixelformat;
+ video->bpp = fmt->fmt.pix.bytesperline * 8 / video->width;
+ video->width = fmt->fmt.pix.width;
+ video->height = fmt->fmt.pix.height;
+ video->imagesize = fmt->fmt.pix.sizeimage;
+
+ return ret;
+}
+
+static int
uvc_v4l2_enum_frameintervals(struct file *file, void *fh,
struct v4l2_frmivalenum *fival)
{
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index bb037fcc90e6..dd1c6b2ca7c6 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -88,6 +88,7 @@ uvc_video_encode_bulk(struct usb_request *req, struct uvc_video *video,
struct uvc_buffer *buf)
{
void *mem = req->buf;
+ struct uvc_request *ureq = req->context;
int len = video->req_size;
int ret;
@@ -113,13 +114,14 @@ uvc_video_encode_bulk(struct usb_request *req, struct uvc_video *video,
video->queue.buf_used = 0;
buf->state = UVC_BUF_STATE_DONE;
list_del(&buf->queue);
- uvcg_complete_buffer(&video->queue, buf);
video->fid ^= UVC_STREAM_FID;
+ ureq->last_buf = buf;
video->payload_size = 0;
}
if (video->payload_size == video->max_payload_size ||
+ video->queue.flags & UVC_QUEUE_DROP_INCOMPLETE ||
buf->bytesused == video->queue.buf_used)
video->payload_size = 0;
}
@@ -155,10 +157,10 @@ uvc_video_encode_isoc_sg(struct usb_request *req, struct uvc_video *video,
sg = sg_next(sg);
for_each_sg(sg, iter, ureq->sgt.nents - 1, i) {
- if (!len || !buf->sg || !sg_dma_len(buf->sg))
+ if (!len || !buf->sg || !buf->sg->length)
break;
- sg_left = sg_dma_len(buf->sg) - buf->offset;
+ sg_left = buf->sg->length - buf->offset;
part = min_t(unsigned int, len, sg_left);
sg_set_page(iter, sg_page(buf->sg), part, buf->offset);
@@ -180,7 +182,8 @@ uvc_video_encode_isoc_sg(struct usb_request *req, struct uvc_video *video,
req->length -= len;
video->queue.buf_used += req->length - header_len;
- if (buf->bytesused == video->queue.buf_used || !buf->sg) {
+ if (buf->bytesused == video->queue.buf_used || !buf->sg ||
+ video->queue.flags & UVC_QUEUE_DROP_INCOMPLETE) {
video->queue.buf_used = 0;
buf->state = UVC_BUF_STATE_DONE;
buf->offset = 0;
@@ -195,6 +198,7 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video,
struct uvc_buffer *buf)
{
void *mem = req->buf;
+ struct uvc_request *ureq = req->context;
int len = video->req_size;
int ret;
@@ -209,12 +213,13 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video,
req->length = video->req_size - len;
- if (buf->bytesused == video->queue.buf_used) {
+ if (buf->bytesused == video->queue.buf_used ||
+ video->queue.flags & UVC_QUEUE_DROP_INCOMPLETE) {
video->queue.buf_used = 0;
buf->state = UVC_BUF_STATE_DONE;
list_del(&buf->queue);
- uvcg_complete_buffer(&video->queue, buf);
video->fid ^= UVC_STREAM_FID;
+ ureq->last_buf = buf;
}
}
@@ -255,6 +260,11 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
case 0:
break;
+ case -EXDEV:
+ uvcg_dbg(&video->uvc->func, "VS request missed xfer.\n");
+ queue->flags |= UVC_QUEUE_DROP_INCOMPLETE;
+ break;
+
case -ESHUTDOWN: /* disconnect from host. */
uvcg_dbg(&video->uvc->func, "VS request cancelled.\n");
uvcg_queue_cancel(queue, 1);
@@ -431,7 +441,8 @@ static void uvcg_video_pump(struct work_struct *work)
/* Endpoint now owns the request */
req = NULL;
- video->req_int_count++;
+ if (buf->state != UVC_BUF_STATE_DONE)
+ video->req_int_count++;
}
if (!req)
diff --git a/drivers/usb/gadget/legacy/serial.c b/drivers/usb/gadget/legacy/serial.c
index dcd3a6603d90..4974bee6049a 100644
--- a/drivers/usb/gadget/legacy/serial.c
+++ b/drivers/usb/gadget/legacy/serial.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/device.h>
+#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
@@ -109,7 +110,7 @@ static int enable_set(const char *s, const struct kernel_param *kp)
if (!s) /* called for no-arg enable == default */
return 0;
- ret = strtobool(s, &do_enable);
+ ret = kstrtobool(s, &do_enable);
if (ret || enable == do_enable)
return ret;
diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c
index 94e22867da1d..53e38f87472b 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -171,7 +171,7 @@ static const struct uvc_format_uncompressed uvc_format_yuv = {
.bDefaultFrameIndex = 1,
.bAspectRatioX = 0,
.bAspectRatioY = 0,
- .bmInterfaceFlags = 0,
+ .bmInterlaceFlags = 0,
.bCopyProtect = 0,
};
@@ -222,7 +222,7 @@ static const struct uvc_format_mjpeg uvc_format_mjpg = {
.bDefaultFrameIndex = 1,
.bAspectRatioX = 0,
.bAspectRatioY = 0,
- .bmInterfaceFlags = 0,
+ .bmInterlaceFlags = 0,
.bCopyProtect = 0,
};
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 5756acb07b8d..b3006d8b04ab 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -33,7 +33,7 @@ menu "USB Peripheral Controller"
config USB_AT91
tristate "Atmel AT91 USB Device Port"
depends on ARCH_AT91
- depends on OF || COMPILE_TEST
+ depends on OF
help
Many Atmel AT91 processors (such as the AT91RM2000) have a
full speed USB Device Port with support for five configurable
@@ -108,17 +108,6 @@ config USB_FUSB300
help
Faraday usb device controller FUSB300 driver
-config USB_FOTG210_UDC
- depends on HAS_DMA
- tristate "Faraday FOTG210 USB Peripheral Controller"
- help
- Faraday USB2.0 OTG controller which can be configured as
- high speed or full speed USB device. This driver supppors
- Bulk Transfer so far.
-
- Say "y" to link the driver statically, or "m" to build a
- dynamically linked module called "fotg210_udc".
-
config USB_GR_UDC
tristate "Aeroflex Gaisler GRUSBDC USB Peripheral Controller Driver"
depends on HAS_DMA
@@ -430,7 +419,7 @@ config USB_EG20T
config USB_GADGET_XILINX
tristate "Xilinx USB Driver"
depends on HAS_DMA
- depends on OF || COMPILE_TEST
+ depends on OF
help
USB peripheral controller driver for Xilinx USB2 device.
Xilinx USB2 device is a soft IP which supports both full
diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile
index 12f9e4c9eb0c..39daf36a2baa 100644
--- a/drivers/usb/gadget/udc/Makefile
+++ b/drivers/usb/gadget/udc/Makefile
@@ -34,7 +34,6 @@ 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_FOTG210_UDC) += fotg210-udc.o
obj-$(CONFIG_USB_MV_U3D) += mv_u3d_core.o
obj-$(CONFIG_USB_GR_UDC) += gr_udc.o
obj-$(CONFIG_USB_GADGET_XILINX) += udc-xilinx.o
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/udc/aspeed-vhub/core.c
index 7a635c499777..ac3ca24f8b04 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/core.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c
@@ -37,7 +37,7 @@ void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req,
list_del_init(&req->queue);
- if (req->req.status == -EINPROGRESS)
+ if ((req->req.status == -EINPROGRESS) || (status == -EOVERFLOW))
req->req.status = status;
if (req->req.dma) {
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/dev.c b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
index b0dfca43fbdc..4f3bc27c1c62 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/dev.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
@@ -591,6 +591,7 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx)
d->gadget.max_speed = USB_SPEED_HIGH;
d->gadget.speed = USB_SPEED_UNKNOWN;
d->gadget.dev.of_node = vhub->pdev->dev.of_node;
+ d->gadget.dev.of_node_reused = true;
rc = usb_add_gadget_udc(d->port_dev, &d->gadget);
if (rc != 0)
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/epn.c b/drivers/usb/gadget/udc/aspeed-vhub/epn.c
index b5252880b389..56e55472daa1 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/epn.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/epn.c
@@ -84,6 +84,7 @@ static void ast_vhub_epn_handle_ack(struct ast_vhub_ep *ep)
{
struct ast_vhub_req *req;
unsigned int len;
+ int status = 0;
u32 stat;
/* Read EP status */
@@ -119,9 +120,15 @@ static void ast_vhub_epn_handle_ack(struct ast_vhub_ep *ep)
len = VHUB_EP_DMA_TX_SIZE(stat);
/* If not using DMA, copy data out if needed */
- if (!req->req.dma && !ep->epn.is_in && len)
- memcpy(req->req.buf + req->req.actual, ep->buf, len);
-
+ if (!req->req.dma && !ep->epn.is_in && len) {
+ if (req->req.actual + len > req->req.length) {
+ req->last_desc = 1;
+ status = -EOVERFLOW;
+ goto done;
+ } else {
+ memcpy(req->req.buf + req->req.actual, ep->buf, len);
+ }
+ }
/* Adjust size */
req->req.actual += len;
@@ -129,9 +136,10 @@ static void ast_vhub_epn_handle_ack(struct ast_vhub_ep *ep)
if (len < ep->ep.maxpacket)
req->last_desc = 1;
+done:
/* That's it ? complete the request and pick a new one */
if (req->last_desc >= 0) {
- ast_vhub_done(ep, req, 0);
+ ast_vhub_done(ep, req, status);
req = list_first_entry_or_null(&ep->queue, struct ast_vhub_req,
queue);
diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
index a9a7b3fc60ec..922b4187004b 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -1628,10 +1628,7 @@ static int at91rm9200_udc_init(struct at91_udc *udc)
static void at91rm9200_udc_pullup(struct at91_udc *udc, int is_on)
{
- if (is_on)
- gpiod_set_value(udc->board.pullup_pin, 1);
- else
- gpiod_set_value(udc->board.pullup_pin, 0);
+ gpiod_set_value(udc->board.pullup_pin, is_on);
}
static const struct at91_udc_caps at91rm9200_udc_caps = {
diff --git a/drivers/usb/gadget/udc/bdc/bdc_udc.c b/drivers/usb/gadget/udc/bdc/bdc_udc.c
index 5ac0ef88334e..53ffaf4e2e37 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_udc.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_udc.c
@@ -151,6 +151,7 @@ static void bdc_uspc_disconnected(struct bdc *bdc, bool reinit)
bdc->delayed_status = false;
bdc->reinit = reinit;
bdc->test_mode = false;
+ usb_gadget_set_state(&bdc->gadget, USB_STATE_NOTATTACHED);
}
/* TNotify wkaeup timer */
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index c63c0c2cf649..23b0629a8774 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -734,13 +734,13 @@ int usb_gadget_disconnect(struct usb_gadget *gadget)
}
ret = gadget->ops->pullup(gadget, 0);
- if (!ret) {
+ if (!ret)
gadget->connected = 0;
- mutex_lock(&udc_lock);
- if (gadget->udc->driver)
- gadget->udc->driver->disconnect(gadget);
- mutex_unlock(&udc_lock);
- }
+
+ mutex_lock(&udc_lock);
+ if (gadget->udc->driver)
+ gadget->udc->driver->disconnect(gadget);
+ mutex_unlock(&udc_lock);
out:
trace_usb_gadget_disconnect(gadget, ret);
@@ -1723,9 +1723,9 @@ static const struct attribute_group *usb_udc_attr_groups[] = {
NULL,
};
-static int usb_udc_uevent(struct device *dev, struct kobj_uevent_env *env)
+static int usb_udc_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
- struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
+ const struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
int ret;
ret = add_uevent_var(env, "USB_UDC_NAME=%s", udc->gadget->name);
diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c
deleted file mode 100644
index fdca28e72a3b..000000000000
--- a/drivers/usb/gadget/udc/fotg210-udc.c
+++ /dev/null
@@ -1,1224 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * FOTG210 UDC Driver supports Bulk transfer so far
- *
- * Copyright (C) 2013 Faraday Technology Corporation
- *
- * Author : Yuan-Hsin Chen <yhchen@faraday-tech.com>
- */
-
-#include <linux/dma-mapping.h>
-#include <linux/err.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/usb/ch9.h>
-#include <linux/usb/gadget.h>
-
-#include "fotg210.h"
-
-#define DRIVER_DESC "FOTG210 USB Device Controller Driver"
-#define DRIVER_VERSION "30-April-2013"
-
-static const char udc_name[] = "fotg210_udc";
-static const char * const fotg210_ep_name[] = {
- "ep0", "ep1", "ep2", "ep3", "ep4"};
-
-static void fotg210_disable_fifo_int(struct fotg210_ep *ep)
-{
- u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR1);
-
- if (ep->dir_in)
- value |= DMISGR1_MF_IN_INT(ep->epnum - 1);
- else
- value |= DMISGR1_MF_OUTSPK_INT(ep->epnum - 1);
- iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR1);
-}
-
-static void fotg210_enable_fifo_int(struct fotg210_ep *ep)
-{
- u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR1);
-
- if (ep->dir_in)
- value &= ~DMISGR1_MF_IN_INT(ep->epnum - 1);
- else
- value &= ~DMISGR1_MF_OUTSPK_INT(ep->epnum - 1);
- iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR1);
-}
-
-static void fotg210_set_cxdone(struct fotg210_udc *fotg210)
-{
- u32 value = ioread32(fotg210->reg + FOTG210_DCFESR);
-
- value |= DCFESR_CX_DONE;
- iowrite32(value, fotg210->reg + FOTG210_DCFESR);
-}
-
-static void fotg210_done(struct fotg210_ep *ep, struct fotg210_request *req,
- int status)
-{
- list_del_init(&req->queue);
-
- /* don't modify queue heads during completion callback */
- if (ep->fotg210->gadget.speed == USB_SPEED_UNKNOWN)
- req->req.status = -ESHUTDOWN;
- else
- req->req.status = status;
-
- spin_unlock(&ep->fotg210->lock);
- usb_gadget_giveback_request(&ep->ep, &req->req);
- spin_lock(&ep->fotg210->lock);
-
- if (ep->epnum) {
- if (list_empty(&ep->queue))
- fotg210_disable_fifo_int(ep);
- } else {
- fotg210_set_cxdone(ep->fotg210);
- }
-}
-
-static void fotg210_fifo_ep_mapping(struct fotg210_ep *ep, u32 epnum,
- u32 dir_in)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
- u32 val;
-
- /* Driver should map an ep to a fifo and then map the fifo
- * to the ep. What a brain-damaged design!
- */
-
- /* map a fifo to an ep */
- val = ioread32(fotg210->reg + FOTG210_EPMAP);
- val &= ~EPMAP_FIFONOMSK(epnum, dir_in);
- val |= EPMAP_FIFONO(epnum, dir_in);
- iowrite32(val, fotg210->reg + FOTG210_EPMAP);
-
- /* map the ep to the fifo */
- val = ioread32(fotg210->reg + FOTG210_FIFOMAP);
- val &= ~FIFOMAP_EPNOMSK(epnum);
- val |= FIFOMAP_EPNO(epnum);
- iowrite32(val, fotg210->reg + FOTG210_FIFOMAP);
-
- /* enable fifo */
- val = ioread32(fotg210->reg + FOTG210_FIFOCF);
- val |= FIFOCF_FIFO_EN(epnum - 1);
- iowrite32(val, fotg210->reg + FOTG210_FIFOCF);
-}
-
-static void fotg210_set_fifo_dir(struct fotg210_ep *ep, u32 epnum, u32 dir_in)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
- u32 val;
-
- val = ioread32(fotg210->reg + FOTG210_FIFOMAP);
- val |= (dir_in ? FIFOMAP_DIRIN(epnum - 1) : FIFOMAP_DIROUT(epnum - 1));
- iowrite32(val, fotg210->reg + FOTG210_FIFOMAP);
-}
-
-static void fotg210_set_tfrtype(struct fotg210_ep *ep, u32 epnum, u32 type)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
- u32 val;
-
- val = ioread32(fotg210->reg + FOTG210_FIFOCF);
- val |= FIFOCF_TYPE(type, epnum - 1);
- iowrite32(val, fotg210->reg + FOTG210_FIFOCF);
-}
-
-static void fotg210_set_mps(struct fotg210_ep *ep, u32 epnum, u32 mps,
- u32 dir_in)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
- u32 val;
- u32 offset = dir_in ? FOTG210_INEPMPSR(epnum) :
- FOTG210_OUTEPMPSR(epnum);
-
- val = ioread32(fotg210->reg + offset);
- val |= INOUTEPMPSR_MPS(mps);
- iowrite32(val, fotg210->reg + offset);
-}
-
-static int fotg210_config_ep(struct fotg210_ep *ep,
- const struct usb_endpoint_descriptor *desc)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
-
- fotg210_set_fifo_dir(ep, ep->epnum, ep->dir_in);
- fotg210_set_tfrtype(ep, ep->epnum, ep->type);
- fotg210_set_mps(ep, ep->epnum, ep->ep.maxpacket, ep->dir_in);
- fotg210_fifo_ep_mapping(ep, ep->epnum, ep->dir_in);
-
- fotg210->ep[ep->epnum] = ep;
-
- return 0;
-}
-
-static int fotg210_ep_enable(struct usb_ep *_ep,
- const struct usb_endpoint_descriptor *desc)
-{
- struct fotg210_ep *ep;
-
- ep = container_of(_ep, struct fotg210_ep, ep);
-
- ep->desc = desc;
- ep->epnum = usb_endpoint_num(desc);
- ep->type = usb_endpoint_type(desc);
- ep->dir_in = usb_endpoint_dir_in(desc);
- ep->ep.maxpacket = usb_endpoint_maxp(desc);
-
- return fotg210_config_ep(ep, desc);
-}
-
-static void fotg210_reset_tseq(struct fotg210_udc *fotg210, u8 epnum)
-{
- struct fotg210_ep *ep = fotg210->ep[epnum];
- u32 value;
- void __iomem *reg;
-
- reg = (ep->dir_in) ?
- fotg210->reg + FOTG210_INEPMPSR(epnum) :
- fotg210->reg + FOTG210_OUTEPMPSR(epnum);
-
- /* Note: Driver needs to set and clear INOUTEPMPSR_RESET_TSEQ
- * bit. Controller wouldn't clear this bit. WTF!!!
- */
-
- value = ioread32(reg);
- value |= INOUTEPMPSR_RESET_TSEQ;
- iowrite32(value, reg);
-
- value = ioread32(reg);
- value &= ~INOUTEPMPSR_RESET_TSEQ;
- iowrite32(value, reg);
-}
-
-static int fotg210_ep_release(struct fotg210_ep *ep)
-{
- if (!ep->epnum)
- return 0;
- ep->epnum = 0;
- ep->stall = 0;
- ep->wedged = 0;
-
- fotg210_reset_tseq(ep->fotg210, ep->epnum);
-
- return 0;
-}
-
-static int fotg210_ep_disable(struct usb_ep *_ep)
-{
- struct fotg210_ep *ep;
- struct fotg210_request *req;
- unsigned long flags;
-
- BUG_ON(!_ep);
-
- ep = container_of(_ep, struct fotg210_ep, ep);
-
- while (!list_empty(&ep->queue)) {
- req = list_entry(ep->queue.next,
- struct fotg210_request, queue);
- spin_lock_irqsave(&ep->fotg210->lock, flags);
- fotg210_done(ep, req, -ECONNRESET);
- spin_unlock_irqrestore(&ep->fotg210->lock, flags);
- }
-
- return fotg210_ep_release(ep);
-}
-
-static struct usb_request *fotg210_ep_alloc_request(struct usb_ep *_ep,
- gfp_t gfp_flags)
-{
- struct fotg210_request *req;
-
- req = kzalloc(sizeof(struct fotg210_request), gfp_flags);
- if (!req)
- return NULL;
-
- INIT_LIST_HEAD(&req->queue);
-
- return &req->req;
-}
-
-static void fotg210_ep_free_request(struct usb_ep *_ep,
- struct usb_request *_req)
-{
- struct fotg210_request *req;
-
- req = container_of(_req, struct fotg210_request, req);
- kfree(req);
-}
-
-static void fotg210_enable_dma(struct fotg210_ep *ep,
- dma_addr_t d, u32 len)
-{
- u32 value;
- struct fotg210_udc *fotg210 = ep->fotg210;
-
- /* set transfer length and direction */
- value = ioread32(fotg210->reg + FOTG210_DMACPSR1);
- value &= ~(DMACPSR1_DMA_LEN(0xFFFF) | DMACPSR1_DMA_TYPE(1));
- value |= DMACPSR1_DMA_LEN(len) | DMACPSR1_DMA_TYPE(ep->dir_in);
- iowrite32(value, fotg210->reg + FOTG210_DMACPSR1);
-
- /* set device DMA target FIFO number */
- value = ioread32(fotg210->reg + FOTG210_DMATFNR);
- if (ep->epnum)
- value |= DMATFNR_ACC_FN(ep->epnum - 1);
- else
- value |= DMATFNR_ACC_CXF;
- iowrite32(value, fotg210->reg + FOTG210_DMATFNR);
-
- /* set DMA memory address */
- iowrite32(d, fotg210->reg + FOTG210_DMACPSR2);
-
- /* enable MDMA_EROR and MDMA_CMPLT interrupt */
- value = ioread32(fotg210->reg + FOTG210_DMISGR2);
- value &= ~(DMISGR2_MDMA_CMPLT | DMISGR2_MDMA_ERROR);
- iowrite32(value, fotg210->reg + FOTG210_DMISGR2);
-
- /* start DMA */
- value = ioread32(fotg210->reg + FOTG210_DMACPSR1);
- value |= DMACPSR1_DMA_START;
- iowrite32(value, fotg210->reg + FOTG210_DMACPSR1);
-}
-
-static void fotg210_disable_dma(struct fotg210_ep *ep)
-{
- iowrite32(DMATFNR_DISDMA, ep->fotg210->reg + FOTG210_DMATFNR);
-}
-
-static void fotg210_wait_dma_done(struct fotg210_ep *ep)
-{
- u32 value;
-
- do {
- value = ioread32(ep->fotg210->reg + FOTG210_DISGR2);
- if ((value & DISGR2_USBRST_INT) ||
- (value & DISGR2_DMA_ERROR))
- goto dma_reset;
- } while (!(value & DISGR2_DMA_CMPLT));
-
- value &= ~DISGR2_DMA_CMPLT;
- iowrite32(value, ep->fotg210->reg + FOTG210_DISGR2);
- return;
-
-dma_reset:
- value = ioread32(ep->fotg210->reg + FOTG210_DMACPSR1);
- value |= DMACPSR1_DMA_ABORT;
- iowrite32(value, ep->fotg210->reg + FOTG210_DMACPSR1);
-
- /* reset fifo */
- if (ep->epnum) {
- value = ioread32(ep->fotg210->reg +
- FOTG210_FIBCR(ep->epnum - 1));
- value |= FIBCR_FFRST;
- iowrite32(value, ep->fotg210->reg +
- FOTG210_FIBCR(ep->epnum - 1));
- } else {
- value = ioread32(ep->fotg210->reg + FOTG210_DCFESR);
- value |= DCFESR_CX_CLR;
- iowrite32(value, ep->fotg210->reg + FOTG210_DCFESR);
- }
-}
-
-static void fotg210_start_dma(struct fotg210_ep *ep,
- struct fotg210_request *req)
-{
- struct device *dev = &ep->fotg210->gadget.dev;
- dma_addr_t d;
- u8 *buffer;
- u32 length;
-
- if (ep->epnum) {
- if (ep->dir_in) {
- buffer = req->req.buf;
- length = req->req.length;
- } else {
- buffer = req->req.buf + req->req.actual;
- length = ioread32(ep->fotg210->reg +
- FOTG210_FIBCR(ep->epnum - 1)) & FIBCR_BCFX;
- if (length > req->req.length - req->req.actual)
- length = req->req.length - req->req.actual;
- }
- } else {
- buffer = req->req.buf + req->req.actual;
- if (req->req.length - req->req.actual > ep->ep.maxpacket)
- length = ep->ep.maxpacket;
- else
- length = req->req.length - req->req.actual;
- }
-
- d = dma_map_single(dev, buffer, length,
- ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
-
- if (dma_mapping_error(dev, d)) {
- pr_err("dma_mapping_error\n");
- return;
- }
-
- fotg210_enable_dma(ep, d, length);
-
- /* check if dma is done */
- fotg210_wait_dma_done(ep);
-
- fotg210_disable_dma(ep);
-
- /* update actual transfer length */
- req->req.actual += length;
-
- dma_unmap_single(dev, d, length, DMA_TO_DEVICE);
-}
-
-static void fotg210_ep0_queue(struct fotg210_ep *ep,
- struct fotg210_request *req)
-{
- if (!req->req.length) {
- fotg210_done(ep, req, 0);
- return;
- }
- if (ep->dir_in) { /* if IN */
- fotg210_start_dma(ep, req);
- if (req->req.length == req->req.actual)
- fotg210_done(ep, req, 0);
- } else { /* OUT */
- u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR0);
-
- value &= ~DMISGR0_MCX_OUT_INT;
- iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR0);
- }
-}
-
-static int fotg210_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
- gfp_t gfp_flags)
-{
- struct fotg210_ep *ep;
- struct fotg210_request *req;
- unsigned long flags;
- int request = 0;
-
- ep = container_of(_ep, struct fotg210_ep, ep);
- req = container_of(_req, struct fotg210_request, req);
-
- if (ep->fotg210->gadget.speed == USB_SPEED_UNKNOWN)
- return -ESHUTDOWN;
-
- spin_lock_irqsave(&ep->fotg210->lock, flags);
-
- if (list_empty(&ep->queue))
- request = 1;
-
- list_add_tail(&req->queue, &ep->queue);
-
- req->req.actual = 0;
- req->req.status = -EINPROGRESS;
-
- if (!ep->epnum) /* ep0 */
- fotg210_ep0_queue(ep, req);
- else if (request && !ep->stall)
- fotg210_enable_fifo_int(ep);
-
- spin_unlock_irqrestore(&ep->fotg210->lock, flags);
-
- return 0;
-}
-
-static int fotg210_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
-{
- struct fotg210_ep *ep;
- struct fotg210_request *req;
- unsigned long flags;
-
- ep = container_of(_ep, struct fotg210_ep, ep);
- req = container_of(_req, struct fotg210_request, req);
-
- spin_lock_irqsave(&ep->fotg210->lock, flags);
- if (!list_empty(&ep->queue))
- fotg210_done(ep, req, -ECONNRESET);
- spin_unlock_irqrestore(&ep->fotg210->lock, flags);
-
- return 0;
-}
-
-static void fotg210_set_epnstall(struct fotg210_ep *ep)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
- u32 value;
- void __iomem *reg;
-
- /* check if IN FIFO is empty before stall */
- if (ep->dir_in) {
- do {
- value = ioread32(fotg210->reg + FOTG210_DCFESR);
- } while (!(value & DCFESR_FIFO_EMPTY(ep->epnum - 1)));
- }
-
- reg = (ep->dir_in) ?
- fotg210->reg + FOTG210_INEPMPSR(ep->epnum) :
- fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum);
- value = ioread32(reg);
- value |= INOUTEPMPSR_STL_EP;
- iowrite32(value, reg);
-}
-
-static void fotg210_clear_epnstall(struct fotg210_ep *ep)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
- u32 value;
- void __iomem *reg;
-
- reg = (ep->dir_in) ?
- fotg210->reg + FOTG210_INEPMPSR(ep->epnum) :
- fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum);
- value = ioread32(reg);
- value &= ~INOUTEPMPSR_STL_EP;
- iowrite32(value, reg);
-}
-
-static int fotg210_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedge)
-{
- struct fotg210_ep *ep;
- struct fotg210_udc *fotg210;
- unsigned long flags;
-
- ep = container_of(_ep, struct fotg210_ep, ep);
-
- fotg210 = ep->fotg210;
-
- spin_lock_irqsave(&ep->fotg210->lock, flags);
-
- if (value) {
- fotg210_set_epnstall(ep);
- ep->stall = 1;
- if (wedge)
- ep->wedged = 1;
- } else {
- fotg210_reset_tseq(fotg210, ep->epnum);
- fotg210_clear_epnstall(ep);
- ep->stall = 0;
- ep->wedged = 0;
- if (!list_empty(&ep->queue))
- fotg210_enable_fifo_int(ep);
- }
-
- spin_unlock_irqrestore(&ep->fotg210->lock, flags);
- return 0;
-}
-
-static int fotg210_ep_set_halt(struct usb_ep *_ep, int value)
-{
- return fotg210_set_halt_and_wedge(_ep, value, 0);
-}
-
-static int fotg210_ep_set_wedge(struct usb_ep *_ep)
-{
- return fotg210_set_halt_and_wedge(_ep, 1, 1);
-}
-
-static void fotg210_ep_fifo_flush(struct usb_ep *_ep)
-{
-}
-
-static const struct usb_ep_ops fotg210_ep_ops = {
- .enable = fotg210_ep_enable,
- .disable = fotg210_ep_disable,
-
- .alloc_request = fotg210_ep_alloc_request,
- .free_request = fotg210_ep_free_request,
-
- .queue = fotg210_ep_queue,
- .dequeue = fotg210_ep_dequeue,
-
- .set_halt = fotg210_ep_set_halt,
- .fifo_flush = fotg210_ep_fifo_flush,
- .set_wedge = fotg210_ep_set_wedge,
-};
-
-static void fotg210_clear_tx0byte(struct fotg210_udc *fotg210)
-{
- u32 value = ioread32(fotg210->reg + FOTG210_TX0BYTE);
-
- value &= ~(TX0BYTE_EP1 | TX0BYTE_EP2 | TX0BYTE_EP3
- | TX0BYTE_EP4);
- iowrite32(value, fotg210->reg + FOTG210_TX0BYTE);
-}
-
-static void fotg210_clear_rx0byte(struct fotg210_udc *fotg210)
-{
- u32 value = ioread32(fotg210->reg + FOTG210_RX0BYTE);
-
- value &= ~(RX0BYTE_EP1 | RX0BYTE_EP2 | RX0BYTE_EP3
- | RX0BYTE_EP4);
- iowrite32(value, fotg210->reg + FOTG210_RX0BYTE);
-}
-
-/* read 8-byte setup packet only */
-static void fotg210_rdsetupp(struct fotg210_udc *fotg210,
- u8 *buffer)
-{
- int i = 0;
- u8 *tmp = buffer;
- u32 data;
- u32 length = 8;
-
- iowrite32(DMATFNR_ACC_CXF, fotg210->reg + FOTG210_DMATFNR);
-
- for (i = (length >> 2); i > 0; i--) {
- data = ioread32(fotg210->reg + FOTG210_CXPORT);
- *tmp = data & 0xFF;
- *(tmp + 1) = (data >> 8) & 0xFF;
- *(tmp + 2) = (data >> 16) & 0xFF;
- *(tmp + 3) = (data >> 24) & 0xFF;
- tmp = tmp + 4;
- }
-
- switch (length % 4) {
- case 1:
- data = ioread32(fotg210->reg + FOTG210_CXPORT);
- *tmp = data & 0xFF;
- break;
- case 2:
- data = ioread32(fotg210->reg + FOTG210_CXPORT);
- *tmp = data & 0xFF;
- *(tmp + 1) = (data >> 8) & 0xFF;
- break;
- case 3:
- data = ioread32(fotg210->reg + FOTG210_CXPORT);
- *tmp = data & 0xFF;
- *(tmp + 1) = (data >> 8) & 0xFF;
- *(tmp + 2) = (data >> 16) & 0xFF;
- break;
- default:
- break;
- }
-
- iowrite32(DMATFNR_DISDMA, fotg210->reg + FOTG210_DMATFNR);
-}
-
-static void fotg210_set_configuration(struct fotg210_udc *fotg210)
-{
- u32 value = ioread32(fotg210->reg + FOTG210_DAR);
-
- value |= DAR_AFT_CONF;
- iowrite32(value, fotg210->reg + FOTG210_DAR);
-}
-
-static void fotg210_set_dev_addr(struct fotg210_udc *fotg210, u32 addr)
-{
- u32 value = ioread32(fotg210->reg + FOTG210_DAR);
-
- value |= (addr & 0x7F);
- iowrite32(value, fotg210->reg + FOTG210_DAR);
-}
-
-static void fotg210_set_cxstall(struct fotg210_udc *fotg210)
-{
- u32 value = ioread32(fotg210->reg + FOTG210_DCFESR);
-
- value |= DCFESR_CX_STL;
- iowrite32(value, fotg210->reg + FOTG210_DCFESR);
-}
-
-static void fotg210_request_error(struct fotg210_udc *fotg210)
-{
- fotg210_set_cxstall(fotg210);
- pr_err("request error!!\n");
-}
-
-static void fotg210_set_address(struct fotg210_udc *fotg210,
- struct usb_ctrlrequest *ctrl)
-{
- if (ctrl->wValue >= 0x0100) {
- fotg210_request_error(fotg210);
- } else {
- fotg210_set_dev_addr(fotg210, ctrl->wValue);
- fotg210_set_cxdone(fotg210);
- }
-}
-
-static void fotg210_set_feature(struct fotg210_udc *fotg210,
- struct usb_ctrlrequest *ctrl)
-{
- switch (ctrl->bRequestType & USB_RECIP_MASK) {
- case USB_RECIP_DEVICE:
- fotg210_set_cxdone(fotg210);
- break;
- case USB_RECIP_INTERFACE:
- fotg210_set_cxdone(fotg210);
- break;
- case USB_RECIP_ENDPOINT: {
- u8 epnum;
- epnum = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK;
- if (epnum)
- fotg210_set_epnstall(fotg210->ep[epnum]);
- else
- fotg210_set_cxstall(fotg210);
- fotg210_set_cxdone(fotg210);
- }
- break;
- default:
- fotg210_request_error(fotg210);
- break;
- }
-}
-
-static void fotg210_clear_feature(struct fotg210_udc *fotg210,
- struct usb_ctrlrequest *ctrl)
-{
- struct fotg210_ep *ep =
- fotg210->ep[ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK];
-
- switch (ctrl->bRequestType & USB_RECIP_MASK) {
- case USB_RECIP_DEVICE:
- fotg210_set_cxdone(fotg210);
- break;
- case USB_RECIP_INTERFACE:
- fotg210_set_cxdone(fotg210);
- break;
- case USB_RECIP_ENDPOINT:
- if (ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK) {
- if (ep->wedged) {
- fotg210_set_cxdone(fotg210);
- break;
- }
- if (ep->stall)
- fotg210_set_halt_and_wedge(&ep->ep, 0, 0);
- }
- fotg210_set_cxdone(fotg210);
- break;
- default:
- fotg210_request_error(fotg210);
- break;
- }
-}
-
-static int fotg210_is_epnstall(struct fotg210_ep *ep)
-{
- struct fotg210_udc *fotg210 = ep->fotg210;
- u32 value;
- void __iomem *reg;
-
- reg = (ep->dir_in) ?
- fotg210->reg + FOTG210_INEPMPSR(ep->epnum) :
- fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum);
- value = ioread32(reg);
- return value & INOUTEPMPSR_STL_EP ? 1 : 0;
-}
-
-static void fotg210_get_status(struct fotg210_udc *fotg210,
- struct usb_ctrlrequest *ctrl)
-{
- u8 epnum;
-
- switch (ctrl->bRequestType & USB_RECIP_MASK) {
- case USB_RECIP_DEVICE:
- fotg210->ep0_data = 1 << USB_DEVICE_SELF_POWERED;
- break;
- case USB_RECIP_INTERFACE:
- fotg210->ep0_data = 0;
- break;
- case USB_RECIP_ENDPOINT:
- epnum = ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK;
- if (epnum)
- fotg210->ep0_data =
- fotg210_is_epnstall(fotg210->ep[epnum])
- << USB_ENDPOINT_HALT;
- else
- fotg210_request_error(fotg210);
- break;
-
- default:
- fotg210_request_error(fotg210);
- return; /* exit */
- }
-
- fotg210->ep0_req->buf = &fotg210->ep0_data;
- fotg210->ep0_req->length = 2;
-
- spin_unlock(&fotg210->lock);
- fotg210_ep_queue(fotg210->gadget.ep0, fotg210->ep0_req, GFP_ATOMIC);
- spin_lock(&fotg210->lock);
-}
-
-static int fotg210_setup_packet(struct fotg210_udc *fotg210,
- struct usb_ctrlrequest *ctrl)
-{
- u8 *p = (u8 *)ctrl;
- u8 ret = 0;
-
- fotg210_rdsetupp(fotg210, p);
-
- fotg210->ep[0]->dir_in = ctrl->bRequestType & USB_DIR_IN;
-
- if (fotg210->gadget.speed == USB_SPEED_UNKNOWN) {
- u32 value = ioread32(fotg210->reg + FOTG210_DMCR);
- fotg210->gadget.speed = value & DMCR_HS_EN ?
- USB_SPEED_HIGH : USB_SPEED_FULL;
- }
-
- /* check request */
- if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
- switch (ctrl->bRequest) {
- case USB_REQ_GET_STATUS:
- fotg210_get_status(fotg210, ctrl);
- break;
- case USB_REQ_CLEAR_FEATURE:
- fotg210_clear_feature(fotg210, ctrl);
- break;
- case USB_REQ_SET_FEATURE:
- fotg210_set_feature(fotg210, ctrl);
- break;
- case USB_REQ_SET_ADDRESS:
- fotg210_set_address(fotg210, ctrl);
- break;
- case USB_REQ_SET_CONFIGURATION:
- fotg210_set_configuration(fotg210);
- ret = 1;
- break;
- default:
- ret = 1;
- break;
- }
- } else {
- ret = 1;
- }
-
- return ret;
-}
-
-static void fotg210_ep0out(struct fotg210_udc *fotg210)
-{
- struct fotg210_ep *ep = fotg210->ep[0];
-
- if (!list_empty(&ep->queue) && !ep->dir_in) {
- struct fotg210_request *req;
-
- req = list_first_entry(&ep->queue,
- struct fotg210_request, queue);
-
- if (req->req.length)
- fotg210_start_dma(ep, req);
-
- if ((req->req.length - req->req.actual) < ep->ep.maxpacket)
- fotg210_done(ep, req, 0);
- } else {
- pr_err("%s : empty queue\n", __func__);
- }
-}
-
-static void fotg210_ep0in(struct fotg210_udc *fotg210)
-{
- struct fotg210_ep *ep = fotg210->ep[0];
-
- if ((!list_empty(&ep->queue)) && (ep->dir_in)) {
- struct fotg210_request *req;
-
- req = list_entry(ep->queue.next,
- struct fotg210_request, queue);
-
- if (req->req.length)
- fotg210_start_dma(ep, req);
-
- if (req->req.actual == req->req.length)
- fotg210_done(ep, req, 0);
- } else {
- fotg210_set_cxdone(fotg210);
- }
-}
-
-static void fotg210_clear_comabt_int(struct fotg210_udc *fotg210)
-{
- u32 value = ioread32(fotg210->reg + FOTG210_DISGR0);
-
- value &= ~DISGR0_CX_COMABT_INT;
- iowrite32(value, fotg210->reg + FOTG210_DISGR0);
-}
-
-static void fotg210_in_fifo_handler(struct fotg210_ep *ep)
-{
- struct fotg210_request *req = list_entry(ep->queue.next,
- struct fotg210_request, queue);
-
- if (req->req.length)
- fotg210_start_dma(ep, req);
- fotg210_done(ep, req, 0);
-}
-
-static void fotg210_out_fifo_handler(struct fotg210_ep *ep)
-{
- struct fotg210_request *req = list_entry(ep->queue.next,
- struct fotg210_request, queue);
- int disgr1 = ioread32(ep->fotg210->reg + FOTG210_DISGR1);
-
- fotg210_start_dma(ep, req);
-
- /* Complete the request when it's full or a short packet arrived.
- * Like other drivers, short_not_ok isn't handled.
- */
-
- if (req->req.length == req->req.actual ||
- (disgr1 & DISGR1_SPK_INT(ep->epnum - 1)))
- fotg210_done(ep, req, 0);
-}
-
-static irqreturn_t fotg210_irq(int irq, void *_fotg210)
-{
- struct fotg210_udc *fotg210 = _fotg210;
- u32 int_grp = ioread32(fotg210->reg + FOTG210_DIGR);
- u32 int_msk = ioread32(fotg210->reg + FOTG210_DMIGR);
-
- int_grp &= ~int_msk;
-
- spin_lock(&fotg210->lock);
-
- if (int_grp & DIGR_INT_G2) {
- void __iomem *reg = fotg210->reg + FOTG210_DISGR2;
- u32 int_grp2 = ioread32(reg);
- u32 int_msk2 = ioread32(fotg210->reg + FOTG210_DMISGR2);
- u32 value;
-
- int_grp2 &= ~int_msk2;
-
- if (int_grp2 & DISGR2_USBRST_INT) {
- usb_gadget_udc_reset(&fotg210->gadget,
- fotg210->driver);
- value = ioread32(reg);
- value &= ~DISGR2_USBRST_INT;
- iowrite32(value, reg);
- pr_info("fotg210 udc reset\n");
- }
- if (int_grp2 & DISGR2_SUSP_INT) {
- value = ioread32(reg);
- value &= ~DISGR2_SUSP_INT;
- iowrite32(value, reg);
- pr_info("fotg210 udc suspend\n");
- }
- if (int_grp2 & DISGR2_RESM_INT) {
- value = ioread32(reg);
- value &= ~DISGR2_RESM_INT;
- iowrite32(value, reg);
- pr_info("fotg210 udc resume\n");
- }
- if (int_grp2 & DISGR2_ISO_SEQ_ERR_INT) {
- value = ioread32(reg);
- value &= ~DISGR2_ISO_SEQ_ERR_INT;
- iowrite32(value, reg);
- pr_info("fotg210 iso sequence error\n");
- }
- if (int_grp2 & DISGR2_ISO_SEQ_ABORT_INT) {
- value = ioread32(reg);
- value &= ~DISGR2_ISO_SEQ_ABORT_INT;
- iowrite32(value, reg);
- pr_info("fotg210 iso sequence abort\n");
- }
- if (int_grp2 & DISGR2_TX0BYTE_INT) {
- fotg210_clear_tx0byte(fotg210);
- value = ioread32(reg);
- value &= ~DISGR2_TX0BYTE_INT;
- iowrite32(value, reg);
- pr_info("fotg210 transferred 0 byte\n");
- }
- if (int_grp2 & DISGR2_RX0BYTE_INT) {
- fotg210_clear_rx0byte(fotg210);
- value = ioread32(reg);
- value &= ~DISGR2_RX0BYTE_INT;
- iowrite32(value, reg);
- pr_info("fotg210 received 0 byte\n");
- }
- if (int_grp2 & DISGR2_DMA_ERROR) {
- value = ioread32(reg);
- value &= ~DISGR2_DMA_ERROR;
- iowrite32(value, reg);
- }
- }
-
- if (int_grp & DIGR_INT_G0) {
- void __iomem *reg = fotg210->reg + FOTG210_DISGR0;
- u32 int_grp0 = ioread32(reg);
- u32 int_msk0 = ioread32(fotg210->reg + FOTG210_DMISGR0);
- struct usb_ctrlrequest ctrl;
-
- int_grp0 &= ~int_msk0;
-
- /* the highest priority in this source register */
- if (int_grp0 & DISGR0_CX_COMABT_INT) {
- fotg210_clear_comabt_int(fotg210);
- pr_info("fotg210 CX command abort\n");
- }
-
- if (int_grp0 & DISGR0_CX_SETUP_INT) {
- if (fotg210_setup_packet(fotg210, &ctrl)) {
- spin_unlock(&fotg210->lock);
- if (fotg210->driver->setup(&fotg210->gadget,
- &ctrl) < 0)
- fotg210_set_cxstall(fotg210);
- spin_lock(&fotg210->lock);
- }
- }
- if (int_grp0 & DISGR0_CX_COMEND_INT)
- pr_info("fotg210 cmd end\n");
-
- if (int_grp0 & DISGR0_CX_IN_INT)
- fotg210_ep0in(fotg210);
-
- if (int_grp0 & DISGR0_CX_OUT_INT)
- fotg210_ep0out(fotg210);
-
- if (int_grp0 & DISGR0_CX_COMFAIL_INT) {
- fotg210_set_cxstall(fotg210);
- pr_info("fotg210 ep0 fail\n");
- }
- }
-
- if (int_grp & DIGR_INT_G1) {
- void __iomem *reg = fotg210->reg + FOTG210_DISGR1;
- u32 int_grp1 = ioread32(reg);
- u32 int_msk1 = ioread32(fotg210->reg + FOTG210_DMISGR1);
- int fifo;
-
- int_grp1 &= ~int_msk1;
-
- for (fifo = 0; fifo < FOTG210_MAX_FIFO_NUM; fifo++) {
- if (int_grp1 & DISGR1_IN_INT(fifo))
- fotg210_in_fifo_handler(fotg210->ep[fifo + 1]);
-
- if ((int_grp1 & DISGR1_OUT_INT(fifo)) ||
- (int_grp1 & DISGR1_SPK_INT(fifo)))
- fotg210_out_fifo_handler(fotg210->ep[fifo + 1]);
- }
- }
-
- spin_unlock(&fotg210->lock);
-
- return IRQ_HANDLED;
-}
-
-static void fotg210_disable_unplug(struct fotg210_udc *fotg210)
-{
- u32 reg = ioread32(fotg210->reg + FOTG210_PHYTMSR);
-
- reg &= ~PHYTMSR_UNPLUG;
- iowrite32(reg, fotg210->reg + FOTG210_PHYTMSR);
-}
-
-static int fotg210_udc_start(struct usb_gadget *g,
- struct usb_gadget_driver *driver)
-{
- struct fotg210_udc *fotg210 = gadget_to_fotg210(g);
- u32 value;
-
- /* hook up the driver */
- driver->driver.bus = NULL;
- fotg210->driver = driver;
-
- /* enable device global interrupt */
- value = ioread32(fotg210->reg + FOTG210_DMCR);
- value |= DMCR_GLINT_EN;
- iowrite32(value, fotg210->reg + FOTG210_DMCR);
-
- return 0;
-}
-
-static void fotg210_init(struct fotg210_udc *fotg210)
-{
- u32 value;
-
- /* disable global interrupt and set int polarity to active high */
- iowrite32(GMIR_MHC_INT | GMIR_MOTG_INT | GMIR_INT_POLARITY,
- fotg210->reg + FOTG210_GMIR);
-
- /* disable device global interrupt */
- value = ioread32(fotg210->reg + FOTG210_DMCR);
- value &= ~DMCR_GLINT_EN;
- iowrite32(value, fotg210->reg + FOTG210_DMCR);
-
- /* enable only grp2 irqs we handle */
- iowrite32(~(DISGR2_DMA_ERROR | DISGR2_RX0BYTE_INT | DISGR2_TX0BYTE_INT
- | DISGR2_ISO_SEQ_ABORT_INT | DISGR2_ISO_SEQ_ERR_INT
- | DISGR2_RESM_INT | DISGR2_SUSP_INT | DISGR2_USBRST_INT),
- fotg210->reg + FOTG210_DMISGR2);
-
- /* disable all fifo interrupt */
- iowrite32(~(u32)0, fotg210->reg + FOTG210_DMISGR1);
-
- /* disable cmd end */
- value = ioread32(fotg210->reg + FOTG210_DMISGR0);
- value |= DMISGR0_MCX_COMEND;
- iowrite32(value, fotg210->reg + FOTG210_DMISGR0);
-}
-
-static int fotg210_udc_stop(struct usb_gadget *g)
-{
- struct fotg210_udc *fotg210 = gadget_to_fotg210(g);
- unsigned long flags;
-
- spin_lock_irqsave(&fotg210->lock, flags);
-
- fotg210_init(fotg210);
- fotg210->driver = NULL;
-
- spin_unlock_irqrestore(&fotg210->lock, flags);
-
- return 0;
-}
-
-static const struct usb_gadget_ops fotg210_gadget_ops = {
- .udc_start = fotg210_udc_start,
- .udc_stop = fotg210_udc_stop,
-};
-
-static int fotg210_udc_remove(struct platform_device *pdev)
-{
- struct fotg210_udc *fotg210 = platform_get_drvdata(pdev);
- int i;
-
- usb_del_gadget_udc(&fotg210->gadget);
- iounmap(fotg210->reg);
- free_irq(platform_get_irq(pdev, 0), fotg210);
-
- fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);
- for (i = 0; i < FOTG210_MAX_NUM_EP; i++)
- kfree(fotg210->ep[i]);
- kfree(fotg210);
-
- return 0;
-}
-
-static int fotg210_udc_probe(struct platform_device *pdev)
-{
- struct resource *res, *ires;
- struct fotg210_udc *fotg210 = NULL;
- struct fotg210_ep *_ep[FOTG210_MAX_NUM_EP];
- int ret = 0;
- int i;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- pr_err("platform_get_resource error.\n");
- return -ENODEV;
- }
-
- ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!ires) {
- pr_err("platform_get_resource IORESOURCE_IRQ error.\n");
- return -ENODEV;
- }
-
- ret = -ENOMEM;
-
- /* initialize udc */
- fotg210 = kzalloc(sizeof(struct fotg210_udc), GFP_KERNEL);
- if (fotg210 == NULL)
- goto err;
-
- for (i = 0; i < FOTG210_MAX_NUM_EP; i++) {
- _ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL);
- if (_ep[i] == NULL)
- goto err_alloc;
- fotg210->ep[i] = _ep[i];
- }
-
- fotg210->reg = ioremap(res->start, resource_size(res));
- if (fotg210->reg == NULL) {
- pr_err("ioremap error.\n");
- goto err_alloc;
- }
-
- spin_lock_init(&fotg210->lock);
-
- platform_set_drvdata(pdev, fotg210);
-
- fotg210->gadget.ops = &fotg210_gadget_ops;
-
- fotg210->gadget.max_speed = USB_SPEED_HIGH;
- fotg210->gadget.dev.parent = &pdev->dev;
- fotg210->gadget.dev.dma_mask = pdev->dev.dma_mask;
- fotg210->gadget.name = udc_name;
-
- INIT_LIST_HEAD(&fotg210->gadget.ep_list);
-
- for (i = 0; i < FOTG210_MAX_NUM_EP; i++) {
- struct fotg210_ep *ep = fotg210->ep[i];
-
- if (i) {
- INIT_LIST_HEAD(&fotg210->ep[i]->ep.ep_list);
- list_add_tail(&fotg210->ep[i]->ep.ep_list,
- &fotg210->gadget.ep_list);
- }
- ep->fotg210 = fotg210;
- INIT_LIST_HEAD(&ep->queue);
- ep->ep.name = fotg210_ep_name[i];
- ep->ep.ops = &fotg210_ep_ops;
- usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0);
-
- if (i == 0) {
- ep->ep.caps.type_control = true;
- } else {
- ep->ep.caps.type_iso = true;
- ep->ep.caps.type_bulk = true;
- ep->ep.caps.type_int = true;
- }
-
- ep->ep.caps.dir_in = true;
- ep->ep.caps.dir_out = true;
- }
- usb_ep_set_maxpacket_limit(&fotg210->ep[0]->ep, 0x40);
- fotg210->gadget.ep0 = &fotg210->ep[0]->ep;
- INIT_LIST_HEAD(&fotg210->gadget.ep0->ep_list);
-
- fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep,
- GFP_KERNEL);
- if (fotg210->ep0_req == NULL)
- goto err_map;
-
- fotg210_init(fotg210);
-
- fotg210_disable_unplug(fotg210);
-
- ret = request_irq(ires->start, fotg210_irq, IRQF_SHARED,
- udc_name, fotg210);
- if (ret < 0) {
- pr_err("request_irq error (%d)\n", ret);
- goto err_req;
- }
-
- ret = usb_add_gadget_udc(&pdev->dev, &fotg210->gadget);
- if (ret)
- goto err_add_udc;
-
- dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
-
- return 0;
-
-err_add_udc:
- free_irq(ires->start, fotg210);
-
-err_req:
- fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);
-
-err_map:
- iounmap(fotg210->reg);
-
-err_alloc:
- for (i = 0; i < FOTG210_MAX_NUM_EP; i++)
- kfree(fotg210->ep[i]);
- kfree(fotg210);
-
-err:
- return ret;
-}
-
-static struct platform_driver fotg210_driver = {
- .driver = {
- .name = udc_name,
- },
- .probe = fotg210_udc_probe,
- .remove = fotg210_udc_remove,
-};
-
-module_platform_driver(fotg210_driver);
-
-MODULE_AUTHOR("Yuan-Hsin Chen, Feng-Hsin Chiang <john453@faraday-tech.com>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/gadget/udc/fotg210.h b/drivers/usb/gadget/udc/fotg210.h
deleted file mode 100644
index 08c32957503b..000000000000
--- a/drivers/usb/gadget/udc/fotg210.h
+++ /dev/null
@@ -1,249 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Faraday FOTG210 USB OTG controller
- *
- * Copyright (C) 2013 Faraday Technology Corporation
- * Author: Yuan-Hsin Chen <yhchen@faraday-tech.com>
- */
-
-#include <linux/kernel.h>
-
-#define FOTG210_MAX_NUM_EP 5 /* ep0...ep4 */
-#define FOTG210_MAX_FIFO_NUM 4 /* fifo0...fifo4 */
-
-/* Global Mask of HC/OTG/DEV interrupt Register(0xC4) */
-#define FOTG210_GMIR 0xC4
-#define GMIR_INT_POLARITY 0x8 /*Active High*/
-#define GMIR_MHC_INT 0x4
-#define GMIR_MOTG_INT 0x2
-#define GMIR_MDEV_INT 0x1
-
-/* Device Main Control Register(0x100) */
-#define FOTG210_DMCR 0x100
-#define DMCR_HS_EN (1 << 6)
-#define DMCR_CHIP_EN (1 << 5)
-#define DMCR_SFRST (1 << 4)
-#define DMCR_GOSUSP (1 << 3)
-#define DMCR_GLINT_EN (1 << 2)
-#define DMCR_HALF_SPEED (1 << 1)
-#define DMCR_CAP_RMWAKUP (1 << 0)
-
-/* Device Address Register(0x104) */
-#define FOTG210_DAR 0x104
-#define DAR_AFT_CONF (1 << 7)
-
-/* Device Test Register(0x108) */
-#define FOTG210_DTR 0x108
-#define DTR_TST_CLRFF (1 << 0)
-
-/* PHY Test Mode Selector register(0x114) */
-#define FOTG210_PHYTMSR 0x114
-#define PHYTMSR_TST_PKT (1 << 4)
-#define PHYTMSR_TST_SE0NAK (1 << 3)
-#define PHYTMSR_TST_KSTA (1 << 2)
-#define PHYTMSR_TST_JSTA (1 << 1)
-#define PHYTMSR_UNPLUG (1 << 0)
-
-/* Cx configuration and FIFO Empty Status register(0x120) */
-#define FOTG210_DCFESR 0x120
-#define DCFESR_FIFO_EMPTY(fifo) (1 << 8 << (fifo))
-#define DCFESR_CX_EMP (1 << 5)
-#define DCFESR_CX_CLR (1 << 3)
-#define DCFESR_CX_STL (1 << 2)
-#define DCFESR_TST_PKDONE (1 << 1)
-#define DCFESR_CX_DONE (1 << 0)
-
-/* Device IDLE Counter Register(0x124) */
-#define FOTG210_DICR 0x124
-
-/* Device Mask of Interrupt Group Register (0x130) */
-#define FOTG210_DMIGR 0x130
-#define DMIGR_MINT_G0 (1 << 0)
-
-/* Device Mask of Interrupt Source Group 0(0x134) */
-#define FOTG210_DMISGR0 0x134
-#define DMISGR0_MCX_COMEND (1 << 3)
-#define DMISGR0_MCX_OUT_INT (1 << 2)
-#define DMISGR0_MCX_IN_INT (1 << 1)
-#define DMISGR0_MCX_SETUP_INT (1 << 0)
-
-/* Device Mask of Interrupt Source Group 1 Register(0x138)*/
-#define FOTG210_DMISGR1 0x138
-#define DMISGR1_MF3_IN_INT (1 << 19)
-#define DMISGR1_MF2_IN_INT (1 << 18)
-#define DMISGR1_MF1_IN_INT (1 << 17)
-#define DMISGR1_MF0_IN_INT (1 << 16)
-#define DMISGR1_MF_IN_INT(fifo) (1 << (16 + (fifo)))
-#define DMISGR1_MF3_SPK_INT (1 << 7)
-#define DMISGR1_MF3_OUT_INT (1 << 6)
-#define DMISGR1_MF2_SPK_INT (1 << 5)
-#define DMISGR1_MF2_OUT_INT (1 << 4)
-#define DMISGR1_MF1_SPK_INT (1 << 3)
-#define DMISGR1_MF1_OUT_INT (1 << 2)
-#define DMISGR1_MF0_SPK_INT (1 << 1)
-#define DMISGR1_MF0_OUT_INT (1 << 0)
-#define DMISGR1_MF_OUTSPK_INT(fifo) (0x3 << (fifo) * 2)
-
-/* Device Mask of Interrupt Source Group 2 Register (0x13C) */
-#define FOTG210_DMISGR2 0x13C
-#define DMISGR2_MDMA_ERROR (1 << 8)
-#define DMISGR2_MDMA_CMPLT (1 << 7)
-
-/* Device Interrupt group Register (0x140) */
-#define FOTG210_DIGR 0x140
-#define DIGR_INT_G2 (1 << 2)
-#define DIGR_INT_G1 (1 << 1)
-#define DIGR_INT_G0 (1 << 0)
-
-/* Device Interrupt Source Group 0 Register (0x144) */
-#define FOTG210_DISGR0 0x144
-#define DISGR0_CX_COMABT_INT (1 << 5)
-#define DISGR0_CX_COMFAIL_INT (1 << 4)
-#define DISGR0_CX_COMEND_INT (1 << 3)
-#define DISGR0_CX_OUT_INT (1 << 2)
-#define DISGR0_CX_IN_INT (1 << 1)
-#define DISGR0_CX_SETUP_INT (1 << 0)
-
-/* Device Interrupt Source Group 1 Register (0x148) */
-#define FOTG210_DISGR1 0x148
-#define DISGR1_OUT_INT(fifo) (1 << ((fifo) * 2))
-#define DISGR1_SPK_INT(fifo) (1 << 1 << ((fifo) * 2))
-#define DISGR1_IN_INT(fifo) (1 << 16 << (fifo))
-
-/* Device Interrupt Source Group 2 Register (0x14C) */
-#define FOTG210_DISGR2 0x14C
-#define DISGR2_DMA_ERROR (1 << 8)
-#define DISGR2_DMA_CMPLT (1 << 7)
-#define DISGR2_RX0BYTE_INT (1 << 6)
-#define DISGR2_TX0BYTE_INT (1 << 5)
-#define DISGR2_ISO_SEQ_ABORT_INT (1 << 4)
-#define DISGR2_ISO_SEQ_ERR_INT (1 << 3)
-#define DISGR2_RESM_INT (1 << 2)
-#define DISGR2_SUSP_INT (1 << 1)
-#define DISGR2_USBRST_INT (1 << 0)
-
-/* Device Receive Zero-Length Data Packet Register (0x150)*/
-#define FOTG210_RX0BYTE 0x150
-#define RX0BYTE_EP8 (1 << 7)
-#define RX0BYTE_EP7 (1 << 6)
-#define RX0BYTE_EP6 (1 << 5)
-#define RX0BYTE_EP5 (1 << 4)
-#define RX0BYTE_EP4 (1 << 3)
-#define RX0BYTE_EP3 (1 << 2)
-#define RX0BYTE_EP2 (1 << 1)
-#define RX0BYTE_EP1 (1 << 0)
-
-/* Device Transfer Zero-Length Data Packet Register (0x154)*/
-#define FOTG210_TX0BYTE 0x154
-#define TX0BYTE_EP8 (1 << 7)
-#define TX0BYTE_EP7 (1 << 6)
-#define TX0BYTE_EP6 (1 << 5)
-#define TX0BYTE_EP5 (1 << 4)
-#define TX0BYTE_EP4 (1 << 3)
-#define TX0BYTE_EP3 (1 << 2)
-#define TX0BYTE_EP2 (1 << 1)
-#define TX0BYTE_EP1 (1 << 0)
-
-/* Device IN Endpoint x MaxPacketSize Register(0x160+4*(x-1)) */
-#define FOTG210_INEPMPSR(ep) (0x160 + 4 * ((ep) - 1))
-#define INOUTEPMPSR_MPS(mps) ((mps) & 0x2FF)
-#define INOUTEPMPSR_STL_EP (1 << 11)
-#define INOUTEPMPSR_RESET_TSEQ (1 << 12)
-
-/* Device OUT Endpoint x MaxPacketSize Register(0x180+4*(x-1)) */
-#define FOTG210_OUTEPMPSR(ep) (0x180 + 4 * ((ep) - 1))
-
-/* Device Endpoint 1~4 Map Register (0x1A0) */
-#define FOTG210_EPMAP 0x1A0
-#define EPMAP_FIFONO(ep, dir) \
- ((((ep) - 1) << ((ep) - 1) * 8) << ((dir) ? 0 : 4))
-#define EPMAP_FIFONOMSK(ep, dir) \
- ((3 << ((ep) - 1) * 8) << ((dir) ? 0 : 4))
-
-/* Device FIFO Map Register (0x1A8) */
-#define FOTG210_FIFOMAP 0x1A8
-#define FIFOMAP_DIROUT(fifo) (0x0 << 4 << (fifo) * 8)
-#define FIFOMAP_DIRIN(fifo) (0x1 << 4 << (fifo) * 8)
-#define FIFOMAP_BIDIR(fifo) (0x2 << 4 << (fifo) * 8)
-#define FIFOMAP_NA(fifo) (0x3 << 4 << (fifo) * 8)
-#define FIFOMAP_EPNO(ep) ((ep) << ((ep) - 1) * 8)
-#define FIFOMAP_EPNOMSK(ep) (0xF << ((ep) - 1) * 8)
-
-/* Device FIFO Confuguration Register (0x1AC) */
-#define FOTG210_FIFOCF 0x1AC
-#define FIFOCF_TYPE(type, fifo) ((type) << (fifo) * 8)
-#define FIFOCF_BLK_SIN(fifo) (0x0 << (fifo) * 8 << 2)
-#define FIFOCF_BLK_DUB(fifo) (0x1 << (fifo) * 8 << 2)
-#define FIFOCF_BLK_TRI(fifo) (0x2 << (fifo) * 8 << 2)
-#define FIFOCF_BLKSZ_512(fifo) (0x0 << (fifo) * 8 << 4)
-#define FIFOCF_BLKSZ_1024(fifo) (0x1 << (fifo) * 8 << 4)
-#define FIFOCF_FIFO_EN(fifo) (0x1 << (fifo) * 8 << 5)
-
-/* Device FIFO n Instruction and Byte Count Register (0x1B0+4*n) */
-#define FOTG210_FIBCR(fifo) (0x1B0 + (fifo) * 4)
-#define FIBCR_BCFX 0x7FF
-#define FIBCR_FFRST (1 << 12)
-
-/* Device DMA Target FIFO Number Register (0x1C0) */
-#define FOTG210_DMATFNR 0x1C0
-#define DMATFNR_ACC_CXF (1 << 4)
-#define DMATFNR_ACC_F3 (1 << 3)
-#define DMATFNR_ACC_F2 (1 << 2)
-#define DMATFNR_ACC_F1 (1 << 1)
-#define DMATFNR_ACC_F0 (1 << 0)
-#define DMATFNR_ACC_FN(fifo) (1 << (fifo))
-#define DMATFNR_DISDMA 0
-
-/* Device DMA Controller Parameter setting 1 Register (0x1C8) */
-#define FOTG210_DMACPSR1 0x1C8
-#define DMACPSR1_DMA_LEN(len) (((len) & 0xFFFF) << 8)
-#define DMACPSR1_DMA_ABORT (1 << 3)
-#define DMACPSR1_DMA_TYPE(dir_in) (((dir_in) ? 1 : 0) << 1)
-#define DMACPSR1_DMA_START (1 << 0)
-
-/* Device DMA Controller Parameter setting 2 Register (0x1CC) */
-#define FOTG210_DMACPSR2 0x1CC
-
-/* Device DMA Controller Parameter setting 3 Register (0x1CC) */
-#define FOTG210_CXPORT 0x1D0
-
-struct fotg210_request {
- struct usb_request req;
- struct list_head queue;
-};
-
-struct fotg210_ep {
- struct usb_ep ep;
- struct fotg210_udc *fotg210;
-
- struct list_head queue;
- unsigned stall:1;
- unsigned wedged:1;
- unsigned use_dma:1;
-
- unsigned char epnum;
- unsigned char type;
- unsigned char dir_in;
- unsigned int maxp;
- const struct usb_endpoint_descriptor *desc;
-};
-
-struct fotg210_udc {
- spinlock_t lock; /* protect the struct */
- void __iomem *reg;
-
- unsigned long irq_trigger;
-
- struct usb_gadget gadget;
- struct usb_gadget_driver *driver;
-
- struct fotg210_ep *ep[FOTG210_MAX_NUM_EP];
-
- struct usb_request *ep0_req; /* for internal request */
- __le16 ep0_data;
- u8 ep0_dir; /* 0/0x80 out/in */
-
- u8 reenum; /* if re-enumeration */
-};
-
-#define gadget_to_fotg210(g) container_of((g), struct fotg210_udc, gadget)
diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c
index 931e6362a13d..c7e421b449f3 100644
--- a/drivers/usb/gadget/udc/m66592-udc.c
+++ b/drivers/usb/gadget/udc/m66592-udc.c
@@ -1519,7 +1519,7 @@ static int m66592_remove(struct platform_device *pdev)
usb_del_gadget_udc(&m66592->gadget);
- del_timer_sync(&m66592->timer);
+ timer_shutdown_sync(&m66592->timer);
iounmap(m66592->reg);
free_irq(platform_get_irq(pdev, 0), m66592);
m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);