Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
[pandora-kernel.git] / drivers / staging / iio / adc / ad7476.h
1 /*
2  * AD7476/5/7/8 (A) SPI ADC driver
3  *
4  * Copyright 2010 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2 or later.
7  */
8 #ifndef IIO_ADC_AD7476_H_
9 #define IIO_ADC_AD7476_H_
10
11 #define RES_MASK(bits)  ((1 << (bits)) - 1)
12
13 /*
14  * TODO: struct ad7476_platform_data needs to go into include/linux/iio
15  */
16
17 struct ad7476_platform_data {
18         u16                             vref_mv;
19 };
20
21 struct ad7476_chip_info {
22         u8                              bits;
23         u8                              storagebits;
24         u8                              res_shift;
25         char                            sign;
26         u16                             int_vref_mv;
27 };
28
29 struct ad7476_state {
30         struct iio_dev                  *indio_dev;
31         struct spi_device               *spi;
32         const struct ad7476_chip_info   *chip_info;
33         struct regulator                *reg;
34         struct work_struct              poll_work;
35         atomic_t                        protect_ring;
36         u16                             int_vref_mv;
37         struct spi_transfer             xfer;
38         struct spi_message              msg;
39         /*
40          * DMA (thus cache coherency maintenance) requires the
41          * transfer buffers to live in their own cache lines.
42          */
43         unsigned char                   data[2] ____cacheline_aligned;
44 };
45
46 enum ad7476_supported_device_ids {
47         ID_AD7466,
48         ID_AD7467,
49         ID_AD7468,
50         ID_AD7475,
51         ID_AD7476,
52         ID_AD7477,
53         ID_AD7478,
54         ID_AD7495
55 };
56
57 #ifdef CONFIG_IIO_RING_BUFFER
58 int ad7476_scan_from_ring(struct ad7476_state *st);
59 int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev);
60 void ad7476_ring_cleanup(struct iio_dev *indio_dev);
61 #else /* CONFIG_IIO_RING_BUFFER */
62 static inline int ad7476_scan_from_ring(struct ad7476_state *st)
63 {
64         return 0;
65 }
66
67 static inline int
68 ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
69 {
70         return 0;
71 }
72
73 static inline void ad7476_ring_cleanup(struct iio_dev *indio_dev)
74 {
75 }
76 #endif /* CONFIG_IIO_RING_BUFFER */
77 #endif /* IIO_ADC_AD7476_H_ */