drivers/iio/adc/qcom-spmi-vadc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/qcom-spmi-vadc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/qcom-spmi-vadc.c- Extension
.c- Size
- 24364 bytes
- Lines
- 952
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/bitops.hlinux/completion.hlinux/delay.hlinux/err.hlinux/iio/adc/qcom-vadc-common.hlinux/iio/iio.hlinux/interrupt.hlinux/kernel.hlinux/math64.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/slab.hlinux/log2.hdt-bindings/iio/qcom,spmi-vadc.h
Detected Declarations
struct vadc_channel_propstruct vadc_privstruct vadc_channelsfunction vadc_readfunction vadc_writefunction vadc_resetfunction vadc_set_statefunction vadc_show_statusfunction vadc_configurefunction vadc_poll_wait_eocfunction vadc_read_resultfunction vadc_do_conversionfunction vadc_measure_ref_pointsfunction vadc_prescaling_from_dtfunction vadc_hw_settle_time_from_dtfunction vadc_avg_samples_from_dtfunction vadc_read_rawfunction vadc_fwnode_xlatefunction vadc_read_labelfunction vadc_get_fw_channel_datafunction vadc_get_fw_datafunction device_for_each_child_node_scopedfunction vadc_isrfunction vadc_check_revisionfunction vadc_probe
Annotated Snippet
struct vadc_channel_prop {
unsigned int channel;
enum vadc_calibration calibration;
unsigned int decimation;
unsigned int prescale;
unsigned int hw_settle_time;
unsigned int avg_samples;
enum vadc_scale_fn_type scale_fn_type;
const char *channel_name;
};
/**
* struct vadc_priv - VADC private structure.
* @regmap: pointer to struct regmap.
* @dev: pointer to struct device.
* @base: base address for the ADC peripheral.
* @nchannels: number of VADC channels.
* @chan_props: array of VADC channel properties.
* @iio_chans: array of IIO channels specification.
* @are_ref_measured: are reference points measured.
* @poll_eoc: use polling instead of interrupt.
* @complete: VADC result notification after interrupt is received.
* @graph: store parameters for calibration.
* @lock: ADC lock for access to the peripheral.
*/
struct vadc_priv {
struct regmap *regmap;
struct device *dev;
u16 base;
unsigned int nchannels;
struct vadc_channel_prop *chan_props;
struct iio_chan_spec *iio_chans;
bool are_ref_measured;
bool poll_eoc;
struct completion complete;
struct vadc_linear_graph graph[2];
struct mutex lock;
};
static const struct u32_fract vadc_prescale_ratios[] = {
{ .numerator = 1, .denominator = 1 },
{ .numerator = 1, .denominator = 3 },
{ .numerator = 1, .denominator = 4 },
{ .numerator = 1, .denominator = 6 },
{ .numerator = 1, .denominator = 20 },
{ .numerator = 1, .denominator = 8 },
{ .numerator = 10, .denominator = 81 },
{ .numerator = 1, .denominator = 10 },
};
static int vadc_read(struct vadc_priv *vadc, u16 offset, u8 *data)
{
return regmap_bulk_read(vadc->regmap, vadc->base + offset, data, 1);
}
static int vadc_write(struct vadc_priv *vadc, u16 offset, u8 data)
{
return regmap_write(vadc->regmap, vadc->base + offset, data);
}
static int vadc_reset(struct vadc_priv *vadc)
{
u8 data;
int ret;
ret = vadc_write(vadc, VADC_ACCESS, VADC_ACCESS_DATA);
if (ret)
return ret;
ret = vadc_read(vadc, VADC_PERH_RESET_CTL3, &data);
if (ret)
return ret;
ret = vadc_write(vadc, VADC_ACCESS, VADC_ACCESS_DATA);
if (ret)
return ret;
data |= VADC_FOLLOW_WARM_RB;
return vadc_write(vadc, VADC_PERH_RESET_CTL3, data);
}
static int vadc_set_state(struct vadc_priv *vadc, bool state)
{
return vadc_write(vadc, VADC_EN_CTL1, state ? VADC_EN_CTL1_SET : 0);
}
static void vadc_show_status(struct vadc_priv *vadc)
{
u8 mode, sta1, chan, dig, en, req;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/completion.h`, `linux/delay.h`, `linux/err.h`, `linux/iio/adc/qcom-vadc-common.h`, `linux/iio/iio.h`, `linux/interrupt.h`, `linux/kernel.h`.
- Detected declarations: `struct vadc_channel_prop`, `struct vadc_priv`, `struct vadc_channels`, `function vadc_read`, `function vadc_write`, `function vadc_reset`, `function vadc_set_state`, `function vadc_show_status`, `function vadc_configure`, `function vadc_poll_wait_eoc`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.