PageRenderTime 38ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/staging/iio/accel/adis16203.h

https://bitbucket.org/slukk/jb-tsm-kernel-4.2
C Header | 127 lines | 93 code | 22 blank | 12 comment | 0 complexity | 164ef909754a023ba313655314ade118 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. #ifndef SPI_ADIS16203_H_
  2. #define SPI_ADIS16203_H_
  3. #define ADIS16203_STARTUP_DELAY 220 /* ms */
  4. #define ADIS16203_READ_REG(a) a
  5. #define ADIS16203_WRITE_REG(a) ((a) | 0x80)
  6. #define ADIS16203_FLASH_CNT 0x00 /* Flash memory write count */
  7. #define ADIS16203_SUPPLY_OUT 0x02 /* Output, power supply */
  8. #define ADIS16203_AUX_ADC 0x08 /* Output, auxiliary ADC input */
  9. #define ADIS16203_TEMP_OUT 0x0A /* Output, temperature */
  10. #define ADIS16203_XINCL_OUT 0x0C /* Output, x-axis inclination */
  11. #define ADIS16203_YINCL_OUT 0x0E /* Output, y-axis inclination */
  12. #define ADIS16203_INCL_NULL 0x18 /* Incline null calibration */
  13. #define ADIS16203_ALM_MAG1 0x20 /* Alarm 1 amplitude threshold */
  14. #define ADIS16203_ALM_MAG2 0x22 /* Alarm 2 amplitude threshold */
  15. #define ADIS16203_ALM_SMPL1 0x24 /* Alarm 1, sample period */
  16. #define ADIS16203_ALM_SMPL2 0x26 /* Alarm 2, sample period */
  17. #define ADIS16203_ALM_CTRL 0x28 /* Alarm control */
  18. #define ADIS16203_AUX_DAC 0x30 /* Auxiliary DAC data */
  19. #define ADIS16203_GPIO_CTRL 0x32 /* General-purpose digital input/output control */
  20. #define ADIS16203_MSC_CTRL 0x34 /* Miscellaneous control */
  21. #define ADIS16203_SMPL_PRD 0x36 /* Internal sample period (rate) control */
  22. #define ADIS16203_AVG_CNT 0x38 /* Operation, filter configuration */
  23. #define ADIS16203_SLP_CNT 0x3A /* Operation, sleep mode control */
  24. #define ADIS16203_DIAG_STAT 0x3C /* Diagnostics, system status register */
  25. #define ADIS16203_GLOB_CMD 0x3E /* Operation, system command register */
  26. #define ADIS16203_OUTPUTS 5
  27. /* MSC_CTRL */
  28. #define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST (1 << 10) /* Self-test at power-on: 1 = disabled, 0 = enabled */
  29. #define ADIS16203_MSC_CTRL_REVERSE_ROT_EN (1 << 9) /* Reverses rotation of both inclination outputs */
  30. #define ADIS16203_MSC_CTRL_SELF_TEST_EN (1 << 8) /* Self-test enable */
  31. #define ADIS16203_MSC_CTRL_DATA_RDY_EN (1 << 2) /* Data-ready enable: 1 = enabled, 0 = disabled */
  32. #define ADIS16203_MSC_CTRL_ACTIVE_HIGH (1 << 1) /* Data-ready polarity: 1 = active high, 0 = active low */
  33. #define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 (1 << 0) /* Data-ready line selection: 1 = DIO1, 0 = DIO0 */
  34. /* DIAG_STAT */
  35. #define ADIS16203_DIAG_STAT_ALARM2 (1<<9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
  36. #define ADIS16203_DIAG_STAT_ALARM1 (1<<8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
  37. #define ADIS16203_DIAG_STAT_SELFTEST_FAIL (1<<5) /* Self-test diagnostic error flag */
  38. #define ADIS16203_DIAG_STAT_SPI_FAIL (1<<3) /* SPI communications failure */
  39. #define ADIS16203_DIAG_STAT_FLASH_UPT (1<<2) /* Flash update failure */
  40. #define ADIS16203_DIAG_STAT_POWER_HIGH (1<<1) /* Power supply above 3.625 V */
  41. #define ADIS16203_DIAG_STAT_POWER_LOW (1<<0) /* Power supply below 3.15 V */
  42. /* GLOB_CMD */
  43. #define ADIS16203_GLOB_CMD_SW_RESET (1<<7)
  44. #define ADIS16203_GLOB_CMD_CLEAR_STAT (1<<4)
  45. #define ADIS16203_GLOB_CMD_FACTORY_CAL (1<<1)
  46. #define ADIS16203_MAX_TX 12
  47. #define ADIS16203_MAX_RX 10
  48. #define ADIS16203_ERROR_ACTIVE (1<<14)
  49. /**
  50. * struct adis16203_state - device instance specific data
  51. * @us: actual spi_device
  52. * @indio_dev: industrial I/O device structure
  53. * @trig: data ready trigger registered with iio
  54. * @tx: transmit buffer
  55. * @rx: receive buffer
  56. * @buf_lock: mutex to protect tx and rx
  57. **/
  58. struct adis16203_state {
  59. struct spi_device *us;
  60. struct iio_dev *indio_dev;
  61. struct iio_trigger *trig;
  62. u8 *tx;
  63. u8 *rx;
  64. struct mutex buf_lock;
  65. };
  66. int adis16203_set_irq(struct iio_dev *indio_dev, bool enable);
  67. enum adis16203_scan {
  68. ADIS16203_SCAN_SUPPLY,
  69. ADIS16203_SCAN_AUX_ADC,
  70. ADIS16203_SCAN_TEMP,
  71. ADIS16203_SCAN_INCLI_X,
  72. ADIS16203_SCAN_INCLI_Y,
  73. };
  74. #ifdef CONFIG_IIO_RING_BUFFER
  75. void adis16203_remove_trigger(struct iio_dev *indio_dev);
  76. int adis16203_probe_trigger(struct iio_dev *indio_dev);
  77. ssize_t adis16203_read_data_from_ring(struct device *dev,
  78. struct device_attribute *attr,
  79. char *buf);
  80. int adis16203_configure_ring(struct iio_dev *indio_dev);
  81. void adis16203_unconfigure_ring(struct iio_dev *indio_dev);
  82. #else /* CONFIG_IIO_RING_BUFFER */
  83. static inline void adis16203_remove_trigger(struct iio_dev *indio_dev)
  84. {
  85. }
  86. static inline int adis16203_probe_trigger(struct iio_dev *indio_dev)
  87. {
  88. return 0;
  89. }
  90. static inline ssize_t
  91. adis16203_read_data_from_ring(struct device *dev,
  92. struct device_attribute *attr,
  93. char *buf)
  94. {
  95. return 0;
  96. }
  97. static int adis16203_configure_ring(struct iio_dev *indio_dev)
  98. {
  99. return 0;
  100. }
  101. static inline void adis16203_unconfigure_ring(struct iio_dev *indio_dev)
  102. {
  103. }
  104. #endif /* CONFIG_IIO_RING_BUFFER */
  105. #endif /* SPI_ADIS16203_H_ */