aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Majewski <l.majewski@samsung.com>2012-02-08 15:52:11 +0100
committerSangwook Lee <sangwook.lee@linaro.org>2012-03-08 12:23:01 +0000
commit3f2223aeff30d9e803706e70089ce5e2cac0deff (patch)
treed807c68601a0393fe527eca4ef6aa98d014752be
parent86394e3cf5e9f667721fc843214b985ec7cf9d14 (diff)
usb:hsotg:samsung: Cable disconnection recovery code
This code allows Samsung SoC's to recover its state when device is disconnected and connected during transfer. It is necessary, in such a scenario, to reinitialize the USB core to assure correct initial state of the driver. This operation is needed since the disconnect interrupt is only available at HOST mode, which is not supported by this driver. A simple mechanism with jiffies has been used to perform core reset only once. Tested with: - DFU gadget (various size of the sent data - also packet = MPS) - Ethernet gadget (CDC and RNDIS) - Multi Function Gadget (g_multi) HW: - Samsung's C210 Universal rev.0 Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index e4fb32fd23a..dea4a36493a 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -151,6 +151,7 @@ struct s3c_hsotg_ep {
* @ctrl_buff: Buffer for EP0 control requests.
* @ctrl_req: Request for EP0 control packets.
* @setup: NAK management for EP0 SETUP
+ * @last_rst: Time of last reset
* @eps: The endpoints being supplied to the gadget framework
*/
struct s3c_hsotg {
@@ -178,6 +179,7 @@ struct s3c_hsotg {
struct usb_gadget gadget;
unsigned int setup;
+ unsigned long last_rst;
struct s3c_hsotg_ep eps[];
};
@@ -2362,23 +2364,26 @@ irq_retry:
}
if (gintsts & S3C_GINTSTS_USBRst) {
+
+ u32 usb_status = readl(hsotg->regs + S3C_GOTGCTL);
+
dev_info(hsotg->dev, "%s: USBRst\n", __func__);
dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
readl(hsotg->regs + S3C_GNPTXSTS));
writel(S3C_GINTSTS_USBRst, hsotg->regs + S3C_GINTSTS);
- kill_all_requests(hsotg, &hsotg->eps[0], -ECONNRESET, true);
+ if (usb_status & S3C_GOTGCTL_BSESVLD) {
+ if (time_after(jiffies, hsotg->last_rst +
+ msecs_to_jiffies(200))) {
- /* it seems after a reset we can end up with a situation
- * where the TXFIFO still has data in it... the docs
- * suggest resetting all the fifos, so use the init_fifo
- * code to relayout and flush the fifos.
- */
+ kill_all_requests(hsotg, &hsotg->eps[0],
+ -ECONNRESET, true);
- s3c_hsotg_init_fifo(hsotg);
-
- s3c_hsotg_enqueue_setup(hsotg);
+ s3c_hsotg_core_init(hsotg);
+ hsotg->last_rst = jiffies;
+ }
+ }
}
/* check both FIFOs */
@@ -2421,6 +2426,7 @@ irq_retry:
writel(S3C_GINTSTS_USBSusp, hsotg->regs + S3C_GINTSTS);
call_gadget(hsotg, suspend);
+ s3c_hsotg_disconnect(hsotg);
}
if (gintsts & S3C_GINTSTS_WkUpInt) {
@@ -2433,6 +2439,8 @@ irq_retry:
if (gintsts & S3C_GINTSTS_ErlySusp) {
dev_dbg(hsotg->dev, "S3C_GINTSTS_ErlySusp\n");
writel(S3C_GINTSTS_ErlySusp, hsotg->regs + S3C_GINTSTS);
+
+ s3c_hsotg_disconnect(hsotg);
}
/* these next two seem to crop-up occasionally causing the core
@@ -2810,7 +2818,7 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver,
}
s3c_hsotg_core_init(hsotg);
-
+ hsotg->last_rst = jiffies;
dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name);
return 0;