drivers/rtc/rtc-cv1800.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-cv1800.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-cv1800.c- Extension
.c- Size
- 5162 bytes
- Lines
- 219
- 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/clk.hlinux/irq.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/rtc.h
Detected Declarations
struct cv1800_rtc_privfunction cv1800_rtc_enabledfunction cv1800_rtc_enablefunction cv1800_rtc_alarm_irq_enablefunction cv1800_rtc_set_alarmfunction cv1800_rtc_read_alarmfunction cv1800_rtc_read_timefunction cv1800_rtc_set_timefunction cv1800_rtc_irq_handlerfunction cv1800_rtc_probe
Annotated Snippet
struct cv1800_rtc_priv {
struct rtc_device *rtc_dev;
struct regmap *rtc_map;
struct clk *clk;
int irq;
};
static bool cv1800_rtc_enabled(struct device *dev)
{
struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
u32 reg;
regmap_read(info->rtc_map, SEC_PULSE_GEN, ®);
return (reg & SEL_SEC_PULSE) == 0;
}
static void cv1800_rtc_enable(struct device *dev)
{
struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
/* Sec pulse generated internally */
regmap_update_bits(info->rtc_map, SEC_PULSE_GEN, SEL_SEC_PULSE, 0);
}
static int cv1800_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
{
struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
regmap_write(info->rtc_map, ALARM_ENABLE, enabled);
return 0;
}
static int cv1800_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
unsigned long alarm_time;
alarm_time = rtc_tm_to_time64(&alrm->time);
cv1800_rtc_alarm_irq_enable(dev, 0);
regmap_write(info->rtc_map, ALARM_TIME, alarm_time);
cv1800_rtc_alarm_irq_enable(dev, alrm->enabled);
return 0;
}
static int cv1800_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
u32 enabled;
u32 time;
if (!cv1800_rtc_enabled(dev)) {
alarm->enabled = 0;
return 0;
}
regmap_read(info->rtc_map, ALARM_ENABLE, &enabled);
alarm->enabled = enabled & ALARM_ENABLE_MASK;
regmap_read(info->rtc_map, ALARM_TIME, &time);
rtc_time64_to_tm(time, &alarm->time);
return 0;
}
static int cv1800_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
u32 sec;
if (!cv1800_rtc_enabled(dev))
return -EINVAL;
regmap_read(info->rtc_map, SEC_CNTR_VAL, &sec);
rtc_time64_to_tm(sec, tm);
return 0;
}
static int cv1800_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct cv1800_rtc_priv *info = dev_get_drvdata(dev);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/irq.h`, `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct cv1800_rtc_priv`, `function cv1800_rtc_enabled`, `function cv1800_rtc_enable`, `function cv1800_rtc_alarm_irq_enable`, `function cv1800_rtc_set_alarm`, `function cv1800_rtc_read_alarm`, `function cv1800_rtc_read_time`, `function cv1800_rtc_set_time`, `function cv1800_rtc_irq_handler`, `function cv1800_rtc_probe`.
- 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.