drivers/iio/adc/palmas_gpadc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/palmas_gpadc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/palmas_gpadc.c- Extension
.c- Size
- 32407 bytes
- Lines
- 1183
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/err.hlinux/irq.hlinux/interrupt.hlinux/platform_device.hlinux/slab.hlinux/delay.hlinux/pm.hlinux/mfd/palmas.hlinux/completion.hlinux/of.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/machine.hlinux/iio/driver.h
Detected Declarations
struct palmas_gpadc_infostruct palmas_adc_eventstruct palmas_gpadc_thresholdsstruct palmas_gpadcfunction palmas_gpadc_channel_is_freerunningfunction Workaroundfunction palmas_gpadc_irqfunction palmas_gpadc_irq_autofunction palmas_gpadc_start_mask_interruptfunction palmas_gpadc_enablefunction palmas_gpadc_read_preparefunction palmas_gpadc_read_donefunction palmas_gpadc_calibratefunction palmas_gpadc_start_conversionfunction palmas_gpadc_get_calibrated_codefunction linearityfunction palmas_gpadc_get_high_threshold_rawfunction palmas_gpadc_get_low_threshold_rawfunction palmas_gpadc_read_rawfunction palmas_gpadc_read_event_configfunction palmas_gpadc_reconfigure_event_channelsfunction palmas_gpadc_enable_event_configfunction palmas_gpadc_disable_event_configfunction palmas_gpadc_write_event_configfunction palmas_gpadc_read_event_valuefunction palmas_gpadc_write_event_valuefunction palmas_gpadc_get_adc_dt_datafunction palmas_gpadc_resetfunction palmas_gpadc_probefunction palmas_adc_configure_eventsfunction palmas_adc_reset_eventsfunction palmas_gpadc_suspendfunction palmas_gpadc_resume
Annotated Snippet
struct palmas_gpadc_info {
/* calibration codes and regs */
int x1; /* lower ideal code */
int x2; /* higher ideal code */
int v1; /* expected lower volt reading */
int v2; /* expected higher volt reading */
u8 trim1_reg; /* register number for lower trim */
u8 trim2_reg; /* register number for upper trim */
int gain; /* calculated from above (after reading trim regs) */
int offset; /* calculated from above (after reading trim regs) */
int gain_error; /* calculated from above (after reading trim regs) */
bool is_uncalibrated; /* if channel has calibration data */
};
#define PALMAS_ADC_INFO(_chan, _x1, _x2, _v1, _v2, _t1, _t2, _is_uncalibrated) \
[PALMAS_ADC_CH_##_chan] = { \
.x1 = _x1, \
.x2 = _x2, \
.v1 = _v1, \
.v2 = _v2, \
.gain = PALMAS_TO_BE_CALCULATED, \
.offset = PALMAS_TO_BE_CALCULATED, \
.gain_error = PALMAS_TO_BE_CALCULATED, \
.trim1_reg = PALMAS_GPADC_TRIM##_t1, \
.trim2_reg = PALMAS_GPADC_TRIM##_t2, \
.is_uncalibrated = _is_uncalibrated \
}
static struct palmas_gpadc_info palmas_gpadc_info[] = {
PALMAS_ADC_INFO(IN0, 2064, 3112, 630, 950, 1, 2, false),
PALMAS_ADC_INFO(IN1, 2064, 3112, 630, 950, 1, 2, false),
PALMAS_ADC_INFO(IN2, 2064, 3112, 1260, 1900, 3, 4, false),
PALMAS_ADC_INFO(IN3, 2064, 3112, 630, 950, 1, 2, false),
PALMAS_ADC_INFO(IN4, 2064, 3112, 630, 950, 1, 2, false),
PALMAS_ADC_INFO(IN5, 2064, 3112, 630, 950, 1, 2, false),
PALMAS_ADC_INFO(IN6, 2064, 3112, 2520, 3800, 5, 6, false),
PALMAS_ADC_INFO(IN7, 2064, 3112, 2520, 3800, 7, 8, false),
PALMAS_ADC_INFO(IN8, 2064, 3112, 3150, 4750, 9, 10, false),
PALMAS_ADC_INFO(IN9, 2064, 3112, 5670, 8550, 11, 12, false),
PALMAS_ADC_INFO(IN10, 2064, 3112, 3465, 5225, 13, 14, false),
PALMAS_ADC_INFO(IN11, 0, 0, 0, 0, INVALID, INVALID, true),
PALMAS_ADC_INFO(IN12, 0, 0, 0, 0, INVALID, INVALID, true),
PALMAS_ADC_INFO(IN13, 0, 0, 0, 0, INVALID, INVALID, true),
PALMAS_ADC_INFO(IN14, 2064, 3112, 3645, 5225, 15, 16, false),
PALMAS_ADC_INFO(IN15, 0, 0, 0, 0, INVALID, INVALID, true),
};
struct palmas_adc_event {
bool enabled;
int channel;
enum iio_event_direction direction;
};
struct palmas_gpadc_thresholds {
int high;
int low;
};
/*
* struct palmas_gpadc - the palmas_gpadc structure
* @ch0_current: channel 0 current source setting
* 0: 0 uA
* 1: 5 uA
* 2: 15 uA
* 3: 20 uA
* @ch3_current: channel 0 current source setting
* 0: 0 uA
* 1: 10 uA
* 2: 400 uA
* 3: 800 uA
* @extended_delay: enable the gpadc extended delay mode
* @auto_conversion_period: define the auto_conversion_period
* @lock: Lock to protect the device state during a potential concurrent
* read access from userspace. Reading a raw value requires a sequence
* of register writes, then a wait for a completion callback,
* and finally a register read, during which userspace could issue
* another read request. This lock protects a read access from
* occurring before another one has finished.
*
* This is the palmas_gpadc structure to store run-time information
* and pointers for this driver instance.
*/
struct palmas_gpadc {
struct device *dev;
struct palmas *palmas;
u8 ch0_current;
u8 ch3_current;
bool extended_delay;
int irq;
int irq_auto_0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/err.h`, `linux/irq.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/delay.h`, `linux/pm.h`.
- Detected declarations: `struct palmas_gpadc_info`, `struct palmas_adc_event`, `struct palmas_gpadc_thresholds`, `struct palmas_gpadc`, `function palmas_gpadc_channel_is_freerunning`, `function Workaround`, `function palmas_gpadc_irq`, `function palmas_gpadc_irq_auto`, `function palmas_gpadc_start_mask_interrupt`, `function palmas_gpadc_enable`.
- 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.