bsps/leon3: Fix AMBA frequency initialization

Where LEON3_GPTIMER_BASE was defined, the finding and initialization of
the timer devices was disabled.  However, this code block has an
important side-effect.  It initializes all frequencies of the device
tree.  Make sure this part is done even if a dynamic initialization of
LEON3_Timer_Adev and LEON3_Timer_Regs is not required.

Close #5541.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This commit is contained in:
Sebastian Huber
2026-04-02 18:11:19 -05:00
committed by Joel Sherrill
parent 1fc01a4393
commit 810b2d50c9
+11 -7
View File
@@ -49,9 +49,10 @@
#if !defined(LEON3_GPTIMER_BASE)
unsigned int leon3_timer_prescaler __attribute__((weak)) = 0;
int leon3_timer_core_index __attribute__((weak)) = 0;
#endif
int leon3_timer_core_index __attribute__((weak)) = 0;
/* AMBA Plug&Play information description.
*
* After software has scanned AMBA PnP it builds a tree to make
@@ -195,22 +196,22 @@ static void amba_initialize(void)
}
#endif
#if !defined(LEON3_GPTIMER_BASE)
/* find GP Timer */
adev = (void *)ambapp_for_each(plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
VENDOR_GAISLER, GAISLER_GPTIMER,
ambapp_find_by_idx, &leon3_timer_core_index);
if (adev) {
LEON3_Timer_Regs = (gptimer *)DEV_TO_APB(adev)->start;
LEON3_Timer_Adev = adev;
gptimer *timer_regs = (gptimer *)DEV_TO_APB(adev)->start;
/* Register AMBA Bus Frequency */
ambapp_freq_init(
plb,
LEON3_Timer_Adev,
(grlib_load_32(&LEON3_Timer_Regs->sreload) + 1)
adev,
(grlib_load_32(&timer_regs->sreload) + 1)
* LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER
);
#if !defined(LEON3_GPTIMER_BASE)
/* Set user prescaler configuration. Use this to increase accuracy of timer
* and accociated services like cpucounter.
* Note that minimum value is the number of timer instances present in
@@ -218,8 +219,11 @@ static void amba_initialize(void)
*/
if (leon3_timer_prescaler)
grlib_store_32(&LEON3_Timer_Regs->sreload, leon3_timer_prescaler);
}
LEON3_Timer_Regs = (gptimer *)DEV_TO_APB(adev)->start;
LEON3_Timer_Adev = adev;
#endif
}
}
RTEMS_SYSINIT_ITEM(