All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aapo Vienamo <avienamo@nvidia.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Mikko Perttunen <mperttunen@nvidia.com>
Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	Aapo Vienamo <avienamo@nvidia.com>
Subject: [PATCH 01/10] mmc: tegra: Poll for calibration completion
Date: Tue, 24 Jul 2018 17:29:42 +0300	[thread overview]
Message-ID: <1532442591-5640-2-git-send-email-avienamo@nvidia.com> (raw)
In-Reply-To: <1532442591-5640-1-git-send-email-avienamo@nvidia.com>

Implement polling with 10 ms timeout for automatic pad drive strength
calibration.

Signed-off-by: Aapo Vienamo <avienamo@nvidia.com>
---
 drivers/mmc/host/sdhci-tegra.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index f108c48..e40ca43 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -49,6 +49,9 @@
 #define SDHCI_AUTO_CAL_START			BIT(31)
 #define SDHCI_AUTO_CAL_ENABLE			BIT(29)
 
+#define SDHCI_TEGRA_AUTO_CAL_STATUS     0x1ec
+#define SDHCI_TEGRA_AUTO_CAL_ACTIVE     BIT(31)
+
 #define NVQUIRK_FORCE_SDHCI_SPEC_200	BIT(0)
 #define NVQUIRK_ENABLE_BLOCK_GAP_DET	BIT(1)
 #define NVQUIRK_ENABLE_SDHCI_SPEC_300	BIT(2)
@@ -198,13 +201,24 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask)
 
 static void tegra_sdhci_pad_autocalib(struct sdhci_host *host)
 {
-	u32 val;
+	unsigned timeout = 10;
+	u32 reg;
 
-	mdelay(1);
+	reg = sdhci_readl(host, SDHCI_TEGRA_AUTO_CAL_CONFIG);
+	reg |= SDHCI_AUTO_CAL_ENABLE | SDHCI_AUTO_CAL_START;
+	sdhci_writel(host, reg, SDHCI_TEGRA_AUTO_CAL_CONFIG);
+	udelay(1);
+
+	do {
+		reg = sdhci_readl(host, SDHCI_TEGRA_AUTO_CAL_STATUS);
+		if (!(reg & SDHCI_TEGRA_AUTO_CAL_ACTIVE))
+			break;
+		mdelay(1);
+		timeout--;
+	} while (timeout);
 
-	val = sdhci_readl(host, SDHCI_TEGRA_AUTO_CAL_CONFIG);
-	val |= SDHCI_AUTO_CAL_ENABLE | SDHCI_AUTO_CAL_START;
-	sdhci_writel(host,val, SDHCI_TEGRA_AUTO_CAL_CONFIG);
+	if (timeout == 0)
+		dev_err(mmc_dev(host->mmc), "Pad autocal timed out\n");
 }
 
 static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Aapo Vienamo <avienamo@nvidia.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Mikko Perttunen <mperttunen@nvidia.com>
Cc: <linux-mmc@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Aapo Vienamo <avienamo@nvidia.com>
Subject: [PATCH 01/10] mmc: tegra: Poll for calibration completion
Date: Tue, 24 Jul 2018 17:29:42 +0300	[thread overview]
Message-ID: <1532442591-5640-2-git-send-email-avienamo@nvidia.com> (raw)
In-Reply-To: <1532442591-5640-1-git-send-email-avienamo@nvidia.com>

Implement polling with 10 ms timeout for automatic pad drive strength
calibration.

Signed-off-by: Aapo Vienamo <avienamo@nvidia.com>
---
 drivers/mmc/host/sdhci-tegra.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index f108c48..e40ca43 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -49,6 +49,9 @@
 #define SDHCI_AUTO_CAL_START			BIT(31)
 #define SDHCI_AUTO_CAL_ENABLE			BIT(29)
 
+#define SDHCI_TEGRA_AUTO_CAL_STATUS     0x1ec
+#define SDHCI_TEGRA_AUTO_CAL_ACTIVE     BIT(31)
+
 #define NVQUIRK_FORCE_SDHCI_SPEC_200	BIT(0)
 #define NVQUIRK_ENABLE_BLOCK_GAP_DET	BIT(1)
 #define NVQUIRK_ENABLE_SDHCI_SPEC_300	BIT(2)
@@ -198,13 +201,24 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask)
 
 static void tegra_sdhci_pad_autocalib(struct sdhci_host *host)
 {
-	u32 val;
+	unsigned timeout = 10;
+	u32 reg;
 
-	mdelay(1);
+	reg = sdhci_readl(host, SDHCI_TEGRA_AUTO_CAL_CONFIG);
+	reg |= SDHCI_AUTO_CAL_ENABLE | SDHCI_AUTO_CAL_START;
+	sdhci_writel(host, reg, SDHCI_TEGRA_AUTO_CAL_CONFIG);
+	udelay(1);
+
+	do {
+		reg = sdhci_readl(host, SDHCI_TEGRA_AUTO_CAL_STATUS);
+		if (!(reg & SDHCI_TEGRA_AUTO_CAL_ACTIVE))
+			break;
+		mdelay(1);
+		timeout--;
+	} while (timeout);
 
-	val = sdhci_readl(host, SDHCI_TEGRA_AUTO_CAL_CONFIG);
-	val |= SDHCI_AUTO_CAL_ENABLE | SDHCI_AUTO_CAL_START;
-	sdhci_writel(host,val, SDHCI_TEGRA_AUTO_CAL_CONFIG);
+	if (timeout == 0)
+		dev_err(mmc_dev(host->mmc), "Pad autocal timed out\n");
 }
 
 static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
-- 
2.7.4


  reply	other threads:[~2018-07-24 14:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24 14:29 [PATCH 00/10] Update the pad autocal procedure Aapo Vienamo
2018-07-24 14:29 ` Aapo Vienamo
2018-07-24 14:29 ` Aapo Vienamo [this message]
2018-07-24 14:29   ` [PATCH 01/10] mmc: tegra: Poll for calibration completion Aapo Vienamo
2018-07-25  7:04   ` Mikko Perttunen
2018-07-24 14:34 ` [PATCH 02/10] mmc: tegra: Set calibration pad voltage reference Aapo Vienamo
2018-07-24 14:34   ` Aapo Vienamo
2018-07-24 14:34   ` [PATCH 03/10] mmc: tegra: Power on the calibration pad Aapo Vienamo
2018-07-24 14:34     ` Aapo Vienamo
2018-07-25  7:11     ` Mikko Perttunen
2018-07-24 14:34   ` [PATCH 04/10] mmc: tegra: Disable card clock during pad calibration Aapo Vienamo
2018-07-24 14:34     ` Aapo Vienamo
2018-07-25  7:14     ` Mikko Perttunen
2018-07-24 14:34   ` [PATCH 05/10] dt-bindings: Add Tegra SDHCI pad pdpu offset bindings Aapo Vienamo
2018-07-24 14:34     ` Aapo Vienamo
2018-07-25  7:16     ` Mikko Perttunen
2018-07-24 14:34   ` [PATCH 06/10] mmc: tegra: Program pad autocal offsets from dt Aapo Vienamo
2018-07-24 14:34     ` Aapo Vienamo
2018-07-25  7:24     ` Mikko Perttunen
2018-07-24 14:34   ` [PATCH 07/10] arm64: dts: tegra186: Add sdmmc pad auto calibration offsets Aapo Vienamo
2018-07-24 14:34     ` Aapo Vienamo
2018-07-24 14:34   ` [PATCH 08/10] arm64: dts: tegra210: " Aapo Vienamo
2018-07-24 14:34     ` Aapo Vienamo
2018-07-24 14:34   ` [PATCH 09/10] mmc: tegra: Perform pad calibration after voltage switch Aapo Vienamo
2018-07-24 14:34     ` Aapo Vienamo
2018-07-25  7:25     ` Mikko Perttunen
2018-07-25 10:43       ` Aapo Vienamo
2018-07-25 10:43         ` Aapo Vienamo
2018-07-25  7:08   ` [PATCH 02/10] mmc: tegra: Set calibration pad voltage reference Mikko Perttunen
2018-07-25 10:00     ` Aapo Vienamo
2018-07-25 10:00       ` Aapo Vienamo
2018-07-25 12:06 ` [PATCH 00/10] Update the pad autocal procedure Peter Geis
2018-07-25 14:28   ` Aapo Vienamo
2018-07-25 14:28     ` Aapo Vienamo
2018-07-25 14:27 ` [PATCH 10/10] mmc: tegra: Enable pad calibration on Tegra210 and Tegra186 Aapo Vienamo
2018-07-25 14:27   ` Aapo Vienamo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1532442591-5640-2-git-send-email-avienamo@nvidia.com \
    --to=avienamo@nvidia.com \
    --cc=adrian.hunter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mperttunen@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.