Re: [PATCH v3 7/8] iio: imu: inv_icm42607: Add accelerometer calibbias support

From: Kanak Shilledar

Date: Wed Sep 16 2026 - 05:43:40 EST


Hi Chris,

On Tue, 2026-09-15 at 12:27 -0500, Chris Morgan wrote:
> [Some people who received this message don't often get email from
> macromorgan@xxxxxxxxxxx. Learn why this is important at
> https://aka.ms/LearnAboutSenderIdentification ;]
>
> On Tue, Sep 01, 2026 at 04:36:00PM +0200, Kanak Shilledar wrote:
> > Expose IIO_CHAN_INFO_CALIBBIAS on the accelerometer channels. The
> > registers are stored in MREG1, which can be accessed by the
> > mreg_read
> > and mreg_write routines. The calibration bias is written to
> > OFFSET_USER4
> > to OFFSET_USER8 registers in MREG1.
> >
> > Note: The accelerometer functionality is tested with Invensense,
> > ICM42370-P development board.
> >
> > Datasheet:
> > https://www.invensense.tdk.com/en-us/products/3-axis/icm-42370-p
> > Datasheet: https://www.lcsc.com/product-detail/C5129967.html
> > Signed-off-by: Kanak Shilledar <kanak.shilledar@xxxxxxxx>
> > ---
> >  drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c | 238
> > +++++++++++++++++++++-
> >  1 file changed, 236 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c
> > b/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c
> > index 318373efeb9e..af2ac9d6a47c 100644
> > --- a/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c
> > +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c
> > @@ -13,6 +13,7 @@
> >  #include <linux/pm_runtime.h>
> >  #include <linux/regmap.h>
> >  #include <linux/types.h>
> > +#include <linux/units.h>
> >
> >  #include "inv_icm42607.h"
> >  #include "inv_icm42607_temp.h"
> > @@ -22,9 +23,11 @@
> >       .type =
> > IIO_ACCEL,                                                      \
> >       .modified =
> > 1,                                                          \
> >       .channel2 =
> > _modifier,                                                  \
> > -     .info_mask_separate =
> > BIT(IIO_CHAN_INFO_RAW),                           \
> > +     .info_mask_separate = BIT(IIO_CHAN_INFO_RAW)
> > |                          \
> > +            
> > BIT(IIO_CHAN_INFO_CALIBBIAS),                                   \
> >       .info_mask_shared_by_type =
> > BIT(IIO_CHAN_INFO_SCALE),                   \
> > -     .info_mask_shared_by_type_available =
> > BIT(IIO_CHAN_INFO_SCALE),         \
> > +     .info_mask_shared_by_type_available =
> > BIT(IIO_CHAN_INFO_SCALE) |        \
> > +            
> > BIT(IIO_CHAN_INFO_CALIBBIAS),                                   \
> >       .info_mask_shared_by_all =
> > BIT(IIO_CHAN_INFO_SAMP_FREQ),                \
> >       .info_mask_shared_by_all_available =
> > BIT(IIO_CHAN_INFO_SAMP_FREQ),      \
> >       .scan_index =
> > _index,                                                   \
> > @@ -56,6 +59,16 @@ static const struct iio_chan_spec
> > inv_icm42607_accel_channels[] = {
> >       INV_ICM42607_TEMP_CHAN(INV_ICM42607_ACCEL_SCAN_TEMP),
> >  };
> >
> > +/*
> > + * Calibration bias values, IIO range format int + micro.
> > + * Value is limited to +/-1g coded on 12 bits signed. Step is
> > 0.5mg.
> > + */
> > +static int inv_icm42607_accel_calibbias[] = {
> > +     -10, 42010, /* Min : -2^11 * 0.0005 * 9.80665      = -
> > 10.042010 m/s²    */
> > +       0,  4903, /* Step: 0.5 * 0.00980655              = 0.004903
> > m/s²      */
> > +      10, 37106, /* Max : (2^11 - 1) * 0.0005 * 9.80665 =
> > 10.037106 m/s²     */
> > +};
> > +
>
> For whatever it's worth, when I read the calibbias values for my
> board
> from sysfs after applying this patch I get 0.000000 for
> in_accel_x_calibbias (or y or z) and in_accel_calibbias_available
> gives
> me an -EINVAL.
>
> But the accelerometer still seems to output data corresponding to the
> correct orientation.
>
> Thank you,
> Chris

Thanks for testing the patch. I have fixed the
in_accel_calibbias_available returning -EINVAL and should not be giving
the error in the v4.

Best Regards,
Kanak Shilledar

Attachment: signature.asc
Description: This is a digitally signed message part