Merge branch 'for-3.0-important' of git://git.drbd.org/linux-2.6-drbd into for-linus
[pandora-kernel.git] / drivers / staging / iio / adc / ad7606.h
1 /*
2  * AD7606 ADC driver
3  *
4  * Copyright 2011 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2.
7  */
8
9 #ifndef IIO_ADC_AD7606_H_
10 #define IIO_ADC_AD7606_H_
11
12 /*
13  * TODO: struct ad7606_platform_data needs to go into include/linux/iio
14  */
15
16 /**
17  * struct ad7606_platform_data - platform/board specifc information
18  * @default_os:         default oversampling value {0, 2, 4, 8, 16, 32, 64}
19  * @default_range:      default range +/-{5000, 10000} mVolt
20  * @gpio_convst:        number of gpio connected to the CONVST pin
21  * @gpio_reset:         gpio connected to the RESET pin, if not used set to -1
22  * @gpio_range:         gpio connected to the RANGE pin, if not used set to -1
23  * @gpio_os0:           gpio connected to the OS0 pin, if not used set to -1
24  * @gpio_os1:           gpio connected to the OS1 pin, if not used set to -1
25  * @gpio_os2:           gpio connected to the OS2 pin, if not used set to -1
26  * @gpio_frstdata:      gpio connected to the FRSTDAT pin, if not used set to -1
27  * @gpio_stby:          gpio connected to the STBY pin, if not used set to -1
28  */
29
30 struct ad7606_platform_data {
31         unsigned                        default_os;
32         unsigned                        default_range;
33         unsigned                        gpio_convst;
34         unsigned                        gpio_reset;
35         unsigned                        gpio_range;
36         unsigned                        gpio_os0;
37         unsigned                        gpio_os1;
38         unsigned                        gpio_os2;
39         unsigned                        gpio_frstdata;
40         unsigned                        gpio_stby;
41 };
42
43 /**
44  * struct ad7606_chip_info - chip specifc information
45  * @name:               indentification string for chip
46  * @int_vref_mv:        the internal reference voltage
47  * @channels:           channel specification
48  * @num_channels:       number of channels
49  */
50
51 struct ad7606_chip_info {
52         const char                      *name;
53         u8                              bits;
54         char                            sign;
55         u16                             int_vref_mv;
56         struct iio_chan_spec            *channels;
57         unsigned                        num_channels;
58 };
59
60 /**
61  * struct ad7606_state - driver instance specific data
62  */
63
64 struct ad7606_state {
65         struct device                   *dev;
66         const struct ad7606_chip_info   *chip_info;
67         struct ad7606_platform_data     *pdata;
68         struct regulator                *reg;
69         struct work_struct              poll_work;
70         wait_queue_head_t               wq_data_avail;
71         size_t                          d_size;
72         const struct ad7606_bus_ops     *bops;
73         int                             irq;
74         unsigned                        id;
75         unsigned                        range;
76         unsigned                        oversampling;
77         bool                            done;
78         bool                            have_frstdata;
79         bool                            have_os;
80         bool                            have_stby;
81         bool                            have_reset;
82         bool                            have_range;
83         void __iomem                    *base_address;
84
85         /*
86          * DMA (thus cache coherency maintenance) requires the
87          * transfer buffers to live in their own cache lines.
88          */
89
90         unsigned short                  data[8] ____cacheline_aligned;
91 };
92
93 struct ad7606_bus_ops {
94         /* more methods added in future? */
95         int (*read_block)(struct device *, int, void *);
96 };
97
98 void ad7606_suspend(struct iio_dev *indio_dev);
99 void ad7606_resume(struct iio_dev *indio_dev);
100 struct iio_dev *ad7606_probe(struct device *dev, int irq,
101                               void __iomem *base_address, unsigned id,
102                               const struct ad7606_bus_ops *bops);
103 int ad7606_remove(struct iio_dev *indio_dev);
104 int ad7606_reset(struct ad7606_state *st);
105
106 enum ad7606_supported_device_ids {
107         ID_AD7606_8,
108         ID_AD7606_6,
109         ID_AD7606_4
110 };
111
112 int ad7606_scan_from_ring(struct iio_dev *indio_dev, unsigned ch);
113 int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev);
114 void ad7606_ring_cleanup(struct iio_dev *indio_dev);
115 #endif /* IIO_ADC_AD7606_H_ */