Commit b21cf937 authored by Peter Chen's avatar Peter Chen Committed by Felipe Balbi

usb: cdns3: gadget: move wait configuration operation

After commit f4cfe5ce ("usb: cdns3: gadget: improve the
set_configuration handling"), the software will inform the
hardware the request has finished at cdns3_ep0_complete_setup.
The configuration set bit is only set after request has finished,
so it needs to move waiting operation after that. Meanwhile,
if it is timeout, it will show warning message and return error.
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 9f650135
...@@ -717,9 +717,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, ...@@ -717,9 +717,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
/* send STATUS stage. Should be called only for SET_CONFIGURATION */ /* send STATUS stage. Should be called only for SET_CONFIGURATION */
if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) { if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) {
u32 val;
cdns3_select_ep(priv_dev, 0x00); cdns3_select_ep(priv_dev, 0x00);
cdns3_set_hw_configuration(priv_dev); cdns3_set_hw_configuration(priv_dev);
cdns3_ep0_complete_setup(priv_dev, 0, 1); cdns3_ep0_complete_setup(priv_dev, 0, 1);
/* wait until configuration set */
ret = readl_poll_timeout_atomic(&priv_dev->regs->usb_sts, val,
val & USB_STS_CFGSTS_MASK, 1, 100);
if (ret == -ETIMEDOUT)
dev_warn(priv_dev->dev, "timeout for waiting configuration set\n");
request->actual = 0; request->actual = 0;
priv_dev->status_completion_no_call = true; priv_dev->status_completion_no_call = true;
priv_dev->pending_status_request = request; priv_dev->pending_status_request = request;
...@@ -731,7 +739,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, ...@@ -731,7 +739,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
* ep0_queue is back. * ep0_queue is back.
*/ */
queue_work(system_freezable_wq, &priv_dev->pending_status_wq); queue_work(system_freezable_wq, &priv_dev->pending_status_wq);
return 0; return ret;
} }
if (!list_empty(&priv_ep->pending_req_list)) { if (!list_empty(&priv_ep->pending_req_list)) {
......
...@@ -1310,7 +1310,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) ...@@ -1310,7 +1310,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev)
{ {
struct cdns3_endpoint *priv_ep; struct cdns3_endpoint *priv_ep;
struct usb_ep *ep; struct usb_ep *ep;
int val;
if (priv_dev->hw_configured_flag) if (priv_dev->hw_configured_flag)
return; return;
...@@ -1320,10 +1319,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) ...@@ -1320,10 +1319,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev)
cdns3_set_register_bit(&priv_dev->regs->usb_conf, cdns3_set_register_bit(&priv_dev->regs->usb_conf,
USB_CONF_U1EN | USB_CONF_U2EN); USB_CONF_U1EN | USB_CONF_U2EN);
/* wait until configuration set */
readl_poll_timeout_atomic(&priv_dev->regs->usb_sts, val,
val & USB_STS_CFGSTS_MASK, 1, 100);
priv_dev->hw_configured_flag = 1; priv_dev->hw_configured_flag = 1;
list_for_each_entry(ep, &priv_dev->gadget.ep_list, ep_list) { list_for_each_entry(ep, &priv_dev->gadget.ep_list, ep_list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment