From 086efb5aaab014a31ef2bd1ee54662e4698b522d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 22 Jan 2021 16:10:20 -0700 Subject: zephyr: Enable base support for real-time-clock (RTC) Add Kconfig options for the various RTC features. Add stubs for the actual implementation, to be implemented using Zephyr API calls to the RTC driver, when available. The duplication of RTC functions across different chips can be addressed in b/179055201 Also add the header to zephyr_host_command.h since otherwise we get a build error. It seems better to have the header there than in the files that use DECLARE_CONSOLE_COMMAND(). BUG=b:178230662, b:179055201 BRANCH=none TEST=build volteer for zephyr, try rtc and rtc_alarm command make BOARD=volteer -j8 Change-Id: I036b1f3d91543a357ad779e475a03584759a3de4 Signed-off-by: Simon Glass Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645570 Reviewed-by: Yuval Peress Commit-Queue: Yuval Peress --- zephyr/Kconfig | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'zephyr/Kconfig') diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 6b5f9e8ec5..002dbcaa9c 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -413,6 +413,60 @@ config PLATFORM_EC_PWM support variable brightness LEDs, backlight controls, and variable-speed fans. +config PLATFORM_EC_RTC + bool "Real-time clock (RTC)" + default y + help + Enable support for a real-time clock. Typically this is available + on-chip in the EC. It provides a way to track the passage of time + in terms of second and minutes. Once set, and provided that it has a + suitable power source, it should be able to keep reasonably accurate + time over a period of days and weeks. + + The starting EC clock is typically set by the AP, since it has access + to the outside world and can often obtain the current time when + desired. + +if PLATFORM_EC_RTC + +config PLATFORM_EC_CONSOLE_CMD_RTC + bool "Console command: rtc" + default y + help + This command allows getting and setting the current RTC value. The + value is in seconds since the Epoch (midnight on 1/1/70). You can + convert this to a human date on the command line with 'date -u -d @n' + where n is the numeric value. To convert a time to seconds, use: + + date -d '1970-01-01 UTC + n seconds' + +config PLATFORM_EC_CONSOLE_CMD_RTC_ALARM + bool "Console command: rtc_alarm" + depends on PLATFORM_EC_CONSOLE_CMD_RTC + default y + help + This command supports setting a real-time-clock (RTC) alarm that + causes an interrupt when the timer reaches that point. To set the + alarm: + + rtc [] + + where: + is the number of seconds since the epoch + is the optional number of microseconds (fractional seconds) + +config PLATFORM_EC_HOSTCMD_RTC + bool "Host command: EC_CMD_RTC_GET_VALUE etc." + depends on PLATFORM_EC_HOSTCMD + default y + help + Enables support for EC_CMD_RTC_GET_VALUE, EC_CMD_RTC_SET_VALUE, + EC_CMD_RTC_GET_ALARM and EC_CMD_RTC_SET_ALARM which colectively allow + the AP to control the EC's real-time-clock. The AP typically makes + use of the EC's RTC to avoid needing a discrete RTC chip on the board. + +endif # PLATFORM_EC_RTC + config PLATFORM_EC_CONSOLE_CMD_SHMEM bool "Console command: shmem" default y -- cgit v1.2.1