drivers/iio/adc/intel_dc_ti_adc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/intel_dc_ti_adc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/intel_dc_ti_adc.c- Extension
.c- Size
- 8451 bytes
- Lines
- 329
- 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/bits.hlinux/bitfield.hlinux/bitops.hlinux/cleanup.hlinux/delay.hlinux/device.hlinux/interrupt.hlinux/mfd/intel_soc_pmic.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/platform_device.hlinux/regmap.hlinux/wait.hlinux/iio/driver.hlinux/iio/iio.hlinux/iio/machine.h
Detected Declarations
struct dc_ti_adc_infoenum dc_ti_adc_idfunction dc_ti_adc_isrfunction dc_ti_adc_scalefunction dc_ti_adc_raw_to_processedfunction dc_ti_adc_samplefunction dc_ti_adc_read_rawfunction dc_ti_adc_probe
Annotated Snippet
struct dc_ti_adc_info {
struct mutex lock; /* Protects against concurrent accesses to the ADC */
wait_queue_head_t wait;
struct device *dev;
struct regmap *regmap;
int vbat_zse;
int vbat_ge;
bool conversion_done;
};
static const struct iio_chan_spec dc_ti_adc_channels[] = {
{
.indexed = 1,
.type = IIO_VOLTAGE,
.channel = DC_TI_ADC_VBAT,
.address = DC_TI_ADC_DATA_REG_CH(0),
.datasheet_name = "CH0",
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_PROCESSED),
}, {
.indexed = 1,
.type = IIO_TEMP,
.channel = DC_TI_ADC_PMICTEMP,
.address = DC_TI_ADC_DATA_REG_CH(1),
.datasheet_name = "CH1",
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
}, {
.indexed = 1,
.type = IIO_TEMP,
.channel = DC_TI_ADC_BATTEMP,
.address = DC_TI_ADC_DATA_REG_CH(2),
.datasheet_name = "CH2",
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
}, {
.indexed = 1,
.type = IIO_TEMP,
.channel = DC_TI_ADC_SYSTEMP0,
.address = DC_TI_ADC_DATA_REG_CH(3),
.datasheet_name = "CH3",
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
}
};
static struct iio_map dc_ti_adc_default_maps[] = {
IIO_MAP("CH0", "chtdc_ti_battery", "VBAT"),
IIO_MAP("CH1", "chtdc_ti_battery", "PMICTEMP"),
IIO_MAP("CH2", "chtdc_ti_battery", "BATTEMP"),
IIO_MAP("CH3", "chtdc_ti_battery", "SYSTEMP0"),
{ }
};
static irqreturn_t dc_ti_adc_isr(int irq, void *data)
{
struct dc_ti_adc_info *info = data;
info->conversion_done = true;
wake_up(&info->wait);
return IRQ_HANDLED;
}
static int dc_ti_adc_scale(struct dc_ti_adc_info *info,
struct iio_chan_spec const *chan,
int *val, int *val2)
{
if (chan->channel != DC_TI_ADC_VBAT)
return -EINVAL;
/* Vbat ADC scale is 4.6875 mV / unit */
*val = 4;
*val2 = 687500;
return IIO_VAL_INT_PLUS_MICRO;
}
static int dc_ti_adc_raw_to_processed(struct dc_ti_adc_info *info,
struct iio_chan_spec const *chan,
int raw, int *val, int *val2)
{
if (chan->channel != DC_TI_ADC_VBAT)
return -EINVAL;
/* Apply calibration */
raw -= info->vbat_zse;
raw = raw * (DC_TI_VBAT_GE_DIV - info->vbat_ge * DC_TI_VBAT_GE_STEP) /
DC_TI_VBAT_GE_DIV;
/* Vbat ADC scale is 4.6875 mV / unit */
raw *= 46875;
/* raw is now in 10000 units / mV, convert to milli + milli/1e6 */
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/cleanup.h`, `linux/delay.h`, `linux/device.h`, `linux/interrupt.h`, `linux/mfd/intel_soc_pmic.h`.
- Detected declarations: `struct dc_ti_adc_info`, `enum dc_ti_adc_id`, `function dc_ti_adc_isr`, `function dc_ti_adc_scale`, `function dc_ti_adc_raw_to_processed`, `function dc_ti_adc_sample`, `function dc_ti_adc_read_raw`, `function dc_ti_adc_probe`.
- 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.