From patchwork Thu Oct 8 00:48:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 7348141 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 0947F9F40A for ; Thu, 8 Oct 2015 00:49:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 158B52060A for ; Thu, 8 Oct 2015 00:49:42 +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 35B4820606 for ; Thu, 8 Oct 2015 00:49:41 +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 1ZjzOu-0005x0-Ue; Thu, 08 Oct 2015 00:49:40 +0000 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZjzOr-0005r0-SF for linux-rockchip@lists.infradead.org; Thu, 08 Oct 2015 00:49:38 +0000 Received: by pacfv12 with SMTP id fv12so37218365pac.2 for ; Wed, 07 Oct 2015 17:49:19 -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 :mime-version:content-type:content-transfer-encoding; bh=blnEf0ZCUMUIY+xvcbTihMbJ4JbiK28qu3+v8iG9Gl4=; b=KdaOPQzypqK6t1NSJqY4CaNxOGHPnEqT4B8gJfvfHcdH2ac0Bc+RKp6hpVz0Cf0yRe Q0ZN1Sk5fSXSH/s5sVKOaXE9O/+YVHiUavwbzWB0d/tzfUVii974r7HHnGRBLuCSd8US baRb8/IPLu7tkWl58jKHVG60C633R1wvJN/fY= 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:mime-version:content-type:content-transfer-encoding; bh=blnEf0ZCUMUIY+xvcbTihMbJ4JbiK28qu3+v8iG9Gl4=; b=SnvF0poXMhPhwvXxrh3sot3zIa6gdagKLNJhspwsQrld1eJfqxcnOE4P87nnGmmyTh hOHVzG+Bdrnj/THom4tjcLRC18hA5FPdKerq8xzztNgQnZlL9fYSo2IktxEgt/PS5BU8 zlqsO6fu3AGGgitgbsQ6l6zIZIXOfC30gJ4jTomGgysPFCNrY8S4CxcIC4aZprnu7G4n 6Eq5RXDL9JqG1w6nDBuXCp2xiy+riweCLq5CrjMiBe5i/3/BxKUepr8TJ30kpOsQQnC+ 1cQd2r/ukWKAgAx3ecTQ8UI3XlpDgMTIHPPSKusWwdrrMIjy122Ii+FUuDqOi4pSXA+t TaAQ== X-Gm-Message-State: ALoCoQnYsXNXly5UuYkyYxPWTPX7oBNS20qzCPO9l8Du519Z9D70vGpLvmncaNONBk48q7qlxfnZ X-Received: by 10.68.181.130 with SMTP id dw2mr4571685pbc.70.1444265359408; Wed, 07 Oct 2015 17:49:19 -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.18 (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 5/5] usb: dwc2: reduce dwc2 driver probe time Date: Wed, 7 Oct 2015 17:48:41 -0700 Message-Id: <1444265321-16768-6-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151007_174938_005214_F8A68A7F X-CRM114-Status: GOOD ( 17.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 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 From: Yunzhi Li I found that the probe function of dwc2 driver takes much time when kernel boot up. There are many long delays in the probe function these take almost 1 second. This patch trying to reduce unnecessary delay time. In dwc2_core_reset() I see it use two at least 20ms delays to wait AHB idle and core soft reset, but dwc2 data book said that dwc2 core soft reset and AHB idle just need a few clocks (I think it refers to AHB clock, and AHB clock run at 150MHz in my RK3288 board), so 20ms is too long, delay 1us for wait AHB idle and soft reset is enough. And in dwc2_get_hwparams() it takes 150ms to wait ForceHostMode and ForceDeviceMode valid but in data book it said software must wait at least 25ms before the change to take effect, so I reduce this time to 25ms~50ms. By the way, is there any state bit show that the force mode take effect ? Could we poll curmod bit for figuring out if the change take effect ? It seems that usleep_range() at boot time will pick the longest value in the range. In dwc2_core_reset() there is a very long delay takes 200ms, and this function run twice when probe, could any one tell me is this delay time resonable ? I have tried this patch in my RK3288-evb board. It works well. Signed-off-by: Yunzhi Li Signed-off-by: Douglas Anderson --- drivers/usb/dwc2/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 27ade0c..59fe48f 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -491,7 +491,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg) /* Wait for AHB master IDLE state */ do { - usleep_range(20000, 40000); + udelay(1); greset = dwc2_readl(hsotg->regs + GRSTCTL); if (++count > 50) { dev_warn(hsotg->dev, @@ -506,7 +506,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg) greset |= GRSTCTL_CSFTRST; dwc2_writel(greset, hsotg->regs + GRSTCTL); do { - usleep_range(20000, 40000); + udelay(1); greset = dwc2_readl(hsotg->regs + GRSTCTL); if (++count > 50) { dev_warn(hsotg->dev, @@ -537,7 +537,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg) * NOTE: This long sleep is _very_ important, otherwise the core will * not stay in host mode after a connector ID change! */ - usleep_range(150000, 200000); + usleep_range(150000, 160000); return 0; } @@ -3107,7 +3107,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); dwc2_writel(gusbcfg | GUSBCFG_FORCEHOSTMODE, hsotg->regs + GUSBCFG); - usleep_range(100000, 150000); + usleep_range(25000, 50000); } gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); @@ -3116,7 +3116,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz); if (hsotg->dr_mode != USB_DR_MODE_HOST) { dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); - usleep_range(100000, 150000); + usleep_range(25000, 50000); } /* hwcfg2 */