summaryrefslogtreecommitdiffstats
path: root/bsps/sparc/leon3/include/bsp
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-19 10:52:20 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-07-14 12:21:33 +0200
commitac9c55b01766b0998beba9a20d446461429c4c9e (patch)
tree0055f7b28f1770ff180f6e1f252756b5320911e5 /bsps/sparc/leon3/include/bsp
parentbsp/leon3: Add LEON3_APBUART_BASE (diff)
downloadrtems-ac9c55b01766b0998beba9a20d446461429c4c9e.tar.bz2
bsp/leon3: LEON3_PLB_FREQUENCY_DEFINED_BY_GPTIMER
Diffstat (limited to 'bsps/sparc/leon3/include/bsp')
-rw-r--r--bsps/sparc/leon3/include/bsp/leon3.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h
index 1402dfca1b..599d616aaf 100644
--- a/bsps/sparc/leon3/include/bsp/leon3.h
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -42,7 +42,9 @@
#include <bspopts.h>
#include <bsp/irqimpl.h>
+#if !defined(LEON3_PLB_FREQUENCY_DEFINED_BY_GPTIMER)
#include <grlib/ambapp.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -195,6 +197,25 @@ extern gptimer *LEON3_Timer_Regs;
extern struct ambapp_dev *LEON3_Timer_Adev;
/**
+ * @brief Gets the processor local bus frequency in Hz.
+ *
+ * @return Returns the frequency.
+ */
+static inline uint32_t leon3_processor_local_bus_frequency( void )
+{
+#if defined(LEON3_PLB_FREQUENCY_DEFINED_BY_GPTIMER)
+ return ( grlib_load_32( &LEON3_Timer_Regs->sreload ) + 1 ) *
+ LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER;
+#else
+ /*
+ * For simplicity, assume that the interrupt controller uses the processor
+ * clock. This is at least true on the GR740.
+ */
+ return ambapp_freq_get( ambapp_plb(), LEON3_IrqCtrl_Adev );
+#endif
+}
+
+/**
* @brief Gets the LEON up-counter low register (%ASR23) value.
*
* @return Returns the register value.
@@ -257,11 +278,7 @@ static inline bool leon3_up_counter_is_available( void )
*/
static inline uint32_t leon3_up_counter_frequency( void )
{
- /*
- * For simplicity, assume that the interrupt controller uses the processor
- * clock. This is at least true on the GR740.
- */
- return ambapp_freq_get( ambapp_plb(), LEON3_IrqCtrl_Adev );
+ return leon3_processor_local_bus_frequency();
}
/**