Re: [PATCH v9 6/6] iio: imu: st_lsm6dsx: Add support for rotation sensor

From: Jonathan Cameron

Date: Wed Mar 25 2026 - 16:11:04 EST


On Wed, 25 Mar 2026 14:55:26 +0000
Jonathan Cameron <jonathan.cameron@xxxxxxxxxx> wrote:

> On Tue, 24 Mar 2026 09:48:07 +0100
> Francesco Lavra <flavra@xxxxxxxxxxxx> wrote:
>
> > Some IMU chips in the LSM6DSX family have sensor fusion features that
> > combine data from the accelerometer and gyroscope. One of these features
> > generates rotation vector data and makes it available in the hardware
> > FIFO as a quaternion (more specifically, the X, Y and Z components of the
> > quaternion vector, expressed as 16-bit half-precision floating-point
> > numbers).
> >
> > Add support for a new sensor instance that allows receiving sensor fusion
> > data, by defining a new struct st_lsm6dsx_fusion_settings (which contains
> > chip-specific details for the sensor fusion functionality), and adding this
> > struct as a new field in struct st_lsm6dsx_settings. In st_lsm6dsx_core.c,
> > populate this new struct for the LSM6DSV and LSM6DSV16X chips, and add the
> > logic to initialize an additional IIO device if this struct is populated
> > for the hardware type being probed.
> > Note: a new IIO device is being defined (as opposed to adding channels to
> > an existing device) because the rate at which sensor fusion data is
> > generated may not match the data rate from any of the existing devices.
> >
> > Tested on LSM6DSV16X.
> >
> > Signed-off-by: Francesco Lavra <flavra@xxxxxxxxxxxx>
> > Acked-by: Lorenzo Bianconi <lorenzo@xxxxxxxxxx>
> One trivial thing. But don't resend for that. Assuming nothing else comes
> up I'll tweak it whilst applying. Same for Andy's line wrap comment.
>

Ah. I tried to pick up the series but we have a dependency on a fix
that hasn't quite made it upstream yet and I don't want the complexity
of merging my own fixes branch in until I know that made it upstream.

Sorry, I don't think I can get this merged this cycle unless we go
to rc8. Will get it queued from start of next cycle.

Jonathan

> thanks,
>
> Jonathan
>
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c
> > new file mode 100644
> > index 000000000000..9fb3e19e4a55
> > --- /dev/null
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c
> > @@ -0,0 +1,243 @@
>
> > +
> > +int st_lsm6dsx_fusion_set_odr(struct st_lsm6dsx_sensor *sensor, bool enable)
> > +{
> > + struct st_lsm6dsx_hw *hw = sensor->hw;
> > + int err;
> > +
> > + guard(mutex)(&hw->page_lock);
> > +
> > + err = st_lsm6dsx_fusion_page_enable(hw);
> > + if (err)
> > + return err;
> > +
> > + err = st_lsm6dsx_fusion_set_odr_locked(sensor, enable);
> > + if (err) {
> > + st_lsm6dsx_fusion_page_disable(hw);
> > + return err;
> > + }
> > +
> > + return st_lsm6dsx_fusion_page_disable(hw);
> > +
> > +out:
> Stray. If nothing else comes up I'll drop this whilst applying.
>
> > +}