From: Jacopo Mondi <jacopo+renesas@jmondi.org>
To: geert+renesas@glider.be
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] iio: adc: max9611: Defer probe on POR read
Date: Wed, 16 Oct 2019 12:25:20 +0200 [thread overview]
Message-ID: <20191016102520.124370-1-jacopo+renesas@jmondi.org> (raw)
The max9611 driver tests communications with the chip by reading the die
temperature during the probe function. If the temperature register
POR (power-on reset) value is returned from the test read, defer probe to
give the chip a bit more time to properly exit from reset.
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
Geert,
I've not been able to reproduce the issue on my boards (M3-N
Salvator-XS and M3-W Salvator-X). As you reported the issue you might be
able to reproduce it, could you please test this?
Also, I opted for deferring probe instead of arbitrary repeat the
temperature read. What's your opinion?
Thanks
j
---
drivers/iio/adc/max9611.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
index da073d72f649..30ae5879252c 100644
--- a/drivers/iio/adc/max9611.c
+++ b/drivers/iio/adc/max9611.c
@@ -80,6 +80,7 @@
* The complete formula to calculate temperature is:
* ((adc_read >> 7) * 1000) / (1 / 480 * 1000)
*/
+#define MAX9611_TEMP_POR 0x8000
#define MAX9611_TEMP_MAX_POS 0x7f80
#define MAX9611_TEMP_MAX_NEG 0xff80
#define MAX9611_TEMP_MIN_NEG 0xd980
@@ -480,8 +481,10 @@ static int max9611_init(struct max9611_dev *max9611)
if (ret)
return ret;
- regval &= MAX9611_TEMP_MASK;
+ if (regval == MAX9611_TEMP_POR)
+ return -EPROBE_DEFER;
+ regval &= MAX9611_TEMP_MASK;
if ((regval > MAX9611_TEMP_MAX_POS &&
regval < MAX9611_TEMP_MIN_NEG) ||
regval > MAX9611_TEMP_MAX_NEG) {
--
2.23.0
next reply other threads:[~2019-10-16 10:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 10:25 Jacopo Mondi [this message]
2019-10-17 12:55 ` [PATCH] iio: adc: max9611: Defer probe on POR read Geert Uytterhoeven
2019-11-10 17:15 ` Jonathan Cameron
2019-11-10 18:45 ` Geert Uytterhoeven
2019-11-13 9:41 ` Geert Uytterhoeven
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=20191016102520.124370-1-jacopo+renesas@jmondi.org \
--to=jacopo+renesas@jmondi.org \
--cc=geert+renesas@glider.be \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).