drivers/iio/adc/ad4030.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad4030.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad4030.c- Extension
.c- Size
- 50305 bytes
- Lines
- 1803
- 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/clk.hlinux/dmaengine.hlinux/limits.hlinux/log2.hlinux/math64.hlinux/minmax.hlinux/pwm.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/offload/consumer.hlinux/spi/spi.hlinux/unaligned.hlinux/units.hlinux/types.hlinux/iio/buffer-dmaengine.hlinux/iio/iio.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct ad4030_chip_infostruct ad4030_stateenum ad4030_out_modefunction BITfunction ad4030_enter_config_modefunction ad4030_exit_config_modefunction ad4030_spi_readfunction ad4030_spi_writefunction ad4030_fill_scale_availfunction ad4030_set_pga_gainfunction ad4030_set_pgafunction ad4030_get_chan_scalefunction ad4030_get_chan_calibscalefunction ad4030_get_chan_calibbiasfunction ad4030_get_sampling_freqfunction ad4030_update_conversion_ratefunction ad4030_set_sampling_freqfunction ad4030_set_chan_calibscalefunction ad4030_set_chan_calibbiasfunction ad4030_set_avg_frame_lenfunction ad4030_is_common_byte_askedfunction ad4030_set_modefunction ad4030_extract_interleavedfunction ad4030_conversionfunction ad4030_single_conversionfunction ad4030_trigger_handlerfunction ad4030_read_availfunction ad4030_read_raw_dispatchfunction ad4030_read_rawfunction ad4030_write_raw_dispatchfunction ad4030_write_rawfunction ad4030_write_raw_get_fmtfunction ad4030_reg_accessfunction ad4030_read_labelfunction ad4030_get_current_scan_typefunction ad4030_update_scan_modefunction ad4030_validate_scan_maskfunction ad4030_prepare_offload_msgfunction ad4030_offload_buffer_postenablefunction ad4030_offload_buffer_predisablefunction ad4030_regulators_getfunction ad4030_resetfunction ad4030_detect_chip_infofunction ad4030_pwm_getfunction ad4030_configfunction ad4030_spi_offload_setupfunction ad4030_setup_pgafunction ad4030_probe
Annotated Snippet
struct ad4030_chip_info {
const char *name;
const unsigned long *available_masks;
const struct iio_chan_spec channels[AD4030_MAX_IIO_CHANNEL_NB];
const struct iio_chan_spec offload_channels[AD4030_MAX_IIO_CHANNEL_NB];
u8 grade;
u8 precision_bits;
bool has_pga;
/* Number of hardware channels */
int num_voltage_inputs;
unsigned int tcyc_ns;
unsigned int max_sample_rate_hz;
};
struct ad4030_state {
struct spi_device *spi;
struct regmap *regmap;
const struct ad4030_chip_info *chip;
struct gpio_desc *cnv_gpio;
int vref_uv;
int vio_uv;
int offset_avail[3];
unsigned int avg_log2;
enum ad4030_out_mode mode;
/* Offload sampling */
struct spi_transfer offload_xfer;
struct spi_message offload_msg;
struct spi_offload *offload;
struct spi_offload_trigger *offload_trigger;
struct spi_offload_trigger_config offload_trigger_config;
struct pwm_device *cnv_trigger;
size_t scale_avail_size;
struct pwm_waveform cnv_wf;
unsigned int scale_avail[ARRAY_SIZE(adaq4216_hw_gains_vpv)][2];
struct gpio_descs *pga_gpios;
unsigned int pga_index;
/*
* DMA (thus cache coherency maintenance) requires the transfer buffers
* to live in their own cache lines.
*/
u8 tx_data[AD4030_SPI_MAX_XFER_LEN] __aligned(IIO_DMA_MINALIGN);
union {
u8 raw[AD4030_MAXIMUM_RX_BUFFER_SIZE];
struct {
s32 diff;
u8 common;
} single;
struct {
s32 diff[2];
u8 common[2];
} dual;
} rx_data;
};
/*
* For a chip with 2 hardware channel this will be used to create 2 common-mode
* channels:
* - voltage4
* - voltage5
* As the common-mode channels are after the differential ones, we compute the
* channel number like this:
* - _idx is the scan_index (the order in the output buffer)
* - _ch is the hardware channel number this common-mode channel is related
* - _idx - _ch gives us the number of channel in the chip
* - _idx - _ch * 2 is the starting number of the common-mode channels, since
* for each differential channel there is a common-mode channel
* - _idx - _ch * 2 + _ch gives the channel number for this specific common-mode
* channel
*/
#define AD4030_CHAN_CMO(_idx, _ch) { \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_SCALE), \
.type = IIO_VOLTAGE, \
.indexed = 1, \
.address = (_ch), \
.channel = ((_idx) - (_ch)) * 2 + (_ch), \
.scan_index = (_idx), \
.scan_type = { \
.sign = 'u', \
.storagebits = 8, \
.realbits = 8, \
.endianness = IIO_BE, \
}, \
}
/*
* For a chip with 2 hardware channel this will be used to create 2 differential
* channels:
* - voltage0-voltage1
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/dmaengine.h`, `linux/limits.h`, `linux/log2.h`, `linux/math64.h`, `linux/minmax.h`.
- Detected declarations: `struct ad4030_chip_info`, `struct ad4030_state`, `enum ad4030_out_mode`, `function BIT`, `function ad4030_enter_config_mode`, `function ad4030_exit_config_mode`, `function ad4030_spi_read`, `function ad4030_spi_write`, `function ad4030_fill_scale_avail`, `function ad4030_set_pga_gain`.
- 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.