Skip to contentSkip to conversation

Add support for ADIS16550

PATCH RESEND In review Robert Budai 4 participants 15 messages Feb 17, 2025 – Mar 4, 2025

Subsystems (6)
lore
Share & tools
lore

Robert Budai

author maintainer
#0 lore raw

v8 cover Add support for ADIS16550

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

Robert Budai (6):
iio: imu: adis: Add custom ops struct
iio: imu: adis: Add reset to custom ops
iio: imu: adis: Add DIAG_STAT register
dt-bindings: iio: Add adis16550 bindings
iio: imu: adis16550: add adis16550 support
docs: iio: add documentation for adis16550 driver

 .../bindings/iio/imu/adi,adis16550.yaml       |   74 ++
 Documentation/iio/adis16550.rst               |  376 ++++++
 Documentation/iio/index.rst                   |    1 +
 MAINTAINERS                                   |   10 +
 drivers/iio/imu/Kconfig                       |   13 +
 drivers/iio/imu/Makefile                      |    1 +
 drivers/iio/imu/adis.c                        |   35 +-
 drivers/iio/imu/adis16550.c                   | 1149 +++++++++++++++++
 include/linux/iio/imu/adis.h                  |   34 +-
 9 files changed, 1680 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
 create mode 100644 Documentation/iio/adis16550.rst
 create mode 100644 drivers/iio/imu/adis16550.c
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH RESEND v8 1/6 iio: imu: adis: Add custom ops struct

This patch introduces a custom ops struct letting users define custom read and write functions. Some adis devices might define a completely different spi protocol from the one used in the default implementation.

---

v8:
- no changes

 drivers/iio/imu/adis.c       | 16 +++++++++++++---
 include/linux/iio/imu/adis.h | 28 +++++++++++++++++++++-------
 2 files changed, 34 insertions(+), 10 deletions(-)
drivers/iio/imu/adis.c +13 -3
index 494171844..54915c7a3 100644
@@ -223,13 +223,13 @@ int __adis_update_bits_base(struct adis *adis, unsigned int reg, const u32 mask,
 	int ret;
 	u32 __val;
 
-	ret = __adis_read_reg(adis, reg, &__val, size);
+	ret = adis->ops->read(adis, reg, &__val, size);
 	if (ret)
 		return ret;
 
 	__val = (__val & ~mask) | (val & mask);
 
-	return __adis_write_reg(adis, reg, __val, size);
+	return adis->ops->write(adis, reg, __val, size);
 }
 EXPORT_SYMBOL_NS_GPL(__adis_update_bits_base, "IIO_ADISLIB");
 
@@ -468,7 +468,7 @@ int adis_single_conversion(struct iio_dev *indio_dev,
 
 	guard(mutex)(&adis->state_lock);
 
-	ret = __adis_read_reg(adis, chan->address, &uval,
+	ret = adis->ops->read(adis, chan->address, &uval,
 			      chan->scan_type.storagebits / 8);
 	if (ret)
 		return ret;
@@ -488,6 +488,11 @@ int adis_single_conversion(struct iio_dev *indio_dev,
 }
 EXPORT_SYMBOL_NS_GPL(adis_single_conversion, "IIO_ADISLIB");
 
+static const struct adis_ops adis_default_ops = {
+	.read = __adis_read_reg,
+	.write = __adis_write_reg,
+};
+
 /**
  * adis_init() - Initialize adis device structure
  * @adis:	The adis device
@@ -517,6 +522,11 @@ int adis_init(struct adis *adis, struct iio_dev *indio_dev,
 
 	adis->spi = spi;
 	adis->data = data;
+	if (!adis->ops->write && !adis->ops->read)
+		adis->ops = &adis_default_ops;
+	else if (!adis->ops->write || !adis->ops->read)
+		return -EINVAL;
+
 	iio_device_set_drvdata(indio_dev, adis);
 
 	if (data->has_paging) {
include/linux/iio/imu/adis.h +21 -7
index 4bb98d973..89cfa75ae 100644
@@ -94,6 +94,18 @@ struct adis_data {
 	unsigned int burst_max_speed_hz;
 };
 
+/**
+ * struct adis_ops: Custom ops for adis devices.
+ * @write: Custom spi write implementation.
+ * @read: Custom spi read implementation.
+ */
+struct adis_ops {
+	int (*write)(struct adis *adis, unsigned int reg, unsigned int value,
+		     unsigned int size);
+	int (*read)(struct adis *adis, unsigned int reg, unsigned int *value,
+		    unsigned int size);
+};
+
 /**
  * struct adis - ADIS device instance data
  * @spi: Reference to SPI device which owns this ADIS IIO device
@@ -101,6 +113,7 @@ struct adis_data {
  * @data: ADIS chip variant specific data
  * @burst_extra_len: Burst extra length. Should only be used by devices that can
  *		     dynamically change their burst mode length.
+ * @ops: ops struct for custom read and write functions
  * @state_lock: Lock used by the device to protect state
  * @msg: SPI message object
  * @xfer: SPI transfer objects to be used for a @msg
@@ -116,6 +129,7 @@ struct adis {
 
 	const struct adis_data	*data;
 	unsigned int		burst_extra_len;
+	const struct adis_ops	*ops;
 	/**
 	 * The state_lock is meant to be used during operations that require
 	 * a sequence of SPI R/W in order to protect the SPI transfer
@@ -168,7 +182,7 @@ int __adis_read_reg(struct adis *adis, unsigned int reg,
 static inline int __adis_write_reg_8(struct adis *adis, unsigned int reg,
 				     u8 val)
 {
-	return __adis_write_reg(adis, reg, val, 1);
+	return adis->ops->write(adis, reg, val, 1);
 }
 
 /**
@@ -180,7 +194,7 @@ static inline int __adis_write_reg_8(struct adis *adis, unsigned int reg,
 static inline int __adis_write_reg_16(struct adis *adis, unsigned int reg,
 				      u16 val)
 {
-	return __adis_write_reg(adis, reg, val, 2);
+	return adis->ops->write(adis, reg, val, 2);
 }
 
 /**
@@ -192,7 +206,7 @@ static inline int __adis_write_reg_16(struct adis *adis, unsigned int reg,
 static inline int __adis_write_reg_32(struct adis *adis, unsigned int reg,
 				      u32 val)
 {
-	return __adis_write_reg(adis, reg, val, 4);
+	return adis->ops->write(adis, reg, val, 4);
 }
 
 /**
@@ -207,7 +221,7 @@ static inline int __adis_read_reg_16(struct adis *adis, unsigned int reg,
 	unsigned int tmp;
 	int ret;
 
-	ret = __adis_read_reg(adis, reg, &tmp, 2);
+	ret = adis->ops->read(adis, reg, &tmp, 2);
 	if (ret == 0)
 		*val = tmp;
 
@@ -226,7 +240,7 @@ static inline int __adis_read_reg_32(struct adis *adis, unsigned int reg,
 	unsigned int tmp;
 	int ret;
 
-	ret = __adis_read_reg(adis, reg, &tmp, 4);
+	ret = adis->ops->read(adis, reg, &tmp, 4);
 	if (ret == 0)
 		*val = tmp;
 
@@ -244,7 +258,7 @@ static inline int adis_write_reg(struct adis *adis, unsigned int reg,
 				 unsigned int val, unsigned int size)
 {
 	guard(mutex)(&adis->state_lock);
-	return __adis_write_reg(adis, reg, val, size);
+	return adis->ops->write(adis, reg, val, size);
 }
 
 /**
@@ -258,7 +272,7 @@ static int adis_read_reg(struct adis *adis, unsigned int reg,
 			 unsigned int *val, unsigned int size)
 {
 	guard(mutex)(&adis->state_lock);
-	return __adis_read_reg(adis, reg, val, size);
+	return adis->ops->read(adis, reg, val, size);
 }
 
 /**
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH RESEND v8 2/6 iio: imu: adis: Add reset to custom ops

In reply to Robert Budai

This patch allows the custom definition of reset functionality for adis object. It is useful in cases where the driver does not need to sleep after the reset since it is handled by the library.

---

v8:
- no changes

 drivers/iio/imu/adis.c       | 5 +++--
 include/linux/iio/imu/adis.h | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/iio/imu/adis.c +3 -2
index 54915c7a3..84344f052 100644
@@ -491,6 +491,7 @@ EXPORT_SYMBOL_NS_GPL(adis_single_conversion, "IIO_ADISLIB");
 static const struct adis_ops adis_default_ops = {
 	.read = __adis_read_reg,
 	.write = __adis_write_reg,
+	.reset = __adis_reset,
 };
 
 /**
@@ -522,9 +523,9 @@ int adis_init(struct adis *adis, struct iio_dev *indio_dev,
 
 	adis->spi = spi;
 	adis->data = data;
-	if (!adis->ops->write && !adis->ops->read)
+	if (!adis->ops->write && !adis->ops->read && !adis->ops->reset)
 		adis->ops = &adis_default_ops;
-	else if (!adis->ops->write || !adis->ops->read)
+	else if (!adis->ops->write || !adis->ops->read || !adis->ops->reset)
 		return -EINVAL;
 
 	iio_device_set_drvdata(indio_dev, adis);
include/linux/iio/imu/adis.h +3 -0
index 89cfa75ae..52652f51d 100644
@@ -98,12 +98,15 @@ struct adis_data {
  * struct adis_ops: Custom ops for adis devices.
  * @write: Custom spi write implementation.
  * @read: Custom spi read implementation.
+ * @reset: Custom sw reset implementation. The custom implementation does not
+ *	   need to sleep after the reset. It's done by the library already.
  */
 struct adis_ops {
 	int (*write)(struct adis *adis, unsigned int reg, unsigned int value,
 		     unsigned int size);
 	int (*read)(struct adis *adis, unsigned int reg, unsigned int *value,
 		    unsigned int size);
+	int (*reset)(struct adis *adis);
 };
 
 /**
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH RESEND v8 3/6 iio: imu: adis: Add DIAG_STAT register

In reply to Robert Budai

Some devices may have more than 16 bits of status. This patch allows the user to specify the size of the DIAG_STAT register. It defaults to 2 if not specified. This is mainly for backward compatibility.

---

v8:
- added extra bracket for kernel styling
- fixed pointer issue

 drivers/iio/imu/adis.c       | 18 +++++++++++++++---
 include/linux/iio/imu/adis.h |  3 +++
 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/iio/imu/adis.c +15 -3
index 84344f052..1c646c36a 100644
@@ -304,11 +304,20 @@ EXPORT_SYMBOL_NS(__adis_enable_irq, "IIO_ADISLIB");
  */
 int __adis_check_status(struct adis *adis)
 {
-	u16 status;
+	unsigned int status;
+	int diag_stat_bits;
+	u16 status_16;
 	int ret;
 	int i;
 
-	ret = __adis_read_reg_16(adis, adis->data->diag_stat_reg, &status);
+	if (adis->data->diag_stat_size) {
+		ret = adis->ops->read(adis, adis->data->diag_stat_reg, &status,
+				      adis->data->diag_stat_size);
+	} else {
+		ret = __adis_read_reg_16(adis, adis->data->diag_stat_reg,
+					 &status_16);
+		status = status_16;
+	}
 	if (ret)
 		return ret;
 
@@ -317,7 +326,10 @@ int __adis_check_status(struct adis *adis)
 	if (status == 0)
 		return 0;
 
-	for (i = 0; i < 16; ++i) {
+	diag_stat_bits = BITS_PER_BYTE * (adis->data->diag_stat_size ?
+					  adis->data->diag_stat_size : 2);
+
+	for (i = 0; i < diag_stat_bits; ++i) {
 		if (status & BIT(i)) {
 			dev_err(&adis->spi->dev, "%s.\n",
 				adis->data->status_error_msgs[i]);
include/linux/iio/imu/adis.h +3 -0
index 52652f51d..aa160511e 100644
@@ -44,6 +44,8 @@ struct adis_timeout {
  * @glob_cmd_reg: Register address of the GLOB_CMD register
  * @msc_ctrl_reg: Register address of the MSC_CTRL register
  * @diag_stat_reg: Register address of the DIAG_STAT register
+ * @diag_stat_size:	Length (in bytes) of the DIAG_STAT register. If 0 the
+ *			default length is 2 bytes long.
  * @prod_id_reg: Register address of the PROD_ID register
  * @prod_id: Product ID code that should be expected when reading @prod_id_reg
  * @self_test_mask: Bitmask of supported self-test operations
@@ -70,6 +72,7 @@ struct adis_data {
 	unsigned int glob_cmd_reg;
 	unsigned int msc_ctrl_reg;
 	unsigned int diag_stat_reg;
+	unsigned int diag_stat_size;
 	unsigned int prod_id_reg;
 
 	unsigned int prod_id;
Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH RESEND v8 4/6 dt-bindings: iio: Add adis16550 bindings

In reply to Robert Budai

Document the ADIS16550 device devicetree bindings.

---

v8:
- added extra blank lines
- changes reset-gpios description according to suggested changes

 .../bindings/iio/imu/adi,adis16550.yaml       | 74 +++++++++++++++++++
 MAINTAINERS                                   | 10 +++
 2 files changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +74 -0
new file mode 100644
index 000000000..a4c273c7a
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/imu/adi,adis16550.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices ADIS16550 and similar IMUs
+
+maintainers:
+  - Nuno Sa <[email protected]>
+  - Ramona Gradinariu <[email protected]>
+  - Antoniu Miclaus <[email protected]>
+  - Robert Budai <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+
+  spi-cpol: true
+
+  spi-max-frequency:
+    maximum: 15000000
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      Active low RESET pin.
+    maxItems: 1
+
+  clocks:
+    description: If not provided, then the internal clock is used.
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - spi-cpha
+  - spi-cpol
+  - spi-max-frequency
+  - vdd-supply
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        imu@0 {
+            compatible = "adi,adis16550";
+            reg = <0>;
+            spi-max-frequency = <15000000>;
+            spi-cpol;
+            spi-cpha;
+            vdd-supply = <&vdd>;
+            interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
+            interrupt-parent = <&gpio>;
+        };
+    };
MAINTAINERS +10 -0
index 25c86f473..d3e6258fa 100644
@@ -1485,6 +1485,16 @@ W:	https://ez.analog.com/linux-software-drivers
 F:	Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml
 F:	drivers/iio/imu/adis16475.c
 
+ANALOG DEVICES INC ADIS16550 DRIVER
+M:	Nuno Sa <[email protected]>
+M:	Ramona Gradinariu <[email protected]>
+M:	Antoniu Miclaus <[email protected]>
+M:	Robert Budai <[email protected]>
+L:	[email protected]
+S:	Supported
+W:	https://ez.analog.com/linux-software-drivers
+F:	Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
+
 ANALOG DEVICES INC ADM1177 DRIVER
 M:	Michael Hennerich <[email protected]>
 L:	[email protected]
Signature · 1 line
2.34.1
maintainer Reviewed-by on v8 4/6
#5 lore raw

Re: [RESEND PATCH v8 4/6] dt-bindings: iio: Add adis16550 bindings

Quoted 8 lines · Robert Budai

Document the ADIS16550 device devicetree bindings.

---

Quoted 9 lines

v8:
- added extra blank lines
- changes reset-gpios description according to suggested changes

 .../bindings/iio/imu/adi,adis16550.yaml       | 74 +++++++++++++++++++
 MAINTAINERS                                   | 10 +++
 2 files changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
author maintainer
#6 lore raw

PATCH RESEND v8 5/6 iio: imu: adis16550: add adis16550 support

In reply to Robert Budai

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

---

v8:
- removed __aligned from struct adis16550, as suggested
- crc buffer extraction into the crc check function
- passed buffer into crc validation as original, __be32 and performed check using be32_to_cpu conversion of the buffer
- added trailing comma to line 993
- removed trailing comma from line 877

 drivers/iio/imu/Kconfig     |   13 +
 drivers/iio/imu/Makefile    |    1 +
 drivers/iio/imu/adis16550.c | 1149 +++++++++++++++++++++++++++++++++++
 3 files changed, 1163 insertions(+)
 create mode 100644 drivers/iio/imu/adis16550.c
drivers/iio/imu/Kconfig +13 -0
index ca0efecb5..15612f0f1 100644
@@ -52,6 +52,19 @@ config ADIS16480
 	  Say yes here to build support for Analog Devices ADIS16375, ADIS16480,
 	  ADIS16485, ADIS16488 inertial sensors.
 
+config ADIS16550
+	tristate "Analog Devices ADIS16550 and similar IMU driver"
+	depends on SPI
+	select IIO_ADIS_LIB
+	select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
+	select CRC32
+	help
+	  Say yes here to build support for Analog Devices ADIS16550 inertial
+	  sensor containing triaxis gyroscope and triaxis accelerometer.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called adis16550.
+
 source "drivers/iio/imu/bmi160/Kconfig"
 source "drivers/iio/imu/bmi270/Kconfig"
 source "drivers/iio/imu/bmi323/Kconfig"
drivers/iio/imu/Makefile +1 -0
index 04c77c2c4..e901aea49 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_ADIS16400) += adis16400.o
 obj-$(CONFIG_ADIS16460) += adis16460.o
 obj-$(CONFIG_ADIS16475) += adis16475.o
 obj-$(CONFIG_ADIS16480) += adis16480.o
+obj-$(CONFIG_ADIS16550) += adis16550.o
 
 adis_lib-y += adis.o
 adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_trigger.o
drivers/iio/imu/adis16550.c new file +1149 -0

1,149 lines not on this page · raw message

Signature · 1 line
2.34.1
#7 lore raw

Re: [RESEND PATCH v8 5/6] iio: imu: adis16550: add adis16550 support

Quoted 8 lines · Robert Budai

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

Quoted 8 lines

---

I guess it would make sense a Co-developed-by: for Robert?

Anyways, all looks good except for one thing that I just spotted...

Quoted 14 lines

v8:
- removed __aligned from struct adis16550, as suggested
- crc buffer extraction into the crc check function
- passed buffer into crc validation as original, __be32 and performed check using be32_to_cpu conversion of the buffer
- added trailing comma to line 993
- removed trailing comma from line 877

 drivers/iio/imu/Kconfig     |   13 + drivers/iio/imu/Makefile    |    1 + drivers/iio/imu/adis16550.c | 1149 +++++++++++++++++++++++++++++++++++

 3 files changed, 1163 insertions(+)

 create mode 100644 drivers/iio/imu/adis16550.c

...

Quoted 32 lines
drivers/iio/imu/adis16550.c new file +23 -0
+static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
+{
+	u16 dec;
+	int ret;
+	u32 sample_rate = st->clk_freq_hz;
+	/*
+	 * The optimal sample rate for the supported IMUs is between
+	 * int_clk - 1000 and int_clk + 500.
+	 */
+	u32 max_sample_rate = st->info->int_clk * 1000 + 500000;
+	u32 min_sample_rate = st->info->int_clk * 1000 - 1000000;
+
+	if (!freq_hz)
+		return -EINVAL;
+
+	adis_dev_auto_lock(&st->adis);
+
+	if (st->sync_mode == ADIS16550_SYNC_MODE_SCALED) {
+		unsigned long scaled_rate = lcm(st->clk_freq_hz, freq_hz);
+		int sync_scale;
+
+		if (scaled_rate > max_sample_rate)
+			scaled_rate = max_sample_rate / st->clk_freq_hz * st-
Quoted 1 line

clk_freq_hz;

(quoted diff) +2 -0
+		else
+			scaled_rate = max_sample_rate / scaled_rate *

scaled_rate;

drivers/iio/imu/adis16550.c new file +3 -0
+
+		if (scaled_rate < min_sample_rate)
+			scaled_rate = roundup(min_sample_rate, st-
Quoted 1 line

clk_freq_hz);

Quoted 1 line

+

I would imagine the above is the same deal as in other devices [1] or do you know for a fact this one is different? Maybe it's simple enough for Jonathan to tweak while applying...

[1]: https://elixir.bootlin.com/linux/v6.13.3/source/drivers/iio/imu/adis16475.c#L364

- Nuno Sá

author maintainer
#8 lore raw

RE: [RESEND PATCH v8 5/6] iio: imu: adis16550: add adis16550 support

Quoted 97 lines

-----Original Message-----
From: Nuno Sá <[email protected]>
Sent: Thursday, February 20, 2025 10:22 AM
To: Budai, Robert <[email protected]>; Lars-Peter Clausen <[email protected]>; Hennerich, Michael <[email protected]>; Sa, Nuno <[email protected]>; Gradinariu, Ramona <[email protected]>; Miclaus, Antoniu <[email protected]>; Jonathan Cameron <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Jonathan Corbet <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [RESEND PATCH v8 5/6] iio: imu: adis16550: add adis16550 support

[External]

Quoted 8 lines · Robert Budai

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

Quoted 8 lines

---

I guess it would make sense a Co-developed-by: for Robert?

Anyways, all looks good except for one thing that I just spotted...

Quoted 11 lines

v8:
- removed __aligned from struct adis16550, as suggested
- crc buffer extraction into the crc check function
- passed buffer into crc validation as original, __be32 and performed check using be32_to_cpu conversion of the buffer
- added trailing comma to line 993
- removed trailing comma from line 877

 drivers/iio/imu/Kconfig     |   13 +
 drivers/iio/imu/Makefile    |    1 +
 drivers/iio/imu/adis16550.c | 1149

+++++++++++++++++++++++++++++++++++

Quoted 3 lines
 3 files changed, 1163 insertions(+)

 create mode 100644 drivers/iio/imu/adis16550.c

...

Quoted 32 lines
drivers/iio/imu/adis16550.c new file +23 -0
+static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
+{
+	u16 dec;
+	int ret;
+	u32 sample_rate = st->clk_freq_hz;
+	/*
+	 * The optimal sample rate for the supported IMUs is between
+	 * int_clk - 1000 and int_clk + 500.
+	 */
+	u32 max_sample_rate = st->info->int_clk * 1000 + 500000;
+	u32 min_sample_rate = st->info->int_clk * 1000 - 1000000;
+
+	if (!freq_hz)
+		return -EINVAL;
+
+	adis_dev_auto_lock(&st->adis);
+
+	if (st->sync_mode == ADIS16550_SYNC_MODE_SCALED) {
+		unsigned long scaled_rate = lcm(st->clk_freq_hz, freq_hz);
+		int sync_scale;
+
+		if (scaled_rate > max_sample_rate)
+			scaled_rate = max_sample_rate / st->clk_freq_hz * st-
Quoted 1 line

clk_freq_hz;

(quoted diff) +2 -0
+		else
+			scaled_rate = max_sample_rate / scaled_rate *

scaled_rate;

drivers/iio/imu/adis16550.c new file +3 -0
+
+		if (scaled_rate < min_sample_rate)
+			scaled_rate = roundup(min_sample_rate, st-
Quoted 1 line

clk_freq_hz);

Quoted 1 line

+

I would imagine the above is the same deal as in other devices [1] or do you know for a fact this one is different? Maybe it's simple enough for Jonathan to tweak while applying...

Quoted 7 lines

[1]:
https://urldefense.com/v3/__https://elixir.bootlin.com/linux/v6.13.3/source
/drivers/iio/imu/adis16475.c*L364__;Iw!!A3Ni8CS0y2Y!7Y71yPaQAxVzNRd O_jT7wEz4k- s6z4tJHOcES84HYkq8qNGsgJH7zxwjfPNjLF3OEGVInSolo1ennLU_mwpmEbo$

- Nuno Sá

[Robert Budai]
No differences were found in the scaled_sync behavior of the ADIS16475 and ADIS16550. It is safe to add from my side.

Best regards,
Robert B

maintainer
#9 lore raw

Re: [RESEND PATCH v8 5/6] iio: imu: adis16550: add adis16550 support

Quoted 35 lines · Robert
Quoted 35 lines

-----Original Message-----
From: Nuno Sá <[email protected]>
Sent: Thursday, February 20, 2025 10:22 AM
To: Budai, Robert <[email protected]>; Lars-Peter Clausen <[email protected]>; Hennerich, Michael <[email protected]>; Sa, Nuno <[email protected]>; Gradinariu, Ramona <[email protected]>; Miclaus, Antoniu <[email protected]>; Jonathan Cameron <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Jonathan Corbet <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [RESEND PATCH v8 5/6] iio: imu: adis16550: add adis16550 support

[External]

Quoted 16 lines · Robert Budai

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

---

Quoted 1 line
Quoted 1 line

I guess it would make sense a Co-developed-by: for Robert?

The From is set to Robert, so that is implicit. It is an odd chain though. Now I've looked at it this doesn't
seem quite right but I am struggling with what it should be :(

I think this chain means that Ramona, Antoniu and Robert made significant contributions. Robert's was after Nuno had handled the patch on some ADI tree?

In the end Roberts was large enough to take 'ownership' rather than the original 'from'. That part is unusual. We rarely do that.

However, from what I can see publicly that isn't what happened.

This patch v1 was posted with Robert as Co-developed and Nuno as the From + SoB (which puts Nuno at same level as a co-developer but the one who posted it).

So really the ownership trail should have remained the same with the From set to Nuno. However that gives us another fun corner.

Robert then started handing the series. That would normally require a SoB to cover that part, but he already has one. Gah.

Anyhow I think the best way to fix this up is actually to add Co-developed-by for Nuno which does transfer patch ownership but at least refects that all of you played some significant part.

Alternative is modify the author ship to reflect earliest posting.

To keep things moving I'm going to assume you are fine with me adding Co-developed by to explain Nuno's SoB where relevant rather than changing the From and adding Co-developed-by for Robert.

The DT binding has a similar issue. There we have Ramona who handled the patch but no co-developed. That's clearly not right as v1 is form Ramona. There I'll make it Codev Ramona.

If you'd prefer to fix this all up with the original From:
then send me a new version and I'll switch out what I have applied.

Interesting this patch doesn't build and has a warning. I tweaked as:
For some reason the first of the u16 val cases didn't trigger the size mismatch that __adis_update_bits() has a BUILD_BUG check on but given the similarity of the two cases I'm not sure why and I tweaked them both. Give me a shout if any of this breaks things.

drivers/iio/imu/adis16550.c +5 -6
index 16f01c61a429..8ec3afe6140b 100644
@@ -509,10 +509,10 @@ static int adis16550_get_accl_filter_freq(struct adis16550 *st, int *freq_hz)
 static int adis16550_set_accl_filter_freq(struct adis16550 *st, int freq_hz)
 {
        u8 en = freq_hz ? 1 : 0;
+       u16 val = FIELD_PREP(ADIS16550_ACCL_FIR_EN_MASK, en);
 
        return __adis_update_bits(&st->adis, ADIS16550_REG_CONFIG,
-                                 ADIS16550_ACCL_FIR_EN_MASK,
-                                 FIELD_PREP(ADIS16550_ACCL_FIR_EN_MASK, en));
+                                 ADIS16550_ACCL_FIR_EN_MASK, val);
 }
 
 static int adis16550_get_gyro_filter_freq(struct adis16550 *st, int *freq_hz)
@@ -535,10 +535,10 @@ static int adis16550_get_gyro_filter_freq(struct adis16550 *st, int *freq_hz)
 static int adis16550_set_gyro_filter_freq(struct adis16550 *st, int freq_hz)
 {
        u8 en = freq_hz ? 1 : 0;
+       u16 val = FIELD_PREP(ADIS16550_GYRO_FIR_EN_MASK, en);
 
        return __adis_update_bits(&st->adis, ADIS16550_REG_CONFIG,
-                                 ADIS16550_GYRO_FIR_EN_MASK,
-                                 FIELD_PREP(ADIS16550_GYRO_FIR_EN_MASK, en));
+                                 ADIS16550_GYRO_FIR_EN_MASK, val);
 }
 
 enum {
@@ -832,7 +832,6 @@ static u32 adis16550_validate_crc(__be32 *buffer, const u8 n_elem)
 
 static irqreturn_t adis16550_trigger_handler(int irq, void *p)
 {
-       u32 crc;
        int ret;
        u16 dummy;
        bool valid;
@@ -1143,7 +1142,7 @@ module_spi_driver(adis16550_driver);
 MODULE_AUTHOR("Nuno Sa <[email protected]>");
 MODULE_AUTHOR("Ramona Gradinariu <[email protected]>");
 MODULE_AUTHOR("Antoniu Miclaus <[email protected]>");
-MODULE_AUTHOR("Robert Budai <[email protected]>")
+MODULE_AUTHOR("Robert Budai <[email protected]>");
 MODULE_DESCRIPTION("Analog Devices ADIS16550 IMU driver");
 MODULE_IMPORT_NS("IIO_
 
Quoted 65 lines
Quoted 65 lines

Anyways, all looks good except for one thing that I just spotted...

Quoted 11 lines

v8:
- removed __aligned from struct adis16550, as suggested
- crc buffer extraction into the crc check function
- passed buffer into crc validation as original, __be32 and performed check using be32_to_cpu conversion of the buffer
- added trailing comma to line 993
- removed trailing comma from line 877

 drivers/iio/imu/Kconfig     |   13 +
 drivers/iio/imu/Makefile    |    1 +
 drivers/iio/imu/adis16550.c | 1149

+++++++++++++++++++++++++++++++++++

Quoted 3 lines
 3 files changed, 1163 insertions(+)

 create mode 100644 drivers/iio/imu/adis16550.c

...

Quoted 32 lines
(quoted diff) +23 -0
+static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
+{
+	u16 dec;
+	int ret;
+	u32 sample_rate = st->clk_freq_hz;
+	/*
+	 * The optimal sample rate for the supported IMUs is between
+	 * int_clk - 1000 and int_clk + 500.
+	 */
+	u32 max_sample_rate = st->info->int_clk * 1000 + 500000;
+	u32 min_sample_rate = st->info->int_clk * 1000 - 1000000;
+
+	if (!freq_hz)
+		return -EINVAL;
+
+	adis_dev_auto_lock(&st->adis);
+
+	if (st->sync_mode == ADIS16550_SYNC_MODE_SCALED) {
+		unsigned long scaled_rate = lcm(st->clk_freq_hz, freq_hz);
+		int sync_scale;
+
+		if (scaled_rate > max_sample_rate)
+			scaled_rate = max_sample_rate / st->clk_freq_hz * st-  
Quoted 1 line

clk_freq_hz;

(quoted diff) +2 -0
+		else
+			scaled_rate = max_sample_rate / scaled_rate *

scaled_rate;

(quoted diff) +3 -0
+
+		if (scaled_rate < min_sample_rate)
+			scaled_rate = roundup(min_sample_rate, st-  
Quoted 1 line

clk_freq_hz);

Quoted 1 line

+

I would imagine the above is the same deal as in other devices [1] or do you know for a fact this one is different? Maybe it's simple enough for Jonathan to tweak while applying...

[1]:
https://urldefense.com/v3/__https://elixir.bootlin.com/linux/v6.13.3/source
/drivers/iio/imu/adis16475.c*L364__;Iw!!A3Ni8CS0y2Y!7Y71yPaQAxVzNRd O_jT7wEz4k- s6z4tJHOcES84HYkq8qNGsgJH7zxwjfPNjLF3OEGVInSolo1ennLU_mwpmEbo$

Quoted 6 lines
Quoted 1 line

- Nuno Sá

[Robert Budai]
No differences were found in the scaled_sync behavior of the ADIS16475 and ADIS16550. It is safe to add from my side.

If we want to do such a module parameter override I am fine with adding it but as a separate patch on top that provides the reasoning etc. It is a little to messy for me to do as a tweak.

Jonathan

Quoted 2 lines

Best regards,
Robert B

#10 lore raw

Re: [RESEND PATCH v8 5/6] iio: imu: adis16550: add adis16550 support

Quoted 41 lines · Jonathan Cameron
Quoted 36 lines · Robert
Quoted 36 lines

-----Original Message-----
From: Nuno Sá <[email protected]>
Sent: Thursday, February 20, 2025 10:22 AM
To: Budai, Robert <[email protected]>; Lars-Peter Clausen <[email protected]>; Hennerich, Michael <[email protected]>; Sa, Nuno <[email protected]>; Gradinariu, Ramona <[email protected]>; Miclaus, Antoniu <[email protected]>; Jonathan Cameron <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Jonathan Corbet <[email protected]>; linux- [email protected]; [email protected]; [email protected];
[email protected]
Subject: Re: [RESEND PATCH v8 5/6] iio: imu: adis16550: add adis16550 support

[External]

Quoted 16 lines · Robert Budai

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

---

Quoted 1 line
Quoted 1 line

I guess it would make sense a Co-developed-by: for Robert?

Quoted 8 lines

The From is set to Robert, so that is implicit.  It is an odd chain though. Now I've looked at it this doesn't
seem quite right but I am struggling with what it should be :(

I think this chain means that Ramona, Antoniu and Robert made significant contributions. Robert's was after Nuno had handled the patch on some ADI tree?

So, I was the one that original wrote the driver (I think about 3 years ago) and the needed modifications on the adis lib. Then, Ramona, Antoniu and Robert all worked on the driver after me when someone remembered it was about time to upstream this :)

...

Quoted 26 lines
drivers/iio/imu/adis16550.c +1 -0
index 16f01c61a429..8ec3afe6140b 100644
@@ -509,10 +509,10 @@ static int adis16550_get_accl_filter_freq(struct
 adis16550 *st, int *freq_hz)
  static int adis16550_set_accl_filter_freq(struct adis16550 *st, int freq_hz)
  {
         u8 en = freq_hz ? 1 : 0;
+       u16 val = FIELD_PREP(ADIS16550_ACCL_FIR_EN_MASK, en);


        return __adis_update_bits(&st->adis, ADIS16550_REG_CONFIG, -                                 ADIS16550_ACCL_FIR_EN_MASK,
-                                 FIELD_PREP(ADIS16550_ACCL_FIR_EN_MASK, en)); +                                 ADIS16550_ACCL_FIR_EN_MASK, val); }

 static int adis16550_get_gyro_filter_freq(struct adis16550 *st, int *freq_hz)

drivers/iio/imu/adis16550.c +1 -0
@@ -535,10 +535,10 @@ static int adis16550_get_gyro_filter_freq(struct
 adis16550 *st, int *freq_hz)
  static int adis16550_set_gyro_filter_freq(struct adis16550 *st, int freq_hz)
  {
         u8 en = freq_hz ? 1 : 0;
+       u16 val = FIELD_PREP(ADIS16550_GYRO_FIR_EN_MASK, en);
Quoted 7 lines


        return __adis_update_bits(&st->adis, ADIS16550_REG_CONFIG, -                                 ADIS16550_GYRO_FIR_EN_MASK,
-                                 FIELD_PREP(ADIS16550_GYRO_FIR_EN_MASK, en)); +                                 ADIS16550_GYRO_FIR_EN_MASK, val); }

LGTM

Quoted 91 lines

 enum {

drivers/iio/imu/adis16550.c +0 -0
@@ -832,7 +832,6 @@ static u32 adis16550_validate_crc(__be32 *buffer, const u8
 n_elem)


 static irqreturn_t adis16550_trigger_handler(int irq, void *p) {
-       u32 crc;
        int ret;
        u16 dummy;
        bool valid;

drivers/iio/imu/adis16550.c +1 -1
@@ -1143,7 +1142,7 @@ module_spi_driver(adis16550_driver);
  MODULE_AUTHOR("Nuno Sa <[email protected]>");
  MODULE_AUTHOR("Ramona Gradinariu <[email protected]>");
  MODULE_AUTHOR("Antoniu Miclaus <[email protected]>");
-MODULE_AUTHOR("Robert Budai <[email protected]>")
+MODULE_AUTHOR("Robert Budai <[email protected]>");
  MODULE_DESCRIPTION("Analog Devices ADIS16550 IMU driver");

 MODULE_IMPORT_NS("IIO_

Quoted 72 lines
Quoted 71 lines

Anyways, all looks good except for one thing that I just spotted...

Quoted 9 lines

v8:
- removed __aligned from struct adis16550, as suggested
- crc buffer extraction into the crc check function
- passed buffer into crc validation as original, __be32 and performed check
using be32_to_cpu conversion of the buffer
- added trailing comma to line 993
- removed trailing comma from line 877

Quoted 3 lines

 drivers/iio/imu/Kconfig     |   13 +
 drivers/iio/imu/Makefile    |    1 +
 drivers/iio/imu/adis16550.c | 1149

+++++++++++++++++++++++++++++++++++

Quoted 3 lines
 3 files changed, 1163 insertions(+)

 create mode 100644 drivers/iio/imu/adis16550.c

...

Quoted 34 lines
(quoted diff) +19 -0
+static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
+{
+	u16 dec;
+	int ret;
+	u32 sample_rate = st->clk_freq_hz;
+	/*
+	 * The optimal sample rate for the supported IMUs is between
+	 * int_clk - 1000 and int_clk + 500.
+	 */
+	u32 max_sample_rate = st->info->int_clk * 1000 + 500000;
+	u32 min_sample_rate = st->info->int_clk * 1000 - 1000000;
+
+	if (!freq_hz)
+		return -EINVAL;
+
+	adis_dev_auto_lock(&st->adis);
+
+	if (st->sync_mode == ADIS16550_SYNC_MODE_SCALED) {
+		unsigned long scaled_rate = lcm(st->clk_freq_hz,

freq_hz);

(quoted diff) +4 -0
+		int sync_scale;
+
+		if (scaled_rate > max_sample_rate)
+			scaled_rate = max_sample_rate / st->clk_freq_hz

* st-

Quoted 1 line

clk_freq_hz;

(quoted diff) +2 -0
+		else
+			scaled_rate = max_sample_rate / scaled_rate *

scaled_rate;

(quoted diff) +3 -0
+
+		if (scaled_rate < min_sample_rate)
+			scaled_rate = roundup(min_sample_rate, st-  
Quoted 1 line

clk_freq_hz);

Quoted 1 line

+

I would imagine the above is the same deal as in other devices [1] or do you
know for a fact this one is different? Maybe it's simple enough for Jonathan to
tweak while applying...

[1]:
https://urldefense.com/v3/__https://elixir.bootlin.com/linux/v6.13.3/source
/drivers/iio/imu/adis16475.c*L364__;Iw!!A3Ni8CS0y2Y!7Y71yPaQAxVzNRd O_jT7wEz4k- s6z4tJHOcES84HYkq8qNGsgJH7zxwjfPNjLF3OEGVInSolo1ennLU_mwpmEbo$

- Nuno Sá

Quoted 8 lines
Quoted 4 lines

[Robert Budai]
No differences were found in the scaled_sync behavior of the ADIS16475 and ADIS16550. It is safe to add from my side.

If we want to do such a module parameter override I am fine with adding it but as a separate patch on top that provides the reasoning etc. It is a little to messy for me to do as a tweak.

That's fair

- Nuno Sá

author maintainer
#11 lore raw

PATCH RESEND v8 6/6 docs: iio: add documentation for adis16550 driver

In reply to Robert Budai

Add documentation for adis16550 driver which describes the driver device files and shows how the user may use the ABI for various scenarios (configuration, measurement, etc.).

---

v8:
- corrected subsection numbering

 Documentation/iio/adis16550.rst | 376 ++++++++++++++++++++++++++++++++
 Documentation/iio/index.rst     |   1 +
 2 files changed, 377 insertions(+)
 create mode 100644 Documentation/iio/adis16550.rst
Documentation/iio/adis16550.rst new file +376 -0
new file mode 100644
index 000000000..25db7b806
@@ -0,0 +1,376 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+================
+ADIS16550 driver
+================
+
+This driver supports Analog Device's IMUs on SPI bus.
+
+1. Supported devices
+====================
+
+* `ADIS16550 <https://www.analog.com/ADIS16550>`_
+
+The ADIS16550 is a complete inertial system that includes a triaxis gyroscope
+and a triaxis accelerometer. The factory calibration characterizes each sensor for
+sensitivity, bias, and alignment. As a result, each sensor has its own dynamic
+compensation formulas that provide accurate sensor measurements.
+
+2. Device attributes
+====================
+
+Accelerometer, gyroscope measurements are always provided. Furthermore, the
+driver offers the capability to retrieve the delta angle and the delta velocity
+measurements computed by the device.
+
+The delta angle measurements represent a calculation of angular displacement
+between each sample update, while the delta velocity measurements represent a
+calculation of linear velocity change between each sample update.
+
+Finally, temperature data are provided which show a coarse measurement of
+the temperature inside of the IMU device. This data is most useful for
+monitoring relative changes in the thermal environment.
+
+Each IIO device, has a device folder under ``/sys/bus/iio/devices/iio:deviceX``,
+where X is the IIO index of the device. Under these folders reside a set of
+device files, depending on the characteristics and features of the hardware
+device in questions. These files are consistently generalized and documented in
+the IIO ABI documentation.
+
+The following tables show the adis16550 related device files, found in the
+specific device folder path ``/sys/bus/iio/devices/iio:deviceX``.
+
++-------------------------------------------+----------------------------------------------------------+
+| 3-Axis Accelerometer related device files | Description                                              |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_scale                            | Scale for the accelerometer channels.                    |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_filter_low_pass_3db_frequency    | Bandwidth for the accelerometer channels.                |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_x_calibbias                      | Calibration offset for the X-axis accelerometer channel. |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_x_calibscale                     | Calibration scale for the X-axis accelerometer channel.  |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_x_raw                            | Raw X-axis accelerometer channel value.                  |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_y_calibbias                      | Calibration offset for the Y-axis accelerometer channel. |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_y_calibscale                     | Calibration scale for the Y-axis accelerometer channel.  |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_y_raw                            | Raw Y-axis accelerometer channel value.                  |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_z_calibbias                      | Calibration offset for the Z-axis accelerometer channel. |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_z_calibscale                     | Calibration scale for the Z-axis accelerometer channel.  |
++-------------------------------------------+----------------------------------------------------------+
+| in_accel_z_raw                            | Raw Z-axis accelerometer channel value.                  |
++-------------------------------------------+----------------------------------------------------------+
+| in_deltavelocity_scale                    | Scale for delta velocity channels.                       |
++-------------------------------------------+----------------------------------------------------------+
+| in_deltavelocity_x_raw                    | Raw X-axis delta velocity channel value.                 |
++-------------------------------------------+----------------------------------------------------------+
+| in_deltavelocity_y_raw                    | Raw Y-axis delta velocity channel value.                 |
++-------------------------------------------+----------------------------------------------------------+
+| in_deltavelocity_z_raw                    | Raw Z-axis delta velocity channel value.                 |
++-------------------------------------------+----------------------------------------------------------+
+
++--------------------------------------------+------------------------------------------------------+
+| 3-Axis Gyroscope related device files      | Description                                          |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_scale                           | Scale for the gyroscope channels.                    |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_filter_low_pass_3db_frequency   | Scale for the gyroscope channels.                    |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_x_calibbias                     | Calibration offset for the X-axis gyroscope channel. |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_x_calibscale                    | Calibration scale for the X-axis gyroscope channel.  |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_x_raw                           | Raw X-axis gyroscope channel value.                  |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_y_calibbias                     | Calibration offset for the Y-axis gyroscope channel. |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_y_calibscale                    | Calibration scale for the Y-axis gyroscope channel.  |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_y_raw                           | Raw Y-axis gyroscope channel value.                  |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_z_calibbias                     | Calibration offset for the Z-axis gyroscope channel. |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_z_calibscale                    | Calibration scale for the Z-axis gyroscope channel.  |
++--------------------------------------------+------------------------------------------------------+
+| in_anglvel_z_raw                           | Raw Z-axis gyroscope channel value.                  |
++--------------------------------------------+------------------------------------------------------+
+| in_deltaangl_scale                         | Scale for delta angle channels.                      |
++--------------------------------------------+------------------------------------------------------+
+| in_deltaangl_x_raw                         | Raw X-axis delta angle channel value.                |
++--------------------------------------------+------------------------------------------------------+
+| in_deltaangl_y_raw                         | Raw Y-axis delta angle channel value.                |
++--------------------------------------------+------------------------------------------------------+
+| in_deltaangl_z_raw                         | Raw Z-axis delta angle channel value.                |
++--------------------------------------------+------------------------------------------------------+
+
++----------------------------------+-------------------------------------------+
+| Temperature sensor related files | Description                               |
++----------------------------------+-------------------------------------------+
+| in_temp0_raw                     | Raw temperature channel value.            |
++----------------------------------+-------------------------------------------+
+| in_temp0_offset                  | Offset for the temperature sensor channel.|
++----------------------------------+-------------------------------------------+
+| in_temp0_scale                   | Scale for the temperature sensor channel. |
++----------------------------------+-------------------------------------------+
+
++----------------------------+--------------------------------------------------------------------------------+
+| Miscellaneous device files | Description                                                                    |
++----------------------------+--------------------------------------------------------------------------------+
+| name                       | Name of the IIO device.                                                        |
++----------------------------+--------------------------------------------------------------------------------+
+| sampling_frequency         | Currently selected sample rate.                                                |
++----------------------------+--------------------------------------------------------------------------------+
+
+The following table shows the adis16550 related device debug files, found in the
+specific device debug folder path ``/sys/kernel/debug/iio/iio:deviceX``.
+
++----------------------+-------------------------------------------------------------------------+
+| Debugfs device files | Description                                                             |
++----------------------+-------------------------------------------------------------------------+
+| serial_number        | The serial number of the chip in hexadecimal format.                    |
++----------------------+-------------------------------------------------------------------------+
+| product_id           | Chip specific product id (16550).                                       |
++----------------------+-------------------------------------------------------------------------+
+| flash_count          | The number of flash writes performed on the device.                     |
++----------------------+-------------------------------------------------------------------------+
+| firmware_revision    | String containing the firmware revision in the following format ##.##.  |
++----------------------+-------------------------------------------------------------------------+
+| firmware_date        | String containing the firmware date in the following format mm-dd-yyyy. |
++----------------------+-------------------------------------------------------------------------+
+
+Channels processed values
+-------------------------
+
+A channel value can be read from its _raw attribute. The value returned is the
+raw value as reported by the devices. To get the processed value of the channel,
+apply the following formula:
+
+.. code-block:: bash
+
+        processed value = (_raw + _offset) * _scale
+
+Where _offset and _scale are device attributes. If no _offset attribute is
+present, simply assume its value is 0.
+
+The adis16550 driver offers data for 5 types of channels, the table below shows
+the measurement units for the processed value, which are defined by the IIO
+framework:
+
++--------------------------------------+---------------------------+
+| Channel type                         | Measurement unit          |
++--------------------------------------+---------------------------+
+| Acceleration on X, Y, and Z axis     | Meters per Second squared |
++--------------------------------------+---------------------------+
+| Angular velocity on X, Y and Z axis  | Radians per second        |
++--------------------------------------+---------------------------+
+| Delta velocity on X. Y, and Z axis   | Meters per Second         |
++--------------------------------------+---------------------------+
+| Delta angle on X, Y, and Z axis      | Radians                   |
++--------------------------------------+---------------------------+
+| Temperature                          | Millidegrees Celsius      |
++--------------------------------------+---------------------------+
+
+Usage examples
+--------------
+
+Show device name:
+
+.. code-block:: bash
+
+	root:/sys/bus/iio/devices/iio:device0> cat name
+        adis16550
+
+Show accelerometer channels value:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_raw
+        6903851
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_y_raw
+        5650550
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_z_raw
+        104873530
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_scale
+        0.000000095
+
+- X-axis acceleration = in_accel_x_raw * in_accel_scale = 0.655865845 m/s^2
+- Y-axis acceleration = in_accel_y_raw * in_accel_scale = 0.53680225 m/s^2
+- Z-axis acceleration = in_accel_z_raw * in_accel_scale = 9.96298535 m/s^2
+
+Show gyroscope channels value:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> cat in_anglvel_x_raw
+        193309
+        root:/sys/bus/iio/devices/iio:device0> cat in_anglvel_y_raw
+        -763676
+        root:/sys/bus/iio/devices/iio:device0> cat in_anglvel_z_raw
+        -358108
+        root:/sys/bus/iio/devices/iio:device0> cat in_anglvel_scale
+        0.000000003
+
+- X-axis angular velocity = in_anglvel_x_raw * in_anglvel_scale = 0.000579927 rad/s
+- Y-axis angular velocity = in_anglvel_y_raw * in_anglvel_scale = −0.002291028 rad/s
+- Z-axis angular velocity = in_anglvel_z_raw * in_anglvel_scale = −0.001074324 rad/s
+
+Set calibration offset for accelerometer channels:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
+        0
+
+        root:/sys/bus/iio/devices/iio:device0> echo 5000 > in_accel_x_calibbias
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
+        5000
+
+Set calibration offset for gyroscope channels:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> cat in_anglvel_y_calibbias
+        0
+
+        root:/sys/bus/iio/devices/iio:device0> echo -5000 > in_anglvel_y_calibbias
+        root:/sys/bus/iio/devices/iio:device0> cat in_anglvel_y_calibbias
+        -5000
+
+Set sampling frequency:
+
+.. code-block:: bash
+
+	root:/sys/bus/iio/devices/iio:device0> cat sampling_frequency
+        4000.000000
+
+        root:/sys/bus/iio/devices/iio:device0> echo 1000 > sampling_frequency
+        1000.000000
+
+Set bandwidth for accelerometer channels:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_filter_low_pass_3db_frequency
+        0
+
+        root:/sys/bus/iio/devices/iio:device0> echo 100 > in_accel_filter_low_pass_3db_frequency
+        root:/sys/bus/iio/devices/iio:device0> cat in_accel_filter_low_pass_3db_frequency
+        100
+
+Show serial number:
+
+.. code-block:: bash
+
+        root:/sys/kernel/debug/iio/iio:device0> cat serial_number
+        0x000000b6
+
+Show product id:
+
+.. code-block:: bash
+
+        root:/sys/kernel/debug/iio/iio:device0> cat product_id
+        16550
+
+Show flash count:
+
+.. code-block:: bash
+
+        root:/sys/kernel/debug/iio/iio:device0> cat flash_count
+        13
+
+Show firmware revision:
+
+.. code-block:: bash
+
+        root:/sys/kernel/debug/iio/iio:device0> cat firmware_revision
+        1.5
+
+Show firmware date:
+
+.. code-block:: bash
+
+        root:/sys/kernel/debug/iio/iio:device0> cat firmware_date
+        28-04-2021
+
+3. Device buffers
+=================
+
+This driver supports IIO buffers.
+
+The device supports retrieving the raw acceleration, gyroscope, delta velocity,
+delta angle and temperature measurements using buffers.
+
+However, when retrieving acceleration or gyroscope data using buffers, delta
+readings will not be available and vice versa. This is because the device only
+allows to read either acceleration and gyroscope data or delta velocity and
+delta angle data at a time and switching between these two burst data selection
+modes is time consuming.
+
+Usage examples
+--------------
+
+Set device trigger in current_trigger, if not already set:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> cat trigger/current_trigger
+
+        root:/sys/bus/iio/devices/iio:device0> echo adis16550-dev0 > trigger/current_trigger
+        root:/sys/bus/iio/devices/iio:device0> cat trigger/current_trigger
+        adis16550-dev0
+
+Select channels for buffer read:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_deltavelocity_x_en
+        root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_deltavelocity_y_en
+        root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_deltavelocity_z_en
+        root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_temp0_en
+
+Set the number of samples to be stored in the buffer:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> echo 10 > buffer/length
+
+Enable buffer readings:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> echo 1 > buffer/enable
+
+Obtain buffered data:
+
+.. code-block:: bash
+
+        root:/sys/bus/iio/devices/iio:device0> hexdump -C /dev/iio\:device0
+        ...
+        0000cdf0  00 00 0d 2f 00 00 08 43  00 00 09 09 00 00 a4 5f  |.../...C......._|
+        0000ce00  00 00 0d 2f 00 00 07 de  00 00 08 db 00 00 a4 4b  |.../...........K|
+        0000ce10  00 00 0d 2f 00 00 07 58  00 00 08 a3 00 00 a4 55  |.../...X.......U|
+        0000ce20  00 00 0d 2f 00 00 06 d6  00 00 08 5c 00 00 a4 62  |.../.......\...b|
+        0000ce30  00 00 0d 2f 00 00 06 45  00 00 08 37 00 00 a4 47  |.../...E...7...G|
+        0000ce40  00 00 0d 2f 00 00 05 d4  00 00 08 30 00 00 a3 fa  |.../.......0....|
+        0000ce50  00 00 0d 2f 00 00 05 d0  00 00 08 12 00 00 a3 d3  |.../............|
+        0000ce60  00 00 0d 2f 00 00 05 dd  00 00 08 2e 00 00 a3 e9  |.../............|
+        0000ce70  00 00 0d 2f 00 00 05 cc  00 00 08 51 00 00 a3 d5  |.../.......Q....|
+        0000ce80  00 00 0d 2f 00 00 05 ba  00 00 08 22 00 00 a3 9a  |.../......."....|
+        0000ce90  00 00 0d 2f 00 00 05 9c  00 00 07 d9 00 00 a3 40  |.../...........@|
+        0000cea0  00 00 0d 2f 00 00 05 68  00 00 07 94 00 00 a2 e4  |.../...h........|
+        0000ceb0  00 00 0d 2f 00 00 05 25  00 00 07 8d 00 00 a2 ce  |.../...%........|
+        ...
+
+See ``Documentation/iio/iio_devbuf.rst`` for more information about how buffered
+data is structured.
+
+4. IIO Interfacing Tools
+========================
+
+See ``Documentation/iio/iio_tools.rst`` for the description of the available IIO
+interfacing tools.
Documentation/iio/index.rst +1 -0
index 5710f5b9e..039ed2d75 100644
@@ -26,6 +26,7 @@ Industrial I/O Kernel Drivers
    ad7944
    adis16475
    adis16480
+   adis16550
    adxl380
    bno055
    ep93xx_adc
Signature · 1 line
2.34.1
maintainer
#12 lore raw
In reply to Robert Budai
Quoted 7 lines · On Mon, 17 Feb 2025 12:57:44 +0200 Robert Budai <[email protected]> wrote:

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

Hi Robert,

The cover letter of any RESEND should always start with why you are doing so. If this was for the tiny fixup you mentioned it should have been v9 and not have been sent for a few days at least. If everything else is fine I don't mind making that sort of fixup whilst applying anyway!

Jonathan

Quoted 22 lines

Robert Budai (6):
iio: imu: adis: Add custom ops struct
iio: imu: adis: Add reset to custom ops
iio: imu: adis: Add DIAG_STAT register
dt-bindings: iio: Add adis16550 bindings
iio: imu: adis16550: add adis16550 support
docs: iio: add documentation for adis16550 driver

 .../bindings/iio/imu/adi,adis16550.yaml       |   74 ++
 Documentation/iio/adis16550.rst               |  376 ++++++
 Documentation/iio/index.rst                   |    1 +
 MAINTAINERS                                   |   10 +
 drivers/iio/imu/Kconfig                       |   13 +
 drivers/iio/imu/Makefile                      |    1 +
 drivers/iio/imu/adis.c                        |   35 +-
 drivers/iio/imu/adis16550.c                   | 1149 +++++++++++++++++
 include/linux/iio/imu/adis.h                  |   34 +-
 9 files changed, 1680 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
 create mode 100644 Documentation/iio/adis16550.rst
 create mode 100644 drivers/iio/imu/adis16550.c
maintainer
#13 lore raw
Quoted 10 lines · On Mon, 17 Feb 2025 14:33:54 +0000 Jonathan Cameron <[email protected]> wrote:
Quoted 7 lines · On Mon, 17 Feb 2025 12:57:44 +0200 Robert Budai <[email protected]> wrote:

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

Quoted 6 lines

Hi Robert,

The cover letter of any RESEND should always start with why you are doing so. If this was for the tiny fixup you mentioned it should have been v9 and not have been sent for a few days at least. If everything else is fine I don't mind making that sort of fixup whilst applying anyway!

With the tweaks to patch 5 and co-developed tags added as mentioned in reply to that commit applied to the togreg branch of iio.git which is initially pushed out as testing.

Jonathan

Quoted 28 lines

Jonathan

Quoted 22 lines

Robert Budai (6):
iio: imu: adis: Add custom ops struct
iio: imu: adis: Add reset to custom ops
iio: imu: adis: Add DIAG_STAT register
dt-bindings: iio: Add adis16550 bindings
iio: imu: adis16550: add adis16550 support
docs: iio: add documentation for adis16550 driver

 .../bindings/iio/imu/adi,adis16550.yaml       |   74 ++
 Documentation/iio/adis16550.rst               |  376 ++++++
 Documentation/iio/index.rst                   |    1 +
 MAINTAINERS                                   |   10 +
 drivers/iio/imu/Kconfig                       |   13 +
 drivers/iio/imu/Makefile                      |    1 +
 drivers/iio/imu/adis.c                        |   35 +-
 drivers/iio/imu/adis16550.c                   | 1149 +++++++++++++++++
 include/linux/iio/imu/adis.h                  |   34 +-
 9 files changed, 1680 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
 create mode 100644 Documentation/iio/adis16550.rst
 create mode 100644 drivers/iio/imu/adis16550.c
maintainer
#14 lore raw
Quoted 15 lines · On Sat, 22 Feb 2025 12:40:30 +0000 Jonathan Cameron <[email protected]> wrote:
Quoted 12 lines · On Mon, 17 Feb 2025 14:33:54 +0000 Jonathan Cameron <[email protected]> wrote:
Quoted 7 lines · On Mon, 17 Feb 2025 12:57:44 +0200 Robert Budai <[email protected]> wrote:

The ADIS16550 is a complete inertial system that includes a triaxis gyroscope and a triaxis accelerometer. Each inertial sensor in the ADIS16550 combines industry leading MEMS only technology with signal conditioning that optimizes dynamic performance. The factory calibration characterizes each sensor for sensitivity, bias, and alignment. As a result, each sensor has its own dynamic compensation formulas that provide accurate sensor measurements.

Hi Robert,

Quoted 9 lines
Quoted 4 lines

The cover letter of any RESEND should always start with why you are doing so. If this was for the tiny fixup you mentioned it should have been v9 and not have been sent for a few days at least. If everything else is fine I don't mind making that sort of fixup whilst applying anyway!

With the tweaks to patch 5 and co-developed tags added as mentioned in reply to that commit applied to the togreg branch of iio.git which is initially pushed out as testing.

Another tweak:
0-day/ coccinelle reported:

55be950cfc6031 Robert Budai 2025-02-17  1024  	.self_test_mask = BIT(1),
55be950cfc6031 Robert Budai 2025-02-17  1025  	.self_test_reg = ADIS16550_REG_COMMAND,
55be950cfc6031 Robert Budai 2025-02-17  1026  	.cs_change_delay = 5,
55be950cfc6031 Robert Budai 2025-02-17  1027  	.unmasked_drdy = true,
55be950cfc6031 Robert Budai 2025-02-17  1028  	.status_error_msgs = adis16550_status_error_msgs,
55be950cfc6031 Robert Budai 2025-02-17 @1029  	.status_error_mask = BIT(ADIS16550_STATUS_CRC_CODE) |
55be950cfc6031 Robert Budai 2025-02-17  1030  			BIT(ADIS16550_STATUS_CRC_CONFIG) |
55be950cfc6031 Robert Budai 2025-02-17  1031  			BIT(ADIS16550_STATUS_FLASH_UPDATE) |
55be950cfc6031 Robert Budai 2025-02-17  1032  			BIT(ADIS16550_STATUS_INERIAL) |
55be950cfc6031 Robert Budai 2025-02-17  1033  			BIT(ADIS16550_STATUS_SENSOR) |
55be950cfc6031 Robert Budai 2025-02-17  1034  			BIT(ADIS16550_STATUS_TEMPERATURE) |
55be950cfc6031 Robert Budai 2025-02-17  1035  			BIT(ADIS16550_STATUS_SPI) |
55be950cfc6031 Robert Budai 2025-02-17  1036  			BIT(ADIS16550_STATUS_PROCESSING) |
55be950cfc6031 Robert Budai 2025-02-17  1037  			BIT(ADIS16550_STATUS_POWER) |
55be950cfc6031 Robert Budai 2025-02-17  1038  			BIT(ADIS16550_STATUS_BOOT) |
55be950cfc6031 Robert Budai 2025-02-17  1039  			BIT(ADIS16550_STATUS_WATCHDOG) |
55be950cfc6031 Robert Budai 2025-02-17  1040  			BIT(ADIS16550_STATUS_REGULATOR) |
55be950cfc6031 Robert Budai 2025-02-17  1041  			BIT(ADIS16550_STATUS_SENSOR_SUPPLY) |
55be950cfc6031 Robert Budai 2025-02-17  1042  			BIT(ADIS16550_STATUS_CPU_SUPPLY) |
55be950cfc6031 Robert Budai 2025-02-17  1043  			BIT(ADIS16550_STATUS_5V_SUPPLY) |
55be950cfc6031 Robert Budai 2025-02-17  1044  			BIT(ADIS16550_STATUS_CRC_CODE),

this is duplicate. I dropped this one.

55be950cfc6031 Robert Budai 2025-02-17  1045  	.timeouts = &adis16550_timeouts,
55be950cfc6031 Robert Budai 2025-02-17  1046  };
55be950cfc6031 Robert Budai 2025-02-17  1047
Quoted 32 lines

Jonathan

Quoted 28 lines

Jonathan

Quoted 22 lines

Robert Budai (6):
iio: imu: adis: Add custom ops struct
iio: imu: adis: Add reset to custom ops
iio: imu: adis: Add DIAG_STAT register
dt-bindings: iio: Add adis16550 bindings
iio: imu: adis16550: add adis16550 support
docs: iio: add documentation for adis16550 driver

 .../bindings/iio/imu/adi,adis16550.yaml       |   74 ++
 Documentation/iio/adis16550.rst               |  376 ++++++
 Documentation/iio/index.rst                   |    1 +
 MAINTAINERS                                   |   10 +
 drivers/iio/imu/Kconfig                       |   13 +
 drivers/iio/imu/Makefile                      |    1 +
 drivers/iio/imu/adis.c                        |   35 +-
 drivers/iio/imu/adis16550.c                   | 1149 +++++++++++++++++
 include/linux/iio/imu/adis.h                  |   34 +-
 9 files changed, 1680 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
 create mode 100644 Documentation/iio/adis16550.rst
 create mode 100644 drivers/iio/imu/adis16550.c