drivers/iio/trigger/stm32-lptimer-trigger.c
Source file repositories/reference/linux-study-clean/drivers/iio/trigger/stm32-lptimer-trigger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/trigger/stm32-lptimer-trigger.c- Extension
.c- Size
- 3890 bytes
- Lines
- 154
- 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.
- 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/export.hlinux/iio/timer/stm32-lptim-trigger.hlinux/mfd/stm32-lptimer.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/property.h
Detected Declarations
struct stm32_lptim_cfgstruct stm32_lptim_triggerfunction stm32_lptim_validate_devicefunction is_stm32_lptim_triggerfunction stm32_lptim_setup_trigfunction stm32_lptim_trigger_probeexport is_stm32_lptim_trigger
Annotated Snippet
struct stm32_lptim_cfg {
const char * const (*triggers)[MAX_TRIGGERS];
unsigned int nb_triggers;
};
/* List Low-Power Timer triggers for H7, MP13, MP15 */
static const char * const stm32_lptim_triggers[][MAX_TRIGGERS] = {
{ LPTIM1_OUT,},
{ LPTIM2_OUT,},
{ LPTIM3_OUT,},
};
/* List Low-Power Timer triggers for STM32MP25 */
static const char * const stm32mp25_lptim_triggers[][MAX_TRIGGERS] = {
{ LPTIM1_CH1, LPTIM1_CH2, },
{ LPTIM2_CH1, LPTIM2_CH2, },
{ LPTIM3_CH1,},
{ LPTIM4_CH1,},
{ LPTIM5_OUT,},
};
static const struct stm32_lptim_cfg stm32mp15_lptim_cfg = {
.triggers = stm32_lptim_triggers,
.nb_triggers = ARRAY_SIZE(stm32_lptim_triggers),
};
static const struct stm32_lptim_cfg stm32mp25_lptim_cfg = {
.triggers = stm32mp25_lptim_triggers,
.nb_triggers = ARRAY_SIZE(stm32mp25_lptim_triggers),
};
struct stm32_lptim_trigger {
struct device *dev;
const char * const *triggers;
};
static int stm32_lptim_validate_device(struct iio_trigger *trig,
struct iio_dev *indio_dev)
{
if (indio_dev->modes & INDIO_HARDWARE_TRIGGERED)
return 0;
return -EINVAL;
}
static const struct iio_trigger_ops stm32_lptim_trigger_ops = {
.validate_device = stm32_lptim_validate_device,
};
/**
* is_stm32_lptim_trigger
* @trig: trigger to be checked
*
* return true if the trigger is a valid STM32 IIO Low-Power Timer Trigger
* either return false
*/
bool is_stm32_lptim_trigger(struct iio_trigger *trig)
{
return (trig->ops == &stm32_lptim_trigger_ops);
}
EXPORT_SYMBOL(is_stm32_lptim_trigger);
static int stm32_lptim_setup_trig(struct stm32_lptim_trigger *priv)
{
const char * const *cur = priv->triggers;
int ret;
while (cur && *cur) {
struct iio_trigger *trig;
trig = devm_iio_trigger_alloc(priv->dev, "%s", *cur);
if (!trig)
return -ENOMEM;
trig->dev.parent = priv->dev->parent;
trig->ops = &stm32_lptim_trigger_ops;
iio_trigger_set_drvdata(trig, priv);
ret = devm_iio_trigger_register(priv->dev, trig);
if (ret)
return ret;
cur++;
}
return 0;
}
static int stm32_lptim_trigger_probe(struct platform_device *pdev)
{
struct stm32_lptim_trigger *priv;
Annotation
- Immediate include surface: `linux/export.h`, `linux/iio/timer/stm32-lptim-trigger.h`, `linux/mfd/stm32-lptimer.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/property.h`.
- Detected declarations: `struct stm32_lptim_cfg`, `struct stm32_lptim_trigger`, `function stm32_lptim_validate_device`, `function is_stm32_lptim_trigger`, `function stm32_lptim_setup_trig`, `function stm32_lptim_trigger_probe`, `export is_stm32_lptim_trigger`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.