All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: <lee.jones@linaro.org>
Cc: <patches@opensource.cirrus.com>, <linux-kernel@vger.kernel.org>,
	"Richard Fitzgerald" <rf@opensource.cirrus.com>
Subject: [PATCH 2/2] mfd: madera: Wait for BOOT_DONE before reading device ID
Date: Mon, 1 Oct 2018 15:33:57 +0100	[thread overview]
Message-ID: <20181001143357.28428-2-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20181001143357.28428-1-rf@opensource.cirrus.com>

It isn't safe to read the device ID in SOFTWARE_RESET register
until the silicon boot sequence has completed. This patch
rearranges the code to wait for BOOT_DONE first.

If we don't have a GPIO to control hard reset we must issue
a soft reset to get the silicon into a known-good booted state
before reading the device ID.

Signed-off-by: Stuart Henderson <stuarth@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 drivers/mfd/madera-core.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
index 3ff9a0615658..b9d42edf96c9 100644
--- a/drivers/mfd/madera-core.c
+++ b/drivers/mfd/madera-core.c
@@ -454,10 +454,23 @@ int madera_dev_init(struct madera *madera)
 	regcache_cache_only(madera->regmap, false);
 	regcache_cache_only(madera->regmap_32bit, false);
 
+	/* If we don't have a reset GPIO use a soft reset */
+	if (!madera->pdata.reset) {
+		ret = madera_soft_reset(madera);
+		if (ret)
+			goto err_reset;
+	}
+
 	/*
-	 * Now we can power up and verify that this is a chip we know about
-	 * before we start doing any writes to its registers.
+	 * Must wait for internal boot sequence to complete before
+	 * reading the device ID
 	 */
+	ret = madera_wait_for_boot(madera);
+	if (ret) {
+		dev_err(madera->dev, "Device failed initial boot: %d\n", ret);
+		goto err_reset;
+	}
+
 	ret = regmap_read(madera->regmap, MADERA_SOFTWARE_RESET, &hwid);
 	if (ret) {
 		dev_err(dev, "Failed to read ID register: %d\n", ret);
@@ -519,22 +532,6 @@ int madera_dev_init(struct madera *madera)
 		goto err_reset;
 	}
 
-	/*
-	 * It looks like a device we support. If we don't have a hard reset
-	 * we can now attempt a soft reset.
-	 */
-	if (!madera->pdata.reset) {
-		ret = madera_soft_reset(madera);
-		if (ret)
-			goto err_reset;
-	}
-
-	ret = madera_wait_for_boot(madera);
-	if (ret) {
-		dev_err(madera->dev, "Device failed initial boot: %d\n", ret);
-		goto err_reset;
-	}
-
 	ret = regmap_read(madera->regmap, MADERA_HARDWARE_REVISION,
 			  &madera->rev);
 	if (ret) {
-- 
2.11.0


  reply	other threads:[~2018-10-01 14:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01 14:33 [PATCH 1/2] mfd: madera: Increase wait for silicon reset Richard Fitzgerald
2018-10-01 14:33 ` Richard Fitzgerald [this message]
2018-10-02  8:52   ` [PATCH 2/2] mfd: madera: Wait for BOOT_DONE before reading device ID Charles Keepax

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=20181001143357.28428-2-rf@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    /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.