drivers/iio/adc/ad7606.h

Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad7606.h

File Facts

System
Linux kernel
Corpus path
drivers/iio/adc/ad7606.h
Extension
.h
Size
9472 bytes
Lines
252
Domain
Driver Families
Bucket
drivers/iio
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ad7606_chip_info {
	unsigned int			max_samplerate;
	const char			*name;
	unsigned int			bits;
	unsigned int			num_adc_channels;
	ad7606_scale_setup_cb_t		scale_setup_cb;
	ad7606_sw_setup_cb_t		sw_setup_cb;
	const unsigned int		*oversampling_avail;
	unsigned int			oversampling_num;
	bool				os_req_reset;
	unsigned long			init_delay_ms;
	u8				offload_storagebits;
	bool				calib_gain_avail;
	const int			*calib_offset_avail;
	const int			(*calib_phase_avail)[2];
};

/**
 * struct ad7606_chan_info - channel configuration
 * @scale_avail:	pointer to the array which stores the available scales
 * @num_scales:		number of elements stored in the scale_avail array
 * @range:		voltage range selection, selects which scale to apply
 * @reg_offset:		offset for the register value, to be applied when
 *			writing the value of 'range' to the register value
 * @r_gain:		gain resistor value in ohms, to be set to match the
 *                      external r_filter value
 */
struct ad7606_chan_info {
#define AD760X_MAX_SCALES		16
	const unsigned int		(*scale_avail)[2];
	unsigned int			num_scales;
	unsigned int			range;
	unsigned int			reg_offset;
	unsigned int			r_gain;
};

/**
 * struct ad7606_state - driver instance specific data
 * @dev:		pointer to kernel device
 * @chip_info:		entry in the table of chips that describes this device
 * @bops:		bus operations (SPI or parallel)
 * @chan_info:		scale configuration for channels
 * @oversampling:	oversampling selection
 * @cnvst_pwm:		pointer to the PWM device connected to the cnvst pin
 * @base_address:	address from where to read data in parallel operation
 * @sw_mode_en:		software mode enabled
 * @oversampling_avail:	pointer to the array which stores the available
 *			oversampling ratios.
 * @num_os_ratios:	number of elements stored in oversampling_avail array
 * @back:		pointer to the iio_backend structure, if used
 * @write_scale:	pointer to the function which writes the scale
 * @write_os:		pointer to the function which writes the os
 * @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
 * @trig:		The IIO trigger associated with the device.
 * @completion:		completion to indicate end of conversion
 * @data:		buffer for reading data from the device
 * @offload_en:		SPI offload enabled
 * @bus_data:		bus-specific variables
 * @d16:		be16 buffer for reading data from the device
 */
struct ad7606_state {
	struct device			*dev;
	const struct ad7606_chip_info	*chip_info;
	const struct ad7606_bus_ops	*bops;
	struct ad7606_chan_info		chan_info[AD760X_MAX_CHANNELS];
	unsigned int			oversampling;
	struct pwm_device		*cnvst_pwm;
	void __iomem			*base_address;
	bool				sw_mode_en;
	const unsigned int		*oversampling_avail;
	unsigned int			num_os_ratios;
	struct iio_backend		*back;
	int (*write_scale)(struct iio_dev *indio_dev, int ch, int val);
	int (*write_os)(struct iio_dev *indio_dev, int val);

	struct mutex			lock; /* protect sensor state */
	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;

Annotation

Implementation Notes