drivers/mfd/stm32-timers.c
Source file repositories/reference/linux-study-clean/drivers/mfd/stm32-timers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/stm32-timers.c- Extension
.c- Size
- 9814 bytes
- Lines
- 369
- Domain
- Driver Families
- Bucket
- drivers/mfd
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/export.hlinux/mfd/stm32-timers.hlinux/module.hlinux/of_platform.hlinux/platform_device.hlinux/property.hlinux/reset.h
Detected Declarations
function stm32_timers_dma_donefunction stm32_timers_dma_burst_readfunction stm32_timers_get_arr_sizefunction stm32_timers_probe_hwcfgrfunction stm32_timers_dma_probefunction stm32_timers_dma_removefunction stm32_timers_irq_probefunction stm32_timers_probefunction stm32_timers_removeexport stm32_timers_dma_burst_read
Annotated Snippet
if (IS_ERR(ddata->dma.chans[i])) {
/* Save the first error code to return */
if (PTR_ERR(ddata->dma.chans[i]) != -ENODEV && !ret)
ret = PTR_ERR(ddata->dma.chans[i]);
ddata->dma.chans[i] = NULL;
}
}
return ret;
}
static void stm32_timers_dma_remove(struct device *dev,
struct stm32_timers *ddata)
{
int i;
for (i = STM32_TIMERS_DMA_CH1; i < STM32_TIMERS_MAX_DMAS; i++)
if (ddata->dma.chans[i])
dma_release_channel(ddata->dma.chans[i]);
}
static const char * const stm32_timers_irq_name[STM32_TIMERS_MAX_IRQS] = {
"brk", "up", "trg-com", "cc"
};
static int stm32_timers_irq_probe(struct platform_device *pdev,
struct stm32_timers *ddata)
{
int i, ret;
/*
* STM32 Timer may have either:
* - a unique global interrupt line
* - four dedicated interrupt lines that may be handled separately.
* Optionally get them here, to be used by child devices.
*/
ret = platform_get_irq_byname_optional(pdev, "global");
if (ret < 0 && ret != -ENXIO) {
return ret;
} else if (ret != -ENXIO) {
ddata->irq[STM32_TIMERS_IRQ_GLOBAL_BRK] = ret;
ddata->nr_irqs = 1;
return 0;
}
for (i = 0; i < STM32_TIMERS_MAX_IRQS; i++) {
ret = platform_get_irq_byname_optional(pdev, stm32_timers_irq_name[i]);
if (ret < 0 && ret != -ENXIO) {
return ret;
} else if (ret != -ENXIO) {
ddata->irq[i] = ret;
ddata->nr_irqs++;
}
}
if (ddata->nr_irqs && ddata->nr_irqs != STM32_TIMERS_MAX_IRQS) {
dev_err(&pdev->dev, "Invalid number of IRQs %d\n", ddata->nr_irqs);
return -EINVAL;
}
return 0;
}
static int stm32_timers_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct stm32_timers *ddata;
struct resource *res;
void __iomem *mmio;
int ret;
ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
return -ENOMEM;
mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(mmio))
return PTR_ERR(mmio);
/* Timer physical addr for DMA */
ddata->dma.phys_base = res->start;
ddata->regmap = devm_regmap_init_mmio_clk(dev, "int", mmio,
&stm32_timers_regmap_cfg);
if (IS_ERR(ddata->regmap))
return PTR_ERR(ddata->regmap);
ddata->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ddata->clk))
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/export.h`, `linux/mfd/stm32-timers.h`, `linux/module.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/property.h`, `linux/reset.h`.
- Detected declarations: `function stm32_timers_dma_done`, `function stm32_timers_dma_burst_read`, `function stm32_timers_get_arr_size`, `function stm32_timers_probe_hwcfgr`, `function stm32_timers_dma_probe`, `function stm32_timers_dma_remove`, `function stm32_timers_irq_probe`, `function stm32_timers_probe`, `function stm32_timers_remove`, `export stm32_timers_dma_burst_read`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: integration 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.