summaryrefslogtreecommitdiff
path: root/lib/utils/fdt
diff options
context:
space:
mode:
authorZong Li <zong.li@sifive.com>2022-04-15 05:24:20 +0300
committerAnup Patel <anup@brainfault.org>2022-04-17 11:27:48 +0300
commit5c5cbb53a4fd2f7d2a7038b584f8ee01266cef04 (patch)
tree6b5b44ba31b880503dc722bd2a707b0d8b14e1f4 /lib/utils/fdt
parent3383d6a4d1461bb029b21fa53417382e34ae4906 (diff)
downloadopensbi-5c5cbb53a4fd2f7d2a7038b584f8ee01266cef04.tar.xz
lib: utils/serial: support 'reg-offset' property
reg-offset property is used for offset to apply to the mapbase from the start of the registers in 8250 UART. In Linux kernel, it has been handled in 8250 UART driver. dt-bindings: <linux>/Documentation/devicetree/bindings/serial/8250.yaml Signed-off-by: Zong Li <zong.li@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib/utils/fdt')
-rw-r--r--lib/utils/fdt/fdt_helper.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 4dd0602..9a35969 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -21,6 +21,7 @@
#define DEFAULT_UART_BAUD 115200
#define DEFAULT_UART_REG_SHIFT 0
#define DEFAULT_UART_REG_IO_WIDTH 1
+#define DEFAULT_UART_REG_OFFSET 0
#define DEFAULT_SIFIVE_UART_FREQ 0
#define DEFAULT_SIFIVE_UART_BAUD 115200
@@ -449,6 +450,12 @@ int fdt_parse_uart8250_node(void *fdt, int nodeoffset,
else
uart->reg_io_width = DEFAULT_UART_REG_IO_WIDTH;
+ val = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "reg-offset", &len);
+ if (len > 0 && val)
+ uart->reg_offset = fdt32_to_cpu(*val);
+ else
+ uart->reg_offset = DEFAULT_UART_REG_OFFSET;
+
return 0;
}