drivers/iio/addac/ad74413r.c
Source file repositories/reference/linux-study-clean/drivers/iio/addac/ad74413r.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/addac/ad74413r.c- Extension
.c- Size
- 38947 bytes
- Lines
- 1533
- 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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/cleanup.hlinux/crc8.hlinux/device.hlinux/err.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/interrupt.hlinux/mod_devicetable.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/types.hlinux/unaligned.hdt-bindings/iio/addac/adi,ad74413r.h
Detected Declarations
struct ad74413r_chip_infostruct ad74413r_channel_configstruct ad74413r_channelsstruct ad74413r_statefunction ad74413r_crcfunction ad74413r_format_reg_writefunction ad74413r_reg_writefunction ad74413r_crc_checkfunction ad74413r_reg_readfunction ad74413r_set_gpo_configfunction ad74413r_set_comp_debouncefunction ad74413r_set_comp_drive_strengthfunction ad74413r_gpio_setfunction ad74413r_gpio_set_multiplefunction for_each_set_bitfunction ad74413r_gpio_getfunction ad74413r_gpio_get_multiplefunction for_each_set_bitfunction ad74413r_gpio_get_gpo_directionfunction ad74413r_gpio_get_comp_directionfunction ad74413r_gpio_set_gpo_configfunction ad74413r_gpio_set_comp_configfunction ad74413r_resetfunction ad74413r_set_channel_dac_codefunction ad74413r_set_channel_functionfunction ad74413r_set_adc_conv_seqfunction ad74413r_set_adc_channel_enablefunction ad74413r_get_adc_rangefunction ad74413r_get_adc_rejectionfunction ad74413r_set_adc_rejectionfunction ad74413r_rejection_to_ratefunction ad74413r_rate_to_rejectionfunction ad74413r_range_to_voltage_rangefunction ad74413r_range_to_voltage_offsetfunction ad74413r_range_to_voltage_offset_rawfunction ad74413r_get_output_voltage_scalefunction ad74413r_get_output_current_scalefunction ad74413r_get_input_voltage_scalefunction ad74413r_get_input_voltage_offsetfunction ad74413r_get_input_current_scalefunction ad74413r_get_input_current_offsetfunction ad74413r_get_adc_ratefunction ad74413r_set_adc_ratefunction ad74413r_trigger_handlerfunction ad74413r_adc_data_interruptfunction _ad74413r_get_single_adc_resultfunction ad74413r_get_single_adc_resultfunction ad74413r_adc_to_resistance_result
Annotated Snippet
struct ad74413r_chip_info {
const char *name;
bool hart_support;
};
struct ad74413r_channel_config {
u32 func;
u32 drive_strength;
bool gpo_comparator;
bool initialized;
};
struct ad74413r_channels {
const struct iio_chan_spec *channels;
unsigned int num_channels;
};
struct ad74413r_state {
struct ad74413r_channel_config channel_configs[AD74413R_CHANNEL_MAX];
unsigned int gpo_gpio_offsets[AD74413R_CHANNEL_MAX];
unsigned int comp_gpio_offsets[AD74413R_CHANNEL_MAX];
struct gpio_chip gpo_gpiochip;
struct gpio_chip comp_gpiochip;
struct completion adc_data_completion;
unsigned int num_gpo_gpios;
unsigned int num_comparator_gpios;
u32 sense_resistor_ohms;
int refin_reg_uv;
/*
* Synchronize consecutive operations when doing a one-shot
* conversion and when updating the ADC samples SPI message.
*/
struct mutex lock;
const struct ad74413r_chip_info *chip_info;
struct spi_device *spi;
struct regmap *regmap;
struct device *dev;
struct iio_trigger *trig;
size_t adc_active_channels;
struct spi_message adc_samples_msg;
struct spi_transfer adc_samples_xfer[AD74413R_CHANNEL_MAX + 1];
/*
* DMA (thus cache coherency maintenance) may require the
* transfer buffers to live in their own cache lines.
*/
struct {
u8 rx_buf[AD74413R_FRAME_SIZE * AD74413R_CHANNEL_MAX];
aligned_s64 timestamp;
} adc_samples_buf __aligned(IIO_DMA_MINALIGN);
u8 adc_samples_tx_buf[AD74413R_FRAME_SIZE * AD74413R_CHANNEL_MAX];
u8 reg_tx_buf[AD74413R_FRAME_SIZE];
u8 reg_rx_buf[AD74413R_FRAME_SIZE];
};
#define AD74413R_REG_NOP 0x00
#define AD74413R_REG_CH_FUNC_SETUP_X(x) (0x01 + (x))
#define AD74413R_CH_FUNC_SETUP_MASK GENMASK(3, 0)
#define AD74413R_REG_ADC_CONFIG_X(x) (0x05 + (x))
#define AD74413R_ADC_CONFIG_RANGE_MASK GENMASK(7, 5)
#define AD74413R_ADC_CONFIG_REJECTION_MASK GENMASK(4, 3)
#define AD74413R_ADC_CONFIG_CH_200K_TO_GND BIT(2)
#define AD74413R_ADC_RANGE_10V 0b000
#define AD74413R_ADC_RANGE_2P5V_EXT_POW 0b001
#define AD74413R_ADC_RANGE_2P5V_INT_POW 0b010
#define AD74413R_ADC_RANGE_5V_BI_DIR 0b011
#define AD74413R_ADC_REJECTION_50_60 0b00
#define AD74413R_ADC_REJECTION_NONE 0b01
#define AD74413R_ADC_REJECTION_50_60_HART 0b10
#define AD74413R_ADC_REJECTION_HART 0b11
#define AD74413R_REG_DIN_CONFIG_X(x) (0x09 + (x))
#define AD74413R_DIN_DEBOUNCE_MASK GENMASK(4, 0)
#define AD74413R_DIN_DEBOUNCE_LEN BIT(5)
#define AD74413R_DIN_SINK_MASK GENMASK(9, 6)
#define AD74413R_REG_DAC_CODE_X(x) (0x16 + (x))
#define AD74413R_DAC_CODE_MAX GENMASK(12, 0)
#define AD74413R_DAC_VOLTAGE_MAX 11000
#define AD74413R_REG_GPO_PAR_DATA 0x0d
#define AD74413R_REG_GPO_CONFIG_X(x) (0x0e + (x))
#define AD74413R_GPO_CONFIG_DATA_MASK BIT(3)
#define AD74413R_GPO_CONFIG_SELECT_MASK GENMASK(2, 0)
#define AD74413R_GPO_CONFIG_100K_PULL_DOWN 0b000
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/crc8.h`, `linux/device.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/gpio/driver.h`, `linux/iio/buffer.h`.
- Detected declarations: `struct ad74413r_chip_info`, `struct ad74413r_channel_config`, `struct ad74413r_channels`, `struct ad74413r_state`, `function ad74413r_crc`, `function ad74413r_format_reg_write`, `function ad74413r_reg_write`, `function ad74413r_crc_check`, `function ad74413r_reg_read`, `function ad74413r_set_gpo_config`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.