linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices
@ 2019-02-27 16:14 Stefan Popa
  2019-02-27 16:14 ` [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator Stefan Popa
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

This series has as main goal to add support for ADIS1649x family of devices as
part of the already existing adis16480, but on the way it also deals with some
outstanding items:

* Make drdy pin configurable
* Add OF device ID table
* Deal with the temperature max scale in a generic way
* Deal with sampling and filter freq in a generic way
* Add missing docs

Changes in v3:
Patch 1, 2, 3:
	- Nothing changed
Patch 4, 5:
	- Added to this series
Patch 6:
	- Added support for sampling and filter freq
Patch 7:
	- Nothing changed

Changes in v2:
Patch 1:
	- use DIO1 pin as default data ready signal instead of DIO2.
Patch 2:
	- nothing changed.
Patch 3, 4:
	- give the scale directly in the adis16480_chip_info struct.
Patch 5: 
	- document the use of DIO1 pin as default data ready signal.

Stefan Popa (7):
  iio: imu: adis16480: Add support for configurable drdy indicator
  iio: imu: adis16480: Add OF device ID table
  iio: imu: adis16480: Treat temperature scale in a generic way
  iio: imu: adis16480: Calculate the sampling frequency in a generic way
  iio: imu: adis16480: Deal with filter freq in a generic way
  iio: imu: adis16480: Add support for ADIS1649x family of devices
  iio: imu: adis16480: Add docs for ADIS16480 IMU

 .../devicetree/bindings/iio/imu/adi,adis16480.txt  |  49 ++++
 MAINTAINERS                                        |   1 +
 drivers/iio/imu/adis16480.c                        | 253 +++++++++++++++++++--
 3 files changed, 290 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt

-- 
2.7.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator
  2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
@ 2019-02-27 16:14 ` Stefan Popa
  2019-03-03 12:46   ` Jonathan Cameron
  2019-02-27 16:14 ` [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table Stefan Popa
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

The FNCTIO_CTRL register provides configuration control for each I/O pin
(DIO1, DIO2, DIO3 and DIO4).

This patch adds the option to configure each DIOx pin as data ready
indicator with positive or negative polarity by reading the 'interrupts'
and 'interrupt-names' properties from the devicetree. The
'interrupt-names' property is optional, if it is not specified, then the
DIO1 pin is used as default data ready signal.

Although the factory default assigns DIO2 as data ready signal, in the
versions previous this patch, DIO1 pin was used. We should leave this
configuration as is, since some devices might be expecting the interrupt
on the wrong physical pin.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 drivers/iio/imu/adis16480.c | 97 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 95 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index a27fe20..98a23ac 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -9,6 +9,8 @@
  *
  */
 
+#include <linux/bitfield.h>
+#include <linux/of_irq.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
@@ -107,6 +109,14 @@
 #define ADIS16480_FIR_COEF_C(x)			ADIS16480_FIR_COEF(0x09, (x))
 #define ADIS16480_FIR_COEF_D(x)			ADIS16480_FIR_COEF(0x0B, (x))
 
+/* ADIS16480_REG_FNCTIO_CTRL */
+#define ADIS16480_DRDY_SEL_MSK		GENMASK(1, 0)
+#define ADIS16480_DRDY_SEL(x)		FIELD_PREP(ADIS16480_DRDY_SEL_MSK, x)
+#define ADIS16480_DRDY_POL_MSK		BIT(2)
+#define ADIS16480_DRDY_POL(x)		FIELD_PREP(ADIS16480_DRDY_POL_MSK, x)
+#define ADIS16480_DRDY_EN_MSK		BIT(3)
+#define ADIS16480_DRDY_EN(x)		FIELD_PREP(ADIS16480_DRDY_EN_MSK, x)
+
 struct adis16480_chip_info {
 	unsigned int num_channels;
 	const struct iio_chan_spec *channels;
@@ -116,12 +126,26 @@ struct adis16480_chip_info {
 	unsigned int accel_max_scale;
 };
 
+enum adis16480_int_pin {
+	ADIS16480_PIN_DIO1,
+	ADIS16480_PIN_DIO2,
+	ADIS16480_PIN_DIO3,
+	ADIS16480_PIN_DIO4
+};
+
 struct adis16480 {
 	const struct adis16480_chip_info *chip_info;
 
 	struct adis adis;
 };
 
+static const char * const adis16480_int_pin_names[4] = {
+	[ADIS16480_PIN_DIO1] = "DIO1",
+	[ADIS16480_PIN_DIO2] = "DIO2",
+	[ADIS16480_PIN_DIO3] = "DIO3",
+	[ADIS16480_PIN_DIO4] = "DIO4",
+};
+
 #ifdef CONFIG_DEBUG_FS
 
 static ssize_t adis16480_show_firmware_revision(struct file *file,
@@ -741,8 +765,17 @@ static int adis16480_stop_device(struct iio_dev *indio_dev)
 
 static int adis16480_enable_irq(struct adis *adis, bool enable)
 {
-	return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL,
-		enable ? BIT(3) : 0);
+	uint16_t val;
+	int ret;
+
+	ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
+	if (ret < 0)
+		return ret;
+
+	val &= ~ADIS16480_DRDY_EN_MSK;
+	val |= ADIS16480_DRDY_EN(enable);
+
+	return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val);
 }
 
 static int adis16480_initial_setup(struct iio_dev *indio_dev)
@@ -826,6 +859,62 @@ static const struct adis_data adis16480_data = {
 	.enable_irq = adis16480_enable_irq,
 };
 
+static int adis16480_config_irq_pin(struct device_node *of_node,
+				    struct adis16480 *st)
+{
+	struct irq_data *desc;
+	enum adis16480_int_pin pin;
+	unsigned int irq_type;
+	uint16_t val;
+	int i, irq = 0;
+
+	desc = irq_get_irq_data(st->adis.spi->irq);
+	if (!desc) {
+		dev_err(&st->adis.spi->dev, "Could not find IRQ %d\n", irq);
+		return -EINVAL;
+	}
+
+	/* Disable data ready since the default after reset is on */
+	val = ADIS16480_DRDY_EN(0);
+
+	/*
+	 * Get the interrupt from the devicetre by reading the interrupt-names
+	 * property. If it is not specified, use DIO1 pin as default.
+	 * According to the datasheet, the factory default assigns DIO2 as data
+	 * ready signal. However, in the previous versions of the driver, DIO1
+	 * pin was used. So, we should leave it as is since some devices might
+	 * be expecting the interrupt on the wrong physical pin.
+	 */
+	pin = ADIS16480_PIN_DIO1;
+	for (i = 0; i < ARRAY_SIZE(adis16480_int_pin_names); i++) {
+		irq = of_irq_get_byname(of_node, adis16480_int_pin_names[i]);
+		if (irq > 0) {
+			pin = i;
+			break;
+		}
+	}
+
+	val |= ADIS16480_DRDY_SEL(pin);
+
+	/*
+	 * Get the interrupt line behaviour. The data ready polarity can be
+	 * configured as positive or negative, corresponding to
+	 * IRQF_TRIGGER_RISING or IRQF_TRIGGER_FALLING respectively.
+	 */
+	irq_type = irqd_get_trigger_type(desc);
+	if (irq_type == IRQF_TRIGGER_RISING) { /* Default */
+		val |= ADIS16480_DRDY_POL(1);
+	} else if (irq_type == IRQF_TRIGGER_FALLING) {
+		val |= ADIS16480_DRDY_POL(0);
+	} else {
+		dev_err(&st->adis.spi->dev,
+			"Invalid interrupt type 0x%x specified\n", irq_type);
+		return -EINVAL;
+	}
+	/* Write the data ready configuration to the FNCTIO_CTRL register */
+	return adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val);
+}
+
 static int adis16480_probe(struct spi_device *spi)
 {
 	const struct spi_device_id *id = spi_get_device_id(spi);
@@ -853,6 +942,10 @@ static int adis16480_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
+	ret = adis16480_config_irq_pin(spi->dev.of_node, st);
+	if (ret)
+		return ret;
+
 	ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL);
 	if (ret)
 		return ret;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table
  2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
  2019-02-27 16:14 ` [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator Stefan Popa
@ 2019-02-27 16:14 ` Stefan Popa
  2019-03-03 12:46   ` Jonathan Cameron
  2019-02-27 16:14 ` [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way Stefan Popa
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

The driver does not have a struct of_device_id table, but supported
devices are registered via Device Trees. This patch adds OF device ID
table.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 drivers/iio/imu/adis16480.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index 98a23ac..150d814 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -991,9 +991,19 @@ static const struct spi_device_id adis16480_ids[] = {
 };
 MODULE_DEVICE_TABLE(spi, adis16480_ids);
 
+static const struct of_device_id adis16480_of_match[] = {
+	{ .compatible = "adi,adis16375" },
+	{ .compatible = "adi,adis16480" },
+	{ .compatible = "adi,adis16485" },
+	{ .compatible = "adi,adis16488" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, adis16480_of_match);
+
 static struct spi_driver adis16480_driver = {
 	.driver = {
 		.name = "adis16480",
+		.of_match_table = adis16480_of_match,
 	},
 	.id_table = adis16480_ids,
 	.probe = adis16480_probe,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way
  2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
  2019-02-27 16:14 ` [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator Stefan Popa
  2019-02-27 16:14 ` [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table Stefan Popa
@ 2019-02-27 16:14 ` Stefan Popa
  2019-03-03 12:47   ` Jonathan Cameron
  2019-02-27 16:14 ` [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency " Stefan Popa
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

All supported devices provide internal temperature measurement from -40 C
to +85 C, with +25 C representing value 0x00.

This patch treats the temperature scale in a generic way, similar to the
accelerometer and gyroscope scales. So far, there are no temperature max
scale differences between the supported devices. However, devices that
will make use of this feature will be added in the future.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 drivers/iio/imu/adis16480.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index 150d814..5a2864a 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -124,6 +124,7 @@ struct adis16480_chip_info {
 	unsigned int gyro_max_scale;
 	unsigned int accel_max_val;
 	unsigned int accel_max_scale;
+	unsigned int temp_scale;
 };
 
 enum adis16480_int_pin {
@@ -530,6 +531,7 @@ static int adis16480_read_raw(struct iio_dev *indio_dev,
 	const struct iio_chan_spec *chan, int *val, int *val2, long info)
 {
 	struct adis16480 *st = iio_priv(indio_dev);
+	unsigned int temp;
 
 	switch (info) {
 	case IIO_CHAN_INFO_RAW:
@@ -549,8 +551,13 @@ static int adis16480_read_raw(struct iio_dev *indio_dev,
 			*val2 = 100; /* 0.0001 gauss */
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_TEMP:
-			*val = 5;
-			*val2 = 650000; /* 5.65 milli degree Celsius */
+			/*
+			 * +85 degrees Celsius = temp_max_scale
+			 * +25 degrees Celsius = 0
+			 * LSB, 25 degrees Celsius  = 60 / temp_max_scale
+			 */
+			*val = st->chip_info->temp_scale / 1000;
+			*val2 = (st->chip_info->temp_scale % 1000) * 1000;
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_PRESSURE:
 			*val = 0;
@@ -561,7 +568,8 @@ static int adis16480_read_raw(struct iio_dev *indio_dev,
 		}
 	case IIO_CHAN_INFO_OFFSET:
 		/* Only the temperature channel has a offset */
-		*val = 4425; /* 25 degree Celsius = 0x0000 */
+		temp = 25 * 1000000LL; /* 25 degree Celsius = 0x0000 */
+		*val = DIV_ROUND_CLOSEST_ULL(temp, st->chip_info->temp_scale);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_CALIBBIAS:
 		return adis16480_get_calibbias(indio_dev, chan, val);
@@ -717,6 +725,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.gyro_max_scale = 300,
 		.accel_max_val = IIO_M_S_2_TO_G(21973),
 		.accel_max_scale = 18,
+		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 	},
 	[ADIS16480] = {
 		.channels = adis16480_channels,
@@ -725,6 +734,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.gyro_max_scale = 450,
 		.accel_max_val = IIO_M_S_2_TO_G(12500),
 		.accel_max_scale = 10,
+		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 	},
 	[ADIS16485] = {
 		.channels = adis16485_channels,
@@ -733,6 +743,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.gyro_max_scale = 450,
 		.accel_max_val = IIO_M_S_2_TO_G(20000),
 		.accel_max_scale = 5,
+		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 	},
 	[ADIS16488] = {
 		.channels = adis16480_channels,
@@ -741,6 +752,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.gyro_max_scale = 450,
 		.accel_max_val = IIO_M_S_2_TO_G(22500),
 		.accel_max_scale = 18,
+		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 	},
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency in a generic way
  2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
                   ` (2 preceding siblings ...)
  2019-02-27 16:14 ` [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way Stefan Popa
@ 2019-02-27 16:14 ` Stefan Popa
  2019-03-03 12:51   ` Jonathan Cameron
  2019-02-27 16:14 ` [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq " Stefan Popa
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

The adis1648x devices have an internal clock of 2.46 kSPS. The sampling
frequency is calculated by applying a decimation rate which can take the
maximum value of 2047.

Although all adis1648x devices are similar in this regard, devices that
will use this feature will be added in the future.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 drivers/iio/imu/adis16480.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index 5a2864a..92abc95 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -125,6 +125,8 @@ struct adis16480_chip_info {
 	unsigned int accel_max_val;
 	unsigned int accel_max_scale;
 	unsigned int temp_scale;
+	unsigned int int_clk;
+	unsigned int max_dec_rate;
 };
 
 enum adis16480_int_pin {
@@ -299,9 +301,9 @@ static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2)
 	if (t <= 0)
 		return -EINVAL;
 
-	t = 2460000 / t;
-	if (t > 2048)
-		t = 2048;
+	t = st->chip_info->int_clk / t;
+	if (t > st->chip_info->max_dec_rate)
+		t = st->chip_info->max_dec_rate;
 
 	if (t != 0)
 		t--;
@@ -320,7 +322,7 @@ static int adis16480_get_freq(struct iio_dev *indio_dev, int *val, int *val2)
 	if (ret < 0)
 		return ret;
 
-	freq = 2460000 / (t + 1);
+	freq = st->chip_info->int_clk / (t + 1);
 	*val = freq / 1000;
 	*val2 = (freq % 1000) * 1000;
 
@@ -726,6 +728,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.accel_max_val = IIO_M_S_2_TO_G(21973),
 		.accel_max_scale = 18,
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
+		.int_clk = 2460000,
+		.max_dec_rate = 2048,
 	},
 	[ADIS16480] = {
 		.channels = adis16480_channels,
@@ -735,6 +739,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.accel_max_val = IIO_M_S_2_TO_G(12500),
 		.accel_max_scale = 10,
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
+		.int_clk = 2460000,
+		.max_dec_rate = 2048,
 	},
 	[ADIS16485] = {
 		.channels = adis16485_channels,
@@ -744,6 +750,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.accel_max_val = IIO_M_S_2_TO_G(20000),
 		.accel_max_scale = 5,
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
+		.int_clk = 2460000,
+		.max_dec_rate = 2048,
 	},
 	[ADIS16488] = {
 		.channels = adis16480_channels,
@@ -753,6 +761,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.accel_max_val = IIO_M_S_2_TO_G(22500),
 		.accel_max_scale = 18,
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
+		.int_clk = 2460000,
+		.max_dec_rate = 2048,
 	},
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq in a generic way
  2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
                   ` (3 preceding siblings ...)
  2019-02-27 16:14 ` [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency " Stefan Popa
@ 2019-02-27 16:14 ` Stefan Popa
  2019-03-03 12:52   ` Jonathan Cameron
  2019-02-27 16:14 ` [PATCH v3 6/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
  2019-02-27 16:14 ` [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU Stefan Popa
  6 siblings, 1 reply; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

When setting the filter frequency, the driver looks into the
adis16480_def_filter_freqs table for the best match. Pass this table to
the chip_info struct since future devices will need to use a different
table.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 drivers/iio/imu/adis16480.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index 92abc95..c90375d 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -127,6 +127,7 @@ struct adis16480_chip_info {
 	unsigned int temp_scale;
 	unsigned int int_clk;
 	unsigned int max_dec_rate;
+	const unsigned int *filter_freqs;
 };
 
 enum adis16480_int_pin {
@@ -483,7 +484,7 @@ static int adis16480_get_filter_freq(struct iio_dev *indio_dev,
 	if (!(val & enable_mask))
 		*freq = 0;
 	else
-		*freq = adis16480_def_filter_freqs[(val >> offset) & 0x3];
+		*freq = st->chip_info->filter_freqs[(val >> offset) & 0x3];
 
 	return IIO_VAL_INT;
 }
@@ -510,10 +511,10 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev,
 		val &= ~enable_mask;
 	} else {
 		best_freq = 0;
-		best_diff = 310;
+		best_diff = st->chip_info->filter_freqs[0];
 		for (i = 0; i < ARRAY_SIZE(adis16480_def_filter_freqs); i++) {
-			if (adis16480_def_filter_freqs[i] >= freq) {
-				diff = adis16480_def_filter_freqs[i] - freq;
+			if (st->chip_info->filter_freqs[i] >= freq) {
+				diff = st->chip_info->filter_freqs[i] - freq;
 				if (diff < best_diff) {
 					best_diff = diff;
 					best_freq = i;
@@ -730,6 +731,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 		.int_clk = 2460000,
 		.max_dec_rate = 2048,
+		.filter_freqs = adis16480_def_filter_freqs,
 	},
 	[ADIS16480] = {
 		.channels = adis16480_channels,
@@ -741,6 +743,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 		.int_clk = 2460000,
 		.max_dec_rate = 2048,
+		.filter_freqs = adis16480_def_filter_freqs,
 	},
 	[ADIS16485] = {
 		.channels = adis16485_channels,
@@ -752,6 +755,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 		.int_clk = 2460000,
 		.max_dec_rate = 2048,
+		.filter_freqs = adis16480_def_filter_freqs,
 	},
 	[ADIS16488] = {
 		.channels = adis16480_channels,
@@ -763,6 +767,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.temp_scale = 5650, /* 5.65 milli degree Celsius */
 		.int_clk = 2460000,
 		.max_dec_rate = 2048,
+		.filter_freqs = adis16480_def_filter_freqs,
 	},
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 6/7] iio: imu: adis16480: Add support for ADIS1649x family of devices
  2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
                   ` (4 preceding siblings ...)
  2019-02-27 16:14 ` [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq " Stefan Popa
@ 2019-02-27 16:14 ` Stefan Popa
  2019-03-03 12:53   ` Jonathan Cameron
  2019-02-27 16:14 ` [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU Stefan Popa
  6 siblings, 1 reply; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

The ADIS16495 and ADIS16497 are inertial systems that include a triaxis
gyroscope and a triaxis accelerometer. The serial peripheral interface
(SPI) provide a simple interface for data collection and configuration
control. The devices are similar to ADIS16475, ADIS16480, ADIS16485 and
ADIS16488, the main differences are highlighted below:

* The temperature data scale is 0.00565 C/LSB for ADIS16475 and ADIS1648x
  devices, while for ADIS1649x 0.0125 C/LSB.

* ADIS1649x devices support different gyroscope measurement ranges which
  are dependent on the dash number (-1, -2, -3), see Table 24 in the
  ADIS16495 datasheet. However, the ADIS16497 gyroscopes have the same
  scale as ADIS16495.

* ADIS16495 devices support the acceleration maximum range of 8g, while
  ADIS16497 devices go up to 40g.

* The internal clock for ADIS1649x devices is 4.25 kSPS. The sampling
  frequency is calculated by applying a decimation rate which can take a
  maximum value of 4250.

* ADIS1649x devices support different default filter frequencies.

Datasheets:
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16495.pdf
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16497.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 drivers/iio/imu/adis16480.c | 97 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index c90375d..28cece3 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -453,6 +453,13 @@ static const unsigned int adis16480_def_filter_freqs[] = {
 	63,
 };
 
+static const unsigned int adis16495_def_filter_freqs[] = {
+	300,
+	100,
+	300,
+	100,
+};
+
 static const unsigned int ad16480_filter_data[][2] = {
 	[ADIS16480_SCAN_GYRO_X]		= { ADIS16480_REG_FILTER_BNK0, 0 },
 	[ADIS16480_SCAN_GYRO_Y]		= { ADIS16480_REG_FILTER_BNK0, 3 },
@@ -713,6 +720,12 @@ enum adis16480_variant {
 	ADIS16480,
 	ADIS16485,
 	ADIS16488,
+	ADIS16495_1,
+	ADIS16495_2,
+	ADIS16495_3,
+	ADIS16497_1,
+	ADIS16497_2,
+	ADIS16497_3,
 };
 
 static const struct adis16480_chip_info adis16480_chip_info[] = {
@@ -769,6 +782,78 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
 		.max_dec_rate = 2048,
 		.filter_freqs = adis16480_def_filter_freqs,
 	},
+	[ADIS16495_1] = {
+		.channels = adis16485_channels,
+		.num_channels = ARRAY_SIZE(adis16485_channels),
+		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
+		.gyro_max_scale = 125,
+		.accel_max_val = IIO_M_S_2_TO_G(32000),
+		.accel_max_scale = 8,
+		.temp_scale = 12500, /* 12.5 milli degree Celsius */
+		.int_clk = 4250000,
+		.max_dec_rate = 4250,
+		.filter_freqs = adis16495_def_filter_freqs,
+	},
+	[ADIS16495_2] = {
+		.channels = adis16485_channels,
+		.num_channels = ARRAY_SIZE(adis16485_channels),
+		.gyro_max_val = IIO_RAD_TO_DEGREE(18000),
+		.gyro_max_scale = 450,
+		.accel_max_val = IIO_M_S_2_TO_G(32000),
+		.accel_max_scale = 8,
+		.temp_scale = 12500, /* 12.5 milli degree Celsius */
+		.int_clk = 4250000,
+		.max_dec_rate = 4250,
+		.filter_freqs = adis16495_def_filter_freqs,
+	},
+	[ADIS16495_3] = {
+		.channels = adis16485_channels,
+		.num_channels = ARRAY_SIZE(adis16485_channels),
+		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
+		.gyro_max_scale = 2000,
+		.accel_max_val = IIO_M_S_2_TO_G(32000),
+		.accel_max_scale = 8,
+		.temp_scale = 12500, /* 12.5 milli degree Celsius */
+		.int_clk = 4250000,
+		.max_dec_rate = 4250,
+		.filter_freqs = adis16495_def_filter_freqs,
+	},
+	[ADIS16497_1] = {
+		.channels = adis16485_channels,
+		.num_channels = ARRAY_SIZE(adis16485_channels),
+		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
+		.gyro_max_scale = 125,
+		.accel_max_val = IIO_M_S_2_TO_G(32000),
+		.accel_max_scale = 40,
+		.temp_scale = 12500, /* 12.5 milli degree Celsius */
+		.int_clk = 4250000,
+		.max_dec_rate = 4250,
+		.filter_freqs = adis16495_def_filter_freqs,
+	},
+	[ADIS16497_2] = {
+		.channels = adis16485_channels,
+		.num_channels = ARRAY_SIZE(adis16485_channels),
+		.gyro_max_val = IIO_RAD_TO_DEGREE(18000),
+		.gyro_max_scale = 450,
+		.accel_max_val = IIO_M_S_2_TO_G(32000),
+		.accel_max_scale = 40,
+		.temp_scale = 12500, /* 12.5 milli degree Celsius */
+		.int_clk = 4250000,
+		.max_dec_rate = 4250,
+		.filter_freqs = adis16495_def_filter_freqs,
+	},
+	[ADIS16497_3] = {
+		.channels = adis16485_channels,
+		.num_channels = ARRAY_SIZE(adis16485_channels),
+		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
+		.gyro_max_scale = 2000,
+		.accel_max_val = IIO_M_S_2_TO_G(32000),
+		.accel_max_scale = 40,
+		.temp_scale = 12500, /* 12.5 milli degree Celsius */
+		.int_clk = 4250000,
+		.max_dec_rate = 4250,
+		.filter_freqs = adis16495_def_filter_freqs,
+	},
 };
 
 static const struct iio_info adis16480_info = {
@@ -1014,6 +1099,12 @@ static const struct spi_device_id adis16480_ids[] = {
 	{ "adis16480", ADIS16480 },
 	{ "adis16485", ADIS16485 },
 	{ "adis16488", ADIS16488 },
+	{ "adis16495-1", ADIS16495_1 },
+	{ "adis16495-2", ADIS16495_2 },
+	{ "adis16495-3", ADIS16495_3 },
+	{ "adis16497-1", ADIS16497_1 },
+	{ "adis16497-2", ADIS16497_2 },
+	{ "adis16497-3", ADIS16497_3 },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, adis16480_ids);
@@ -1023,6 +1114,12 @@ static const struct of_device_id adis16480_of_match[] = {
 	{ .compatible = "adi,adis16480" },
 	{ .compatible = "adi,adis16485" },
 	{ .compatible = "adi,adis16488" },
+	{ .compatible = "adi,adis16495-1" },
+	{ .compatible = "adi,adis16495-2" },
+	{ .compatible = "adi,adis16495-3" },
+	{ .compatible = "adi,adis16497-1" },
+	{ .compatible = "adi,adis16497-2" },
+	{ .compatible = "adi,adis16497-3" },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, adis16480_of_match);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU
  2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
                   ` (5 preceding siblings ...)
  2019-02-27 16:14 ` [PATCH v3 6/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
@ 2019-02-27 16:14 ` Stefan Popa
  2019-03-03 12:54   ` Jonathan Cameron
  6 siblings, 1 reply; 15+ messages in thread
From: Stefan Popa @ 2019-02-27 16:14 UTC (permalink / raw)
  To: jic23, robh+dt
  Cc: Stefan Popa, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

Document support for ADIS16480 Inertial Measurement Unit.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/iio/imu/adi,adis16480.txt  | 49 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt

diff --git a/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt
new file mode 100644
index 0000000..39ab016
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt
@@ -0,0 +1,49 @@
+
+Analog Devices ADIS16480 and similar IMUs
+
+Required properties for the ADIS16480:
+
+- compatible: Must be one of
+	* "adi,adis16375"
+	* "adi,adis16480"
+	* "adi,adis16485"
+	* "adi,adis16488"
+	* "adi,adis16495-1"
+	* "adi,adis16495-2"
+	* "adi,adis16495-3"
+	* "adi,adis16497-1"
+	* "adi,adis16497-2"
+	* "adi,adis16497-3"
+- reg: SPI chip select number for the device
+- spi-max-frequency: Max SPI frequency to use
+	see: Documentation/devicetree/bindings/spi/spi-bus.txt
+- spi-cpha: See Documentation/devicetree/bindings/spi/spi-bus.txt
+- spi-cpol: See Documentation/devicetree/bindings/spi/spi-bus.txt
+- interrupts: interrupt mapping for IRQ, accepted values are:
+	* IRQF_TRIGGER_RISING
+	* IRQF_TRIGGER_FALLING
+
+Optional properties:
+
+- interrupt-names: Data ready line selection. Valid values are:
+	* DIO1
+	* DIO2
+	* DIO3
+	* DIO4
+	If this field is left empty, DIO1 is assigned as default data ready
+	signal.
+- reset-gpios: must be the device tree identifier of the RESET pin. As the line
+	is active low, it should be marked GPIO_ACTIVE_LOW.
+
+Example:
+
+	imu@0 {
+		compatible = "adi,adis16495-1";
+		reg = <0>;
+		spi-max-frequency = <3200000>;
+		spi-cpol;
+		spi-cpha;
+		interrupts = <25 IRQF_TRIGGER_FALLING>;
+		interrupt-parent = <&gpio>;
+		interrupt-names = "DIO2";
+	};
diff --git a/MAINTAINERS b/MAINTAINERS
index e4091ac..beecd1e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -942,6 +942,7 @@ F:	drivers/dma/dma-axi-dmac.c
 ANALOG DEVICES INC IIO DRIVERS
 M:	Lars-Peter Clausen <lars@metafoo.de>
 M:	Michael Hennerich <Michael.Hennerich@analog.com>
+M:	Stefan Popa <stefan.popa@analog.com>
 W:	http://wiki.analog.com/
 W:	http://ez.analog.com/community/linux-device-drivers
 S:	Supported
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator
  2019-02-27 16:14 ` [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator Stefan Popa
@ 2019-03-03 12:46   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2019-03-03 12:46 UTC (permalink / raw)
  To: Stefan Popa
  Cc: robh+dt, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

On Wed, 27 Feb 2019 18:14:22 +0200
Stefan Popa <stefan.popa@analog.com> wrote:

> The FNCTIO_CTRL register provides configuration control for each I/O pin
> (DIO1, DIO2, DIO3 and DIO4).
> 
> This patch adds the option to configure each DIOx pin as data ready
> indicator with positive or negative polarity by reading the 'interrupts'
> and 'interrupt-names' properties from the devicetree. The
> 'interrupt-names' property is optional, if it is not specified, then the
> DIO1 pin is used as default data ready signal.
> 
> Although the factory default assigns DIO2 as data ready signal, in the
> versions previous this patch, DIO1 pin was used. We should leave this
> configuration as is, since some devices might be expecting the interrupt
> on the wrong physical pin.
> 
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Nice detailed description.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16480.c | 97 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 95 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index a27fe20..98a23ac 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -9,6 +9,8 @@
>   *
>   */
>  
> +#include <linux/bitfield.h>
> +#include <linux/of_irq.h>
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
>  #include <linux/mutex.h>
> @@ -107,6 +109,14 @@
>  #define ADIS16480_FIR_COEF_C(x)			ADIS16480_FIR_COEF(0x09, (x))
>  #define ADIS16480_FIR_COEF_D(x)			ADIS16480_FIR_COEF(0x0B, (x))
>  
> +/* ADIS16480_REG_FNCTIO_CTRL */
> +#define ADIS16480_DRDY_SEL_MSK		GENMASK(1, 0)
> +#define ADIS16480_DRDY_SEL(x)		FIELD_PREP(ADIS16480_DRDY_SEL_MSK, x)
> +#define ADIS16480_DRDY_POL_MSK		BIT(2)
> +#define ADIS16480_DRDY_POL(x)		FIELD_PREP(ADIS16480_DRDY_POL_MSK, x)
> +#define ADIS16480_DRDY_EN_MSK		BIT(3)
> +#define ADIS16480_DRDY_EN(x)		FIELD_PREP(ADIS16480_DRDY_EN_MSK, x)
> +
>  struct adis16480_chip_info {
>  	unsigned int num_channels;
>  	const struct iio_chan_spec *channels;
> @@ -116,12 +126,26 @@ struct adis16480_chip_info {
>  	unsigned int accel_max_scale;
>  };
>  
> +enum adis16480_int_pin {
> +	ADIS16480_PIN_DIO1,
> +	ADIS16480_PIN_DIO2,
> +	ADIS16480_PIN_DIO3,
> +	ADIS16480_PIN_DIO4
> +};
> +
>  struct adis16480 {
>  	const struct adis16480_chip_info *chip_info;
>  
>  	struct adis adis;
>  };
>  
> +static const char * const adis16480_int_pin_names[4] = {
> +	[ADIS16480_PIN_DIO1] = "DIO1",
> +	[ADIS16480_PIN_DIO2] = "DIO2",
> +	[ADIS16480_PIN_DIO3] = "DIO3",
> +	[ADIS16480_PIN_DIO4] = "DIO4",
> +};
> +
>  #ifdef CONFIG_DEBUG_FS
>  
>  static ssize_t adis16480_show_firmware_revision(struct file *file,
> @@ -741,8 +765,17 @@ static int adis16480_stop_device(struct iio_dev *indio_dev)
>  
>  static int adis16480_enable_irq(struct adis *adis, bool enable)
>  {
> -	return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL,
> -		enable ? BIT(3) : 0);
> +	uint16_t val;
> +	int ret;
> +
> +	ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
> +	if (ret < 0)
> +		return ret;
> +
> +	val &= ~ADIS16480_DRDY_EN_MSK;
> +	val |= ADIS16480_DRDY_EN(enable);
> +
> +	return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val);
>  }
>  
>  static int adis16480_initial_setup(struct iio_dev *indio_dev)
> @@ -826,6 +859,62 @@ static const struct adis_data adis16480_data = {
>  	.enable_irq = adis16480_enable_irq,
>  };
>  
> +static int adis16480_config_irq_pin(struct device_node *of_node,
> +				    struct adis16480 *st)
> +{
> +	struct irq_data *desc;
> +	enum adis16480_int_pin pin;
> +	unsigned int irq_type;
> +	uint16_t val;
> +	int i, irq = 0;
> +
> +	desc = irq_get_irq_data(st->adis.spi->irq);
> +	if (!desc) {
> +		dev_err(&st->adis.spi->dev, "Could not find IRQ %d\n", irq);
> +		return -EINVAL;
> +	}
> +
> +	/* Disable data ready since the default after reset is on */
> +	val = ADIS16480_DRDY_EN(0);
> +
> +	/*
> +	 * Get the interrupt from the devicetre by reading the interrupt-names
> +	 * property. If it is not specified, use DIO1 pin as default.
> +	 * According to the datasheet, the factory default assigns DIO2 as data
> +	 * ready signal. However, in the previous versions of the driver, DIO1
> +	 * pin was used. So, we should leave it as is since some devices might
> +	 * be expecting the interrupt on the wrong physical pin.
> +	 */
> +	pin = ADIS16480_PIN_DIO1;
> +	for (i = 0; i < ARRAY_SIZE(adis16480_int_pin_names); i++) {
> +		irq = of_irq_get_byname(of_node, adis16480_int_pin_names[i]);
> +		if (irq > 0) {
> +			pin = i;
> +			break;
> +		}
> +	}
> +
> +	val |= ADIS16480_DRDY_SEL(pin);
> +
> +	/*
> +	 * Get the interrupt line behaviour. The data ready polarity can be
> +	 * configured as positive or negative, corresponding to
> +	 * IRQF_TRIGGER_RISING or IRQF_TRIGGER_FALLING respectively.
> +	 */
> +	irq_type = irqd_get_trigger_type(desc);
> +	if (irq_type == IRQF_TRIGGER_RISING) { /* Default */
> +		val |= ADIS16480_DRDY_POL(1);
> +	} else if (irq_type == IRQF_TRIGGER_FALLING) {
> +		val |= ADIS16480_DRDY_POL(0);
> +	} else {
> +		dev_err(&st->adis.spi->dev,
> +			"Invalid interrupt type 0x%x specified\n", irq_type);
> +		return -EINVAL;
> +	}
> +	/* Write the data ready configuration to the FNCTIO_CTRL register */
> +	return adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val);
> +}
> +
>  static int adis16480_probe(struct spi_device *spi)
>  {
>  	const struct spi_device_id *id = spi_get_device_id(spi);
> @@ -853,6 +942,10 @@ static int adis16480_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> +	ret = adis16480_config_irq_pin(spi->dev.of_node, st);
> +	if (ret)
> +		return ret;
> +
>  	ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL);
>  	if (ret)
>  		return ret;


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table
  2019-02-27 16:14 ` [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table Stefan Popa
@ 2019-03-03 12:46   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2019-03-03 12:46 UTC (permalink / raw)
  To: Stefan Popa
  Cc: robh+dt, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

On Wed, 27 Feb 2019 18:14:23 +0200
Stefan Popa <stefan.popa@analog.com> wrote:

> The driver does not have a struct of_device_id table, but supported
> devices are registered via Device Trees. This patch adds OF device ID
> table.
> 
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16480.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index 98a23ac..150d814 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -991,9 +991,19 @@ static const struct spi_device_id adis16480_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(spi, adis16480_ids);
>  
> +static const struct of_device_id adis16480_of_match[] = {
> +	{ .compatible = "adi,adis16375" },
> +	{ .compatible = "adi,adis16480" },
> +	{ .compatible = "adi,adis16485" },
> +	{ .compatible = "adi,adis16488" },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, adis16480_of_match);
> +
>  static struct spi_driver adis16480_driver = {
>  	.driver = {
>  		.name = "adis16480",
> +		.of_match_table = adis16480_of_match,
>  	},
>  	.id_table = adis16480_ids,
>  	.probe = adis16480_probe,


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way
  2019-02-27 16:14 ` [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way Stefan Popa
@ 2019-03-03 12:47   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2019-03-03 12:47 UTC (permalink / raw)
  To: Stefan Popa
  Cc: robh+dt, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

On Wed, 27 Feb 2019 18:14:24 +0200
Stefan Popa <stefan.popa@analog.com> wrote:

> All supported devices provide internal temperature measurement from -40 C
> to +85 C, with +25 C representing value 0x00.
> 
> This patch treats the temperature scale in a generic way, similar to the
> accelerometer and gyroscope scales. So far, there are no temperature max
> scale differences between the supported devices. However, devices that
> will make use of this feature will be added in the future.
> 
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Applied.  Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16480.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index 150d814..5a2864a 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -124,6 +124,7 @@ struct adis16480_chip_info {
>  	unsigned int gyro_max_scale;
>  	unsigned int accel_max_val;
>  	unsigned int accel_max_scale;
> +	unsigned int temp_scale;
>  };
>  
>  enum adis16480_int_pin {
> @@ -530,6 +531,7 @@ static int adis16480_read_raw(struct iio_dev *indio_dev,
>  	const struct iio_chan_spec *chan, int *val, int *val2, long info)
>  {
>  	struct adis16480 *st = iio_priv(indio_dev);
> +	unsigned int temp;
>  
>  	switch (info) {
>  	case IIO_CHAN_INFO_RAW:
> @@ -549,8 +551,13 @@ static int adis16480_read_raw(struct iio_dev *indio_dev,
>  			*val2 = 100; /* 0.0001 gauss */
>  			return IIO_VAL_INT_PLUS_MICRO;
>  		case IIO_TEMP:
> -			*val = 5;
> -			*val2 = 650000; /* 5.65 milli degree Celsius */
> +			/*
> +			 * +85 degrees Celsius = temp_max_scale
> +			 * +25 degrees Celsius = 0
> +			 * LSB, 25 degrees Celsius  = 60 / temp_max_scale
> +			 */
> +			*val = st->chip_info->temp_scale / 1000;
> +			*val2 = (st->chip_info->temp_scale % 1000) * 1000;
>  			return IIO_VAL_INT_PLUS_MICRO;
>  		case IIO_PRESSURE:
>  			*val = 0;
> @@ -561,7 +568,8 @@ static int adis16480_read_raw(struct iio_dev *indio_dev,
>  		}
>  	case IIO_CHAN_INFO_OFFSET:
>  		/* Only the temperature channel has a offset */
> -		*val = 4425; /* 25 degree Celsius = 0x0000 */
> +		temp = 25 * 1000000LL; /* 25 degree Celsius = 0x0000 */
> +		*val = DIV_ROUND_CLOSEST_ULL(temp, st->chip_info->temp_scale);
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_CALIBBIAS:
>  		return adis16480_get_calibbias(indio_dev, chan, val);
> @@ -717,6 +725,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.gyro_max_scale = 300,
>  		.accel_max_val = IIO_M_S_2_TO_G(21973),
>  		.accel_max_scale = 18,
> +		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  	},
>  	[ADIS16480] = {
>  		.channels = adis16480_channels,
> @@ -725,6 +734,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.gyro_max_scale = 450,
>  		.accel_max_val = IIO_M_S_2_TO_G(12500),
>  		.accel_max_scale = 10,
> +		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  	},
>  	[ADIS16485] = {
>  		.channels = adis16485_channels,
> @@ -733,6 +743,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.gyro_max_scale = 450,
>  		.accel_max_val = IIO_M_S_2_TO_G(20000),
>  		.accel_max_scale = 5,
> +		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  	},
>  	[ADIS16488] = {
>  		.channels = adis16480_channels,
> @@ -741,6 +752,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.gyro_max_scale = 450,
>  		.accel_max_val = IIO_M_S_2_TO_G(22500),
>  		.accel_max_scale = 18,
> +		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  	},
>  };
>  


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency in a generic way
  2019-02-27 16:14 ` [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency " Stefan Popa
@ 2019-03-03 12:51   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2019-03-03 12:51 UTC (permalink / raw)
  To: Stefan Popa
  Cc: robh+dt, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

On Wed, 27 Feb 2019 18:14:25 +0200
Stefan Popa <stefan.popa@analog.com> wrote:

> The adis1648x devices have an internal clock of 2.46 kSPS. The sampling
> frequency is calculated by applying a decimation rate which can take the
> maximum value of 2047.
> 
> Although all adis1648x devices are similar in this regard, devices that
> will use this feature will be added in the future.
> 
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Straight forward refactor so fine.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

A comment inline about something in the old code!

Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16480.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index 5a2864a..92abc95 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -125,6 +125,8 @@ struct adis16480_chip_info {
>  	unsigned int accel_max_val;
>  	unsigned int accel_max_scale;
>  	unsigned int temp_scale;
> +	unsigned int int_clk;
> +	unsigned int max_dec_rate;
>  };
>  
>  enum adis16480_int_pin {
> @@ -299,9 +301,9 @@ static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2)
>  	if (t <= 0)
>  		return -EINVAL;
>  
> -	t = 2460000 / t;
> -	if (t > 2048)
> -		t = 2048;
> +	t = st->chip_info->int_clk / t;
> +	if (t > st->chip_info->max_dec_rate)
> +		t = st->chip_info->max_dec_rate;
>  
>  	if (t != 0)
>  		t--;
> @@ -320,7 +322,7 @@ static int adis16480_get_freq(struct iio_dev *indio_dev, int *val, int *val2)
>  	if (ret < 0)
>  		return ret;
>  
> -	freq = 2460000 / (t + 1);
> +	freq = st->chip_info->int_clk / (t + 1);

I'm a little curious about why t + 1?  Presumably to avoid weird rounding
issues, but maybe a nice addition would be a comment explaining this.

>  	*val = freq / 1000;
>  	*val2 = (freq % 1000) * 1000;
>  
> @@ -726,6 +728,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.accel_max_val = IIO_M_S_2_TO_G(21973),
>  		.accel_max_scale = 18,
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
> +		.int_clk = 2460000,
> +		.max_dec_rate = 2048,
>  	},
>  	[ADIS16480] = {
>  		.channels = adis16480_channels,
> @@ -735,6 +739,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.accel_max_val = IIO_M_S_2_TO_G(12500),
>  		.accel_max_scale = 10,
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
> +		.int_clk = 2460000,
> +		.max_dec_rate = 2048,
>  	},
>  	[ADIS16485] = {
>  		.channels = adis16485_channels,
> @@ -744,6 +750,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.accel_max_val = IIO_M_S_2_TO_G(20000),
>  		.accel_max_scale = 5,
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
> +		.int_clk = 2460000,
> +		.max_dec_rate = 2048,
>  	},
>  	[ADIS16488] = {
>  		.channels = adis16480_channels,
> @@ -753,6 +761,8 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.accel_max_val = IIO_M_S_2_TO_G(22500),
>  		.accel_max_scale = 18,
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
> +		.int_clk = 2460000,
> +		.max_dec_rate = 2048,
>  	},
>  };
>  


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq in a generic way
  2019-02-27 16:14 ` [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq " Stefan Popa
@ 2019-03-03 12:52   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2019-03-03 12:52 UTC (permalink / raw)
  To: Stefan Popa
  Cc: robh+dt, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

On Wed, 27 Feb 2019 18:14:26 +0200
Stefan Popa <stefan.popa@analog.com> wrote:

> When setting the filter frequency, the driver looks into the
> adis16480_def_filter_freqs table for the best match. Pass this table to
> the chip_info struct since future devices will need to use a different
> table.
> 
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16480.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index 92abc95..c90375d 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -127,6 +127,7 @@ struct adis16480_chip_info {
>  	unsigned int temp_scale;
>  	unsigned int int_clk;
>  	unsigned int max_dec_rate;
> +	const unsigned int *filter_freqs;
>  };
>  
>  enum adis16480_int_pin {
> @@ -483,7 +484,7 @@ static int adis16480_get_filter_freq(struct iio_dev *indio_dev,
>  	if (!(val & enable_mask))
>  		*freq = 0;
>  	else
> -		*freq = adis16480_def_filter_freqs[(val >> offset) & 0x3];
> +		*freq = st->chip_info->filter_freqs[(val >> offset) & 0x3];
>  
>  	return IIO_VAL_INT;
>  }
> @@ -510,10 +511,10 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev,
>  		val &= ~enable_mask;
>  	} else {
>  		best_freq = 0;
> -		best_diff = 310;
> +		best_diff = st->chip_info->filter_freqs[0];
>  		for (i = 0; i < ARRAY_SIZE(adis16480_def_filter_freqs); i++) {
> -			if (adis16480_def_filter_freqs[i] >= freq) {
> -				diff = adis16480_def_filter_freqs[i] - freq;
> +			if (st->chip_info->filter_freqs[i] >= freq) {
> +				diff = st->chip_info->filter_freqs[i] - freq;
>  				if (diff < best_diff) {
>  					best_diff = diff;
>  					best_freq = i;
> @@ -730,6 +731,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  		.int_clk = 2460000,
>  		.max_dec_rate = 2048,
> +		.filter_freqs = adis16480_def_filter_freqs,
>  	},
>  	[ADIS16480] = {
>  		.channels = adis16480_channels,
> @@ -741,6 +743,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  		.int_clk = 2460000,
>  		.max_dec_rate = 2048,
> +		.filter_freqs = adis16480_def_filter_freqs,
>  	},
>  	[ADIS16485] = {
>  		.channels = adis16485_channels,
> @@ -752,6 +755,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  		.int_clk = 2460000,
>  		.max_dec_rate = 2048,
> +		.filter_freqs = adis16480_def_filter_freqs,
>  	},
>  	[ADIS16488] = {
>  		.channels = adis16480_channels,
> @@ -763,6 +767,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.temp_scale = 5650, /* 5.65 milli degree Celsius */
>  		.int_clk = 2460000,
>  		.max_dec_rate = 2048,
> +		.filter_freqs = adis16480_def_filter_freqs,
>  	},
>  };
>  


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 6/7] iio: imu: adis16480: Add support for ADIS1649x family of devices
  2019-02-27 16:14 ` [PATCH v3 6/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
@ 2019-03-03 12:53   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2019-03-03 12:53 UTC (permalink / raw)
  To: Stefan Popa
  Cc: robh+dt, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

On Wed, 27 Feb 2019 18:14:27 +0200
Stefan Popa <stefan.popa@analog.com> wrote:

> The ADIS16495 and ADIS16497 are inertial systems that include a triaxis
> gyroscope and a triaxis accelerometer. The serial peripheral interface
> (SPI) provide a simple interface for data collection and configuration
> control. The devices are similar to ADIS16475, ADIS16480, ADIS16485 and
> ADIS16488, the main differences are highlighted below:
> 
> * The temperature data scale is 0.00565 C/LSB for ADIS16475 and ADIS1648x
>   devices, while for ADIS1649x 0.0125 C/LSB.
> 
> * ADIS1649x devices support different gyroscope measurement ranges which
>   are dependent on the dash number (-1, -2, -3), see Table 24 in the
>   ADIS16495 datasheet. However, the ADIS16497 gyroscopes have the same
>   scale as ADIS16495.
> 
> * ADIS16495 devices support the acceleration maximum range of 8g, while
>   ADIS16497 devices go up to 40g.
> 
> * The internal clock for ADIS1649x devices is 4.25 kSPS. The sampling
>   frequency is calculated by applying a decimation rate which can take a
>   maximum value of 4250.
> 
> * ADIS1649x devices support different default filter frequencies.
> 
> Datasheets:
> Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16495.pdf
> Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16497.pdf
> 
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Applied. Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16480.c | 97 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 97 insertions(+)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index c90375d..28cece3 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -453,6 +453,13 @@ static const unsigned int adis16480_def_filter_freqs[] = {
>  	63,
>  };
>  
> +static const unsigned int adis16495_def_filter_freqs[] = {
> +	300,
> +	100,
> +	300,
> +	100,
> +};
> +
>  static const unsigned int ad16480_filter_data[][2] = {
>  	[ADIS16480_SCAN_GYRO_X]		= { ADIS16480_REG_FILTER_BNK0, 0 },
>  	[ADIS16480_SCAN_GYRO_Y]		= { ADIS16480_REG_FILTER_BNK0, 3 },
> @@ -713,6 +720,12 @@ enum adis16480_variant {
>  	ADIS16480,
>  	ADIS16485,
>  	ADIS16488,
> +	ADIS16495_1,
> +	ADIS16495_2,
> +	ADIS16495_3,
> +	ADIS16497_1,
> +	ADIS16497_2,
> +	ADIS16497_3,
>  };
>  
>  static const struct adis16480_chip_info adis16480_chip_info[] = {
> @@ -769,6 +782,78 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
>  		.max_dec_rate = 2048,
>  		.filter_freqs = adis16480_def_filter_freqs,
>  	},
> +	[ADIS16495_1] = {
> +		.channels = adis16485_channels,
> +		.num_channels = ARRAY_SIZE(adis16485_channels),
> +		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
> +		.gyro_max_scale = 125,
> +		.accel_max_val = IIO_M_S_2_TO_G(32000),
> +		.accel_max_scale = 8,
> +		.temp_scale = 12500, /* 12.5 milli degree Celsius */
> +		.int_clk = 4250000,
> +		.max_dec_rate = 4250,
> +		.filter_freqs = adis16495_def_filter_freqs,
> +	},
> +	[ADIS16495_2] = {
> +		.channels = adis16485_channels,
> +		.num_channels = ARRAY_SIZE(adis16485_channels),
> +		.gyro_max_val = IIO_RAD_TO_DEGREE(18000),
> +		.gyro_max_scale = 450,
> +		.accel_max_val = IIO_M_S_2_TO_G(32000),
> +		.accel_max_scale = 8,
> +		.temp_scale = 12500, /* 12.5 milli degree Celsius */
> +		.int_clk = 4250000,
> +		.max_dec_rate = 4250,
> +		.filter_freqs = adis16495_def_filter_freqs,
> +	},
> +	[ADIS16495_3] = {
> +		.channels = adis16485_channels,
> +		.num_channels = ARRAY_SIZE(adis16485_channels),
> +		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
> +		.gyro_max_scale = 2000,
> +		.accel_max_val = IIO_M_S_2_TO_G(32000),
> +		.accel_max_scale = 8,
> +		.temp_scale = 12500, /* 12.5 milli degree Celsius */
> +		.int_clk = 4250000,
> +		.max_dec_rate = 4250,
> +		.filter_freqs = adis16495_def_filter_freqs,
> +	},
> +	[ADIS16497_1] = {
> +		.channels = adis16485_channels,
> +		.num_channels = ARRAY_SIZE(adis16485_channels),
> +		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
> +		.gyro_max_scale = 125,
> +		.accel_max_val = IIO_M_S_2_TO_G(32000),
> +		.accel_max_scale = 40,
> +		.temp_scale = 12500, /* 12.5 milli degree Celsius */
> +		.int_clk = 4250000,
> +		.max_dec_rate = 4250,
> +		.filter_freqs = adis16495_def_filter_freqs,
> +	},
> +	[ADIS16497_2] = {
> +		.channels = adis16485_channels,
> +		.num_channels = ARRAY_SIZE(adis16485_channels),
> +		.gyro_max_val = IIO_RAD_TO_DEGREE(18000),
> +		.gyro_max_scale = 450,
> +		.accel_max_val = IIO_M_S_2_TO_G(32000),
> +		.accel_max_scale = 40,
> +		.temp_scale = 12500, /* 12.5 milli degree Celsius */
> +		.int_clk = 4250000,
> +		.max_dec_rate = 4250,
> +		.filter_freqs = adis16495_def_filter_freqs,
> +	},
> +	[ADIS16497_3] = {
> +		.channels = adis16485_channels,
> +		.num_channels = ARRAY_SIZE(adis16485_channels),
> +		.gyro_max_val = IIO_RAD_TO_DEGREE(20000),
> +		.gyro_max_scale = 2000,
> +		.accel_max_val = IIO_M_S_2_TO_G(32000),
> +		.accel_max_scale = 40,
> +		.temp_scale = 12500, /* 12.5 milli degree Celsius */
> +		.int_clk = 4250000,
> +		.max_dec_rate = 4250,
> +		.filter_freqs = adis16495_def_filter_freqs,
> +	},
>  };
>  
>  static const struct iio_info adis16480_info = {
> @@ -1014,6 +1099,12 @@ static const struct spi_device_id adis16480_ids[] = {
>  	{ "adis16480", ADIS16480 },
>  	{ "adis16485", ADIS16485 },
>  	{ "adis16488", ADIS16488 },
> +	{ "adis16495-1", ADIS16495_1 },
> +	{ "adis16495-2", ADIS16495_2 },
> +	{ "adis16495-3", ADIS16495_3 },
> +	{ "adis16497-1", ADIS16497_1 },
> +	{ "adis16497-2", ADIS16497_2 },
> +	{ "adis16497-3", ADIS16497_3 },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(spi, adis16480_ids);
> @@ -1023,6 +1114,12 @@ static const struct of_device_id adis16480_of_match[] = {
>  	{ .compatible = "adi,adis16480" },
>  	{ .compatible = "adi,adis16485" },
>  	{ .compatible = "adi,adis16488" },
> +	{ .compatible = "adi,adis16495-1" },
> +	{ .compatible = "adi,adis16495-2" },
> +	{ .compatible = "adi,adis16495-3" },
> +	{ .compatible = "adi,adis16497-1" },
> +	{ .compatible = "adi,adis16497-2" },
> +	{ .compatible = "adi,adis16497-3" },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, adis16480_of_match);


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU
  2019-02-27 16:14 ` [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU Stefan Popa
@ 2019-03-03 12:54   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2019-03-03 12:54 UTC (permalink / raw)
  To: Stefan Popa
  Cc: robh+dt, Michael.Hennerich, knaack.h, lars, pmeerw, gregkh,
	linux-kernel, linux-iio, devicetree

On Wed, 27 Feb 2019 18:14:28 +0200
Stefan Popa <stefan.popa@analog.com> wrote:

> Document support for ADIS16480 Inertial Measurement Unit.
> 
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
> Reviewed-by: Rob Herring <robh@kernel.org>
Applied.

Thanks,

Jonathan

> ---
>  .../devicetree/bindings/iio/imu/adi,adis16480.txt  | 49 ++++++++++++++++++++++
>  MAINTAINERS                                        |  1 +
>  2 files changed, 50 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt
> 
> diff --git a/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt
> new file mode 100644
> index 0000000..39ab016
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt
> @@ -0,0 +1,49 @@
> +
> +Analog Devices ADIS16480 and similar IMUs
> +
> +Required properties for the ADIS16480:
> +
> +- compatible: Must be one of
> +	* "adi,adis16375"
> +	* "adi,adis16480"
> +	* "adi,adis16485"
> +	* "adi,adis16488"
> +	* "adi,adis16495-1"
> +	* "adi,adis16495-2"
> +	* "adi,adis16495-3"
> +	* "adi,adis16497-1"
> +	* "adi,adis16497-2"
> +	* "adi,adis16497-3"
> +- reg: SPI chip select number for the device
> +- spi-max-frequency: Max SPI frequency to use
> +	see: Documentation/devicetree/bindings/spi/spi-bus.txt
> +- spi-cpha: See Documentation/devicetree/bindings/spi/spi-bus.txt
> +- spi-cpol: See Documentation/devicetree/bindings/spi/spi-bus.txt
> +- interrupts: interrupt mapping for IRQ, accepted values are:
> +	* IRQF_TRIGGER_RISING
> +	* IRQF_TRIGGER_FALLING
> +
> +Optional properties:
> +
> +- interrupt-names: Data ready line selection. Valid values are:
> +	* DIO1
> +	* DIO2
> +	* DIO3
> +	* DIO4
> +	If this field is left empty, DIO1 is assigned as default data ready
> +	signal.
> +- reset-gpios: must be the device tree identifier of the RESET pin. As the line
> +	is active low, it should be marked GPIO_ACTIVE_LOW.
> +
> +Example:
> +
> +	imu@0 {
> +		compatible = "adi,adis16495-1";
> +		reg = <0>;
> +		spi-max-frequency = <3200000>;
> +		spi-cpol;
> +		spi-cpha;
> +		interrupts = <25 IRQF_TRIGGER_FALLING>;
> +		interrupt-parent = <&gpio>;
> +		interrupt-names = "DIO2";
> +	};
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e4091ac..beecd1e 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -942,6 +942,7 @@ F:	drivers/dma/dma-axi-dmac.c
>  ANALOG DEVICES INC IIO DRIVERS
>  M:	Lars-Peter Clausen <lars@metafoo.de>
>  M:	Michael Hennerich <Michael.Hennerich@analog.com>
> +M:	Stefan Popa <stefan.popa@analog.com>
>  W:	http://wiki.analog.com/
>  W:	http://ez.analog.com/community/linux-device-drivers
>  S:	Supported


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-03-03 12:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 16:14 [PATCH v3 0/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
2019-02-27 16:14 ` [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator Stefan Popa
2019-03-03 12:46   ` Jonathan Cameron
2019-02-27 16:14 ` [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table Stefan Popa
2019-03-03 12:46   ` Jonathan Cameron
2019-02-27 16:14 ` [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way Stefan Popa
2019-03-03 12:47   ` Jonathan Cameron
2019-02-27 16:14 ` [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency " Stefan Popa
2019-03-03 12:51   ` Jonathan Cameron
2019-02-27 16:14 ` [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq " Stefan Popa
2019-03-03 12:52   ` Jonathan Cameron
2019-02-27 16:14 ` [PATCH v3 6/7] iio: imu: adis16480: Add support for ADIS1649x family of devices Stefan Popa
2019-03-03 12:53   ` Jonathan Cameron
2019-02-27 16:14 ` [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU Stefan Popa
2019-03-03 12:54   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).