Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1426896

[PATCH v3 05/15] phy: rockchip-emmc: Increase lock time allowance

Path csiph.com!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Douglas Anderson <dianders@chromium.org>
Newsgroups linux.kernel
Subject [PATCH v3 05/15] phy: rockchip-emmc: Increase lock time allowance
Date Mon, 20 Jun 2016 20:10:02 +0200
Message-ID <rMbO2-3aM-33@gated-at.bofh.it> (permalink)
References <rMbO2-3aM-21@gated-at.bofh.it>
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; bh=L5YCNT6XiGvqXROuN10HB2Hoc04hegAmSQEf3szD5bA=; b=TWR+bqPEQE166QGbDFrZM9RJUtFZAh78unDZeKr1mG07TLNSFAACBkY6MjvMw8keQ+ z1VXJ2LJ7YqV9h0w4tNaeKciQ/sR4zw4uae6165+C2hMEUpB+Uv7HnjSheMECNyg+ZY2 FivZfEMJwomrOSTZvTWBZGpATZTBPn4sGyNmk=
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; bh=L5YCNT6XiGvqXROuN10HB2Hoc04hegAmSQEf3szD5bA=; b=d8dcY5NaW0kK7P3LqhB5CYP3ctXQsRWQY9Xp8VS3Ryj/H8B/gReEx4VtdZ5uvq3Nsk CLJ0btPAap3IifM4tZi09lOAcHVRE7lE4WS2rHBOCnEYcrijGyGpz6YwbvsTx78bSTDA U+CDDeuHIbk5/nCD8d0ezv6/MFQJBJlkLIpQK6MHQRXTp4kvu4pca9djHiAId2rOe/P/ oJsnwnF+cGcViW0SwIk7u6qNObHKqb9xDDkGfz+nSJCOlNotdjbVFM069x/QEjVEEOck D75miY1zMqEtpZywgTPOLslVoPDSD9M1c/1ZUZ8XjVLsQ+DunBMJemIeI9UXOOD4c99I sQzQ==
X-Gm-Message-State ALyK8tIIsTFNnir63atkAsB9vmcBd5OaJzIsba6HY5PwENHSjpAWPmaJXXjv6pqYDwBEkhIZ
X-Received by 10.98.70.144 with SMTP id o16mr22843889pfi.126.1466445638634; Mon, 20 Jun 2016 11:00:38 -0700 (PDT)
X-Mailer git-send-email 2.8.0.rc3.226.g39d4020
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 79
Organization linux.* mail to news gateway
X-Original-Cc kishon@ti.com, robh+dt@kernel.org, shawn.lin@rock-chips.com, xzy.xu@rock-chips.com, briannorris@chromium.org, adrian.hunter@intel.com, linux-rockchip@lists.infradead.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, groeck@chromium.org, Douglas Anderson <dianders@chromium.org>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
X-Original-Date Mon, 20 Jun 2016 10:56:44 -0700
X-Original-Message-ID <1466445414-11974-6-git-send-email-dianders@chromium.org>
X-Original-References <1466445414-11974-1-git-send-email-dianders@chromium.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1426896

Show key headers only | View raw


Previous PHY code waited a fixed amount of time for the DLL to lock at
power on time.  Unfortunately, the time for the DLL to lock is actually
a bit more dynamic and can be longer if the card clock is slower.

Instead of waiting a fixed 30 us, let's now dynamically wait until the
lock bit gets set.  We'll wait up to 10 ms which should be OK even if
the card clock is at the super slow 100 kHz.

On its own, this change makes the PHY power on code a little more
robust.  Before this change the PHY was relying on the eMMC code to make
sure the PHY was only powered on when the card clock was set to at least
50 MHz before, though this reliance wasn't documented anywhere.

This change will be even more useful in future changes where we actually
need to be able to wait for a DLL lock at slower clock speeds.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
---
Changes in v3:
- Add collected tags

Changes in v2:
- Indicate that 5.1 ms is calculated (Shawn).

 drivers/phy/phy-rockchip-emmc.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/phy/phy-rockchip-emmc.c b/drivers/phy/phy-rockchip-emmc.c
index a69f53630e67..2d059c046978 100644
--- a/drivers/phy/phy-rockchip-emmc.c
+++ b/drivers/phy/phy-rockchip-emmc.c
@@ -85,6 +85,7 @@ static int rockchip_emmc_phy_power(struct rockchip_emmc_phy *rk_phy,
 {
 	unsigned int caldone;
 	unsigned int dllrdy;
+	unsigned long timeout;
 
 	/*
 	 * Keep phyctrl_pdb and phyctrl_endll low to allow
@@ -137,15 +138,26 @@ static int rockchip_emmc_phy_power(struct rockchip_emmc_phy *rk_phy,
 				   PHYCTRL_ENDLL_MASK,
 				   PHYCTRL_ENDLL_SHIFT));
 	/*
-	 * After enable analog DLL circuits, we need an extra 10.2us
-	 * for dll to be ready for work. But according to testing, we
-	 * find some chips need more than 25us.
+	 * After enabling analog DLL circuits docs say that we need 10.2 us if
+	 * our source clock is at 50 MHz and that lock time scales linearly
+	 * with clock speed.  If we are powering on the PHY and the card clock
+	 * is super slow (like 100 kHZ) this could take as long as 5.1 ms as
+	 * per the math: 10.2 us * (50000000 Hz / 100000 Hz) => 5.1 ms
+	 * Hopefully we won't be running at 100 kHz, but we should still make
+	 * sure we wait long enough.
 	 */
-	udelay(30);
-	regmap_read(rk_phy->reg_base,
-		    rk_phy->reg_offset + GRF_EMMCPHY_STATUS,
-		    &dllrdy);
-	dllrdy = (dllrdy >> PHYCTRL_DLLRDY_SHIFT) & PHYCTRL_DLLRDY_MASK;
+	timeout = jiffies + msecs_to_jiffies(10);
+	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;
-- 
2.8.0.rc3.226.g39d4020

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v3 05/15] phy: rockchip-emmc: Increase lock time allowance Douglas Anderson <dianders@chromium.org> - 2016-06-20 20:10 +0200
  Re: [PATCH v3 05/15] phy: rockchip-emmc: Increase lock time allowance Doug Anderson <dianders@chromium.org> - 2016-06-20 21:40 +0200
    Re: [PATCH v3 05/15] phy: rockchip-emmc: Increase lock time allowance Guenter Roeck <groeck@google.com> - 2016-06-20 21:40 +0200
  Re: [PATCH v3 05/15] phy: rockchip-emmc: Increase lock time allowance Guenter Roeck <groeck@google.com> - 2016-06-20 21:40 +0200

csiph-web