drivers/iio/adc/cpcap-adc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/cpcap-adc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/cpcap-adc.c- Extension
.c- Size
- 27385 bytes
- Lines
- 1037
- 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/delay.hlinux/device.hlinux/err.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/iio/buffer.hlinux/iio/driver.hlinux/iio/iio.hlinux/iio/kfifo_buf.hlinux/mfd/motorola-cpcap.h
Detected Declarations
struct cpcap_adc_atostruct cpcap_adcstruct cpcap_adc_phasing_tblstruct cpcap_adc_conversion_tblstruct cpcap_adc_requestenum cpcap_adc_channelenum cpcap_adc_timingfunction cpcap_adc_irq_threadfunction cpcap_adc_setup_calibratefunction cpcap_adc_calibrate_onefunction cpcap_adc_calibratefunction cpcap_adc_setup_bankfunction cpcap_adc_start_bankfunction cpcap_adc_stop_bankfunction cpcap_adc_phasefunction cpcap_adc_table_to_millicelciusfunction cpcap_adc_convertfunction cpcap_adc_read_bank_scaledfunction cpcap_adc_init_requestfunction cpcap_adc_read_st_die_tempfunction cpcap_adc_readfunction cpcap_adc_probe
Annotated Snippet
struct cpcap_adc_ato {
unsigned short ato_in;
unsigned short atox_in;
unsigned short adc_ps_factor_in;
unsigned short atox_ps_factor_in;
unsigned short ato_out;
unsigned short atox_out;
unsigned short adc_ps_factor_out;
unsigned short atox_ps_factor_out;
};
/**
* struct cpcap_adc - cpcap adc device driver data
* @reg: cpcap regmap
* @dev: struct device
* @vendor: cpcap vendor
* @irq: interrupt
* @lock: mutex
* @ato: request timings
* @wq_data_avail: work queue
* @done: work done
*/
struct cpcap_adc {
struct regmap *reg;
struct device *dev;
u16 vendor;
int irq;
struct mutex lock; /* ADC register access lock */
const struct cpcap_adc_ato *ato;
wait_queue_head_t wq_data_avail;
bool done;
};
/*
* enum cpcap_adc_channel - cpcap adc channels
*/
enum cpcap_adc_channel {
/* Bank0 channels */
CPCAP_ADC_AD0, /* Battery temperature */
CPCAP_ADC_BATTP, /* Battery voltage */
CPCAP_ADC_VBUS, /* USB VBUS voltage */
CPCAP_ADC_AD3, /* Die temperature when charging */
CPCAP_ADC_BPLUS_AD4, /* Another battery or system voltage */
CPCAP_ADC_CHG_ISENSE, /* Calibrated charge current */
CPCAP_ADC_BATTI, /* Calibrated system current */
CPCAP_ADC_USB_ID, /* USB OTG ID, unused on droid 4? */
/* Bank1 channels */
CPCAP_ADC_AD8, /* Seems unused */
CPCAP_ADC_AD9, /* Seems unused */
CPCAP_ADC_LICELL, /* Maybe system voltage? Always 3V */
CPCAP_ADC_HV_BATTP, /* Another battery detection? */
CPCAP_ADC_TSX1_AD12, /* Seems unused, for touchscreen? */
CPCAP_ADC_TSX2_AD13, /* Seems unused, for touchscreen? */
CPCAP_ADC_TSY1_AD14, /* Seems unused, for touchscreen? */
CPCAP_ADC_TSY2_AD15, /* Seems unused, for touchscreen? */
/* Remuxed channels using bank0 entries */
CPCAP_ADC_BATTP_PI16, /* Alternative mux mode for BATTP */
CPCAP_ADC_BATTI_PI17, /* Alternative mux mode for BATTI */
CPCAP_ADC_CHANNEL_NUM,
};
/*
* enum cpcap_adc_timing - cpcap adc timing options
*
* CPCAP_ADC_TIMING_IMM seems to be immediate with no timings.
* Please document when using.
*/
enum cpcap_adc_timing {
CPCAP_ADC_TIMING_IMM,
CPCAP_ADC_TIMING_IN,
CPCAP_ADC_TIMING_OUT,
};
/**
* struct cpcap_adc_phasing_tbl - cpcap phasing table
* @offset: offset in the phasing table
* @multiplier: multiplier in the phasing table
* @divider: divider in the phasing table
* @min: minimum value
* @max: maximum value
*/
struct cpcap_adc_phasing_tbl {
short offset;
unsigned short multiplier;
unsigned short divider;
short min;
short max;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct cpcap_adc_ato`, `struct cpcap_adc`, `struct cpcap_adc_phasing_tbl`, `struct cpcap_adc_conversion_tbl`, `struct cpcap_adc_request`, `enum cpcap_adc_channel`, `enum cpcap_adc_timing`, `function cpcap_adc_irq_thread`, `function cpcap_adc_setup_calibrate`, `function cpcap_adc_calibrate_one`.
- 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.