Skip to content

Commit 3a63da2

Browse files
LorenzoBianconijic23
authored andcommitted
iio: imu: st_lsm6dsx: flush hw FIFO before resetting the device
flush hw FIFO before device reset in order to avoid possible races on interrupt line 1. If the first interrupt line is asserted during hw reset the device will work in I3C-only mode (if it is supported) Fixes: 801a6e0 ("iio: imu: st_lsm6dsx: add support to LSM6DSO") Fixes: 4390100 ("iio: imu: st_lsm6dsx: add support to LSM6DSR") Reported-by: Mario Tesi <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Vitor Soares <[email protected]> Tested-by: Vitor Soares <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 5403f28 commit 3a63da2

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,11 +2036,21 @@ static int st_lsm6dsx_init_hw_timer(struct st_lsm6dsx_hw *hw)
20362036
return 0;
20372037
}
20382038

2039-
static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
2039+
static int st_lsm6dsx_reset_device(struct st_lsm6dsx_hw *hw)
20402040
{
20412041
const struct st_lsm6dsx_reg *reg;
20422042
int err;
20432043

2044+
/*
2045+
* flush hw FIFO before device reset in order to avoid
2046+
* possible races on interrupt line 1. If the first interrupt
2047+
* line is asserted during hw reset the device will work in
2048+
* I3C-only mode (if it is supported)
2049+
*/
2050+
err = st_lsm6dsx_flush_fifo(hw);
2051+
if (err < 0 && err != -ENOTSUPP)
2052+
return err;
2053+
20442054
/* device sw reset */
20452055
reg = &hw->settings->reset;
20462056
err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
@@ -2059,6 +2069,18 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
20592069

20602070
msleep(50);
20612071

2072+
return 0;
2073+
}
2074+
2075+
static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
2076+
{
2077+
const struct st_lsm6dsx_reg *reg;
2078+
int err;
2079+
2080+
err = st_lsm6dsx_reset_device(hw);
2081+
if (err < 0)
2082+
return err;
2083+
20622084
/* enable Block Data Update */
20632085
reg = &hw->settings->bdu;
20642086
err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,

0 commit comments

Comments
 (0)