diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-21 08:34:33 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-05-18 11:36:06 +0200 |
commit | 7af159bcb912a9b116f7dbb4f16f948c4c003a50 (patch) | |
tree | 71c33becb74aa41519f7aff5ec6a99bc2a2c0ccf | |
parent | 77984bfbc22d36e698a51676096c0bb9bb005da7 (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.h | 72 | ||||
-rw-r--r-- | bsps/sparc/leon3/include/leon.h | 45 |
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 |