summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-16 10:35:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-23 16:31:12 +0200
commita07c31ef5d1d0e34d93ac3743393d159baaa4a98 (patch)
tree33f742b2c6150582c989713fa29e6d248c117db5
parenta665fb3a105c5e22cf0754e7d8d542978e07f45f (diff)
bsp/leon3: Add LEON3_APBUART_BASE
-rw-r--r--bsps/sparc/leon3/console/printk_support.c31
-rw-r--r--bsps/sparc/leon3/include/bsp/leon3.h5
-rw-r--r--bsps/sparc/leon3/include/leon.h2
-rw-r--r--spec/build/bsps/sparc/leon3/grp.yml2
-rw-r--r--spec/build/bsps/sparc/leon3/optapbuartbase.yml24
5 files changed, 57 insertions, 7 deletions
diff --git a/bsps/sparc/leon3/console/printk_support.c b/bsps/sparc/leon3/console/printk_support.c
index d540e75911..fbd8b030ac 100644
--- a/bsps/sparc/leon3/console/printk_support.c
+++ b/bsps/sparc/leon3/console/printk_support.c
@@ -19,20 +19,27 @@
#include <bsp/leon3.h>
#include <rtems/bspIo.h>
#include <rtems/sysinit.h>
-#include <rtems/score/thread.h>
#include <grlib/apbuart.h>
#include <grlib/io.h>
+#if !defined(LEON3_APBUART_BASE)
#include <grlib/ambapp.h>
int leon3_debug_uart_index __attribute__((weak)) = 0;
+
apbuart *leon3_debug_uart = NULL;
+#endif
static void bsp_debug_uart_init(void);
-static void bsp_debug_uart_discard(char c)
+static void apbuart_enable_receive_and_transmit(apbuart *regs)
{
- (void) c;
+ uint32_t ctrl;
+
+ ctrl = grlib_load_32(&regs->ctrl);
+ ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
+ grlib_store_32(&regs->ctrl, ctrl);
+ grlib_store_32(&regs->status, 0);
}
static void bsp_debug_uart_output_char(char c)
@@ -52,6 +59,17 @@ static void bsp_debug_uart_pre_init_out(char c)
(*BSP_output_char)(c);
}
+#if defined(LEON3_APBUART_BASE)
+
+static void bsp_debug_uart_init(void)
+{
+ apbuart_enable_receive_and_transmit(leon3_debug_uart);
+ BSP_poll_char = bsp_debug_uart_poll_char;
+ BSP_output_char = bsp_debug_uart_output_char;
+}
+
+#else /* !LEON3_APBUART_BASE */
+
/* Initialize the BSP system debug console layer. It will scan AMBA Plu&Play
* for a debug APBUART and enable RX/TX for that UART.
*/
@@ -97,16 +115,15 @@ static void bsp_debug_uart_init(void)
*/
apb = (struct ambapp_apb_info *)adev->devinfo;
leon3_debug_uart = (apbuart *)apb->start;
- ctrl = grlib_load_32(&leon3_debug_uart->ctrl);
- ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
- grlib_store_32(&leon3_debug_uart->ctrl, ctrl);
- grlib_store_32(&leon3_debug_uart->status, 0);
+ apbuart_enable_receive_and_transmit(leon3_debug_uart);
BSP_poll_char = bsp_debug_uart_poll_char;
BSP_output_char = bsp_debug_uart_output_char;
}
}
+#endif /* LEON3_APBUART_BASE */
+
RTEMS_SYSINIT_ITEM(
bsp_debug_uart_init,
RTEMS_SYSINIT_BSP_START,
diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h
index 1087c8ab58..852d6970ce 100644
--- a/bsps/sparc/leon3/include/bsp/leon3.h
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -36,6 +36,7 @@
#ifndef _BSP_LEON3_H
#define _BSP_LEON3_H
+#include <bspopts.h>
#include <rtems.h>
#include <grlib/apbuart-regs.h>
#include <grlib/gptimer-regs.h>
@@ -348,7 +349,11 @@ static inline uint32_t leon3_up_counter_frequency( void )
/**
* @brief This pointer provides the debug APBUART register block address.
*/
+#if defined(LEON3_APBUART_BASE)
+#define leon3_debug_uart ((struct apbuart *) LEON3_APBUART_BASE)
+#else
extern apbuart *leon3_debug_uart;
+#endif
/** @} */
diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
index efae07b18c..49d1ff8676 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -304,6 +304,7 @@ static inline unsigned int leon_r32_no_cache(uintptr_t addr)
*/
extern int syscon_uart_index;
+#if !defined(LEON3_APBUART_BASE)
/* Let user override which on-chip APBUART will be debug UART
* 0 = Default APBUART. On MP system CPU0=APBUART0, CPU1=APBUART1...
* 1 = APBUART[0]
@@ -312,6 +313,7 @@ extern int syscon_uart_index;
* ...
*/
extern int leon3_debug_uart_index;
+#endif
/* Let user override which on-chip TIMER core will be used for system clock
* timer. This controls which timer core will be accociated with
diff --git a/spec/build/bsps/sparc/leon3/grp.yml b/spec/build/bsps/sparc/leon3/grp.yml
index 2af5756c5a..04166f0ad8 100644
--- a/spec/build/bsps/sparc/leon3/grp.yml
+++ b/spec/build/bsps/sparc/leon3/grp.yml
@@ -32,6 +32,8 @@ links:
- role: build-dependency
uid: objsmp
- role: build-dependency
+ uid: optapbuartbase
+- role: build-dependency
uid: optconirq
- role: build-dependency
uid: optleon3smp
diff --git a/spec/build/bsps/sparc/leon3/optapbuartbase.yml b/spec/build/bsps/sparc/leon3/optapbuartbase.yml
new file mode 100644
index 0000000000..86bce89e68
--- /dev/null
+++ b/spec/build/bsps/sparc/leon3/optapbuartbase.yml
@@ -0,0 +1,24 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+actions:
+- get-integer: null
+- format-and-define: null
+build-type: option
+default: null
+default-by-family: []
+default-by-variant:
+- value: 0x80000100
+ variants:
+ - sparc/gr712rc
+- value: 0xff900000
+ variants:
+ - sparc/gr740
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: LEON3_APBUART_BASE
+description: |
+ This option defines the base address of the debug/console APBUART register
+ block.
+type: build