summaryrefslogtreecommitdiffstats
path: root/bsps/riscv
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-10 13:04:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-17 12:58:33 +0200
commit2c07f24af210c4738fbe6f75a53c58fbd80fb658 (patch)
tree4d8e061e716beb451cdb45bd8761f2025ce062bb /bsps/riscv
parentgrlib: Customizable allocation in ambapp_scan() (diff)
downloadrtems-2c07f24af210c4738fbe6f75a53c58fbd80fb658.tar.bz2
grlib: Add ambapp_plb()
Replace the global variable ambapp_plb with a function to allow an automatic on demand initialization.
Diffstat (limited to 'bsps/riscv')
-rw-r--r--bsps/riscv/griscv/console/console.c4
-rw-r--r--bsps/riscv/griscv/console/printk_support.c2
-rw-r--r--bsps/riscv/griscv/include/amba.h5
-rw-r--r--bsps/riscv/griscv/start/amba.c6
-rw-r--r--bsps/riscv/griscv/start/bspstart.c24
5 files changed, 25 insertions, 16 deletions
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(