drivers/iio/adc/qcom-pm8xxx-xoadc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/qcom-pm8xxx-xoadc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/qcom-pm8xxx-xoadc.c- Extension
.c- Size
- 34628 bytes
- Lines
- 1024
- 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/iio/adc/qcom-vadc-common.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/init.hlinux/interrupt.hlinux/regulator/consumer.h
Detected Declarations
struct xoadc_channelstruct xoadc_variantstruct pm8xxx_chan_infostruct pm8xxx_xoadcfunction pm8xxx_eoc_irqfunction pm8xxx_get_channelfunction pm8xxx_read_channel_rsvfunction pm8xxx_read_channelfunction pm8xxx_calibrate_devicefunction pm8xxx_read_rawfunction pm8xxx_fwnode_xlatefunction pm8xxx_xoadc_parse_channelfunction pm8xxx_xoadc_parse_channelsfunction pm8xxx_xoadc_probefunction pm8xxx_xoadc_remove
Annotated Snippet
struct xoadc_channel {
const char *datasheet_name;
u8 pre_scale_mux:2;
u8 amux_channel:4;
const struct u32_fract prescale;
enum iio_chan_type type;
enum vadc_scale_fn_type scale_fn_type;
u8 amux_ip_rsv:3;
};
/**
* struct xoadc_variant - encodes the XOADC variant characteristics
* @name: name of this PMIC variant
* @channels: the hardware channels and respective settings and defaults
* @broken_ratiometric: if the PMIC has broken ratiometric scaling (this
* is a known problem on PM8058)
* @prescaling: this variant uses AMUX bits 2 & 3 for prescaling (PM8058)
* @second_level_mux: this variant uses AMUX bits 2 & 3 for a second level
* mux
*/
struct xoadc_variant {
const char name[16];
const struct xoadc_channel *channels;
bool broken_ratiometric;
bool prescaling;
bool second_level_mux;
};
/*
* XOADC_CHAN macro parameters:
* _dname: the name of the channel
* _presmux: prescaler (PM8058) or premux (PM8921) setting for this channel
* _amux: the value in bits 2..7 of the ADC_ARB_USRP_AMUX_CNTRL register
* for this channel. On some PMICs some of the bits select a prescaler, and
* on some PMICs some of the bits select various complex multiplex settings.
* _type: IIO channel type
* _prenum: prescaler numerator (dividend)
* _preden: prescaler denominator (divisor)
* _scale: scaling function type, this selects how the raw valued is mangled
* to output the actual processed measurement
* _amip: analog mux input parent when using ratiometric measurements
*/
#define XOADC_CHAN(_dname, _presmux, _amux, _type, _prenum, _preden, _scale, _amip) \
{ \
.datasheet_name = __stringify(_dname), \
.pre_scale_mux = _presmux, \
.amux_channel = _amux, \
.prescale = { \
.numerator = _prenum, .denominator = _preden, \
}, \
.type = _type, \
.scale_fn_type = _scale, \
.amux_ip_rsv = _amip, \
}
/*
* Taken from arch/arm/mach-msm/board-9615.c in the vendor tree:
* TODO: incomplete, needs testing.
*/
static const struct xoadc_channel pm8018_xoadc_channels[] = {
XOADC_CHAN(VCOIN, 0x00, 0x00, IIO_VOLTAGE, 1, 3, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(VBAT, 0x00, 0x01, IIO_VOLTAGE, 1, 3, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(VPH_PWR, 0x00, 0x02, IIO_VOLTAGE, 1, 3, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(DIE_TEMP, 0x00, 0x0b, IIO_TEMP, 1, 1, SCALE_PMIC_THERM, AMUX_RSV1),
/* Used for battery ID or battery temperature */
XOADC_CHAN(AMUX8, 0x00, 0x08, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV2),
XOADC_CHAN(INTERNAL, 0x00, 0x0c, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(125V, 0x00, 0x0d, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(MUXOFF, 0x00, 0x0f, IIO_TEMP, 1, 1, SCALE_XOTHERM, AMUX_RSV0),
{ }, /* Sentinel */
};
/*
* Taken from arch/arm/mach-msm/board-8930-pmic.c in the vendor tree:
* TODO: needs testing.
*/
static const struct xoadc_channel pm8038_xoadc_channels[] = {
XOADC_CHAN(VCOIN, 0x00, 0x00, IIO_VOLTAGE, 1, 3, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(VBAT, 0x00, 0x01, IIO_VOLTAGE, 1, 3, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(DCIN, 0x00, 0x02, IIO_VOLTAGE, 1, 6, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(ICHG, 0x00, 0x03, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(VPH_PWR, 0x00, 0x04, IIO_VOLTAGE, 1, 3, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(AMUX5, 0x00, 0x05, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(AMUX6, 0x00, 0x06, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(AMUX7, 0x00, 0x07, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV1),
/* AMUX8 used for battery temperature in most cases */
XOADC_CHAN(AMUX8, 0x00, 0x08, IIO_TEMP, 1, 1, SCALE_THERM_100K_PULLUP, AMUX_RSV2),
XOADC_CHAN(AMUX9, 0x00, 0x09, IIO_VOLTAGE, 1, 1, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(USB_VBUS, 0x00, 0x0a, IIO_VOLTAGE, 1, 4, SCALE_DEFAULT, AMUX_RSV1),
XOADC_CHAN(DIE_TEMP, 0x00, 0x0b, IIO_TEMP, 1, 1, SCALE_PMIC_THERM, AMUX_RSV1),
Annotation
- Immediate include surface: `linux/iio/adc/qcom-vadc-common.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/property.h`, `linux/regmap.h`.
- Detected declarations: `struct xoadc_channel`, `struct xoadc_variant`, `struct pm8xxx_chan_info`, `struct pm8xxx_xoadc`, `function pm8xxx_eoc_irq`, `function pm8xxx_get_channel`, `function pm8xxx_read_channel_rsv`, `function pm8xxx_read_channel`, `function pm8xxx_calibrate_device`, `function pm8xxx_read_raw`.
- 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.