adis16400_core.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  1. /*
  2. * adis16400.c support Analog Devices ADIS16400/5
  3. * 3d 2g Linear Accelerometers,
  4. * 3d Gyroscopes,
  5. * 3d Magnetometers via SPI
  6. *
  7. * Copyright (c) 2009 Manuel Stahl <[email protected]>
  8. * Copyright (c) 2007 Jonathan Cameron <[email protected]>
  9. * Copyright (c) 2011 Analog Devices Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. */
  16. #include <linux/interrupt.h>
  17. #include <linux/irq.h>
  18. #include <linux/delay.h>
  19. #include <linux/mutex.h>
  20. #include <linux/device.h>
  21. #include <linux/kernel.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/slab.h>
  24. #include <linux/sysfs.h>
  25. #include <linux/list.h>
  26. #include <linux/module.h>
  27. #include <linux/debugfs.h>
  28. #include <linux/bitops.h>
  29. #include <linux/iio/iio.h>
  30. #include <linux/iio/sysfs.h>
  31. #include <linux/iio/buffer.h>
  32. #include "adis16400.h"
  33. #ifdef CONFIG_DEBUG_FS
  34. static ssize_t adis16400_show_serial_number(struct file *file,
  35. char __user *userbuf, size_t count, loff_t *ppos)
  36. {
  37. struct adis16400_state *st = file->private_data;
  38. u16 lot1, lot2, serial_number;
  39. char buf[16];
  40. size_t len;
  41. int ret;
  42. ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID1, &lot1);
  43. if (ret < 0)
  44. return ret;
  45. ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID2, &lot2);
  46. if (ret < 0)
  47. return ret;
  48. ret = adis_read_reg_16(&st->adis, ADIS16334_SERIAL_NUMBER,
  49. &serial_number);
  50. if (ret < 0)
  51. return ret;
  52. len = snprintf(buf, sizeof(buf), "%.4x-%.4x-%.4x\n", lot1, lot2,
  53. serial_number);
  54. return simple_read_from_buffer(userbuf, count, ppos, buf, len);
  55. }
  56. static const struct file_operations adis16400_serial_number_fops = {
  57. .open = simple_open,
  58. .read = adis16400_show_serial_number,
  59. .llseek = default_llseek,
  60. .owner = THIS_MODULE,
  61. };
  62. static int adis16400_show_product_id(void *arg, u64 *val)
  63. {
  64. struct adis16400_state *st = arg;
  65. uint16_t prod_id;
  66. int ret;
  67. ret = adis_read_reg_16(&st->adis, ADIS16400_PRODUCT_ID, &prod_id);
  68. if (ret < 0)
  69. return ret;
  70. *val = prod_id;
  71. return 0;
  72. }
  73. DEFINE_SIMPLE_ATTRIBUTE(adis16400_product_id_fops,
  74. adis16400_show_product_id, NULL, "%lld\n");
  75. static int adis16400_show_flash_count(void *arg, u64 *val)
  76. {
  77. struct adis16400_state *st = arg;
  78. uint16_t flash_count;
  79. int ret;
  80. ret = adis_read_reg_16(&st->adis, ADIS16400_FLASH_CNT, &flash_count);
  81. if (ret < 0)
  82. return ret;
  83. *val = flash_count;
  84. return 0;
  85. }
  86. DEFINE_SIMPLE_ATTRIBUTE(adis16400_flash_count_fops,
  87. adis16400_show_flash_count, NULL, "%lld\n");
  88. static int adis16400_debugfs_init(struct iio_dev *indio_dev)
  89. {
  90. struct adis16400_state *st = iio_priv(indio_dev);
  91. if (st->variant->flags & ADIS16400_HAS_SERIAL_NUMBER)
  92. debugfs_create_file("serial_number", 0400,
  93. indio_dev->debugfs_dentry, st,
  94. &adis16400_serial_number_fops);
  95. if (st->variant->flags & ADIS16400_HAS_PROD_ID)
  96. debugfs_create_file("product_id", 0400,
  97. indio_dev->debugfs_dentry, st,
  98. &adis16400_product_id_fops);
  99. debugfs_create_file("flash_count", 0400, indio_dev->debugfs_dentry,
  100. st, &adis16400_flash_count_fops);
  101. return 0;
  102. }
  103. #else
  104. static int adis16400_debugfs_init(struct iio_dev *indio_dev)
  105. {
  106. return 0;
  107. }
  108. #endif
  109. enum adis16400_chip_variant {
  110. ADIS16300,
  111. ADIS16334,
  112. ADIS16350,
  113. ADIS16360,
  114. ADIS16362,
  115. ADIS16364,
  116. ADIS16367,
  117. ADIS16400,
  118. ADIS16445,
  119. ADIS16448,
  120. };
  121. static int adis16334_get_freq(struct adis16400_state *st)
  122. {
  123. int ret;
  124. uint16_t t;
  125. ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
  126. if (ret < 0)
  127. return ret;
  128. t >>= ADIS16334_RATE_DIV_SHIFT;
  129. return 819200 >> t;
  130. }
  131. static int adis16334_set_freq(struct adis16400_state *st, unsigned int freq)
  132. {
  133. unsigned int t;
  134. if (freq < 819200)
  135. t = ilog2(819200 / freq);
  136. else
  137. t = 0;
  138. if (t > 0x31)
  139. t = 0x31;
  140. t <<= ADIS16334_RATE_DIV_SHIFT;
  141. t |= ADIS16334_RATE_INT_CLK;
  142. return adis_write_reg_16(&st->adis, ADIS16400_SMPL_PRD, t);
  143. }
  144. static int adis16400_get_freq(struct adis16400_state *st)
  145. {
  146. int sps, ret;
  147. uint16_t t;
  148. ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
  149. if (ret < 0)
  150. return ret;
  151. sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 52851 : 1638404;
  152. sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
  153. return sps;
  154. }
  155. static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq)
  156. {
  157. unsigned int t;
  158. uint8_t val = 0;
  159. t = 1638404 / freq;
  160. if (t >= 128) {
  161. val |= ADIS16400_SMPL_PRD_TIME_BASE;
  162. t = 52851 / freq;
  163. if (t >= 128)
  164. t = 127;
  165. } else if (t != 0) {
  166. t--;
  167. }
  168. val |= t;
  169. if (t >= 0x0A || (val & ADIS16400_SMPL_PRD_TIME_BASE))
  170. st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
  171. else
  172. st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
  173. return adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, val);
  174. }
  175. static const unsigned adis16400_3db_divisors[] = {
  176. [0] = 2, /* Special case */
  177. [1] = 6,
  178. [2] = 12,
  179. [3] = 25,
  180. [4] = 50,
  181. [5] = 100,
  182. [6] = 200,
  183. [7] = 200, /* Not a valid setting */
  184. };
  185. static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
  186. {
  187. struct adis16400_state *st = iio_priv(indio_dev);
  188. uint16_t val16;
  189. int i, ret;
  190. for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
  191. if (sps / adis16400_3db_divisors[i] >= val)
  192. break;
  193. }
  194. ret = adis_read_reg_16(&st->adis, ADIS16400_SENS_AVG, &val16);
  195. if (ret < 0)
  196. return ret;
  197. ret = adis_write_reg_16(&st->adis, ADIS16400_SENS_AVG,
  198. (val16 & ~0x07) | i);
  199. return ret;
  200. }
  201. /* Power down the device */
  202. static int adis16400_stop_device(struct iio_dev *indio_dev)
  203. {
  204. struct adis16400_state *st = iio_priv(indio_dev);
  205. int ret;
  206. ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
  207. ADIS16400_SLP_CNT_POWER_OFF);
  208. if (ret)
  209. dev_err(&indio_dev->dev,
  210. "problem with turning device off: SLP_CNT");
  211. return ret;
  212. }
  213. static int adis16400_initial_setup(struct iio_dev *indio_dev)
  214. {
  215. struct adis16400_state *st = iio_priv(indio_dev);
  216. uint16_t prod_id, smp_prd;
  217. unsigned int device_id;
  218. int ret;
  219. /* use low spi speed for init if the device has a slow mode */
  220. if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
  221. st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
  222. else
  223. st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
  224. st->adis.spi->mode = SPI_MODE_3;
  225. spi_setup(st->adis.spi);
  226. ret = adis_initial_startup(&st->adis);
  227. if (ret)
  228. return ret;
  229. if (st->variant->flags & ADIS16400_HAS_PROD_ID) {
  230. ret = adis_read_reg_16(&st->adis,
  231. ADIS16400_PRODUCT_ID, &prod_id);
  232. if (ret)
  233. goto err_ret;
  234. ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
  235. if (ret != 1) {
  236. ret = -EINVAL;
  237. goto err_ret;
  238. }
  239. if (prod_id != device_id)
  240. dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.",
  241. device_id, prod_id);
  242. dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
  243. indio_dev->name, prod_id,
  244. st->adis.spi->chip_select, st->adis.spi->irq);
  245. }
  246. /* use high spi speed if possible */
  247. if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
  248. ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &smp_prd);
  249. if (ret)
  250. goto err_ret;
  251. if ((smp_prd & ADIS16400_SMPL_PRD_DIV_MASK) < 0x0A) {
  252. st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
  253. spi_setup(st->adis.spi);
  254. }
  255. }
  256. err_ret:
  257. return ret;
  258. }
  259. static const uint8_t adis16400_addresses[] = {
  260. [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
  261. [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
  262. [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
  263. [ADIS16400_SCAN_ACC_X] = ADIS16400_XACCL_OFF,
  264. [ADIS16400_SCAN_ACC_Y] = ADIS16400_YACCL_OFF,
  265. [ADIS16400_SCAN_ACC_Z] = ADIS16400_ZACCL_OFF,
  266. };
  267. static int adis16400_write_raw(struct iio_dev *indio_dev,
  268. struct iio_chan_spec const *chan, int val, int val2, long info)
  269. {
  270. struct adis16400_state *st = iio_priv(indio_dev);
  271. int ret, sps;
  272. switch (info) {
  273. case IIO_CHAN_INFO_CALIBBIAS:
  274. mutex_lock(&indio_dev->mlock);
  275. ret = adis_write_reg_16(&st->adis,
  276. adis16400_addresses[chan->scan_index], val);
  277. mutex_unlock(&indio_dev->mlock);
  278. return ret;
  279. case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
  280. /*
  281. * Need to cache values so we can update if the frequency
  282. * changes.
  283. */
  284. mutex_lock(&indio_dev->mlock);
  285. st->filt_int = val;
  286. /* Work out update to current value */
  287. sps = st->variant->get_freq(st);
  288. if (sps < 0) {
  289. mutex_unlock(&indio_dev->mlock);
  290. return sps;
  291. }
  292. ret = adis16400_set_filter(indio_dev, sps,
  293. val * 1000 + val2 / 1000);
  294. mutex_unlock(&indio_dev->mlock);
  295. return ret;
  296. case IIO_CHAN_INFO_SAMP_FREQ:
  297. sps = val * 1000 + val2 / 1000;
  298. if (sps <= 0)
  299. return -EINVAL;
  300. mutex_lock(&indio_dev->mlock);
  301. ret = st->variant->set_freq(st, sps);
  302. mutex_unlock(&indio_dev->mlock);
  303. return ret;
  304. default:
  305. return -EINVAL;
  306. }
  307. }
  308. static int adis16400_read_raw(struct iio_dev *indio_dev,
  309. struct iio_chan_spec const *chan, int *val, int *val2, long info)
  310. {
  311. struct adis16400_state *st = iio_priv(indio_dev);
  312. int16_t val16;
  313. int ret;
  314. switch (info) {
  315. case IIO_CHAN_INFO_RAW:
  316. return adis_single_conversion(indio_dev, chan, 0, val);
  317. case IIO_CHAN_INFO_SCALE:
  318. switch (chan->type) {
  319. case IIO_ANGL_VEL:
  320. *val = 0;
  321. *val2 = st->variant->gyro_scale_micro;
  322. return IIO_VAL_INT_PLUS_MICRO;
  323. case IIO_VOLTAGE:
  324. *val = 0;
  325. if (chan->channel == 0) {
  326. *val = 2;
  327. *val2 = 418000; /* 2.418 mV */
  328. } else {
  329. *val = 0;
  330. *val2 = 805800; /* 805.8 uV */
  331. }
  332. return IIO_VAL_INT_PLUS_MICRO;
  333. case IIO_ACCEL:
  334. *val = 0;
  335. *val2 = st->variant->accel_scale_micro;
  336. return IIO_VAL_INT_PLUS_MICRO;
  337. case IIO_MAGN:
  338. *val = 0;
  339. *val2 = 500; /* 0.5 mgauss */
  340. return IIO_VAL_INT_PLUS_MICRO;
  341. case IIO_TEMP:
  342. *val = st->variant->temp_scale_nano / 1000000;
  343. *val2 = (st->variant->temp_scale_nano % 1000000);
  344. return IIO_VAL_INT_PLUS_MICRO;
  345. case IIO_PRESSURE:
  346. /* 20 uBar = 0.002kPascal */
  347. *val = 0;
  348. *val2 = 2000;
  349. return IIO_VAL_INT_PLUS_MICRO;
  350. default:
  351. return -EINVAL;
  352. }
  353. case IIO_CHAN_INFO_CALIBBIAS:
  354. mutex_lock(&indio_dev->mlock);
  355. ret = adis_read_reg_16(&st->adis,
  356. adis16400_addresses[chan->scan_index], &val16);
  357. mutex_unlock(&indio_dev->mlock);
  358. if (ret)
  359. return ret;
  360. val16 = sign_extend32(val16, 11);
  361. *val = val16;
  362. return IIO_VAL_INT;
  363. case IIO_CHAN_INFO_OFFSET:
  364. /* currently only temperature */
  365. *val = st->variant->temp_offset;
  366. return IIO_VAL_INT;
  367. case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
  368. mutex_lock(&indio_dev->mlock);
  369. /* Need both the number of taps and the sampling frequency */
  370. ret = adis_read_reg_16(&st->adis,
  371. ADIS16400_SENS_AVG,
  372. &val16);
  373. if (ret < 0) {
  374. mutex_unlock(&indio_dev->mlock);
  375. return ret;
  376. }
  377. ret = st->variant->get_freq(st);
  378. if (ret >= 0) {
  379. ret /= adis16400_3db_divisors[val16 & 0x07];
  380. *val = ret / 1000;
  381. *val2 = (ret % 1000) * 1000;
  382. }
  383. mutex_unlock(&indio_dev->mlock);
  384. if (ret < 0)
  385. return ret;
  386. return IIO_VAL_INT_PLUS_MICRO;
  387. case IIO_CHAN_INFO_SAMP_FREQ:
  388. ret = st->variant->get_freq(st);
  389. if (ret < 0)
  390. return ret;
  391. *val = ret / 1000;
  392. *val2 = (ret % 1000) * 1000;
  393. return IIO_VAL_INT_PLUS_MICRO;
  394. default:
  395. return -EINVAL;
  396. }
  397. }
  398. #define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si, chn) { \
  399. .type = IIO_VOLTAGE, \
  400. .indexed = 1, \
  401. .channel = chn, \
  402. .extend_name = name, \
  403. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
  404. BIT(IIO_CHAN_INFO_SCALE), \
  405. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
  406. .address = (addr), \
  407. .scan_index = (si), \
  408. .scan_type = { \
  409. .sign = 'u', \
  410. .realbits = (bits), \
  411. .storagebits = 16, \
  412. .shift = 0, \
  413. .endianness = IIO_BE, \
  414. }, \
  415. }
  416. #define ADIS16400_SUPPLY_CHAN(addr, bits) \
  417. ADIS16400_VOLTAGE_CHAN(addr, bits, "supply", ADIS16400_SCAN_SUPPLY, 0)
  418. #define ADIS16400_AUX_ADC_CHAN(addr, bits) \
  419. ADIS16400_VOLTAGE_CHAN(addr, bits, NULL, ADIS16400_SCAN_ADC, 1)
  420. #define ADIS16400_GYRO_CHAN(mod, addr, bits) { \
  421. .type = IIO_ANGL_VEL, \
  422. .modified = 1, \
  423. .channel2 = IIO_MOD_ ## mod, \
  424. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
  425. BIT(IIO_CHAN_INFO_CALIBBIAS), \
  426. .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
  427. BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
  428. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
  429. .address = addr, \
  430. .scan_index = ADIS16400_SCAN_GYRO_ ## mod, \
  431. .scan_type = { \
  432. .sign = 's', \
  433. .realbits = (bits), \
  434. .storagebits = 16, \
  435. .shift = 0, \
  436. .endianness = IIO_BE, \
  437. }, \
  438. }
  439. #define ADIS16400_ACCEL_CHAN(mod, addr, bits) { \
  440. .type = IIO_ACCEL, \
  441. .modified = 1, \
  442. .channel2 = IIO_MOD_ ## mod, \
  443. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
  444. BIT(IIO_CHAN_INFO_CALIBBIAS), \
  445. .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
  446. BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
  447. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
  448. .address = (addr), \
  449. .scan_index = ADIS16400_SCAN_ACC_ ## mod, \
  450. .scan_type = { \
  451. .sign = 's', \
  452. .realbits = (bits), \
  453. .storagebits = 16, \
  454. .shift = 0, \
  455. .endianness = IIO_BE, \
  456. }, \
  457. }
  458. #define ADIS16400_MAGN_CHAN(mod, addr, bits) { \
  459. .type = IIO_MAGN, \
  460. .modified = 1, \
  461. .channel2 = IIO_MOD_ ## mod, \
  462. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
  463. .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
  464. BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
  465. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
  466. .address = (addr), \
  467. .scan_index = ADIS16400_SCAN_MAGN_ ## mod, \
  468. .scan_type = { \
  469. .sign = 's', \
  470. .realbits = (bits), \
  471. .storagebits = 16, \
  472. .shift = 0, \
  473. .endianness = IIO_BE, \
  474. }, \
  475. }
  476. #define ADIS16400_MOD_TEMP_NAME_X "x"
  477. #define ADIS16400_MOD_TEMP_NAME_Y "y"
  478. #define ADIS16400_MOD_TEMP_NAME_Z "z"
  479. #define ADIS16400_MOD_TEMP_CHAN(mod, addr, bits) { \
  480. .type = IIO_TEMP, \
  481. .indexed = 1, \
  482. .channel = 0, \
  483. .extend_name = ADIS16400_MOD_TEMP_NAME_ ## mod, \
  484. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
  485. BIT(IIO_CHAN_INFO_OFFSET) | \
  486. BIT(IIO_CHAN_INFO_SCALE), \
  487. .info_mask_shared_by_type = \
  488. BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
  489. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
  490. .address = (addr), \
  491. .scan_index = ADIS16350_SCAN_TEMP_ ## mod, \
  492. .scan_type = { \
  493. .sign = 's', \
  494. .realbits = (bits), \
  495. .storagebits = 16, \
  496. .shift = 0, \
  497. .endianness = IIO_BE, \
  498. }, \
  499. }
  500. #define ADIS16400_TEMP_CHAN(addr, bits) { \
  501. .type = IIO_TEMP, \
  502. .indexed = 1, \
  503. .channel = 0, \
  504. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
  505. BIT(IIO_CHAN_INFO_OFFSET) | \
  506. BIT(IIO_CHAN_INFO_SCALE), \
  507. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
  508. .address = (addr), \
  509. .scan_index = ADIS16350_SCAN_TEMP_X, \
  510. .scan_type = { \
  511. .sign = 's', \
  512. .realbits = (bits), \
  513. .storagebits = 16, \
  514. .shift = 0, \
  515. .endianness = IIO_BE, \
  516. }, \
  517. }
  518. #define ADIS16400_INCLI_CHAN(mod, addr, bits) { \
  519. .type = IIO_INCLI, \
  520. .modified = 1, \
  521. .channel2 = IIO_MOD_ ## mod, \
  522. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
  523. .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
  524. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
  525. .address = (addr), \
  526. .scan_index = ADIS16300_SCAN_INCLI_ ## mod, \
  527. .scan_type = { \
  528. .sign = 's', \
  529. .realbits = (bits), \
  530. .storagebits = 16, \
  531. .shift = 0, \
  532. .endianness = IIO_BE, \
  533. }, \
  534. }
  535. static const struct iio_chan_spec adis16400_channels[] = {
  536. ADIS16400_SUPPLY_CHAN(ADIS16400_SUPPLY_OUT, 14),
  537. ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
  538. ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
  539. ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 14),
  540. ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
  541. ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
  542. ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
  543. ADIS16400_MAGN_CHAN(X, ADIS16400_XMAGN_OUT, 14),
  544. ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 14),
  545. ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 14),
  546. ADIS16400_TEMP_CHAN(ADIS16400_TEMP_OUT, 12),
  547. ADIS16400_AUX_ADC_CHAN(ADIS16400_AUX_ADC, 12),
  548. IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
  549. };
  550. static const struct iio_chan_spec adis16445_channels[] = {
  551. ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 16),
  552. ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 16),
  553. ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 16),
  554. ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 16),
  555. ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 16),
  556. ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 16),
  557. ADIS16400_TEMP_CHAN(ADIS16448_TEMP_OUT, 12),
  558. IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
  559. };
  560. static const struct iio_chan_spec adis16448_channels[] = {
  561. ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 16),
  562. ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 16),
  563. ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 16),
  564. ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 16),
  565. ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 16),
  566. ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 16),
  567. ADIS16400_MAGN_CHAN(X, ADIS16400_XMAGN_OUT, 16),
  568. ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 16),
  569. ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 16),
  570. {
  571. .type = IIO_PRESSURE,
  572. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
  573. .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
  574. .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
  575. .address = ADIS16448_BARO_OUT,
  576. .scan_index = ADIS16400_SCAN_BARO,
  577. .scan_type = {
  578. .sign = 's',
  579. .realbits = 16,
  580. .storagebits = 16,
  581. .endianness = IIO_BE,
  582. },
  583. },
  584. ADIS16400_TEMP_CHAN(ADIS16448_TEMP_OUT, 12),
  585. IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
  586. };
  587. static const struct iio_chan_spec adis16350_channels[] = {
  588. ADIS16400_SUPPLY_CHAN(ADIS16400_SUPPLY_OUT, 12),
  589. ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
  590. ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
  591. ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 14),
  592. ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
  593. ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
  594. ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
  595. ADIS16400_MAGN_CHAN(X, ADIS16400_XMAGN_OUT, 14),
  596. ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 14),
  597. ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 14),
  598. ADIS16400_AUX_ADC_CHAN(ADIS16300_AUX_ADC, 12),
  599. ADIS16400_MOD_TEMP_CHAN(X, ADIS16350_XTEMP_OUT, 12),
  600. ADIS16400_MOD_TEMP_CHAN(Y, ADIS16350_YTEMP_OUT, 12),
  601. ADIS16400_MOD_TEMP_CHAN(Z, ADIS16350_ZTEMP_OUT, 12),
  602. IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
  603. };
  604. static const struct iio_chan_spec adis16300_channels[] = {
  605. ADIS16400_SUPPLY_CHAN(ADIS16400_SUPPLY_OUT, 12),
  606. ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
  607. ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
  608. ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
  609. ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
  610. ADIS16400_TEMP_CHAN(ADIS16350_XTEMP_OUT, 12),
  611. ADIS16400_AUX_ADC_CHAN(ADIS16300_AUX_ADC, 12),
  612. ADIS16400_INCLI_CHAN(X, ADIS16300_PITCH_OUT, 13),
  613. ADIS16400_INCLI_CHAN(Y, ADIS16300_ROLL_OUT, 13),
  614. IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
  615. };
  616. static const struct iio_chan_spec adis16334_channels[] = {
  617. ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
  618. ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
  619. ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 14),
  620. ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
  621. ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
  622. ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
  623. ADIS16400_TEMP_CHAN(ADIS16350_XTEMP_OUT, 12),
  624. IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
  625. };
  626. static struct adis16400_chip_info adis16400_chips[] = {
  627. [ADIS16300] = {
  628. .channels = adis16300_channels,
  629. .num_channels = ARRAY_SIZE(adis16300_channels),
  630. .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
  631. ADIS16400_HAS_SERIAL_NUMBER,
  632. .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
  633. .accel_scale_micro = 5884,
  634. .temp_scale_nano = 140000000, /* 0.14 C */
  635. .temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
  636. .set_freq = adis16400_set_freq,
  637. .get_freq = adis16400_get_freq,
  638. },
  639. [ADIS16334] = {
  640. .channels = adis16334_channels,
  641. .num_channels = ARRAY_SIZE(adis16334_channels),
  642. .flags = ADIS16400_HAS_PROD_ID | ADIS16400_NO_BURST |
  643. ADIS16400_HAS_SERIAL_NUMBER,
  644. .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
  645. .accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
  646. .temp_scale_nano = 67850000, /* 0.06785 C */
  647. .temp_offset = 25000000 / 67850, /* 25 C = 0x00 */
  648. .set_freq = adis16334_set_freq,
  649. .get_freq = adis16334_get_freq,
  650. },
  651. [ADIS16350] = {
  652. .channels = adis16350_channels,
  653. .num_channels = ARRAY_SIZE(adis16350_channels),
  654. .gyro_scale_micro = IIO_DEGREE_TO_RAD(73260), /* 0.07326 deg/s */
  655. .accel_scale_micro = IIO_G_TO_M_S_2(2522), /* 0.002522 g */
  656. .temp_scale_nano = 145300000, /* 0.1453 C */
  657. .temp_offset = 25000000 / 145300, /* 25 C = 0x00 */
  658. .flags = ADIS16400_NO_BURST | ADIS16400_HAS_SLOW_MODE,
  659. .set_freq = adis16400_set_freq,
  660. .get_freq = adis16400_get_freq,
  661. },
  662. [ADIS16360] = {
  663. .channels = adis16350_channels,
  664. .num_channels = ARRAY_SIZE(adis16350_channels),
  665. .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
  666. ADIS16400_HAS_SERIAL_NUMBER,
  667. .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
  668. .accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
  669. .temp_scale_nano = 136000000, /* 0.136 C */
  670. .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
  671. .set_freq = adis16400_set_freq,
  672. .get_freq = adis16400_get_freq,
  673. },
  674. [ADIS16362] = {
  675. .channels = adis16350_channels,
  676. .num_channels = ARRAY_SIZE(adis16350_channels),
  677. .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
  678. ADIS16400_HAS_SERIAL_NUMBER,
  679. .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
  680. .accel_scale_micro = IIO_G_TO_M_S_2(333), /* 0.333 mg */
  681. .temp_scale_nano = 136000000, /* 0.136 C */
  682. .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
  683. .set_freq = adis16400_set_freq,
  684. .get_freq = adis16400_get_freq,
  685. },
  686. [ADIS16364] = {
  687. .channels = adis16350_channels,
  688. .num_channels = ARRAY_SIZE(adis16350_channels),
  689. .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
  690. ADIS16400_HAS_SERIAL_NUMBER,
  691. .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
  692. .accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
  693. .temp_scale_nano = 136000000, /* 0.136 C */
  694. .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
  695. .set_freq = adis16400_set_freq,
  696. .get_freq = adis16400_get_freq,
  697. },
  698. [ADIS16367] = {
  699. .channels = adis16350_channels,
  700. .num_channels = ARRAY_SIZE(adis16350_channels),
  701. .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
  702. ADIS16400_HAS_SERIAL_NUMBER,
  703. .gyro_scale_micro = IIO_DEGREE_TO_RAD(2000), /* 0.2 deg/s */
  704. .accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
  705. .temp_scale_nano = 136000000, /* 0.136 C */
  706. .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
  707. .set_freq = adis16400_set_freq,
  708. .get_freq = adis16400_get_freq,
  709. },
  710. [ADIS16400] = {
  711. .channels = adis16400_channels,
  712. .num_channels = ARRAY_SIZE(adis16400_channels),
  713. .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE,
  714. .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
  715. .accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
  716. .temp_scale_nano = 140000000, /* 0.14 C */
  717. .temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
  718. .set_freq = adis16400_set_freq,
  719. .get_freq = adis16400_get_freq,
  720. },
  721. [ADIS16445] = {
  722. .channels = adis16445_channels,
  723. .num_channels = ARRAY_SIZE(adis16445_channels),
  724. .flags = ADIS16400_HAS_PROD_ID |
  725. ADIS16400_HAS_SERIAL_NUMBER |
  726. ADIS16400_BURST_DIAG_STAT,
  727. .gyro_scale_micro = IIO_DEGREE_TO_RAD(10000), /* 0.01 deg/s */
  728. .accel_scale_micro = IIO_G_TO_M_S_2(250), /* 1/4000 g */
  729. .temp_scale_nano = 73860000, /* 0.07386 C */
  730. .temp_offset = 31000000 / 73860, /* 31 C = 0x00 */
  731. .set_freq = adis16334_set_freq,
  732. .get_freq = adis16334_get_freq,
  733. },
  734. [ADIS16448] = {
  735. .channels = adis16448_channels,
  736. .num_channels = ARRAY_SIZE(adis16448_channels),
  737. .flags = ADIS16400_HAS_PROD_ID |
  738. ADIS16400_HAS_SERIAL_NUMBER |
  739. ADIS16400_BURST_DIAG_STAT,
  740. .gyro_scale_micro = IIO_DEGREE_TO_RAD(40000), /* 0.04 deg/s */
  741. .accel_scale_micro = IIO_G_TO_M_S_2(833), /* 1/1200 g */
  742. .temp_scale_nano = 73860000, /* 0.07386 C */
  743. .temp_offset = 31000000 / 73860, /* 31 C = 0x00 */
  744. .set_freq = adis16334_set_freq,
  745. .get_freq = adis16334_get_freq,
  746. }
  747. };
  748. static const struct iio_info adis16400_info = {
  749. .driver_module = THIS_MODULE,
  750. .read_raw = &adis16400_read_raw,
  751. .write_raw = &adis16400_write_raw,
  752. .update_scan_mode = adis16400_update_scan_mode,
  753. .debugfs_reg_access = adis_debugfs_reg_access,
  754. };
  755. static const char * const adis16400_status_error_msgs[] = {
  756. [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
  757. [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
  758. [ADIS16400_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
  759. [ADIS16400_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
  760. [ADIS16400_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
  761. [ADIS16400_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
  762. [ADIS16400_DIAG_STAT_ALARM2] = "Alarm 2 active",
  763. [ADIS16400_DIAG_STAT_ALARM1] = "Alarm 1 active",
  764. [ADIS16400_DIAG_STAT_FLASH_CHK] = "Flash checksum error",
  765. [ADIS16400_DIAG_STAT_SELF_TEST] = "Self test error",
  766. [ADIS16400_DIAG_STAT_OVERFLOW] = "Sensor overrange",
  767. [ADIS16400_DIAG_STAT_SPI_FAIL] = "SPI failure",
  768. [ADIS16400_DIAG_STAT_FLASH_UPT] = "Flash update failed",
  769. [ADIS16400_DIAG_STAT_POWER_HIGH] = "Power supply above 5.25V",
  770. [ADIS16400_DIAG_STAT_POWER_LOW] = "Power supply below 4.75V",
  771. };
  772. static const struct adis_data adis16400_data = {
  773. .msc_ctrl_reg = ADIS16400_MSC_CTRL,
  774. .glob_cmd_reg = ADIS16400_GLOB_CMD,
  775. .diag_stat_reg = ADIS16400_DIAG_STAT,
  776. .read_delay = 50,
  777. .write_delay = 50,
  778. .self_test_mask = ADIS16400_MSC_CTRL_MEM_TEST,
  779. .startup_delay = ADIS16400_STARTUP_DELAY,
  780. .status_error_msgs = adis16400_status_error_msgs,
  781. .status_error_mask = BIT(ADIS16400_DIAG_STAT_ZACCL_FAIL) |
  782. BIT(ADIS16400_DIAG_STAT_YACCL_FAIL) |
  783. BIT(ADIS16400_DIAG_STAT_XACCL_FAIL) |
  784. BIT(ADIS16400_DIAG_STAT_XGYRO_FAIL) |
  785. BIT(ADIS16400_DIAG_STAT_YGYRO_FAIL) |
  786. BIT(ADIS16400_DIAG_STAT_ZGYRO_FAIL) |
  787. BIT(ADIS16400_DIAG_STAT_ALARM2) |
  788. BIT(ADIS16400_DIAG_STAT_ALARM1) |
  789. BIT(ADIS16400_DIAG_STAT_FLASH_CHK) |
  790. BIT(ADIS16400_DIAG_STAT_SELF_TEST) |
  791. BIT(ADIS16400_DIAG_STAT_OVERFLOW) |
  792. BIT(ADIS16400_DIAG_STAT_SPI_FAIL) |
  793. BIT(ADIS16400_DIAG_STAT_FLASH_UPT) |
  794. BIT(ADIS16400_DIAG_STAT_POWER_HIGH) |
  795. BIT(ADIS16400_DIAG_STAT_POWER_LOW),
  796. };
  797. static void adis16400_setup_chan_mask(struct adis16400_state *st)
  798. {
  799. const struct adis16400_chip_info *chip_info = st->variant;
  800. unsigned i;
  801. for (i = 0; i < chip_info->num_channels; i++) {
  802. const struct iio_chan_spec *ch = &chip_info->channels[i];
  803. if (ch->scan_index >= 0 &&
  804. ch->scan_index != ADIS16400_SCAN_TIMESTAMP)
  805. st->avail_scan_mask[0] |= BIT(ch->scan_index);
  806. }
  807. }
  808. static int adis16400_probe(struct spi_device *spi)
  809. {
  810. struct adis16400_state *st;
  811. struct iio_dev *indio_dev;
  812. int ret;
  813. indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
  814. if (indio_dev == NULL)
  815. return -ENOMEM;
  816. st = iio_priv(indio_dev);
  817. /* this is only used for removal purposes */
  818. spi_set_drvdata(spi, indio_dev);
  819. /* setup the industrialio driver allocated elements */
  820. st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data];
  821. indio_dev->dev.parent = &spi->dev;
  822. indio_dev->name = spi_get_device_id(spi)->name;
  823. indio_dev->channels = st->variant->channels;
  824. indio_dev->num_channels = st->variant->num_channels;
  825. indio_dev->info = &adis16400_info;
  826. indio_dev->modes = INDIO_DIRECT_MODE;
  827. if (!(st->variant->flags & ADIS16400_NO_BURST)) {
  828. adis16400_setup_chan_mask(st);
  829. indio_dev->available_scan_masks = st->avail_scan_mask;
  830. }
  831. ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
  832. if (ret)
  833. return ret;
  834. ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev,
  835. adis16400_trigger_handler);
  836. if (ret)
  837. return ret;
  838. /* Get the device into a sane initial state */
  839. ret = adis16400_initial_setup(indio_dev);
  840. if (ret)
  841. goto error_cleanup_buffer;
  842. ret = iio_device_register(indio_dev);
  843. if (ret)
  844. goto error_cleanup_buffer;
  845. adis16400_debugfs_init(indio_dev);
  846. return 0;
  847. error_cleanup_buffer:
  848. adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
  849. return ret;
  850. }
  851. static int adis16400_remove(struct spi_device *spi)
  852. {
  853. struct iio_dev *indio_dev = spi_get_drvdata(spi);
  854. struct adis16400_state *st = iio_priv(indio_dev);
  855. iio_device_unregister(indio_dev);
  856. adis16400_stop_device(indio_dev);
  857. adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
  858. return 0;
  859. }
  860. static const struct spi_device_id adis16400_id[] = {
  861. {"adis16300", ADIS16300},
  862. {"adis16305", ADIS16300},
  863. {"adis16334", ADIS16334},
  864. {"adis16350", ADIS16350},
  865. {"adis16354", ADIS16350},
  866. {"adis16355", ADIS16350},
  867. {"adis16360", ADIS16360},
  868. {"adis16362", ADIS16362},
  869. {"adis16364", ADIS16364},
  870. {"adis16365", ADIS16360},
  871. {"adis16367", ADIS16367},
  872. {"adis16400", ADIS16400},
  873. {"adis16405", ADIS16400},
  874. {"adis16445", ADIS16445},
  875. {"adis16448", ADIS16448},
  876. {}
  877. };
  878. MODULE_DEVICE_TABLE(spi, adis16400_id);
  879. static struct spi_driver adis16400_driver = {
  880. .driver = {
  881. .name = "adis16400",
  882. },
  883. .id_table = adis16400_id,
  884. .probe = adis16400_probe,
  885. .remove = adis16400_remove,
  886. };
  887. module_spi_driver(adis16400_driver);
  888. MODULE_AUTHOR("Manuel Stahl <[email protected]>");
  889. MODULE_DESCRIPTION("Analog Devices ADIS16400/5 IMU SPI driver");
  890. MODULE_LICENSE("GPL v2");