From patchwork Thu Jan 11 02:40:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 10156779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DEA6F602B3 for ; Thu, 11 Jan 2018 02:41:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9FC228429 for ; Thu, 11 Jan 2018 02:41:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEBF728528; Thu, 11 Jan 2018 02:41:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 67A6828429 for ; Thu, 11 Jan 2018 02:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HAXhBxffdD7mxauZ9TiD8pfi8SABh4e8kOlI6+28n5w=; b=K3n2V4pPf++tu/s958U0FJxOde Bz57ALBzPmxGCvh9Trpfrghy0vjGtVi28l1ZQl6NUuBk6i//TVovOB614e5lzlcERbr5m82huFHcq sSc/aCnnsIY7U5MB41kYz1NC3EE3OVcW6I3lK5aFiulvz3yKZGWcntpHyG0dzIj+Yx59z08ejbMTC oMVWHGez3qWBUjWNf0u7APNahmU3ctmGzZ8nTTcLjJPMuWmM+5ubfnTE3i44ITV9p7/bCMEa/Uu5+ Y/7zkK5axNYfnaC79ULtEj8e4sObp05RY/Fx4jQE77xEnEtenfkaWJ8jCk7LozOA8+blP7U60SQbu mPZvn5Mw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZSo0-00068H-BY; Thu, 11 Jan 2018 02:41:24 +0000 Received: from mail-pf0-f196.google.com ([209.85.192.196]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZSnY-00059P-HN; Thu, 11 Jan 2018 02:41:01 +0000 Received: by mail-pf0-f196.google.com with SMTP id k19so72485pfj.5; Wed, 10 Jan 2018 18:40:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zIb01+ZEMsZynL3Eu2boAniidmJcggAFOycfQHwvpbE=; b=PL7vgKVeRTFTML7jk7QWjMXkIy0RqTSxctqNuLzWRSsMOFp3gzwQQxtZEN+O+z5tXd y+7irazRWsmOqpbn9eUqQ1JZOZ+9DWe8CVKePklCe5S4TzrOJuZdl0unyXKmfwxNVpof BpSkd4zkbcFi/Iw+F/xy9j+GHog4Cf+ov36KoKzPW5+181uZcuXLv+y9daJL38v1f0py U+B4FEkXxHbRCKcnN0f4ipQqxhgg/mNBxS1iS54pGoWLEBNU8nE+U8LeOxHZov/XQ6A1 Bqx0tVjesWz5q6S4qzwgTdPMTVgrBsRYY8/of3NLW0DfR2l7cZT25ozB+3qlMsceEnzq 6tyQ== X-Gm-Message-State: AKGB3mJaYl4S2Im6XbbD6gxAsp4Gi5rpd19xSUk34g2lxAkTC/Wb9HPw cy+Pkmvuo+NSjrJse98s/WJQyQ== X-Google-Smtp-Source: ACJfBotOXGszxa9prHDRIRuUZhsVYvdcpqfvE5s1EpVy49CjfIWWORu2dfhbKJsvXp4d1m9l4mI/Og== X-Received: by 10.99.185.4 with SMTP id z4mr16139044pge.299.1515638445628; Wed, 10 Jan 2018 18:40:45 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id c11sm31726679pgv.40.2018.01.10.18.40.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jan 2018 18:40:45 -0800 (PST) From: Caesar Wang To: Kishon Vijay Abraham I Subject: [PATCH v3 2/2] phy: rockchip-emmc: use regmap_read_poll_timeout to poll dllrdy Date: Thu, 11 Jan 2018 10:40:27 +0800 Message-Id: <1515638427-15117-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515638427-15117-1-git-send-email-wxt@rock-chips.com> References: <1515638427-15117-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180110_184056_753375_A63F9EDF X-CRM114-Status: GOOD ( 14.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Shawn Lin , Brian Norris , linux-kernel@vger.kernel.org, Douglas Anderson , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shawn Lin Just use the API instead of open-coding it, no functional change intended. Signed-off-by: Shawn Lin Reviewed-by: Brian Norris Signed-off-by: Caesar Wang Reviewed-by: Douglas Anderson --- Changes in v3: - As Doug commented on https://patchwork.kernel.org/patch/10154797, Change "1, 50" to "0, 50". Changes in v2: - As Brian commented on https://patchwork.kernel.org/patch/10139891/, changed the note and added to print error value with regmap_read_poll_timeout API. drivers/phy/rockchip/phy-rockchip-emmc.c | 33 +++++++++++--------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c index b0d1093..b237360 100644 --- a/drivers/phy/rockchip/phy-rockchip-emmc.c +++ b/drivers/phy/rockchip/phy-rockchip-emmc.c @@ -79,6 +79,9 @@ #define PHYCTRL_IS_CALDONE(x) \ ((((x) >> PHYCTRL_CALDONE_SHIFT) & \ PHYCTRL_CALDONE_MASK) == PHYCTRL_CALDONE_DONE) +#define PHYCTRL_IS_DLLRDY(x) \ + ((((x) >> PHYCTRL_DLLRDY_SHIFT) & \ + PHYCTRL_DLLRDY_MASK) == PHYCTRL_DLLRDY_DONE) struct rockchip_emmc_phy { unsigned int reg_offset; @@ -93,7 +96,6 @@ static int rockchip_emmc_phy_power(struct phy *phy, bool on_off) unsigned int dllrdy; unsigned int freqsel = PHYCTRL_FREQSEL_200M; unsigned long rate; - unsigned long timeout; int ret; /* @@ -217,28 +219,15 @@ static int rockchip_emmc_phy_power(struct phy *phy, bool on_off) * NOTE: There appear to be corner cases where the DLL seems to take * extra long to lock for reasons that aren't understood. In some * extreme cases we've seen it take up to over 10ms (!). We'll be - * generous and give it 50ms. We still busy wait here because: - * - In most cases it should be super fast. - * - This is not called lots during normal operation so it shouldn't - * be a power or performance problem to busy wait. We expect it - * only at boot / resume. In both cases, eMMC is probably on the - * critical path so busy waiting a little extra time should be OK. + * generous and give it 50ms. */ - timeout = jiffies + msecs_to_jiffies(50); - do { - udelay(1); - - regmap_read(rk_phy->reg_base, - rk_phy->reg_offset + GRF_EMMCPHY_STATUS, - &dllrdy); - dllrdy = (dllrdy >> PHYCTRL_DLLRDY_SHIFT) & PHYCTRL_DLLRDY_MASK; - if (dllrdy == PHYCTRL_DLLRDY_DONE) - break; - } while (!time_after(jiffies, timeout)); - - if (dllrdy != PHYCTRL_DLLRDY_DONE) { - pr_err("rockchip_emmc_phy_power: dllrdy timeout.\n"); - return -ETIMEDOUT; + ret = regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->reg_offset + GRF_EMMCPHY_STATUS, + dllrdy, PHYCTRL_IS_DLLRDY(dllrdy), + 0, 50 * USEC_PER_MSEC); + if (ret) { + pr_err("%s: dllrdy failed. ret=%d\n", __func__, ret); + return ret; } return 0;