drivers/rtc/rtc-renesas-rtca3.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-renesas-rtca3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-renesas-rtca3.c- Extension
.c- Size
- 25481 bytes
- Lines
- 897
- 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.
- 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/bcd.hlinux/bitfield.hlinux/cleanup.hlinux/clk.hlinux/completion.hlinux/delay.hlinux/iopoll.hlinux/interrupt.hlinux/jiffies.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/rtc.h
Detected Declarations
struct rtca3_ppb_per_cyclestruct rtca3_privenum rtca3_alrm_set_stepfunction rtca3_byte_update_bitsfunction rtca3_alarm_handler_helperfunction rtca3_alarm_handlerfunction rtca3_periodic_handlerfunction rtca3_prepare_cntalrm_regs_for_readfunction rtca3_read_timefunction rtca3_set_timefunction rtca3_alarm_irq_set_helperfunction rtca3_alarm_irq_enablefunction rtca3_read_alarmfunction rtca3_set_alarmfunction scoped_guardfunction scoped_guardfunction rtca3_read_offsetfunction scoped_guardfunction rtca3_set_offsetfunction rtca3_initial_setupfunction rtca3_request_irqsfunction rtca3_actionfunction rtca3_probefunction rtca3_removefunction rtca3_suspendfunction rtca3_clean_alarmfunction rtca3_resume
Annotated Snippet
struct rtca3_ppb_per_cycle {
int ten_sec;
int sixty_sec;
};
/**
* struct rtca3_priv - RTCA3 private data structure
* @base: base address
* @rtc_dev: RTC device
* @rstc: reset control
* @set_alarm_completion: alarm setup completion
* @alrm_sstep: alarm setup step (see enum rtca3_alrm_set_step)
* @lock: device lock
* @ppb: ppb per cycle for each the available adjustment modes
* @wakeup_irq: wakeup IRQ
*/
struct rtca3_priv {
void __iomem *base;
struct rtc_device *rtc_dev;
struct reset_control *rstc;
struct completion set_alarm_completion;
atomic_t alrm_sstep;
spinlock_t lock;
struct rtca3_ppb_per_cycle ppb;
int wakeup_irq;
};
static void rtca3_byte_update_bits(struct rtca3_priv *priv, u8 off, u8 mask, u8 val)
{
u8 tmp;
tmp = readb(priv->base + off);
tmp &= ~mask;
tmp |= (val & mask);
writeb(tmp, priv->base + off);
}
static u8 rtca3_alarm_handler_helper(struct rtca3_priv *priv)
{
u8 val, pending;
val = readb(priv->base + RTCA3_RSR);
pending = val & RTCA3_RSR_AF;
writeb(val & ~pending, priv->base + RTCA3_RSR);
if (pending)
rtc_update_irq(priv->rtc_dev, 1, RTC_AF | RTC_IRQF);
return pending;
}
static irqreturn_t rtca3_alarm_handler(int irq, void *dev_id)
{
struct rtca3_priv *priv = dev_id;
u8 pending;
guard(spinlock)(&priv->lock);
pending = rtca3_alarm_handler_helper(priv);
return IRQ_RETVAL(pending);
}
static irqreturn_t rtca3_periodic_handler(int irq, void *dev_id)
{
struct rtca3_priv *priv = dev_id;
u8 val, pending;
guard(spinlock)(&priv->lock);
val = readb(priv->base + RTCA3_RSR);
pending = val & RTCA3_RSR_PF;
if (pending) {
writeb(val & ~pending, priv->base + RTCA3_RSR);
if (atomic_read(&priv->alrm_sstep) > RTCA3_ALRM_SSTEP_IRQ) {
/* Alarm setup in progress. */
atomic_dec(&priv->alrm_sstep);
if (atomic_read(&priv->alrm_sstep) == RTCA3_ALRM_SSTEP_IRQ) {
/*
* We got 2 * 1/64 periodic interrupts. Disable
* interrupt and let alarm setup continue.
*/
rtca3_byte_update_bits(priv, RTCA3_RCR1,
RTCA3_RCR1_PIE, 0);
readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, val,
!(val & RTCA3_RCR1_PIE),
10, RTCA3_DEFAULT_TIMEOUT_US);
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/bitfield.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/iopoll.h`, `linux/interrupt.h`.
- Detected declarations: `struct rtca3_ppb_per_cycle`, `struct rtca3_priv`, `enum rtca3_alrm_set_step`, `function rtca3_byte_update_bits`, `function rtca3_alarm_handler_helper`, `function rtca3_alarm_handler`, `function rtca3_periodic_handler`, `function rtca3_prepare_cntalrm_regs_for_read`, `function rtca3_read_time`, `function rtca3_set_time`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source 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.