staging:iio:ad7606: Use GPIO descriptor API
[linux-2.6-block.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 int ad7606_reset(struct ad7606_state *st);
65 int ad7606_read_samples(struct ad7606_state *st);
66
67 enum ad7606_supported_device_ids {
68         ID_AD7606_8,
69         ID_AD7606_6,
70         ID_AD7606_4
71 };
72
73 int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev);
74 void ad7606_ring_cleanup(struct iio_dev *indio_dev);
75
76 #ifdef CONFIG_PM_SLEEP
77 extern const struct dev_pm_ops ad7606_pm_ops;
78 #define AD7606_PM_OPS (&ad7606_pm_ops)
79 #else
80 #define AD7606_PM_OPS NULL
81 #endif
82
83 #endif /* IIO_ADC_AD7606_H_ */