Linux-libre 4.10.3-gnu
[librecmc/linux-libre.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  * struct ad7606_chip_info - chip specific information
14  * @name:               identification string for chip
15  * @channels:           channel specification
16  * @num_channels:       number of channels
17  */
18
19 struct ad7606_chip_info {
20         const struct iio_chan_spec      *channels;
21         unsigned int                    num_channels;
22 };
23
24 /**
25  * struct ad7606_state - driver instance specific data
26  */
27
28 struct ad7606_state {
29         struct device                   *dev;
30         const struct ad7606_chip_info   *chip_info;
31         struct regulator                *reg;
32         struct work_struct              poll_work;
33         wait_queue_head_t               wq_data_avail;
34         const struct ad7606_bus_ops     *bops;
35         unsigned int                    range;
36         unsigned int                    oversampling;
37         bool                            done;
38         void __iomem                    *base_address;
39
40         struct gpio_desc                *gpio_convst;
41         struct gpio_desc                *gpio_reset;
42         struct gpio_desc                *gpio_range;
43         struct gpio_desc                *gpio_standby;
44         struct gpio_desc                *gpio_frstdata;
45         struct gpio_descs               *gpio_os;
46
47         /*
48          * DMA (thus cache coherency maintenance) requires the
49          * transfer buffers to live in their own cache lines.
50          * 8 * 16-bit samples + 64-bit timestamp
51          */
52         unsigned short                  data[12] ____cacheline_aligned;
53 };
54
55 struct ad7606_bus_ops {
56         /* more methods added in future? */
57         int (*read_block)(struct device *, int, void *);
58 };
59
60 int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
61                  const char *name, unsigned int id,
62                  const struct ad7606_bus_ops *bops);
63 int ad7606_remove(struct device *dev, int irq);
64
65 enum ad7606_supported_device_ids {
66         ID_AD7606_8,
67         ID_AD7606_6,
68         ID_AD7606_4
69 };
70
71 #ifdef CONFIG_PM_SLEEP
72 extern const struct dev_pm_ops ad7606_pm_ops;
73 #define AD7606_PM_OPS (&ad7606_pm_ops)
74 #else
75 #define AD7606_PM_OPS NULL
76 #endif
77
78 #endif /* IIO_ADC_AD7606_H_ */