From patchwork Thu Oct 8 00:48:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 7348171 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C9E7A9F40A for ; Thu, 8 Oct 2015 00:49:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D426720609 for ; Thu, 8 Oct 2015 00:49:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC3CD20604 for ; Thu, 8 Oct 2015 00:49:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZjzOw-0005yJ-IU; Thu, 08 Oct 2015 00:49:42 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZjzOt-0005qq-66 for linux-rockchip@lists.infradead.org; Thu, 08 Oct 2015 00:49:40 +0000 Received: by pablk4 with SMTP id lk4so36366270pab.3 for ; Wed, 07 Oct 2015 17:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V0HHixcQyOanjpRsin4Uwc4Cu3KAQ3V2n9Ge6e315S0=; b=QPuKd24+R4xUaiSP/fjMdkADEKzY6qIGrYcNuCumHiR65ia6MVOG+qpvdIJG2OQ2S8 pkMPUrWwrDqByU0humonzMo898Uh/UMBKQbvfFCzeJpDA9HkNvqO9hbwfOWwnD6gf8Ic XaH+GG7DmVqSLCicc2SvrR+RbtDCZiLxFzOL0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V0HHixcQyOanjpRsin4Uwc4Cu3KAQ3V2n9Ge6e315S0=; b=EDeYzsR8QZB62940FOFNpalFAC+1WR4p5prC1qKObpuHJmib/afqbveOiR4EbCtjwR pv8zrtQ/obMEONvw+AEO09shmYs2DfyKc7iw86QvTUbXj7Jqr0yc7f5EMzhXlWr8e8hy wrXpWkEU+2T5a3QlbKmr1/8eFg1biL/ZR4o7pkdNL7e3QMdUn/y3lhe7CnWdVCZteBCV Xnk2KdMyXglhR8zt35hGZQ+3q745jT1w0/syHR8Mhzr04s67fJrXy4nk4vFC6465eIiD kKTcjtUI43V5AV1SmZeFkr+qIpQE63+1nWWOHMIHti71uHVck7oanlU8HdD5jn0YZ6et Menw== X-Gm-Message-State: ALoCoQnFVn2CJgaKkwgHPotr9KefBrek+4pH6T1JMLgA7kjtxEuXAcPAeZzrDFFt2Hr5U14Gqlg3 X-Received: by 10.66.102.7 with SMTP id fk7mr4484990pab.119.1444265358526; Wed, 07 Oct 2015 17:49:18 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id fe8sm42011024pab.40.2015.10.07.17.49.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Oct 2015 17:49:18 -0700 (PDT) From: Douglas Anderson To: John Youn Subject: [PATCH 4/5] usb: dwc2: Speed dwc2_get_hwparams() on some host-only ports Date: Wed, 7 Oct 2015 17:48:40 -0700 Message-Id: <1444265321-16768-5-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1444265321-16768-1-git-send-email-dianders@chromium.org> References: <1444265321-16768-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151007_174939_333332_36F132C2 X-CRM114-Status: GOOD ( 13.82 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Heiko=20St=C3=BCbner?= , johnyoun@synopsys.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Yunzhi Li , Julius Werner MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On some host-only DWC2 ports (like the one in rk3288) when we set GUSBCFG_FORCEHOSTMODE in GUSBCFG and then read back, we don't see the bit set. Presumably that's because the port is always forced to HOST mode so there's no reason to implement these status bits. Since we know dwc2_core_reset() is always called before dwc2_get_hwparams() and we know dwc2_core_reset() should have set GUSBCFG_FORCEHOSTMODE whenever hsotg->dr_mode == USB_DR_MODE_HOST, we can just check hsotg->dr_mode to decide that we can skip the delays in dwc2_get_hwparams(). Signed-off-by: Douglas Anderson --- drivers/usb/dwc2/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 9f1c438..27ade0c 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -3070,7 +3070,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) unsigned width; u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4; u32 hptxfsiz, grxfsiz, gnptxfsiz; - u32 gusbcfg; + u32 gusbcfg = 0; /* * Attempt to ensure this device is really a DWC_otg Controller. @@ -3103,8 +3103,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz); /* Force host mode to get HPTXFSIZ / GNPTXFSIZ exact power on value */ - gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); - if (!(gusbcfg & GUSBCFG_FORCEHOSTMODE)) { + if (hsotg->dr_mode != USB_DR_MODE_HOST) { + gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); dwc2_writel(gusbcfg | GUSBCFG_FORCEHOSTMODE, hsotg->regs + GUSBCFG); usleep_range(100000, 150000); @@ -3114,7 +3114,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ); dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz); dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz); - if (!(gusbcfg & GUSBCFG_FORCEHOSTMODE)) { + if (hsotg->dr_mode != USB_DR_MODE_HOST) { dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); usleep_range(100000, 150000); }