drivers/rtc/rtc-omap.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-omap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-omap.c- Extension
.c- Size
- 27224 bytes
- Lines
- 1032
- Domain
- Driver Families
- Bucket
- drivers/rtc
- 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.
- 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/clk.hlinux/delay.hlinux/init.hlinux/io.hlinux/ioport.hlinux/kernel.hlinux/module.hlinux/of.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinconf-generic.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hlinux/rtc.hlinux/rtc/rtc-omap.h
Detected Declarations
struct omap_rtcstruct omap_rtc_device_typestruct omap_rtcfunction rtc_readfunction rtc_readlfunction rtc_writefunction rtc_writelfunction am3352_rtc_unlockfunction am3352_rtc_lockfunction default_rtc_unlockfunction rtc_irqfunction omap_rtc_alarm_irq_enablefunction tm2bcdfunction bcd2tmfunction omap_rtc_read_time_rawfunction omap_rtc_read_timefunction omap_rtc_set_timefunction omap_rtc_read_alarmfunction omap_rtc_set_alarmfunction omap_rtc_power_off_programfunction periodfunction rtc_pinctrl_get_groups_countfunction rtc_pinconf_getfunction rtc_pinconf_setfunction omap_rtc_scratch_readfunction omap_rtc_scratch_writefunction omap_rtc_probefunction omap_rtc_removefunction omap_rtc_suspendfunction omap_rtc_resumefunction omap_rtc_runtime_suspendfunction omap_rtc_shutdownexport omap_rtc_power_off_program
Annotated Snippet
struct omap_rtc_device_type {
bool has_32kclk_en;
bool has_irqwakeen;
bool has_pmic_mode;
bool has_power_up_reset;
void (*lock)(struct omap_rtc *rtc);
void (*unlock)(struct omap_rtc *rtc);
};
struct omap_rtc {
struct rtc_device *rtc;
void __iomem *base;
struct clk *clk;
int irq_alarm;
int irq_timer;
u8 interrupts_reg;
bool is_pmic_controller;
bool has_ext_clk;
bool is_suspending;
const struct omap_rtc_device_type *type;
struct pinctrl_dev *pctldev;
};
static inline u8 rtc_read(struct omap_rtc *rtc, unsigned int reg)
{
return readb(rtc->base + reg);
}
static inline u32 rtc_readl(struct omap_rtc *rtc, unsigned int reg)
{
return readl(rtc->base + reg);
}
static inline void rtc_write(struct omap_rtc *rtc, unsigned int reg, u8 val)
{
writeb(val, rtc->base + reg);
}
static inline void rtc_writel(struct omap_rtc *rtc, unsigned int reg, u32 val)
{
writel(val, rtc->base + reg);
}
static void am3352_rtc_unlock(struct omap_rtc *rtc)
{
rtc_writel(rtc, OMAP_RTC_KICK0_REG, KICK0_VALUE);
rtc_writel(rtc, OMAP_RTC_KICK1_REG, KICK1_VALUE);
}
static void am3352_rtc_lock(struct omap_rtc *rtc)
{
rtc_writel(rtc, OMAP_RTC_KICK0_REG, 0);
rtc_writel(rtc, OMAP_RTC_KICK1_REG, 0);
}
static void default_rtc_unlock(struct omap_rtc *rtc)
{
}
static void default_rtc_lock(struct omap_rtc *rtc)
{
}
/*
* We rely on the rtc framework to handle locking (rtc->ops_lock),
* so the only other requirement is that register accesses which
* require BUSY to be clear are made with IRQs locally disabled
*/
static void rtc_wait_not_busy(struct omap_rtc *rtc)
{
int count;
u8 status;
/* BUSY may stay active for 1/32768 second (~30 usec) */
for (count = 0; count < 50; count++) {
status = rtc_read(rtc, OMAP_RTC_STATUS_REG);
if (!(status & OMAP_RTC_STATUS_BUSY))
break;
udelay(1);
}
/* now we have ~15 usec to read/write various registers */
}
static irqreturn_t rtc_irq(int irq, void *dev_id)
{
struct omap_rtc *rtc = dev_id;
unsigned long events = 0;
u8 irq_data;
irq_data = rtc_read(rtc, OMAP_RTC_STATUS_REG);
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/clk.h`, `linux/delay.h`, `linux/init.h`, `linux/io.h`, `linux/ioport.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct omap_rtc`, `struct omap_rtc_device_type`, `struct omap_rtc`, `function rtc_read`, `function rtc_readl`, `function rtc_write`, `function rtc_writel`, `function am3352_rtc_unlock`, `function am3352_rtc_lock`, `function default_rtc_unlock`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: integration 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.