From: Ryan Long <ryan.l...@oarcorp.com> --- .../microblaze_fpga/console/console-io.c | 19 ++++++++++-- .../microblaze_fpga/console/debug-io.c | 29 +++++++++++++++---- bsps/microblaze/shared/dev/serial/uartlite.c | 9 +++++- 3 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/bsps/microblaze/microblaze_fpga/console/console-io.c b/bsps/microblaze/microblaze_fpga/console/console-io.c index cb2e367035..81c4e73690 100644 --- a/bsps/microblaze/microblaze_fpga/console/console-io.c +++ b/bsps/microblaze/microblaze_fpga/console/console-io.c @@ -35,20 +35,35 @@ */ #include <bsp/console-termios.h> +#include <bsp/microblaze-fdt-support.h> #include <dev/serial/uartlite.h> #include <bspopts.h> uart_lite_context microblaze_qemu_uart_context = { .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "UARTLITE" ), - .address = BSP_MICROBLAZE_FPGA_UART_BASE, .initial_baud = 115200 }; +static bool fill_uart_base(rtems_termios_device_context *context) +{ + uint32_t mblaze_uart_base; + + mblaze_uart_base = try_get_prop_from_device_tree( + "xlnx,xps-uartlite-1.00.a", + "reg", + BSP_MICROBLAZE_FPGA_UART_BASE + ); + + microblaze_qemu_uart_context.address = mblaze_uart_base; + + return true; +} + const console_device console_device_table[] = { { .device_file = "/dev/ttyS0", - .probe = console_device_probe_default, + .probe = fill_uart_base, .handler = µblaze_uart_fns, .context = µblaze_qemu_uart_context.base } diff --git a/bsps/microblaze/microblaze_fpga/console/debug-io.c b/bsps/microblaze/microblaze_fpga/console/debug-io.c index e88f5468a7..d85229ae9e 100644 --- a/bsps/microblaze/microblaze_fpga/console/debug-io.c +++ b/bsps/microblaze/microblaze_fpga/console/debug-io.c @@ -37,23 +37,42 @@ #include <dev/serial/uartlite_l.h> #include <rtems/bspIo.h> +#include <bsp.h> #include <bspopts.h> +static uint32_t mblaze_uart_base = 0; + static void output_char( char c ) { - if ( c == '\n' ) { - XUartLite_SendByte( BSP_MICROBLAZE_FPGA_UART_BASE, '\r' ); + if (mblaze_uart_base == 0 ) { + mblaze_uart_base = try_get_prop_from_device_tree( + "xlnx,xps-uartlite-1.00.a", + "reg", + BSP_MICROBLAZE_FPGA_UART_BASE + ); + } + + if ( c == '\n' ) { + XUartLite_SendByte( mblaze_uart_base, '\r' ); } - XUartLite_SendByte( BSP_MICROBLAZE_FPGA_UART_BASE, c ); + XUartLite_SendByte( mblaze_uart_base, c ); } static int xUartLite_RecvByte( int minor ) { - if ( XUartLite_IsReceiveEmpty( BSP_MICROBLAZE_FPGA_UART_BASE ) ) { + if (mblaze_uart_base == 0 ) { + mblaze_uart_base = try_get_prop_from_device_tree( + "xlnx,xps-uartlite-1.00.a", + "reg", + BSP_MICROBLAZE_FPGA_UART_BASE + ); + } + + if ( XUartLite_IsReceiveEmpty( mblaze_uart_base ) ) { return -1; } - return XUartLite_ReadReg( BSP_MICROBLAZE_FPGA_UART_BASE, XUL_RX_FIFO_OFFSET ); + return XUartLite_ReadReg( mblaze_uart_base, XUL_RX_FIFO_OFFSET ); } static int get_char( void ) diff --git a/bsps/microblaze/shared/dev/serial/uartlite.c b/bsps/microblaze/shared/dev/serial/uartlite.c index a5fc4fe82b..953c630759 100644 --- a/bsps/microblaze/shared/dev/serial/uartlite.c +++ b/bsps/microblaze/shared/dev/serial/uartlite.c @@ -70,8 +70,15 @@ static bool uart_first_open( #ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS XUartLite_EnableIntr( ctx->address ); + + uint32_t uart_irq_num = try_get_prop_from_device_tree( + "xlnx,xps-uartlite-1.00.a", + "interrupts", + 1 + ); + sc = rtems_interrupt_handler_install( - 1, + uart_irq_num, "UART", RTEMS_INTERRUPT_SHARED, microblaze_uart_interrupt, -- 2.34.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel