Skip to content

Commit

Permalink
usb: cdns3: gadget: improve the set_configuration handling
Browse files Browse the repository at this point in the history
- 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.

(This patch is porting from upstream with some tiny changes)
Signed-off-by: Peter Chen <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
  • Loading branch information
Peter Chen committed Aug 5, 2020
1 parent 3979e33 commit 2475b58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
11 changes: 3 additions & 8 deletions drivers/usb/cdns3/ep0.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,12 @@ static int cdns3_req_ep0_set_configuration(struct cdns3_device *priv_dev,
if (result)
return result;

if (config) {
cdns3_set_hw_configuration(priv_dev);
} else {
if (!config) {
cdns3_hw_reset_eps_config(priv_dev);
usb_gadget_set_state(&priv_dev->gadget,
USB_STATE_ADDRESS);
}

break;
case USB_STATE_CONFIGURED:
result = cdns3_ep0_delegate_req(priv_dev, ctrl_req);
Expand Down Expand Up @@ -757,7 +756,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep);
struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
unsigned long flags;
int erdy_sent = 0;
int ret = 0;

cdns3_dbg(priv_ep->cdns3_dev, "Queue to Ep0%s L: %d\n",
Expand All @@ -776,11 +774,8 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) {
cdns3_select_ep(priv_dev, 0x00);

erdy_sent = !priv_dev->hw_configured_flag;
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);

request->actual = 0;
priv_dev->status_completion_no_call = true;
Expand Down
1 change: 0 additions & 1 deletion drivers/usb/cdns3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev)
return;

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,
USB_CONF_U1EN | USB_CONF_U2EN);
Expand Down

0 comments on commit 2475b58

Please sign in to comment.