Skip to contentSkip to conversation

imx: syscounter: support timer_get_boot_us

PATCH In review Jun Nie 4 participants 4 messages Jul 21, 2022 – Jul 26, 2022

Subsystems (3)
lore
Share & tools
lore

Jun Nie

author
#0 lore raw

PATCH 1/1 imx: syscounter: support timer_get_boot_us

With supporting timer_get_boot_us, we can profile boot up time with below configs and function bootstage_mark_name().

CONFIG_BOOTSTAGE=y
CONFIG_BOOTSTAGE_REPORT=y
CONFIG_CMD_BOOTSTAGE=y

---
 arch/arm/mach-imx/syscounter.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/mach-imx/syscounter.c +9 -0
index 7c02e199a3..df478a2326 100644
@@ -79,6 +79,7 @@ int timer_init(void)
 	gd->arch.tbl = 0;
 	gd->arch.tbu = 0;
 
+	gd->arch.timer_rate_hz = freq;
 	return 0;
 }
 #endif
@@ -100,6 +101,14 @@ ulong get_timer(ulong base)
 	return tick_to_time(get_ticks()) - base;
 }
 
+ulong timer_get_boot_us(void)
+{
+	if (!gd->arch.timer_rate_hz)
+		timer_init();
+
+	return tick_to_time(get_ticks());
+}
+
 void __udelay(unsigned long usec)
 {
 	unsigned long long tmp;
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jun Nie

With supporting timer_get_boot_us, we can profile boot up time with below configs and function bootstage_mark_name().

CONFIG_BOOTSTAGE=y
CONFIG_BOOTSTAGE_REPORT=y
CONFIG_CMD_BOOTSTAGE=y

FWIW, it also fixes boot failure when bootstage is enabled.

Shawn

Quoted 34 lines
---
 arch/arm/mach-imx/syscounter.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/mach-imx/syscounter.c +9 -1
index 7c02e199a3..df478a2326 100644
@@ -79,6 +79,7 @@ int timer_init(void)
        gd->arch.tbl = 0;
        gd->arch.tbu = 0;
 
+       gd->arch.timer_rate_hz = freq;
        return 0;
 }
 #endif
@@ -100,6 +101,14 @@ ulong get_timer(ulong base)
        return tick_to_time(get_ticks()) - base;
 }
 
+ulong timer_get_boot_us(void)
+{
+       if (!gd->arch.timer_rate_hz)
+               timer_init();
+
+       return tick_to_time(get_ticks());
+}
+
 void __udelay(unsigned long usec)
 {
        unsigned long long tmp;
--

2.25.1

#3 lore raw

PATCH 1/1 imx: syscounter: support timer_get_boot_us

In reply to Jun Nie
Quoted 8 lines

With supporting timer_get_boot_us, we can profile boot up time with below configs and function bootstage_mark_name(). CONFIG_BOOTSTAGE=y
CONFIG_BOOTSTAGE_REPORT=y
CONFIG_CMD_BOOTSTAGE=y

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================