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

usb: cdns3: gadget: improve the set_configuration handling

- Delete the duplicated EP_CMD_ERDY and EP_CMD_REQ_CMPL setting
- Prepare the next setup before setting EP_CMD_ERDY and EP_CMD_REQ_CMPL,
it could avoid a bug that DMA hang at EP0 OUT for DEV_VER_NXP_V1
- Delete the duplicated cdns3_set_hw_configuration calling at
cdns3_req_ep0_set_configuration, the composite.c will handle
this request, and call .ep0_queue back, and at .ep_queue it will
call cdns3_set_hw_configuration.
- Move cdns3_allow_enable_l1 into cdns3_set_hw_configuration since
it is part of this function.
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 7a410953
...@@ -161,13 +161,12 @@ static int cdns3_req_ep0_set_configuration(struct cdns3_device *priv_dev, ...@@ -161,13 +161,12 @@ static int cdns3_req_ep0_set_configuration(struct cdns3_device *priv_dev,
if (result) if (result)
return result; return result;
if (config) { if (!config) {
cdns3_set_hw_configuration(priv_dev);
} else {
cdns3_hw_reset_eps_config(priv_dev); cdns3_hw_reset_eps_config(priv_dev);
usb_gadget_set_state(&priv_dev->gadget, usb_gadget_set_state(&priv_dev->gadget,
USB_STATE_ADDRESS); USB_STATE_ADDRESS);
} }
break; break;
case USB_STATE_CONFIGURED: case USB_STATE_CONFIGURED:
result = cdns3_ep0_delegate_req(priv_dev, ctrl_req); result = cdns3_ep0_delegate_req(priv_dev, ctrl_req);
...@@ -707,7 +706,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, ...@@ -707,7 +706,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep); struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep);
struct cdns3_device *priv_dev = priv_ep->cdns3_dev; struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
unsigned long flags; unsigned long flags;
int erdy_sent = 0;
int ret = 0; int ret = 0;
u8 zlp = 0; u8 zlp = 0;
...@@ -723,15 +721,8 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, ...@@ -723,15 +721,8 @@ 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) {
cdns3_select_ep(priv_dev, 0x00); cdns3_select_ep(priv_dev, 0x00);
erdy_sent = !priv_dev->hw_configured_flag;
cdns3_set_hw_configuration(priv_dev); cdns3_set_hw_configuration(priv_dev);
if (!erdy_sent)
cdns3_ep0_complete_setup(priv_dev, 0, 1); cdns3_ep0_complete_setup(priv_dev, 0, 1);
cdns3_allow_enable_l1(priv_dev, 1);
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;
......
...@@ -1315,7 +1315,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) ...@@ -1315,7 +1315,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev)
return; return;
writel(USB_CONF_CFGSET, &priv_dev->regs->usb_conf); writel(USB_CONF_CFGSET, &priv_dev->regs->usb_conf);
writel(EP_CMD_ERDY | EP_CMD_REQ_CMPL, &priv_dev->regs->ep_cmd);
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);
...@@ -1332,6 +1331,8 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) ...@@ -1332,6 +1331,8 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev)
cdns3_start_all_request(priv_dev, priv_ep); cdns3_start_all_request(priv_dev, priv_ep);
} }
} }
cdns3_allow_enable_l1(priv_dev, 1);
} }
/** /**
......
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