// SPDX-License-Identifier: GPL-2.0 /* * RTC interface for Wilco Embedded Controller with R/W abilities * * Copyright 2018 Google LLC * * The corresponding platform device is typically registered in * drivers/platform/chrome/wilco_ec/core.c */ #include <linux/bcd.h> #include <linux/err.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/platform_data/wilco-ec.h> #include <linux/rtc.h> #include <linux/timekeeping.h> #define EC_COMMAND_CMOS … #define EC_CMOS_TOD_WRITE … #define EC_CMOS_TOD_READ … /* Message sent to the EC to request the current time. */ struct ec_rtc_read_request { … } __packed; static struct ec_rtc_read_request read_rq = …; /** * 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 { … } __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 { … } __packed; static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) { … } static int wilco_ec_rtc_write(struct device *dev, struct rtc_time *tm) { … } static const struct rtc_class_ops wilco_ec_rtc_ops = …; static int wilco_ec_rtc_probe(struct platform_device *pdev) { … } static struct platform_driver wilco_ec_rtc_driver = …; module_platform_driver(…) …; MODULE_ALIAS(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; MODULE_DESCRIPTION(…) …;