drivers/rtc/rtc-rc5t619.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-rc5t619.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-rc5t619.c- Extension
.c- Size
- 10275 bytes
- Lines
- 452
- 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/kernel.hlinux/device.hlinux/errno.hlinux/init.hlinux/module.hlinux/mfd/rn5t618.hlinux/platform_device.hlinux/regmap.hlinux/bcd.hlinux/rtc.hlinux/slab.hlinux/irqdomain.h
Detected Declarations
struct rc5t619_rtcfunction rtc5t619_12hour_bcd2binfunction rtc5t619_12hour_bin2bcdfunction rc5t619_rtc_periodic_disablefunction rc5t619_rtc_pon_setupfunction rc5t619_rtc_read_timefunction rc5t619_rtc_set_timefunction rc5t619_rtc_alarm_enablefunction rc5t619_rtc_read_alarmfunction rc5t619_rtc_set_alarmfunction rc5t619_rtc_alarm_flag_clrfunction rc5t619_rtc_irqfunction rc5t619_rtc_probe
Annotated Snippet
struct rc5t619_rtc {
int irq;
struct rtc_device *rtc;
struct rn5t618 *rn5t618;
};
#define CTRL1_ALARM_ENABLED 0x40
#define CTRL1_24HR 0x20
#define CTRL1_PERIODIC_MASK 0xf
#define CTRL2_PON 0x10
#define CTRL2_ALARM_STATUS 0x80
#define CTRL2_CTFG 0x4
#define CTRL2_CTC 0x1
#define MONTH_CENTFLAG 0x80
#define HOUR_PMFLAG 0x20
#define MDAY_DAL_EXT 0x80
static uint8_t rtc5t619_12hour_bcd2bin(uint8_t hour)
{
if (hour & HOUR_PMFLAG) {
hour = bcd2bin(hour & ~HOUR_PMFLAG);
return hour == 12 ? 12 : 12 + hour;
}
hour = bcd2bin(hour);
return hour == 12 ? 0 : hour;
}
static uint8_t rtc5t619_12hour_bin2bcd(uint8_t hour)
{
if (!hour)
return 0x12;
if (hour < 12)
return bin2bcd(hour);
if (hour == 12)
return 0x12 | HOUR_PMFLAG;
return bin2bcd(hour - 12) | HOUR_PMFLAG;
}
static int rc5t619_rtc_periodic_disable(struct device *dev)
{
struct rc5t619_rtc *rtc = dev_get_drvdata(dev);
int err;
/* disable function */
err = regmap_update_bits(rtc->rn5t618->regmap,
RN5T618_RTC_CTRL1, CTRL1_PERIODIC_MASK, 0);
if (err < 0)
return err;
/* clear alarm flag and CTFG */
err = regmap_update_bits(rtc->rn5t618->regmap, RN5T618_RTC_CTRL2,
CTRL2_ALARM_STATUS | CTRL2_CTFG | CTRL2_CTC,
0);
if (err < 0)
return err;
return 0;
}
/* things to be done once after power on */
static int rc5t619_rtc_pon_setup(struct device *dev)
{
struct rc5t619_rtc *rtc = dev_get_drvdata(dev);
int err;
unsigned int reg_data;
err = regmap_read(rtc->rn5t618->regmap, RN5T618_RTC_CTRL2, ®_data);
if (err < 0)
return err;
/* clear VDET PON */
reg_data &= ~(CTRL2_PON | CTRL2_CTC | 0x4a); /* 0101-1011 */
reg_data |= 0x20; /* 0010-0000 */
err = regmap_write(rtc->rn5t618->regmap, RN5T618_RTC_CTRL2, reg_data);
if (err < 0)
return err;
/* clearing RTC Adjust register */
err = regmap_write(rtc->rn5t618->regmap, RN5T618_RTC_ADJUST, 0);
if (err)
return err;
return regmap_update_bits(rtc->rn5t618->regmap,
RN5T618_RTC_CTRL1,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/device.h`, `linux/errno.h`, `linux/init.h`, `linux/module.h`, `linux/mfd/rn5t618.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct rc5t619_rtc`, `function rtc5t619_12hour_bcd2bin`, `function rtc5t619_12hour_bin2bcd`, `function rc5t619_rtc_periodic_disable`, `function rc5t619_rtc_pon_setup`, `function rc5t619_rtc_read_time`, `function rc5t619_rtc_set_time`, `function rc5t619_rtc_alarm_enable`, `function rc5t619_rtc_read_alarm`, `function rc5t619_rtc_set_alarm`.
- 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.