diff options
author | Kinsey Moore <kinsey.moore@oarcorp.com> | 2020-12-02 13:20:36 -0600 |
---|---|---|
committer | Jan Sommer <jan.sommer@dlr.de> | 2021-03-09 09:28:43 +0100 |
commit | 2f323700b9cde52603e5773611bdc8932c109f58 (patch) | |
tree | ff7c07ad7f47b8c7a16b9da81a662ee895372253 /bsps/arm/shared/serial/zynq-uart.c | |
parent | sparc,leon: avoid triggering LEON3FT errata TN-0009 (diff) | |
download | rtems-2f323700b9cde52603e5773611bdc8932c109f58.tar.bz2 |
zynq-uart: Fix set_attributes implementation
The zynq-uart set_attributes implementation was configured to always
return false which causes spconsole01 to fail. This restores the
disabled implementation which sets the baud rate registers
appropriately and allows spconsole01 to pass. This also expands the
set_attributes functionality to allow setting of the stop bits,
character width, and parity.
Updates #4236
Diffstat (limited to 'bsps/arm/shared/serial/zynq-uart.c')
-rw-r--r-- | bsps/arm/shared/serial/zynq-uart.c | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/bsps/arm/shared/serial/zynq-uart.c b/bsps/arm/shared/serial/zynq-uart.c index fc670441b8..a0dfc0c929 100644 --- a/bsps/arm/shared/serial/zynq-uart.c +++ b/bsps/arm/shared/serial/zynq-uart.c @@ -142,25 +142,71 @@ static bool zynq_uart_set_attributes( const struct termios *term ) { -#if 0 - volatile zynq_uart *regs = zynq_uart_get_regs(minor); + zynq_uart_context *ctx = (zynq_uart_context *) context; + volatile zynq_uart *regs = ctx->regs; uint32_t brgr = 0; uint32_t bauddiv = 0; + uint32_t mode = 0; int rc; rc = zynq_cal_baud_rate(115200, &brgr, &bauddiv, regs->mode); if (rc != 0) return rc; + /* + * Configure the mode register + */ + mode |= ZYNQ_UART_MODE_CHMODE(ZYNQ_UART_MODE_CHMODE_NORMAL); + + /* + * Parity + */ + mode |= ZYNQ_UART_MODE_PAR(ZYNQ_UART_MODE_PAR_NONE); + if (term->c_cflag & PARENB) { + if (!(term->c_cflag & PARODD)) { + mode |= ZYNQ_UART_MODE_PAR(ZYNQ_UART_MODE_PAR_ODD); + } else { + mode |= ZYNQ_UART_MODE_PAR(ZYNQ_UART_MODE_PAR_EVEN); + } + } + + /* + * Character Size + */ + switch (term->c_cflag & CSIZE) + { + case CS5: + return false; + case CS6: + mode |= ZYNQ_UART_MODE_CHRL(ZYNQ_UART_MODE_CHRL_6); + break; + case CS7: + mode |= ZYNQ_UART_MODE_CHRL(ZYNQ_UART_MODE_CHRL_7); + break; + case CS8: + default: + mode |= ZYNQ_UART_MODE_CHRL(ZYNQ_UART_MODE_CHRL_8); + break; + } + + /* + * Stop Bits + */ + if (term->c_cflag & CSTOPB) { + /* 2 stop bits */ + mode |= ZYNQ_UART_MODE_NBSTOP(ZYNQ_UART_MODE_NBSTOP_STOP_2); + } else { + /* 1 stop bit */ + mode |= ZYNQ_UART_MODE_NBSTOP(ZYNQ_UART_MODE_NBSTOP_STOP_1); + } + regs->control &= ~(ZYNQ_UART_CONTROL_RXEN | ZYNQ_UART_CONTROL_TXEN); + regs->mode = mode; regs->baud_rate_gen = ZYNQ_UART_BAUD_RATE_GEN_CD(brgr); regs->baud_rate_div = ZYNQ_UART_BAUD_RATE_DIV_BDIV(bauddiv); regs->control |= ZYNQ_UART_CONTROL_RXEN | ZYNQ_UART_CONTROL_TXEN; return true; -#else - return false; -#endif } const rtems_termios_device_handler zynq_uart_handler = { |