Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753466AbbHRPpn (ORCPT ); Tue, 18 Aug 2015 11:45:43 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:39836 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752578AbbHRPpl (ORCPT ); Tue, 18 Aug 2015 11:45:41 -0400 X-IronPort-AV: E=Sophos;i="5.15,702,1432623600"; d="scan'208";a="72788956" From: Scott Branden To: John Youn , Greg Kroah-Hartman , CC: , , Roman Bacik , Scott Branden Subject: [PATCH 1/1] usb: dwc2: gadget: parity fix in isochronous mode Date: Tue, 18 Aug 2015 08:45:18 -0700 Message-ID: <1439912718-21045-2-git-send-email-sbranden@broadcom.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1439912718-21045-1-git-send-email-sbranden@broadcom.com> References: <1439912718-21045-1-git-send-email-sbranden@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4485 Lines: 132 From: Roman Bacik USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd microframes. This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is received. Signed-off-by: Roman Bacik Reviewed-by: Abhinav Ratna Reviewed-by: Srinath Mannam Reviewed-by: Scott Branden Signed-off-by: Scott Branden --- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/usb/dwc2/hw.h | 1 + 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 0ed87620..954d1cd 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int parity_set:1; char name[10]; }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4d47b7c..28e4393 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1954,6 +1954,8 @@ static void s3c_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, ints &= ~DXEPINT_XFERCOMPL; if (ints & DXEPINT_XFERCOMPL) { + if (hs_ep->isochronous && !hs_ep->parity_set) + hs_ep->parity_set = 1; if (hs_ep->isochronous && hs_ep->interval == 1) { if (ctrl & DXEPCTL_EOFRNUM) ctrl |= DXEPCTL_SETEVENFR; @@ -2316,7 +2318,8 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, GINTSTS_CONIDSTSCHNG | GINTSTS_USBRST | GINTSTS_RESETDET | GINTSTS_ENUMDONE | GINTSTS_OTGINT | GINTSTS_USBSUSP | - GINTSTS_WKUPINT, + GINTSTS_WKUPINT | + GINTSTS_INCOMPL_SOIN | GINTSTS_INCOMPL_SOOUT, hsotg->regs + GINTMSK); if (using_dma(hsotg)) @@ -2581,6 +2584,48 @@ irq_retry: s3c_hsotg_dump(hsotg); } + if (gintsts & GINTSTS_INCOMPL_SOIN) { + u32 idx; + struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n", __func__); + for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_in[idx]; + if (hs_ep->isochronous && !hs_ep->parity_set) { + u32 epctl_reg = DIEPCTL(idx); + u32 ctrl = readl(hsotg->regs + epctl_reg); + + if (ctrl & DXEPCTL_EOFRNUM) + ctrl |= DXEPCTL_SETEVENFR; + else + ctrl |= DXEPCTL_SETODDFR; + writel(ctrl, hsotg->regs + epctl_reg); + } + } + writel(GINTSTS_INCOMPL_SOIN, hsotg->regs + GINTSTS); + } + + if (gintsts & GINTSTS_INCOMPL_SOOUT) { + u32 idx; + struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOOUT\n", __func__); + for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_out[idx]; + if (hs_ep->isochronous && !hs_ep->parity_set) { + u32 epctl_reg = DOEPCTL(idx); + u32 ctrl = readl(hsotg->regs + epctl_reg); + + if (ctrl & DXEPCTL_EOFRNUM) + ctrl |= DXEPCTL_SETEVENFR; + else + ctrl |= DXEPCTL_SETODDFR; + writel(ctrl, hsotg->regs + epctl_reg); + } + } + writel(GINTSTS_INCOMPL_SOOUT, hsotg->regs + GINTSTS); + } + /* * if we've had fifo events, we should try and go around the * loop again to see if there's any point in returning yet. @@ -2667,6 +2712,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, hs_ep->periodic = 0; hs_ep->halted = 0; hs_ep->interval = desc->bInterval; + hs_ep->parity_set = 0; if (hs_ep->interval > 1 && hs_ep->mc > 1) dev_err(hsotg->dev, "MC > 1 when interval is not 1\n"); diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h index d0a5ed8..553f246 100644 --- a/drivers/usb/dwc2/hw.h +++ b/drivers/usb/dwc2/hw.h @@ -142,6 +142,7 @@ #define GINTSTS_RESETDET (1 << 23) #define GINTSTS_FET_SUSP (1 << 22) #define GINTSTS_INCOMPL_IP (1 << 21) +#define GINTSTS_INCOMPL_SOOUT (1 << 21) #define GINTSTS_INCOMPL_SOIN (1 << 20) #define GINTSTS_OEPINT (1 << 19) #define GINTSTS_IEPINT (1 << 18) -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/