drivers/iio/adc/ad7091r8.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad7091r8.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad7091r8.c- Extension
.c- Size
- 8279 bytes
- Lines
- 273
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/iio/iio.hlinux/module.hlinux/regmap.hlinux/gpio/consumer.hlinux/spi/spi.had7091r-base.h
Detected Declarations
enum ad7091r8_info_idsfunction ad7091r8_set_modefunction ad7091r8_reg_result_chan_idfunction ad7091r_pulse_convstfunction ad7091r_regmap_bus_reg_readfunction ad7091r_regmap_bus_reg_writefunction ad7091r8_regmap_initfunction ad7091r8_gpio_setupfunction ad7091r8_spi_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Analog Devices AD7091R8 12-bit SAR ADC driver
*
* Copyright 2023 Analog Devices Inc.
*/
#include <linux/bitfield.h>
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/gpio/consumer.h>
#include <linux/spi/spi.h>
#include "ad7091r-base.h"
#define AD7091R8_REG_ADDR_MSK GENMASK(15, 11)
#define AD7091R8_RD_WR_FLAG_MSK BIT(10)
#define AD7091R8_REG_DATA_MSK GENMASK(9, 0)
#define AD7091R_SPI_REGMAP_CONFIG(n) { \
.reg_bits = 8, \
.val_bits = 16, \
.volatile_reg = ad7091r_volatile_reg, \
.writeable_reg = ad7091r_writeable_reg, \
.max_register = AD7091R_REG_CH_HYSTERESIS(n), \
}
static int ad7091r8_set_mode(struct ad7091r_state *st, enum ad7091r_mode mode)
{
/* AD7091R-2/-4/-8 don't set sample/command/autocycle mode in conf reg */
st->mode = mode;
return 0;
}
static unsigned int ad7091r8_reg_result_chan_id(unsigned int val)
{
return AD7091R8_REG_RESULT_CH_ID(val);
}
#define AD7091R_SPI_CHIP_INFO(_n, _name) { \
.name = _name, \
.channels = ad7091r##_n##_channels, \
.num_channels = ARRAY_SIZE(ad7091r##_n##_channels), \
.vref_mV = 2500, \
.reg_result_chan_id = &ad7091r8_reg_result_chan_id, \
.set_mode = &ad7091r8_set_mode, \
}
#define AD7091R_SPI_CHIP_INFO_IRQ(_n, _name) { \
.name = _name, \
.channels = ad7091r##_n##_channels_irq, \
.num_channels = ARRAY_SIZE(ad7091r##_n##_channels_irq), \
.vref_mV = 2500, \
.reg_result_chan_id = &ad7091r8_reg_result_chan_id, \
.set_mode = &ad7091r8_set_mode, \
}
enum ad7091r8_info_ids {
AD7091R2_INFO,
AD7091R4_INFO,
AD7091R4_INFO_IRQ,
AD7091R8_INFO,
AD7091R8_INFO_IRQ,
};
static const struct iio_chan_spec ad7091r2_channels[] = {
AD7091R_CHANNEL(0, 12, NULL, 0),
AD7091R_CHANNEL(1, 12, NULL, 0),
};
static const struct iio_chan_spec ad7091r4_channels[] = {
AD7091R_CHANNEL(0, 12, NULL, 0),
AD7091R_CHANNEL(1, 12, NULL, 0),
AD7091R_CHANNEL(2, 12, NULL, 0),
AD7091R_CHANNEL(3, 12, NULL, 0),
};
static const struct iio_chan_spec ad7091r4_channels_irq[] = {
AD7091R_CHANNEL(0, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)),
AD7091R_CHANNEL(1, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)),
AD7091R_CHANNEL(2, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)),
AD7091R_CHANNEL(3, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)),
};
static const struct iio_chan_spec ad7091r8_channels[] = {
AD7091R_CHANNEL(0, 12, NULL, 0),
AD7091R_CHANNEL(1, 12, NULL, 0),
AD7091R_CHANNEL(2, 12, NULL, 0),
AD7091R_CHANNEL(3, 12, NULL, 0),
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/iio/iio.h`, `linux/module.h`, `linux/regmap.h`, `linux/gpio/consumer.h`, `linux/spi/spi.h`, `ad7091r-base.h`.
- Detected declarations: `enum ad7091r8_info_ids`, `function ad7091r8_set_mode`, `function ad7091r8_reg_result_chan_id`, `function ad7091r_pulse_convst`, `function ad7091r_regmap_bus_reg_read`, `function ad7091r_regmap_bus_reg_write`, `function ad7091r8_regmap_init`, `function ad7091r8_gpio_setup`, `function ad7091r8_spi_probe`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
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.