summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-04-24 12:51:34 +0300
committerAnup Patel <anup@brainfault.org>2020-05-01 07:06:13 +0300
commit01a8c8eebb6f219afb3873fce82a11a7cf49a03e (patch)
treeaf88966d45c52d7a5a919bb35dc647e3ca30d3b3 /lib/utils
parente6c1345f89f0c2fa5d8b0dde733eb80366056632 (diff)
downloadopensbi-01a8c8eebb6f219afb3873fce82a11a7cf49a03e.tar.xz
lib: utils: Improve fdt_parse_uart8250() API
The information parsed by fdt_parse_uart8250() API is not complete. We need to parse reg-shift and reg-io-width for UART 8520 as well. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/fdt/fdt_helper.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 07f7221..f620e74 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -13,6 +13,11 @@
#include <sbi/sbi_scratch.h>
#include <sbi_utils/fdt/fdt_helper.h>
+#define DEFAULT_UART_FREQ 0
+#define DEFAULT_UART_BAUD 115200
+#define DEFAULT_UART_REG_SHIFT 0
+#define DEFAULT_UART_REG_IO_WIDTH 1
+
static int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr,
unsigned long *size)
{
@@ -81,10 +86,26 @@ int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
val = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "clock-frequency", &len);
if (len > 0 && val)
uart->freq = fdt32_to_cpu(*val);
+ else
+ uart->freq = DEFAULT_UART_FREQ;
val = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "current-speed", &len);
if (len > 0 && val)
uart->baud = fdt32_to_cpu(*val);
+ else
+ uart->baud = DEFAULT_UART_BAUD;
+
+ val = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "reg-shift", &len);
+ if (len > 0 && val)
+ uart->reg_shift = fdt32_to_cpu(*val);
+ else
+ uart->reg_shift = DEFAULT_UART_REG_SHIFT;
+
+ val = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "reg-io-width", &len);
+ if (len > 0 && val)
+ uart->reg_io_width = fdt32_to_cpu(*val);
+ else
+ uart->reg_io_width = DEFAULT_UART_REG_IO_WIDTH;
return 0;
}