[PATCH v2 1/4] zynq-uart: Fix set_attributes implementation
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Dec 3 05:56:47 UTC 2020
On 03/12/2020 02:12, Kinsey Moore wrote:
> 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.
> ---
> bsps/include/dev/serial/zynq-uart.h | 5 ++
> bsps/shared/dev/serial/zynq-uart-polled.c | 2 +-
> bsps/shared/dev/serial/zynq-uart.c | 62 +++++++++++++++++++++--
> 3 files changed, 63 insertions(+), 6 deletions(-)
>
> diff --git a/bsps/include/dev/serial/zynq-uart.h b/bsps/include/dev/serial/zynq-uart.h
> index 2c0f250a3a..e3e8cae6fd 100644
> --- a/bsps/include/dev/serial/zynq-uart.h
> +++ b/bsps/include/dev/serial/zynq-uart.h
> @@ -78,6 +78,11 @@ void zynq_uart_write_polled(
> */
> void zynq_uart_reset_tx_flush(zynq_uart_context *ctx);
>
> +int zynq_cal_baud_rate(uint32_t baudrate,
> + uint32_t* brgr,
> + uint32_t* bauddiv,
> + uint32_t modereg);
New coding style?
> +
> #ifdef __cplusplus
> }
> #endif /* __cplusplus */
> diff --git a/bsps/shared/dev/serial/zynq-uart-polled.c b/bsps/shared/dev/serial/zynq-uart-polled.c
> index a1b51ea521..442431d502 100644
> --- a/bsps/shared/dev/serial/zynq-uart-polled.c
> +++ b/bsps/shared/dev/serial/zynq-uart-polled.c
> @@ -40,7 +40,7 @@ uint32_t zynq_uart_input_clock(void)
> return ZYNQ_CLOCK_UART;
> }
>
> -static int zynq_cal_baud_rate(uint32_t baudrate,
> +int zynq_cal_baud_rate(uint32_t baudrate,
> uint32_t* brgr,
> uint32_t* bauddiv,
> uint32_t modereg)
> diff --git a/bsps/shared/dev/serial/zynq-uart.c b/bsps/shared/dev/serial/zynq-uart.c
> index 41adb196ab..e2b614c270 100644
> --- a/bsps/shared/dev/serial/zynq-uart.c
> +++ b/bsps/shared/dev/serial/zynq-uart.c
> @@ -142,25 +142,77 @@ 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))
https://docs.rtems.org/branches/master/eng/coding-conventions.html#language-and-compiler
> + mode |= ZYNQ_UART_MODE_PAR(ZYNQ_UART_MODE_PAR_ODD);
> + else
> + mode |= ZYNQ_UART_MODE_PAR(ZYNQ_UART_MODE_PAR_EVEN);
I think we should use { } also for one liner if/else.
> + }
> +
> + /*
> + * Character Size
> + */
> +
> + if (term->c_cflag & CSIZE) {
> + switch (term->c_cflag & CSIZE) {
> + case CS5:
> + return false;
Why not use the default case here?
Indentation level is wrong.
[...]
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hubere at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
More information about the devel
mailing list