drivers/iio/adc/ad7768-1.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad7768-1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad7768-1.c- Extension
.c- Size
- 54444 bytes
- Lines
- 1954
- 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/array_size.hlinux/bitfield.hlinux/cleanup.hlinux/clk.hlinux/completion.hlinux/delay.hlinux/device.hlinux/err.hlinux/gpio/driver.hlinux/gpio/consumer.hlinux/interrupt.hlinux/limits.hlinux/math.hlinux/minmax.hlinux/module.hlinux/mutex.hlinux/rational.hlinux/regmap.hlinux/regulator/consumer.hlinux/regulator/driver.hlinux/sysfs.hlinux/spi/offload/consumer.hlinux/spi/offload/provider.hlinux/spi/spi.hlinux/unaligned.hlinux/units.hlinux/util_macros.hlinux/iio/buffer.hlinux/iio/buffer-dmaengine.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.h
Detected Declarations
struct ad7768_chip_infostruct ad7768_stateenum ad7768_conv_modeenum ad7768_pwrmodeenum ad7768_mclk_divenum ad7768_filter_typeenum ad7768_filter_regvalenum ad7768_scan_typefunction ad7768_send_sync_pulsefunction ad7768_fill_samp_freq_tblfunction ad7768_set_mclk_divfunction ad7768_set_modefunction ad7768_scan_directfunction ad7768_reg_accessfunction ad7768_fill_scale_tblfunction ad7768_set_sinc3_dec_ratefunction ad7768_configure_dig_filfunction ad7768_setup_pgafunction ad7768_calc_pga_gainfunction ad7768_set_pga_gainfunction ad7768_gpio_direction_inputfunction ad7768_gpio_direction_outputfunction ad7768_gpio_getfunction ad7768_gpio_setfunction ad7768_gpio_initfunction ad7768_set_freqfunction ad7768_set_filter_type_attrfunction ad7768_get_filter_type_attrfunction ad7768_update_dec_ratefunction ad7768_read_rawfunction ad7768_read_availfunction ad7768_write_raw_get_fmtfunction ad7768_write_rawfunction ad7768_read_labelfunction ad7768_get_current_scan_typefunction ad7768_fwnode_find_reference_argsfunction ad7768_trigger_sources_sync_setupfunction ad7768_trigger_sources_get_syncfunction ad7768_setupfunction ad7768_trigger_handlerfunction ad7768_interruptfunction ad7768_buffer_postenablefunction ad7768_buffer_predisablefunction ad7768_offload_buffer_postenablefunction ad7768_offload_buffer_predisablefunction ad7768_set_trigger_statefunction ad7768_set_channel_labelfunction device_for_each_child_node_scoped
Annotated Snippet
struct ad7768_chip_info {
const char *name;
const struct iio_chan_spec *channel_spec;
int num_channels;
const int *pga_gains;
int num_pga_modes;
int default_pga_mode;
int pgia_mode2pin_offset;
bool has_pga;
bool has_variable_aaf;
bool has_vcm_regulator;
};
struct ad7768_state {
struct spi_device *spi;
struct spi_offload *offload;
struct spi_offload_trigger *offload_trigger;
struct regmap *regmap;
struct regmap *regmap24;
int vref_uv;
struct regulator_dev *vcm_rdev;
unsigned int vcm_output_sel;
struct clk *mclk;
unsigned int mclk_freq;
unsigned int oversampling_ratio;
enum ad7768_filter_type filter_type;
unsigned int samp_freq;
unsigned int samp_freq_avail[ARRAY_SIZE(ad7768_mclk_div_rates)];
unsigned int samp_freq_avail_len;
unsigned int pga_gain_mode;
unsigned int aaf_gain;
int scale_tbl[ADAQ776X_MAX_GAIN_MODES][2];
struct completion completion;
struct iio_trigger *trig;
struct gpio_descs *pga_gpios;
struct gpio_desc *gpio_sync_in;
struct gpio_desc *gpio_reset;
const char *labels[AD7768_MAX_CHANNELS];
struct gpio_chip gpiochip;
struct spi_transfer offload_xfer;
struct spi_message offload_msg;
const struct ad7768_chip_info *chip;
bool en_spi_sync;
struct mutex pga_lock; /* protect device internal state (PGA) */
/*
* DMA (thus cache coherency maintenance) may require the
* transfer buffers to live in their own cache lines.
*/
union {
struct {
__be32 chan;
aligned_s64 timestamp;
} scan;
__be32 d32;
u8 d8[2];
} data __aligned(IIO_DMA_MINALIGN);
};
static const struct regmap_range ad7768_regmap_rd_ranges[] = {
regmap_reg_range(AD7768_REG_CHIP_TYPE, AD7768_REG_CHIP_GRADE),
regmap_reg_range(AD7768_REG_SCRATCH_PAD, AD7768_REG_SCRATCH_PAD),
regmap_reg_range(AD7768_REG_VENDOR_L, AD7768_REG_VENDOR_H),
regmap_reg_range(AD7768_REG_INTERFACE_FORMAT, AD7768_REG_GAIN_LO),
regmap_reg_range(AD7768_REG_SPI_DIAG_ENABLE, AD7768_REG_DIG_DIAG_ENABLE),
regmap_reg_range(AD7768_REG_MASTER_STATUS, AD7768_REG_COEFF_CONTROL),
regmap_reg_range(AD7768_REG_ACCESS_KEY, AD7768_REG_ACCESS_KEY),
};
static const struct regmap_access_table ad7768_regmap_rd_table = {
.yes_ranges = ad7768_regmap_rd_ranges,
.n_yes_ranges = ARRAY_SIZE(ad7768_regmap_rd_ranges),
};
static const struct regmap_range ad7768_regmap_wr_ranges[] = {
regmap_reg_range(AD7768_REG_SCRATCH_PAD, AD7768_REG_SCRATCH_PAD),
regmap_reg_range(AD7768_REG_INTERFACE_FORMAT, AD7768_REG_GPIO_WRITE),
regmap_reg_range(AD7768_REG_OFFSET_HI, AD7768_REG_GAIN_LO),
regmap_reg_range(AD7768_REG_SPI_DIAG_ENABLE, AD7768_REG_DIG_DIAG_ENABLE),
regmap_reg_range(AD7768_REG_SPI_DIAG_STATUS, AD7768_REG_SPI_DIAG_STATUS),
regmap_reg_range(AD7768_REG_COEFF_CONTROL, AD7768_REG_COEFF_CONTROL),
regmap_reg_range(AD7768_REG_ACCESS_KEY, AD7768_REG_ACCESS_KEY),
};
static const struct regmap_access_table ad7768_regmap_wr_table = {
.yes_ranges = ad7768_regmap_wr_ranges,
.n_yes_ranges = ARRAY_SIZE(ad7768_regmap_wr_ranges),
};
static const struct regmap_config ad7768_regmap_config = {
.name = "ad7768-1-8",
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`.
- Detected declarations: `struct ad7768_chip_info`, `struct ad7768_state`, `enum ad7768_conv_mode`, `enum ad7768_pwrmode`, `enum ad7768_mclk_div`, `enum ad7768_filter_type`, `enum ad7768_filter_regval`, `enum ad7768_scan_type`, `function ad7768_send_sync_pulse`, `function ad7768_fill_samp_freq_tbl`.
- 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.