linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: max9611: Defer probe on POR read
@ 2019-10-16 10:25 Jacopo Mondi
  2019-10-17 12:55 ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Jacopo Mondi @ 2019-10-16 10:25 UTC (permalink / raw)
  To: geert+renesas; +Cc: Jacopo Mondi, linux-iio, linux-renesas-soc, linux-kernel

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-13  9:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 10:25 [PATCH] iio: adc: max9611: Defer probe on POR read Jacopo Mondi
2019-10-17 12:55 ` Geert Uytterhoeven
2019-11-10 17:15   ` Jonathan Cameron
2019-11-10 18:45   ` Geert Uytterhoeven
2019-11-13  9:41     ` Geert Uytterhoeven

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).