drivers/rtc/rtc-s3c.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-s3c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-s3c.c- Extension
.c- Size
- 13536 bytes
- Lines
- 567
- 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/module.hlinux/fs.hlinux/string.hlinux/init.hlinux/platform_device.hlinux/interrupt.hlinux/rtc.hlinux/bcd.hlinux/clk.hlinux/log2.hlinux/slab.hlinux/of.hlinux/uaccess.hlinux/io.hasm/irq.hrtc-s3c.h
Detected Declarations
struct s3c_rtcstruct s3c_rtc_datafunction s3c_rtc_enable_clkfunction s3c_rtc_disable_clkfunction s3c_rtc_alarmirqfunction s3c_rtc_setaiefunction s3c_rtc_read_timefunction s3c_rtc_write_timefunction s3c_rtc_gettimefunction s3c_rtc_settimefunction s3c_rtc_getalarmfunction s3c_rtc_setalarmfunction s3c6410_rtc_enablefunction s3c6410_rtc_disablefunction s3c_rtc_removefunction s3c_rtc_probefunction s3c_rtc_suspendfunction s3c_rtc_resumefunction s3c6410_rtc_irq
Annotated Snippet
struct s3c_rtc {
struct device *dev;
struct rtc_device *rtc;
void __iomem *base;
struct clk *rtc_clk;
struct clk *rtc_src_clk;
bool alarm_enabled;
const struct s3c_rtc_data *data;
int irq_alarm;
spinlock_t alarm_lock;
bool wake_en;
};
struct s3c_rtc_data {
bool needs_src_clk;
void (*irq_handler) (struct s3c_rtc *info, int mask);
void (*enable) (struct s3c_rtc *info);
void (*disable) (struct s3c_rtc *info);
};
static int s3c_rtc_enable_clk(struct s3c_rtc *info)
{
int ret;
ret = clk_enable(info->rtc_clk);
if (ret)
return ret;
if (info->data->needs_src_clk) {
ret = clk_enable(info->rtc_src_clk);
if (ret) {
clk_disable(info->rtc_clk);
return ret;
}
}
return 0;
}
static void s3c_rtc_disable_clk(struct s3c_rtc *info)
{
if (info->data->needs_src_clk)
clk_disable(info->rtc_src_clk);
clk_disable(info->rtc_clk);
}
/* IRQ Handler */
static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
{
struct s3c_rtc *info = (struct s3c_rtc *)id;
if (info->data->irq_handler)
info->data->irq_handler(info, S3C2410_INTP_ALM);
return IRQ_HANDLED;
}
/* Update control registers */
static int s3c_rtc_setaie(struct device *dev, unsigned int enabled)
{
struct s3c_rtc *info = dev_get_drvdata(dev);
unsigned long flags;
unsigned int tmp;
int ret;
dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled);
ret = s3c_rtc_enable_clk(info);
if (ret)
return ret;
tmp = readb(info->base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN;
if (enabled)
tmp |= S3C2410_RTCALM_ALMEN;
writeb(tmp, info->base + S3C2410_RTCALM);
spin_lock_irqsave(&info->alarm_lock, flags);
if (info->alarm_enabled && !enabled)
s3c_rtc_disable_clk(info);
else if (!info->alarm_enabled && enabled)
ret = s3c_rtc_enable_clk(info);
info->alarm_enabled = enabled;
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/string.h`, `linux/init.h`, `linux/platform_device.h`, `linux/interrupt.h`, `linux/rtc.h`, `linux/bcd.h`.
- Detected declarations: `struct s3c_rtc`, `struct s3c_rtc_data`, `function s3c_rtc_enable_clk`, `function s3c_rtc_disable_clk`, `function s3c_rtc_alarmirq`, `function s3c_rtc_setaie`, `function s3c_rtc_read_time`, `function s3c_rtc_write_time`, `function s3c_rtc_gettime`, `function s3c_rtc_settime`.
- 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.