From patchwork Mon Aug 31 16:17:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Branden X-Patchwork-Id: 52897 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 06E5622EB3 for ; Mon, 31 Aug 2015 16:17:58 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf39830577lbc.2 for ; Mon, 31 Aug 2015 09:17:57 -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=4wYsikCkkV9azLehQMDR9hcotAemxLggu6jw6ycMkdE=; b=eg0EWLgcr/UMQz7pkc0gkvcHdIRjjNzWAcNsthyLRkuqL4DXfJHpcDUZ5s/GiE/3+t QTxrwhu5iwtKj6EKFmasAAgtOnXRxtFg+ysVYSHLnkHeHXStzhS1idIao10HpTvaFD+K JLUpre0DagWhhwH8Q/DFTzulMx4aIo63oZBZeP7y6P0/AFvLiVN5937eS2EO5SzRJI3Y dIn6du9569rgQ/1oa8U4FFHYPbM38ssRo/NTMZqqNqKLU9SDkXQBHMXKQQYgPl9zm4JE 9VJvzW4/ZL4KwwgzJo4aRbiJ6nP0vjybCIGdjyM/1dx/629Zistw5hPN007YLygZIPrW 5trA== X-Gm-Message-State: ALoCoQkAjoOrH4B58wxb/+7Vwf3sO0J9NQc0qjbCWRGk0XoxWKL5ux1qROtxuKggCYMAE2MKLPP3 X-Received: by 10.112.138.2 with SMTP id qm2mr6414173lbb.19.1441037877011; Mon, 31 Aug 2015 09:17:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.232 with SMTP id d8ls512749lab.13.gmail; Mon, 31 Aug 2015 09:17:56 -0700 (PDT) X-Received: by 10.112.204.162 with SMTP id kz2mr10719381lbc.115.1441037876843; Mon, 31 Aug 2015 09:17:56 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id ea10si13533850lbc.34.2015.08.31.09.17.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 09:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbcbn3 with SMTP id bn3so63241450lbc.2 for ; Mon, 31 Aug 2015 09:17:56 -0700 (PDT) X-Received: by 10.152.198.140 with SMTP id jc12mr1735455lac.19.1441037876600; Mon, 31 Aug 2015 09:17:56 -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.151.194 with SMTP id us2csp1736082lbb; Mon, 31 Aug 2015 09:17:55 -0700 (PDT) X-Received: by 10.67.30.232 with SMTP id kh8mr39451301pad.36.1441037875251; Mon, 31 Aug 2015 09:17:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dl4si24510480pbc.167.2015.08.31.09.17.53; Mon, 31 Aug 2015 09:17:55 -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 S1753873AbbHaQRn (ORCPT + 28 others); Mon, 31 Aug 2015 12:17:43 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:13790 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753495AbbHaQRh (ORCPT ); Mon, 31 Aug 2015 12:17:37 -0400 X-IronPort-AV: E=Sophos;i="5.17,442,1437462000"; d="scan'208";a="73859130" Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw2-out.broadcom.com with ESMTP; 31 Aug 2015 09:40:43 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.3.235.1; Mon, 31 Aug 2015 09:17:34 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.235.1; Mon, 31 Aug 2015 09:17:34 -0700 Received: from mail.broadcom.com (unknown [10.136.13.65]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 5CDCB40FFB; Mon, 31 Aug 2015 09:15:02 -0700 (PDT) From: Scott Branden To: John Youn , Greg Kroah-Hartman , , Roman Bacik CC: , , Scott Branden Subject: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode Date: Mon, 31 Aug 2015 09:17:18 -0700 Message-ID: <1441037838-8864-2-git-send-email-sbranden@broadcom.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1441037838-8864-1-git-send-email-sbranden@broadcom.com> References: <1441037838-8864-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.169 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 | 51 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) 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..fac3e2f 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1954,6 +1954,7 @@ 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; @@ -2316,7 +2317,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 +2583,52 @@ irq_retry: s3c_hsotg_dump(hsotg); } + if (gintsts & GINTSTS_INCOMPL_SOIN) { + u32 idx, epctl_reg, ctrl; + 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->has_correct_parity) + continue; + + epctl_reg = DIEPCTL(idx); + 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, epctl_reg, ctrl; + 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->has_correct_parity) + continue; + + epctl_reg = DOEPCTL(idx); + 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 +2715,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)