From patchwork Thu Jan 11 02:40:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 10156775 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 353DB602B3 for ; Thu, 11 Jan 2018 02:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DF4328429 for ; Thu, 11 Jan 2018 02:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E96D28528; Thu, 11 Jan 2018 02:41:12 +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 1910628429 for ; Thu, 11 Jan 2018 02:41:11 +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=i1fGQSdxW2CNPCCN4yOE2k6B0lQnAQySO9R2BRR9bp4=; b=ltYUMT8hOTGtPHbCaKqTwsn6mh Didv3fXHfBPOl8j5qH+eaFKwbDtYBUanJnGlWWfnYHV81NbCXDJGg9KKuJCoxQvIRMgK94Y9uFCA3 dbnumLCOq7neOan0hMw67XU3FtbrRR25XcAP7J3VB6b+t4TPCO0ZKM9relaFfOQuUN7Hco/jx9JlF kZ+IxDY1uYMSzh7eUrjf/YDsfiCdVLHwNiRZ1NNAEI6bshbPXym+JjYAxtNgx8ti/ojRjlMHkL7wL k/UdY5VrU04W4bTjnverXM0C0nACChbYcBktMQ5oBMJ5OsIqNo4/XGDy7FBqe7/uBO0FmqPwDkJf4 7uxW7XuA==; 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 1eZSnm-0005ku-H8; Thu, 11 Jan 2018 02:41:10 +0000 Received: from mail-pf0-f194.google.com ([209.85.192.194]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZSnV-00056E-B8; Thu, 11 Jan 2018 02:40:54 +0000 Received: by mail-pf0-f194.google.com with SMTP id e11so72046pff.6; Wed, 10 Jan 2018 18:40:42 -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=wlGTJDGE9BI+x2GnTeYV20vQVYBQlV28H/O9fUeIaWA=; b=q7nxD/bEcl3aO/q5HDYDEgShTub6n22fxI5tRoscqt5jSsv3SUOM+f75/eKc9MCin/ qITFFcZUlzkuug1pbLsof17yxoE9XTwrwiEQabAoZ//HPzBc3aQswMYHbPZn8H2tbb8E BRnmz1S5LVCGa/NnS9653MegglO+baZIv+c96MO62emz/apYwlj2lMvmNQNMK42AUZ6H G5ldE6+eYrdSvrvYvmt6YUzx2Pcn+qHu7k2YFwijTd/6xgwH/4Gfn7+OhSlWpW/vqjE+ P5AfvP5JiggjDlQ/+40A4Age+dZKR1cBN1LR9LT+aZ+Bx7nQpYF3rwwqwu2wkvi75o/W ISBg== X-Gm-Message-State: AKGB3mL7JUTuG9RJKtJPBrAuXObk/frrXHez8IsrSk7wDg1S+QQzrxCc r7uNqKBdQ5jrsdiXnTrppss= X-Google-Smtp-Source: ACJfBoutdWQdh7AAbmSmbKQJjNdFjX9ZMvdIIvwFUswbnHCrp/S0odKiVoQSOikBMhIrr9TjapLK2Q== X-Received: by 10.99.94.193 with SMTP id s184mr16614847pgb.311.1515638442481; Wed, 10 Jan 2018 18:40:42 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id c11sm31726679pgv.40.2018.01.10.18.40.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jan 2018 18:40:41 -0800 (PST) From: Caesar Wang To: Kishon Vijay Abraham I Subject: [PATCH v3 1/2] phy: rockchip-emmc: retry calpad busy trimming Date: Thu, 11 Jan 2018 10:40:26 +0800 Message-Id: <1515638427-15117-2-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_184053_384538_9B1BF9B6 X-CRM114-Status: GOOD ( 13.81 ) 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 Reviewed-by: Douglas Anderson --- Changes in v3: - As Doug commented on both upstream and gerrit. Change "5, 50" to "0, 50", and the message of print. 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..b0d1093 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), + 0, 50); + if (ret) { + pr_err("%s: caldone failed, ret=%d\n", __func__, ret); + return ret; } /* Set the frequency of the DLL operation */