drivers/iio/addac/ad74115.c

Source file repositories/reference/linux-study-clean/drivers/iio/addac/ad74115.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/addac/ad74115.c
Extension
.c
Size
51604 bytes
Lines
1931
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 ad74115_channels {
	const struct iio_chan_spec	*channels;
	unsigned int			num_channels;
};

struct ad74115_state {
	struct spi_device		*spi;
	struct regmap			*regmap;
	struct iio_trigger		*trig;

	/*
	 * Synchronize consecutive operations when doing a one-shot
	 * conversion and when updating the ADC samples SPI message.
	 */
	struct mutex			lock;
	struct gpio_chip		gc;
	struct gpio_chip		comp_gc;
	int				irq;

	unsigned int			avdd_mv;
	unsigned long			gpio_valid_mask;
	bool				dac_bipolar;
	bool				dac_hart_slew;
	bool				rtd_mode_4_wire;
	enum ad74115_ch_func		ch_func;
	enum ad74115_din_threshold_mode	din_threshold_mode;

	struct completion		adc_data_completion;
	struct spi_message		adc_samples_msg;
	struct spi_transfer		adc_samples_xfer[AD74115_ADC_CH_NUM + 1];

	/*
	 * DMA (thus cache coherency maintenance) requires the
	 * transfer buffers to live in their own cache lines.
	 */
	u8				reg_tx_buf[AD74115_FRAME_SIZE] __aligned(IIO_DMA_MINALIGN);
	u8				reg_rx_buf[AD74115_FRAME_SIZE];
	u8				adc_samples_tx_buf[AD74115_FRAME_SIZE * AD74115_ADC_CH_NUM];
	u8				adc_samples_rx_buf[AD74115_FRAME_SIZE * AD74115_ADC_CH_NUM];
};

struct ad74115_fw_prop {
	const char			*name;
	bool				is_boolean;
	bool				negate;
	unsigned int			max;
	unsigned int			reg;
	unsigned int			mask;
	const unsigned int		*lookup_tbl;
	unsigned int			lookup_tbl_len;
};

#define AD74115_FW_PROP(_name, _max, _reg, _mask)		\
{								\
	.name = (_name),					\
	.max = (_max),						\
	.reg = (_reg),						\
	.mask = (_mask),					\
}

#define AD74115_FW_PROP_TBL(_name, _tbl, _reg, _mask)		\
{								\
	.name = (_name),					\
	.reg = (_reg),						\
	.mask = (_mask),					\
	.lookup_tbl = (_tbl),					\
	.lookup_tbl_len = ARRAY_SIZE(_tbl),			\
}

#define AD74115_FW_PROP_BOOL(_name, _reg, _mask)		\
{								\
	.name = (_name),					\
	.is_boolean = true,					\
	.reg = (_reg),						\
	.mask = (_mask),					\
}

#define AD74115_FW_PROP_BOOL_NEG(_name, _reg, _mask)		\
{								\
	.name = (_name),					\
	.is_boolean = true,					\
	.negate = true,						\
	.reg = (_reg),						\
	.mask = (_mask),					\
}

static const int ad74115_dac_rate_tbl[] = {
	0,
	4 * 8,
	4 * 15,

Annotation

Implementation Notes