drivers/iio/adc/stm32-adc-core.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/stm32-adc-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/stm32-adc-core.c- Extension
.c- Size
- 24837 bytes
- Lines
- 918
- 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.
- 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/bitfield.hlinux/clk.hlinux/interrupt.hlinux/irqchip/chained_irq.hlinux/irqdesc.hlinux/irqdomain.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/slab.hlinux/units.hstm32-adc-core.h
Detected Declarations
struct stm32_adc_common_regsstruct stm32_adc_privstruct stm32_adc_priv_cfgstruct stm32_adc_privstruct stm32h7_adc_ck_specfunction stm32f4_adc_clk_selfunction stm32h7_adc_clk_selfunction stm32_adc_eoc_enabledfunction stm32_adc_irq_handlerfunction stm32_adc_domain_mapfunction stm32_adc_domain_unmapfunction stm32_adc_irq_probefunction stm32_adc_irq_removefunction stm32_adc_core_switches_supply_enfunction switchesfunction stm32_adc_core_switches_supply_disfunction stm32_adc_core_hw_startfunction stm32_adc_core_hw_stopfunction stm32_adc_core_switches_probefunction stm32_adc_probe_identificationfunction for_each_child_of_nodefunction stm32_adc_probefunction stm32_adc_removefunction stm32_adc_core_runtime_suspendfunction stm32_adc_core_runtime_resumefunction stm32_adc_core_runtime_idle
Annotated Snippet
struct stm32_adc_common_regs {
u32 csr;
u32 ccr;
u32 eoc_msk[STM32_ADC_MAX_ADCS];
u32 ovr_msk[STM32_ADC_MAX_ADCS];
u32 ier;
u32 eocie_msk;
};
struct stm32_adc_priv;
/**
* struct stm32_adc_priv_cfg - stm32 core compatible configuration data
* @regs: common registers for all instances
* @clk_sel: clock selection routine
* @max_clk_rate_hz: maximum analog clock rate (Hz, from datasheet)
* @ipid: adc identification number
* @has_syscfg: SYSCFG capability flags
* @num_irqs: number of interrupt lines
* @num_adcs: maximum number of ADC instances in the common registers
*/
struct stm32_adc_priv_cfg {
const struct stm32_adc_common_regs *regs;
int (*clk_sel)(struct platform_device *, struct stm32_adc_priv *);
u32 max_clk_rate_hz;
u32 ipid;
unsigned int has_syscfg;
unsigned int num_irqs;
unsigned int num_adcs;
};
/**
* struct stm32_adc_priv - stm32 ADC core private data
* @irq: irq(s) for ADC block
* @nb_adc_max: actual maximum number of instance per ADC block
* @domain: irq domain reference
* @aclk: clock reference for the analog circuitry
* @bclk: bus clock common for all ADCs, depends on part used
* @max_clk_rate: desired maximum clock rate
* @booster: booster supply reference
* @vdd: vdd supply reference
* @vdda: vdda analog supply reference
* @vref: regulator reference
* @vdd_uv: vdd supply voltage (microvolts)
* @vdda_uv: vdda supply voltage (microvolts)
* @cfg: compatible configuration data
* @common: common data for all ADC instances
* @ccr_bak: backup CCR in low power mode
* @syscfg: reference to syscon, system control registers
*/
struct stm32_adc_priv {
int irq[STM32_ADC_MAX_ADCS];
unsigned int nb_adc_max;
struct irq_domain *domain;
struct clk *aclk;
struct clk *bclk;
u32 max_clk_rate;
struct regulator *booster;
struct regulator *vdd;
struct regulator *vdda;
struct regulator *vref;
int vdd_uv;
int vdda_uv;
const struct stm32_adc_priv_cfg *cfg;
struct stm32_adc_common common;
u32 ccr_bak;
struct regmap *syscfg;
};
static struct stm32_adc_priv *to_stm32_adc_priv(struct stm32_adc_common *com)
{
return container_of(com, struct stm32_adc_priv, common);
}
/* STM32F4 ADC internal common clock prescaler division ratios */
static int stm32f4_pclk_div[] = {2, 4, 6, 8};
/**
* stm32f4_adc_clk_sel() - Select stm32f4 ADC common clock prescaler
* @pdev: platform device
* @priv: stm32 ADC core private data
* Select clock prescaler used for analog conversions, before using ADC.
*/
static int stm32f4_adc_clk_sel(struct platform_device *pdev,
struct stm32_adc_priv *priv)
{
unsigned long rate;
u32 val;
int i;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/interrupt.h`, `linux/irqchip/chained_irq.h`, `linux/irqdesc.h`, `linux/irqdomain.h`, `linux/mfd/syscon.h`, `linux/module.h`.
- Detected declarations: `struct stm32_adc_common_regs`, `struct stm32_adc_priv`, `struct stm32_adc_priv_cfg`, `struct stm32_adc_priv`, `struct stm32h7_adc_ck_spec`, `function stm32f4_adc_clk_sel`, `function stm32h7_adc_clk_sel`, `function stm32_adc_eoc_enabled`, `function stm32_adc_irq_handler`, `function stm32_adc_domain_map`.
- 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.
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.