drivers/rtc/rtc-ab-b5ze-s3.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-ab-b5ze-s3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-ab-b5ze-s3.c- Extension
.c- Size
- 28948 bytes
- Lines
- 955
- 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/module.hlinux/rtc.hlinux/i2c.hlinux/bcd.hlinux/of.hlinux/regmap.hlinux/interrupt.h
Detected Declarations
struct abb5zes3_rtc_datafunction abb5zes3_i2c_validate_chipfunction _abb5zes3_rtc_clear_alarmfunction _abb5zes3_rtc_update_alarmfunction _abb5zes3_rtc_update_timerfunction _abb5zes3_rtc_read_timefunction abb5zes3_rtc_set_timefunction registersfunction sec_from_timer_afunction _abb5zes3_rtc_read_timerfunction _abb5zes3_rtc_read_alarmfunction abb5zes3_rtc_read_alarmfunction minutefunction watchdogfunction abb5zes3_rtc_set_alarmfunction _abb5zes3_rtc_battery_low_irq_enablefunction abb5zes3_rtc_check_setupfunction abb5zes3_rtc_alarm_irq_enablefunction _abb5zes3_rtc_interruptfunction setfunction abb5zes3_probefunction abb5zes3_rtc_suspendfunction abb5zes3_rtc_resume
Annotated Snippet
struct abb5zes3_rtc_data {
struct rtc_device *rtc;
struct regmap *regmap;
int irq;
bool battery_low;
bool timer_alarm; /* current alarm is via timer A */
};
/*
* Try and match register bits w/ fixed null values to see whether we
* are dealing with an ABB5ZES3.
*/
static int abb5zes3_i2c_validate_chip(struct regmap *regmap)
{
u8 regs[ABB5ZES3_MEM_MAP_LEN];
static const u8 mask[ABB5ZES3_MEM_MAP_LEN] = { 0x00, 0x00, 0x10, 0x00,
0x80, 0xc0, 0xc0, 0xf8,
0xe0, 0x00, 0x00, 0x40,
0x40, 0x78, 0x00, 0x00,
0xf8, 0x00, 0x88, 0x00 };
int ret, i;
ret = regmap_bulk_read(regmap, 0, regs, ABB5ZES3_MEM_MAP_LEN);
if (ret)
return ret;
for (i = 0; i < ABB5ZES3_MEM_MAP_LEN; ++i) {
if (regs[i] & mask[i]) /* check if bits are cleared */
return -ENODEV;
}
return 0;
}
/* Clear alarm status bit. */
static int _abb5zes3_rtc_clear_alarm(struct device *dev)
{
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
int ret;
ret = regmap_update_bits(data->regmap, ABB5ZES3_REG_CTRL2,
ABB5ZES3_REG_CTRL2_AF, 0);
if (ret)
dev_err(dev, "%s: clearing alarm failed (%d)\n", __func__, ret);
return ret;
}
/* Enable or disable alarm (i.e. alarm interrupt generation) */
static int _abb5zes3_rtc_update_alarm(struct device *dev, bool enable)
{
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
int ret;
ret = regmap_update_bits(data->regmap, ABB5ZES3_REG_CTRL1,
ABB5ZES3_REG_CTRL1_AIE,
enable ? ABB5ZES3_REG_CTRL1_AIE : 0);
if (ret)
dev_err(dev, "%s: writing alarm INT failed (%d)\n",
__func__, ret);
return ret;
}
/* Enable or disable timer (watchdog timer A interrupt generation) */
static int _abb5zes3_rtc_update_timer(struct device *dev, bool enable)
{
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
int ret;
ret = regmap_update_bits(data->regmap, ABB5ZES3_REG_CTRL2,
ABB5ZES3_REG_CTRL2_WTAIE,
enable ? ABB5ZES3_REG_CTRL2_WTAIE : 0);
if (ret)
dev_err(dev, "%s: writing timer INT failed (%d)\n",
__func__, ret);
return ret;
}
/*
* Note: we only read, so regmap inner lock protection is sufficient, i.e.
* we do not need driver's main lock protection.
*/
static int _abb5zes3_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
u8 regs[ABB5ZES3_REG_RTC_SC + ABB5ZES3_RTC_SEC_LEN];
Annotation
- Immediate include surface: `linux/module.h`, `linux/rtc.h`, `linux/i2c.h`, `linux/bcd.h`, `linux/of.h`, `linux/regmap.h`, `linux/interrupt.h`.
- Detected declarations: `struct abb5zes3_rtc_data`, `function abb5zes3_i2c_validate_chip`, `function _abb5zes3_rtc_clear_alarm`, `function _abb5zes3_rtc_update_alarm`, `function _abb5zes3_rtc_update_timer`, `function _abb5zes3_rtc_read_time`, `function abb5zes3_rtc_set_time`, `function registers`, `function sec_from_timer_a`, `function _abb5zes3_rtc_read_timer`.
- 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.