drivers/rtc/rtc-rx8025.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-rx8025.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-rx8025.c- Extension
.c- Size
- 14701 bytes
- Lines
- 589
- 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/bcd.hlinux/bitops.hlinux/i2c.hlinux/kernel.hlinux/kstrtox.hlinux/module.hlinux/rtc.h
Detected Declarations
struct rx8025_dataenum rx_modelfunction rx8025_read_regfunction rx8025_read_regsfunction rx8025_write_regfunction rx8025_write_regsfunction rx8025_is_osc_stoppedfunction rx8025_check_validityfunction rx8025_reset_validityfunction rx8025_handle_irqfunction rx8025_get_timefunction rx8025_set_timefunction rx8025_init_clientfunction rx8025_read_alarmfunction rx8025_set_alarmfunction rx8025_alarm_irq_enablefunction rx8025_read_offsetfunction rx8025_set_offsetfunction rx8025_sysfs_show_clock_adjustfunction rx8025_sysfs_store_clock_adjustfunction rx8025_probe
Annotated Snippet
struct rx8025_data {
struct rtc_device *rtc;
enum rx_model model;
u8 ctrl1;
int is_24;
};
static s32 rx8025_read_reg(const struct i2c_client *client, u8 number)
{
return i2c_smbus_read_byte_data(client, number << 4);
}
static int rx8025_read_regs(const struct i2c_client *client,
u8 number, u8 length, u8 *values)
{
int ret = i2c_smbus_read_i2c_block_data(client, number << 4, length,
values);
if (ret != length)
return ret < 0 ? ret : -EIO;
return 0;
}
static s32 rx8025_write_reg(const struct i2c_client *client, u8 number,
u8 value)
{
return i2c_smbus_write_byte_data(client, number << 4, value);
}
static s32 rx8025_write_regs(const struct i2c_client *client,
u8 number, u8 length, const u8 *values)
{
return i2c_smbus_write_i2c_block_data(client, number << 4,
length, values);
}
static int rx8025_is_osc_stopped(enum rx_model model, int ctrl2)
{
int xstp = ctrl2 & RX8025_BIT_CTRL2_XST;
/* XSTP bit has different polarity on RX-8025 vs RX-8035.
* RX-8025: 0 == oscillator stopped
* RX-8035: 1 == oscillator stopped
*/
if (model == model_rx_8025)
xstp = !xstp;
return xstp;
}
static int rx8025_check_validity(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct rx8025_data *drvdata = dev_get_drvdata(dev);
int ctrl2;
int xstp;
ctrl2 = rx8025_read_reg(client, RX8025_REG_CTRL2);
if (ctrl2 < 0)
return ctrl2;
if (ctrl2 & RX8025_BIT_CTRL2_VDET)
dev_warn(dev, "power voltage drop detected\n");
if (ctrl2 & RX8025_BIT_CTRL2_PON) {
dev_warn(dev, "power-on reset detected, date is invalid\n");
return -EINVAL;
}
xstp = rx8025_is_osc_stopped(drvdata->model, ctrl2);
if (xstp) {
dev_warn(dev, "crystal stopped, date is invalid\n");
return -EINVAL;
}
return 0;
}
static int rx8025_reset_validity(struct i2c_client *client)
{
struct rx8025_data *drvdata = i2c_get_clientdata(client);
int ctrl2 = rx8025_read_reg(client, RX8025_REG_CTRL2);
if (ctrl2 < 0)
return ctrl2;
ctrl2 &= ~(RX8025_BIT_CTRL2_PON | RX8025_BIT_CTRL2_VDET);
if (drvdata->model == model_rx_8025)
ctrl2 |= RX8025_BIT_CTRL2_XST;
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/bitops.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/kstrtox.h`, `linux/module.h`, `linux/rtc.h`.
- Detected declarations: `struct rx8025_data`, `enum rx_model`, `function rx8025_read_reg`, `function rx8025_read_regs`, `function rx8025_write_reg`, `function rx8025_write_regs`, `function rx8025_is_osc_stopped`, `function rx8025_check_validity`, `function rx8025_reset_validity`, `function rx8025_handle_irq`.
- 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.