[PATCHv2 1/2] bsps/riscv: UART - Read reg-shift from DTB to properly set/get registers

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Apr 9 05:41:36 UTC 2019


On 08/04/2019 14:44, Hesham Almatary wrote:
> ---
>   bsps/riscv/riscv/console/console-config.c | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/bsps/riscv/riscv/console/console-config.c b/bsps/riscv/riscv/console/console-config.c
> index 464b4b0e26..04d0b28361 100644
> --- a/bsps/riscv/riscv/console/console-config.c
> +++ b/bsps/riscv/riscv/console/console-config.c
> @@ -145,12 +145,19 @@ static void riscv_console_probe(void)
>         ns16550_context *ctx;
>         fdt32_t *val;
>         int len;
> +      int reg_shift = 0;

Please initialize this variable blow, just like the other ones.

>   
>         ctx = &ns16550_instances[ns16550_devices];
>         ctx->initial_baud = BSP_CONSOLE_BAUD;
>   
> -      if (RISCV_CONSOLE_IS_COMPATIBLE(compat, compat_len, "ns16750")) {
> -        ctx->has_precision_clock_synthesizer = true;
> +      // Get register shift property of the UART device

No C++ style comments.

> +      val = (fdt32_t *) fdt_getprop(fdt, node, "reg-shift", &len);
> +
> +      if (val) {
> +        reg_shift = fdt32_to_cpu(val[0]);
> +      }
> +
> +      if (reg_shift == 2) {
>           ctx->get_reg = riscv_console_get_reg_32;
>           ctx->set_reg = riscv_console_set_reg_32;
>         } else {
> @@ -158,6 +165,10 @@ static void riscv_console_probe(void)
>           ctx->set_reg = riscv_console_set_reg_8;
>         }
>   
> +      if (RISCV_CONSOLE_IS_COMPATIBLE(compat, compat_len, "ns16750")) {
> +        ctx->has_precision_clock_synthesizer = true;
> +      }
> +
>         ctx->port = (uintptr_t) riscv_fdt_get_address(fdt, node);
>   
>         if (ctx->port == 0) {

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list