summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2014-10-22 14:12:11 +0800
committerPeter Chen <peter.chen@freescale.com>2014-10-28 16:44:01 +0800
commitb19e4ef6dca1ec3c6a355bf9fd913305bad47cd5 (patch)
treed03aa4f241cff2364dc6f25f9c55ee0e3003d531 /drivers/usb
parent056b47174a5b4502a5adb906accd4ff7b43fe2dd (diff)
MLK-9709-2 usb: chipidea: add controller reset API
Add controller reset API, it may be used for host/otg driver in future. Signed-off-by: Peter Chen <peter.chen@freescale.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/chipidea/ci.h1
-rw-r--r--drivers/usb/chipidea/core.c26
2 files changed, 24 insertions, 3 deletions
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 3b6fa0492d2b..f26c510da24b 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -388,6 +388,7 @@ u8 hw_port_test_get(struct ci_hdrc *ci);
int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
u32 value, unsigned int timeout_ms);
+int hw_controller_reset(struct ci_hdrc *ci);
#ifdef CONFIG_PM
void ci_hdrc_delay_suspend(struct ci_hdrc *ci, int ms);
#else
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 80389bf5df6c..ef3114b65f7b 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -349,6 +349,28 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
}
/**
+ * hw_controller_reset: do controller reset
+ * @ci: the controller
+ *
+ * This function returns an error code
+ */
+int hw_controller_reset(struct ci_hdrc *ci)
+{
+ int count = 0;
+
+ hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
+ while (hw_read(ci, OP_USBCMD, USBCMD_RST)) {
+ udelay(10);
+ if (count++ > 1000) {
+ dev_err(ci->dev, "timeout for reset\n");
+ return -ETIMEDOUT;
+ }
+ }
+
+ return 0;
+}
+
+/**
* hw_device_reset: resets chip (execute without interruption)
* @ci: the controller
*
@@ -360,9 +382,7 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
hw_write(ci, OP_ENDPTFLUSH, ~0, ~0);
hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
- hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
- while (hw_read(ci, OP_USBCMD, USBCMD_RST))
- udelay(10); /* not RTOS friendly */
+ hw_controller_reset(ci);
if (ci->platdata->notify_event)
ci->platdata->notify_event(ci,