From: Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Nuno Sa <nuno.sa@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Alexandru Ardelean <alexandru.ardelean@analog.com>,
Radu Sabau <radu.sabau@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux@analog.com,
Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH v5 8/8] iio: imu: adis16607: Add calibration bias support for gyro/accel
Date: Mon, 02 Nov 2026 11:25:44 +0200 [thread overview]
Message-ID: <20261102-adis16607-v5-8-4f98b0d271ac@analog.com> (raw)
In-Reply-To: <20261102-adis16607-v5-0-4f98b0d271ac@analog.com>
From: Radu Sabau <radu.sabau@analog.com>
Add IIO_CHAN_INFO_CALIBBIAS support for the gyroscope and
accelerometer axes, backed by the device's per-axis bias registers
(XA/YA/ZA_BIAS, XG/YG/ZG_BIAS).
Signed-off-by: Radu Sabau <radu.sabau@analog.com>
---
drivers/iio/imu/adis16607.c | 39 ++++++++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/imu/adis16607.c b/drivers/iio/imu/adis16607.c
index 58504d351de1..ab80e0909bf6 100644
--- a/drivers/iio/imu/adis16607.c
+++ b/drivers/iio/imu/adis16607.c
@@ -57,6 +57,12 @@
#define ADIS16607_REG_SOFT_RESET 0x36
#define ADIS16607_REG_SELF_TEST 0x39
#define ADIS16607_REG_DEC_RATE 0x3A
+#define ADIS16607_REG_XA_BIAS 0x3B
+#define ADIS16607_REG_YA_BIAS 0x3C
+#define ADIS16607_REG_ZA_BIAS 0x3D
+#define ADIS16607_REG_XG_BIAS 0x3E
+#define ADIS16607_REG_YG_BIAS 0x3F
+#define ADIS16607_REG_ZG_BIAS 0x40
#define ADIS16607_REG_DIGITAL_STATUS 0x4E
/* SPI Half-Duplex lock value */
@@ -168,15 +174,16 @@ enum {
struct adis16607_chan_regs {
u16 raw_reg;
+ u16 calib_bias_reg; /* 0 if the channel has no calibbias support */
};
static const struct adis16607_chan_regs adis16607_chan_regs[] = {
- [ADIS16607_SCAN_ACCEL_X] = { ADIS16607_REG_X_ACCEL },
- [ADIS16607_SCAN_ACCEL_Y] = { ADIS16607_REG_Y_ACCEL },
- [ADIS16607_SCAN_ACCEL_Z] = { ADIS16607_REG_Z_ACCEL },
- [ADIS16607_SCAN_GYRO_X] = { ADIS16607_REG_X_GYRO },
- [ADIS16607_SCAN_GYRO_Y] = { ADIS16607_REG_Y_GYRO },
- [ADIS16607_SCAN_GYRO_Z] = { ADIS16607_REG_Z_GYRO },
+ [ADIS16607_SCAN_ACCEL_X] = { ADIS16607_REG_X_ACCEL, ADIS16607_REG_XA_BIAS },
+ [ADIS16607_SCAN_ACCEL_Y] = { ADIS16607_REG_Y_ACCEL, ADIS16607_REG_YA_BIAS },
+ [ADIS16607_SCAN_ACCEL_Z] = { ADIS16607_REG_Z_ACCEL, ADIS16607_REG_ZA_BIAS },
+ [ADIS16607_SCAN_GYRO_X] = { ADIS16607_REG_X_GYRO, ADIS16607_REG_XG_BIAS },
+ [ADIS16607_SCAN_GYRO_Y] = { ADIS16607_REG_Y_GYRO, ADIS16607_REG_YG_BIAS },
+ [ADIS16607_SCAN_GYRO_Z] = { ADIS16607_REG_Z_GYRO, ADIS16607_REG_ZG_BIAS },
[ADIS16607_SCAN_DELTVEL_X] = { ADIS16607_REG_X_DELTVEL },
[ADIS16607_SCAN_DELTVEL_Y] = { ADIS16607_REG_Y_DELTVEL },
[ADIS16607_SCAN_DELTVEL_Z] = { ADIS16607_REG_Z_DELTVEL },
@@ -1030,6 +1037,16 @@ static int adis16607_read_raw(struct iio_dev *indio_dev,
/* Temperature: 0 raw counts = 25°C; offset = 25000 mdeg / 5 mdeg per LSB = 5000 */
*val = 5000;
return IIO_VAL_INT;
+ case IIO_CHAN_INFO_CALIBBIAS: {
+ u16 reg = adis16607_chan_regs[chan->address].calib_bias_reg;
+ u16 tmp16;
+
+ ret = adis_read_reg_16(&st->adis, reg, &tmp16);
+ if (ret)
+ return ret;
+ *val = sign_extend32(tmp16, 15);
+ return IIO_VAL_INT;
+ }
case IIO_CHAN_INFO_SAMP_FREQ:
ret = adis16607_get_freq(st, &tmp);
if (ret)
@@ -1067,6 +1084,13 @@ static int adis16607_write_raw(struct iio_dev *indio_dev,
val2 / (MICROHZ_PER_HZ / MILLIHZ_PER_HZ);
return adis16607_set_freq(st, tmp);
}
+ case IIO_CHAN_INFO_CALIBBIAS: {
+ u16 reg = adis16607_chan_regs[chan->address].calib_bias_reg;
+
+ if (val < S16_MIN || val > S16_MAX)
+ return -EINVAL;
+ return adis_write_reg_16(&st->adis, reg, val);
+ }
default:
return -EINVAL;
}
@@ -1081,7 +1105,8 @@ static int adis16607_write_raw(struct iio_dev *indio_dev,
.type = (_type), \
.modified = 1, \
.channel2 = (_mod), \
- .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_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
.address = (_idx), \
--
2.43.0
prev parent reply other threads:[~2026-11-02 9:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 9:25 [PATCH v5 0/8] iio: imu: Add support for the ADI ADIS16607 Radu Sabau via B4 Relay
2026-11-02 9:25 ` [PATCH v5 1/8] iio: imu: adis: Fix custom reset dispatch in adislib Radu Sabau via B4 Relay
2026-11-02 9:25 ` [PATCH v5 2/8] iio: imu: adis: Add optional self_test callback Radu Sabau via B4 Relay
2026-11-02 9:25 ` [PATCH v5 3/8] iio: imu: adis: Add optional init callback Radu Sabau via B4 Relay
2026-11-02 9:25 ` [PATCH v5 4/8] dt-bindings: iio: imu: Add bindings for ADI ADIS16607 Radu Sabau via B4 Relay
2026-11-02 9:25 ` [PATCH v5 5/8] iio: imu: Add driver for the " Radu Sabau via B4 Relay
2026-11-02 9:25 ` [PATCH v5 6/8] iio: imu: adis16607: Add FIFO-based buffered/triggered capture Radu Sabau via B4 Relay
2026-11-02 9:25 ` [PATCH v5 7/8] iio: imu: adis16607: Add external clock sync support Radu Sabau via B4 Relay
2026-11-02 9:25 ` Radu Sabau via B4 Relay [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261102-adis16607-v5-8-4f98b0d271ac@analog.com \
--to=devnull+radu.sabau.analog.com@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=nuno.sa@analog.com \
--cc=radu.sabau@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®