diff options
Diffstat (limited to 'bsps/sparc/leon3/console/printk_support.c')
-rw-r--r-- | bsps/sparc/leon3/console/printk_support.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/bsps/sparc/leon3/console/printk_support.c b/bsps/sparc/leon3/console/printk_support.c index cb77c66a96..9e260d2eac 100644 --- a/bsps/sparc/leon3/console/printk_support.c +++ b/bsps/sparc/leon3/console/printk_support.c @@ -38,20 +38,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(®s->ctrl); + ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE; + grlib_store_32(®s->ctrl, ctrl); + grlib_store_32(®s->status, 0); } static void bsp_debug_uart_output_char(char c) @@ -71,6 +78,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. */ @@ -108,7 +131,6 @@ static void bsp_debug_uart_init(void) ambapp_find_by_idx, (void *)&i); if (adev != NULL) { struct ambapp_apb_info *apb; - uint32_t ctrl; /* * Found a matching debug console, initialize debug UART if present for @@ -116,16 +138,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, |