drivers/iio/adc/twl6030-gpadc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/twl6030-gpadc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/twl6030-gpadc.c- Extension
.c- Size
- 25577 bytes
- Lines
- 1022
- 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/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/property.hlinux/mfd/twl.hlinux/iio/iio.hlinux/iio/sysfs.h
Detected Declarations
struct twl6030_chnl_calibstruct twl6030_ideal_codestruct twl6030_gpadc_datastruct twl6030_gpadc_platform_datastruct twl6030_gpadc_datafunction twl6030_gpadc_writefunction twl6030_gpadc_readfunction twl6030_gpadc_enable_irqfunction twl6030_gpadc_disable_irqfunction twl6030_gpadc_irq_handlerfunction twl6030_start_conversionfunction twl6032_start_conversionfunction twl6030_channel_to_regfunction twl6032_channel_to_regfunction twl6030_gpadc_lookupfunction twl6030_channel_calibratedfunction twl6030_gpadc_make_correctionfunction twl6030_gpadc_get_rawfunction twl6030_gpadc_get_processedfunction twl6030_gpadc_read_rawfunction differencefunction twl6030_gpadc_get_trim_offsetfunction twl6030_calibrationfunction twl6032_get_trim_valuefunction twl6032_calibrationfunction twl6030_gpadc_probefunction twl6030_gpadc_removefunction twl6030_gpadc_suspendfunction twl6030_gpadc_resume
Annotated Snippet
struct twl6030_chnl_calib {
s32 gain;
s32 gain_error;
s32 offset_error;
};
/**
* struct twl6030_ideal_code - GPADC calibration parameters
* GPADC is calibrated in two points: close to the beginning and
* to the and of the measurable input range
*
* @channel: channel number
* @code1: ideal code for the input at the beginning
* @code2: ideal code for at the end of the range
* @volt1: voltage input at the beginning(low voltage)
* @volt2: voltage input at the end(high voltage)
*/
struct twl6030_ideal_code {
int channel;
u16 code1;
u16 code2;
u16 volt1;
u16 volt2;
};
struct twl6030_gpadc_data;
/**
* struct twl6030_gpadc_platform_data - platform specific data
* @nchannels: number of GPADC channels
* @iio_channels: iio channels
* @ideal: pointer to calibration parameters
* @start_conversion: pointer to ADC start conversion function
* @channel_to_reg: pointer to ADC function to convert channel to
* register address for reading conversion result
* @calibrate: pointer to calibration function
*/
struct twl6030_gpadc_platform_data {
const int nchannels;
const struct iio_chan_spec *iio_channels;
const struct twl6030_ideal_code *ideal;
int (*start_conversion)(int channel);
u8 (*channel_to_reg)(int channel);
int (*calibrate)(struct twl6030_gpadc_data *gpadc);
};
/**
* struct twl6030_gpadc_data - GPADC data
* @dev: device pointer
* @lock: mutual exclusion lock for the structure
* @irq_complete: completion to signal end of conversion
* @twl6030_cal_tbl: pointer to calibration data for each
* channel with gain error and offset
* @pdata: pointer to device specific data
*/
struct twl6030_gpadc_data {
struct device *dev;
struct mutex lock;
struct completion irq_complete;
struct twl6030_chnl_calib *twl6030_cal_tbl;
const struct twl6030_gpadc_platform_data *pdata;
};
/*
* channels 11, 12, 13, 15 and 16 have no calibration data
* calibration offset is same for channels 1, 3, 4, 5
*
* The data is taken from GPADC_TRIM registers description.
* GPADC_TRIM registers keep difference between the code measured
* at volt1 and volt2 input voltages and corresponding code1 and code2
*/
static const struct twl6030_ideal_code
twl6030_ideal[TWL6030_GPADC_USED_CHANNELS] = {
[0] = { /* ch 0, external, battery type, resistor value */
.channel = 0,
.code1 = 116,
.code2 = 745,
.volt1 = 141,
.volt2 = 910,
},
[1] = { /* ch 1, external, battery temperature, NTC resistor value */
.channel = 1,
.code1 = 82,
.code2 = 900,
.volt1 = 100,
.volt2 = 1100,
},
[2] = { /* ch 2, external, audio accessory/general purpose */
.channel = 2,
.code1 = 55,
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/property.h`, `linux/mfd/twl.h`, `linux/iio/iio.h`.
- Detected declarations: `struct twl6030_chnl_calib`, `struct twl6030_ideal_code`, `struct twl6030_gpadc_data`, `struct twl6030_gpadc_platform_data`, `struct twl6030_gpadc_data`, `function twl6030_gpadc_write`, `function twl6030_gpadc_read`, `function twl6030_gpadc_enable_irq`, `function twl6030_gpadc_disable_irq`, `function twl6030_gpadc_irq_handler`.
- 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.