/drivers/staging/iio/accel/adis16240.h

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t · C Header · 196 lines · 108 code · 24 blank · 64 comment · 0 complexity · d703f05ef3298d7686540d6b03fcbc33 MD5 · raw file

  1. #ifndef SPI_ADIS16240_H_
  2. #define SPI_ADIS16240_H_
  3. #define ADIS16240_STARTUP_DELAY 220 /* ms */
  4. #define ADIS16240_READ_REG(a) a
  5. #define ADIS16240_WRITE_REG(a) ((a) | 0x80)
  6. /* Flash memory write count */
  7. #define ADIS16240_FLASH_CNT 0x00
  8. /* Output, power supply */
  9. #define ADIS16240_SUPPLY_OUT 0x02
  10. /* Output, x-axis accelerometer */
  11. #define ADIS16240_XACCL_OUT 0x04
  12. /* Output, y-axis accelerometer */
  13. #define ADIS16240_YACCL_OUT 0x06
  14. /* Output, z-axis accelerometer */
  15. #define ADIS16240_ZACCL_OUT 0x08
  16. /* Output, auxiliary ADC input */
  17. #define ADIS16240_AUX_ADC 0x0A
  18. /* Output, temperature */
  19. #define ADIS16240_TEMP_OUT 0x0C
  20. /* Output, x-axis acceleration peak */
  21. #define ADIS16240_XPEAK_OUT 0x0E
  22. /* Output, y-axis acceleration peak */
  23. #define ADIS16240_YPEAK_OUT 0x10
  24. /* Output, z-axis acceleration peak */
  25. #define ADIS16240_ZPEAK_OUT 0x12
  26. /* Output, sum-of-squares acceleration peak */
  27. #define ADIS16240_XYZPEAK_OUT 0x14
  28. /* Output, Capture Buffer 1, X and Y acceleration */
  29. #define ADIS16240_CAPT_BUF1 0x16
  30. /* Output, Capture Buffer 2, Z acceleration */
  31. #define ADIS16240_CAPT_BUF2 0x18
  32. /* Diagnostic, error flags */
  33. #define ADIS16240_DIAG_STAT 0x1A
  34. /* Diagnostic, event counter */
  35. #define ADIS16240_EVNT_CNTR 0x1C
  36. /* Diagnostic, check sum value from firmware test */
  37. #define ADIS16240_CHK_SUM 0x1E
  38. /* Calibration, x-axis acceleration offset adjustment */
  39. #define ADIS16240_XACCL_OFF 0x20
  40. /* Calibration, y-axis acceleration offset adjustment */
  41. #define ADIS16240_YACCL_OFF 0x22
  42. /* Calibration, z-axis acceleration offset adjustment */
  43. #define ADIS16240_ZACCL_OFF 0x24
  44. /* Clock, hour and minute */
  45. #define ADIS16240_CLK_TIME 0x2E
  46. /* Clock, month and day */
  47. #define ADIS16240_CLK_DATE 0x30
  48. /* Clock, year */
  49. #define ADIS16240_CLK_YEAR 0x32
  50. /* Wake-up setting, hour and minute */
  51. #define ADIS16240_WAKE_TIME 0x34
  52. /* Wake-up setting, month and day */
  53. #define ADIS16240_WAKE_DATE 0x36
  54. /* Alarm 1 amplitude threshold */
  55. #define ADIS16240_ALM_MAG1 0x38
  56. /* Alarm 2 amplitude threshold */
  57. #define ADIS16240_ALM_MAG2 0x3A
  58. /* Alarm control */
  59. #define ADIS16240_ALM_CTRL 0x3C
  60. /* Capture, external trigger control */
  61. #define ADIS16240_XTRIG_CTRL 0x3E
  62. /* Capture, address pointer */
  63. #define ADIS16240_CAPT_PNTR 0x40
  64. /* Capture, configuration and control */
  65. #define ADIS16240_CAPT_CTRL 0x42
  66. /* General-purpose digital input/output control */
  67. #define ADIS16240_GPIO_CTRL 0x44
  68. /* Miscellaneous control */
  69. #define ADIS16240_MSC_CTRL 0x46
  70. /* Internal sample period (rate) control */
  71. #define ADIS16240_SMPL_PRD 0x48
  72. /* System command */
  73. #define ADIS16240_GLOB_CMD 0x4A
  74. #define ADIS16240_OUTPUTS 6
  75. /* MSC_CTRL */
  76. /* Enables sum-of-squares output (XYZPEAK_OUT) */
  77. #define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN (1 << 15)
  78. /* Enables peak tracking output (XPEAK_OUT, YPEAK_OUT, and ZPEAK_OUT) */
  79. #define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN (1 << 14)
  80. /* Self-test enable: 1 = apply electrostatic force, 0 = disabled */
  81. #define ADIS16240_MSC_CTRL_SELF_TEST_EN (1 << 8)
  82. /* Data-ready enable: 1 = enabled, 0 = disabled */
  83. #define ADIS16240_MSC_CTRL_DATA_RDY_EN (1 << 2)
  84. /* Data-ready polarity: 1 = active high, 0 = active low */
  85. #define ADIS16240_MSC_CTRL_ACTIVE_HIGH (1 << 1)
  86. /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
  87. #define ADIS16240_MSC_CTRL_DATA_RDY_DIO2 (1 << 0)
  88. /* DIAG_STAT */
  89. /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
  90. #define ADIS16240_DIAG_STAT_ALARM2 (1<<9)
  91. /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
  92. #define ADIS16240_DIAG_STAT_ALARM1 (1<<8)
  93. /* Capture buffer full: 1 = capture buffer is full */
  94. #define ADIS16240_DIAG_STAT_CPT_BUF_FUL (1<<7)
  95. /* Flash test, checksum flag: 1 = mismatch, 0 = match */
  96. #define ADIS16240_DIAG_STAT_CHKSUM (1<<6)
  97. /* Power-on, self-test flag: 1 = failure, 0 = pass */
  98. #define ADIS16240_DIAG_STAT_PWRON_FAIL (1<<5)
  99. /* Power-on self-test: 1 = in-progress, 0 = complete */
  100. #define ADIS16240_DIAG_STAT_PWRON_BUSY (1<<4)
  101. /* SPI communications failure */
  102. #define ADIS16240_DIAG_STAT_SPI_FAIL (1<<3)
  103. /* Flash update failure */
  104. #define ADIS16240_DIAG_STAT_FLASH_UPT (1<<2)
  105. /* Power supply above 3.625 V */
  106. #define ADIS16240_DIAG_STAT_POWER_HIGH (1<<1)
  107. /* Power supply below 3.15 V */
  108. #define ADIS16240_DIAG_STAT_POWER_LOW (1<<0)
  109. /* GLOB_CMD */
  110. #define ADIS16240_GLOB_CMD_RESUME (1<<8)
  111. #define ADIS16240_GLOB_CMD_SW_RESET (1<<7)
  112. #define ADIS16240_GLOB_CMD_STANDBY (1<<2)
  113. #define ADIS16240_ERROR_ACTIVE (1<<14)
  114. #define ADIS16240_MAX_TX 24
  115. #define ADIS16240_MAX_RX 24
  116. /**
  117. * struct adis16240_state - device instance specific data
  118. * @us: actual spi_device
  119. * @trig: data ready trigger registered with iio
  120. * @tx: transmit buffer
  121. * @rx: receive buffer
  122. * @buf_lock: mutex to protect tx and rx
  123. **/
  124. struct adis16240_state {
  125. struct spi_device *us;
  126. struct iio_trigger *trig;
  127. struct mutex buf_lock;
  128. u8 tx[ADIS16240_MAX_TX] ____cacheline_aligned;
  129. u8 rx[ADIS16240_MAX_RX];
  130. };
  131. int adis16240_set_irq(struct iio_dev *indio_dev, bool enable);
  132. /* At the moment triggers are only used for ring buffer
  133. * filling. This may change!
  134. */
  135. #define ADIS16240_SCAN_SUPPLY 0
  136. #define ADIS16240_SCAN_ACC_X 1
  137. #define ADIS16240_SCAN_ACC_Y 2
  138. #define ADIS16240_SCAN_ACC_Z 3
  139. #define ADIS16240_SCAN_AUX_ADC 4
  140. #define ADIS16240_SCAN_TEMP 5
  141. #ifdef CONFIG_IIO_RING_BUFFER
  142. void adis16240_remove_trigger(struct iio_dev *indio_dev);
  143. int adis16240_probe_trigger(struct iio_dev *indio_dev);
  144. ssize_t adis16240_read_data_from_ring(struct device *dev,
  145. struct device_attribute *attr,
  146. char *buf);
  147. int adis16240_configure_ring(struct iio_dev *indio_dev);
  148. void adis16240_unconfigure_ring(struct iio_dev *indio_dev);
  149. #else /* CONFIG_IIO_RING_BUFFER */
  150. static inline void adis16240_remove_trigger(struct iio_dev *indio_dev)
  151. {
  152. }
  153. static inline int adis16240_probe_trigger(struct iio_dev *indio_dev)
  154. {
  155. return 0;
  156. }
  157. static inline ssize_t
  158. adis16240_read_data_from_ring(struct device *dev,
  159. struct device_attribute *attr,
  160. char *buf)
  161. {
  162. return 0;
  163. }
  164. static int adis16240_configure_ring(struct iio_dev *indio_dev)
  165. {
  166. return 0;
  167. }
  168. static inline void adis16240_unconfigure_ring(struct iio_dev *indio_dev)
  169. {
  170. }
  171. #endif /* CONFIG_IIO_RING_BUFFER */
  172. #endif /* SPI_ADIS16240_H_ */