summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-21 08:34:33 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-01-03 15:43:45 +0100
commit7e05bdc30eb67452580e4c785c49f5e16d7db71a (patch)
treeec16e3c84a0eaaba59322e8c5248939a13bdcf44
parent2bb4781b76611ce267004aad1dcb0146aaabb5d2 (diff)
bsp/leon3: Move up-counter support
Move, document, and reformat support functions from <leon.h> to <bsp/leon3.h>.
-rw-r--r--bsps/sparc/leon3/include/bsp/leon3.h72
-rw-r--r--bsps/sparc/leon3/include/leon.h45
2 files changed, 72 insertions, 45 deletions
diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h
index daa3f43591..2fc11d9a3e 100644
--- a/bsps/sparc/leon3/include/bsp/leon3.h
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -41,6 +41,8 @@
#include <grlib/irqamp-regs.h>
#include <grlib/io.h>
+#include <grlib/ambapp.h>
+
struct ambapp_dev;
#ifdef __cplusplus
@@ -232,6 +234,76 @@ static inline uint32_t bsp_irq_fixup( uint32_t irq )
}
/**
+ * @brief Gets the LEON up-counter low register (%ASR23) value.
+ *
+ * @return Returns the register value.
+ */
+static inline uint32_t leon3_up_counter_low( void )
+{
+ uint32_t asr23;
+
+ __asm__ volatile (
+ "mov %%asr23, %0"
+ : "=&r" (asr23)
+ );
+
+ return asr23;
+}
+
+/**
+ * @brief Gets the LEON up-counter high register (%ASR22) value.
+ *
+ * @return Returns the register value.
+ */
+static inline uint32_t leon3_up_counter_high(void)
+{
+ uint32_t asr22;
+
+ __asm__ volatile (
+ "mov %%asr22, %0"
+ : "=&r" (asr22)
+ );
+
+ return asr22;
+}
+
+/**
+ * @brief Enables the LEON up-counter.
+ */
+static inline void leon3_up_counter_enable( void )
+{
+ __asm__ volatile (
+ "mov %g0, %asr22"
+ );
+}
+
+/**
+ * @brief Checks if the LEON up-counter is available.
+ *
+ * The LEON up-counter must have been enabled.
+ *
+ * @return Returns true, if the LEON up-counter is available, otherwise false.
+ */
+static inline bool leon3_up_counter_is_available( void )
+{
+ return leon3_up_counter_low() != leon3_up_counter_low();
+}
+
+/**
+ * @brief Gets the LEON up-counter frequency in Hz.
+ *
+ * @return Returns the frequency.
+ */
+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 );
+}
+
+/**
* @brief This pointer provides the debug APBUART register block address.
*/
extern apbuart *leon3_debug_uart;
diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
index 2856f71816..6fe499989d 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -379,51 +379,6 @@ extern unsigned int leon3_timer_prescaler;
RTEMS_NO_RETURN void leon3_power_down_loop(void);
-static inline uint32_t leon3_up_counter_low(void)
-{
- uint32_t asr23;
-
- __asm__ volatile (
- "mov %%asr23, %0"
- : "=&r" (asr23)
- );
-
- return asr23;
-}
-
-static inline uint32_t leon3_up_counter_high(void)
-{
- uint32_t asr22;
-
- __asm__ volatile (
- "mov %%asr22, %0"
- : "=&r" (asr22)
- );
-
- return asr22;
-}
-
-static inline void leon3_up_counter_enable(void)
-{
- __asm__ volatile (
- "mov %g0, %asr22"
- );
-}
-
-static inline bool leon3_up_counter_is_available(void)
-{
- return leon3_up_counter_low() != leon3_up_counter_low();
-}
-
-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);
-}
-
#endif /* !ASM */
#ifdef __cplusplus