]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
timer: orion-timer: Fix problem with early static variable
authorStefan Roese <sr@denx.de>
Wed, 21 Dec 2022 09:18:49 +0000 (10:18 +0100)
committerStefan Roese <sr@denx.de>
Mon, 2 Jan 2023 08:14:16 +0000 (09:14 +0100)
We've noticed that at least one Kirkwood board (Pogo v4) has problems
with the new orion DM timer implementation. Debugging revealed that this
issue is related with the static variable "early_init_done" which does
not work correctly before relocation in all cases.

This patch removes this static variable and replaces it's functionality
via a function that detects if the timer is already initialized.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Pali Rohár <pali@kernel.org>
Cc: Michael Walle <michael@walle.cc>
Cc: Tony Dinh <mibodhi@gmail.com>
Tested-by: Tony Dinh <mibodhi@gmail.com>
drivers/timer/orion-timer.c

index d0eab3ce781dc6dac06c71c57144aaf57cdf1353..6804bf0fa2cb302a128c85c33e67fe5a9ae585b1 100644 (file)
@@ -23,15 +23,19 @@ struct orion_timer_priv {
 
 #define MVEBU_TIMER_FIXED_RATE_25MHZ   25000000
 
-static bool early_init_done __section(".data") = false;
+static bool early_init_done(void *base)
+{
+       if (readl(base + TIMER_CTRL) & TIMER0_EN)
+               return true;
+       return false;
+}
 
 /* Common functions for early (boot) and DM based timer */
 static void orion_timer_init(void *base, enum input_clock_type type)
 {
        /* Only init the timer once */
-       if (early_init_done)
+       if (early_init_done(base))
                return;
-       early_init_done = true;
 
        writel(~0, base + TIMER0_VAL);
        writel(~0, base + TIMER0_RELOAD);