drivers/rtc/rtc-88pm886.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-88pm886.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-88pm886.c- Extension
.c- Size
- 2232 bytes
- Lines
- 98
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/limits.hlinux/mod_devicetable.hlinux/platform_device.hlinux/rtc.hlinux/mfd/88pm886.h
Detected Declarations
function pm886_rtc_read_timefunction pm886_rtc_set_timefunction pm886_rtc_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/limits.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
#include <linux/mfd/88pm886.h>
/*
* Time is calculated as the sum of a 32-bit read-only advancing counter and a
* writeable constant offset stored in the chip's spare registers.
*/
static int pm886_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct regmap *regmap = dev_get_drvdata(dev);
u32 time;
u32 buf;
int ret;
ret = regmap_bulk_read(regmap, PM886_REG_RTC_SPARE1, &buf, 4);
if (ret)
return ret;
time = buf;
ret = regmap_bulk_read(regmap, PM886_REG_RTC_CNT1, &buf, 4);
if (ret)
return ret;
time += buf;
rtc_time64_to_tm(time, tm);
return 0;
}
static int pm886_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct regmap *regmap = dev_get_drvdata(dev);
u32 buf;
int ret;
ret = regmap_bulk_read(regmap, PM886_REG_RTC_CNT1, &buf, 4);
if (ret)
return ret;
buf = rtc_tm_to_time64(tm) - buf;
return regmap_bulk_write(regmap, PM886_REG_RTC_SPARE1, &buf, 4);
}
static const struct rtc_class_ops pm886_rtc_ops = {
.read_time = pm886_rtc_read_time,
.set_time = pm886_rtc_set_time,
};
static int pm886_rtc_probe(struct platform_device *pdev)
{
struct pm886_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct device *dev = &pdev->dev;
struct rtc_device *rtc;
int ret;
platform_set_drvdata(pdev, chip->regmap);
rtc = devm_rtc_allocate_device(dev);
if (IS_ERR(rtc))
return dev_err_probe(dev, PTR_ERR(rtc),
"Failed to allocate RTC device\n");
rtc->ops = &pm886_rtc_ops;
rtc->range_max = U32_MAX;
ret = devm_rtc_register_device(rtc);
if (ret)
return dev_err_probe(dev, ret, "Failed to register RTC device\n");
return 0;
}
static const struct platform_device_id pm886_rtc_id_table[] = {
{ "88pm886-rtc", },
{ }
};
MODULE_DEVICE_TABLE(platform, pm886_rtc_id_table);
static struct platform_driver pm886_rtc_driver = {
.driver = {
.name = "88pm886-rtc",
},
.probe = pm886_rtc_probe,
Annotation
- Immediate include surface: `linux/limits.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/rtc.h`, `linux/mfd/88pm886.h`.
- Detected declarations: `function pm886_rtc_read_time`, `function pm886_rtc_set_time`, `function pm886_rtc_probe`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source implementation candidate.
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.