Skip to contentSkip to conversation

drivers: iio: temperature: Add delay after the addressed reset command in mlx90632.c

PATCH Superseded Slaveyko Slaveykov 3 participants 3 messages Dec 11, 2020 – Dec 12, 2020

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: iio: temperature: Add delay after the addressed reset command in mlx90632.c

After an I2C reset command, the mlx90632 needs some time before responding to other I2C commands. Without that delay, there is a chance that the I2C command(s) after the reset will not be accepted

---
 drivers/iio/temperature/mlx90632.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/temperature/mlx90632.c +1 -0
index 503fe54a0bb9..ee50f61e496a 100644
@@ -247,6 +247,7 @@ static int mlx90632_set_meas_type(struct regmap *regmap, u8 type)
 	ret = regmap_write(regmap, MLX90632_REG_I2C_CMD, MLX90632_RESET_CMD);
 	if (ret < 0)
 		return ret;
+	usleep(150, 200);
 
 	ret = regmap_write_bits(regmap, MLX90632_REG_CONTROL,
 				 (MLX90632_CFG_MTYP_MASK | MLX90632_CFG_PWR_MASK),
Signature · 1 line
2.16.2.windows.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

We did not detect this issue on Linux chips, but there is a slight possibility that it might occur nevertheless. So I am proposing this to add to_fixes as well (maybe even for the upcoming 5.10?)

Best regards,
Crt

Quoted 25 lines · Slaveyko Slaveykov

After an I2C reset command, the mlx90632 needs some time before responding to other I2C commands. Without that delay, there is a chance that the I2C command(s) after the reset will not be accepted

---
 drivers/iio/temperature/mlx90632.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/temperature/mlx90632.c +1 -1
index 503fe54a0bb9..ee50f61e496a 100644
@@ -247,6 +247,7 @@ static int mlx90632_set_meas_type(struct regmap *regmap, u8 type)
        ret = regmap_write(regmap, MLX90632_REG_I2C_CMD, MLX90632_RESET_CMD);
        if (ret < 0)
                return ret;
+       usleep(150, 200);
 
        ret = regmap_write_bits(regmap, MLX90632_REG_CONTROL,
                                 (MLX90632_CFG_MTYP_MASK | MLX90632_CFG_PWR_MASK),
--

2.16.2.windows.1

#2 lore raw
In reply to Slaveyko Slaveykov
Quoted 4 lines · Slaveyko Slaveykov

After an I2C reset command, the mlx90632 needs some time before responding to other I2C commands. Without that delay, there is a chance that the I2C command(s) after the reset will not be accepted

...

It's good to put some comments here in the code.

Quoted 1 line

+ usleep(150, 200);

Signature · 2 lines
With Best Regards,
Andy Shevchenko