[PATCH 08/10] board_f/r: Don't call timer_init() when TIMER is enabled

Stefan Roese sr at denx.de
Wed Sep 21 16:06:23 CEST 2022


The timer initialization is done implicitly when CONFIG_TIMER is
enabled. There is no need to re-configure the timer again. Even worse,
another call to the timer init function may lead to a re-init of the
counter register and therefore non consecutive timer values.

This patch makes sure, that timer_init() is not called in case that
CONFIG_TIMER is configured.

Signed-off-by: Stefan Roese <sr at denx.de>
---
 common/board_f.c | 2 +-
 common/board_r.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index b1f67bfa72aa..fbc5d3e9d205 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -851,7 +851,7 @@ static const init_fnc_t init_sequence_f[] = {
 	/* get CPU and bus clocks according to the environment variable */
 	get_clocks,		/* get CPU and bus clocks (etc.) */
 #endif
-#if !defined(CONFIG_M68K)
+#if !defined(CONFIG_M68K) && !IS_ENABLED(CONFIG_TIMER)
 	timer_init,		/* initialize timer */
 #endif
 #if defined(CONFIG_BOARD_POSTCLK_INIT)
diff --git a/common/board_r.c b/common/board_r.c
index 56575e552df8..149cfdc3d351 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -745,7 +745,8 @@ static init_fnc_t init_sequence_r[] = {
 	kgdb_init,
 #endif
 	interrupt_init,
-#if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)
+#if (defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)) && \
+	!IS_ENABLED(CONFIG_TIMER)
 	timer_init,		/* initialize timer */
 #endif
 #if defined(CONFIG_LED_STATUS)
-- 
2.37.3



More information about the U-Boot mailing list