Add support for ADIS16550
Subsystems (6)
Robert Budai
maintainerv6 cover Add support for ADIS16550
*** BLURB HERE ***
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 | 83 ++ Documentation/iio/adis16550.rst | 376 ++++++ Documentation/iio/index.rst | 1 + MAINTAINERS | 9 + drivers/iio/imu/Kconfig | 13 + drivers/iio/imu/Makefile | 1 + drivers/iio/imu/adis.c | 36 +- drivers/iio/imu/adis16550.c | 1156 +++++++++++++++++ include/linux/iio/imu/adis.h | 34 +- 9 files changed, 1696 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.39.5
Robert Budai
maintainerPATCH v6 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.
---
v6:
- commit message wrapped at 75 characters
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
@@ -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
@@ -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
@@ -102,6 +114,7 @@ struct adis_data {* @burst: ADIS burst transfer information * @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
@@ -117,6 +130,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
@@ -169,7 +183,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 ); }/**
@@ -181,7 +195,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 ); }/**
@@ -193,7 +207,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 ); }/**
@@ -208,7 +222,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;
@@ -227,7 +241,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;
@@ -245,7 +259,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); }/**
@@ -259,7 +273,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.39.5
Robert Budai
maintainerPATCH v6 2/6 iio: imu: adis: Add reset to custom ops
In reply to Robert BudaiThis 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.
---
v6:
-commit message wrapped at 75 characters
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
@@ -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
@@ -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.39.5
Robert Budai
maintainerPATCH v6 3/6 iio: imu: adis: Add DIAG_STAT register
In reply to Robert BudaiSome 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.
---
v6:
- commit message wrapped at 75 characters
- added local variable for status register
- applied suggestion for diag_stat_size description
drivers/iio/imu/adis.c | 19 ++++++++++++++++--- include/linux/iio/imu/adis.h | 3 +++ 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/iio/imu/adis.c +16 -3
@@ -304,11 +304,21 @@ 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 +327,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
@@ -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.39.5
Robert Budai
maintainerPATCH v6 4/6 dt-bindings: iio: Add adis16550 bindings
In reply to Robert BudaiDocument the ADIS16550 device devicetree bindings.
---
v6:
- applied blank line suggestions
- added clock-frequency dependency change suggestions
- yamllint corrections
.../bindings/iio/imu/adi,adis16550.yaml | 83 +++++++++++++++++++ MAINTAINERS | 9 ++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +83 -0
@@ -0,0 +1,83 @@ +# 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 + + reg: + maxItems: 1 + + spi-cpha: true + spi-cpol: true + + spi-max-frequency: + maximum: 15000000 + + vdd-supply: true + + interrupts: + maxItems: 1 + + reset-gpios: + description: + Must be the device tree identifier of the RESET pin. If specified, + it will be asserted during driver probe. As the line is active low, + it should be marked GPIO_ACTIVE_LOW. + maxItems: 1 + + clocks: + description: If not provided, then the internal clock is used. + maxItems: 1 + + clock-frequency: + description: Clock frequency in Hz when an external clock is used. + oneOf: + - minimum: 1 + maximum: 128 + - minimum: 3000 + maximum: 4500 + +required: + - compatible + - reg + - interrupts + - spi-cpha + - spi-cpol + - spi-max-frequency + - vdd-supply + +dependentRequired: + clock: [clock-frequency] + +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 +9 -0
@@ -1452,6 +1452,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.39.5
Re: [PATCH v6 4/6] dt-bindings: iio: Add adis16550 bindings
Quoted 64 lines · Robert Budai
Document the ADIS16550 device devicetree bindings.
Co-developed-by Antoniu Miclaus <[email protected]>Signed-off-by Antoniu Miclaus <[email protected]>Signed-off-by Ramona Gradinariu <[email protected]>Signed-off-by Robert Budai <[email protected]>---
v6:
- applied blank line suggestions
- added clock-frequency dependency change suggestions
- yamllint corrections.../bindings/iio/imu/adi,adis16550.yaml | 83 +++++++++++++++++++ MAINTAINERS | 9 ++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16550.yamlDocumentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +40
-0@@ -0,0 +1,83 @@ +# 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 + + reg: + maxItems: 1 + + spi-cpha: true + spi-cpol: true + + spi-max-frequency: + maximum: 15000000 + + vdd-supply: true + + interrupts: + maxItems: 1 + + reset-gpios: + description: + Must be the device tree identifier of the RESET pin. If specified, + it will be asserted during driver probe. As the line is active low, + it should be marked GPIO_ACTIVE_LOW. + maxItems: 1 + + clocks:
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +10
-0+ description: If not provided, then the internal clock is used. + maxItems: 1 + + clock-frequency: + description: Clock frequency in Hz when an external clock is used. + oneOf: + - minimum: 1 + maximum: 128 + - minimum: 3000 + maximum: 4500
I don't get why this is a property, to be honest. When you've got an external clock, why isn't the frequency obtained from the clock provider node?
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 62
Quoted 12 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +12
-0+ +required: + - compatible + - reg + - interrupts + - spi-cpha + - spi-cpol + - spi-max-frequency + - vdd-supply + +dependentRequired: + clock: [clock-frequency]
^
typo, missing s.
Quoted 44 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +21
-0+ +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 +9
-0@@ -1452,6 +1452,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.39.5
Re: [PATCH v6 4/6] dt-bindings: iio: Add adis16550 bindings
Quoted 73 lines · Conor Dooley
Quoted 72 lines · Robert Budai
Document the ADIS16550 device devicetree bindings.
Co-developed-by Antoniu Miclaus <[email protected]>Signed-off-by Antoniu Miclaus <[email protected]>Signed-off-by Ramona Gradinariu <[email protected]>Signed-off-by Robert Budai <[email protected]>---
v6:
- applied blank line suggestions
- added clock-frequency dependency change suggestions
- yamllint corrections.../bindings/iio/imu/adi,adis16550.yaml | 83 +++++++++++++++++++ MAINTAINERS | 9 ++
2 files changed, 92 insertions(+)create mode 100644
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yamlDocumentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +46
-0@@ -0,0 +1,83 @@ +# 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 + + reg: + maxItems: 1 + + spi-cpha: true + spi-cpol: true + + spi-max-frequency: + maximum: 15000000 + + vdd-supply: true + + interrupts: + maxItems: 1 + + reset-gpios: + description: + Must be the device tree identifier of the RESET pin. If specified, + it will be asserted during driver probe. As the line is active low, + it should be marked GPIO_ACTIVE_LOW. + maxItems: 1 + + clocks: + description: If not provided, then the internal clock is used. + maxItems: 1 + + clock-frequency: + description: Clock frequency in Hz when an external clock is used. + oneOf:
Quoted 9 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 50
Quoted 4 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +4
-0+ - minimum: 1 + maximum: 128 + - minimum: 3000 + maximum: 4500I don't get why this is a property, to be honest. When you've got an external clock, why isn't the frequency obtained from the clock provider node?
The main purpose of this property is actually to show/document the constrains of the external clock. We can very well just error out in the driver (and we do that) and not have this property. I mentioned this property to Robert some revisions ago and I also pointed out that I wasn't really sure if it should be used or not (I guess this is more for fixed clock providers...). IIRC, I did asked for some advice/comments but we got none so I assume Robert just decided to use it and see what you guys had to say about it.
- Nuno Sá
Quoted 60 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 62
Quoted 12 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +12
-0+ +required: + - compatible + - reg + - interrupts + - spi-cpha + - spi-cpol + - spi-max-frequency + - vdd-supply + +dependentRequired: + clock: [clock-frequency]^
typo, missing s.Quoted 45 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +21
-0+ +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 +0
-0@@ -1452,6 +1452,15 @@W: https://ez.analog.com/linux-software-drivers
F:Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml
F:drivers/iio/imu/adis16475.cMAINTAINERS +9
-0+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.39.5
Re: [PATCH v6 4/6] dt-bindings: iio: Add adis16550 bindings
Quoted 84 lines · Nuno Sá
Quoted 73 lines · Conor Dooley
Quoted 72 lines · Robert Budai
Document the ADIS16550 device devicetree bindings.
Co-developed-by Antoniu Miclaus <[email protected]>Signed-off-by Antoniu Miclaus <[email protected]>Signed-off-by Ramona Gradinariu <[email protected]>Signed-off-by Robert Budai <[email protected]>---
v6:
- applied blank line suggestions
- added clock-frequency dependency change suggestions
- yamllint corrections.../bindings/iio/imu/adi,adis16550.yaml | 83 +++++++++++++++++++ MAINTAINERS | 9 ++
2 files changed, 92 insertions(+)create mode 100644
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yamlDocumentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +46
-0@@ -0,0 +1,83 @@ +# 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 + + reg: + maxItems: 1 + + spi-cpha: true + spi-cpol: true + + spi-max-frequency: + maximum: 15000000 + + vdd-supply: true + + interrupts: + maxItems: 1 + + reset-gpios: + description: + Must be the device tree identifier of the RESET pin. If specified, + it will be asserted during driver probe. As the line is active low, + it should be marked GPIO_ACTIVE_LOW. + maxItems: 1 + + clocks: + description: If not provided, then the internal clock is used. + maxItems: 1 + + clock-frequency: + description: Clock frequency in Hz when an external clock is used. + oneOf:Quoted 9 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 50
Quoted 4 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +4
-0+ - minimum: 1 + maximum: 128 + - minimum: 3000 + maximum: 4500I don't get why this is a property, to be honest. When you've got an external clock, why isn't the frequency obtained from the clock provider node?
Quoted 7 lines
The main purpose of this property is actually to show/document the constrains of the external clock. We can very well just error out in the driver (and we do that) and not have this property. I mentioned this property to Robert some revisions ago and I also pointed out that I wasn't really sure if it should be used or not (I guess this is more for fixed clock providers...). IIRC, I did asked for some advice/comments but we got none so I assume Robert just decided to use it and see what you guys had to say about it.
NGL, this is one of the kinda of things where if you're relying on dt-bindings to avoid cocking up your board design, things have already gotten pretty badly wrong! That said, "clock-frequency" is a property for cpus, fixed-frequency clock providers and i2c buses, you'd need a vendor prefix and a unit suffix here IMO. Also, I don't really think that it actually does anything at all, given it does not constrain the clock you're linking to with the clocks property. This may as well just be a comment in the description of the clocks property, for all that it does.
Jonathan Cameron
maintainerRe: [PATCH v6 4/6] dt-bindings: iio: Add adis16550 bindings
Quoted 93 lines · On Wed, 5 Feb 2025 19:52:37 +0000 Conor Dooley <[email protected]> wrote:
Quoted 84 lines · Nuno Sá
Quoted 73 lines · Conor Dooley
Quoted 72 lines · Robert Budai
Document the ADIS16550 device devicetree bindings.
Co-developed-by Antoniu Miclaus <[email protected]>Signed-off-by Antoniu Miclaus <[email protected]>Signed-off-by Ramona Gradinariu <[email protected]>Signed-off-by Robert Budai <[email protected]>---
v6:
- applied blank line suggestions
- added clock-frequency dependency change suggestions
- yamllint corrections.../bindings/iio/imu/adi,adis16550.yaml | 83 +++++++++++++++++++ MAINTAINERS | 9 ++
2 files changed, 92 insertions(+)create mode 100644
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yamlDocumentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +46
-0@@ -0,0 +1,83 @@ +# 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 + + reg: + maxItems: 1 + + spi-cpha: true + spi-cpol: true + + spi-max-frequency: + maximum: 15000000 + + vdd-supply: true + + interrupts: + maxItems: 1 + + reset-gpios: + description: + Must be the device tree identifier of the RESET pin. If specified, + it will be asserted during driver probe. As the line is active low, + it should be marked GPIO_ACTIVE_LOW. + maxItems: 1 + + clocks: + description: If not provided, then the internal clock is used. + maxItems: 1 + + clock-frequency: + description: Clock frequency in Hz when an external clock is used. + oneOf:Quoted 9 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml line 50
Quoted 4 lines
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +4
-0+ - minimum: 1 + maximum: 128 + - minimum: 3000 + maximum: 4500I don't get why this is a property, to be honest. When you've got an external clock, why isn't the frequency obtained from the clock provider node?
Quoted 7 lines
The main purpose of this property is actually to show/document the constrains of the external clock. We can very well just error out in the driver (and we do that) and not have this property. I mentioned this property to Robert some revisions ago and I also pointed out that I wasn't really sure if it should be used or not (I guess this is more for fixed clock providers...). IIRC, I did asked for some advice/comments but we got none so I assume Robert just decided to use it and see what you guys had to say about it.
Quoted 8 lines
NGL, this is one of the kinda of things where if you're relying on dt-bindings to avoid cocking up your board design, things have already gotten pretty badly wrong! That said, "clock-frequency" is a property for cpus, fixed-frequency clock providers and i2c buses, you'd need a vendor prefix and a unit suffix here IMO. Also, I don't really think that it actually does anything at all, given it does not constrain the clock you're linking to with the clocks property. This may as well just be a comment in the description of the clocks property, for all that it does.
I'd just drop it.
Jonathan
Re: [PATCH v6 4/6] dt-bindings: iio: Add adis16550 bindings
Quoted 115 lines · Jonathan Cameron
Quoted 103 lines · On Wed, 5 Feb 2025 19:52:37 +0000 Conor Dooley <[email protected]> wrote:
Quoted 89 lines · Nuno Sá
Quoted 79 lines · Conor Dooley
Quoted 78 lines · Robert Budai
Document the ADIS16550 device devicetree bindings.
Co-developed-by Antoniu Miclaus <[email protected]>Signed-off-by Antoniu Miclaus <[email protected]>Signed-off-by Ramona Gradinariu <[email protected]>Signed-off-by Robert Budai <[email protected]>---
v6:
- applied blank line suggestions
- added clock-frequency dependency change suggestions
- yamllint corrections.../bindings/iio/imu/adi,adis16550.yaml | 83
+++++++++++++++++++
MAINTAINERS | 9 ++2 files changed, 92 insertions(+)create mode 100644
Documentation/devicetree/bindings/iio/imu/adi,adis16550.yamldiff --git
a/Documentation/devicetree/bindings/iio/imu/adi,adis16550.yamlb/Documentation/devicetree/bindings/iio/imu/adi,adis16550.yamlnew file mode 100644
index 000000000000..8750bb937979Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +35
-0@@ -0,0 +1,83 @@ +# 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 + + reg: + maxItems: 1 + + spi-cpha: true + spi-cpol: true + + spi-max-frequency: + maximum: 15000000 + + vdd-supply: true + + interrupts: + maxItems: 1 + + reset-gpios: + description: + Must be the device tree identifier of the RESET pin. Ifspecified,
+ it will be asserted during driver probe. As the line is active low,
+ it should be markedGPIO_ACTIVE_LOW.
+ maxItems: 1Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml new file +7
-0+ + clocks: + description: If not provided, then the internal clock is used. + maxItems: 1 + + clock-frequency: + description: Clock frequency in Hz when an external clock isused.
+ oneOf:
+ - minimum: 1Quoted 8 lines
Quoted 3 lines
+ maximum: 128
+ - minimum: 3000
+ maximum: 4500I don't get why this is a property, to be honest. When you've got an external clock, why isn't the frequency obtained from the clock provider node?
Quoted 12 lines
The main purpose of this property is actually to show/document the constrains of
the external clock. We can very well just error out in the driver (and we do
that) and not have this property. I mentioned this property to Robert some revisions ago and I also pointed out that I wasn't really sure if it should be
used or not (I guess this is more for fixed clock providers...). IIRC, I did
asked for some advice/comments but we got none so I assume Robert just decided
to use it and see what you guys had to say about it.Quoted 8 lines
NGL, this is one of the kinda of things where if you're relying on dt-bindings to avoid cocking up your board design, things have already gotten pretty badly wrong! That said, "clock-frequency" is a property for cpus, fixed-frequency clock providers and i2c buses, you'd need a vendor prefix and a unit suffix here IMO. Also, I don't really think that it actually does anything at all, given it does not constrain the clock you're linking to with the clocks property. This may as well just be a comment in the description of the clocks property, for all that it does.
Quoted 2 lines
I'd just drop it.
Agreed...
- Nuno Sá
Robert Budai
maintainerPATCH v6 5/6 iio: imu: adis16550: add adis16550 support
In reply to Robert BudaiThe 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.
---
v6:
-commit message wrapped at 75 characters
- moved spi xfer buffers and data buffers to iio_priv
- styling suggestions applied
- deleted remove function of adis16550
drivers/iio/imu/Kconfig | 13 + drivers/iio/imu/Makefile | 1 + drivers/iio/imu/adis16550.c | 1156 +++++++++++++++++++++++++++++++++++ 3 files changed, 1170 insertions(+) create mode 100644 drivers/iio/imu/adis16550.c
drivers/iio/imu/Kconfig +13 -0
@@ -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
@@ -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 +1156 -0
1,156 lines not on this page · raw message
Signature · 1 line
2.39.5
Jonathan Cameron
maintainerRe: [PATCH v6 5/6] iio: imu: adis16550: add adis16550 support
Quoted 8 lines · On Tue, 4 Feb 2025 16:36:09 +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
Co-developed-by Ramona Gradinariu <[email protected]>Signed-off-by Ramona Gradinariu <[email protected]>Co-developed-by Antoniu Miclaus <[email protected]>Signed-off-by Antoniu Miclaus <[email protected]>Signed-off-by Nuno Sá <[email protected]>Signed-off-by Robert Budai <[email protected]>
A few minor comments inline given you will need to do a v7 for the DT feedback. Otherwise I might just have tweaked these whilst applying.
Quoted 7 lines
drivers/iio/imu/adis16550.c new file +0
-0@@ -0,0 +1,1156 @@
drivers/iio/imu/adis16550.c line 117
Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10
-0+ +struct adis16550 { +const struct adis16550_chip_info *info; +struct adis adis; +unsigned long clk_freq_hz; +u32 sync_mode; +struct spi_transfer xfer[2 ]; +u8 buffer[ADIS16550_BURST_DATA_LEN +sizeof (u32)]__aligned(IIO_DMA_MINALIGN) ; +__be32 din[2 ]__aligned(IIO_DMA_MINALIGN) ; +__be32 dout[2 ]__aligned(IIO_DMA_MINALIGN) ;
In most cases only one such marking is needed. Devices tend not to interfere with themselves and we tend not to be changing values from software in one of the buffer DMA is targetting whilst the device is using the others.
So we normally just mark the first one of a set like this. That avoids adding a lot of padding when it is not needed.
drivers/iio/imu/adis16550.c line 543
Quoted 10 lines
drivers/iio/imu/adis16550.c new file +8
-0+}; + +static int adis16550_set_gyro_filter_freq (struct adis16550 *st,int freq_hz) +{ +u8 en =0 ; + +if (freq_hz) + en =1 ;
Could save a line or two without greatly affecting readability. Same thing applies in at least one other place.
u8 en = freq_hz ? 1 : 0;
drivers/iio/imu/adis16550.c line 874
Quoted 13 lines
drivers/iio/imu/adis16550.c new file +11
-0+ +return __adis_update_bits (&st->adis,ADIS16550_REG_CONFIG , +ADIS16550_GYRO_FIR_EN_MASK , +FIELD_PREP (ADIS16550_GYRO_FIR_EN_MASK , en)); +} + +static irqreturn_t adis16550_trigger_handler (int irq,void *p) +{ +memcpy (data, &buffer[3 ], (ADIS16550_SCAN_ACCEL_Z - +ADIS16550_SCAN_GYRO_X +2 ) * +sizeof (__be32));
Strange alignment.
memcpy(data, &buffer[3], (ADIS16550_SCAN_ACCEL_Z - ADIS16550_SCAN_GYRO_X + 2) * sizeof(__be32));
Is about the best I could come up with.
Good to add a comment on why the + 2 as well.
Quoted 38 lines
drivers/iio/imu/adis16550.c new file +35
-0+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_probe (struct spi_device *spi) +{ +u16 burst_length =ADIS16550_BURST_DATA_LEN ; +struct device *dev = &spi->dev; +struct iio_dev *indio_dev; +struct adis16550 *st; +struct adis *adis; +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 ; + adis = &st->adis; + indio_dev->name = st->info->name; + indio_dev->channels = st->info->channels; + indio_dev->num_channels = st->info->num_channels; + indio_dev->available_scan_masks = adis16550_channel_masks; + indio_dev->info = &adis16550_info; + indio_dev->modes =INDIO_DIRECT_MODE ; + + st->adis.ops = &adis16550_ops; + st->xfer[0 ].tx_buf = st->buffer + burst_length; + st->xfer[0 ].len =4 ; + st->xfer[0 ].cs_change =1 ; + st->xfer[0 ].delay.value =8 ;
drivers/iio/imu/adis16550.c
Quoted 10 lines
drivers/iio/imu/adis16550.c new file +10
-0+ st->xfer[0 ].delay.unit =SPI_DELAY_UNIT_USECS ; + st->xfer[1 ].rx_buf = st->buffer; + st->xfer[1 ].len = burst_length; + +spi_message_init_with_transfers (&adis->msg, st->xfer,2 ); + + ret =devm_regulator_get_enable (dev,"vdd" ); +if (ret) +return dev_err_probe (dev, ret, +"Failed to get vdd regulator\n" );
Totally trivial but preference is to align after ( unless the line ends up too long. In those cases it is fine to indent just one tab more than the line above.
Here it actually fits on one line anyway as it's exactly 80 chars.
return dev_err_probe(dev, ret, "Failed to get vdd regulator\n");
Quoted 26 lines
drivers/iio/imu/adis16550.c new file +26
-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 ; +}
Robert Budai
maintainerPATCH v6 6/6 docs: iio: add documentation for adis16550 driver
In reply to Robert BudaiAdd 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.).
---
v6:
- commit message wrapped at 75 characters
- removed extra file deescriptin
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
@@ -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. + +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. | ++----------------------------+--------------------------------------------------------------------------------+ + +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
@@ -26,6 +26,7 @@ Industrial I/O Kernel Drivers ad7944 adis16475 adis16480 + adis16550 adxl380 bno055 ep93xx_adc
Signature · 1 line
2.39.5