From patchwork Wed Jan 10 07:37:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 10154127 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 62623602D8 for ; Wed, 10 Jan 2018 07:38:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 531CB1FE8A for ; Wed, 10 Jan 2018 07:38:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47ACF2835B; Wed, 10 Jan 2018 07:38:43 +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 D7B551FE8A for ; Wed, 10 Jan 2018 07:38:42 +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=NvzSYpKguI2qKjZijO24YijtQp0x9RRDEw1uSqdfqwk=; b=MwmL1NlnMOvBJh2Z52u03AMK7E nla9Y+2b10WqfFiv2fFL4ajLTJZjdIfDsB4qUMX3i6c0C3Bcdaaa/a8CkXAd3bAMVDNFltr9OVyC4 EAV6f4+psRqimI1yI3Ksdu5GIpy3MA8+SzywiLjtyyulEsPaVQ1Ja5Riuw6BVh7EIQAYSluwWBSmb dfW6gycabvEE2Dx8qOTG/47HJL2AKp8Khm5rd/lA2xmW/ShQ7ovk0fLlnfHw4XJl+qYqn6400KBk6 D+6tD96oq7IJRVYTzzwLYt9XhRnWH6IYw5ZjHiXoRK/5r0leTRblfSUWYAIEuGOT3CKUxcgyUHOrJ qFuAV/RA==; 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 1eZAy9-00021v-2j; Wed, 10 Jan 2018 07:38:41 +0000 Received: from mail-pg0-f66.google.com ([74.125.83.66]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZAxu-0001U5-CQ; Wed, 10 Jan 2018 07:38:27 +0000 Received: by mail-pg0-f66.google.com with SMTP id c194so9218026pga.12; Tue, 09 Jan 2018 23:38:16 -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=/8SYgtYsaHYRYC5EY7pUwuCR0tUL5WiHjW5mPz2WiyM=; b=rP77SxqxzqvmbUvQJcyPRjOIP6Tq7RYpTjzf7g2Pqb13zjTXlnMIupFHCWld/LIDji +Z8Ez7QZLLWa1sKam12405d8G9g8otLt3hIWAtO3igl5Y3VebBmx9gOKmJooAhdAADiz Y+Swx2l5aZJSsJov7txODlhC8mth5QpwjZELsOi5DAf1DEMnlP+gWbKPO4gv2UP8lES0 YCueN+yL47Rewi+hL8dwxEGIwjDP0uoe9zj3P/CVhfmjK+foLjnMJ3J7Dea/Sgz8Sca7 WkDR1MCu2+D99mIWK1QZep3QPR+9PZ+2bjMDrInqCeICnXmCfvdRpQ9pRPLilZ0GO+jL OiSA== X-Gm-Message-State: AKGB3mLuLE9ZJ6dr3Ac5/+HXj62TS/R4xaTKmgTSvDKmkXflIcoteSC3 8nJycCusB14zAcSSQh0e8Sw= X-Google-Smtp-Source: ACJfBoug0mvv2PdPKZIHph5gOTKmhgTmb1BfF1w8+zvprNVBE13ADso/s946izwjZs75d2lM47l0hg== X-Received: by 10.98.9.146 with SMTP id 18mr16254778pfj.29.1515569895764; Tue, 09 Jan 2018 23:38:15 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id s184sm31699688pfb.9.2018.01.09.23.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 23:38:15 -0800 (PST) From: Caesar Wang To: Kishon Vijay Abraham I Subject: [PATCH v2 1/2] phy: rockchip-emmc: retry calpad busy trimming Date: Wed, 10 Jan 2018 15:37:58 +0800 Message-Id: <1515569879-31808-2-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_233826_426899_E2183535 X-CRM114-Status: GOOD ( 13.72 ) 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 It turns out that 5us isn't enough for all cases, so let's retry some more times to wait for caldone. Signed-off-by: Shawn Lin Tested-by: Ziyuan Xu Signed-off-by: Caesar Wang --- Changes in v2: - print the return valut with regmap_read_poll_timeout failing. drivers/phy/rockchip/phy-rockchip-emmc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c index f1b24f1..574838f 100644 --- a/drivers/phy/rockchip/phy-rockchip-emmc.c +++ b/drivers/phy/rockchip/phy-rockchip-emmc.c @@ -76,6 +76,10 @@ #define PHYCTRL_OTAPDLYSEL_MASK 0xf #define PHYCTRL_OTAPDLYSEL_SHIFT 0x7 +#define PHYCTRL_IS_CALDONE(x) \ + ((((x) >> PHYCTRL_CALDONE_SHIFT) & \ + PHYCTRL_CALDONE_MASK) == PHYCTRL_CALDONE_DONE) + struct rockchip_emmc_phy { unsigned int reg_offset; struct regmap *reg_base; @@ -90,6 +94,7 @@ static int rockchip_emmc_phy_power(struct phy *phy, bool on_off) unsigned int freqsel = PHYCTRL_FREQSEL_200M; unsigned long rate; unsigned long timeout; + int ret; /* * Keep phyctrl_pdb and phyctrl_endll low to allow @@ -160,17 +165,19 @@ static int rockchip_emmc_phy_power(struct phy *phy, bool on_off) PHYCTRL_PDB_SHIFT)); /* - * According to the user manual, it asks driver to - * wait 5us for calpad busy trimming + * According to the user manual, it asks driver to wait 5us for + * calpad busy trimming. However it is documented that this value is + * PVT(A.K.A process,voltage and temperature) relevant, so some + * failure cases are found which indicates we should be more tolerant + * to calpad busy trimming. */ - udelay(5); - regmap_read(rk_phy->reg_base, - rk_phy->reg_offset + GRF_EMMCPHY_STATUS, - &caldone); - caldone = (caldone >> PHYCTRL_CALDONE_SHIFT) & PHYCTRL_CALDONE_MASK; - if (caldone != PHYCTRL_CALDONE_DONE) { - pr_err("rockchip_emmc_phy_power: caldone timeout.\n"); - return -ETIMEDOUT; + ret = regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->reg_offset + GRF_EMMCPHY_STATUS, + caldone, PHYCTRL_IS_CALDONE(caldone), + 5, 50); + if (ret) { + pr_err("%s: caldone timeout, ret=%d\n", __func__, ret); + return ret; } /* Set the frequency of the DLL operation */