Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[pandora-kernel.git] / drivers / staging / iio / gyro / adis16060.h
1 #ifndef SPI_ADIS16060_H_
2 #define SPI_ADIS16060_H_
3
4 #define ADIS16060_GYRO       0x20 /* Measure Angular Rate (Gyro) */
5 #define ADIS16060_SUPPLY_OUT 0x10 /* Measure Temperature */
6 #define ADIS16060_AIN2       0x80 /* Measure AIN2 */
7 #define ADIS16060_AIN1       0x40 /* Measure AIN1 */
8 #define ADIS16060_TEMP_OUT   0x22 /* Set Positive Self-Test and Output for Angular Rate */
9 #define ADIS16060_ANGL_OUT   0x21 /* Set Negative Self-Test and Output for Angular Rate */
10
11 #define ADIS16060_MAX_TX     3
12 #define ADIS16060_MAX_RX     3
13
14 /**
15  * struct adis16060_state - device instance specific data
16  * @us_w:                       actual spi_device to write data
17  * @work_trigger_to_ring: bh for triggered event handling
18  * @inter:              used to check if new interrupt has been triggered
19  * @last_timestamp:     passing timestamp from th to bh of interrupt handler
20  * @indio_dev:          industrial I/O device structure
21  * @trig:               data ready trigger registered with iio
22  * @tx:                 transmit buffer
23  * @rx:                 recieve buffer
24  * @buf_lock:           mutex to protect tx and rx
25  **/
26 struct adis16060_state {
27         struct spi_device               *us_w;
28         struct spi_device               *us_r;
29         struct work_struct              work_trigger_to_ring;
30         s64                             last_timestamp;
31         struct iio_dev                  *indio_dev;
32         struct iio_trigger              *trig;
33         u8                              *tx;
34         u8                              *rx;
35         struct mutex                    buf_lock;
36 };
37
38 #if defined(CONFIG_IIO_RING_BUFFER) && defined(THIS_HAS_RING_BUFFER_SUPPORT)
39 /* At the moment triggers are only used for ring buffer
40  * filling. This may change!
41  */
42
43 enum adis16060_scan {
44         ADIS16060_SCAN_GYRO,
45         ADIS16060_SCAN_TEMP,
46         ADIS16060_SCAN_ADC_1,
47         ADIS16060_SCAN_ADC_2,
48 };
49
50 void adis16060_remove_trigger(struct iio_dev *indio_dev);
51 int adis16060_probe_trigger(struct iio_dev *indio_dev);
52
53 ssize_t adis16060_read_data_from_ring(struct device *dev,
54                                       struct device_attribute *attr,
55                                       char *buf);
56
57
58 int adis16060_configure_ring(struct iio_dev *indio_dev);
59 void adis16060_unconfigure_ring(struct iio_dev *indio_dev);
60
61 int adis16060_initialize_ring(struct iio_ring_buffer *ring);
62 void adis16060_uninitialize_ring(struct iio_ring_buffer *ring);
63 #else /* CONFIG_IIO_RING_BUFFER */
64
65 static inline void adis16060_remove_trigger(struct iio_dev *indio_dev)
66 {
67 }
68
69 static inline int adis16060_probe_trigger(struct iio_dev *indio_dev)
70 {
71         return 0;
72 }
73
74 static inline ssize_t
75 adis16060_read_data_from_ring(struct device *dev,
76                               struct device_attribute *attr,
77                               char *buf)
78 {
79         return 0;
80 }
81
82 static int adis16060_configure_ring(struct iio_dev *indio_dev)
83 {
84         return 0;
85 }
86
87 static inline void adis16060_unconfigure_ring(struct iio_dev *indio_dev)
88 {
89 }
90
91 static inline int adis16060_initialize_ring(struct iio_ring_buffer *ring)
92 {
93         return 0;
94 }
95
96 static inline void adis16060_uninitialize_ring(struct iio_ring_buffer *ring)
97 {
98 }
99
100 #endif /* CONFIG_IIO_RING_BUFFER */
101 #endif /* SPI_ADIS16060_H_ */