drivers/iio/adc/ad7779.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad7779.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad7779.c- Extension
.c- Size
- 26162 bytes
- Lines
- 1051
- 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/bitmap.hlinux/clk.hlinux/crc8.hlinux/delay.hlinux/err.hlinux/gpio/consumer.hlinux/interrupt.hlinux/irq.hlinux/math.hlinux/module.hlinux/mod_devicetable.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/string.hlinux/types.hlinux/unaligned.hlinux/units.hlinux/iio/iio.hlinux/iio/backend.hlinux/iio/buffer.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.h
Detected Declarations
struct ad7779_chip_infostruct ad7779_stateenum ad7779_filterenum ad7779_variantenum ad7779_power_modefunction ad7779_spi_readfunction ad7779_spi_writefunction ad7779_spi_write_maskfunction ad7779_reg_accessfunction ad7779_set_sampling_frequencyfunction ad7779_get_filterfunction ad7779_set_filterfunction ad7779_get_calibscalefunction ad7779_set_calibscalefunction ad7779_get_calibbiasfunction ad7779_set_calibbiasfunction __ad7779_read_rawfunction ad7779_read_rawfunction __ad7779_write_rawfunction ad7779_write_rawfunction ad7779_buffer_preenablefunction ad7779_buffer_postdisablefunction ad7779_trigger_handlerfunction ad7779_resetfunction ad7779_update_scan_modefunction ad7779_conffunction ad7779_set_data_linesfunction ad7779_setup_channelsfunction ad7779_setup_without_backendfunction ad7779_setup_backendfunction ad7779_probefunction ad7779_suspendfunction ad7779_resume
Annotated Snippet
struct ad7779_chip_info {
const char *name;
struct iio_chan_spec const *channels;
};
struct ad7779_state {
struct spi_device *spi;
const struct ad7779_chip_info *chip_info;
struct clk *mclk;
struct iio_trigger *trig;
struct completion completion;
unsigned int sampling_freq;
enum ad7779_filter filter_enabled;
struct iio_backend *back;
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/
struct {
u32 chans[8];
aligned_s64 timestamp;
} data __aligned(IIO_DMA_MINALIGN);
u32 spidata_tx[8];
u8 reg_rx_buf[3];
u8 reg_tx_buf[3];
u8 reset_buf[8];
};
static const char * const ad7779_filter_type[] = {
[AD7779_SINC3] = "sinc3",
[AD7779_SINC5] = "sinc5",
};
static const char * const ad7779_power_supplies[] = {
"avdd1", "avdd2", "avdd4",
};
static int ad7779_spi_read(struct ad7779_state *st, u8 reg, u8 *rbuf)
{
int ret;
u8 crc_buf[2];
u8 exp_crc;
struct spi_transfer t = {
.tx_buf = st->reg_tx_buf,
.rx_buf = st->reg_rx_buf,
};
st->reg_tx_buf[0] = AD7779_SPI_READ_CMD | FIELD_GET(AD7779_REG_MSK, reg);
st->reg_tx_buf[1] = 0;
if (reg == AD7779_REG_GEN_ERR_REG_1_EN) {
t.len = 2;
} else {
t.len = 3;
st->reg_tx_buf[2] = crc8(ad7779_crc8_table, st->reg_tx_buf,
t.len - 1, 0);
}
ret = spi_sync_transfer(st->spi, &t, 1);
if (ret)
return ret;
crc_buf[0] = AD7779_SPI_READ_CMD | FIELD_GET(AD7779_REG_MSK, reg);
crc_buf[1] = st->reg_rx_buf[1];
exp_crc = crc8(ad7779_crc8_table, crc_buf, ARRAY_SIZE(crc_buf), 0);
if (reg != AD7779_REG_GEN_ERR_REG_1_EN && exp_crc != st->reg_rx_buf[2]) {
dev_err(&st->spi->dev, "Bad CRC %x, expected %x",
st->reg_rx_buf[2], exp_crc);
return -EINVAL;
}
*rbuf = st->reg_rx_buf[1];
return 0;
}
static int ad7779_spi_write(struct ad7779_state *st, u8 reg, u8 val)
{
u8 length = 3;
st->reg_tx_buf[0] = FIELD_GET(AD7779_REG_MSK, reg);
st->reg_tx_buf[1] = val;
if (reg == AD7779_REG_GEN_ERR_REG_1_EN)
length = 2;
else
st->reg_tx_buf[2] = crc8(ad7779_crc8_table, st->reg_tx_buf,
length - 1, 0);
return spi_write(st->spi, st->reg_tx_buf, length);
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitmap.h`, `linux/clk.h`, `linux/crc8.h`, `linux/delay.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`.
- Detected declarations: `struct ad7779_chip_info`, `struct ad7779_state`, `enum ad7779_filter`, `enum ad7779_variant`, `enum ad7779_power_mode`, `function ad7779_spi_read`, `function ad7779_spi_write`, `function ad7779_spi_write_mask`, `function ad7779_reg_access`, `function ad7779_set_sampling_frequency`.
- 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.