1 #ifndef SPI_ADIS16209_H_
2 #define SPI_ADIS16209_H_
4 #define ADIS16209_STARTUP_DELAY 220 /* ms */
6 #define ADIS16209_READ_REG(a) a
7 #define ADIS16209_WRITE_REG(a) ((a) | 0x80)
9 /* Flash memory write count */
10 #define ADIS16209_FLASH_CNT 0x00
11 /* Output, power supply */
12 #define ADIS16209_SUPPLY_OUT 0x02
13 /* Output, x-axis accelerometer */
14 #define ADIS16209_XACCL_OUT 0x04
15 /* Output, y-axis accelerometer */
16 #define ADIS16209_YACCL_OUT 0x06
17 /* Output, auxiliary ADC input */
18 #define ADIS16209_AUX_ADC 0x08
19 /* Output, temperature */
20 #define ADIS16209_TEMP_OUT 0x0A
21 /* Output, x-axis inclination */
22 #define ADIS16209_XINCL_OUT 0x0C
23 /* Output, y-axis inclination */
24 #define ADIS16209_YINCL_OUT 0x0E
25 /* Output, +/-180 vertical rotational position */
26 #define ADIS16209_ROT_OUT 0x10
27 /* Calibration, x-axis acceleration offset null */
28 #define ADIS16209_XACCL_NULL 0x12
29 /* Calibration, y-axis acceleration offset null */
30 #define ADIS16209_YACCL_NULL 0x14
31 /* Calibration, x-axis inclination offset null */
32 #define ADIS16209_XINCL_NULL 0x16
33 /* Calibration, y-axis inclination offset null */
34 #define ADIS16209_YINCL_NULL 0x18
35 /* Calibration, vertical rotation offset null */
36 #define ADIS16209_ROT_NULL 0x1A
37 /* Alarm 1 amplitude threshold */
38 #define ADIS16209_ALM_MAG1 0x20
39 /* Alarm 2 amplitude threshold */
40 #define ADIS16209_ALM_MAG2 0x22
41 /* Alarm 1, sample period */
42 #define ADIS16209_ALM_SMPL1 0x24
43 /* Alarm 2, sample period */
44 #define ADIS16209_ALM_SMPL2 0x26
46 #define ADIS16209_ALM_CTRL 0x28
47 /* Auxiliary DAC data */
48 #define ADIS16209_AUX_DAC 0x30
49 /* General-purpose digital input/output control */
50 #define ADIS16209_GPIO_CTRL 0x32
51 /* Miscellaneous control */
52 #define ADIS16209_MSC_CTRL 0x34
53 /* Internal sample period (rate) control */
54 #define ADIS16209_SMPL_PRD 0x36
55 /* Operation, filter configuration */
56 #define ADIS16209_AVG_CNT 0x38
57 /* Operation, sleep mode control */
58 #define ADIS16209_SLP_CNT 0x3A
59 /* Diagnostics, system status register */
60 #define ADIS16209_DIAG_STAT 0x3C
61 /* Operation, system command register */
62 #define ADIS16209_GLOB_CMD 0x3E
64 #define ADIS16209_OUTPUTS 8
67 /* Self-test at power-on: 1 = disabled, 0 = enabled */
68 #define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST (1 << 10)
69 /* Self-test enable */
70 #define ADIS16209_MSC_CTRL_SELF_TEST_EN (1 << 8)
71 /* Data-ready enable: 1 = enabled, 0 = disabled */
72 #define ADIS16209_MSC_CTRL_DATA_RDY_EN (1 << 2)
73 /* Data-ready polarity: 1 = active high, 0 = active low */
74 #define ADIS16209_MSC_CTRL_ACTIVE_HIGH (1 << 1)
75 /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
76 #define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 (1 << 0)
79 /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
80 #define ADIS16209_DIAG_STAT_ALARM2 (1<<9)
81 /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
82 #define ADIS16209_DIAG_STAT_ALARM1 (1<<8)
83 /* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */
84 #define ADIS16209_DIAG_STAT_SELFTEST_FAIL (1<<5)
85 /* SPI communications failure */
86 #define ADIS16209_DIAG_STAT_SPI_FAIL (1<<3)
87 /* Flash update failure */
88 #define ADIS16209_DIAG_STAT_FLASH_UPT (1<<2)
89 /* Power supply above 3.625 V */
90 #define ADIS16209_DIAG_STAT_POWER_HIGH (1<<1)
91 /* Power supply below 3.15 V */
92 #define ADIS16209_DIAG_STAT_POWER_LOW (1<<0)
95 #define ADIS16209_GLOB_CMD_SW_RESET (1<<7)
96 #define ADIS16209_GLOB_CMD_CLEAR_STAT (1<<4)
97 #define ADIS16209_GLOB_CMD_FACTORY_CAL (1<<1)
99 #define ADIS16209_MAX_TX 24
100 #define ADIS16209_MAX_RX 24
102 #define ADIS16209_ERROR_ACTIVE (1<<14)
105 * struct adis16209_state - device instance specific data
106 * @us: actual spi_device
107 * @trig: data ready trigger registered with iio
108 * @tx: transmit buffer
109 * @rx: receive buffer
110 * @buf_lock: mutex to protect tx and rx
112 struct adis16209_state
{
113 struct spi_device
*us
;
114 struct iio_trigger
*trig
;
115 struct mutex buf_lock
;
116 u8 tx
[ADIS16209_MAX_TX
] ____cacheline_aligned
;
117 u8 rx
[ADIS16209_MAX_RX
];
120 int adis16209_set_irq(struct iio_dev
*indio_dev
, bool enable
);
122 #define ADIS16209_SCAN_SUPPLY 0
123 #define ADIS16209_SCAN_ACC_X 1
124 #define ADIS16209_SCAN_ACC_Y 2
125 #define ADIS16209_SCAN_AUX_ADC 3
126 #define ADIS16209_SCAN_TEMP 4
127 #define ADIS16209_SCAN_INCLI_X 5
128 #define ADIS16209_SCAN_INCLI_Y 6
129 #define ADIS16209_SCAN_ROT 7
131 #ifdef CONFIG_IIO_BUFFER
133 void adis16209_remove_trigger(struct iio_dev
*indio_dev
);
134 int adis16209_probe_trigger(struct iio_dev
*indio_dev
);
136 ssize_t
adis16209_read_data_from_ring(struct device
*dev
,
137 struct device_attribute
*attr
,
140 int adis16209_configure_ring(struct iio_dev
*indio_dev
);
141 void adis16209_unconfigure_ring(struct iio_dev
*indio_dev
);
143 #else /* CONFIG_IIO_BUFFER */
145 static inline void adis16209_remove_trigger(struct iio_dev
*indio_dev
)
149 static inline int adis16209_probe_trigger(struct iio_dev
*indio_dev
)
154 static inline ssize_t
155 adis16209_read_data_from_ring(struct device
*dev
,
156 struct device_attribute
*attr
,
162 static int adis16209_configure_ring(struct iio_dev
*indio_dev
)
167 static inline void adis16209_unconfigure_ring(struct iio_dev
*indio_dev
)
171 #endif /* CONFIG_IIO_BUFFER */
172 #endif /* SPI_ADIS16209_H_ */