diff options
Diffstat (limited to 'drivers/rtc/emul_rtc.c')
-rw-r--r-- | drivers/rtc/emul_rtc.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/rtc/emul_rtc.c b/drivers/rtc/emul_rtc.c index 209b4965c17..7e522103fd5 100644 --- a/drivers/rtc/emul_rtc.c +++ b/drivers/rtc/emul_rtc.c @@ -8,6 +8,7 @@ #include <common.h> #include <div64.h> #include <dm.h> +#include <env.h> #include <generated/timestamp_autogenerated.h> #include <rtc.h> @@ -60,9 +61,18 @@ static int emul_rtc_set(struct udevice *dev, const struct rtc_time *time) int emul_rtc_probe(struct udevice *dev) { struct emul_rtc *priv = dev_get_priv(dev); - - /* Use the build date as initial time */ - priv->offset_us = U_BOOT_EPOCH * 1000000ULL - timer_get_us(); + const char *epoch_str; + u64 epoch; + + epoch_str = env_get("rtc_emul_epoch"); + + if (epoch_str) { + epoch = simple_strtoull(epoch_str, NULL, 10); + } else { + /* Use the build date as initial time */ + epoch = U_BOOT_EPOCH; + } + priv->offset_us = epoch * 1000000ULL - timer_get_us(); priv->isdst = -1; return 0; |