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>2022-09-09 09:12:40 +0200
commit31a8a0d35d15fb51057c741893fbf83db8491678 (patch)
tree927c6d8fc4f043b3553e0dfe2764b2972e4378e2
parenta1bc573160adc08e1804ba95b86715587cded586 (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 99c8873c00..f72b38685b 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -360,51 +360,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