usb: chipidea: add controller reset API
Add controller reset API, currently it is used for device mode only. It may be used for host/otg driver in future. Ususally, we need this API for dual-role switch and back from hibernation suspend to let the controller at default state. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
947c88592f
commit
cdd278f21e
@@ -384,6 +384,26 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hw_controller_reset: do controller reset
|
||||||
|
* @ci: the controller
|
||||||
|
*
|
||||||
|
* This function returns an error code
|
||||||
|
*/
|
||||||
|
static 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)
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hw_device_reset: resets chip (execute without interruption)
|
* hw_device_reset: resets chip (execute without interruption)
|
||||||
* @ci: the controller
|
* @ci: the controller
|
||||||
@@ -392,13 +412,17 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
|
|||||||
*/
|
*/
|
||||||
int hw_device_reset(struct ci_hdrc *ci, u32 mode)
|
int hw_device_reset(struct ci_hdrc *ci, u32 mode)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* should flush & stop before reset */
|
/* should flush & stop before reset */
|
||||||
hw_write(ci, OP_ENDPTFLUSH, ~0, ~0);
|
hw_write(ci, OP_ENDPTFLUSH, ~0, ~0);
|
||||||
hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
|
hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
|
||||||
|
|
||||||
hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
|
ret = hw_controller_reset(ci);
|
||||||
while (hw_read(ci, OP_USBCMD, USBCMD_RST))
|
if (ret) {
|
||||||
udelay(10); /* not RTOS friendly */
|
dev_err(ci->dev, "error resetting controller, ret=%d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (ci->platdata->notify_event)
|
if (ci->platdata->notify_event)
|
||||||
ci->platdata->notify_event(ci,
|
ci->platdata->notify_event(ci,
|
||||||
|
|||||||
Reference in New Issue
Block a user