]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/staging/iio/accel/adis16209.h
Fix common misspellings
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / iio / accel / adis16209.h
CommitLineData
671ece14
BS
1#ifndef SPI_ADIS16209_H_
2#define SPI_ADIS16209_H_
3
4#define ADIS16209_STARTUP_DELAY 220 /* ms */
5
6#define ADIS16209_READ_REG(a) a
7#define ADIS16209_WRITE_REG(a) ((a) | 0x80)
8
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
45/* Alarm control */
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
63
64#define ADIS16209_OUTPUTS 8
65
66/* MSC_CTRL */
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)
77
78/* DIAG_STAT */
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)
93
94/* GLOB_CMD */
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)
98
99#define ADIS16209_MAX_TX 24
100#define ADIS16209_MAX_RX 24
101
102#define ADIS16209_ERROR_ACTIVE (1<<14)
103
104/**
105 * struct adis16209_state - device instance specific data
106 * @us: actual spi_device
107 * @work_trigger_to_ring: bh for triggered event handling
671ece14
BS
108 * @last_timestamp: passing timestamp from th to bh of interrupt handler
109 * @indio_dev: industrial I/O device structure
110 * @trig: data ready trigger registered with iio
111 * @tx: transmit buffer
25985edc 112 * @rx: receive buffer
671ece14
BS
113 * @buf_lock: mutex to protect tx and rx
114 **/
115struct adis16209_state {
116 struct spi_device *us;
117 struct work_struct work_trigger_to_ring;
671ece14
BS
118 s64 last_timestamp;
119 struct iio_dev *indio_dev;
120 struct iio_trigger *trig;
121 u8 *tx;
122 u8 *rx;
123 struct mutex buf_lock;
124};
125
126int adis16209_set_irq(struct device *dev, bool enable);
127
128#ifdef CONFIG_IIO_RING_BUFFER
69584bd6
JC
129
130#define ADIS16209_SCAN_SUPPLY 0
131#define ADIS16209_SCAN_ACC_X 1
132#define ADIS16209_SCAN_ACC_Y 2
133#define ADIS16209_SCAN_AUX_ADC 3
134#define ADIS16209_SCAN_TEMP 4
135#define ADIS16209_SCAN_INCLI_X 5
136#define ADIS16209_SCAN_INCLI_Y 6
137#define ADIS16209_SCAN_ROT 7
671ece14
BS
138
139void adis16209_remove_trigger(struct iio_dev *indio_dev);
140int adis16209_probe_trigger(struct iio_dev *indio_dev);
141
142ssize_t adis16209_read_data_from_ring(struct device *dev,
143 struct device_attribute *attr,
144 char *buf);
145
146int adis16209_configure_ring(struct iio_dev *indio_dev);
147void adis16209_unconfigure_ring(struct iio_dev *indio_dev);
148
671ece14
BS
149#else /* CONFIG_IIO_RING_BUFFER */
150
151static inline void adis16209_remove_trigger(struct iio_dev *indio_dev)
152{
153}
154
155static inline int adis16209_probe_trigger(struct iio_dev *indio_dev)
156{
157 return 0;
158}
159
160static inline ssize_t
161adis16209_read_data_from_ring(struct device *dev,
162 struct device_attribute *attr,
163 char *buf)
164{
165 return 0;
166}
167
168static int adis16209_configure_ring(struct iio_dev *indio_dev)
169{
170 return 0;
171}
172
173static inline void adis16209_unconfigure_ring(struct iio_dev *indio_dev)
174{
175}
176
671ece14
BS
177#endif /* CONFIG_IIO_RING_BUFFER */
178#endif /* SPI_ADIS16209_H_ */