[rtems commit] leon: restart and load timer counter at initialization

Daniel Hellstrom danielh at rtems.org
Sun Mar 7 15:56:14 UTC 2021


Module:    rtems
Branch:    5
Commit:    cb8379dc0915c10960a0923a9869e98869e410bd
Changeset: http://git.rtems.org/rtems/commit/?id=cb8379dc0915c10960a0923a9869e98869e410bd

Author:    Daniel Hellstrom <daniel at gaisler.com>
Date:      Tue Oct 29 15:17:57 2019 +0100

leon: restart and load timer counter at initialization

Without this smp05 and smpthreadlife01 tests may fail
depending on how the boot loader initialized the GPTIMER.
Before the time counter stopped counting when reaching
zero, but tests could work since it could take 2^32 us
before stopping.

The timer driver will potentially overwrite this, but it
happens later due to the initialization order having
RTEMS_SYSINIT_CPU_COUNTER very early.

Update #4312.

---

 bsps/sparc/leon3/start/cpucounter.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c
index 007bb6d..4a0a5fe 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -60,7 +60,10 @@ static void leon3_counter_initialize(void)
     counter->counter_register = &gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].value;
 
     /* Enable timer just in case no clock driver is configured */
-    gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].ctrl |= GPTIMER_TIMER_CTRL_EN;
+    gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].reload = 0xffffffff;
+    gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].ctrl |= GPTIMER_TIMER_CTRL_EN |
+                                                    GPTIMER_TIMER_CTRL_RS |
+                                                    GPTIMER_TIMER_CTRL_LD;
 
     leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev) /
       (gpt->scaler_reload + 1);



More information about the vc mailing list