// 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
*/
/* Message sent to the EC to request the current time. */ struct ec_rtc_read_request {
u8 command;
u8 reserved;
u8 param;
} __packed; staticstruct 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;
if (rtc_valid_tm(tm)) {
dev_err(dev, "Time from RTC is invalid: %ptRr\n", tm); return -EIO;
}
return 0;
}
staticint wilco_ec_rtc_write(struct device *dev, struct rtc_time *tm)
{ struct wilco_ec_device *ec = dev_get_drvdata(dev->parent); struct ec_rtc_write_request rtc; struct wilco_ec_message msg; int year = tm->tm_year + 1900; /* * Convert from 0=Sunday to 0=Saturday for the EC * We DO need to set weekday because the EC controls battery charging * schedules that depend on the day of the week.
*/ int wday = tm->tm_wday == 6 ? 0 : tm->tm_wday + 1; int ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.