bsps/microblaze: Add device tree support to UART Lite

This commit is contained in:
Ryan Long
2022-10-19 13:46:14 -05:00
committed by Joel Sherrill
parent 3fd8cf2d37
commit 9d5354e897
3 changed files with 49 additions and 8 deletions

View File

@@ -35,20 +35,35 @@
*/ */
#include <bsp/console-termios.h> #include <bsp/console-termios.h>
#include <bsp/microblaze-fdt-support.h>
#include <dev/serial/uartlite.h> #include <dev/serial/uartlite.h>
#include <bspopts.h> #include <bspopts.h>
uart_lite_context microblaze_qemu_uart_context = { uart_lite_context microblaze_qemu_uart_context = {
.base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "UARTLITE" ), .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "UARTLITE" ),
.address = BSP_MICROBLAZE_FPGA_UART_BASE,
.initial_baud = 115200 .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[] = { const console_device console_device_table[] = {
{ {
.device_file = "/dev/ttyS0", .device_file = "/dev/ttyS0",
.probe = console_device_probe_default, .probe = fill_uart_base,
.handler = &microblaze_uart_fns, .handler = &microblaze_uart_fns,
.context = &microblaze_qemu_uart_context.base .context = &microblaze_qemu_uart_context.base
} }

View File

@@ -37,23 +37,42 @@
#include <dev/serial/uartlite_l.h> #include <dev/serial/uartlite_l.h>
#include <rtems/bspIo.h> #include <rtems/bspIo.h>
#include <bsp.h>
#include <bspopts.h> #include <bspopts.h>
static uint32_t mblaze_uart_base = 0;
static void output_char( char c ) static void output_char( char c )
{ {
if ( c == '\n' ) { if (mblaze_uart_base == 0 ) {
XUartLite_SendByte( BSP_MICROBLAZE_FPGA_UART_BASE, '\r' ); mblaze_uart_base = try_get_prop_from_device_tree(
"xlnx,xps-uartlite-1.00.a",
"reg",
BSP_MICROBLAZE_FPGA_UART_BASE
);
} }
XUartLite_SendByte( BSP_MICROBLAZE_FPGA_UART_BASE, c );
if ( c == '\n' ) {
XUartLite_SendByte( mblaze_uart_base, '\r' );
}
XUartLite_SendByte( mblaze_uart_base, c );
} }
static int xUartLite_RecvByte( int minor ) 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 -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 ) static int get_char( void )

View File

@@ -70,8 +70,15 @@ static bool uart_first_open(
#ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS #ifdef BSP_MICROBLAZE_FPGA_CONSOLE_INTERRUPTS
XUartLite_EnableIntr( ctx->address ); 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( sc = rtems_interrupt_handler_install(
1, uart_irq_num,
"UART", "UART",
RTEMS_INTERRUPT_SHARED, RTEMS_INTERRUPT_SHARED,
microblaze_uart_interrupt, microblaze_uart_interrupt,