drivers/iio/adc/ad7944.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad7944.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad7944.c- Extension
.c- Size
- 25698 bytes
- Lines
- 890
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/align.hlinux/bitfield.hlinux/bitops.hlinux/delay.hlinux/device.hlinux/err.hlinux/gpio/consumer.hlinux/module.hlinux/property.hlinux/regulator/consumer.hlinux/spi/offload/consumer.hlinux/spi/spi.hlinux/string_helpers.hlinux/units.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/buffer-dmaengine.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct ad7944_timing_specstruct ad7944_adcstruct ad7944_chip_infoenum ad7944_spi_modefunction ad7944_3wire_cs_mode_init_msgfunction ad7944_4wire_mode_init_msgfunction ad7944_chain_mode_init_msgfunction ad7944_3wire_cs_mode_init_msgfunction ad7944_convert_and_acquirefunction ad7944_single_conversionfunction ad7944_read_availfunction ad7944_read_rawfunction ad7944_set_sample_freqfunction ad7944_write_rawfunction ad7944_write_raw_get_fmtfunction ad7944_offload_buffer_postenablefunction ad7944_offload_buffer_predisablefunction ad7944_trigger_handlerfunction ad7944_chain_mode_allocfunction ad7944_probe
Annotated Snippet
struct ad7944_timing_spec {
/* Normal mode max conversion time (t_{CONV}). */
unsigned int conv_ns;
/* TURBO mode max conversion time (t_{CONV}). */
unsigned int turbo_conv_ns;
};
enum ad7944_spi_mode {
/* datasheet calls this "4-wire mode" */
AD7944_SPI_MODE_DEFAULT,
/* datasheet calls this "3-wire mode" (not related to SPI_3WIRE!) */
AD7944_SPI_MODE_SINGLE,
/* datasheet calls this "chain mode" */
AD7944_SPI_MODE_CHAIN,
};
/* maps adi,spi-mode property value to enum */
static const char * const ad7944_spi_modes[] = {
[AD7944_SPI_MODE_DEFAULT] = "",
[AD7944_SPI_MODE_SINGLE] = "single",
[AD7944_SPI_MODE_CHAIN] = "chain",
};
struct ad7944_adc {
struct spi_device *spi;
enum ad7944_spi_mode spi_mode;
struct spi_transfer xfers[3];
struct spi_message msg;
struct spi_transfer offload_xfers[2];
struct spi_message offload_msg;
struct spi_offload *offload;
struct spi_offload_trigger *offload_trigger;
unsigned long offload_trigger_hz;
int sample_freq_range[3];
void *chain_mode_buf;
/* Chip-specific timing specifications. */
const struct ad7944_timing_spec *timing_spec;
/* GPIO connected to CNV pin. */
struct gpio_desc *cnv;
/* Optional GPIO to enable turbo mode. */
struct gpio_desc *turbo;
/* Indicates TURBO is hard-wired to be always enabled. */
bool always_turbo;
/* Reference voltage (millivolts). */
unsigned int ref_mv;
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/
struct {
union {
u16 u16;
u32 u32;
} raw;
aligned_s64 timestamp;
} sample __aligned(IIO_DMA_MINALIGN);
};
/* quite time before CNV rising edge */
#define AD7944_T_QUIET_NS 20
/* minimum CNV high time to trigger conversion */
#define AD7944_T_CNVH_NS 10
static const struct ad7944_timing_spec ad7944_timing_spec = {
.conv_ns = 420,
.turbo_conv_ns = 320,
};
static const struct ad7944_timing_spec ad7986_timing_spec = {
.conv_ns = 500,
.turbo_conv_ns = 400,
};
struct ad7944_chip_info {
const char *name;
const struct ad7944_timing_spec *timing_spec;
u32 max_sample_rate_hz;
const struct iio_chan_spec channels[2];
const struct iio_chan_spec offload_channels[1];
};
/* get number of bytes for SPI xfer */
#define AD7944_SPI_BYTES(scan_type) ((scan_type).realbits > 16 ? 4 : 2)
/*
* AD7944_DEFINE_CHIP_INFO - Define a chip info structure for a specific chip
* @_name: The name of the chip
* @_ts: The timing specification for the chip
* @_max: The maximum sample rate in Hz
Annotation
- Immediate include surface: `linux/align.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/module.h`.
- Detected declarations: `struct ad7944_timing_spec`, `struct ad7944_adc`, `struct ad7944_chip_info`, `enum ad7944_spi_mode`, `function ad7944_3wire_cs_mode_init_msg`, `function ad7944_4wire_mode_init_msg`, `function ad7944_chain_mode_init_msg`, `function ad7944_3wire_cs_mode_init_msg`, `function ad7944_convert_and_acquire`, `function ad7944_single_conversion`.
- 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.