iio: imu: adis16480: Add support for ADIS1649x family of devices
Subsystems (3)
v3 cover iio: imu: adis16480: Add support for ADIS1649x family of devices
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
Signature · 1 line
2.7.4
PATCH v3 1/7 iio: imu: adis16480: Add support for configurable drdy indicator
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.
--- drivers/iio/imu/adis16480.c | 97 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-)
drivers/iio/imu/adis16480.c +95 -2
@@ -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;
Signature · 1 line
2.7.4
PATCH v3 2/7 iio: imu: adis16480: Add OF device ID table
In reply to Stefan PopaThe 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.
--- drivers/iio/imu/adis16480.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/iio/imu/adis16480.c +10 -0
@@ -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,
Signature · 1 line
2.7.4
PATCH v3 3/7 iio: imu: adis16480: Treat temperature scale in a generic way
In reply to Stefan PopaAll 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.
--- drivers/iio/imu/adis16480.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/iio/imu/adis16480.c +15 -3
@@ -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 */ }, };
Signature · 1 line
2.7.4
PATCH v3 4/7 iio: imu: adis16480: Calculate the sampling frequency in a generic way
In reply to Stefan PopaThe 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.
--- drivers/iio/imu/adis16480.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/iio/imu/adis16480.c +14 -4
@@ -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, }, };
Signature · 1 line
2.7.4
PATCH v3 5/7 iio: imu: adis16480: Deal with filter freq in a generic way
In reply to Stefan PopaWhen 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.
--- drivers/iio/imu/adis16480.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/iio/imu/adis16480.c +9 -4
@@ -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, }, };
Signature · 1 line
2.7.4
PATCH v3 6/7 iio: imu: adis16480: Add support for ADIS1649x family of devices
In reply to Stefan PopaThe 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:
--- drivers/iio/imu/adis16480.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
drivers/iio/imu/adis16480.c +97 -0
@@ -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);
Signature · 1 line
2.7.4
PATCH v3 7/7 iio: imu: adis16480: Add docs for ADIS16480 IMU
In reply to Stefan PopaDocument support for ADIS16480 Inertial Measurement Unit.
--- .../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
Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt new file +49 -0
@@ -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"; + };
MAINTAINERS +1 -0
@@ -942,6 +942,7 @@ F: drivers/dma/dma-axi-dmac.c ANALOG DEVICES INC IIO DRIVERS M: Lars-Peter Clausen <[email protected]> M: Michael Hennerich <[email protected]> +M: Stefan Popa <[email protected]> W: http://wiki.analog.com/ W: http://ez.analog.com/community/linux-device-drivers S: Supported
Signature · 1 line
2.7.4
Jonathan Cameron
maintainerRe: [PATCH v3 1/7] iio: imu: adis16480: Add support for configurable drdy indicator
In reply to Stefan PopaQuoted 9 lines · On Wed, 27 Feb 2019 18:14:22 +0200 Stefan Popa <[email protected]> wrote:
The
FNCTIO_CTRLregister 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.
Quoted 6 lines
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 <[email protected]>
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
Quoted 153 lines
--- drivers/iio/imu/adis16480.c | 97 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-)drivers/iio/imu/adis16480.c +95
-2@@ -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;
Jonathan Cameron
maintainerRe: [PATCH v3 2/7] iio: imu: adis16480: Add OF device ID table
In reply to Stefan PopaQuoted 5 lines · On Wed, 27 Feb 2019 18:14:23 +0200 Stefan Popa <[email protected]> wrote:
The driver does not have a struct
of_device_idtable, but supported devices are registered via Device Trees. This patch adds OF device ID table.Signed-off-by Stefan Popa <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 28 lines
--- drivers/iio/imu/adis16480.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/iio/imu/adis16480.c +10
-0@@ -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,
Re: [PATCH v3 3/7] iio: imu: adis16480: Treat temperature scale in a generic way
In reply to Stefan PopaQuoted 9 lines · On Wed, 27 Feb 2019 18:14:24 +0200 Stefan Popa <[email protected]> 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 <[email protected]>
Applied. Thanks,
Jonathan
Quoted 82 lines
--- drivers/iio/imu/adis16480.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)drivers/iio/imu/adis16480.c +15
-3@@ -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 */ }, };
Jonathan Cameron
maintainerRe: [PATCH v3 4/7] iio: imu: adis16480: Calculate the sampling frequency in a generic way
In reply to Stefan PopaQuoted 8 lines · On Wed, 27 Feb 2019 18:14:25 +0200 Stefan Popa <[email protected]> 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 <[email protected]>
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
Quoted 31 lines
--- drivers/iio/imu/adis16480.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/iio/imu/adis16480.c +5
-3@@ -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--;
drivers/iio/imu/adis16480.c static int adis16480_get_freq(struct iio_dev *indio_dev, int *val, int *val2) · line 325
Quoted 5 lines
drivers/iio/imu/adis16480.c +1
-1@@ -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.
Quoted 39 lines
drivers/iio/imu/adis16480.c +8
-0*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, }, };
Jonathan Cameron
maintainerRe: [PATCH v3 5/7] iio: imu: adis16480: Deal with filter freq in a generic way
In reply to Stefan PopaQuoted 6 lines · On Wed, 27 Feb 2019 18:14:26 +0200 Stefan Popa <[email protected]> wrote:
When setting the filter frequency, the driver looks into the
adis16480_def_filter_freqstable for the best match. Pass this table to thechip_infostruct since future devices will need to use a different table.Signed-off-by Stefan Popa <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 71 lines
--- drivers/iio/imu/adis16480.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/iio/imu/adis16480.c +9
-4@@ -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, }, };
Quoted 21 lines · On Wed, 27 Feb 2019 18:14:27 +0200 Stefan Popa <[email protected]> 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.
Quoted 7 lines
* ADIS1649x devices support different default filter frequencies.
Datasheets:
Signed-off-by Stefan Popa <[email protected]>
Applied. Thanks,
Jonathan
Quoted 140 lines
--- drivers/iio/imu/adis16480.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)drivers/iio/imu/adis16480.c +97
-0@@ -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);
Re: [PATCH v3 7/7] iio: imu: adis16480: Add docs for ADIS16480 IMU
In reply to Stefan PopaQuoted 4 lines · On Wed, 27 Feb 2019 18:14:28 +0200 Stefan Popa <[email protected]> wrote:
Document support for ADIS16480 Inertial Measurement Unit.
Signed-off-by Stefan Popa <[email protected]>Reviewed-by Rob Herring <[email protected]>
Applied.
Thanks,
Jonathan
Quoted 73 lines
--- .../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.txtDocumentation/devicetree/bindings/iio/imu/adi,adis16480.txt new file +49
-0@@ -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"; + };MAINTAINERS +1
-0@@ -942,6 +942,7 @@ F: drivers/dma/dma-axi-dmac.c ANALOG DEVICES INC IIO DRIVERS M: Lars-Peter Clausen <[email protected]> M: Michael Hennerich <[email protected]> +M: Stefan Popa <[email protected]> W: http://wiki.analog.com/ W: http://ez.analog.com/community/linux-device-drivers S: Supported