summaryrefslogtreecommitdiffstats
path: root/bsps/aarch64/xilinx-versal/dev/serial/versal-uart-polled.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsps/aarch64/xilinx-versal/dev/serial/versal-uart-polled.c')
-rw-r--r--bsps/aarch64/xilinx-versal/dev/serial/versal-uart-polled.c48
1 files changed, 7 insertions, 41 deletions
diff --git a/bsps/aarch64/xilinx-versal/dev/serial/versal-uart-polled.c b/bsps/aarch64/xilinx-versal/dev/serial/versal-uart-polled.c
index be46c99efd..9453dc248b 100644
--- a/bsps/aarch64/xilinx-versal/dev/serial/versal-uart-polled.c
+++ b/bsps/aarch64/xilinx-versal/dev/serial/versal-uart-polled.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (C) 2021 Gedare Bloom <gedare@rtems.org>
+ * Copyright (C) 2021 Gedare Bloom <gedare@rtems.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -68,7 +68,7 @@ int32_t versal_cal_baud_rate(
return -1;
}
- /*
+ /*
* The UART clock cannot be larger than 16*65535*baudrate.
* Could maybe use an estimate (inputclk / 2**16) to save a division.
* This invariant gets checked below, by ensuring ibdiv < 2**16.
@@ -78,7 +78,7 @@ int32_t versal_cal_baud_rate(
* The UART clock cannot be more than 5/3 times faster than the LPD_LSBUS_CLK
* - TODO?
*/
-
+
/*
* The baud rate divisor is a 16-bit integer and 6-bit fractional part.
* It is equal to the UART clock / (16 * baudrate).
@@ -138,7 +138,8 @@ int versal_uart_initialize(rtems_termios_device_context *base)
}
/* Line control: 8-bit word length, no parity, no FIFO, 1 stop bit */
- regs->uartlcr_h = VERSAL_UARTLCR_H_WLEN( VERSAL_UARTLCR_H_WLEN_8 );
+ regs->uartlcr_h = VERSAL_UARTLCR_H_WLEN( VERSAL_UARTLCR_H_WLEN_8 )
+ | VERSAL_UARTLCR_H_FEN;
/* Control: receive, transmit, uart enable, no CTS, no RTS, no loopback */
regs->uartcr = VERSAL_UARTCR_RXE
@@ -151,23 +152,6 @@ int versal_uart_initialize(rtems_termios_device_context *base)
return 0;
}
-static bool versal_uart_first_open(
- struct rtems_termios_tty *tty,
- rtems_termios_device_context *base,
- struct termios *term,
- rtems_libio_open_close_args_t *args
-)
-{
- int rc = versal_uart_initialize(base);
- if ( rc < 0 ) {
- return false;
- }
-
- rtems_termios_set_initial_baud(tty, VERSAL_UART_DEFAULT_BAUD);
-
- return true;
-}
-
int versal_uart_read_polled(rtems_termios_device_context *base)
{
volatile versal_uart *regs = versal_uart_get_regs(base);
@@ -204,25 +188,7 @@ void versal_uart_reset_tx_flush(rtems_termios_device_context *base)
while ((regs->uartfr & VERSAL_UARTFR_TXFE) == 0) {
/* Wait for empty */
}
-}
-
-static void versal_uart_write_support(
- rtems_termios_device_context *base,
- const char *s,
- size_t n
-)
-{
- size_t i;
-
- for (i = 0; i < n; i++) {
- versal_uart_write_polled(base, s[i]);
+ while ((regs->uartfr & VERSAL_UARTFR_BUSY) != 0) {
+ /* Wait for empty */
}
}
-
-const rtems_termios_device_handler versal_uart_handler = {
- .first_open = versal_uart_first_open,
- .write = versal_uart_write_support,
- .poll_read = versal_uart_read_polled,
- .mode = TERMIOS_POLLED
-};
-