rtc: initialize emulated RTC from environment variable
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 30 Oct 2020 02:27:22 +0000 (03:27 +0100)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 30 Oct 2020 13:20:27 +0000 (14:20 +0100)
commitfb71c3f49016abcadf0d0cbe9df99975e64de651
tree8cf9d6fdf0c3bcda7afa498d975c0fcf429020a3
parent0ca4b558b59d69d0b39ce42664c601690ecc8d6c
rtc: initialize emulated RTC from environment variable

Up to now the emulated RTC is initialized using the U-Boot build time.

With this patch the environment variable 'rtc_emul_epoch' can be used to
provide a better initial time. The variable is a decimal string with
the number of seconds since 1970-01-01. Here is an example where the RTC
had not been probed yet:

    => setenv rtc_emul_epoch 1610109000
    => date
    Date: 2021-01-08 (Friday)    Time: 12:30:00

If the variable does not exist, the U-Boot build time is used as fallback.

The environment variable may be set when shutting down the operating system
if the U-Boot environment is exposed to the OS (cf. ENV_IS_IN_FAT and
ENV_IS_IN_EXT4).

Suggested-by: Pablo Sebastián Greco <pgreco@centosproject.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
drivers/rtc/Kconfig
drivers/rtc/emul_rtc.c