drivers/rtc/rtc-wilco-ec.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-wilco-ec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-wilco-ec.c- Extension
.c- Size
- 4712 bytes
- Lines
- 195
- 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/bcd.hlinux/err.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/platform_data/wilco-ec.hlinux/rtc.hlinux/timekeeping.h
Detected Declarations
struct ec_rtc_read_requeststruct ec_rtc_read_responsestruct ec_rtc_write_requestfunction wilco_ec_rtc_readfunction wilco_ec_rtc_writefunction wilco_ec_rtc_probe
Annotated Snippet
struct ec_rtc_read_request {
u8 command;
u8 reserved;
u8 param;
} __packed;
static struct ec_rtc_read_request read_rq = {
.command = EC_COMMAND_CMOS,
.param = EC_CMOS_TOD_READ,
};
/**
* struct ec_rtc_read_response - Format of RTC returned by EC.
* @reserved: Unused byte
* @second: Second value (0..59)
* @minute: Minute value (0..59)
* @hour: Hour value (0..23)
* @day: Day value (1..31)
* @month: Month value (1..12)
* @year: Year value (full year % 100)
* @century: Century value (full year / 100)
*
* All values are presented in binary (not BCD).
*/
struct ec_rtc_read_response {
u8 reserved;
u8 second;
u8 minute;
u8 hour;
u8 day;
u8 month;
u8 year;
u8 century;
} __packed;
/**
* struct ec_rtc_write_request - Format of RTC sent to the EC.
* @command: Always EC_COMMAND_CMOS
* @reserved: Unused byte
* @param: Always EC_CMOS_TOD_WRITE
* @century: Century value (full year / 100)
* @year: Year value (full year % 100)
* @month: Month value (1..12)
* @day: Day value (1..31)
* @hour: Hour value (0..23)
* @minute: Minute value (0..59)
* @second: Second value (0..59)
* @weekday: Day of the week (0=Saturday)
*
* All values are presented in BCD.
*/
struct ec_rtc_write_request {
u8 command;
u8 reserved;
u8 param;
u8 century;
u8 year;
u8 month;
u8 day;
u8 hour;
u8 minute;
u8 second;
u8 weekday;
} __packed;
static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm)
{
struct wilco_ec_device *ec = dev_get_drvdata(dev->parent);
struct ec_rtc_read_response rtc;
struct wilco_ec_message msg;
int ret;
memset(&msg, 0, sizeof(msg));
msg.type = WILCO_EC_MSG_LEGACY;
msg.request_data = &read_rq;
msg.request_size = sizeof(read_rq);
msg.response_data = &rtc;
msg.response_size = sizeof(rtc);
ret = wilco_ec_mailbox(ec, &msg);
if (ret < 0)
return ret;
tm->tm_sec = rtc.second;
tm->tm_min = rtc.minute;
tm->tm_hour = rtc.hour;
tm->tm_mday = rtc.day;
tm->tm_mon = rtc.month - 1;
tm->tm_year = rtc.year + (rtc.century * 100) - 1900;
/* Ignore other tm fields, man rtc says userspace shouldn't use them. */
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/err.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/platform_data/wilco-ec.h`, `linux/rtc.h`, `linux/timekeeping.h`.
- Detected declarations: `struct ec_rtc_read_request`, `struct ec_rtc_read_response`, `struct ec_rtc_write_request`, `function wilco_ec_rtc_read`, `function wilco_ec_rtc_write`, `function wilco_ec_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.