drivers/rtc/rtc-stm32.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-stm32.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-stm32.c- Extension
.c- Size
- 34512 bytes
- Lines
- 1289
- Domain
- Driver Families
- Bucket
- drivers/rtc
- 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.
- 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/bcd.hlinux/bitfield.hlinux/clk.hlinux/clk-provider.hlinux/errno.hlinux/iopoll.hlinux/ioport.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinmux.hlinux/platform_device.hlinux/pm_wakeirq.hlinux/regmap.hlinux/rtc.h
Detected Declarations
struct stm32_rtcstruct stm32_rtc_registersstruct stm32_rtc_eventsstruct stm32_rtc_datastruct stm32_rtcstruct stm32_rtc_rif_resourcestruct stm32_rtc_pinmux_funcenum stm32_rtc_pin_namefunction Copyrightfunction stm32_rtc_wpr_unlockfunction stm32_rtc_wpr_lockfunction stm32_rtc_pinctrl_get_groups_countfunction stm32_rtc_pinctrl_get_group_pinsfunction stm32_rtc_pinmux_action_alarmfunction stm32_rtc_pinmux_lsco_availablefunction stm32_rtc_pinmux_action_lscofunction stm32_rtc_pinmux_get_functions_countfunction stm32_rtc_pinmux_get_groupsfunction stm32_rtc_pinmux_set_muxfunction stm32_rtc_enter_init_modefunction stm32_rtc_exit_init_modefunction stm32_rtc_wait_syncfunction stm32_rtc_clear_event_flagsfunction stm32_rtc_alarm_irqfunction tm2bcdfunction bcd2tmfunction stm32_rtc_read_timefunction stm32_rtc_set_timefunction stm32_rtc_read_alarmfunction stm32_rtc_alarm_irq_enablefunction stm32_rtc_valid_alrmfunction stm32_rtc_set_alarmfunction stm32_rtc_clear_eventsfunction stm32mp1_rtc_clear_eventsfunction stm32_rtc_clean_outsfunction stm32_rtc_check_riffunction stm32_rtc_initfunction stm32_rtc_probefunction stm32_rtc_removefunction stm32_rtc_suspendfunction stm32_rtc_resume
Annotated Snippet
struct stm32_rtc_registers {
u16 tr;
u16 dr;
u16 cr;
u16 isr;
u16 prer;
u16 alrmar;
u16 wpr;
u16 sr;
u16 scr;
u16 cfgr;
u16 verr;
};
struct stm32_rtc_events {
u32 alra;
};
struct stm32_rtc_data {
const struct stm32_rtc_registers regs;
const struct stm32_rtc_events events;
void (*clear_events)(struct stm32_rtc *rtc, unsigned int flags);
bool has_pclk;
bool need_dbp;
bool need_accuracy;
bool rif_protected;
bool has_lsco;
bool has_alarm_out;
};
struct stm32_rtc {
struct rtc_device *rtc_dev;
void __iomem *base;
struct regmap *dbp;
unsigned int dbp_reg;
unsigned int dbp_mask;
struct clk *pclk;
struct clk *rtc_ck;
const struct stm32_rtc_data *data;
int irq_alarm;
struct clk *clk_lsco;
};
struct stm32_rtc_rif_resource {
unsigned int num;
u32 bit;
};
static const struct stm32_rtc_rif_resource STM32_RTC_RES_ALRA = {0, STM32_RTC_SECCFGR_ALRA_SEC};
static const struct stm32_rtc_rif_resource STM32_RTC_RES_INIT = {5, STM32_RTC_SECCFGR_INIT_SEC};
static void stm32_rtc_wpr_unlock(struct stm32_rtc *rtc)
{
const struct stm32_rtc_registers *regs = &rtc->data->regs;
writel_relaxed(RTC_WPR_1ST_KEY, rtc->base + regs->wpr);
writel_relaxed(RTC_WPR_2ND_KEY, rtc->base + regs->wpr);
}
static void stm32_rtc_wpr_lock(struct stm32_rtc *rtc)
{
const struct stm32_rtc_registers *regs = &rtc->data->regs;
writel_relaxed(RTC_WPR_WRONG_KEY, rtc->base + regs->wpr);
}
enum stm32_rtc_pin_name {
NONE,
OUT1,
OUT2,
OUT2_RMP
};
static const struct pinctrl_pin_desc stm32_rtc_pinctrl_pins[] = {
PINCTRL_PIN(OUT1, "out1"),
PINCTRL_PIN(OUT2, "out2"),
PINCTRL_PIN(OUT2_RMP, "out2_rmp"),
};
static int stm32_rtc_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
{
return ARRAY_SIZE(stm32_rtc_pinctrl_pins);
}
static const char *stm32_rtc_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
unsigned int selector)
{
return stm32_rtc_pinctrl_pins[selector].name;
}
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/errno.h`, `linux/iopoll.h`, `linux/ioport.h`, `linux/mfd/syscon.h`.
- Detected declarations: `struct stm32_rtc`, `struct stm32_rtc_registers`, `struct stm32_rtc_events`, `struct stm32_rtc_data`, `struct stm32_rtc`, `struct stm32_rtc_rif_resource`, `struct stm32_rtc_pinmux_func`, `enum stm32_rtc_pin_name`, `function Copyright`, `function stm32_rtc_wpr_unlock`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source implementation candidate.
- 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.