Tim Wawrzynczak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31770
Change subject: ec/google/chromeec: Synchronize AP RTC to the EC. ......................................................................
ec/google/chromeec: Synchronize AP RTC to the EC.
In google_chromeec_init(), if the AP is set as the RTC source for the system, then send current RTC timestamp over to the EC for synchronization.
BUG=b:111675966 BRANCH=none TEST=Tested with EC changes from b87515e21
Change-Id: Ib081aee5d10ec64dac79fc0ebf3fc39eab380a7f Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/ec/google/chromeec/ec_commands.h 3 files changed, 42 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/70/31770/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 70b3f49..317cede 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1076,6 +1076,35 @@
static int ec_image_type; /* Cached EC image type (ro or rw). */
+#if !IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_RTC) +int google_chromeec_sync_rtc(void) +{ + struct chromeec_command cec_cmd; + struct ec_params_sync_rtc cmd_sync; + struct rtc_time tm; + int rtc_time_sec; + + if (rtc_get(&tm)) + { + return 1; + } + + rtc_time_sec = rtc_mktime(&tm); + + cec_cmd.cmd_code = EC_CMD_SYNC_RTC; + cec_cmd.cmd_version = 0; + cmd_sync.rtc_time_sec = (uint32_t)rtc_time_sec; + cec_cmd.cmd_data_in = &cmd_sync; + cec_cmd.cmd_data_out = NULL; + cec_cmd.cmd_size_in = sizeof(cmd_sync); + cec_cmd.cmd_size_out = 0; + cec_cmd.cmd_dev_index = 0; + google_chromeec_command(&cec_cmd); + printk(BIOS_WARNING, "Google Chrome synced RTC time; %lu\n", (unsigned long)rtc_time_sec); + return cec_cmd.cmd_code; +} +#endif /* !IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_RTC) */ + void google_chromeec_init(void) { struct chromeec_command cec_cmd; @@ -1103,6 +1132,9 @@ ec_image_type = cec_resp.current_image; }
+#if !IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_RTC) + google_chromeec_sync_rtc(); +#endif google_chromeec_log_uptimeinfo(); }
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 7a38336..75a441c 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -38,6 +38,7 @@ void google_chromeec_init(void); int google_chromeec_pd_get_amode(uint16_t svid); int google_chromeec_wait_for_displayport(long timeout); +int google_chromeec_sync_rtc(void);
/* Device events */ uint64_t google_chromeec_get_device_enabled_events(void); diff --git a/src/ec/google/chromeec/ec_commands.h b/src/ec/google/chromeec/ec_commands.h index 140ba5a..ffc3a90 100644 --- a/src/ec/google/chromeec/ec_commands.h +++ b/src/ec/google/chromeec/ec_commands.h @@ -5125,6 +5125,15 @@ uint8_t allow_charging; };
+/* + * Sync RTC information to the EC + */ +#define EC_CMD_SYNC_RTC 0x0603 + +struct __ec_align4 ec_params_sync_rtc { + uint32_t rtc_time_sec; +}; + /*****************************************************************************/ /* * Reserve a range of host commands for board-specific, experimental, or