drivers/iio/adc/stm32-dfsdm-core.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/stm32-dfsdm-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/stm32-dfsdm-core.c- Extension
.c- Size
- 13298 bytes
- Lines
- 523
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/export.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/slab.hstm32-dfsdm.h
Detected Declarations
struct stm32_dfsdm_dev_datastruct dfsdm_privfunction stm32_dfsdm_volatile_regfunction stm32_dfsdm_clk_prepare_enablefunction stm32_dfsdm_clk_disable_unpreparefunction stm32_dfsdm_start_dfsdmfunction stm32_dfsdm_stop_dfsdmfunction stm32_dfsdm_parse_offunction stm32_dfsdm_probe_identificationfunction for_each_child_of_nodefunction stm32_dfsdm_probefunction stm32_dfsdm_core_removefunction stm32_dfsdm_core_suspendfunction stm32_dfsdm_core_resumefunction stm32_dfsdm_core_runtime_suspendfunction stm32_dfsdm_core_runtime_resumeexport stm32_dfsdm_start_dfsdmexport stm32_dfsdm_stop_dfsdm
Annotated Snippet
struct stm32_dfsdm_dev_data {
u32 ipid;
unsigned int num_filters;
unsigned int num_channels;
const struct regmap_config *regmap_cfg;
};
#define STM32H7_DFSDM_NUM_FILTERS 4
#define STM32H7_DFSDM_NUM_CHANNELS 8
static bool stm32_dfsdm_volatile_reg(struct device *dev, unsigned int reg)
{
if (reg < DFSDM_FILTER_BASE_ADR)
return false;
/*
* Mask is done on register to avoid to list registers of all
* filter instances.
*/
switch (reg & DFSDM_FILTER_REG_MASK) {
case DFSDM_CR1(0) & DFSDM_FILTER_REG_MASK:
case DFSDM_ISR(0) & DFSDM_FILTER_REG_MASK:
case DFSDM_JDATAR(0) & DFSDM_FILTER_REG_MASK:
case DFSDM_RDATAR(0) & DFSDM_FILTER_REG_MASK:
return true;
}
return false;
}
static const struct regmap_config stm32h7_dfsdm_regmap_cfg = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = sizeof(u32),
.max_register = 0x2B8,
.volatile_reg = stm32_dfsdm_volatile_reg,
.fast_io = true,
};
static const struct stm32_dfsdm_dev_data stm32h7_dfsdm_data = {
.num_filters = STM32H7_DFSDM_NUM_FILTERS,
.num_channels = STM32H7_DFSDM_NUM_CHANNELS,
.regmap_cfg = &stm32h7_dfsdm_regmap_cfg,
};
static const struct regmap_config stm32mp1_dfsdm_regmap_cfg = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = sizeof(u32),
.max_register = 0x7fc,
.volatile_reg = stm32_dfsdm_volatile_reg,
.fast_io = true,
};
static const struct stm32_dfsdm_dev_data stm32mp1_dfsdm_data = {
.ipid = STM32MP15_IPIDR_NUMBER,
.regmap_cfg = &stm32mp1_dfsdm_regmap_cfg,
};
struct dfsdm_priv {
struct platform_device *pdev; /* platform device */
struct stm32_dfsdm dfsdm; /* common data exported for all instances */
unsigned int spi_clk_out_div; /* SPI clkout divider value */
atomic_t n_active_ch; /* number of current active channels */
struct clk *clk; /* DFSDM clock */
struct clk *aclk; /* audio clock */
};
static inline struct dfsdm_priv *to_stm32_dfsdm_priv(struct stm32_dfsdm *dfsdm)
{
return container_of(dfsdm, struct dfsdm_priv, dfsdm);
}
static int stm32_dfsdm_clk_prepare_enable(struct stm32_dfsdm *dfsdm)
{
struct dfsdm_priv *priv = to_stm32_dfsdm_priv(dfsdm);
int ret;
ret = clk_prepare_enable(priv->clk);
if (ret || !priv->aclk)
return ret;
ret = clk_prepare_enable(priv->aclk);
if (ret)
clk_disable_unprepare(priv->clk);
return ret;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/export.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct stm32_dfsdm_dev_data`, `struct dfsdm_priv`, `function stm32_dfsdm_volatile_reg`, `function stm32_dfsdm_clk_prepare_enable`, `function stm32_dfsdm_clk_disable_unprepare`, `function stm32_dfsdm_start_dfsdm`, `function stm32_dfsdm_stop_dfsdm`, `function stm32_dfsdm_parse_of`, `function stm32_dfsdm_probe_identification`, `function for_each_child_of_node`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.