drivers/iio/adc/mt6359-auxadc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/mt6359-auxadc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/mt6359-auxadc.c- Extension
.c- Size
- 32521 bytes
- Lines
- 910
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bits.hlinux/cleanup.hlinux/delay.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/types.hlinux/iio/iio.hlinux/mfd/mt6397/core.hdt-bindings/iio/adc/mediatek,mt6357-auxadc.hdt-bindings/iio/adc/mediatek,mt6358-auxadc.hdt-bindings/iio/adc/mediatek,mt6359-auxadc.hdt-bindings/iio/adc/mediatek,mt6363-auxadc.h
Detected Declarations
struct mt6359_auxadcstruct mtk_pmic_auxadc_chanstruct mtk_pmic_auxadc_infoenum mtk_pmic_auxadc_regsenum mtk_pmic_auxadc_channelsfunction mt6358_stop_imp_convfunction mt6358_start_imp_convfunction mt6358_read_impfunction mt6359_read_impfunction mt6359_auxadc_resetfunction mt6359_auxadc_sample_adc_valfunction ADCfunction mt6359_auxadc_read_adcfunction mt6359_auxadc_read_labelfunction mt6359_auxadc_read_rawfunction scoped_guardfunction mt6359_auxadc_probe
Annotated Snippet
struct mt6359_auxadc {
struct device *dev;
struct regmap *regmap;
const struct mtk_pmic_auxadc_info *chip_info;
struct mutex lock;
bool timed_out;
};
/**
* struct mtk_pmic_auxadc_chan - PMIC AUXADC channel data
* @req_idx: Request register number
* @req_mask: Bitmask to activate a channel
* @rdy_idx: Readiness register number
* @rdy_mask: Bitmask to determine channel readiness
* @ext_sel_idx: PMIC GPIO channel register number
* @ext_sel_ch: PMIC GPIO number
* @ext_sel_pu: PMIC GPIO channel pullup resistor selector
* @num_samples: Number of AUXADC samples for averaging
* @r_ratio: Resistance ratio fractional
*/
struct mtk_pmic_auxadc_chan {
u8 req_idx;
u16 req_mask;
u8 rdy_idx;
u16 rdy_mask;
s8 ext_sel_idx;
u8 ext_sel_ch;
u8 ext_sel_pu;
u16 num_samples;
struct u8_fract r_ratio;
};
/**
* struct mtk_pmic_auxadc_info - PMIC specific chip info
* @model_name: PMIC model name
* @channels: IIO specification of ADC channels
* @num_channels: Number of ADC channels
* @desc: PMIC AUXADC channel data
* @regs: List of PMIC specific registers
* @sec_unlock_key: Security unlock key for HK_TOP writes
* @vref_mV: AUXADC Reference Voltage (VREF) in millivolts
* @imp_adc_num: ADC channel for battery impedance readings
* @is_spmi: Defines whether this PMIC communicates over SPMI
* @no_reset: If true, this PMIC does not support ADC reset
* @read_imp: Callback to read impedance channels
*/
struct mtk_pmic_auxadc_info {
const char *model_name;
const struct iio_chan_spec *channels;
u8 num_channels;
const struct mtk_pmic_auxadc_chan *desc;
const u16 *regs;
u16 sec_unlock_key;
u32 vref_mV;
u8 imp_adc_num;
bool is_spmi;
bool no_reset;
int (*read_imp)(struct mt6359_auxadc *adc_dev,
const struct iio_chan_spec *chan, int *vbat, int *ibat);
};
#define MTK_PMIC_ADC_EXT_CHAN(_ch_idx, _req_idx, _req_bit, _rdy_idx, _rdy_bit, \
_ext_sel_idx, _ext_sel_ch, _ext_sel_pu, \
_samples, _rnum, _rdiv) \
[PMIC_AUXADC_CHAN_##_ch_idx] = { \
.req_idx = _req_idx, \
.req_mask = BIT(_req_bit), \
.rdy_idx = _rdy_idx, \
.rdy_mask = BIT(_rdy_bit), \
.ext_sel_idx = _ext_sel_idx, \
.ext_sel_ch = _ext_sel_ch, \
.ext_sel_pu = _ext_sel_pu, \
.num_samples = _samples, \
.r_ratio = { _rnum, _rdiv } \
}
#define MTK_PMIC_ADC_CHAN(_ch_idx, _req_idx, _req_bit, _rdy_idx, _rdy_bit, \
_samples, _rnum, _rdiv) \
MTK_PMIC_ADC_EXT_CHAN(_ch_idx, _req_idx, _req_bit, _rdy_idx, _rdy_bit, \
-1, 0, 0, _samples, _rnum, _rdiv)
#define MTK_PMIC_IIO_CHAN(_model, _name, _ch_idx, _adc_idx, _nbits, _ch_type) \
{ \
.type = _ch_type, \
.channel = _model##_AUXADC_##_ch_idx, \
.address = _adc_idx, \
.scan_index = PMIC_AUXADC_CHAN_##_ch_idx, \
.datasheet_name = __stringify(_name), \
.scan_type = { \
.sign = 'u', \
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/delay.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/property.h`.
- Detected declarations: `struct mt6359_auxadc`, `struct mtk_pmic_auxadc_chan`, `struct mtk_pmic_auxadc_info`, `enum mtk_pmic_auxadc_regs`, `enum mtk_pmic_auxadc_channels`, `function mt6358_stop_imp_conv`, `function mt6358_start_imp_conv`, `function mt6358_read_imp`, `function mt6359_read_imp`, `function mt6359_auxadc_reset`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
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.