1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright 2019 Analog Devices Inc.
7 #include <linux/bitfield.h>
8 #include <linux/bitops.h>
10 #include <linux/debugfs.h>
11 #include <linux/delay.h>
12 #include <linux/device.h>
13 #include <linux/kernel.h>
14 #include <linux/iio/buffer.h>
15 #include <linux/iio/iio.h>
16 #include <linux/iio/imu/adis.h>
17 #include <linux/iio/sysfs.h>
18 #include <linux/iio/trigger_consumer.h>
19 #include <linux/irq.h>
20 #include <linux/lcm.h>
21 #include <linux/math.h>
22 #include <linux/module.h>
23 #include <linux/mod_devicetable.h>
24 #include <linux/property.h>
25 #include <linux/spi/spi.h>
27 #define ADIS16475_REG_DIAG_STAT 0x02
28 #define ADIS16475_REG_X_GYRO_L 0x04
29 #define ADIS16475_REG_Y_GYRO_L 0x08
30 #define ADIS16475_REG_Z_GYRO_L 0x0C
31 #define ADIS16475_REG_X_ACCEL_L 0x10
32 #define ADIS16475_REG_Y_ACCEL_L 0x14
33 #define ADIS16475_REG_Z_ACCEL_L 0x18
34 #define ADIS16475_REG_TEMP_OUT 0x1c
35 #define ADIS16475_REG_X_DELTANG_L 0x24
36 #define ADIS16475_REG_Y_DELTANG_L 0x28
37 #define ADIS16475_REG_Z_DELTANG_L 0x2C
38 #define ADIS16475_REG_X_DELTVEL_L 0x30
39 #define ADIS16475_REG_Y_DELTVEL_L 0x34
40 #define ADIS16475_REG_Z_DELTVEL_L 0x38
41 #define ADIS16475_REG_X_GYRO_BIAS_L 0x40
42 #define ADIS16475_REG_Y_GYRO_BIAS_L 0x44
43 #define ADIS16475_REG_Z_GYRO_BIAS_L 0x48
44 #define ADIS16475_REG_X_ACCEL_BIAS_L 0x4c
45 #define ADIS16475_REG_Y_ACCEL_BIAS_L 0x50
46 #define ADIS16475_REG_Z_ACCEL_BIAS_L 0x54
47 #define ADIS16475_REG_FILT_CTRL 0x5c
48 #define ADIS16475_FILT_CTRL_MASK GENMASK(2, 0)
49 #define ADIS16475_FILT_CTRL(x) FIELD_PREP(ADIS16475_FILT_CTRL_MASK, x)
50 #define ADIS16475_REG_MSG_CTRL 0x60
51 #define ADIS16475_MSG_CTRL_DR_POL_MASK BIT(0)
52 #define ADIS16475_MSG_CTRL_DR_POL(x) \
53 FIELD_PREP(ADIS16475_MSG_CTRL_DR_POL_MASK, x)
54 #define ADIS16475_SYNC_MODE_MASK GENMASK(4, 2)
55 #define ADIS16475_SYNC_MODE(x) FIELD_PREP(ADIS16475_SYNC_MODE_MASK, x)
56 #define ADIS16575_SYNC_4KHZ_MASK BIT(11)
57 #define ADIS16575_SYNC_4KHZ(x) FIELD_PREP(ADIS16575_SYNC_4KHZ_MASK, x)
58 #define ADIS16475_REG_UP_SCALE 0x62
59 #define ADIS16475_REG_DEC_RATE 0x64
60 #define ADIS16475_REG_GLOB_CMD 0x68
61 #define ADIS16475_REG_FIRM_REV 0x6c
62 #define ADIS16475_REG_FIRM_DM 0x6e
63 #define ADIS16475_REG_FIRM_Y 0x70
64 #define ADIS16475_REG_PROD_ID 0x72
65 #define ADIS16475_REG_SERIAL_NUM 0x74
66 #define ADIS16475_REG_FLASH_CNT 0x7c
67 #define ADIS16500_BURST_DATA_SEL_MASK BIT(8)
68 #define ADIS16500_BURST32_MASK BIT(9)
69 #define ADIS16500_BURST32(x) FIELD_PREP(ADIS16500_BURST32_MASK, x)
70 /* number of data elements in burst mode */
71 #define ADIS16475_BURST32_MAX_DATA_NO_TS32 32
72 #define ADIS16575_BURST32_DATA_TS32 34
73 #define ADIS16475_BURST_MAX_DATA 20
74 #define ADIS16475_MAX_SCAN_DATA 20
75 /* spi max speed in brust mode */
76 #define ADIS16475_BURST_MAX_SPEED 1000000
77 #define ADIS16575_BURST_MAX_SPEED 8000000
78 #define ADIS16475_LSB_DEC_MASK 0
79 #define ADIS16475_LSB_FIR_MASK 1
80 #define ADIS16500_BURST_DATA_SEL_0_CHN_MASK GENMASK(5, 0)
81 #define ADIS16500_BURST_DATA_SEL_1_CHN_MASK GENMASK(12, 7)
82 #define ADIS16575_MAX_FIFO_WM 511UL
83 #define ADIS16475_REG_FIFO_CTRL 0x5A
84 #define ADIS16575_WM_LVL_MASK GENMASK(15, 4)
85 #define ADIS16575_WM_LVL(x) FIELD_PREP(ADIS16575_WM_LVL_MASK, x)
86 #define ADIS16575_WM_POL_MASK BIT(3)
87 #define ADIS16575_WM_POL(x) FIELD_PREP(ADIS16575_WM_POL_MASK, x)
88 #define ADIS16575_WM_EN_MASK BIT(2)
89 #define ADIS16575_WM_EN(x) FIELD_PREP(ADIS16575_WM_EN_MASK, x)
90 #define ADIS16575_OVERFLOW_MASK BIT(1)
91 #define ADIS16575_STOP_ENQUEUE FIELD_PREP(ADIS16575_OVERFLOW_MASK, 0)
92 #define ADIS16575_OVERWRITE_OLDEST FIELD_PREP(ADIS16575_OVERFLOW_MASK, 1)
93 #define ADIS16575_FIFO_EN_MASK BIT(0)
94 #define ADIS16575_FIFO_EN(x) FIELD_PREP(ADIS16575_FIFO_EN_MASK, x)
95 #define ADIS16575_FIFO_FLUSH_CMD BIT(5)
96 #define ADIS16575_REG_FIFO_CNT 0x3C
99 ADIS16475_SYNC_DIRECT = 1,
100 ADIS16475_SYNC_SCALED,
101 ADIS16475_SYNC_OUTPUT,
102 ADIS16475_SYNC_PULSE = 5,
105 struct adis16475_sync {
111 struct adis16475_chip_info {
112 const struct iio_chan_spec *channels;
113 const struct adis16475_sync *sync;
114 const struct adis_data adis_data;
116 #define ADIS16475_HAS_BURST32 BIT(0)
117 #define ADIS16475_HAS_BURST_DELTA_DATA BIT(1)
118 #define ADIS16475_HAS_TIMESTAMP32 BIT(2)
119 #define ADIS16475_NEEDS_BURST_REQUEST BIT(3)
135 const struct adis16475_chip_info *info;
139 unsigned long lsb_flag;
142 /* Alignment needed for the timestamp */
143 __be16 data[ADIS16475_MAX_SCAN_DATA] __aligned(8);
147 ADIS16475_SCAN_GYRO_X,
148 ADIS16475_SCAN_GYRO_Y,
149 ADIS16475_SCAN_GYRO_Z,
150 ADIS16475_SCAN_ACCEL_X,
151 ADIS16475_SCAN_ACCEL_Y,
152 ADIS16475_SCAN_ACCEL_Z,
154 ADIS16475_SCAN_DELTANG_X,
155 ADIS16475_SCAN_DELTANG_Y,
156 ADIS16475_SCAN_DELTANG_Z,
157 ADIS16475_SCAN_DELTVEL_X,
158 ADIS16475_SCAN_DELTVEL_Y,
159 ADIS16475_SCAN_DELTVEL_Z,
162 static bool low_rate_allow;
163 module_param(low_rate_allow, bool, 0444);
164 MODULE_PARM_DESC(low_rate_allow,
165 "Allow IMU rates below the minimum advisable when external clk is used in SCALED mode (default: N)");
167 #ifdef CONFIG_DEBUG_FS
168 static ssize_t adis16475_show_firmware_revision(struct file *file,
169 char __user *userbuf,
170 size_t count, loff_t *ppos)
172 struct adis16475 *st = file->private_data;
178 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIRM_REV, &rev);
182 len = scnprintf(buf, sizeof(buf), "%x.%x\n", rev >> 8, rev & 0xff);
184 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
187 static const struct file_operations adis16475_firmware_revision_fops = {
189 .read = adis16475_show_firmware_revision,
190 .llseek = default_llseek,
191 .owner = THIS_MODULE,
194 static ssize_t adis16475_show_firmware_date(struct file *file,
195 char __user *userbuf,
196 size_t count, loff_t *ppos)
198 struct adis16475 *st = file->private_data;
204 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIRM_Y, &year);
208 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIRM_DM, &md);
212 len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n", md >> 8, md & 0xff,
215 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
218 static const struct file_operations adis16475_firmware_date_fops = {
220 .read = adis16475_show_firmware_date,
221 .llseek = default_llseek,
222 .owner = THIS_MODULE,
225 static int adis16475_show_serial_number(void *arg, u64 *val)
227 struct adis16475 *st = arg;
231 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_SERIAL_NUM, &serial);
239 DEFINE_DEBUGFS_ATTRIBUTE(adis16475_serial_number_fops,
240 adis16475_show_serial_number, NULL, "0x%.4llx\n");
242 static int adis16475_show_product_id(void *arg, u64 *val)
244 struct adis16475 *st = arg;
248 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_PROD_ID, &prod_id);
256 DEFINE_DEBUGFS_ATTRIBUTE(adis16475_product_id_fops,
257 adis16475_show_product_id, NULL, "%llu\n");
259 static int adis16475_show_flash_count(void *arg, u64 *val)
261 struct adis16475 *st = arg;
265 ret = adis_read_reg_32(&st->adis, ADIS16475_REG_FLASH_CNT,
274 DEFINE_DEBUGFS_ATTRIBUTE(adis16475_flash_count_fops,
275 adis16475_show_flash_count, NULL, "%lld\n");
277 static void adis16475_debugfs_init(struct iio_dev *indio_dev)
279 struct adis16475 *st = iio_priv(indio_dev);
280 struct dentry *d = iio_get_debugfs_dentry(indio_dev);
282 debugfs_create_file_unsafe("serial_number", 0400,
283 d, st, &adis16475_serial_number_fops);
284 debugfs_create_file_unsafe("product_id", 0400,
285 d, st, &adis16475_product_id_fops);
286 debugfs_create_file_unsafe("flash_count", 0400,
287 d, st, &adis16475_flash_count_fops);
288 debugfs_create_file("firmware_revision", 0400,
289 d, st, &adis16475_firmware_revision_fops);
290 debugfs_create_file("firmware_date", 0400, d,
291 st, &adis16475_firmware_date_fops);
294 static void adis16475_debugfs_init(struct iio_dev *indio_dev)
299 static int adis16475_get_freq(struct adis16475 *st, u32 *freq)
303 u32 sample_rate = st->clk_freq;
305 adis_dev_auto_lock(&st->adis);
307 if (st->sync_mode == ADIS16475_SYNC_SCALED) {
310 ret = __adis_read_reg_16(&st->adis, ADIS16475_REG_UP_SCALE, &sync_scale);
314 sample_rate = st->clk_freq * sync_scale;
317 ret = __adis_read_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, &dec);
321 *freq = DIV_ROUND_CLOSEST(sample_rate, dec + 1);
326 static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
330 u32 sample_rate = st->clk_freq;
331 /* The optimal sample rate for the supported IMUs is between int_clk - 100 and int_clk + 100. */
332 u32 max_sample_rate = st->info->int_clk * 1000 + 100000;
333 u32 min_sample_rate = st->info->int_clk * 1000 - 100000;
338 adis_dev_auto_lock(&st->adis);
340 * When using sync scaled mode, the input clock needs to be scaled so that we have
341 * an IMU sample rate between (optimally) int_clk - 100 and int_clk + 100.
342 * After this, we can use the decimation filter to lower the sampling rate in order
343 * to get what the user wants.
344 * Optimally, the user sample rate is a multiple of both the IMU sample rate and
345 * the input clock. Hence, calculating the sync_scale dynamically gives us better
346 * chances of achieving a perfect/integer value for DEC_RATE. The math here is:
347 * 1. lcm of the input clock and the desired output rate.
348 * 2. get the highest multiple of the previous result lower than the adis max rate.
349 * 3. The last result becomes the IMU sample rate. Use that to calculate SYNC_SCALE
350 * and DEC_RATE (to get the user output rate)
352 if (st->sync_mode == ADIS16475_SYNC_SCALED) {
353 unsigned long scaled_rate = lcm(st->clk_freq, freq);
357 * If lcm is bigger than the IMU maximum sampling rate there's no perfect
358 * solution. In this case, we get the highest multiple of the input clock
359 * lower than the IMU max sample rate.
361 if (scaled_rate > max_sample_rate)
362 scaled_rate = max_sample_rate / st->clk_freq * st->clk_freq;
364 scaled_rate = max_sample_rate / scaled_rate * scaled_rate;
367 * This is not an hard requirement but it's not advised to run the IMU
368 * with a sample rate lower than internal clock frequency, due to possible
369 * undersampling issues. However, there are users that might really want
370 * to take the risk. Hence, we provide a module parameter for them. If set,
371 * we allow sample rates lower than internal clock frequency.
372 * By default, we won't allow this and we just roundup the rate to the next
373 * multiple of the input clock. This is done like this as in some cases
374 * (when DEC_RATE is 0) might give us the closest value to the one desired
377 if (scaled_rate < min_sample_rate && !low_rate_allow)
378 scaled_rate = roundup(min_sample_rate, st->clk_freq);
380 sync_scale = scaled_rate / st->clk_freq;
381 ret = __adis_write_reg_16(&st->adis, ADIS16475_REG_UP_SCALE, sync_scale);
385 sample_rate = scaled_rate;
388 dec = DIV_ROUND_CLOSEST(sample_rate, freq);
393 if (dec > st->info->max_dec)
394 dec = st->info->max_dec;
396 ret = __adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
401 * If decimation is used, then gyro and accel data will have meaningful
402 * bits on the LSB registers. This info is used on the trigger handler.
404 assign_bit(ADIS16475_LSB_DEC_MASK, &st->lsb_flag, dec);
409 /* The values are approximated. */
410 static const u32 adis16475_3db_freqs[] = {
411 [0] = 720, /* Filter disabled, full BW (~720Hz) */
420 static int adis16475_get_filter(struct adis16475 *st, u32 *filter)
424 const int mask = ADIS16475_FILT_CTRL_MASK;
426 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FILT_CTRL, &filter_sz);
430 *filter = adis16475_3db_freqs[filter_sz & mask];
435 static int adis16475_set_filter(struct adis16475 *st, const u32 filter)
437 int i = ARRAY_SIZE(adis16475_3db_freqs);
441 if (adis16475_3db_freqs[i] >= filter)
445 ret = adis_write_reg_16(&st->adis, ADIS16475_REG_FILT_CTRL,
446 ADIS16475_FILT_CTRL(i));
451 * If FIR is used, then gyro and accel data will have meaningful
452 * bits on the LSB registers. This info is used on the trigger handler.
454 assign_bit(ADIS16475_LSB_FIR_MASK, &st->lsb_flag, i);
459 static ssize_t adis16475_get_fifo_enabled(struct device *dev,
460 struct device_attribute *attr,
463 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
464 struct adis16475 *st = iio_priv(indio_dev);
468 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIFO_CTRL, &val);
472 return sysfs_emit(buf, "%lu\n", FIELD_GET(ADIS16575_FIFO_EN_MASK, val));
475 static ssize_t adis16475_get_fifo_watermark(struct device *dev,
476 struct device_attribute *attr,
479 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
480 struct adis16475 *st = iio_priv(indio_dev);
484 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIFO_CTRL, &val);
488 return sysfs_emit(buf, "%lu\n", FIELD_GET(ADIS16575_WM_LVL_MASK, val) + 1);
491 static ssize_t hwfifo_watermark_min_show(struct device *dev,
492 struct device_attribute *attr,
495 return sysfs_emit(buf, "1\n");
498 static ssize_t hwfifo_watermark_max_show(struct device *dev,
499 struct device_attribute *attr,
502 return sysfs_emit(buf, "%lu\n", ADIS16575_MAX_FIFO_WM);
505 static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
506 static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
507 static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
508 adis16475_get_fifo_watermark, NULL, 0);
509 static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
510 adis16475_get_fifo_enabled, NULL, 0);
512 static const struct iio_dev_attr *adis16475_fifo_attributes[] = {
513 &iio_dev_attr_hwfifo_watermark_min,
514 &iio_dev_attr_hwfifo_watermark_max,
515 &iio_dev_attr_hwfifo_watermark,
516 &iio_dev_attr_hwfifo_enabled,
520 static int adis16475_buffer_postenable(struct iio_dev *indio_dev)
522 struct adis16475 *st = iio_priv(indio_dev);
523 struct adis *adis = &st->adis;
525 return adis_update_bits(adis, ADIS16475_REG_FIFO_CTRL,
526 ADIS16575_FIFO_EN_MASK, (u16)ADIS16575_FIFO_EN(1));
529 static int adis16475_buffer_postdisable(struct iio_dev *indio_dev)
531 struct adis16475 *st = iio_priv(indio_dev);
532 struct adis *adis = &st->adis;
535 adis_dev_auto_lock(&st->adis);
537 ret = __adis_update_bits(adis, ADIS16475_REG_FIFO_CTRL,
538 ADIS16575_FIFO_EN_MASK, (u16)ADIS16575_FIFO_EN(0));
542 return __adis_write_reg_16(adis, ADIS16475_REG_GLOB_CMD,
543 ADIS16575_FIFO_FLUSH_CMD);
546 static const struct iio_buffer_setup_ops adis16475_buffer_ops = {
547 .postenable = adis16475_buffer_postenable,
548 .postdisable = adis16475_buffer_postdisable,
551 static int adis16475_set_watermark(struct iio_dev *indio_dev, unsigned int val)
553 struct adis16475 *st = iio_priv(indio_dev);
557 adis_dev_auto_lock(&st->adis);
559 val = min_t(unsigned int, val, ADIS16575_MAX_FIFO_WM);
561 wm_lvl = ADIS16575_WM_LVL(val - 1);
562 ret = __adis_update_bits(&st->adis, ADIS16475_REG_FIFO_CTRL, ADIS16575_WM_LVL_MASK, wm_lvl);
566 st->fifo_watermark = val;
571 static const u32 adis16475_calib_regs[] = {
572 [ADIS16475_SCAN_GYRO_X] = ADIS16475_REG_X_GYRO_BIAS_L,
573 [ADIS16475_SCAN_GYRO_Y] = ADIS16475_REG_Y_GYRO_BIAS_L,
574 [ADIS16475_SCAN_GYRO_Z] = ADIS16475_REG_Z_GYRO_BIAS_L,
575 [ADIS16475_SCAN_ACCEL_X] = ADIS16475_REG_X_ACCEL_BIAS_L,
576 [ADIS16475_SCAN_ACCEL_Y] = ADIS16475_REG_Y_ACCEL_BIAS_L,
577 [ADIS16475_SCAN_ACCEL_Z] = ADIS16475_REG_Z_ACCEL_BIAS_L,
580 static int adis16475_read_raw(struct iio_dev *indio_dev,
581 const struct iio_chan_spec *chan,
582 int *val, int *val2, long info)
584 struct adis16475 *st = iio_priv(indio_dev);
589 case IIO_CHAN_INFO_RAW:
590 return adis_single_conversion(indio_dev, chan, 0, val);
591 case IIO_CHAN_INFO_SCALE:
592 switch (chan->type) {
594 *val = st->info->gyro_max_val;
595 *val2 = st->info->gyro_max_scale;
596 return IIO_VAL_FRACTIONAL;
598 *val = st->info->accel_max_val;
599 *val2 = st->info->accel_max_scale;
600 return IIO_VAL_FRACTIONAL;
602 *val = st->info->temp_scale;
605 *val = st->info->deltang_max_val;
607 return IIO_VAL_FRACTIONAL_LOG2;
608 case IIO_DELTA_VELOCITY:
609 *val = st->info->deltvel_max_val;
611 return IIO_VAL_FRACTIONAL_LOG2;
615 case IIO_CHAN_INFO_CALIBBIAS:
616 ret = adis_read_reg_32(&st->adis,
617 adis16475_calib_regs[chan->scan_index],
623 case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
624 ret = adis16475_get_filter(st, val);
629 case IIO_CHAN_INFO_SAMP_FREQ:
630 ret = adis16475_get_freq(st, &tmp);
635 *val2 = (tmp % 1000) * 1000;
636 return IIO_VAL_INT_PLUS_MICRO;
642 static int adis16475_write_raw(struct iio_dev *indio_dev,
643 const struct iio_chan_spec *chan,
644 int val, int val2, long info)
646 struct adis16475 *st = iio_priv(indio_dev);
650 case IIO_CHAN_INFO_SAMP_FREQ:
651 tmp = val * 1000 + val2 / 1000;
652 return adis16475_set_freq(st, tmp);
653 case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
654 return adis16475_set_filter(st, val);
655 case IIO_CHAN_INFO_CALIBBIAS:
656 return adis_write_reg_32(&st->adis,
657 adis16475_calib_regs[chan->scan_index],
664 #define ADIS16475_MOD_CHAN(_type, _mod, _address, _si, _r_bits, _s_bits) \
668 .channel2 = (_mod), \
669 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
670 BIT(IIO_CHAN_INFO_CALIBBIAS), \
671 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
672 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
673 BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
674 .address = (_address), \
675 .scan_index = (_si), \
678 .realbits = (_r_bits), \
679 .storagebits = (_s_bits), \
680 .endianness = IIO_BE, \
684 #define ADIS16475_GYRO_CHANNEL(_mod) \
685 ADIS16475_MOD_CHAN(IIO_ANGL_VEL, IIO_MOD_ ## _mod, \
686 ADIS16475_REG_ ## _mod ## _GYRO_L, \
687 ADIS16475_SCAN_GYRO_ ## _mod, 32, 32)
689 #define ADIS16475_ACCEL_CHANNEL(_mod) \
690 ADIS16475_MOD_CHAN(IIO_ACCEL, IIO_MOD_ ## _mod, \
691 ADIS16475_REG_ ## _mod ## _ACCEL_L, \
692 ADIS16475_SCAN_ACCEL_ ## _mod, 32, 32)
694 #define ADIS16475_TEMP_CHANNEL() { \
698 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
699 BIT(IIO_CHAN_INFO_SCALE), \
700 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
701 BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
702 .address = ADIS16475_REG_TEMP_OUT, \
703 .scan_index = ADIS16475_SCAN_TEMP, \
708 .endianness = IIO_BE, \
712 #define ADIS16475_MOD_CHAN_DELTA(_type, _mod, _address, _si, _r_bits, _s_bits) { \
715 .channel2 = (_mod), \
716 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
717 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
718 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
719 BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
720 .address = (_address), \
724 .realbits = (_r_bits), \
725 .storagebits = (_s_bits), \
726 .endianness = IIO_BE, \
730 #define ADIS16475_DELTANG_CHAN(_mod) \
731 ADIS16475_MOD_CHAN_DELTA(IIO_DELTA_ANGL, IIO_MOD_ ## _mod, \
732 ADIS16475_REG_ ## _mod ## _DELTANG_L, ADIS16475_SCAN_DELTANG_ ## _mod, 32, 32)
734 #define ADIS16475_DELTVEL_CHAN(_mod) \
735 ADIS16475_MOD_CHAN_DELTA(IIO_DELTA_VELOCITY, IIO_MOD_ ## _mod, \
736 ADIS16475_REG_ ## _mod ## _DELTVEL_L, ADIS16475_SCAN_DELTVEL_ ## _mod, 32, 32)
738 #define ADIS16475_DELTANG_CHAN_NO_SCAN(_mod) \
739 ADIS16475_MOD_CHAN_DELTA(IIO_DELTA_ANGL, IIO_MOD_ ## _mod, \
740 ADIS16475_REG_ ## _mod ## _DELTANG_L, -1, 32, 32)
742 #define ADIS16475_DELTVEL_CHAN_NO_SCAN(_mod) \
743 ADIS16475_MOD_CHAN_DELTA(IIO_DELTA_VELOCITY, IIO_MOD_ ## _mod, \
744 ADIS16475_REG_ ## _mod ## _DELTVEL_L, -1, 32, 32)
746 static const struct iio_chan_spec adis16477_channels[] = {
747 ADIS16475_GYRO_CHANNEL(X),
748 ADIS16475_GYRO_CHANNEL(Y),
749 ADIS16475_GYRO_CHANNEL(Z),
750 ADIS16475_ACCEL_CHANNEL(X),
751 ADIS16475_ACCEL_CHANNEL(Y),
752 ADIS16475_ACCEL_CHANNEL(Z),
753 ADIS16475_TEMP_CHANNEL(),
754 ADIS16475_DELTANG_CHAN(X),
755 ADIS16475_DELTANG_CHAN(Y),
756 ADIS16475_DELTANG_CHAN(Z),
757 ADIS16475_DELTVEL_CHAN(X),
758 ADIS16475_DELTVEL_CHAN(Y),
759 ADIS16475_DELTVEL_CHAN(Z),
760 IIO_CHAN_SOFT_TIMESTAMP(13)
763 static const struct iio_chan_spec adis16475_channels[] = {
764 ADIS16475_GYRO_CHANNEL(X),
765 ADIS16475_GYRO_CHANNEL(Y),
766 ADIS16475_GYRO_CHANNEL(Z),
767 ADIS16475_ACCEL_CHANNEL(X),
768 ADIS16475_ACCEL_CHANNEL(Y),
769 ADIS16475_ACCEL_CHANNEL(Z),
770 ADIS16475_TEMP_CHANNEL(),
771 ADIS16475_DELTANG_CHAN_NO_SCAN(X),
772 ADIS16475_DELTANG_CHAN_NO_SCAN(Y),
773 ADIS16475_DELTANG_CHAN_NO_SCAN(Z),
774 ADIS16475_DELTVEL_CHAN_NO_SCAN(X),
775 ADIS16475_DELTVEL_CHAN_NO_SCAN(Y),
776 ADIS16475_DELTVEL_CHAN_NO_SCAN(Z),
777 IIO_CHAN_SOFT_TIMESTAMP(7)
780 static const struct iio_chan_spec adis16575_channels[] = {
781 ADIS16475_GYRO_CHANNEL(X),
782 ADIS16475_GYRO_CHANNEL(Y),
783 ADIS16475_GYRO_CHANNEL(Z),
784 ADIS16475_ACCEL_CHANNEL(X),
785 ADIS16475_ACCEL_CHANNEL(Y),
786 ADIS16475_ACCEL_CHANNEL(Z),
787 ADIS16475_TEMP_CHANNEL(),
788 ADIS16475_DELTANG_CHAN(X),
789 ADIS16475_DELTANG_CHAN(Y),
790 ADIS16475_DELTANG_CHAN(Z),
791 ADIS16475_DELTVEL_CHAN(X),
792 ADIS16475_DELTVEL_CHAN(Y),
793 ADIS16475_DELTVEL_CHAN(Z),
796 enum adis16475_variant {
827 ADIS16475_DIAG_STAT_DATA_PATH = 1,
828 ADIS16475_DIAG_STAT_FLASH_MEM,
829 ADIS16475_DIAG_STAT_SPI,
830 ADIS16475_DIAG_STAT_STANDBY,
831 ADIS16475_DIAG_STAT_SENSOR,
832 ADIS16475_DIAG_STAT_MEMORY,
833 ADIS16475_DIAG_STAT_CLK,
836 static const char * const adis16475_status_error_msgs[] = {
837 [ADIS16475_DIAG_STAT_DATA_PATH] = "Data Path Overrun",
838 [ADIS16475_DIAG_STAT_FLASH_MEM] = "Flash memory update failure",
839 [ADIS16475_DIAG_STAT_SPI] = "SPI communication error",
840 [ADIS16475_DIAG_STAT_STANDBY] = "Standby mode",
841 [ADIS16475_DIAG_STAT_SENSOR] = "Sensor failure",
842 [ADIS16475_DIAG_STAT_MEMORY] = "Memory failure",
843 [ADIS16475_DIAG_STAT_CLK] = "Clock error",
846 #define ADIS16475_DATA(_prod_id, _timeouts, _burst_max_len, _burst_max_speed_hz, _has_fifo) \
848 .msc_ctrl_reg = ADIS16475_REG_MSG_CTRL, \
849 .glob_cmd_reg = ADIS16475_REG_GLOB_CMD, \
850 .diag_stat_reg = ADIS16475_REG_DIAG_STAT, \
851 .prod_id_reg = ADIS16475_REG_PROD_ID, \
852 .prod_id = (_prod_id), \
853 .self_test_mask = BIT(2), \
854 .self_test_reg = ADIS16475_REG_GLOB_CMD, \
855 .cs_change_delay = 16, \
858 .status_error_msgs = adis16475_status_error_msgs, \
859 .status_error_mask = BIT(ADIS16475_DIAG_STAT_DATA_PATH) | \
860 BIT(ADIS16475_DIAG_STAT_FLASH_MEM) | \
861 BIT(ADIS16475_DIAG_STAT_SPI) | \
862 BIT(ADIS16475_DIAG_STAT_STANDBY) | \
863 BIT(ADIS16475_DIAG_STAT_SENSOR) | \
864 BIT(ADIS16475_DIAG_STAT_MEMORY) | \
865 BIT(ADIS16475_DIAG_STAT_CLK), \
866 .unmasked_drdy = true, \
867 .has_fifo = _has_fifo, \
868 .timeouts = (_timeouts), \
869 .burst_reg_cmd = ADIS16475_REG_GLOB_CMD, \
870 .burst_len = ADIS16475_BURST_MAX_DATA, \
871 .burst_max_len = _burst_max_len, \
872 .burst_max_speed_hz = _burst_max_speed_hz \
875 static const struct adis16475_sync adis16475_sync_mode[] = {
876 { ADIS16475_SYNC_OUTPUT },
877 { ADIS16475_SYNC_DIRECT, 1900, 2100 },
878 { ADIS16475_SYNC_SCALED, 1, 128 },
879 { ADIS16475_SYNC_PULSE, 1000, 2100 },
882 static const struct adis16475_sync adis16575_sync_mode[] = {
883 { ADIS16475_SYNC_OUTPUT },
884 { ADIS16475_SYNC_DIRECT, 1900, 4100 },
885 { ADIS16475_SYNC_SCALED, 1, 400 },
888 static const struct adis_timeout adis16475_timeouts = {
894 static const struct adis_timeout adis1650x_timeouts = {
900 static const struct adis16475_chip_info adis16475_chip_info[] = {
903 .num_channels = ARRAY_SIZE(adis16475_channels),
904 .channels = adis16475_channels,
906 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
908 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
910 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
911 .deltvel_max_val = 400,
914 .sync = adis16475_sync_mode,
915 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
916 .adis_data = ADIS16475_DATA(16470, &adis16475_timeouts,
917 ADIS16475_BURST32_MAX_DATA_NO_TS32,
918 ADIS16475_BURST_MAX_SPEED, false),
921 .name = "adis16475-1",
922 .num_channels = ARRAY_SIZE(adis16475_channels),
923 .channels = adis16475_channels,
925 .gyro_max_scale = IIO_RAD_TO_DEGREE(160 << 16),
927 .accel_max_scale = IIO_M_S_2_TO_G(4000 << 16),
929 .deltang_max_val = IIO_DEGREE_TO_RAD(360),
930 .deltvel_max_val = 100,
933 .sync = adis16475_sync_mode,
934 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
935 .adis_data = ADIS16475_DATA(16475, &adis16475_timeouts,
936 ADIS16475_BURST32_MAX_DATA_NO_TS32,
937 ADIS16475_BURST_MAX_SPEED, false),
940 .name = "adis16475-2",
941 .num_channels = ARRAY_SIZE(adis16475_channels),
942 .channels = adis16475_channels,
944 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
946 .accel_max_scale = IIO_M_S_2_TO_G(4000 << 16),
948 .deltang_max_val = IIO_DEGREE_TO_RAD(720),
949 .deltvel_max_val = 100,
952 .sync = adis16475_sync_mode,
953 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
954 .adis_data = ADIS16475_DATA(16475, &adis16475_timeouts,
955 ADIS16475_BURST32_MAX_DATA_NO_TS32,
956 ADIS16475_BURST_MAX_SPEED, false),
959 .name = "adis16475-3",
960 .num_channels = ARRAY_SIZE(adis16475_channels),
961 .channels = adis16475_channels,
963 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
965 .accel_max_scale = IIO_M_S_2_TO_G(4000 << 16),
967 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
968 .deltvel_max_val = 100,
971 .sync = adis16475_sync_mode,
972 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
973 .adis_data = ADIS16475_DATA(16475, &adis16475_timeouts,
974 ADIS16475_BURST32_MAX_DATA_NO_TS32,
975 ADIS16475_BURST_MAX_SPEED, false),
978 .name = "adis16477-1",
979 .num_channels = ARRAY_SIZE(adis16477_channels),
980 .channels = adis16477_channels,
982 .gyro_max_scale = IIO_RAD_TO_DEGREE(160 << 16),
984 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
986 .deltang_max_val = IIO_DEGREE_TO_RAD(360),
987 .deltvel_max_val = 400,
990 .sync = adis16475_sync_mode,
991 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
992 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
993 .adis_data = ADIS16475_DATA(16477, &adis16475_timeouts,
994 ADIS16475_BURST32_MAX_DATA_NO_TS32,
995 ADIS16475_BURST_MAX_SPEED, false),
998 .name = "adis16477-2",
999 .num_channels = ARRAY_SIZE(adis16477_channels),
1000 .channels = adis16477_channels,
1002 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1004 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
1006 .deltang_max_val = IIO_DEGREE_TO_RAD(720),
1007 .deltvel_max_val = 400,
1010 .sync = adis16475_sync_mode,
1011 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1012 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1013 .adis_data = ADIS16475_DATA(16477, &adis16475_timeouts,
1014 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1015 ADIS16475_BURST_MAX_SPEED, false),
1018 .name = "adis16477-3",
1019 .num_channels = ARRAY_SIZE(adis16477_channels),
1020 .channels = adis16477_channels,
1022 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1024 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
1026 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
1027 .deltvel_max_val = 400,
1030 .sync = adis16475_sync_mode,
1031 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1032 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1033 .adis_data = ADIS16475_DATA(16477, &adis16475_timeouts,
1034 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1035 ADIS16475_BURST_MAX_SPEED, false),
1038 .name = "adis16465-1",
1039 .num_channels = ARRAY_SIZE(adis16475_channels),
1040 .channels = adis16475_channels,
1042 .gyro_max_scale = IIO_RAD_TO_DEGREE(160 << 16),
1044 .accel_max_scale = IIO_M_S_2_TO_G(4000 << 16),
1046 .deltang_max_val = IIO_DEGREE_TO_RAD(360),
1047 .deltvel_max_val = 100,
1050 .sync = adis16475_sync_mode,
1051 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1052 .adis_data = ADIS16475_DATA(16465, &adis16475_timeouts,
1053 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1054 ADIS16475_BURST_MAX_SPEED, false),
1057 .name = "adis16465-2",
1058 .num_channels = ARRAY_SIZE(adis16475_channels),
1059 .channels = adis16475_channels,
1061 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1063 .accel_max_scale = IIO_M_S_2_TO_G(4000 << 16),
1065 .deltang_max_val = IIO_DEGREE_TO_RAD(720),
1066 .deltvel_max_val = 100,
1069 .sync = adis16475_sync_mode,
1070 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1071 .adis_data = ADIS16475_DATA(16465, &adis16475_timeouts,
1072 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1073 ADIS16475_BURST_MAX_SPEED, false),
1076 .name = "adis16465-3",
1077 .num_channels = ARRAY_SIZE(adis16475_channels),
1078 .channels = adis16475_channels,
1080 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1082 .accel_max_scale = IIO_M_S_2_TO_G(4000 << 16),
1084 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
1085 .deltvel_max_val = 100,
1088 .sync = adis16475_sync_mode,
1089 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1090 .adis_data = ADIS16475_DATA(16465, &adis16475_timeouts,
1091 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1092 ADIS16475_BURST_MAX_SPEED, false),
1095 .name = "adis16467-1",
1096 .num_channels = ARRAY_SIZE(adis16475_channels),
1097 .channels = adis16475_channels,
1099 .gyro_max_scale = IIO_RAD_TO_DEGREE(160 << 16),
1101 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
1103 .deltang_max_val = IIO_DEGREE_TO_RAD(360),
1104 .deltvel_max_val = 400,
1107 .sync = adis16475_sync_mode,
1108 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1109 .adis_data = ADIS16475_DATA(16467, &adis16475_timeouts,
1110 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1111 ADIS16475_BURST_MAX_SPEED, false),
1114 .name = "adis16467-2",
1115 .num_channels = ARRAY_SIZE(adis16475_channels),
1116 .channels = adis16475_channels,
1118 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1120 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
1122 .deltang_max_val = IIO_DEGREE_TO_RAD(720),
1123 .deltvel_max_val = 400,
1126 .sync = adis16475_sync_mode,
1127 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1128 .adis_data = ADIS16475_DATA(16467, &adis16475_timeouts,
1129 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1130 ADIS16475_BURST_MAX_SPEED, false),
1133 .name = "adis16467-3",
1134 .num_channels = ARRAY_SIZE(adis16475_channels),
1135 .channels = adis16475_channels,
1137 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1139 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
1141 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
1142 .deltvel_max_val = 400,
1145 .sync = adis16475_sync_mode,
1146 .num_sync = ARRAY_SIZE(adis16475_sync_mode),
1147 .adis_data = ADIS16475_DATA(16467, &adis16475_timeouts,
1148 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1149 ADIS16475_BURST_MAX_SPEED, false),
1152 .name = "adis16500",
1153 .num_channels = ARRAY_SIZE(adis16477_channels),
1154 .channels = adis16477_channels,
1156 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1157 .accel_max_val = 392,
1158 .accel_max_scale = 32000 << 16,
1160 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
1161 .deltvel_max_val = 400,
1164 .sync = adis16475_sync_mode,
1165 /* pulse sync not supported */
1166 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1167 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1168 .adis_data = ADIS16475_DATA(16500, &adis1650x_timeouts,
1169 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1170 ADIS16475_BURST_MAX_SPEED, false),
1173 .name = "adis16501",
1174 .num_channels = ARRAY_SIZE(adis16477_channels),
1175 .channels = adis16477_channels,
1177 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1179 .accel_max_scale = IIO_M_S_2_TO_G(800 << 16),
1181 .deltang_max_val = IIO_DEGREE_TO_RAD(720),
1182 .deltvel_max_val = 125,
1185 .sync = adis16475_sync_mode,
1186 /* pulse sync not supported */
1187 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1188 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1189 .adis_data = ADIS16475_DATA(16501, &adis1650x_timeouts,
1190 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1191 ADIS16475_BURST_MAX_SPEED, false),
1194 .name = "adis16505-1",
1195 .num_channels = ARRAY_SIZE(adis16477_channels),
1196 .channels = adis16477_channels,
1198 .gyro_max_scale = IIO_RAD_TO_DEGREE(160 << 16),
1199 .accel_max_val = 78,
1200 .accel_max_scale = 32000 << 16,
1202 .deltang_max_val = IIO_DEGREE_TO_RAD(360),
1203 .deltvel_max_val = 100,
1206 .sync = adis16475_sync_mode,
1207 /* pulse sync not supported */
1208 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1209 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1210 .adis_data = ADIS16475_DATA(16505, &adis1650x_timeouts,
1211 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1212 ADIS16475_BURST_MAX_SPEED, false),
1215 .name = "adis16505-2",
1216 .num_channels = ARRAY_SIZE(adis16477_channels),
1217 .channels = adis16477_channels,
1219 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1220 .accel_max_val = 78,
1221 .accel_max_scale = 32000 << 16,
1223 .deltang_max_val = IIO_DEGREE_TO_RAD(720),
1224 .deltvel_max_val = 100,
1227 .sync = adis16475_sync_mode,
1228 /* pulse sync not supported */
1229 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1230 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1231 .adis_data = ADIS16475_DATA(16505, &adis1650x_timeouts,
1232 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1233 ADIS16475_BURST_MAX_SPEED, false),
1236 .name = "adis16505-3",
1237 .num_channels = ARRAY_SIZE(adis16477_channels),
1238 .channels = adis16477_channels,
1240 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1241 .accel_max_val = 78,
1242 .accel_max_scale = 32000 << 16,
1244 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
1245 .deltvel_max_val = 100,
1248 .sync = adis16475_sync_mode,
1249 /* pulse sync not supported */
1250 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1251 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1252 .adis_data = ADIS16475_DATA(16505, &adis1650x_timeouts,
1253 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1254 ADIS16475_BURST_MAX_SPEED, false),
1257 .name = "adis16507-1",
1258 .num_channels = ARRAY_SIZE(adis16477_channels),
1259 .channels = adis16477_channels,
1261 .gyro_max_scale = IIO_RAD_TO_DEGREE(160 << 16),
1262 .accel_max_val = 392,
1263 .accel_max_scale = 32000 << 16,
1265 .deltang_max_val = IIO_DEGREE_TO_RAD(360),
1266 .deltvel_max_val = 400,
1269 .sync = adis16475_sync_mode,
1270 /* pulse sync not supported */
1271 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1272 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1273 .adis_data = ADIS16475_DATA(16507, &adis1650x_timeouts,
1274 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1275 ADIS16475_BURST_MAX_SPEED, false),
1278 .name = "adis16507-2",
1279 .num_channels = ARRAY_SIZE(adis16477_channels),
1280 .channels = adis16477_channels,
1282 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1283 .accel_max_val = 392,
1284 .accel_max_scale = 32000 << 16,
1286 .deltang_max_val = IIO_DEGREE_TO_RAD(720),
1287 .deltvel_max_val = 400,
1290 .sync = adis16475_sync_mode,
1291 /* pulse sync not supported */
1292 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1293 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1294 .adis_data = ADIS16475_DATA(16507, &adis1650x_timeouts,
1295 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1296 ADIS16475_BURST_MAX_SPEED, false),
1299 .name = "adis16507-3",
1300 .num_channels = ARRAY_SIZE(adis16477_channels),
1301 .channels = adis16477_channels,
1303 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1304 .accel_max_val = 392,
1305 .accel_max_scale = 32000 << 16,
1307 .deltang_max_val = IIO_DEGREE_TO_RAD(2160),
1308 .deltvel_max_val = 400,
1311 .sync = adis16475_sync_mode,
1312 /* pulse sync not supported */
1313 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
1314 .flags = ADIS16475_HAS_BURST32 | ADIS16475_HAS_BURST_DELTA_DATA,
1315 .adis_data = ADIS16475_DATA(16507, &adis1650x_timeouts,
1316 ADIS16475_BURST32_MAX_DATA_NO_TS32,
1317 ADIS16475_BURST_MAX_SPEED, false),
1320 .name = "adis16575-2",
1321 .num_channels = ARRAY_SIZE(adis16575_channels),
1322 .channels = adis16575_channels,
1324 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1326 .accel_max_scale = IIO_M_S_2_TO_G(32000 << 16),
1328 .deltang_max_val = IIO_DEGREE_TO_RAD(450),
1329 .deltvel_max_val = 100,
1332 .sync = adis16575_sync_mode,
1333 .num_sync = ARRAY_SIZE(adis16575_sync_mode),
1334 .flags = ADIS16475_HAS_BURST32 |
1335 ADIS16475_HAS_BURST_DELTA_DATA |
1336 ADIS16475_NEEDS_BURST_REQUEST |
1337 ADIS16475_HAS_TIMESTAMP32,
1338 .adis_data = ADIS16475_DATA(16575, &adis16475_timeouts,
1339 ADIS16575_BURST32_DATA_TS32,
1340 ADIS16575_BURST_MAX_SPEED, true),
1343 .name = "adis16575-3",
1344 .num_channels = ARRAY_SIZE(adis16575_channels),
1345 .channels = adis16575_channels,
1347 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1349 .accel_max_scale = IIO_M_S_2_TO_G(32000 << 16),
1351 .deltang_max_val = IIO_DEGREE_TO_RAD(2000),
1352 .deltvel_max_val = 100,
1355 .sync = adis16575_sync_mode,
1356 .num_sync = ARRAY_SIZE(adis16575_sync_mode),
1357 .flags = ADIS16475_HAS_BURST32 |
1358 ADIS16475_HAS_BURST_DELTA_DATA |
1359 ADIS16475_NEEDS_BURST_REQUEST |
1360 ADIS16475_HAS_TIMESTAMP32,
1361 .adis_data = ADIS16475_DATA(16575, &adis16475_timeouts,
1362 ADIS16575_BURST32_DATA_TS32,
1363 ADIS16575_BURST_MAX_SPEED, true),
1366 .name = "adis16576-2",
1367 .num_channels = ARRAY_SIZE(adis16575_channels),
1368 .channels = adis16575_channels,
1370 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1371 .accel_max_val = 40,
1372 .accel_max_scale = IIO_M_S_2_TO_G(32000 << 16),
1374 .deltang_max_val = IIO_DEGREE_TO_RAD(450),
1375 .deltvel_max_val = 125,
1378 .sync = adis16575_sync_mode,
1379 .num_sync = ARRAY_SIZE(adis16575_sync_mode),
1380 .flags = ADIS16475_HAS_BURST32 |
1381 ADIS16475_HAS_BURST_DELTA_DATA |
1382 ADIS16475_NEEDS_BURST_REQUEST |
1383 ADIS16475_HAS_TIMESTAMP32,
1384 .adis_data = ADIS16475_DATA(16576, &adis16475_timeouts,
1385 ADIS16575_BURST32_DATA_TS32,
1386 ADIS16575_BURST_MAX_SPEED, true),
1389 .name = "adis16576-3",
1390 .num_channels = ARRAY_SIZE(adis16575_channels),
1391 .channels = adis16575_channels,
1393 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1394 .accel_max_val = 40,
1395 .accel_max_scale = IIO_M_S_2_TO_G(32000 << 16),
1397 .deltang_max_val = IIO_DEGREE_TO_RAD(2000),
1398 .deltvel_max_val = 125,
1401 .sync = adis16575_sync_mode,
1402 .num_sync = ARRAY_SIZE(adis16575_sync_mode),
1403 .flags = ADIS16475_HAS_BURST32 |
1404 ADIS16475_HAS_BURST_DELTA_DATA |
1405 ADIS16475_NEEDS_BURST_REQUEST |
1406 ADIS16475_HAS_TIMESTAMP32,
1407 .adis_data = ADIS16475_DATA(16576, &adis16475_timeouts,
1408 ADIS16575_BURST32_DATA_TS32,
1409 ADIS16575_BURST_MAX_SPEED, true),
1412 .name = "adis16577-2",
1413 .num_channels = ARRAY_SIZE(adis16575_channels),
1414 .channels = adis16575_channels,
1416 .gyro_max_scale = IIO_RAD_TO_DEGREE(40 << 16),
1417 .accel_max_val = 40,
1418 .accel_max_scale = IIO_M_S_2_TO_G(32000 << 16),
1420 .deltang_max_val = IIO_DEGREE_TO_RAD(450),
1421 .deltvel_max_val = 400,
1424 .sync = adis16575_sync_mode,
1425 .num_sync = ARRAY_SIZE(adis16575_sync_mode),
1426 .flags = ADIS16475_HAS_BURST32 |
1427 ADIS16475_HAS_BURST_DELTA_DATA |
1428 ADIS16475_NEEDS_BURST_REQUEST |
1429 ADIS16475_HAS_TIMESTAMP32,
1430 .adis_data = ADIS16475_DATA(16577, &adis16475_timeouts,
1431 ADIS16575_BURST32_DATA_TS32,
1432 ADIS16575_BURST_MAX_SPEED, true),
1435 .name = "adis16577-3",
1436 .num_channels = ARRAY_SIZE(adis16575_channels),
1437 .channels = adis16575_channels,
1439 .gyro_max_scale = IIO_RAD_TO_DEGREE(10 << 16),
1440 .accel_max_val = 40,
1441 .accel_max_scale = IIO_M_S_2_TO_G(32000 << 16),
1443 .deltang_max_val = IIO_DEGREE_TO_RAD(2000),
1444 .deltvel_max_val = 400,
1447 .sync = adis16575_sync_mode,
1448 .num_sync = ARRAY_SIZE(adis16575_sync_mode),
1449 .flags = ADIS16475_HAS_BURST32 |
1450 ADIS16475_HAS_BURST_DELTA_DATA |
1451 ADIS16475_NEEDS_BURST_REQUEST |
1452 ADIS16475_HAS_TIMESTAMP32,
1453 .adis_data = ADIS16475_DATA(16577, &adis16475_timeouts,
1454 ADIS16575_BURST32_DATA_TS32,
1455 ADIS16575_BURST_MAX_SPEED, true),
1459 static int adis16475_update_scan_mode(struct iio_dev *indio_dev,
1460 const unsigned long *scan_mask)
1464 struct adis16475 *st = iio_priv(indio_dev);
1466 if (st->info->flags & ADIS16475_HAS_BURST_DELTA_DATA) {
1467 if ((*scan_mask & ADIS16500_BURST_DATA_SEL_0_CHN_MASK) &&
1468 (*scan_mask & ADIS16500_BURST_DATA_SEL_1_CHN_MASK))
1470 if (*scan_mask & ADIS16500_BURST_DATA_SEL_0_CHN_MASK)
1471 en = FIELD_PREP(ADIS16500_BURST_DATA_SEL_MASK, 0);
1473 en = FIELD_PREP(ADIS16500_BURST_DATA_SEL_MASK, 1);
1475 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL,
1476 ADIS16500_BURST_DATA_SEL_MASK, en);
1481 return adis_update_scan_mode(indio_dev, scan_mask);
1484 static const struct iio_info adis16475_info = {
1485 .read_raw = &adis16475_read_raw,
1486 .write_raw = &adis16475_write_raw,
1487 .update_scan_mode = adis16475_update_scan_mode,
1488 .debugfs_reg_access = adis_debugfs_reg_access,
1491 static const struct iio_info adis16575_info = {
1492 .read_raw = &adis16475_read_raw,
1493 .write_raw = &adis16475_write_raw,
1494 .update_scan_mode = adis16475_update_scan_mode,
1495 .debugfs_reg_access = adis_debugfs_reg_access,
1496 .hwfifo_set_watermark = adis16475_set_watermark,
1499 static bool adis16475_validate_crc(const u8 *buffer, u16 crc,
1500 u16 burst_size, u16 start_idx)
1504 for (i = start_idx; i < burst_size - 2; i++)
1510 static void adis16475_burst32_check(struct adis16475 *st)
1513 struct adis *adis = &st->adis;
1516 if (!(st->info->flags & ADIS16475_HAS_BURST32))
1519 if (st->info->flags & ADIS16475_HAS_TIMESTAMP32)
1522 if (st->lsb_flag && !st->burst32) {
1523 const u16 en = ADIS16500_BURST32(1);
1525 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL,
1526 ADIS16500_BURST32_MASK, en);
1533 * In 32-bit mode we need extra 2 bytes for all gyro
1534 * and accel channels.
1535 * If the device has 32-bit timestamp value we need 2 extra
1538 adis->burst_extra_len = (6 + timestamp32) * sizeof(u16);
1539 adis->xfer[1].len += (6 + timestamp32) * sizeof(u16);
1541 dev_dbg(&adis->spi->dev, "Enable burst32 mode, xfer:%d",
1544 } else if (!st->lsb_flag && st->burst32) {
1545 const u16 en = ADIS16500_BURST32(0);
1547 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL,
1548 ADIS16500_BURST32_MASK, en);
1552 st->burst32 = false;
1554 /* Remove the extra bits */
1555 adis->burst_extra_len = 0;
1556 adis->xfer[1].len -= (6 + timestamp32) * sizeof(u16);
1557 dev_dbg(&adis->spi->dev, "Disable burst32 mode, xfer:%d\n",
1562 static int adis16475_push_single_sample(struct iio_poll_func *pf)
1564 struct iio_dev *indio_dev = pf->indio_dev;
1565 struct adis16475 *st = iio_priv(indio_dev);
1566 struct adis *adis = &st->adis;
1567 int ret, bit, buff_offset = 0, i = 0;
1572 u16 burst_size = ADIS16475_BURST_MAX_DATA;
1573 u16 start_idx = (st->info->flags & ADIS16475_HAS_TIMESTAMP32) ? 2 : 0;
1575 /* offset until the first element after gyro and accel */
1576 const u8 offset = st->burst32 ? 13 : 7;
1579 crc_offset = (st->info->flags & ADIS16475_HAS_TIMESTAMP32) ? 16 : 15;
1580 burst_size = adis->data->burst_max_len;
1583 ret = spi_sync(adis->spi, &adis->msg);
1587 buffer = adis->buffer;
1589 crc = be16_to_cpu(buffer[crc_offset]);
1590 valid = adis16475_validate_crc(adis->buffer, crc, burst_size, start_idx);
1592 dev_err(&adis->spi->dev, "Invalid crc\n");
1596 for_each_set_bit(bit, indio_dev->active_scan_mask,
1597 indio_dev->masklength) {
1599 * When burst mode is used, system flags is the first data
1600 * channel in the sequence, but the scan index is 7.
1603 case ADIS16475_SCAN_TEMP:
1604 st->data[i++] = buffer[offset];
1606 * The temperature channel has 16-bit storage size.
1607 * We need to perform the padding to have the buffer
1608 * elements naturally aligned in case there are any
1609 * 32-bit storage size channels enabled which have a
1610 * scan index higher than the temperature channel scan
1613 if (*indio_dev->active_scan_mask & GENMASK(ADIS16475_SCAN_DELTVEL_Z, ADIS16475_SCAN_DELTANG_X))
1616 case ADIS16475_SCAN_DELTANG_X ... ADIS16475_SCAN_DELTVEL_Z:
1617 buff_offset = ADIS16475_SCAN_DELTANG_X;
1619 case ADIS16475_SCAN_GYRO_X ... ADIS16475_SCAN_ACCEL_Z:
1621 * The first 2 bytes on the received data are the
1622 * DIAG_STAT reg, hence the +1 offset here...
1626 st->data[i++] = buffer[(bit - buff_offset) * 2 + 2];
1628 st->data[i++] = buffer[(bit - buff_offset) * 2 + 1];
1630 st->data[i++] = buffer[(bit - buff_offset) + 1];
1632 * Don't bother in doing the manual read if the
1633 * device supports burst32. burst32 will be
1634 * enabled in the next call to
1635 * adis16475_burst32_check()...
1637 if (st->lsb_flag && !(st->info->flags & ADIS16475_HAS_BURST32)) {
1639 const u32 reg = ADIS16475_REG_X_GYRO_L +
1642 adis_read_reg_16(adis, reg, &val);
1643 st->data[i++] = cpu_to_be16(val);
1645 /* lower not used */
1653 /* There might not be a timestamp option for some devices. */
1654 iio_push_to_buffers_with_timestamp(indio_dev, st->data, pf->timestamp);
1659 static irqreturn_t adis16475_trigger_handler(int irq, void *p)
1661 struct iio_poll_func *pf = p;
1662 struct iio_dev *indio_dev = pf->indio_dev;
1663 struct adis16475 *st = iio_priv(indio_dev);
1665 adis16475_push_single_sample(pf);
1667 * We only check the burst mode at the end of the current capture since
1668 * it takes a full data ready cycle for the device to update the burst
1671 adis16475_burst32_check(st);
1673 iio_trigger_notify_done(indio_dev->trig);
1679 * This function updates the first tx byte from the adis message based on the
1680 * given burst request.
1682 static void adis16575_update_msg_for_burst(struct adis *adis, u8 burst_req)
1684 unsigned int burst_max_length;
1687 if (adis->data->burst_max_len)
1688 burst_max_length = adis->data->burst_max_len;
1690 burst_max_length = adis->data->burst_len + adis->burst_extra_len;
1692 tx = adis->buffer + burst_max_length;
1693 tx[0] = ADIS_READ_REG(burst_req);
1696 static int adis16575_custom_burst_read(struct iio_poll_func *pf, u8 burst_req)
1698 struct iio_dev *indio_dev = pf->indio_dev;
1699 struct adis16475 *st = iio_priv(indio_dev);
1700 struct adis *adis = &st->adis;
1702 adis16575_update_msg_for_burst(adis, burst_req);
1705 return spi_sync(adis->spi, &adis->msg);
1707 return adis16475_push_single_sample(pf);
1711 * This handler is meant to be used for devices which support burst readings
1712 * from FIFO (namely devices from adis1657x family).
1713 * In order to pop the FIFO the 0x68 0x00 FIFO pop burst request has to be sent.
1714 * If the previous device command was not a FIFO pop burst request, the FIFO pop
1715 * burst request will simply pop the FIFO without returning valid data.
1716 * For the nth consecutive burst request, thedevice will send the data popped
1717 * with the (n-1)th consecutive burst request.
1718 * In order to read the data which was popped previously, without popping the
1719 * FIFO, the 0x00 0x00 burst request has to be sent.
1720 * If after a 0x68 0x00 FIFO pop burst request, there is any other device access
1721 * different from a 0x68 0x00 or a 0x00 0x00 burst request, the FIFO data popped
1722 * previously will be lost.
1724 static irqreturn_t adis16475_trigger_handler_with_fifo(int irq, void *p)
1726 struct iio_poll_func *pf = p;
1727 struct iio_dev *indio_dev = pf->indio_dev;
1728 struct adis16475 *st = iio_priv(indio_dev);
1729 struct adis *adis = &st->adis;
1733 adis_dev_auto_lock(&st->adis);
1735 ret = __adis_read_reg_16(adis, ADIS16575_REG_FIFO_CNT, &fifo_cnt);
1740 * If no sample is available, nothing can be read. This can happen if
1741 * a the used trigger has a higher frequency than the selected sample rate.
1747 * First burst request - FIFO pop: popped data will be returned in the
1748 * next burst request.
1750 ret = adis16575_custom_burst_read(pf, adis->data->burst_reg_cmd);
1754 for (i = 0; i < fifo_cnt - 1; i++) {
1755 ret = adis16475_push_single_sample(pf);
1760 /* FIFO read without popping */
1761 ret = adis16575_custom_burst_read(pf, 0);
1765 * We only check the burst mode at the end of the current capture since
1766 * reading data from registers will impact the FIFO reading.
1768 adis16475_burst32_check(st);
1769 iio_trigger_notify_done(indio_dev->trig);
1774 static int adis16475_config_sync_mode(struct adis16475 *st)
1777 struct device *dev = &st->adis.spi->dev;
1778 const struct adis16475_sync *sync;
1780 u16 max_sample_rate = st->info->int_clk + 100;
1783 /* if available, enable 4khz internal clock */
1784 if (st->info->int_clk == 4000) {
1785 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL,
1786 ADIS16575_SYNC_4KHZ_MASK,
1787 (u16)ADIS16575_SYNC_4KHZ(1));
1792 /* default to internal clk */
1793 st->clk_freq = st->info->int_clk * 1000;
1795 ret = device_property_read_u32(dev, "adi,sync-mode", &sync_mode);
1799 if (sync_mode >= st->info->num_sync) {
1800 dev_err(dev, "Invalid sync mode: %u for %s\n", sync_mode,
1805 sync = &st->info->sync[sync_mode];
1806 st->sync_mode = sync->sync_mode;
1808 /* All the other modes require external input signal */
1809 if (sync->sync_mode != ADIS16475_SYNC_OUTPUT) {
1810 struct clk *clk = devm_clk_get_enabled(dev, NULL);
1813 return PTR_ERR(clk);
1815 st->clk_freq = clk_get_rate(clk);
1816 if (st->clk_freq < sync->min_rate ||
1817 st->clk_freq > sync->max_rate) {
1819 "Clk rate:%u not in a valid range:[%u %u]\n",
1820 st->clk_freq, sync->min_rate, sync->max_rate);
1824 if (sync->sync_mode == ADIS16475_SYNC_SCALED) {
1828 * In sync scaled mode, the IMU sample rate is the clk_freq * sync_scale.
1829 * Hence, default the IMU sample rate to the highest multiple of the input
1830 * clock lower than the IMU max sample rate.
1832 up_scale = max_sample_rate / st->clk_freq;
1834 ret = __adis_write_reg_16(&st->adis,
1835 ADIS16475_REG_UP_SCALE,
1841 st->clk_freq *= 1000;
1844 * Keep in mind that the mask for the clk modes in adis1650*
1845 * chips is different (1100 instead of 11100). However, we
1846 * are not configuring BIT(4) in these chips and the default
1847 * value is 0, so we are fine in doing the below operations.
1848 * I'm keeping this for simplicity and avoiding extra variables
1851 val = ADIS16475_SYNC_MODE(sync->sync_mode);
1852 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL,
1853 ADIS16475_SYNC_MODE_MASK, val);
1857 usleep_range(250, 260);
1862 static int adis16475_config_irq_pin(struct adis16475 *st)
1868 struct spi_device *spi = st->adis.spi;
1870 irq_type = irq_get_trigger_type(spi->irq);
1872 if (st->adis.data->has_fifo) {
1874 * It is possible to configure the fifo watermark pin polarity.
1875 * Furthermore, we need to update the adis struct if we want the
1876 * watermark pin active low.
1878 if (irq_type == IRQ_TYPE_LEVEL_HIGH) {
1880 st->adis.irq_flag = IRQF_TRIGGER_HIGH;
1881 } else if (irq_type == IRQ_TYPE_LEVEL_LOW) {
1883 st->adis.irq_flag = IRQF_TRIGGER_LOW;
1885 dev_err(&spi->dev, "Invalid interrupt type 0x%x specified\n",
1890 /* Configure the watermark pin polarity. */
1891 val = ADIS16575_WM_POL(polarity);
1892 ret = adis_update_bits(&st->adis, ADIS16475_REG_FIFO_CTRL,
1893 ADIS16575_WM_POL_MASK, val);
1897 /* Enable watermark interrupt pin. */
1898 ret = adis_update_bits(&st->adis, ADIS16475_REG_FIFO_CTRL,
1899 ADIS16575_WM_EN_MASK,
1900 (u16)ADIS16575_WM_EN(1));
1906 * It is possible to configure the data ready polarity. Furthermore, we
1907 * need to update the adis struct if we want data ready as active low.
1909 if (irq_type == IRQ_TYPE_EDGE_RISING) {
1911 st->adis.irq_flag = IRQF_TRIGGER_RISING;
1912 } else if (irq_type == IRQ_TYPE_EDGE_FALLING) {
1914 st->adis.irq_flag = IRQF_TRIGGER_FALLING;
1916 dev_err(&spi->dev, "Invalid interrupt type 0x%x specified\n",
1921 val = ADIS16475_MSG_CTRL_DR_POL(polarity);
1922 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL,
1923 ADIS16475_MSG_CTRL_DR_POL_MASK, val);
1927 * There is a delay writing to any bits written to the MSC_CTRL
1928 * register. It should not be bigger than 200us, so 250 should be more
1931 usleep_range(250, 260);
1938 static int adis16475_probe(struct spi_device *spi)
1940 struct iio_dev *indio_dev;
1941 struct adis16475 *st;
1945 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
1949 st = iio_priv(indio_dev);
1951 st->info = spi_get_device_match_data(spi);
1955 ret = adis_init(&st->adis, indio_dev, spi, &st->info->adis_data);
1959 indio_dev->name = st->info->name;
1960 indio_dev->channels = st->info->channels;
1961 indio_dev->num_channels = st->info->num_channels;
1962 if (st->adis.data->has_fifo)
1963 indio_dev->info = &adis16575_info;
1965 indio_dev->info = &adis16475_info;
1966 indio_dev->modes = INDIO_DIRECT_MODE;
1968 ret = __adis_initial_startup(&st->adis);
1972 ret = adis16475_config_irq_pin(st);
1976 ret = adis16475_config_sync_mode(st);
1980 if (st->adis.data->has_fifo) {
1981 ret = devm_adis_setup_buffer_and_trigger_with_attrs(&st->adis, indio_dev,
1982 adis16475_trigger_handler_with_fifo,
1983 &adis16475_buffer_ops,
1984 adis16475_fifo_attributes);
1988 /* Update overflow behavior to always overwrite the oldest sample. */
1989 val = ADIS16575_OVERWRITE_OLDEST;
1990 ret = adis_update_bits(&st->adis, ADIS16475_REG_FIFO_CTRL,
1991 ADIS16575_OVERFLOW_MASK, val);
1995 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev,
1996 adis16475_trigger_handler);
2001 ret = devm_iio_device_register(&spi->dev, indio_dev);
2005 adis16475_debugfs_init(indio_dev);
2010 static const struct of_device_id adis16475_of_match[] = {
2011 { .compatible = "adi,adis16470",
2012 .data = &adis16475_chip_info[ADIS16470] },
2013 { .compatible = "adi,adis16475-1",
2014 .data = &adis16475_chip_info[ADIS16475_1] },
2015 { .compatible = "adi,adis16475-2",
2016 .data = &adis16475_chip_info[ADIS16475_2] },
2017 { .compatible = "adi,adis16475-3",
2018 .data = &adis16475_chip_info[ADIS16475_3] },
2019 { .compatible = "adi,adis16477-1",
2020 .data = &adis16475_chip_info[ADIS16477_1] },
2021 { .compatible = "adi,adis16477-2",
2022 .data = &adis16475_chip_info[ADIS16477_2] },
2023 { .compatible = "adi,adis16477-3",
2024 .data = &adis16475_chip_info[ADIS16477_3] },
2025 { .compatible = "adi,adis16465-1",
2026 .data = &adis16475_chip_info[ADIS16465_1] },
2027 { .compatible = "adi,adis16465-2",
2028 .data = &adis16475_chip_info[ADIS16465_2] },
2029 { .compatible = "adi,adis16465-3",
2030 .data = &adis16475_chip_info[ADIS16465_3] },
2031 { .compatible = "adi,adis16467-1",
2032 .data = &adis16475_chip_info[ADIS16467_1] },
2033 { .compatible = "adi,adis16467-2",
2034 .data = &adis16475_chip_info[ADIS16467_2] },
2035 { .compatible = "adi,adis16467-3",
2036 .data = &adis16475_chip_info[ADIS16467_3] },
2037 { .compatible = "adi,adis16500",
2038 .data = &adis16475_chip_info[ADIS16500] },
2039 { .compatible = "adi,adis16501",
2040 .data = &adis16475_chip_info[ADIS16501] },
2041 { .compatible = "adi,adis16505-1",
2042 .data = &adis16475_chip_info[ADIS16505_1] },
2043 { .compatible = "adi,adis16505-2",
2044 .data = &adis16475_chip_info[ADIS16505_2] },
2045 { .compatible = "adi,adis16505-3",
2046 .data = &adis16475_chip_info[ADIS16505_3] },
2047 { .compatible = "adi,adis16507-1",
2048 .data = &adis16475_chip_info[ADIS16507_1] },
2049 { .compatible = "adi,adis16507-2",
2050 .data = &adis16475_chip_info[ADIS16507_2] },
2051 { .compatible = "adi,adis16507-3",
2052 .data = &adis16475_chip_info[ADIS16507_3] },
2053 { .compatible = "adi,adis16575-2",
2054 .data = &adis16475_chip_info[ADIS16575_2] },
2055 { .compatible = "adi,adis16575-3",
2056 .data = &adis16475_chip_info[ADIS16575_3] },
2057 { .compatible = "adi,adis16576-2",
2058 .data = &adis16475_chip_info[ADIS16576_2] },
2059 { .compatible = "adi,adis16576-3",
2060 .data = &adis16475_chip_info[ADIS16576_3] },
2061 { .compatible = "adi,adis16577-2",
2062 .data = &adis16475_chip_info[ADIS16577_2] },
2063 { .compatible = "adi,adis16577-3",
2064 .data = &adis16475_chip_info[ADIS16577_3] },
2067 MODULE_DEVICE_TABLE(of, adis16475_of_match);
2069 static const struct spi_device_id adis16475_ids[] = {
2070 { "adis16470", (kernel_ulong_t)&adis16475_chip_info[ADIS16470] },
2071 { "adis16475-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_1] },
2072 { "adis16475-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_2] },
2073 { "adis16475-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_3] },
2074 { "adis16477-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_1] },
2075 { "adis16477-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_2] },
2076 { "adis16477-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_3] },
2077 { "adis16465-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_1] },
2078 { "adis16465-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_2] },
2079 { "adis16465-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_3] },
2080 { "adis16467-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_1] },
2081 { "adis16467-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_2] },
2082 { "adis16467-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_3] },
2083 { "adis16500", (kernel_ulong_t)&adis16475_chip_info[ADIS16500] },
2084 { "adis16501", (kernel_ulong_t)&adis16475_chip_info[ADIS16501] },
2085 { "adis16505-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_1] },
2086 { "adis16505-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_2] },
2087 { "adis16505-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_3] },
2088 { "adis16507-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_1] },
2089 { "adis16507-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_2] },
2090 { "adis16507-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_3] },
2091 { "adis16575-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16575_2] },
2092 { "adis16575-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16575_3] },
2093 { "adis16576-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16576_2] },
2094 { "adis16576-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16576_3] },
2095 { "adis16577-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16577_2] },
2096 { "adis16577-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16577_3] },
2099 MODULE_DEVICE_TABLE(spi, adis16475_ids);
2101 static struct spi_driver adis16475_driver = {
2103 .name = "adis16475",
2104 .of_match_table = adis16475_of_match,
2106 .probe = adis16475_probe,
2107 .id_table = adis16475_ids,
2109 module_spi_driver(adis16475_driver);
2112 MODULE_DESCRIPTION("Analog Devices ADIS16475 IMU driver");
2113 MODULE_LICENSE("GPL");
2114 MODULE_IMPORT_NS(IIO_ADISLIB);