drivers/iio/dac/stm32-dac-core.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/stm32-dac-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/stm32-dac-core.c- Extension
.c- Size
- 6234 bytes
- Lines
- 261
- 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.
- 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/clk.hlinux/delay.hlinux/mod_devicetable.hlinux/module.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hlinux/regulator/consumer.hlinux/reset.hstm32-dac-core.h
Detected Declarations
struct stm32_dac_privstruct stm32_dac_cfgfunction stm32_dac_core_hw_startfunction stm32_dac_core_hw_stopfunction stm32_dac_probefunction stm32_dac_removefunction stm32_dac_core_resumefunction stm32_dac_core_runtime_suspendfunction stm32_dac_core_runtime_resume
Annotated Snippet
struct stm32_dac_priv {
struct clk *pclk;
struct regulator *vref;
struct stm32_dac_common common;
};
/**
* struct stm32_dac_cfg - DAC configuration
* @has_hfsel: DAC has high frequency control
*/
struct stm32_dac_cfg {
bool has_hfsel;
};
static struct stm32_dac_priv *to_stm32_dac_priv(struct stm32_dac_common *com)
{
return container_of(com, struct stm32_dac_priv, common);
}
static const struct regmap_config stm32_dac_regmap_cfg = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = sizeof(u32),
.max_register = 0x3fc,
};
static int stm32_dac_core_hw_start(struct device *dev)
{
struct stm32_dac_common *common = dev_get_drvdata(dev);
struct stm32_dac_priv *priv = to_stm32_dac_priv(common);
int ret;
ret = regulator_enable(priv->vref);
if (ret < 0) {
dev_err(dev, "vref enable failed: %d\n", ret);
return ret;
}
ret = clk_prepare_enable(priv->pclk);
if (ret < 0) {
dev_err(dev, "pclk enable failed: %d\n", ret);
goto err_regulator_disable;
}
return 0;
err_regulator_disable:
regulator_disable(priv->vref);
return ret;
}
static void stm32_dac_core_hw_stop(struct device *dev)
{
struct stm32_dac_common *common = dev_get_drvdata(dev);
struct stm32_dac_priv *priv = to_stm32_dac_priv(common);
clk_disable_unprepare(priv->pclk);
regulator_disable(priv->vref);
}
static int stm32_dac_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct stm32_dac_cfg *cfg;
struct stm32_dac_priv *priv;
struct regmap *regmap;
void __iomem *mmio;
struct reset_control *rst;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
platform_set_drvdata(pdev, &priv->common);
cfg = device_get_match_data(dev);
mmio = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(mmio))
return PTR_ERR(mmio);
regmap = devm_regmap_init_mmio_clk(dev, "pclk", mmio,
&stm32_dac_regmap_cfg);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
priv->common.regmap = regmap;
priv->pclk = devm_clk_get(dev, "pclk");
if (IS_ERR(priv->pclk))
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/property.h`.
- Detected declarations: `struct stm32_dac_priv`, `struct stm32_dac_cfg`, `function stm32_dac_core_hw_start`, `function stm32_dac_core_hw_stop`, `function stm32_dac_probe`, `function stm32_dac_remove`, `function stm32_dac_core_resume`, `function stm32_dac_core_runtime_suspend`, `function stm32_dac_core_runtime_resume`.
- 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.