From patchwork Wed Jan 10 07:37:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 10154137 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 42B92602D8 for ; Wed, 10 Jan 2018 07:39:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 351801FE8A for ; Wed, 10 Jan 2018 07:39:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 289E52835B; Wed, 10 Jan 2018 07:39:02 +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=ham 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 A14541FE8A for ; Wed, 10 Jan 2018 07:39:01 +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=CmCqtlKTXWrjonj+V3bl8H/MVKYANCZnepzSljWSlyM=; b=spxNsKfrAwQnVl9kdPLzrozrQJ WvPpDkdjGafSVJQYBRMOluz+CaH9JmoHj2pH0DsT+HEuBdl0LGf+O/FrwQYYq1ri1MC1acHcV4Et/ y66vUFCPqcoVajX1fnkDobWUfcYSGk9NhB2b2PHdSCR7y0M5hncJz+wArcdsvlERhJogQc+lyRlyj XRYojhcvb5mjnuPDh3wwvQUulDavDNog/CpXBULAAxLSnU9+eALT+QHGDCgpdb1rsuErdEtMjkgzX CXwc5mUExdmxoWp6dJwNLfUclGj4KvaF7te0SWiVHFkjl1j7xyF9sYyza2Z/25Vt8KU6tAkUxfYp7 SnuBHNIw==; 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 1eZAyR-0002T1-Jz; Wed, 10 Jan 2018 07:38:59 +0000 Received: from mail-pg0-f65.google.com ([74.125.83.65]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZAxx-0001Xw-71; Wed, 10 Jan 2018 07:38:31 +0000 Received: by mail-pg0-f65.google.com with SMTP id j4so10202528pgp.1; Tue, 09 Jan 2018 23:38:18 -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=FhuzKh4jeTbQDPPtO01wdm/J6HP3kgCCOdnOWIjCaDE=; b=Z/AVFCUpmofA1X0VDQhNaSA7gaXd9DrK8zwRlCiz3bHetWZzhEqAFoeVddBme9QFHa nEKTGmER9ZPCH/TFbpib7WzXh2W8kmY3ojCT20x1O4eHI4TYCo6+/0TmdCG6hcp0rrUs 79NaMgveuCkocpQ+g/4/+mmHKt4lhWp0PO7an/A08UtSgmyzowVomlaPrq033+m0D8gF 52hFF+/dW9CFW4+7G5Jm5HPIrcRJTWlCaypsUe2+6hIY5TGrqjODS5AYA56O0VN4uq2A bxwxUfr0ihjYZrhVYC8ip7fOauKP0fLOFHDcOFDapQ6atcghSYKchDIPR0lBs8Ds5Mvm wemQ== X-Gm-Message-State: AKGB3mJJd/PjJW29iXE48I96zr7n68cBQcjyXqREjXOagICtw4Fg/xdg gO2hkcl2HiF79rrSWe2Ppis= X-Google-Smtp-Source: ACJfBotHKF0ebFl7Jl1zzLvxGCc8z+9lKtJCCUi+LGTkmamkHPiBvCwTGyEBbMuLXcNxUapgx7WBWg== X-Received: by 10.98.53.195 with SMTP id c186mr16202881pfa.115.1515569898512; Tue, 09 Jan 2018 23:38:18 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id s184sm31699688pfb.9.2018.01.09.23.38.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 23:38:18 -0800 (PST) From: Caesar Wang To: Kishon Vijay Abraham I Subject: [PATCH v2 2/2] phy: rockchip-emmc: use regmap_read_poll_timeout to poll dllrdy Date: Wed, 10 Jan 2018 15:37:59 +0800 Message-Id: <1515569879-31808-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515569879-31808-1-git-send-email-wxt@rock-chips.com> References: <1515569879-31808-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180109_233829_266555_86819927 X-CRM114-Status: GOOD ( 14.61 ) 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 --- 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 574838f..343c623 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), + 1, 50 * USEC_PER_MSEC); + if (ret) { + pr_err("%s: dllrdy timeout. ret=%d\n", __func__, ret); + return ret; } return 0;