drivers/iio/adc/ad7606.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad7606.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad7606.c- Extension
.c- Size
- 45699 bytes
- Lines
- 1713
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/cleanup.hlinux/delay.hlinux/device.hlinux/err.hlinux/gpio/consumer.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/property.hlinux/pwm.hlinux/regulator/consumer.hlinux/sched.hlinux/slab.hlinux/sysfs.hlinux/units.hlinux/util_macros.hlinux/iio/backend.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.had7606.h
Detected Declarations
function ad7606_resetfunction ad7606_16bit_chan_scale_setupfunction ad7606_get_chan_configfunction device_for_each_child_node_scopedfunction ad7606c_18bit_chan_scale_setupfunction ad7606c_16bit_chan_scale_setupfunction ad7607_chan_scale_setupfunction ad7608_chan_scale_setupfunction ad7609_chan_scale_setupfunction ad7606_reg_accessfunction ad7606_pwm_set_highfunction ad7606_pwm_set_lowfunction ad7606_pwm_set_swingfunction ad7606_pwm_is_swingingfunction ad7606_set_sampling_freqfunction ad7606_read_samplesfunction ad7606_trigger_handlerfunction ad7606_scan_directfunction ad7606_get_calib_offsetfunction ad7606_get_calib_phasefunction ad7606_read_rawfunction in_voltage_scale_available_showfunction ad7606_write_scale_hwfunction ad7606_write_os_hwfunction ad7606_set_calib_offsetfunction ad7606_set_calib_phasefunction ad7606_write_raw_get_fmtfunction ad7606_write_rawfunction ad7606_oversampling_ratio_availfunction ad7606_request_gpiosfunction ad7606_interruptfunction ad7606_validate_triggerfunction ad7606_buffer_postenablefunction ad7606_buffer_predisablefunction ad7606_read_availfunction ad7606_backend_buffer_postenablefunction ad7606_backend_buffer_predisablefunction ad7606_update_scan_modefunction ad7606_write_maskfunction ad7616_write_scale_swfunction ad7616_write_os_swfunction ad7606_write_scale_swfunction ad7606_write_os_swfunction ad7616_sw_mode_setupfunction ad7606b_sw_mode_setupfunction ad7606_set_gain_calibfunction ad7606_probe_channelsfunction ad7606_pwm_disable
Annotated Snippet
if (ret == 0 && (pins[0] != reg || pins[1] != reg)) {
dev_err(dev,
"Differential pins must be the same as 'reg'");
return -EINVAL;
}
*differential = (ret == 0);
if (*differential && !*bipolar) {
dev_err(dev,
"'bipolar' must be added for diff channel %d\n",
reg);
return -EINVAL;
}
ci = &st->chan_info[reg - 1];
ci->r_gain = 0;
ret = fwnode_property_read_u32(child, "adi,rfilter-ohms",
&ci->r_gain);
if (ret == 0 && ci->r_gain > AD7606_CALIB_GAIN_MAX)
return -EINVAL;
return 0;
}
return 0;
}
static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev,
struct iio_chan_spec *chan)
{
struct ad7606_state *st = iio_priv(indio_dev);
struct ad7606_chan_info *ci = &st->chan_info[chan->scan_index];
bool bipolar, differential;
int ret;
if (!st->sw_mode_en) {
ci->range = 0;
ci->scale_avail = ad7606_18bit_hw_scale_avail;
ci->num_scales = ARRAY_SIZE(ad7606_18bit_hw_scale_avail);
return 0;
}
ret = ad7606_get_chan_config(indio_dev, chan->scan_index, &bipolar,
&differential);
if (ret)
return ret;
if (differential) {
ci->scale_avail = ad7606c_18bit_differential_bipolar_scale_avail;
ci->num_scales =
ARRAY_SIZE(ad7606c_18bit_differential_bipolar_scale_avail);
/* Bipolar differential ranges start at 8 (b1000) */
ci->reg_offset = 8;
ci->range = 1;
chan->differential = 1;
chan->channel2 = chan->channel;
return 0;
}
chan->differential = 0;
if (bipolar) {
ci->scale_avail = ad7606c_18bit_single_ended_bipolar_scale_avail;
ci->num_scales =
ARRAY_SIZE(ad7606c_18bit_single_ended_bipolar_scale_avail);
/* Bipolar single-ended ranges start at 0 (b0000) */
ci->reg_offset = 0;
ci->range = 3;
chan->scan_type.sign = 's';
return 0;
}
ci->scale_avail = ad7606c_18bit_single_ended_unipolar_scale_avail;
ci->num_scales =
ARRAY_SIZE(ad7606c_18bit_single_ended_unipolar_scale_avail);
/* Unipolar single-ended ranges start at 5 (b0101) */
ci->reg_offset = 5;
ci->range = 1;
chan->scan_type.sign = 'u';
return 0;
}
static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev,
struct iio_chan_spec *chan)
{
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `function ad7606_reset`, `function ad7606_16bit_chan_scale_setup`, `function ad7606_get_chan_config`, `function device_for_each_child_node_scoped`, `function ad7606c_18bit_chan_scale_setup`, `function ad7606c_16bit_chan_scale_setup`, `function ad7607_chan_scale_setup`, `function ad7608_chan_scale_setup`, `function ad7609_chan_scale_setup`, `function ad7606_reg_access`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.