[PATCH 2/7] grlib: Add ambapp_plb()

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jun 10 13:24:01 UTC 2021


Replace the global variable ambapp_plb with a function to allow an automatic on
demand initialization.
---
 bsps/include/grlib/ambapp.h                |  5 ++
 bsps/include/grlib/grlib_impl.h            |  2 -
 bsps/riscv/griscv/console/console.c        |  4 +-
 bsps/riscv/griscv/console/printk_support.c |  2 +-
 bsps/riscv/griscv/include/amba.h           |  5 +-
 bsps/riscv/griscv/start/amba.c             |  6 +-
 bsps/riscv/griscv/start/bspstart.c         | 24 ++++++--
 bsps/shared/grlib/ascs/grascs.c            |  4 +-
 bsps/shared/grlib/can/canmux.c             |  2 +-
 bsps/shared/grlib/can/satcan.c             |  2 +-
 bsps/shared/grlib/slink/grslink.c          |  4 +-
 bsps/sparc/leon3/clock/ckinit.c            |  2 +-
 bsps/sparc/leon3/console/console.c         |  4 +-
 bsps/sparc/leon3/console/printk_support.c  |  2 +-
 bsps/sparc/leon3/include/amba.h            | 11 ----
 bsps/sparc/leon3/include/leon.h            |  2 +-
 bsps/sparc/leon3/start/amba.c              | 72 ++++++++++++++++------
 bsps/sparc/leon3/start/cache.c             |  2 +-
 bsps/sparc/leon3/start/cpucounter.c        |  4 +-
 19 files changed, 96 insertions(+), 63 deletions(-)

diff --git a/bsps/include/grlib/ambapp.h b/bsps/include/grlib/ambapp.h
index 12911a6a3d..62d6a51930 100644
--- a/bsps/include/grlib/ambapp.h
+++ b/bsps/include/grlib/ambapp.h
@@ -188,6 +188,11 @@ struct ambapp_context {
   void *(*alloc)(size_t);
 };
 
+/**
+ * @brief Gets the fully scanned AMBA Plug & Play Processor Local Bus (PLB).
+ */
+extern struct ambapp_bus *ambapp_plb(void);
+
 /* Scan a AMBA Plug & Play bus and create all device structures describing the 
  * the devices. The devices will form a tree, where every node describes one
  * interface. The resulting tree is placed in the location pointed to by root.
diff --git a/bsps/include/grlib/grlib_impl.h b/bsps/include/grlib/grlib_impl.h
index 3bff2af0da..919f6d69ab 100644
--- a/bsps/include/grlib/grlib_impl.h
+++ b/bsps/include/grlib/grlib_impl.h
@@ -157,8 +157,6 @@ RTEMS_INLINE_ROUTINE unsigned int grlib_read_uncached32(unsigned int address)
 
 #endif
 
-extern struct ambapp_bus ambapp_plb;
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/bsps/riscv/griscv/console/console.c b/bsps/riscv/griscv/console/console.c
index c92be99fdb..c0e19cddfe 100644
--- a/bsps/riscv/griscv/console/console.c
+++ b/bsps/riscv/griscv/console/console.c
@@ -68,7 +68,7 @@ static int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
   /* Get APBUART core frequency, it is assumed that it is the same
    * as Bus frequency where the UART is situated
    */
-  apbuarts[uarts].freq_hz = ambapp_freq_get(&ambapp_plb, dev);
+  apbuarts[uarts].freq_hz = ambapp_freq_get(ambapp_plb(), dev);
   uarts++;
 
   if (uarts >= BSP_NUMBER_OF_TERMIOS_PORTS)
@@ -83,7 +83,7 @@ static void grlib_console_scan_uarts(void)
   memset(apbuarts, 0, sizeof(apbuarts));
 
   /* Find APBUART cores */
-  ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER,
+  ambapp_for_each(ambapp_plb(), (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER,
                   GAISLER_APBUART, find_matching_apbuart, NULL);
 }
 
diff --git a/bsps/riscv/griscv/console/printk_support.c b/bsps/riscv/griscv/console/printk_support.c
index f8c14692c1..e789924e4f 100644
--- a/bsps/riscv/griscv/console/printk_support.c
+++ b/bsps/riscv/griscv/console/printk_support.c
@@ -64,7 +64,7 @@ static void bsp_debug_uart_init(void)
 
   /* Find APBUART core for System Debug Console */
   i = grlib_debug_uart_index;
-  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+  adev = (void *)ambapp_for_each(ambapp_plb(), (OPTIONS_ALL|OPTIONS_APB_SLVS),
                                  VENDOR_GAISLER, GAISLER_APBUART,
                                  ambapp_find_by_idx, (void *)&i);
   if (adev) {
diff --git a/bsps/riscv/griscv/include/amba.h b/bsps/riscv/griscv/include/amba.h
index 8833cdfba6..292660d5c1 100644
--- a/bsps/riscv/griscv/include/amba.h
+++ b/bsps/riscv/griscv/include/amba.h
@@ -69,9 +69,6 @@
 extern "C" {
 #endif
 
-/* The AMBA Plug&Play info of the bus that the cpu sits on */
-extern struct ambapp_bus ambapp_plb;
-
 extern uint32_t GRLIB_Cpu_Index;
 extern const unsigned char GRLIB_mp_irq;
 
@@ -89,7 +86,7 @@ static inline uint32_t grlib_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, GRLIB_IrqCtrl_Adev);
+  return ambapp_freq_get(ambapp_plb(), GRLIB_IrqCtrl_Adev);
 }
 
 extern rtems_interrupt_lock GRLIB_IrqCtrl_Lock;
diff --git a/bsps/riscv/griscv/start/amba.c b/bsps/riscv/griscv/start/amba.c
index 182f659d69..ffb609dc38 100644
--- a/bsps/riscv/griscv/start/amba.c
+++ b/bsps/riscv/griscv/start/amba.c
@@ -42,7 +42,7 @@ void irqmp_initialize(void)
   struct ambapp_dev *adev;
 
   /* Find GRLIB Interrupt controller */
-  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+  adev = (void *)ambapp_for_each(ambapp_plb(), (OPTIONS_ALL|OPTIONS_APB_SLVS),
                                  VENDOR_GAISLER, GAISLER_IRQMP,
                                  ambapp_find_by_idx, NULL);
   if (adev != NULL) {
@@ -89,7 +89,7 @@ void gptimer_initialize(void)
   struct ambapp_dev *adev;
 
   /* find GP Timer */
-  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+  adev = (void *)ambapp_for_each(ambapp_plb(), (OPTIONS_ALL|OPTIONS_APB_SLVS),
                                  VENDOR_GAISLER, GAISLER_GPTIMER,
                                  ambapp_find_by_idx, &grlib_timer_core_index);
   if (adev) {
@@ -98,7 +98,7 @@ void gptimer_initialize(void)
 
     /* Register AMBA Bus Frequency */
     ambapp_freq_init(
-      &ambapp_plb,
+      ambapp_plb(),
       GRLIB_Timer_Adev,
       (GRLIB_Timer_Regs->scaler_reload + 1)
         * GRLIB_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER
diff --git a/bsps/riscv/griscv/start/bspstart.c b/bsps/riscv/griscv/start/bspstart.c
index dd83c80818..26c214caac 100644
--- a/bsps/riscv/griscv/start/bspstart.c
+++ b/bsps/riscv/griscv/start/bspstart.c
@@ -53,14 +53,26 @@ void bsp_start(void)
 #endif
 }
 
-void amba_initialize(void);
-struct ambapp_bus ambapp_plb;
+static struct ambapp_bus ambapp_plb_instance;
 
-void amba_initialize(void)
+struct ambapp_bus *ambapp_plb( void )
 {
-  ambapp_scan(&ambapp_plb, GRLIB_IO_AREA, NULL, NULL);
-  gptimer_initialize();
-  irqmp_initialize();
+  struct ambapp_bus *plb;
+
+  plb = &ambapp_plb_instance;
+
+  if ( plb->root == NULL ) {
+    ambapp_scan( plb, GRLIB_IO_AREA, NULL, NULL );
+    gptimer_initialize();
+    irqmp_initialize();
+  }
+
+  return plb;
+}
+
+static void amba_initialize( void )
+{
+  (void) ambapp_plb();
 }
 
 RTEMS_SYSINIT_ITEM(
diff --git a/bsps/shared/grlib/ascs/grascs.c b/bsps/shared/grlib/ascs/grascs.c
index 200cf67409..0e4a2ba868 100644
--- a/bsps/shared/grlib/ascs/grascs.c
+++ b/bsps/shared/grlib/ascs/grascs.c
@@ -72,7 +72,7 @@ static int ASCS_get_addr(int *base, int *irq) {
 
   struct ambapp_apb_info core;
   
-  if(ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_ASCS, &core) == 1) {
+  if(ambapp_find_apbslv(ambapp_plb(), VENDOR_GAISLER, GAISLER_ASCS, &core) == 1) {
     *base = core.start;
     *irq = core.common.irq;
     DBG("ASCS_get_addr: Registerd ASCS core at 0x%x with irq %i\n",core.start, core.irq);
@@ -108,7 +108,7 @@ static int ASCS_get_sysfreq(void) {
   struct gptimer_regs *tregs;
   int tmp;
 
-  if(ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_GPTIMER, &gpt) == 1) {
+  if(ambapp_find_apbslv(ambapp_plb(), VENDOR_GAISLER, GAISLER_GPTIMER, &gpt) == 1) {
     tregs = (struct gptimer_regs *) gpt.start;
     tmp = (tregs->scaler_reload + 1)*1000;
     DBG("ASCS_get_sysfreq: Detected system frequency %i kHz\n",tmp);
diff --git a/bsps/shared/grlib/can/canmux.c b/bsps/shared/grlib/can/canmux.c
index 369cb3dd0a..631b9d941a 100644
--- a/bsps/shared/grlib/can/canmux.c
+++ b/bsps/shared/grlib/can/canmux.c
@@ -132,7 +132,7 @@ static rtems_device_driver canmux_initialize(rtems_device_major_number major, rt
 	strcpy(fs_name, CANMUX_DEVNAME);
 	
 	/* Find core and initialize register pointer */
-	if (!ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_CANMUX, &d)) {
+	if (!ambapp_find_apbslv(ambapp_plb(), VENDOR_GAISLER, GAISLER_CANMUX, &d)) {
 		printk("CAN_MUX: Failed to find CAN_MUX core\n\r");
 		return -1;
 	}
diff --git a/bsps/shared/grlib/can/satcan.c b/bsps/shared/grlib/can/satcan.c
index 52e674cb04..a94d570955 100644
--- a/bsps/shared/grlib/can/satcan.c
+++ b/bsps/shared/grlib/can/satcan.c
@@ -585,7 +585,7 @@ static rtems_device_driver satcan_initialize(rtems_device_major_number major, rt
 	strcpy(fs_name, SATCAN_DEVNAME);
 
 	/* Find core and initialize register pointer */
-	if (!ambapp_find_ahbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_SATCAN, &d)) {
+	if (!ambapp_find_ahbslv(ambapp_plb(), VENDOR_GAISLER, GAISLER_SATCAN, &d)) {
 		printk("SatCAN: Failed to find SatCAN core\n\r");
 		return -1;
 	}
diff --git a/bsps/shared/grlib/slink/grslink.c b/bsps/shared/grlib/slink/grslink.c
index 3ed3e3c370..7c1eb8e290 100644
--- a/bsps/shared/grlib/slink/grslink.c
+++ b/bsps/shared/grlib/slink/grslink.c
@@ -181,7 +181,7 @@ static int SLINK_getaddr(int *base, int *irq)
 {	
 	struct ambapp_apb_info c;
 
-	if (ambapp_find_apbslv(&ambapp_plb,VENDOR_GAISLER,GAISLER_SLINK,&c) == 1) {
+	if (ambapp_find_apbslv(ambapp_plb(),VENDOR_GAISLER,GAISLER_SLINK,&c) == 1) {
 		*base = c.start;
 		*irq = c.common.irq;
 		return 0;
@@ -215,7 +215,7 @@ static int SLINK_getsysfreq(void)
 	struct ambapp_apb_info t;
 	struct gptimer_regs *tregs;
 		
-	if (ambapp_find_apbslv(&ambapp_plb,VENDOR_GAISLER,GAISLER_GPTIMER,&t)==1) {
+	if (ambapp_find_apbslv(ambapp_plb(),VENDOR_GAISLER,GAISLER_GPTIMER,&t)==1) {
 		tregs = (struct gptimer_regs *)t.start;
 		DBG("SLINK_getsysfreq returning %d\n", 
 		    (tregs->scaler_reload+1)*1000*1000);
diff --git a/bsps/sparc/leon3/clock/ckinit.c b/bsps/sparc/leon3/clock/ckinit.c
index 43e5f55ae5..4d30e0fd64 100644
--- a/bsps/sparc/leon3/clock/ckinit.c
+++ b/bsps/sparc/leon3/clock/ckinit.c
@@ -185,7 +185,7 @@ static void leon3_clock_initialize(void)
   } 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);
+    tc->tc_frequency = ambapp_freq_get(ambapp_plb(), LEON3_Timer_Adev);
 
     leon3_tc_tick = leon3_tc_tick_irqmp_timestamp_init;
 
diff --git a/bsps/sparc/leon3/console/console.c b/bsps/sparc/leon3/console/console.c
index 9fb1f54828..d5fff88d18 100644
--- a/bsps/sparc/leon3/console/console.c
+++ b/bsps/sparc/leon3/console/console.c
@@ -66,7 +66,7 @@ static int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
   /* Get APBUART core frequency, it is assumed that it is the same
    * as Bus frequency where the UART is situated
    */
-  apbuarts[uarts].freq_hz = ambapp_freq_get(&ambapp_plb, dev);
+  apbuarts[uarts].freq_hz = ambapp_freq_get(ambapp_plb(), dev);
   uarts++;
 
   if (uarts >= BSP_NUMBER_OF_TERMIOS_PORTS)
@@ -81,7 +81,7 @@ static void leon3_console_scan_uarts(void)
   memset(apbuarts, 0, sizeof(apbuarts));
 
   /* Find APBUART cores */
-  ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER,
+  ambapp_for_each(ambapp_plb(), (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER,
                   GAISLER_APBUART, find_matching_apbuart, NULL);
 }
 
diff --git a/bsps/sparc/leon3/console/printk_support.c b/bsps/sparc/leon3/console/printk_support.c
index 760ddd4b4c..f521f09a4c 100644
--- a/bsps/sparc/leon3/console/printk_support.c
+++ b/bsps/sparc/leon3/console/printk_support.c
@@ -85,7 +85,7 @@ static void bsp_debug_uart_init(void)
 
   /* Find APBUART core for System Debug Console */
   i = leon3_debug_uart_index;
-  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+  adev = (void *)ambapp_for_each(ambapp_plb(), (OPTIONS_ALL|OPTIONS_APB_SLVS),
                                  VENDOR_GAISLER, GAISLER_APBUART,
                                  ambapp_find_by_idx, (void *)&i);
   if (adev != NULL) {
diff --git a/bsps/sparc/leon3/include/amba.h b/bsps/sparc/leon3/include/amba.h
index c41c70a5a7..1492661fa5 100644
--- a/bsps/sparc/leon3/include/amba.h
+++ b/bsps/sparc/leon3/include/amba.h
@@ -45,17 +45,6 @@
 #include <grlib/ambapp.h>
 #include <grlib/grlib.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* The AMBA Plug&Play info of the bus that the LEON3 sits on */
-extern struct ambapp_bus ambapp_plb;
-
-#ifdef __cplusplus
-}
-#endif
-
 /** @} */
 
 #endif /* __AMBA_H__ */
diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
index 7eed5894c6..5fadb08052 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -494,7 +494,7 @@ 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);
+  return ambapp_freq_get(ambapp_plb(), LEON3_IrqCtrl_Adev);
 }
 
 #endif /* !ASM */
diff --git a/bsps/sparc/leon3/start/amba.c b/bsps/sparc/leon3/start/amba.c
index 1de206139f..66aa9c5e0b 100644
--- a/bsps/sparc/leon3/start/amba.c
+++ b/bsps/sparc/leon3/start/amba.c
@@ -15,8 +15,11 @@
 #include <bsp/fatal.h>
 #include <leon.h>
 #include <grlib/ambapp.h>
+#include <rtems/score/memory.h>
 #include <rtems/sysinit.h>
 
+#include <string.h>
+
 unsigned int leon3_timer_prescaler __attribute__((weak)) = 0;
 int leon3_timer_core_index __attribute__((weak)) = 0;
 
@@ -25,7 +28,35 @@ int leon3_timer_core_index __attribute__((weak)) = 0;
  * After software has scanned AMBA PnP it builds a tree to make
  * it easier for drivers to work with the bus architecture.
  */
-struct ambapp_bus ambapp_plb;
+static struct ambapp_bus ambapp_plb_instance;
+
+static void *ambapp_plb_alloc( size_t size )
+{
+  return _Memory_Allocate( _Memory_Get(), size, CPU_HEAP_ALIGNMENT );
+}
+
+struct ambapp_bus *ambapp_plb( void )
+{
+  struct ambapp_bus *plb;
+
+  plb = &ambapp_plb_instance;
+
+  if ( plb->root == NULL ) {
+    struct ambapp_context ctx;
+
+    ctx.memfunc = (ambapp_memcpy_t) memcpy;
+    ctx.alloc = ambapp_plb_alloc;
+
+    /* Scan AMBA Plug&Play read-only information. The routine builds a PnP
+     * tree into ambapp_plb in RAM, after this we never access the PnP
+     * information in hardware directly any more.
+     * Since on Processor Local Bus (PLB) memory mapping is 1:1
+     */
+    ambapp_scan( plb, LEON3_IO_AREA, &ctx, NULL );
+  }
+
+  return plb;
+}
 
 /* If RTEMS_DRVMGR_STARTUP is defined extra code is added that
  * registers the GRLIB AMBA PnP bus driver as root driver.
@@ -48,10 +79,20 @@ struct drvmgr_bus_res grlib_drv_resources __attribute__((weak)) =
 };
 
 /* GRLIB AMBA bus configuration (the LEON3 root bus configuration) */
-struct grlib_config grlib_bus_config =
+struct grlib_config grlib_bus_config;
+
+static void ambapp_grlib_root_initialize( void )
 {
-  &ambapp_plb,              /* AMBAPP bus setup */
-  &grlib_drv_resources,     /* Driver configuration */
+  /* Register Root bus, Use GRLIB AMBA PnP bus as root bus for LEON3 */
+  grlib_bus_config.abus = ambapp_plb();
+  grlib_bus_config.resources = &grlib_drv_resources;
+  ambapp_grlib_root_register(&grlib_bus_config);
+}
+
+RTEMS_SYSINIT_ITEM(
+  ambapp_grlib_root_initialize,
+  RTEMS_SYSINIT_BSP_START,
+  RTEMS_SYSINIT_ORDER_SECOND
 };
 #endif
 
@@ -78,16 +119,12 @@ static void amba_initialize(void)
 {
   int icsel;
   struct ambapp_dev *adev;
+  struct ambapp_bus *plb;
 
-  /* Scan AMBA Plug&Play read-only information. The routine builds a PnP
-   * tree into ambapp_plb in RAM, after this we never access the PnP
-   * information in hardware directly any more.
-   * Since on Processor Local Bus (PLB) memory mapping is 1:1
-   */
-  ambapp_scan(&ambapp_plb, LEON3_IO_AREA, NULL, NULL);
+  plb = ambapp_plb();
 
   /* Find LEON3 Interrupt controller */
-  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+  adev = (void *)ambapp_for_each(plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
                                  VENDOR_GAISLER, GAISLER_IRQMP,
                                  ambapp_find_by_idx, NULL);
   if (adev == NULL) {
@@ -118,7 +155,7 @@ static void amba_initialize(void)
   leon3_ext_irq_init();
 
   /* find GP Timer */
-  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+  adev = (void *)ambapp_for_each(plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
                                  VENDOR_GAISLER, GAISLER_GPTIMER,
                                  ambapp_find_by_idx, &leon3_timer_core_index);
   if (adev) {
@@ -127,7 +164,7 @@ static void amba_initialize(void)
 
     /* Register AMBA Bus Frequency */
     ambapp_freq_init(
-      &ambapp_plb,
+      plb,
       LEON3_Timer_Adev,
       (LEON3_Timer_Regs->scaler_reload + 1)
         * LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER
@@ -140,15 +177,10 @@ static void amba_initialize(void)
     if (leon3_timer_prescaler)
       LEON3_Timer_Regs->scaler_reload = leon3_timer_prescaler;
   }
-
-#ifdef RTEMS_DRVMGR_STARTUP
-  /* Register Root bus, Use GRLIB AMBA PnP bus as root bus for LEON3 */
-  ambapp_grlib_root_register(&grlib_bus_config);
-#endif
 }
 
 RTEMS_SYSINIT_ITEM(
   amba_initialize,
-  RTEMS_SYSINIT_BSP_START,
-  RTEMS_SYSINIT_ORDER_SECOND
+  RTEMS_SYSINIT_BSP_EARLY,
+  RTEMS_SYSINIT_ORDER_MIDDLE
 );
diff --git a/bsps/sparc/leon3/start/cache.c b/bsps/sparc/leon3/start/cache.c
index fb210a1f70..c428efa119 100644
--- a/bsps/sparc/leon3/start/cache.c
+++ b/bsps/sparc/leon3/start/cache.c
@@ -31,7 +31,7 @@ static inline volatile struct l2c_regs *get_l2c_regs(void)
   struct ambapp_dev *adev;
 
   adev = (void *) ambapp_for_each(
-    &ambapp_plb,
+    ambapp_plb(),
     OPTIONS_ALL | OPTIONS_AHB_SLVS,
     VENDOR_GAISLER,
     GAISLER_L2CACHE,
diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c
index 068c631af1..73a306a1eb 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -52,7 +52,7 @@ static void leon3_counter_initialize(void)
     /* Enable interrupt timestamping for an arbitrary interrupt line */
     irqmp_ts->control = 0x1;
 
-    leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_IrqCtrl_Adev);
+    leon3_counter_frequency = ambapp_freq_get(ambapp_plb(), LEON3_IrqCtrl_Adev);
   } else if (gpt != NULL) {
     /* Fall back to the first GPTIMER if available */
     counter->read_isr_disabled = _SPARC_Counter_read_down;
@@ -65,7 +65,7 @@ static void leon3_counter_initialize(void)
                                                     GPTIMER_TIMER_CTRL_RS |
                                                     GPTIMER_TIMER_CTRL_LD;
 
-    leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev) /
+    leon3_counter_frequency = ambapp_freq_get(ambapp_plb(), LEON3_Timer_Adev) /
       (gpt->scaler_reload + 1);
   }
 }
-- 
2.26.2



More information about the devel mailing list