blob: 0035e4f4db63ff46ad6e096fdc0c5edd757a9827 [file] [log] [blame]
Thomas Gleixner80503b22019-05-24 12:04:09 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Barry Song671ece12010-05-07 15:38:59 +01002/*
Reto Schneider58401bd2016-11-20 22:11:24 +01003 * ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer
Barry Song671ece12010-05-07 15:38:59 +01004 *
5 * Copyright 2010 Analog Devices Inc.
Barry Song671ece12010-05-07 15:38:59 +01006 */
7
Barry Song671ece12010-05-07 15:38:59 +01008#include <linux/device.h>
9#include <linux/kernel.h>
Shreeya Patel5824d092018-03-02 18:49:23 +053010#include <linux/module.h>
Barry Song671ece12010-05-07 15:38:59 +010011#include <linux/spi/spi.h>
Barry Song671ece12010-05-07 15:38:59 +010012
Jonathan Cameron06458e22012-04-25 15:54:58 +010013#include <linux/iio/iio.h>
Lars-Peter Clausenec04cb02012-11-13 13:28:00 +000014#include <linux/iio/imu/adis.h>
Barry Song671ece12010-05-07 15:38:59 +010015
Shreeya Patelc97712c2018-03-02 18:53:41 +053016#define ADIS16209_STARTUP_DELAY_MS 220
Shreeya Patel200905f2018-03-02 18:55:56 +053017#define ADIS16209_FLASH_CNT_REG 0x00
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020018
Shreeya Patelf3cfe182018-03-04 18:06:22 +053019/* Data Output Register Definitions */
Shreeya Patel200905f2018-03-02 18:55:56 +053020#define ADIS16209_SUPPLY_OUT_REG 0x02
Shreeya Patel200905f2018-03-02 18:55:56 +053021#define ADIS16209_XACCL_OUT_REG 0x04
Shreeya Patel200905f2018-03-02 18:55:56 +053022#define ADIS16209_YACCL_OUT_REG 0x06
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020023/* Output, auxiliary ADC input */
Shreeya Patel200905f2018-03-02 18:55:56 +053024#define ADIS16209_AUX_ADC_REG 0x08
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020025/* Output, temperature */
Shreeya Patel200905f2018-03-02 18:55:56 +053026#define ADIS16209_TEMP_OUT_REG 0x0A
Shreeya Patelf3cfe182018-03-04 18:06:22 +053027/* Output, +/- 90 degrees X-axis inclination */
Shreeya Patel200905f2018-03-02 18:55:56 +053028#define ADIS16209_XINCL_OUT_REG 0x0C
Shreeya Patel200905f2018-03-02 18:55:56 +053029#define ADIS16209_YINCL_OUT_REG 0x0E
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020030/* Output, +/-180 vertical rotational position */
Shreeya Patel200905f2018-03-02 18:55:56 +053031#define ADIS16209_ROT_OUT_REG 0x10
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020032
Shreeya Patelf3cfe182018-03-04 18:06:22 +053033/*
34 * Calibration Register Definitions.
35 * Acceleration, inclination or rotation offset null.
36 */
Shreeya Patel200905f2018-03-02 18:55:56 +053037#define ADIS16209_XACCL_NULL_REG 0x12
Shreeya Patel200905f2018-03-02 18:55:56 +053038#define ADIS16209_YACCL_NULL_REG 0x14
Shreeya Patel200905f2018-03-02 18:55:56 +053039#define ADIS16209_XINCL_NULL_REG 0x16
Shreeya Patel200905f2018-03-02 18:55:56 +053040#define ADIS16209_YINCL_NULL_REG 0x18
Shreeya Patel200905f2018-03-02 18:55:56 +053041#define ADIS16209_ROT_NULL_REG 0x1A
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020042
Shreeya Patelf3cfe182018-03-04 18:06:22 +053043/* Alarm Register Definitions */
Shreeya Patel200905f2018-03-02 18:55:56 +053044#define ADIS16209_ALM_MAG1_REG 0x20
Shreeya Patel200905f2018-03-02 18:55:56 +053045#define ADIS16209_ALM_MAG2_REG 0x22
Shreeya Patel200905f2018-03-02 18:55:56 +053046#define ADIS16209_ALM_SMPL1_REG 0x24
Shreeya Patel200905f2018-03-02 18:55:56 +053047#define ADIS16209_ALM_SMPL2_REG 0x26
Shreeya Patel200905f2018-03-02 18:55:56 +053048#define ADIS16209_ALM_CTRL_REG 0x28
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020049
Shreeya Patel200905f2018-03-02 18:55:56 +053050#define ADIS16209_AUX_DAC_REG 0x30
Shreeya Patel200905f2018-03-02 18:55:56 +053051#define ADIS16209_GPIO_CTRL_REG 0x32
Shreeya Patel200905f2018-03-02 18:55:56 +053052#define ADIS16209_SMPL_PRD_REG 0x36
Shreeya Patel200905f2018-03-02 18:55:56 +053053#define ADIS16209_AVG_CNT_REG 0x38
Shreeya Patel200905f2018-03-02 18:55:56 +053054#define ADIS16209_SLP_CNT_REG 0x3A
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020055
Shreeya Patelf3cfe182018-03-04 18:06:22 +053056#define ADIS16209_MSC_CTRL_REG 0x34
57#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10)
58#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8)
59#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2)
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020060/* Data-ready polarity: 1 = active high, 0 = active low */
Shreeya Patelf3cfe182018-03-04 18:06:22 +053061#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1)
62#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0)
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020063
Shreeya Patel1026bb32018-03-04 18:11:17 +053064#define ADIS16209_STAT_REG 0x3C
65#define ADIS16209_STAT_ALARM2 BIT(9)
66#define ADIS16209_STAT_ALARM1 BIT(8)
Shreeya Patel55cdd2e2018-03-29 14:42:02 +053067#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5
68#define ADIS16209_STAT_SPI_FAIL_BIT 3
69#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020070/* Power supply above 3.625 V */
Shreeya Patel55cdd2e2018-03-29 14:42:02 +053071#define ADIS16209_STAT_POWER_HIGH_BIT 1
Alexandru Ardelean10dd5712019-06-25 15:48:40 +030072/* Power supply below 2.975 V */
Shreeya Patel55cdd2e2018-03-29 14:42:02 +053073#define ADIS16209_STAT_POWER_LOW_BIT 0
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020074
Shreeya Patel1026bb32018-03-04 18:11:17 +053075#define ADIS16209_CMD_REG 0x3E
76#define ADIS16209_CMD_SW_RESET BIT(7)
77#define ADIS16209_CMD_CLEAR_STAT BIT(4)
78#define ADIS16209_CMD_FACTORY_CAL BIT(1)
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020079
Shreeya Patelf3cfe182018-03-04 18:06:22 +053080#define ADIS16209_ERROR_ACTIVE BIT(14)
Narcisa Ana Maria Vasile21a123b2017-03-04 15:47:08 +020081
Narcisa Ana Maria Vasilea3b2ce92017-03-05 18:26:41 +020082enum adis16209_scan {
83 ADIS16209_SCAN_SUPPLY,
84 ADIS16209_SCAN_ACC_X,
85 ADIS16209_SCAN_ACC_Y,
86 ADIS16209_SCAN_AUX_ADC,
87 ADIS16209_SCAN_TEMP,
88 ADIS16209_SCAN_INCLI_X,
89 ADIS16209_SCAN_INCLI_Y,
90 ADIS16209_SCAN_ROT,
91};
Barry Song671ece12010-05-07 15:38:59 +010092
Lars-Peter Clausen511fb292012-11-13 13:28:00 +000093static const u8 adis16209_addresses[8][1] = {
94 [ADIS16209_SCAN_SUPPLY] = { },
95 [ADIS16209_SCAN_AUX_ADC] = { },
Shreeya Patel200905f2018-03-02 18:55:56 +053096 [ADIS16209_SCAN_ACC_X] = { ADIS16209_XACCL_NULL_REG },
97 [ADIS16209_SCAN_ACC_Y] = { ADIS16209_YACCL_NULL_REG },
98 [ADIS16209_SCAN_INCLI_X] = { ADIS16209_XINCL_NULL_REG },
99 [ADIS16209_SCAN_INCLI_Y] = { ADIS16209_YINCL_NULL_REG },
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000100 [ADIS16209_SCAN_ROT] = { },
101 [ADIS16209_SCAN_TEMP] = { },
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100102};
Barry Song671ece12010-05-07 15:38:59 +0100103
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100104static int adis16209_write_raw(struct iio_dev *indio_dev,
105 struct iio_chan_spec const *chan,
106 int val,
107 int val2,
108 long mask)
109{
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000110 struct adis *st = iio_priv(indio_dev);
Shreeya Patelabb07082018-03-29 14:51:19 +0530111 int m;
Murilo Opsfelder Araujod7b79512014-07-08 01:22:00 +0100112
Shreeya Patelabb07082018-03-29 14:51:19 +0530113 if (mask != IIO_CHAN_INFO_CALIBBIAS)
114 return -EINVAL;
115
116 switch (chan->type) {
117 case IIO_ACCEL:
118 case IIO_INCLI:
119 m = GENMASK(13, 0);
120 break;
121 default:
122 return -EINVAL;
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100123 }
Shreeya Patelabb07082018-03-29 14:51:19 +0530124
125 return adis_write_reg_16(st, adis16209_addresses[chan->scan_index][0],
126 val & m);
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100127}
Barry Song671ece12010-05-07 15:38:59 +0100128
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100129static int adis16209_read_raw(struct iio_dev *indio_dev,
130 struct iio_chan_spec const *chan,
131 int *val, int *val2,
132 long mask)
133{
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000134 struct adis *st = iio_priv(indio_dev);
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100135 int ret;
136 int bits;
137 u8 addr;
138 s16 val16;
Barry Song671ece12010-05-07 15:38:59 +0100139
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100140 switch (mask) {
Jonathan Cameron31313fc2012-04-15 17:41:17 +0100141 case IIO_CHAN_INFO_RAW:
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000142 return adis_single_conversion(indio_dev, chan,
143 ADIS16209_ERROR_ACTIVE, val);
Jonathan Cameronc8a9f802011-10-26 17:41:36 +0100144 case IIO_CHAN_INFO_SCALE:
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100145 switch (chan->type) {
Jonathan Cameron6835cb62011-09-27 09:56:41 +0100146 case IIO_VOLTAGE:
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100147 *val = 0;
Shreeya Patel0df8bae2018-03-04 18:13:12 +0530148 switch (chan->channel) {
149 case 0:
Lars-Peter Clausend5304b72012-10-15 10:35:00 +0100150 *val2 = 305180; /* 0.30518 mV */
Shreeya Patel0df8bae2018-03-04 18:13:12 +0530151 break;
152 case 1:
Lars-Peter Clausend5304b72012-10-15 10:35:00 +0100153 *val2 = 610500; /* 0.6105 mV */
Shreeya Patel0df8bae2018-03-04 18:13:12 +0530154 break;
155 default:
156 return -EINVAL;
157 }
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100158 return IIO_VAL_INT_PLUS_MICRO;
159 case IIO_TEMP:
Shreeya Patelf3cfe182018-03-04 18:06:22 +0530160 *val = -470;
Lars-Peter Clausend5304b72012-10-15 10:35:00 +0100161 *val2 = 0;
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100162 return IIO_VAL_INT_PLUS_MICRO;
163 case IIO_ACCEL:
Shreeya Patelf3cfe182018-03-04 18:06:22 +0530164 /*
165 * IIO base unit for sensitivity of accelerometer
166 * is milli g.
167 * 1 LSB represents 0.244 mg.
168 */
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100169 *val = 0;
Shreeya Patelf3cfe182018-03-04 18:06:22 +0530170 *val2 = IIO_G_TO_M_S_2(244140);
Lars-Peter Clausend5304b72012-10-15 10:35:00 +0100171 return IIO_VAL_INT_PLUS_NANO;
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100172 case IIO_INCLI:
Lars-Peter Clausend5304b72012-10-15 10:35:00 +0100173 case IIO_ROT:
Shreeya Patelf3cfe182018-03-04 18:06:22 +0530174 /*
175 * IIO base units for rotation are degrees.
176 * 1 LSB represents 0.025 milli degrees.
177 */
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100178 *val = 0;
Shreeya Patelf3cfe182018-03-04 18:06:22 +0530179 *val2 = 25000;
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100180 return IIO_VAL_INT_PLUS_MICRO;
181 default:
182 return -EINVAL;
183 }
184 break;
Jonathan Cameronc8a9f802011-10-26 17:41:36 +0100185 case IIO_CHAN_INFO_OFFSET:
Shreeya Patelf3cfe182018-03-04 18:06:22 +0530186 /*
187 * The raw ADC value is 0x4FE when the temperature
Shreeya Patel524c7622018-03-29 14:52:51 +0530188 * is 45 degrees and the scale factor per milli
Shreeya Patelf3cfe182018-03-04 18:06:22 +0530189 * degree celcius is -470.
190 */
191 *val = 25000 / -470 - 0x4FE;
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100192 return IIO_VAL_INT;
Jonathan Cameronc8a9f802011-10-26 17:41:36 +0100193 case IIO_CHAN_INFO_CALIBBIAS:
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100194 switch (chan->type) {
195 case IIO_ACCEL:
196 bits = 14;
197 break;
198 default:
199 return -EINVAL;
Peter Senna Tschudin73327b42012-09-28 10:57:00 +0100200 }
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000201 addr = adis16209_addresses[chan->scan_index][0];
202 ret = adis_read_reg_16(st, addr, &val16);
Mark Stengleinbaecc572017-03-23 02:18:12 -0400203 if (ret)
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100204 return ret;
Shreeya Patel9dd6ec12018-03-04 18:15:06 +0530205
206 *val = sign_extend32(val16, bits - 1);
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100207 return IIO_VAL_INT;
208 }
209 return -EINVAL;
210}
211
Lars-Peter Clausenf4e4b952012-08-09 08:51:00 +0100212static const struct iio_chan_spec adis16209_channels[] = {
Shreeya Patel200905f2018-03-02 18:55:56 +0530213 ADIS_SUPPLY_CHAN(ADIS16209_SUPPLY_OUT_REG, ADIS16209_SCAN_SUPPLY,
214 0, 14),
215 ADIS_TEMP_CHAN(ADIS16209_TEMP_OUT_REG, ADIS16209_SCAN_TEMP, 0, 12),
216 ADIS_ACCEL_CHAN(X, ADIS16209_XACCL_OUT_REG, ADIS16209_SCAN_ACC_X,
Haneen Mohammed9963bce2015-03-25 10:51:55 +0300217 BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
Shreeya Patel200905f2018-03-02 18:55:56 +0530218 ADIS_ACCEL_CHAN(Y, ADIS16209_YACCL_OUT_REG, ADIS16209_SCAN_ACC_Y,
Haneen Mohammed9963bce2015-03-25 10:51:55 +0300219 BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
Shreeya Patel200905f2018-03-02 18:55:56 +0530220 ADIS_AUX_ADC_CHAN(ADIS16209_AUX_ADC_REG, ADIS16209_SCAN_AUX_ADC, 0, 12),
221 ADIS_INCLI_CHAN(X, ADIS16209_XINCL_OUT_REG, ADIS16209_SCAN_INCLI_X,
Haneen Mohammed9963bce2015-03-25 10:51:55 +0300222 0, 0, 14),
Shreeya Patel200905f2018-03-02 18:55:56 +0530223 ADIS_INCLI_CHAN(Y, ADIS16209_YINCL_OUT_REG, ADIS16209_SCAN_INCLI_Y,
Haneen Mohammed9963bce2015-03-25 10:51:55 +0300224 0, 0, 14),
Shreeya Patel200905f2018-03-02 18:55:56 +0530225 ADIS_ROT_CHAN(X, ADIS16209_ROT_OUT_REG, ADIS16209_SCAN_ROT, 0, 0, 14),
Jonathan Camerona34c26dc2011-05-18 14:41:49 +0100226 IIO_CHAN_SOFT_TIMESTAMP(8)
227};
Barry Song671ece12010-05-07 15:38:59 +0100228
Jonathan Cameron6fe81352011-05-18 14:42:37 +0100229static const struct iio_info adis16209_info = {
simran singhalebfb1152017-03-11 19:56:41 +0530230 .read_raw = adis16209_read_raw,
231 .write_raw = adis16209_write_raw,
Lars-Peter Clausenaacff892012-11-13 13:28:00 +0000232 .update_scan_mode = adis_update_scan_mode,
Jonathan Cameron6fe81352011-05-18 14:42:37 +0100233};
234
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000235static const char * const adis16209_status_error_msgs[] = {
Shreeya Patel1026bb32018-03-04 18:11:17 +0530236 [ADIS16209_STAT_SELFTEST_FAIL_BIT] = "Self test failure",
237 [ADIS16209_STAT_SPI_FAIL_BIT] = "SPI failure",
238 [ADIS16209_STAT_FLASH_UPT_FAIL_BIT] = "Flash update failed",
239 [ADIS16209_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V",
Alexandru Ardelean10dd5712019-06-25 15:48:40 +0300240 [ADIS16209_STAT_POWER_LOW_BIT] = "Power supply below 2.975V",
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000241};
242
Nuno Sá380b1072020-01-07 13:17:04 +0200243static const struct adis_timeout adis16209_timeouts = {
244 .reset_ms = ADIS16209_STARTUP_DELAY_MS,
245 .self_test_ms = ADIS16209_STARTUP_DELAY_MS,
246 .sw_reset_ms = ADIS16209_STARTUP_DELAY_MS,
247};
248
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000249static const struct adis_data adis16209_data = {
250 .read_delay = 30,
Shreeya Patel200905f2018-03-02 18:55:56 +0530251 .msc_ctrl_reg = ADIS16209_MSC_CTRL_REG,
Shreeya Patel1026bb32018-03-04 18:11:17 +0530252 .glob_cmd_reg = ADIS16209_CMD_REG,
253 .diag_stat_reg = ADIS16209_STAT_REG,
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000254
255 .self_test_mask = ADIS16209_MSC_CTRL_SELF_TEST_EN,
Nuno Sáfdcf6bb2020-02-10 15:26:02 +0200256 .self_test_reg = ADIS16209_MSC_CTRL_REG,
Lars-Peter Clausen5d116ed2016-04-15 16:59:41 +0200257 .self_test_no_autoclear = true,
Nuno Sá380b1072020-01-07 13:17:04 +0200258 .timeouts = &adis16209_timeouts,
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000259
260 .status_error_msgs = adis16209_status_error_msgs,
Shreeya Patel1026bb32018-03-04 18:11:17 +0530261 .status_error_mask = BIT(ADIS16209_STAT_SELFTEST_FAIL_BIT) |
262 BIT(ADIS16209_STAT_SPI_FAIL_BIT) |
263 BIT(ADIS16209_STAT_FLASH_UPT_FAIL_BIT) |
264 BIT(ADIS16209_STAT_POWER_HIGH_BIT) |
265 BIT(ADIS16209_STAT_POWER_LOW_BIT),
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000266};
267
Bill Pemberton4ae1c612012-11-19 13:21:57 -0500268static int adis16209_probe(struct spi_device *spi)
Barry Song671ece12010-05-07 15:38:59 +0100269{
Jonathan Cameron35212df2011-06-27 13:07:13 +0100270 struct iio_dev *indio_dev;
Shreeya Patel0a9d5dc2018-03-29 14:43:23 +0530271 struct adis *st;
272 int ret;
Jonathan Cameron35212df2011-06-27 13:07:13 +0100273
Sachin Kamat864bf5c2013-08-24 19:48:00 +0100274 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
275 if (!indio_dev)
276 return -ENOMEM;
Shreeya Patelec418772018-03-29 14:44:42 +0530277
Jonathan Cameron35212df2011-06-27 13:07:13 +0100278 st = iio_priv(indio_dev);
Barry Song671ece12010-05-07 15:38:59 +0100279
Jonathan Cameron35212df2011-06-27 13:07:13 +0100280 indio_dev->name = spi->dev.driver->name;
Jonathan Cameron35212df2011-06-27 13:07:13 +0100281 indio_dev->info = &adis16209_info;
282 indio_dev->channels = adis16209_channels;
283 indio_dev->num_channels = ARRAY_SIZE(adis16209_channels);
284 indio_dev->modes = INDIO_DIRECT_MODE;
Barry Song671ece12010-05-07 15:38:59 +0100285
Lars-Peter Clausen511fb292012-11-13 13:28:00 +0000286 ret = adis_init(st, indio_dev, spi, &adis16209_data);
287 if (ret)
Sachin Kamat864bf5c2013-08-24 19:48:00 +0100288 return ret;
Shreeya Patelec418772018-03-29 14:44:42 +0530289
Nuno Sá17ff2042020-09-15 14:02:50 +0200290 ret = devm_adis_setup_buffer_and_trigger(st, indio_dev, NULL);
Barry Song671ece12010-05-07 15:38:59 +0100291 if (ret)
Sachin Kamat864bf5c2013-08-24 19:48:00 +0100292 return ret;
Barry Song671ece12010-05-07 15:38:59 +0100293
Ramona Bolboaca09f83602022-11-22 10:27:51 +0200294 ret = __adis_initial_startup(st);
Barry Song671ece12010-05-07 15:38:59 +0100295 if (ret)
Nuno Sá17ff2042020-09-15 14:02:50 +0200296 return ret;
Jonathan Cameron26d25ae2011-09-02 17:14:40 +0100297
Nuno Sá17ff2042020-09-15 14:02:50 +0200298 return devm_iio_device_register(&spi->dev, indio_dev);
Barry Song671ece12010-05-07 15:38:59 +0100299}
300
301static struct spi_driver adis16209_driver = {
302 .driver = {
303 .name = "adis16209",
Barry Song671ece12010-05-07 15:38:59 +0100304 },
305 .probe = adis16209_probe,
Barry Song671ece12010-05-07 15:38:59 +0100306};
Lars-Peter Clausenae6ae6f2011-11-16 10:13:39 +0100307module_spi_driver(adis16209_driver);
Barry Song671ece12010-05-07 15:38:59 +0100308
309MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
Reto Schneider58401bd2016-11-20 22:11:24 +0100310MODULE_DESCRIPTION("Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer");
Barry Song671ece12010-05-07 15:38:59 +0100311MODULE_LICENSE("GPL v2");
Lars-Peter Clausen55e43902011-11-16 08:53:31 +0100312MODULE_ALIAS("spi:adis16209");
Jonathan Cameron6c9304d2022-01-30 20:56:53 +0000313MODULE_IMPORT_NS(IIO_ADISLIB);