2018-12-17 19:23:36 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2011-02-23 03:46:18 +07:00
|
|
|
/*
|
|
|
|
* AD7606 ADC driver
|
|
|
|
*
|
|
|
|
* Copyright 2011 Analog Devices Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IIO_ADC_AD7606_H_
|
|
|
|
#define IIO_ADC_AD7606_H_
|
|
|
|
|
|
|
|
/**
|
2014-04-22 18:23:00 +07:00
|
|
|
* struct ad7606_chip_info - chip specific information
|
2011-05-18 20:42:00 +07:00
|
|
|
* @channels: channel specification
|
|
|
|
* @num_channels: number of channels
|
2018-09-13 18:02:12 +07:00
|
|
|
* @has_oversampling: whether the device has oversampling support
|
2011-02-23 03:46:18 +07:00
|
|
|
*/
|
|
|
|
struct ad7606_chip_info {
|
2012-08-09 14:51:00 +07:00
|
|
|
const struct iio_chan_spec *channels;
|
2016-03-27 02:50:24 +07:00
|
|
|
unsigned int num_channels;
|
2018-09-13 18:02:12 +07:00
|
|
|
bool has_oversampling;
|
2011-02-23 03:46:18 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct ad7606_state - driver instance specific data
|
2018-09-18 19:15:03 +07:00
|
|
|
* @dev pointer to kernel device
|
|
|
|
* @chip_info entry in the table of chips that describes this device
|
|
|
|
* @reg regulator info for the the power supply of the device
|
|
|
|
* @bops bus operations (SPI or parallel)
|
|
|
|
* @range voltage range selection, selects which scale to apply
|
|
|
|
* @oversampling oversampling selection
|
|
|
|
* @base_address address from where to read data in parallel operation
|
|
|
|
* @lock protect sensor state from concurrent accesses to GPIOs
|
|
|
|
* @gpio_convst GPIO descriptor for conversion start signal (CONVST)
|
|
|
|
* @gpio_reset GPIO descriptor for device hard-reset
|
|
|
|
* @gpio_range GPIO descriptor for range selection
|
|
|
|
* @gpio_standby GPIO descriptor for stand-by signal (STBY),
|
|
|
|
* controls power-down mode of device
|
|
|
|
* @gpio_frstdata GPIO descriptor for reading from device when data
|
|
|
|
* is being read on the first channel
|
|
|
|
* @gpio_os GPIO descriptors to control oversampling on the device
|
2018-12-13 19:46:15 +07:00
|
|
|
* @complete completion to indicate end of conversion
|
2018-12-17 19:23:37 +07:00
|
|
|
* @trig The IIO trigger associated with the device.
|
2018-09-18 19:15:03 +07:00
|
|
|
* @data buffer for reading data from the device
|
2011-02-23 03:46:18 +07:00
|
|
|
*/
|
|
|
|
struct ad7606_state {
|
|
|
|
struct device *dev;
|
|
|
|
const struct ad7606_chip_info *chip_info;
|
|
|
|
struct regulator *reg;
|
|
|
|
const struct ad7606_bus_ops *bops;
|
2016-03-27 02:50:24 +07:00
|
|
|
unsigned int range;
|
|
|
|
unsigned int oversampling;
|
2011-02-23 03:46:18 +07:00
|
|
|
void __iomem *base_address;
|
|
|
|
|
2017-03-21 02:51:34 +07:00
|
|
|
struct mutex lock; /* protect sensor state */
|
2016-10-20 00:07:07 +07:00
|
|
|
struct gpio_desc *gpio_convst;
|
|
|
|
struct gpio_desc *gpio_reset;
|
|
|
|
struct gpio_desc *gpio_range;
|
|
|
|
struct gpio_desc *gpio_standby;
|
|
|
|
struct gpio_desc *gpio_frstdata;
|
|
|
|
struct gpio_descs *gpio_os;
|
2018-12-17 19:23:37 +07:00
|
|
|
struct iio_trigger *trig;
|
2018-12-13 19:46:15 +07:00
|
|
|
struct completion completion;
|
2016-10-20 00:07:07 +07:00
|
|
|
|
2011-02-23 03:46:18 +07:00
|
|
|
/*
|
|
|
|
* DMA (thus cache coherency maintenance) requires the
|
|
|
|
* transfer buffers to live in their own cache lines.
|
2016-10-20 00:07:01 +07:00
|
|
|
* 8 * 16-bit samples + 64-bit timestamp
|
2011-02-23 03:46:18 +07:00
|
|
|
*/
|
2016-10-20 00:07:01 +07:00
|
|
|
unsigned short data[12] ____cacheline_aligned;
|
2011-02-23 03:46:18 +07:00
|
|
|
};
|
|
|
|
|
2018-09-18 19:15:03 +07:00
|
|
|
/**
|
|
|
|
* struct ad7606_bus_ops - driver bus operations
|
|
|
|
* @read_block function pointer for reading blocks of data
|
|
|
|
*/
|
2011-02-23 03:46:18 +07:00
|
|
|
struct ad7606_bus_ops {
|
|
|
|
/* more methods added in future? */
|
2018-06-09 05:13:31 +07:00
|
|
|
int (*read_block)(struct device *dev, int num, void *data);
|
2011-02-23 03:46:18 +07:00
|
|
|
};
|
|
|
|
|
2016-10-20 00:07:04 +07:00
|
|
|
int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
|
|
|
|
const char *name, unsigned int id,
|
|
|
|
const struct ad7606_bus_ops *bops);
|
2011-02-23 03:46:18 +07:00
|
|
|
|
|
|
|
enum ad7606_supported_device_ids {
|
2018-09-13 18:02:12 +07:00
|
|
|
ID_AD7605_4,
|
2011-02-23 03:46:18 +07:00
|
|
|
ID_AD7606_8,
|
|
|
|
ID_AD7606_6,
|
|
|
|
ID_AD7606_4
|
|
|
|
};
|
|
|
|
|
2016-02-08 17:13:29 +07:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
|
|
extern const struct dev_pm_ops ad7606_pm_ops;
|
|
|
|
#define AD7606_PM_OPS (&ad7606_pm_ops)
|
|
|
|
#else
|
|
|
|
#define AD7606_PM_OPS NULL
|
|
|
|
#endif
|
|
|
|
|
2011-02-23 03:46:18 +07:00
|
|
|
#endif /* IIO_ADC_AD7606_H_ */
|