[PATCH] grlib: Add and use irqmp_has_timestamp()

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Oct 8 05:51:55 UTC 2020


Replace leon3_irqmp_has_timestamp() with irqmp_has_timestamp() and move
it to grlib.h.

Close #4128.
---
 bsps/riscv/griscv/clock/clockdrv.c     | 2 +-
 bsps/shared/grlib/btimer/tlib_ckinit.c | 2 +-
 bsps/sparc/leon3/clock/ckinit.c        | 4 ++--
 bsps/sparc/leon3/include/leon.h        | 7 -------
 bsps/sparc/leon3/start/cpucounter.c    | 2 +-
 5 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/bsps/riscv/griscv/clock/clockdrv.c b/bsps/riscv/griscv/clock/clockdrv.c
index c94c167fdf..4cf15fe4f8 100644
--- a/bsps/riscv/griscv/clock/clockdrv.c
+++ b/bsps/riscv/griscv/clock/clockdrv.c
@@ -171,7 +171,7 @@ static void grlib_clock_initialize(void)
   volatile struct irqmp_timestamp_regs *irqmp_ts =
     &GRLIB_IrqCtrl_Regs->timestamp[0];
 
-    if (!grlib_irqmp_has_timestamp(irqmp_ts)) {
+    if (!irqmp_has_timestamp(irqmp_ts)) {
       bsp_fatal(GRLIB_FATAL_CLOCK_NO_IRQMP_TIMESTAMP_SUPPORT);
     }
 #endif
diff --git a/bsps/shared/grlib/btimer/tlib_ckinit.c b/bsps/shared/grlib/btimer/tlib_ckinit.c
index 4f679984d8..5a34d97c00 100644
--- a/bsps/shared/grlib/btimer/tlib_ckinit.c
+++ b/bsps/shared/grlib/btimer/tlib_ckinit.c
@@ -126,7 +126,7 @@ static rtems_device_driver tlib_clock_find_timer(void)
     volatile struct irqmp_timestamp_regs *irqmp_ts;
 
     irqmp_ts = &LEON3_IrqCtrl_Regs->timestamp[0];
-    if (leon3_irqmp_has_timestamp(irqmp_ts)) {
+    if (irqmp_has_timestamp(irqmp_ts)) {
       priv.ops = &ops_irqamp;
       return RTEMS_SUCCESSFUL;
     }
diff --git a/bsps/sparc/leon3/clock/ckinit.c b/bsps/sparc/leon3/clock/ckinit.c
index f485123f6b..bf0c506ec0 100644
--- a/bsps/sparc/leon3/clock/ckinit.c
+++ b/bsps/sparc/leon3/clock/ckinit.c
@@ -176,13 +176,13 @@ static void leon3_clock_initialize(void)
     tc->tc_frequency = leon3_up_counter_frequency();
 
 #ifdef RTEMS_PROFILING
-    if (!leon3_irqmp_has_timestamp(irqmp_ts)) {
+    if (!irqmp_has_timestamp(irqmp_ts)) {
       bsp_fatal(LEON3_FATAL_CLOCK_NO_IRQMP_TIMESTAMP_SUPPORT);
     }
 #endif
 
     leon3_tc_tick = leon3_tc_tick_irqmp_timestamp_init;
-  } else if (leon3_irqmp_has_timestamp(irqmp_ts)) {
+  } else if (irqmp_has_timestamp(irqmp_ts)) {
     /* Use the interrupt controller timestamp counter if available */
     tc->tc_get_timecount = _SPARC_Get_timecount_up;
     tc->tc_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev);
diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
index afe0d91ca4..d25825c8e8 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -454,13 +454,6 @@ static inline uint32_t leon3_get_data_cache_config_register(void)
   return leon3_get_system_register(0xc);
 }
 
-static inline bool leon3_irqmp_has_timestamp(
-  volatile struct irqmp_timestamp_regs *irqmp_ts
-)
-{
-  return (irqmp_ts->control >> 27) > 0;
-}
-
 static inline uint32_t leon3_up_counter_low(void)
 {
   uint32_t asr23;
diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c
index 007bb6d8ec..1d96e3b221 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -43,7 +43,7 @@ static void leon3_counter_initialize(void)
     counter->read = _SPARC_Counter_read_asr23;
 
     leon3_counter_frequency = leon3_up_counter_frequency();
-  } else if (leon3_irqmp_has_timestamp(irqmp_ts)) {
+  } else if (irqmp_has_timestamp(irqmp_ts)) {
     /* Use the interrupt controller timestamp counter if available */
     counter->read_isr_disabled = _SPARC_Counter_read_up;
     counter->read = _SPARC_Counter_read_up;
-- 
2.26.2



More information about the devel mailing list