// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
 *
 * This driver emulates a real time clock based on timer ticks.
 */

#include <common.h>
#include <div64.h>
#include <dm.h>
#include <generated/timestamp_autogenerated.h>
#include <rtc.h>

/**
 * struct emul_rtc - private data for emulated RTC driver
 */
struct emul_rtc {
	/**
	 * @offset_us: microseconds from 1970-01-01 to timer_get_us() base
	 */
	u64 offset_us;
	/**
	 * @isdst: daylight saving time
	 */
	int isdst;
};

static int emul_rtc_get(struct udevice *dev, struct rtc_time *time)
{
	struct emul_rtc *priv = dev_get_priv(dev);
	u64 now;

	if (!priv->offset_us) {
		/* Use the build date as initial time */
		priv->offset_us = U_BOOT_EPOCH * 1000000ULL - timer_get_us();
		priv->isdst = -1;
	}

	now = timer_get_us() + priv->offset_us;
	do_div(now, 1000000);
	rtc_to_tm(now, time);
	time->tm_isdst = priv->isdst;

	return 0;
}

static int emul_rtc_set(struct udevice *dev, const struct rtc_time *time)
{
	struct emul_rtc *priv = dev_get_priv(dev);

	if (time->tm_year < 1970)
		return -EINVAL;

	priv->offset_us = rtc_mktime(time) * 1000000ULL - timer_get_us();

	if (time->tm_isdst > 0)
		priv->isdst = 1;
	else if (time->tm_isdst < 0)
		priv->isdst = -1;
	else
		priv->isdst = 0;

	return 0;
}

static const struct rtc_ops emul_rtc_ops = {
	.get = emul_rtc_get,
	.set = emul_rtc_set,
};

U_BOOT_DRIVER(rtc_emul) = {
	.name	= "rtc_emul",
	.id	= UCLASS_RTC,
	.ops	= &emul_rtc_ops,
	.priv_auto_alloc_size = sizeof(struct emul_rtc),
};

U_BOOT_DEVICE(rtc_emul) = {
	.name	= "rtc_emul",
};
