forked from Imagelibrary/rtems
bsps/microblaze: Add device tree support to UART Lite
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
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 )
|
||||
{
|
||||
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 )
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user