summaryrefslogtreecommitdiffstats
path: root/bsps/sparc/leon3/console/printk_support.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsps/sparc/leon3/console/printk_support.c')
-rw-r--r--bsps/sparc/leon3/console/printk_support.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/bsps/sparc/leon3/console/printk_support.c b/bsps/sparc/leon3/console/printk_support.c
index 9fd1b1a089..fd23a5033f 100644
--- a/bsps/sparc/leon3/console/printk_support.c
+++ b/bsps/sparc/leon3/console/printk_support.c
@@ -1,10 +1,15 @@
/* SPDX-License-Identifier: BSD-2-Clause */
-/*
- * This file contains the TTY driver for the serial ports on the LEON.
+/**
+ * @file
*
- * This driver uses the termios pseudo driver.
+ * @ingroup RTEMSBSPsSPARCLEON3
*
+ * @brief This source file contains the definition of ::BSP_output_char and
+ * ::BSP_poll_char.
+ */
+
+/*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
@@ -35,20 +40,30 @@
*/
#include <bsp.h>
-#include <leon.h>
+#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;
-struct apbuart_regs *leon3_debug_uart = NULL;
+
+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)
@@ -68,6 +83,22 @@ 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 */
+
+static void bsp_debug_uart_discard(char c)
+{
+ (void) c;
+}
+
/* Initialize the BSP system debug console layer. It will scan AMBA Plu&Play
* for a debug APBUART and enable RX/TX for that UART.
*/
@@ -111,15 +142,16 @@ static void bsp_debug_uart_init(void)
* printk().
*/
apb = (struct ambapp_apb_info *)adev->devinfo;
- leon3_debug_uart = (struct apbuart_regs *)apb->start;
- leon3_debug_uart->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
- leon3_debug_uart->status = 0;
+ leon3_debug_uart = (apbuart *)apb->start;
+ 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,