diff mbox series

[02/10] arm: imx: syscounter: Add timer_early functions

Message ID 20220921140625.999002-3-sr@denx.de
State Changes Requested
Delegated to: Simon Glass
Headers show
Series bootstage: Migrate from timer_get_boot_us() to timer_get_us() | expand

Commit Message

Stefan Roese Sept. 21, 2022, 2:06 p.m. UTC
Currently this timer driver provides timer_get_boot_us() to support the
BOOTSTAGE functionality. This patch adds the timer_early functions so
that the "normal" timer functions can be used, when CONFIG_TIMER_EARLY
is enabled.

timer_get_boot_us() will get removed in a follow-up patch, once the
BOOTSTAGE interface is migrated to timer_get_us().

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jun Nie <jun.nie@linaro.org>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
---
 arch/arm/mach-imx/syscounter.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Simon Glass Sept. 25, 2022, 2:15 p.m. UTC | #1
On Wed, 21 Sept 2022 at 08:06, Stefan Roese <sr@denx.de> wrote:
>
> Currently this timer driver provides timer_get_boot_us() to support the
> BOOTSTAGE functionality. This patch adds the timer_early functions so
> that the "normal" timer functions can be used, when CONFIG_TIMER_EARLY
> is enabled.
>
> timer_get_boot_us() will get removed in a follow-up patch, once the
> BOOTSTAGE interface is migrated to timer_get_us().
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jun Nie <jun.nie@linaro.org>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  arch/arm/mach-imx/syscounter.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c
index df478a232637..dbe55ee3913d 100644
--- a/arch/arm/mach-imx/syscounter.c
+++ b/arch/arm/mach-imx/syscounter.c
@@ -109,6 +109,22 @@  ulong timer_get_boot_us(void)
 	return tick_to_time(get_ticks());
 }
 
+unsigned long notrace timer_early_get_rate(void)
+{
+	if (!gd->arch.timer_rate_hz)
+		timer_init();
+
+	return gd->arch.timer_rate_hz;
+}
+
+u64 notrace timer_early_get_count(void)
+{
+	if (!gd->arch.timer_rate_hz)
+		timer_init();
+
+	return get_ticks();
+}
+
 void __udelay(unsigned long usec)
 {
 	unsigned long long tmp;