[PATCH v2 23/32] bsp/leon3: Add LEON3_PROBE_ASR_22_23_UP_COUNTER

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 16 06:01:20 UTC 2023


---
 bsps/sparc/leon3/clock/ckinit.c               |  5 +++++
 bsps/sparc/leon3/start/cpucounter.c           |  5 +++++
 spec/build/bsps/sparc/leon3/grp.yml           |  2 ++
 .../bsps/sparc/leon3/optasrupcntprobe.yml     | 19 +++++++++++++++++++
 4 files changed, 31 insertions(+)
 create mode 100644 spec/build/bsps/sparc/leon3/optasrupcntprobe.yml

diff --git a/bsps/sparc/leon3/clock/ckinit.c b/bsps/sparc/leon3/clock/ckinit.c
index 0c8a0a8754..93826416c0 100644
--- a/bsps/sparc/leon3/clock/ckinit.c
+++ b/bsps/sparc/leon3/clock/ckinit.c
@@ -183,6 +183,8 @@ static void bsp_clock_handler_install(rtems_interrupt_handler isr)
 #define Clock_driver_support_set_interrupt_affinity(online_processors) \
   bsp_interrupt_set_affinity(clkirq, online_processors)
 
+#if defined(LEON3_HAS_ASR_22_23_UP_COUNTER) || \
+   defined(LEON3_PROBE_ASR_22_23_UP_COUNTER)
 static void leon3_clock_use_up_counter(struct timecounter *tc)
 {
   tc->tc_get_timecount = _SPARC_Get_timecount_asr23;
@@ -198,6 +200,7 @@ static void leon3_clock_use_up_counter(struct timecounter *tc)
 
   rtems_timecounter_install(tc);
 }
+#endif
 
 #if defined(LEON3_IRQAMP_PROBE_TIMESTAMP)
 static void leon3_clock_use_irqamp_timestamp(
@@ -289,11 +292,13 @@ static void leon3_clock_initialize(void)
 #if defined(LEON3_HAS_ASR_22_23_UP_COUNTER)
   leon3_clock_use_up_counter(tc);
 #else /* LEON3_HAS_ASR_22_23_UP_COUNTER */
+#if defined(LEON3_PROBE_ASR_22_23_UP_COUNTER)
   if (leon3_up_counter_is_available()) {
     /* Use the LEON4 up-counter if available */
     leon3_clock_use_up_counter(tc);
     return;
   }
+#endif
 
 #if defined(LEON3_IRQAMP_PROBE_TIMESTAMP)
   irqmp_ts = irqamp_get_timestamp_registers(LEON3_IrqCtrl_Regs);
diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c
index d09dbe651b..46e0b304e5 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -39,6 +39,8 @@ uint32_t _CPU_Counter_frequency(void)
   return leon3_counter_frequency;
 }
 
+#if defined(LEON3_HAS_ASR_22_23_UP_COUNTER) || \
+   defined(LEON3_PROBE_ASR_22_23_UP_COUNTER)
 static void leon3_counter_use_up_counter(SPARC_Counter *counter)
 {
   counter->read_isr_disabled = _SPARC_Counter_read_asr23;
@@ -46,6 +48,7 @@ static void leon3_counter_use_up_counter(SPARC_Counter *counter)
 
   leon3_counter_frequency = leon3_up_counter_frequency();
 }
+#endif
 
 #if defined(LEON3_IRQAMP_PROBE_TIMESTAMP)
 static void leon3_counter_use_irqamp_timestamp(
@@ -108,11 +111,13 @@ static void leon3_counter_initialize(void)
 #if defined(LEON3_HAS_ASR_22_23_UP_COUNTER)
   leon3_counter_use_up_counter(counter);
 #else /* LEON3_HAS_ASR_22_23_UP_COUNTER */
+#if defined(LEON3_PROBE_ASR_22_23_UP_COUNTER)
   if (leon3_up_counter_is_available()) {
     /* Use the LEON4 up-counter if available */
     leon3_counter_use_up_counter(counter);
     return;
   }
+#endif
 
 #if defined(LEON3_IRQAMP_PROBE_TIMESTAMP)
   irqmp_ts = irqamp_get_timestamp_registers(LEON3_IrqCtrl_Regs);
diff --git a/spec/build/bsps/sparc/leon3/grp.yml b/spec/build/bsps/sparc/leon3/grp.yml
index 6d7a1b75c3..94d11bed55 100644
--- a/spec/build/bsps/sparc/leon3/grp.yml
+++ b/spec/build/bsps/sparc/leon3/grp.yml
@@ -36,6 +36,8 @@ links:
   uid: optapbuartbase
 - role: build-dependency
   uid: optasrupcnt
+- role: build-dependency
+  uid: optasrupcntprobe
 - role: build-dependency
   uid: optgptimerbase
 - role: build-dependency
diff --git a/spec/build/bsps/sparc/leon3/optasrupcntprobe.yml b/spec/build/bsps/sparc/leon3/optasrupcntprobe.yml
new file mode 100644
index 0000000000..73c9cb6685
--- /dev/null
+++ b/spec/build/bsps/sparc/leon3/optasrupcntprobe.yml
@@ -0,0 +1,19 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH & Co. KG
+actions:
+- get-boolean: null
+- define-condition: null
+build-type: option
+default:
+- enabled-by:
+  - sparc/gr712rc
+  - sparc/gr740
+  value: false
+enabled-by: true
+links: []
+name: LEON3_PROBE_ASR_22_23_UP_COUNTER
+description: |
+  If this option is set to true, then it will be probed if the %asr22 and
+  %asr23 up-counter is available.
+type: build
-- 
2.35.3



More information about the devel mailing list