Re: [PATCH v2] iio: adc: max9611: Fix too short conversion time delay

From: Wolfram Sang
Date: Mon Dec 02 2019 - 04:23:34 EST


On Mon, Dec 02, 2019 at 09:55:46AM +0100, Geert Uytterhoeven wrote:
> As of commit b9ddd5091160793e ("iio: adc: max9611: Fix temperature
> reading in probe"), max9611 initialization sometimes fails on the
> Salvator-X(S) development board with:
>
> max9611 4-007f: Invalid value received from ADC 0x8000: aborting
> max9611: probe of 4-007f failed with error -5
>
> The max9611 driver tests communications with the chip by reading the die
> temperature during the probe function, which returns an invalid value.
>
> According to the datasheet, the typical ADC conversion time is 2 ms, but
> no minimum or maximum values are provided. Maxim Technical Support
> confirmed this was tested with temperature Ta=25 degreeC, and promised
> to inform me if a maximum/minimum value is available (they didn't get
> back to me, so I assume it is not).
>
> However, the driver assumes a 1 ms conversion time. Usually the
> usleep_range() call returns after more than 1.8 ms, hence it succeeds.
> When it returns earlier, the data register may be read too early, and
> the previous measurement value will be returned. After boot, this is
> the temperature POR (power-on reset) value, causing the failure above.
>
> Fix this by increasing the delay from 1000-2000 Âs to 3000-3300 Âs.
>
> Note that this issue has always been present, but it was exposed by the
> aformentioned commit.
>
> Fixes: 69780a3bbc0b1e7e ("iio: adc: Add Maxim max9611 ADC driver")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> Reviewed-by: Jacopo Mondi <jacopo+renesas@xxxxxxxxxx>

Reviewed-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>

One minor nit, though:

> /*
> * need a delay here to make register configuration
> - * stabilize. 1 msec at least, from empirical testing.
> + * stabilize.

This could be a one line comment now?

Attachment: signature.asc
Description: PGP signature