1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Copyright 2011 Analog Devices Inc.
8 #ifndef IIO_ADC_AD7606_H_
9 #define IIO_ADC_AD7606_H_
12 * struct ad7606_chip_info - chip specific information
13 * @channels: channel specification
14 * @num_channels: number of channels
15 * @has_oversampling: whether the device has oversampling support
17 struct ad7606_chip_info {
18 const struct iio_chan_spec *channels;
19 unsigned int num_channels;
20 bool has_oversampling;
24 * struct ad7606_state - driver instance specific data
25 * @dev pointer to kernel device
26 * @chip_info entry in the table of chips that describes this device
27 * @reg regulator info for the the power supply of the device
28 * @bops bus operations (SPI or parallel)
29 * @range voltage range selection, selects which scale to apply
30 * @oversampling oversampling selection
31 * @base_address address from where to read data in parallel operation
32 * @lock protect sensor state from concurrent accesses to GPIOs
33 * @gpio_convst GPIO descriptor for conversion start signal (CONVST)
34 * @gpio_reset GPIO descriptor for device hard-reset
35 * @gpio_range GPIO descriptor for range selection
36 * @gpio_standby GPIO descriptor for stand-by signal (STBY),
37 * controls power-down mode of device
38 * @gpio_frstdata GPIO descriptor for reading from device when data
39 * is being read on the first channel
40 * @gpio_os GPIO descriptors to control oversampling on the device
41 * @complete completion to indicate end of conversion
42 * @trig The IIO trigger associated with the device.
43 * @data buffer for reading data from the device
47 const struct ad7606_chip_info *chip_info;
48 struct regulator *reg;
49 const struct ad7606_bus_ops *bops;
51 unsigned int oversampling;
52 void __iomem *base_address;
54 struct mutex lock; /* protect sensor state */
55 struct gpio_desc *gpio_convst;
56 struct gpio_desc *gpio_reset;
57 struct gpio_desc *gpio_range;
58 struct gpio_desc *gpio_standby;
59 struct gpio_desc *gpio_frstdata;
60 struct gpio_descs *gpio_os;
61 struct iio_trigger *trig;
62 struct completion completion;
65 * DMA (thus cache coherency maintenance) requires the
66 * transfer buffers to live in their own cache lines.
67 * 8 * 16-bit samples + 64-bit timestamp
69 unsigned short data[12] ____cacheline_aligned;
73 * struct ad7606_bus_ops - driver bus operations
74 * @read_block function pointer for reading blocks of data
76 struct ad7606_bus_ops {
77 /* more methods added in future? */
78 int (*read_block)(struct device *dev, int num, void *data);
81 int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
82 const char *name, unsigned int id,
83 const struct ad7606_bus_ops *bops);
85 enum ad7606_supported_device_ids {
92 #ifdef CONFIG_PM_SLEEP
93 extern const struct dev_pm_ops ad7606_pm_ops;
94 #define AD7606_PM_OPS (&ad7606_pm_ops)
96 #define AD7606_PM_OPS NULL
99 #endif /* IIO_ADC_AD7606_H_ */