Commit ae79dd5d authored by Vahram Aharonyan's avatar Vahram Aharonyan Committed by Felipe Balbi

usb: dwc2: gadget: Correct dwc2_hsotg_ep_stop_xfr() function

Correct dwc2_hsotg_ep_stop_xfr() function to follow dwc2 programming
guide for setting NAK on specific endpoint, disabling it and flushing
corresponding FIFO.

Current code does not take into account whether core acts in shared or
dedicated FIFO mode, current endpoint is periodic or not. It does not
clear EPDISBLD interrupt after programming of DXEPCTL_EPDIS, does not
flush shared TX FIFO and tries to clear global out NAK in wrong manner
instead of setting DCTL_CGOUTNAK.
Signed-off-by: default avatarVahram Aharonyan <vahrama@synopsys.com>
Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent f0afdb42
...@@ -3868,13 +3868,25 @@ static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg, ...@@ -3868,13 +3868,25 @@ static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
dev_dbg(hsotg->dev, "%s: stopping transfer on %s\n", __func__, dev_dbg(hsotg->dev, "%s: stopping transfer on %s\n", __func__,
hs_ep->name); hs_ep->name);
if (hs_ep->dir_in) { if (hs_ep->dir_in) {
if (hsotg->dedicated_fifos || hs_ep->periodic) {
__orr32(hsotg->regs + epctrl_reg, DXEPCTL_SNAK); __orr32(hsotg->regs + epctrl_reg, DXEPCTL_SNAK);
/* Wait for Nak effect */ /* Wait for Nak effect */
if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg, if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg,
DXEPINT_INEPNAKEFF, 100)) DXEPINT_INEPNAKEFF, 100))
dev_warn(hsotg->dev, dev_warn(hsotg->dev,
"%s: timeout DIEPINT.NAKEFF\n", __func__); "%s: timeout DIEPINT.NAKEFF\n",
__func__);
} else {
__orr32(hsotg->regs + DCTL, DCTL_SGNPINNAK);
/* Wait for Nak effect */
if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS,
GINTSTS_GINNAKEFF, 100))
dev_warn(hsotg->dev,
"%s: timeout GINTSTS.GINNAKEFF\n",
__func__);
}
} else { } else {
if (!(dwc2_readl(hsotg->regs + GINTSTS) & GINTSTS_GOUTNAKEFF)) if (!(dwc2_readl(hsotg->regs + GINTSTS) & GINTSTS_GOUTNAKEFF))
__orr32(hsotg->regs + DCTL, DCTL_SGOUTNAK); __orr32(hsotg->regs + DCTL, DCTL_SGOUTNAK);
...@@ -3882,8 +3894,8 @@ static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg, ...@@ -3882,8 +3894,8 @@ static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
/* Wait for global nak to take effect */ /* Wait for global nak to take effect */
if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS,
GINTSTS_GOUTNAKEFF, 100)) GINTSTS_GOUTNAKEFF, 100))
dev_warn(hsotg->dev, dev_warn(hsotg->dev, "%s: timeout GINTSTS.GOUTNAKEFF\n",
"%s: timeout GINTSTS.GOUTNAKEFF\n", __func__); __func__);
} }
/* Disable ep */ /* Disable ep */
...@@ -3894,21 +3906,27 @@ static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg, ...@@ -3894,21 +3906,27 @@ static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
dev_warn(hsotg->dev, dev_warn(hsotg->dev,
"%s: timeout DOEPCTL.EPDisable\n", __func__); "%s: timeout DOEPCTL.EPDisable\n", __func__);
/* Clear EPDISBLD interrupt */
__orr32(hsotg->regs + epint_reg, DXEPINT_EPDISBLD);
if (hs_ep->dir_in) { if (hs_ep->dir_in) {
if (hsotg->dedicated_fifos) { unsigned short fifo_index;
dwc2_writel(GRSTCTL_TXFNUM(hs_ep->fifo_index) |
GRSTCTL_TXFFLSH, hsotg->regs + GRSTCTL); if (hsotg->dedicated_fifos || hs_ep->periodic)
/* Wait for fifo flush */ fifo_index = hs_ep->fifo_index;
if (dwc2_hsotg_wait_bit_set(hsotg, GRSTCTL, else
GRSTCTL_TXFFLSH, 100)) fifo_index = 0;
dev_warn(hsotg->dev,
"%s: timeout flushing fifos\n", /* Flush TX FIFO */
__func__); dwc2_flush_tx_fifo(hsotg, fifo_index);
}
/* TODO: Flush shared tx fifo */ /* Clear Global In NP NAK in Shared FIFO for non periodic ep */
if (!hsotg->dedicated_fifos && !hs_ep->periodic)
__orr32(hsotg->regs + DCTL, DCTL_CGNPINNAK);
} else { } else {
/* Remove global NAKs */ /* Remove global NAKs */
__bic32(hsotg->regs + DCTL, DCTL_SGOUTNAK); __orr32(hsotg->regs + DCTL, DCTL_CGOUTNAK);
} }
} }
......
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