From patchwork Fri Sep 11 01:13:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Branden X-Patchwork-Id: 53399 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 82E0222B19 for ; Fri, 11 Sep 2015 01:14:23 +0000 (UTC) Received: by lanb10 with SMTP id b10sf20660939lan.3 for ; Thu, 10 Sep 2015 18:14:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=h44iN7GEh/ohqtNsX5pQkehsuMVys39uHXTvJIrF9a8=; b=exz1X2RRhEfDNpPiumTpp5O2cPHQ+7rKyxSQ6t43m3SyGISYJM3OGiRSUjjFQuHUgv nhd+tHyeBd7PXzMZSIarGWdQ1i+gu+7UDtGMEPgrTLYlqGuTIxLOZDExaGXPqVLIJuYt a5PsgvqzEunMA75Sd3SLFNwsuiVSzXpV8wf/jP4JTuWt015J/esxDSQkBaP2tjByJkp/ BLqwzzO9V6LkKJSusCNp3xIkrjXIhihnDKXaVJ45buaVVTOKDcOzDB4CfUSCadaOiCoF hVgcg2d13Sd6zYBB9gb91kD4rVbT1qSjA2TSLXs8dwomKfC1AAveHwV5dJLLn74M3Kmq dGlQ== X-Gm-Message-State: ALoCoQnwU1UE2M9JePzMMztq5gyOsqmvFMDylX7XxMw6EEAUgeESSBkNNPMLnrLUSdWQcXlzK//r X-Received: by 10.152.21.233 with SMTP id y9mr10560487lae.5.1441934062021; Thu, 10 Sep 2015 18:14:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.180.75 with SMTP id dm11ls248216lac.102.gmail; Thu, 10 Sep 2015 18:14:21 -0700 (PDT) X-Received: by 10.112.149.68 with SMTP id ty4mr33011605lbb.74.1441934061839; Thu, 10 Sep 2015 18:14:21 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id e1si12139496laa.33.2015.09.10.18.14.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2015 18:14:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbpo4 with SMTP id o4so32236846lbp.2 for ; Thu, 10 Sep 2015 18:14:21 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr38016639lbc.41.1441934061690; Thu, 10 Sep 2015 18:14:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1283979lbq; Thu, 10 Sep 2015 18:14:20 -0700 (PDT) X-Received: by 10.66.101.7 with SMTP id fc7mr78508053pab.57.1441934060171; Thu, 10 Sep 2015 18:14:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ev3si10344442pbc.67.2015.09.10.18.14.16; Thu, 10 Sep 2015 18:14:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbbIKBOP (ORCPT + 28 others); Thu, 10 Sep 2015 21:14:15 -0400 Received: from mail-gw3-out.broadcom.com ([216.31.210.64]:59084 "EHLO mail-gw3-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbbIKBON (ORCPT ); Thu, 10 Sep 2015 21:14:13 -0400 X-IronPort-AV: E=Sophos;i="5.17,508,1437462000"; d="scan'208";a="74636523" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw3-out.broadcom.com with ESMTP; 10 Sep 2015 18:37:25 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 10 Sep 2015 18:14:12 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.235.1; Thu, 10 Sep 2015 18:14:12 -0700 Received: from mail.broadcom.com (unknown [10.136.13.65]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 8B64B40FF0; Thu, 10 Sep 2015 18:11:34 -0700 (PDT) From: Scott Branden To: John Youn , Greg Kroah-Hartman , , Roman Bacik CC: , , Scott Branden Subject: [PATCH v3 1/1] usb: dwc2: gadget: parity fix in isochronous mode Date: Thu, 10 Sep 2015 18:13:43 -0700 Message-ID: <1441934023-6557-2-git-send-email-sbranden@broadcom.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1441934023-6557-1-git-send-email-sbranden@broadcom.com> References: <1441934023-6557-1-git-send-email-sbranden@broadcom.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sbranden@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Signed-off-by: Scott Branden --- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 58 ++++++++++++++++++++++++++++++++++++++++++----- drivers/usb/dwc2/hw.h | 1 + 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 0ed87620..a5634fd 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 has_correct_parity:1; char name[10]; }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4d47b7c..efaab76 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1916,6 +1916,19 @@ static void s3c_hsotg_complete_in(struct dwc2_hsotg *hsotg, s3c_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); } +static void s3c_hsotg_change_ep_iso_parity(struct dwc2_hsotg *hsotg, + u32 epctl_reg) +{ + u32 ctrl; + + ctrl = readl(hsotg->regs + epctl_reg); + if (ctrl & DXEPCTL_EOFRNUM) + ctrl |= DXEPCTL_SETEVENFR; + else + ctrl |= DXEPCTL_SETODDFR; + writel(ctrl, hsotg->regs + epctl_reg); +} + /** * s3c_hsotg_epint - handle an in/out endpoint interrupt * @hsotg: The driver state @@ -1954,12 +1967,9 @@ static void s3c_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, ints &= ~DXEPINT_XFERCOMPL; if (ints & DXEPINT_XFERCOMPL) { + hs_ep->has_correct_parity = 1; if (hs_ep->isochronous && hs_ep->interval == 1) { - if (ctrl & DXEPCTL_EOFRNUM) - ctrl |= DXEPCTL_SETEVENFR; - else - ctrl |= DXEPCTL_SETODDFR; - writel(ctrl, hsotg->regs + epctl_reg); + s3c_hsotg_change_ep_iso_parity(hsotg, epctl_reg); } dev_dbg(hsotg->dev, @@ -2316,7 +2326,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 +2592,40 @@ irq_retry: s3c_hsotg_dump(hsotg); } + if (gintsts & GINTSTS_INCOMPL_SOIN) { + u32 idx, epctl_reg; + struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n", __func__); + for (idx = 1; idx < hsotg->num_of_eps; idx++) { + hs_ep = hsotg->eps_in[idx]; + + if (!hs_ep->isochronous || hs_ep->has_correct_parity) + continue; + + epctl_reg = DIEPCTL(idx); + s3c_hsotg_change_ep_iso_parity(hsotg, epctl_reg); + } + writel(GINTSTS_INCOMPL_SOIN, hsotg->regs + GINTSTS); + } + + if (gintsts & GINTSTS_INCOMPL_SOOUT) { + u32 idx, epctl_reg; + struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOOUT\n", __func__); + for (idx = 1; idx < hsotg->num_of_eps; idx++) { + hs_ep = hsotg->eps_out[idx]; + + if (!hs_ep->isochronous || hs_ep->has_correct_parity) + continue; + + epctl_reg = DOEPCTL(idx); + s3c_hsotg_change_ep_iso_parity(hsotg, 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->has_correct_parity = 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)