drivers/rtc/rtc-rv3028.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-rv3028.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-rv3028.c- Extension
.c- Size
- 24942 bytes
- Lines
- 1064
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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-provider.hlinux/bcd.hlinux/bitfield.hlinux/bitops.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/log2.hlinux/module.hlinux/of.hlinux/regmap.hlinux/rtc.h
Detected Declarations
struct rv3028_dataenum rv3028_typefunction timestamp0_storefunction timestamp0_showfunction timestamp0_count_showfunction rv3028_exit_eerdfunction rv3028_enter_eerdfunction rv3028_update_eepromfunction rv3028_update_cfgfunction rv3028_handle_irqfunction rv3028_get_timefunction rv3028_set_timefunction rv3028_get_alarmfunction rv3028_set_alarmfunction rv3028_alarm_irq_enablefunction rv3028_read_offsetfunction rv3028_set_offsetfunction rv3028_param_getfunction rv3028_param_setfunction rv3028_ioctlfunction rv3028_nvram_writefunction rv3028_nvram_readfunction rv3028_eeprom_writefunction rv3028_eeprom_readfunction rv3028_clkout_recalc_ratefunction rv3028_clkout_determine_ratefunction rv3028_clkout_set_ratefunction rv3028_clkout_preparefunction rv3028_clkout_unpreparefunction rv3028_clkout_is_preparedfunction rv3028_clkout_register_clkfunction rv3028_set_trickle_chargerfunction rv3028_probe
Annotated Snippet
struct rv3028_data {
struct regmap *regmap;
struct rtc_device *rtc;
enum rv3028_type type;
#ifdef CONFIG_COMMON_CLK
struct clk_hw clkout_hw;
#endif
};
static u16 rv3028_trickle_resistors[] = {3000, 5000, 9000, 15000};
static ssize_t timestamp0_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct rv3028_data *rv3028 = dev_get_drvdata(dev->parent);
regmap_update_bits(rv3028->regmap, RV3028_EVT_CTRL, RV3028_EVT_CTRL_TSR,
RV3028_EVT_CTRL_TSR);
return count;
};
static ssize_t timestamp0_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct rv3028_data *rv3028 = dev_get_drvdata(dev->parent);
struct rtc_time tm;
unsigned int count;
u8 date[6];
int ret;
ret = regmap_read(rv3028->regmap, RV3028_TS_COUNT, &count);
if (ret)
return ret;
if (!count)
return 0;
ret = regmap_bulk_read(rv3028->regmap, RV3028_TS_SEC, date,
sizeof(date));
if (ret)
return ret;
tm.tm_sec = bcd2bin(date[0]);
tm.tm_min = bcd2bin(date[1]);
tm.tm_hour = bcd2bin(date[2]);
tm.tm_mday = bcd2bin(date[3]);
tm.tm_mon = bcd2bin(date[4]) - 1;
tm.tm_year = bcd2bin(date[5]) + 100;
ret = rtc_valid_tm(&tm);
if (ret)
return ret;
return sprintf(buf, "%llu\n",
(unsigned long long)rtc_tm_to_time64(&tm));
};
static DEVICE_ATTR_RW(timestamp0);
static ssize_t timestamp0_count_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct rv3028_data *rv3028 = dev_get_drvdata(dev->parent);
unsigned int count;
int ret;
ret = regmap_read(rv3028->regmap, RV3028_TS_COUNT, &count);
if (ret)
return ret;
return sprintf(buf, "%u\n", count);
};
static DEVICE_ATTR_RO(timestamp0_count);
static struct attribute *rv3028_attrs[] = {
&dev_attr_timestamp0.attr,
&dev_attr_timestamp0_count.attr,
NULL
};
static const struct attribute_group rv3028_attr_group = {
.attrs = rv3028_attrs,
};
static int rv3028_exit_eerd(struct rv3028_data *rv3028, u32 eerd)
{
if (eerd)
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/bcd.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/log2.h`.
- Detected declarations: `struct rv3028_data`, `enum rv3028_type`, `function timestamp0_store`, `function timestamp0_show`, `function timestamp0_count_show`, `function rv3028_exit_eerd`, `function rv3028_enter_eerd`, `function rv3028_update_eeprom`, `function rv3028_update_cfg`, `function rv3028_handle_irq`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.