diff options
Diffstat (limited to 'bsps/riscv/riscv/console')
-rw-r--r-- | bsps/riscv/riscv/console/console-config.c | 35 | ||||
-rw-r--r-- | bsps/riscv/riscv/console/fe310-uart.c | 9 | ||||
-rw-r--r-- | bsps/riscv/riscv/console/htif.c | 2 |
3 files changed, 23 insertions, 23 deletions
diff --git a/bsps/riscv/riscv/console/console-config.c b/bsps/riscv/riscv/console/console-config.c index d962a5a418..df9828cf27 100644 --- a/bsps/riscv/riscv/console/console-config.c +++ b/bsps/riscv/riscv/console/console-config.c @@ -11,7 +11,7 @@ */ /* - * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -55,12 +55,12 @@ #include <libfdt.h> #include <string.h> -#if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0 +#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0 #include <bsp/fe310-uart.h> static fe310_uart_context fe310_uart_instance; #endif -#if RISCV_ENABLE_HTIF_SUPPORT != 0 +#ifdef RISCV_ENABLE_HTIF_SUPPORT static htif_console_context htif_console_instance; #endif @@ -139,10 +139,6 @@ static void riscv_console_set_reg_32(uintptr_t addr, uint8_t i, uint8_t val) } #endif -#define RISCV_CONSOLE_IS_COMPATIBLE(actual, actual_len, desired) \ - (actual_len == sizeof(desired) \ - && memcmp(actual, desired, sizeof(desired) - 1) == 0) - static void riscv_console_probe(void) { const void *fdt; @@ -169,8 +165,9 @@ static void riscv_console_probe(void) compat_len = 0; } -#if RISCV_ENABLE_HTIF_SUPPORT != 0 - if (RISCV_CONSOLE_IS_COMPATIBLE(compat, compat_len, "ucb,htif0")) { +#ifdef RISCV_ENABLE_HTIF_SUPPORT + /* Search for HTIF (eg. on Spike) and use it if found */ + if (fdt_stringlist_contains(compat, compat_len, "ucb,htif0")) { htif_console_context_init(&htif_console_instance.base, node); riscv_console.context = &htif_console_instance.base; @@ -181,8 +178,8 @@ static void riscv_console_probe(void) #if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0 if ( - (RISCV_CONSOLE_IS_COMPATIBLE(compat, compat_len, "ns16550a") - || RISCV_CONSOLE_IS_COMPATIBLE(compat, compat_len, "ns16750")) + (fdt_stringlist_contains(compat, compat_len, "ns16550a") + || fdt_stringlist_contains(compat, compat_len, "ns16750")) && ns16550_devices < RISCV_CONSOLE_MAX_NS16550_DEVICES ) { ns16550_context *ctx; @@ -203,7 +200,7 @@ static void riscv_console_probe(void) ctx->set_reg = riscv_console_set_reg_8; } - if (RISCV_CONSOLE_IS_COMPATIBLE(compat, compat_len, "ns16750")) { + if (fdt_stringlist_contains(compat, compat_len, "ns16750")) { ctx->has_precision_clock_synthesizer = true; } @@ -242,8 +239,8 @@ static void riscv_console_probe(void) } #endif -#if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0 - if (RISCV_CONSOLE_IS_COMPATIBLE(compat, compat_len, "sifive,uart0")) { +#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0 + if (fdt_stringlist_contains(compat, compat_len, "sifive,uart0")) { fe310_uart_context *ctx; ctx = &fe310_uart_instance; @@ -258,7 +255,7 @@ static void riscv_console_probe(void) riscv_console.getchar = fe310_uart_read; } - rtems_termios_device_context_initialize(&ctx->base, "FE310UART"); + rtems_termios_device_context_initialize(&ctx->base, "SIFIVEUART"); } #endif @@ -284,7 +281,7 @@ rtems_status_code console_initialize( void *arg ) { -#if RISCV_ENABLE_HTIF_SUPPORT != 0 +#ifdef RISCV_ENABLE_HTIF_SUPPORT rtems_termios_device_context *base; char htif_path[] = "/dev/ttyShtif"; #endif @@ -293,14 +290,14 @@ rtems_status_code console_initialize( size_t i; #endif -#if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0 +#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0 fe310_uart_context *ctx; char fe310_path[] = "/dev/ttyS0"; #endif rtems_termios_initialize(); -#if RISCV_ENABLE_HTIF_SUPPORT != 0 +#ifdef RISCV_ENABLE_HTIF_SUPPORT base = &htif_console_instance.base; rtems_termios_device_install(htif_path, &htif_console_handler, NULL, base); @@ -329,7 +326,7 @@ rtems_status_code console_initialize( } #endif -#if RISCV_ENABLE_FRDME310ARTY_SUPPORT != 0 +#if RISCV_ENABLE_SIFIVE_UART_SUPPORT != 0 ctx = &fe310_uart_instance; rtems_termios_device_install( fe310_path, diff --git a/bsps/riscv/riscv/console/fe310-uart.c b/bsps/riscv/riscv/console/fe310-uart.c index 4ae62d7176..ddabcff4c8 100644 --- a/bsps/riscv/riscv/console/fe310-uart.c +++ b/bsps/riscv/riscv/console/fe310-uart.c @@ -34,11 +34,13 @@ int fe310_uart_read(rtems_termios_device_context *base) { fe310_uart_context * ctx = (fe310_uart_context*) base; + int32_t rxdata; - if ((ctx->regs->rxdata & TXRXREADY) != 0) { + rxdata = ctx->regs->rxdata; + if ((rxdata & TXRXREADY) != 0) { return -1; } else { - return ctx->regs->rxdata; + return rxdata & 0xFF; } } @@ -51,7 +53,7 @@ static void fe310_uart_write ( fe310_uart_context * ctx = (fe310_uart_context*) base; size_t i; - ctx->regs->div = riscv_get_core_frequency() / 115200 - 1; + ctx->regs->div = (riscv_get_core_frequency() / 115200 - 1) & 0xFFFF; ctx->regs->txctrl |= 1; ctx->regs->rxctrl |= 1; @@ -91,6 +93,7 @@ static bool fe310_uart_first_open ( (ctx->regs)->div = riscv_get_core_frequency() / 115200 - 1; (ctx->regs)->txctrl |= 1; (ctx->regs)->rxctrl |= 1; + (ctx->regs)->ie = 0; return true; }; diff --git a/bsps/riscv/riscv/console/htif.c b/bsps/riscv/riscv/console/htif.c index bcfe6a5db5..159d9d72fb 100644 --- a/bsps/riscv/riscv/console/htif.c +++ b/bsps/riscv/riscv/console/htif.c @@ -29,7 +29,7 @@ #include <bsp/riscv.h> -#if RISCV_ENABLE_HTIF_SUPPORT != 0 +#ifdef RISCV_ENABLE_HTIF_SUPPORT #include <dev/serial/htif.h> |