Skip to contentSkip to conversation

Add support for ADIS16550 and ADIS16550W

PATCH Superseded Robert Budai 5 participants 21 messages Jan 10, 2025 – Jan 15, 2025

Subsystems (6)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Robert Budai

author maintainer
#0 lore raw

v4 cover Add support for ADIS16550 and ADIS16550W

Add support for ADIS16550 and ADIS16550W

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 size
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       |   96 ++
 Documentation/iio/adis16550.rst               |  378 ++++++
 Documentation/iio/index.rst                   |    1 +
 MAINTAINERS                                   |    9 +
 drivers/iio/imu/Kconfig                       |   13 +
 drivers/iio/imu/Makefile                      |    1 +
 drivers/iio/imu/adis.c                        |   30 +-
 drivers/iio/imu/adis16550.c                   | 1202 +++++++++++++++++
 include/linux/iio/imu/adis.h                  |   33 +-
 9 files changed, 1749 insertions(+), 14 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 v4 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.

---
 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 494171844812..54915c7a3e76 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 4bb98d9731de..89cfa75ae9ea 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 v4 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.

---
 drivers/iio/imu/adis.c       | 7 ++++---
 include/linux/iio/imu/adis.h | 3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/iio/imu/adis.c +4 -3
index 54915c7a3e76..9e4113473dc4 100644
@@ -340,7 +340,7 @@ int __adis_reset(struct adis *adis)
 	const struct adis_timeout *timeouts = adis->data->timeouts;
 
 	ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg,
-				 ADIS_GLOB_CMD_SW_RESET);
+					 ADIS_GLOB_CMD_SW_RESET);
 	if (ret) {
 		dev_err(&adis->spi->dev, "Failed to reset device: %d\n", ret);
 		return ret;
@@ -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 89cfa75ae9ea..52652f51db2e 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
maintainer
#3 lore raw

Re: [PATCH v4 2/6] iio: imu: adis: Add reset to custom ops

Quoted 20 lines · On Fri, 10 Jan 2025 09:42:50 +0200 Robert Budai <[email protected]> wrote:

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.

---
 drivers/iio/imu/adis.c       | 7 ++++---
 include/linux/iio/imu/adis.h | 3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/iio/imu/adis.c +0 -0
index 54915c7a3e76..9e4113473dc4 100644

drivers/iio/imu/adis.c int __adis_reset(struct adis *adis) · line 343

Quoted 5 lines
drivers/iio/imu/adis.c +1 -1
@@ -340,7 +340,7 @@ int __adis_reset(struct adis *adis)
 	const struct adis_timeout *timeouts = adis->data->timeouts;
 
 	ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg,
-				 ADIS_GLOB_CMD_SW_RESET);
+					 ADIS_GLOB_CMD_SW_RESET);

Accidental change I guess, but bad anyway. Original looks better aligned.

Quoted 43 lines
drivers/iio/imu/adis.c +3 -2
 	if (ret) {
 		dev_err(&adis->spi->dev, "Failed to reset device: %d\n", ret);
 		return ret;
@@ -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 89cfa75ae9ea..52652f51db2e 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);
 };
 
 /**
author maintainer
#4 lore raw

PATCH v4 3/6 iio: imu: adis: Add DIAG_STAT register size

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.

---
 drivers/iio/imu/adis.c       | 11 ++++++++---
 include/linux/iio/imu/adis.h |  2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/iio/imu/adis.c +8 -3
index 9e4113473dc4..a072307bfb6a 100644
@@ -304,11 +304,15 @@ EXPORT_SYMBOL_NS(__adis_enable_irq, "IIO_ADISLIB");
  */
 int __adis_check_status(struct adis *adis)
 {
-	u16 status;
+	unsigned int status;
 	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, (u16 *)&status);
 	if (ret)
 		return ret;
 
@@ -317,7 +321,8 @@ int __adis_check_status(struct adis *adis)
 	if (status == 0)
 		return 0;
 
-	for (i = 0; i < 16; ++i) {
+	for (i = 0; i < BITS_PER_BYTE * ((adis->data->diag_stat_size) ?
+					 adis->data->diag_stat_size : 2); ++i) {
 		if (status & BIT(i)) {
 			dev_err(&adis->spi->dev, "%s.\n",
 				adis->data->status_error_msgs[i]);
include/linux/iio/imu/adis.h +2 -0
index 52652f51db2e..b888b22f5c8c 100644
@@ -44,6 +44,7 @@ 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.
  * @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 +71,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
maintainer
#5 lore raw

Re: [PATCH v4 3/6] iio: imu: adis: Add DIAG_STAT register size

Quoted 38 lines · On Fri, 10 Jan 2025 09:42:51 +0200 Robert Budai <[email protected]> wrote:

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.

---
 drivers/iio/imu/adis.c       | 11 ++++++++---
 include/linux/iio/imu/adis.h |  2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/iio/imu/adis.c +6 -2
index 9e4113473dc4..a072307bfb6a 100644
@@ -304,11 +304,15 @@ EXPORT_SYMBOL_NS(__adis_enable_irq, "IIO_ADISLIB");
  */
 int __adis_check_status(struct adis *adis)
 {
-	u16 status;
+	unsigned int status;
 	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, (u16 *)&status);
 	if (ret)
 		return ret;
 

drivers/iio/imu/adis.c int __adis_check_status(struct adis *adis) · line 325

Quoted 6 lines
drivers/iio/imu/adis.c +2 -1
@@ -317,7 +321,8 @@ int __adis_check_status(struct adis *adis)
 	if (status == 0)
 		return 0;
 
-	for (i = 0; i < 16; ++i) {
+	for (i = 0; i < BITS_PER_BYTE * ((adis->data->diag_stat_size) ?
+					 adis->data->diag_stat_size : 2); ++i) {

This is getting hard to read. I think a local variable is appropriate.

include/linux/iio/imu/adis.h struct adis_timeout { · line 47

Quoted 12 lines
drivers/iio/imu/adis.c +0 -0
 		if (status & BIT(i)) {
 			dev_err(&adis->spi->dev, "%s.\n",
 				adis->data->status_error_msgs[i]);
include/linux/iio/imu/adis.h +1 -0
index 52652f51db2e..b888b22f5c8c 100644
@@ -44,6 +44,7 @@ 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.

Add something about 0 being treated as meaning 2. Or add this to all instances of this structure so we don't need that 0 case. Whilst there are quite a lot instances, they are mostly filled by a couple of macros so it shouldn't be too bad to update them all.

Quoted 11 lines
include/linux/iio/imu/adis.h +1 -0
  * @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 +71,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;
author maintainer
#6 lore raw

PATCH v4 4/6 dt-bindings: iio: Add adis16550 bindings

In reply to Robert Budai

Document the ADIS16550 device devicetree bindings.

---

4:
- applied styling changes to the bindings file
- restricted sync-mode to intervals 1-2

 .../bindings/iio/imu/adi,adis16550.yaml       | 96 +++++++++++++++++++
 MAINTAINERS                                   |  9 ++
 2 files changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +96 -0
new file mode 100644
index 000000000000..e7ccf3883e55
@@ -0,0 +1,96 @@
+# 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]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+      - adi,adis16550w
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+
+  spi-cpol: true
+
+  spi-max-frequency:
+    maximum: 15000000
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      RESET active low pin.
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+    description: If not provided, then the internal clock is used.
+
+  adi,sync-mode:
+    description:
+      Configures the device SYNC pin. The following modes are supported
+      0 - output_sync
+      1 - direct_sync
+      2 - scaled_sync
+      3 - pulse_sync
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 2
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - spi-cpha
+  - spi-cpol
+  - spi-max-frequency
+  - vdd-supply
+
+allOf:
+  - if:
+      properties:
+        adi,sync-mode:
+          const: 2
+
+    then:
+      dependencies:
+        adi,sync-mode: [ clocks ]
+
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+unevaluatedProperties: 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 +9 -0
index 30cbc3d44cd5..89ef9571e025 100644
@@ -1453,6 +1453,15 @@ 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]>
+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
#7 lore raw

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

Quoted 62 lines · On Fri, 10 Jan 2025 09:42:52 +0200 Robert Budai <[email protected]> wrote:

Document the ADIS16550 device devicetree bindings.

---

4:
- applied styling changes to the bindings file
- restricted sync-mode to intervals 1-2

 .../bindings/iio/imu/adi,adis16550.yaml       | 96 +++++++++++++++++++
 MAINTAINERS                                   |  9 ++
 2 files changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +39 -0
new file mode 100644
index 000000000000..e7ccf3883e55
@@ -0,0 +1,96 @@
+# 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]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+      - adi,adis16550w
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+
+  spi-cpol: true
+
+  spi-max-frequency:
+    maximum: 15000000
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      RESET active low pin.
+    maxItems: 1
+

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10 -0
+  clocks:
+    maxItems: 1
+    description: If not provided, then the internal clock is used.
+
+  adi,sync-mode:
+    description:
+      Configures the device SYNC pin. The following modes are supported
+      0 - output_sync
+      1 - direct_sync
+      2 - scaled_sync

A little more on these would be good. They are 'weird' options that are not commonly seen so help the reader out.

For scaled_sync don't we need information on the scale for it to be useful? If we had that then a value of 1 would mean direct sync and wouldn't need another control.

I'm not fully understanding the usecases for this.

If we have a say a pulse per second input, the control of the scale should be userspace anyway. So maybe this maps to the input clock that we can elect to use and control the effective frequency of by using scaled sync?

I'm not sure what pulse sync is. Grepping the datasheet didn't give me
anything that seemed related. The sync pin is input only so I'm also
not sure on output sync.

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 53

Quoted 4 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +4 -0
+      3 - pulse_sync
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 2

You describe 0 to 3 but only allow 1 or 2?

Quoted 43 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +43 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - spi-cpha
+  - spi-cpol
+  - spi-max-frequency
+  - vdd-supply
+
+allOf:
+  - if:
+      properties:
+        adi,sync-mode:
+          const: 2
+
+    then:
+      dependencies:
+        adi,sync-mode: [ clocks ]
+
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+unevaluatedProperties: 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>;
+        };
+    };
+...
#8 lore raw

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

Quoted 85 lines · Jonathan Cameron
Quoted 64 lines · On Fri, 10 Jan 2025 09:42:52 +0200 Robert Budai <[email protected]> wrote:

Document the ADIS16550 device devicetree bindings.

---

4:
- applied styling changes to the bindings file
- restricted sync-mode to intervals 1-2

 .../bindings/iio/imu/adi,adis16550.yaml       | 96 +++++++++++++++++++ MAINTAINERS                                   |  9 ++

 2 files changed, 105 insertions(+)

 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +39 -0
new file mode 100644
index 000000000000..e7ccf3883e55
@@ -0,0 +1,96 @@
+# 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]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+      - adi,adis16550w
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+
+  spi-cpol: true
+
+  spi-max-frequency:
+    maximum: 15000000
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      RESET active low pin.
+    maxItems: 1
+

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10 -0
+  clocks:
+    maxItems: 1
+    description: If not provided, then the internal clock is used.
+
+  adi,sync-mode:
+    description:
+      Configures the device SYNC pin. The following modes are supported
+      0 - output_sync
+      1 - direct_sync
+      2 - scaled_sync

A little more on these would be good.  They are 'weird' options that are not commonly seen so help the reader out.

For scaled_sync don't we need information on the scale for it to be useful? If we had that then a value of 1 would mean direct sync and wouldn't need another control.

Quoted 6 lines

I'm not fully understanding the usecases for this.

If we have a say a pulse per second input, the control of the scale should be userspace anyway.  So maybe this maps to the input clock that we can elect to
use and control the effective frequency of by using scaled sync?

I guess you likely already saw it in the driver. The scale value is automatically set by the driver depending on the desired ODR (sampling frequency).

Quoted 4 lines

I'm not sure what pulse sync is. Grepping the datasheet didn't give me anything that seemed related.   The sync pin is input only so I'm also not sure on output sync.

I think this is a copy paste from the adis16475 bindings. For this device, it seems we only have:
* internal clock;
* external:
* direct mode
* scaled mode

But yeah, as you pointed out I think we do not need the binding. The presence of an optional input clock plus the frequency should be all we need in order to set the desired configuration. It should also be possible to add the allowed ranges to the external input clock in the bindings...

- Nuno Sá

author maintainer
#9 lore raw

RE: [PATCH v4 4/6] dt-bindings: iio: Add adis16550 bindings

Quoted 136 lines

-----Original Message-----
From: Nuno Sá <[email protected]>
Sent: Monday, January 13, 2025 11:30 AM
To: Jonathan Cameron <[email protected]>; Budai, Robert <[email protected]>
Cc: Sa, Nuno <[email protected]>; Gradinariu, Ramona <[email protected]>; Miclaus, Antoniu <[email protected]>; Lars-Peter Clausen <[email protected]>; Hennerich, Michael <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Jonathan Corbet <[email protected]>; Alex Lanzano <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH v4 4/6] dt-bindings: iio: Add adis16550 bindings

[External]

Quoted 15 lines · Jonathan Cameron
Quoted 12 lines · On Fri, 10 Jan 2025 09:42:52 +0200 Robert Budai <[email protected]> wrote:

Document the ADIS16550 device devicetree bindings.

---

4:
- applied styling changes to the bindings file
- restricted sync-mode to intervals 1-2

Quoted 7 lines
Quoted 7 lines

 .../bindings/iio/imu/adi,adis16550.yaml       | 96 +++++++++++++++++++ MAINTAINERS                                   |  9 ++

 2 files changed, 105 insertions(+)

 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml

diff --git

a/Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml

Quoted 10 lines

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 4

Quoted 10 lines

b/Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file mode 100644
index 000000000000..e7ccf3883e55

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +4 -0
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id:

https://urldefense.com/v3/__http://devicetree.org/schemas/iio/imu/adi,adis
16550.yaml*__;Iw!!A3Ni8CS0y2Y!74KHajr7iKZQ7Ld5deb4LytVFckO_Og8tIG Ukf233OLregM6AqtN-v-IBRfAn-4Z1tC0bwbcEpNO7Glv8YjiXWI$

Quoted 1 line

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 5

Quoted 1 line
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +1 -0
+$schema: https://urldefense.com/v3/__http://devicetree.org/meta-

schemas/core.yaml*__;Iw!!A3Ni8CS0y2Y!74KHajr7iKZQ7Ld5deb4LytVFckO_ Og8tIGUkf233OLregM6AqtN-v-IBRfAn-4Z1tC0bwbcEpNO7GlvNAV5ERI$

Quoted 48 lines
Quoted 34 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +34 -0
+
+title: Analog Devices ADIS16550 and similar IMUs
+
+maintainers:
+  - Nuno Sa <[email protected]>
+  - Ramona Gradinariu <[email protected]>
+  - Antoniu Miclaus <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+      - adi,adis16550w
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+
+  spi-cpol: true
+
+  spi-max-frequency:
+    maximum: 15000000
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      RESET active low pin.
+    maxItems: 1
+

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10 -0
+  clocks:
+    maxItems: 1
+    description: If not provided, then the internal clock is used.
+
+  adi,sync-mode:
+    description:
+      Configures the device SYNC pin. The following modes are supported
+      0 - output_sync
+      1 - direct_sync
+      2 - scaled_sync

A little more on these would be good.  They are 'weird' options that are not commonly seen so help the reader out.

Quoted 8 lines

For scaled_sync don't we need information on the scale for it to be useful? If we had that then a value of 1 would mean direct sync and wouldn't need another control.

I'm not fully understanding the usecases for this.

If we have a say a pulse per second input, the control of the scale should be userspace anyway.  So maybe this maps to the input clock that we can

elect

Quoted 2 lines

to
use and control the effective frequency of by using scaled sync?

I guess you likely already saw it in the driver. The scale value is automatically set by the driver depending on the desired ODR (sampling frequency).

Quoted 4 lines

I'm not sure what pulse sync is. Grepping the datasheet didn't give me anything that seemed related.   The sync pin is input only so I'm also not sure on output sync.

I think this is a copy paste from the adis16475 bindings. For this device, it seems we only have:
* internal clock;
* external:
* direct mode
* scaled mode

Quoted 9 lines

But yeah, as you pointed out I think we do not need the binding. The presence of
an optional input clock plus the frequency should be all we need in order to set the desired configuration. It should also be possible to add the allowed ranges to the external input clock in the bindings...

- Nuno Sá

Will drop this binding than and add a frequency one that is dependent on clock with specified ranges.

- Robert Budai

#10 lore raw

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

Quoted 148 lines · Robert
Quoted 148 lines

-----Original Message-----
From: Nuno Sá <[email protected]>
Sent: Monday, January 13, 2025 11:30 AM
To: Jonathan Cameron <[email protected]>; Budai, Robert <[email protected]>
Cc: Sa, Nuno <[email protected]>; Gradinariu, Ramona <[email protected]>; Miclaus, Antoniu <[email protected]>; Lars-Peter Clausen <[email protected]>; Hennerich, Michael <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Jonathan Corbet <[email protected]>; Alex Lanzano <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH v4 4/6] dt-bindings: iio: Add adis16550 bindings

[External]

Quoted 15 lines · Jonathan Cameron
Quoted 12 lines · On Fri, 10 Jan 2025 09:42:52 +0200 Robert Budai <[email protected]> wrote:

Document the ADIS16550 device devicetree bindings.

---

4:
- applied styling changes to the bindings file
- restricted sync-mode to intervals 1-2

Quoted 7 lines
Quoted 7 lines

 .../bindings/iio/imu/adi,adis16550.yaml       | 96 +++++++++++++++++++ MAINTAINERS                                   |  9 ++

 2 files changed, 105 insertions(+)

 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml

diff --git

a/Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml

Quoted 10 lines

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 4

Quoted 10 lines

b/Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file mode 100644
index 000000000000..e7ccf3883e55

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +4 -0
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id:

https://urldefense.com/v3/__http://devicetree.org/schemas/iio/imu/adi,adis
16550.yaml*__;Iw!!A3Ni8CS0y2Y!74KHajr7iKZQ7Ld5deb4LytVFckO_Og8tIG Ukf233OLregM6AqtN-v-IBRfAn-4Z1tC0bwbcEpNO7Glv8YjiXWI$

Quoted 1 line

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 5

Quoted 1 line
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +1 -0
+$schema: https://urldefense.com/v3/__http://devicetree.org/meta-

schemas/core.yaml*__;Iw!!A3Ni8CS0y2Y!74KHajr7iKZQ7Ld5deb4LytVFckO_ Og8tIGUkf233OLregM6AqtN-v-IBRfAn-4Z1tC0bwbcEpNO7GlvNAV5ERI$

Quoted 53 lines
Quoted 34 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +34 -0
+
+title: Analog Devices ADIS16550 and similar IMUs
+
+maintainers:
+  - Nuno Sa <[email protected]>
+  - Ramona Gradinariu <[email protected]>
+  - Antoniu Miclaus <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+      - adi,adis16550w
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+
+  spi-cpol: true
+
+  spi-max-frequency:
+    maximum: 15000000
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      RESET active low pin.
+    maxItems: 1
+

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10 -0
+  clocks:
+    maxItems: 1
+    description: If not provided, then the internal clock is used.
+
+  adi,sync-mode:
+    description:
+      Configures the device SYNC pin. The following modes are supported
+      0 - output_sync
+      1 - direct_sync
+      2 - scaled_sync

A little more on these would be good.  They are 'weird' options that are not commonly seen so help the reader out.

For scaled_sync don't we need information on the scale for it to be useful?
If we had that then a value of 1 would mean direct sync and wouldn't need another control.

Quoted 4 lines

I'm not fully understanding the usecases for this.

If we have a say a pulse per second input, the control of the scale should be userspace anyway.  So maybe this maps to the input clock that we can

elect

Quoted 2 lines

to
use and control the effective frequency of by using scaled sync?

I guess you likely already saw it in the driver. The scale value is automatically set by the driver depending on the desired ODR (sampling frequency).

Quoted 4 lines

I'm not sure what pulse sync is. Grepping the datasheet didn't give me anything that seemed related.   The sync pin is input only so I'm also not sure on output sync.

I think this is a copy paste from the adis16475 bindings. For this device, it
seems we only have:
 * internal clock;
 * external:
   * direct mode
   * scaled mode

But yeah, as you pointed out I think we do not need the binding. The presence
of
an optional input clock plus the frequency should be all we need in order to set
the desired configuration. It should also be possible to add the allowed ranges
to the external input clock in the bindings...

Quoted 5 lines
Quoted 2 lines

- Nuno Sá

Will drop this binding than and add a frequency one that is dependent on clock with specified ranges.

Note I would not add a new binding if there's no standard one. My previous comment can be misleading... I see there is a 'clock-frequency' property in the clock schema but descriptions says it's legacy and apparently for fixed-clocks. So maybe not suitable for this case?

- Nuno Sá

#11 lore raw

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

In reply to Robert Budai

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 18

Quoted 10 lines · Robert Budai
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10 -0
+maintainers:
+  - Nuno Sa <[email protected]>
+  - Ramona Gradinariu <[email protected]>
+  - Antoniu Miclaus <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+      - adi,adis16550w

Where is the answer for my questions at v1? No responses on email, nothing improved in the patchset. Go back to my comments and respond to them or implement them.

Quoted 25 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +25 -0
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+
+  spi-cpol: true
+
+  spi-max-frequency:
+    maximum: 15000000
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      RESET active low pin.
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+    description: If not provided, then the internal clock is used.
+

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 53

Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10 -0
+  adi,sync-mode:
+    description:
+      Configures the device SYNC pin. The following modes are supported
+      0 - output_sync
+      1 - direct_sync
+      2 - scaled_sync
+      3 - pulse_sync
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 2

So what does the "3" mean? Why documenting something impossible?

Anyway, use strings for these and drop "_sync" suffixes.

Best regards,
Krzysztof

author maintainer
#12 lore raw

RE: [PATCH v4 4/6] dt-bindings: iio: Add adis16550 bindings

Quoted 20 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Monday, January 13, 2025 10:44 AM
To: Budai, Robert <[email protected]>
Cc: Sa, Nuno <[email protected]>; Gradinariu, Ramona <[email protected]>; Miclaus, Antoniu <[email protected]>; Lars-Peter Clausen <[email protected]>; Hennerich, Michael <[email protected]>; Jonathan Cameron <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Jonathan Corbet <[email protected]>; Alex Lanzano <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v4 4/6] dt-bindings: iio: Add adis16550 bindings

[External]

On Fri, Jan 10, 2025 at 09:42:52AM +0200, Robert Budai wrote:

Quoted 15 lines

Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 18

Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10 -0
+maintainers:
+  - Nuno Sa <[email protected]>
+  - Ramona Gradinariu <[email protected]>
+  - Antoniu Miclaus <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - adi,adis16550
+      - adi,adis16550w

Where is the answer for my questions at v1? No responses on email, nothing improved in the patchset. Go back to my comments and respond to them or implement them.

[Robert Budai

author maintainer
#13 lore raw

PATCH v4 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 com- pensation formulas that provide accurate sensor measurements

---

4:
- reorganized channels to match the order in the datasheet
- removed extra checks and goto statements
- for buffer memory allocation used only kfree, since adis library already takes care of freeing the buffer

 drivers/iio/imu/Kconfig     |   13 +
 drivers/iio/imu/Makefile    |    1 +
 drivers/iio/imu/adis16550.c | 1202 +++++++++++++++++++++++++++++++++++
 3 files changed, 1216 insertions(+)
 create mode 100644 drivers/iio/imu/adis16550.c
drivers/iio/imu/Kconfig +13 -0
index ca0efecb5b5c..c4e06ebbe058 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.
+
+	  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 04c77c2c4df8..e901aea498d3 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 +1202 -0

1,202 lines not on this page · raw message

Signature · 1 line
2.34.1
#14 lore raw

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

kernel test robot noticed the following build errors:

Hi Robert,

kernel test robot noticed the following build errors:

[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on linus/master v6.13-rc6 next-20250110] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Robert-Budai/iio-imu-adis-Add-custom-ops-struct/20250110-154645
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link:    https://lore.kernel.org/r/20250110074254.38966-6-robert.budai%40analog.com
patch subject: [PATCH v4 5/6] iio: imu: adis16550: add adis16550 support
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20250111/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250111/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from include/linux/module.h:22,

                    from include/linux/device/driver.h:21,
                    from include/linux/device.h:32,
                    from include/linux/iio/iio.h:10,
                    from include/linux/iio/buffer.h:10,
                    from drivers/iio/imu/adis16550.c:12:
>> drivers/iio/imu/adis16550.c:1202:18: error: expected ',' or ';' before 'IIO_ADISLIB'
    1202 | MODULE_IMPORT_NS(IIO_ADISLIB);
         |                  ^~~~~~~~~~~
   include/linux/moduleparam.h:26:61: note: in definition of macro '__MODULE_INFO'
      26 |                 = __MODULE_INFO_PREFIX __stringify(tag) "=" info
         |                                                             ^~~~
   include/linux/module.h:299:33: note: in expansion of macro 'MODULE_INFO'
     299 | #define MODULE_IMPORT_NS(ns)    MODULE_INFO(import_ns, ns)
         |                                 ^~~~~~~~~~~
   drivers/iio/imu/adis16550.c:1202:1: note: in expansion of macro 'MODULE_IMPORT_NS'
    1202 | MODULE_IMPORT_NS(IIO_ADISLIB);
         | ^~~~~~~~~~~~~~~~

vim +1202 drivers/iio/imu/adis16550.c

1196
1197 MODULE_AUTHOR("Nuno Sa <[email protected]>");
1198 MODULE_AUTHOR("Ramona Gradinariu <[email protected]>");
1199 MODULE_AUTHOR("Antoniu Miclaus <[email protected]>");
1200 MODULE_DESCRIPTION("Analog Devices ADIS16550 IMU driver");
1201 MODULE_LICENSE("GPL");

> 1202	MODULE_IMPORT_NS(IIO_ADISLIB);
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#15 lore raw

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

Quoted 45 lines · On Sat, 11 Jan 2025 20:03:22 +0800 kernel test robot <[email protected]> wrote:

Hi Robert,

kernel test robot noticed the following build errors:

[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on linus/master v6.13-rc6 next-20250110] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Robert-Budai/iio-imu-adis-Add-custom-ops-struct/20250110-154645
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link:    https://lore.kernel.org/r/20250110074254.38966-6-robert.budai%40analog.com
patch subject: [PATCH v4 5/6] iio: imu: adis16550: add adis16550 support
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20250111/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250111/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from include/linux/module.h:22,

                    from include/linux/device/driver.h:21,
                    from include/linux/device.h:32,
                    from include/linux/iio/iio.h:10,
                    from include/linux/iio/buffer.h:10,
                    from drivers/iio/imu/adis16550.c:12:
Quoted 1 line
Quoted 1 line

drivers/iio/imu/adis16550.c:1202:18: error: expected ',' or ';' before 'IIO_ADISLIB'

    1202 | MODULE_IMPORT_NS(IIO_ADISLIB);
         |                  ^~~~~~~~~~~
   include/linux/moduleparam.h:26:61: note: in definition of macro '__MODULE_INFO'
      26 |                 = __MODULE_INFO_PREFIX __stringify(tag) "=" info
         |                                                             ^~~~
   include/linux/module.h:299:33: note: in expansion of macro 'MODULE_INFO'
     299 | #define MODULE_IMPORT_NS(ns)    MODULE_INFO(import_ns, ns)
         |                                 ^~~~~~~~~~~
   drivers/iio/imu/adis16550.c:1202:1: note: in expansion of macro 'MODULE_IMPORT_NS'
    1202 | MODULE_IMPORT_NS(IIO_ADISLIB);
         | ^~~~~~~~~~~~~~~~
Quoted 10 lines

vim +1202 drivers/iio/imu/adis16550.c

1196
1197 MODULE_AUTHOR("Nuno Sa <[email protected]>");
1198 MODULE_AUTHOR("Ramona Gradinariu <[email protected]>");
1199 MODULE_AUTHOR("Antoniu Miclaus <[email protected]>");
1200 MODULE_DESCRIPTION("Analog Devices ADIS16550 IMU driver");
1201 MODULE_LICENSE("GPL");

Quoted 1 line

1202 MODULE_IMPORT_NS(IIO_ADISLIB);

You need a base commit from rc2 or above. (technically 2 patches after rc1 but rc2 is probably a better choice!) This will be material for next kernel release anyway now so this all may become moot!

Jonathan

#16 lore raw

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

In reply to Robert Budai
kernel test robot noticed the following build errors:

Hi Robert,

kernel test robot noticed the following build errors:

[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on linus/master v6.13-rc6 next-20250110] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Robert-Budai/iio-imu-adis-Add-custom-ops-struct/20250110-154645
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link:    https://lore.kernel.org/r/20250110074254.38966-6-robert.budai%40analog.com
patch subject: [PATCH v4 5/6] iio: imu: adis16550: add adis16550 support
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20250112/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250112/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/iio/imu/adis16550.c:1202:18: error: expected ';' after top level declarator
    1202 | MODULE_IMPORT_NS(IIO_ADISLIB);
         |                  ^

1 error generated.

vim +1202 drivers/iio/imu/adis16550.c

1196
1197 MODULE_AUTHOR("Nuno Sa <[email protected]>");
1198 MODULE_AUTHOR("Ramona Gradinariu <[email protected]>");
1199 MODULE_AUTHOR("Antoniu Miclaus <[email protected]>");
1200 MODULE_DESCRIPTION("Analog Devices ADIS16550 IMU driver");
1201 MODULE_LICENSE("GPL");

> 1202	MODULE_IMPORT_NS(IIO_ADISLIB);
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#17 lore raw

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

In reply to Robert Budai
Quoted 14 lines · On Fri, 10 Jan 2025 09:42:53 +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 com- pensation formulas that provide accurate sensor measurements

Quoted 6 lines

---

4:
- reorganized channels to match the order in the datasheet
- removed extra checks and goto statements
- for buffer memory allocation used only kfree, since adis library already takes care of freeing the buffer

That last bit makes for a mess wrt to who owns the buffer and lifetime management. Suggestions inline.

Jonathan

Quoted 6 lines
drivers/iio/imu/adis16550.c new file +0 -0
new file mode 100644
index 000000000000..49c3ff9ef1e2
@@ -0,0 +1,1202 @@

...

drivers/iio/imu/adis16550.c line 515

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+static int adis16550_set_accl_filter_freq(struct adis16550 *st, int freq_hz)
+{
+	bool en = false;
+
+	if (freq_hz)
+		en = true;
+
+	return __adis_update_bits(&st->adis, ADIS16550_REG_CONFIG,
+				  ADIS16550_ACCL_FIR_EN_MASK,
+				  (u32)FIELD_PREP(ADIS16550_ACCL_FIR_EN_MASK, en));

Why is the cast needed? Only bit 3 is set.

Quoted 5 lines
drivers/iio/imu/adis16550.c new file +4 -0
+}
 
+static irqreturn_t adis16550_trigger_handler(int irq, void *p)
+{
+	u32 crc;

drivers/iio/imu/adis16550.c line 865

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+	u16 dummy;
+	bool valid;
+	int ret, i = 0;
+	u8 data_offset = 3;
+	struct iio_poll_func *pf = p;
+	__be32 data[ADIS16550_MAX_SCAN_DATA];
+	struct iio_dev *indio_dev = pf->indio_dev;
+	struct adis16550 *st = iio_priv(indio_dev);
+	struct adis *adis = iio_device_get_drvdata(indio_dev);
+	__be32 *buffer = adis->buffer;

Related to below lifetime comment. Move this buffer into iio_priv() given you aren't using the lifetime management in the adis library code.

Quoted 12 lines
drivers/iio/imu/adis16550.c new file +12 -0
+
+	ret = spi_sync(adis->spi, &adis->msg);
+	if (ret)
+		goto done;
+	/*
+	 * Validate the header. The header is a normal spi reply with state
+	 * vector and crc4.
+	 */
+	ret = adis16550_spi_validate(&st->adis, buffer[0], &dummy);
+	if (ret)
+		goto done;
+

drivers/iio/imu/adis16550.c line 887

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+	crc = be32_to_cpu(buffer[ADIS16550_BURST_N_ELEM - 1]);
+	/* the header is not included in the crc */
+	valid = adis16550_validate_crc((u32 *)&buffer[1],
+				       ADIS16550_BURST_N_ELEM - 2, crc);
+	if (!valid) {
+		dev_err(&adis->spi->dev, "Burst Invalid crc!\n");
+		goto done;
+	}
+
+	memcpy(&data[i], &buffer[data_offset], (ADIS16550_SCAN_ACCEL_Z -

i is always 0? If so just use data here and get rid of i. If data_offset is always 3, encode that directly here as well instead of confusing local variable.

Quoted 13 lines
drivers/iio/imu/adis16550.c new file +12 -0
+						ADIS16550_SCAN_GYRO_X + 2) *
+						sizeof(__be32));
+	iio_push_to_buffers_with_timestamp(indio_dev, data, pf->timestamp);
+done:
+	iio_trigger_notify_done(indio_dev->trig);
+	return IRQ_HANDLED;
+}
 
+static int adis16550_update_scan_mode(struct iio_dev *indio_dev,
+				      const unsigned long *scan_mask)
+{
+	struct adis *adis = iio_device_get_drvdata(indio_dev);
+	u16 burst_length = ADIS16550_BURST_DATA_LEN;

drivers/iio/imu/adis16550.c line 915

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+	u8 burst_cmd;
+	u8 *tx;
+
+	if (*scan_mask & ADIS16550_BURST_DATA_GYRO_ACCEL_MASK)
+		burst_cmd = ADIS16550_REG_BURST_GYRO_ACCEL;
+	else
+		burst_cmd = ADIS16550_REG_BURST_DELTA_ANG_VEL;
+
+	memset(adis->xfer, 0, 2 * sizeof(*adis->xfer));
+	memset(adis->buffer, 0, burst_length + sizeof(u32));

This overlaps with the comment on lifetime management below. I would move the xfer and buffer pointers into iio_priv leaving adis->xfer and adis->buffer == NULL so that the core frees nothing.

Quoted 46 lines
drivers/iio/imu/adis16550.c new file +45 -0
+
+	tx = adis->buffer + burst_length;
+	tx[0] = 0x00;
+	tx[1] = 0x00;
+	tx[2] = burst_cmd;
+	/* crc4 is 0 on burst command */
+	tx[3] = spi_crc4(get_unaligned_le32(tx));
+
+	adis->xfer[0].tx_buf = tx;
+	adis->xfer[0].len = 4;
+	adis->xfer[0].cs_change = 1;
+	adis->xfer[0].delay.value = 8;
+	adis->xfer[0].delay.unit = SPI_DELAY_UNIT_USECS;
+	adis->xfer[1].rx_buf = adis->buffer;
+	adis->xfer[1].len = burst_length;
+
+	spi_message_init_with_transfers(&adis->msg, adis->xfer, 2);
+
+	return 0;
+}
 
+static int adis16550_config_sync(struct adis16550 *st)
+{
+	struct device *dev = &st->adis.spi->dev;
+	const struct adis16550_sync *sync;
+	struct clk *clk;
+	u32 sync_mode;
+	u16 mode;
+	int ret;
+
+	ret = device_property_read_u32(dev, "adi,sync-mode", &sync_mode);
+	if (ret) {
+		st->clk_freq_hz = st->info->int_clk * 1000;
+		return 0;
+	}
+
+	if (sync_mode >= st->info->num_sync) {
+		dev_err(dev, "Invalid sync mode: %u for %s\n", sync_mode,
+			st->info->name);
+		return -EINVAL;
+	}
+
+	sync = &st->info->sync_mode[sync_mode];
+	st->sync_mode = sync->sync_mode;
+
+	clk = devm_clk_get_enabled(dev, NULL);

drivers/iio/imu/adis16550.c line 976

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	st->clk_freq_hz = clk_get_rate(clk);
+	if (st->clk_freq_hz > sync->max_rate || st->clk_freq_hz < sync->min_rate)
+		return dev_err_probe(dev, -EINVAL,
+				     "Clk rate: %lu not in a valid range:[%u %u]\n",
+				     st->clk_freq_hz, sync->min_rate, sync->max_rate);
+
+	if (sync->sync_mode == ADIS16550_SYNC_MODE_SCALED) {

Similar to DT binding discussion. You can see from the clock frequency if you need to need to use sync_mode_scaled or not. I don't see a need for a binding to control that.

Quoted 56 lines
drivers/iio/imu/adis16550.c new file +55 -0
+		u16 sync_scale;
+		u32 scaled_freq = 0;
+		/*
+		 * In pps scaled sync we must scale the input clock to a range
+		 * of [3000 45000].
+		 */
+		ret = device_property_read_u32(dev, "adi,scaled-output-hz",
+					       &scaled_freq);
+		if (ret)
+			return dev_err_probe(dev, ret,
+					     "adi,scaled-output-hz property not found");
+
+		if (scaled_freq < 3000 || scaled_freq > 4500)
+			return dev_err_probe(dev, -EINVAL,
+					     "Invalid value:%u for adi,scaled-output-hz",
+					     scaled_freq);
+
+		sync_scale = DIV_ROUND_CLOSEST(scaled_freq, st->clk_freq_hz);
+
+		ret = adis_write_reg_16(&st->adis, ADIS16550_REG_SYNC_SCALE,
+					sync_scale);
+		if (ret)
+			return ret;
+
+		st->clk_freq_hz = scaled_freq;
+	}
+
+	st->clk_freq_hz *= 1000;
+
+	mode = FIELD_PREP(ADIS16550_SYNC_MODE_MASK, sync->sync_mode) |
+	       FIELD_PREP(ADIS16550_SYNC_EN_MASK, true);
+
+	return __adis_update_bits(&st->adis, ADIS16550_REG_CONFIG,
+				  ADIS16550_SYNC_MASK, mode);
+}
 
+
+static int adis16550_probe(struct spi_device *spi)
+{
+	struct device *dev = &spi->dev;
+	struct iio_dev *indio_dev;
+	struct adis16550 *st;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	st = iio_priv(indio_dev);
+	st->info = spi_get_device_match_data(spi);
+	if (!st->info)
+		return -EINVAL;
+
+	indio_dev->name = st->info->name;
+	indio_dev->channels = st->info->channels;
+	indio_dev->num_channels = st->info->num_channels;

drivers/iio/imu/adis16550.c line 1125

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+	indio_dev->available_scan_masks = adis16550_channel_masks;
+	indio_dev->info = &adis16550_info;
+	indio_dev->modes = INDIO_DIRECT_MODE;
+
+	st->adis.ops = &adis16550_ops;
+
+	/*
+	 * Allocate the xfer and buffer for the burst read operation. The buffer
+	 * is used to store the burst data and the xfer is used to send the burst
+	 * command and receive the data. On device remove the adis libraary is going

library.

drivers/iio/imu/adis16550.c line 1126

Quoted 1 line
drivers/iio/imu/adis16550.c new file +1 -0
+	 * to free the xfer and buffer.

That is a horrible lifetime control. They should either be allocated in the library and freed in the library or allocated and freed in the driver. Mixing that doesn't make sense.

Can you store them somewhere else so that the ownership is never in the adis library?

Quoted 5 lines
drivers/iio/imu/adis16550.c new file +5 -0
+	 */
+	st->adis.xfer = kzalloc(2 * sizeof(*st->adis.xfer),
+	if (!st->adis.xfer)
+		return -ENOMEM;
+

drivers/iio/imu/adis16550.c line 1142

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+	st->adis.buffer = kzalloc(ADIS16550_BURST_DATA_LEN + sizeof(u32),
+				  GFP_KERNEL);
+	if (!st->adis.buffer)
+		return -ENOMEM;
+
+	ret = devm_regulator_get_enable(dev, "vdd");
+	if (ret) {
+		dev_err_probe(dev, ret,
+			      "Failed to get vdd regulator\n");
+		return ret;

return dev_err_probe()

and drop the brackets.

Quoted 30 lines
drivers/iio/imu/adis16550.c new file +30 -0
+	}
+
+	ret = adis_init(&st->adis, indio_dev, spi, &adis16550_data);
+	if (ret)
+		return ret;
+
+	ret = __adis_initial_startup(&st->adis);
+	if (ret)
+		return ret;
+
+	ret = adis16550_config_sync(st);
+	if (ret)
+		return ret;
+
+	ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev,
+						 adis16550_trigger_handler);
+	if (ret)
+		return ret;
+
+	ret = devm_iio_device_register(dev, indio_dev);
+	if (ret)
+		return ret;
+
+	adis16550_debugfs_init(indio_dev);
+
+	return 0;
+}
+
+static const struct spi_device_id adis16550_id[] = {
+	{ "adis16550",  (kernel_ulong_t)&adis16550_chip_info},

drivers/iio/imu/adis16550.c line 1182

Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10 -0
+	{ "adis16550w", (kernel_ulong_t)&adis16550w_chip_info},
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, adis16550_id);
+
+static const struct of_device_id adis16550_of_match[] = {
+	{ .compatible = "adi,adis16550",
+		.data = &adis16550_chip_info },
+	{ .compatible = "adi,adis16550w",
+		.data = &adis16550w_chip_info },

Under 80 chars on one line, so don't wrap these.

Quoted 2 lines
drivers/iio/imu/adis16550.c new file +2 -0
+	{ }
+};
#18 lore raw

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

Quoted 29 lines · Jonathan Cameron
Quoted 14 lines · On Fri, 10 Jan 2025 09:42:53 +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 com- pensation formulas that provide accurate sensor measurements

Quoted 7 lines

---

4:
- reorganized channels to match the order in the datasheet
- removed extra checks and goto statements
- for buffer memory allocation used only kfree, since adis library already takes care of freeing the buffer

That last bit makes for a mess wrt to who owns the buffer and lifetime management. Suggestions inline.

...

Quoted 11 lines
Quoted 8 lines
drivers/iio/imu/adis16550.c new file +3 -0
+
+	/*
+	 * Allocate the xfer and buffer for the burst read operation. The

buffer

(quoted diff) +1 -0
+	 * is used to store the burst data and the xfer is used to send the

burst

(quoted diff) +1 -0
+	 * command and receive the data. On device remove the adis libraary

is going

library.

Quoted 7 lines

drivers/iio/imu/adis16550.c line 1126

Quoted 1 line
drivers/iio/imu/adis16550.c new file +1 -0
+	 * to free the xfer and buffer.

That is a horrible lifetime control.  They should either be allocated in the library
and freed in the library or allocated and freed in the driver.  Mixing that doesn't
make sense.

Agreed. TBH, I did not remembered at all to suggest ignoring the library and let it call kfree() on NULL. I also don't like that much of how things are done in the lib but I don't think it would be that straight to change things for the non 'burst mode' cases. For the devices implementing 'burst mode' doing the free + allocation on every update_scan_modes seems unnecessary. Anyways, maybe something worth looking at in the future.

- Nuno Sá

#19 lore raw

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

In reply to Jonathan Cameron
Quoted 39 lines · Jonathan Cameron
Quoted 14 lines · On Fri, 10 Jan 2025 09:42:53 +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 com- pensation formulas that provide accurate sensor measurements

Quoted 7 lines

---

4:
- reorganized channels to match the order in the datasheet
- removed extra checks and goto statements
- for buffer memory allocation used only kfree, since adis library already takes care of freeing the buffer

That last bit makes for a mess wrt to who owns the buffer and lifetime management. Suggestions inline.

Jonathan

Quoted 6 lines
drivers/iio/imu/adis16550.c new file +0 -0
new file mode 100644
index 000000000000..49c3ff9ef1e2
@@ -0,0 +1,1202 @@

...

Quoted 14 lines
Quoted 11 lines

+static int adis16550_set_accl_filter_freq(struct adis16550 *st, int freq_hz)

drivers/iio/imu/adis16550.c new file +9 -0
+{
+	bool en = false;
+
+	if (freq_hz)
+		en = true;
+
+	return __adis_update_bits(&st->adis, ADIS16550_REG_CONFIG,
+				  ADIS16550_ACCL_FIR_EN_MASK,
+				 
Quoted 1 line

(u32)FIELD_PREP(ADIS16550_ACCL_FIR_EN_MASK, en));

Why is the cast needed? Only bit 3 is set.

Typically this is needed for the cases where we want to write in 2 byte registers and we want to make sure sizeof(val) (on the macro evaluation) gives us the proper size. But yes, for this case as we want 4 bytes, it should not be needed. Hmm but I think we might get 'unsigned long' from FIELD_PREP() since mask is also of that type?

- Nuno Sá

author maintainer
#20 lore raw

PATCH v4 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.).

---

v4:
- removed extra text bits from the documentation

 Documentation/iio/adis16550.rst | 378 ++++++++++++++++++++++++++++++++
 Documentation/iio/index.rst     |   1 +
 2 files changed, 379 insertions(+)
 create mode 100644 Documentation/iio/adis16550.rst
Documentation/iio/adis16550.rst new file +378 -0
new file mode 100644
index 000000000000..1ea85fb77bb8
@@ -0,0 +1,378 @@
+.. 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.
+
+1. 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.                                                |
++----------------------------+--------------------------------------------------------------------------------+
+| write_lock_enable          | Lock the device from further configuration. Only a reset will remove the lock. |
++----------------------------+--------------------------------------------------------------------------------+
+
+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 074dbbf7ba0a..2c3fa1716a69 100644
@@ -26,6 +26,7 @@ Industrial I/O Kernel Drivers
    ad7944
    adis16475
    adis16480
+   adis16550
    adxl380
    bno055
    ep93xx_adc
Signature · 1 line
2.34.1