From 1611dcc053a319731e12255a7ad58ad002b2c38c Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Tue, 2 Dec 2025 13:42:50 +0800 Subject: [PATCH 1/5] [DM][OFW] Fixup fdt address reg and cells parse The bubble up should stop when the #xxx-cells is match. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/ofw/raw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/drivers/ofw/raw.c b/components/drivers/ofw/raw.c index 35e7aaa3435..9e7f47bb8e2 100755 --- a/components/drivers/ofw/raw.c +++ b/components/drivers/ofw/raw.c @@ -93,6 +93,7 @@ int fdt_io_addr_cells(void *fdt, int nodeoffset) if (cells_tmp) { cells = fdt32_to_cpu(*cells_tmp); + break; } } @@ -116,6 +117,7 @@ int fdt_io_size_cells(void *fdt, int nodeoffset) if (cells_tmp) { cells = fdt32_to_cpu(*cells_tmp); + break; } } From f1b6fc1d6506c255be2d462dc4ebf33dfac9ea6d Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Tue, 2 Dec 2025 13:45:39 +0800 Subject: [PATCH 2/5] [DM][OFW] Clean codes Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/ofw/base.c | 1 - components/drivers/ofw/io.c | 1 - 2 files changed, 2 deletions(-) diff --git a/components/drivers/ofw/base.c b/components/drivers/ofw/base.c index 744cc96f41b..1b0e761be3c 100644 --- a/components/drivers/ofw/base.c +++ b/components/drivers/ofw/base.c @@ -1763,7 +1763,6 @@ const char *rt_ofw_get_prop_fuzzy_name(const struct rt_ofw_node *np, const char return propname; } - struct rt_ofw_prop *rt_ofw_get_prop(const struct rt_ofw_node *np, const char *name, rt_ssize_t *out_length) { struct rt_ofw_prop *prop = RT_NULL; diff --git a/components/drivers/ofw/io.c b/components/drivers/ofw/io.c index b0a7526f5b6..a84df210a6e 100755 --- a/components/drivers/ofw/io.c +++ b/components/drivers/ofw/io.c @@ -155,7 +155,6 @@ rt_err_t rt_ofw_get_address(struct rt_ofw_node *np, int index, rt_uint64_t *out_ static rt_err_t ofw_get_address_by_name(struct rt_ofw_node *np, const char *name, rt_uint64_t *out_address, rt_uint64_t *out_size) - { int index = 0; rt_err_t err = -RT_EEMPTY; From b0c556f9604cb2a110c3ecffd08616a6b329e5b0 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Tue, 2 Dec 2025 13:46:21 +0800 Subject: [PATCH 3/5] [DM][OFW] Support only option name way for earlycon Like "earlycon=hvc earlycon=sbi"... Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/ofw/fdt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/drivers/ofw/fdt.c b/components/drivers/ofw/fdt.c index 0c8b2ce3a44..dce20f8c2e0 100644 --- a/components/drivers/ofw/fdt.c +++ b/components/drivers/ofw/fdt.c @@ -692,7 +692,11 @@ rt_err_t rt_fdt_scan_chosen_stdout(void) if (*options) { + int type_len_no_option; + type_len = strchrnul(options, ',') - options; + type_len_no_option = strchrnul(options, ' ') - options; + type_len = rt_min(type_len, type_len_no_option); } } @@ -795,6 +799,10 @@ rt_err_t rt_fdt_scan_chosen_stdout(void) LOG_I("Earlycon: %s at MMIO/PIO %p (options '%s')", con_type, fdt_earlycon.mmio, fdt_earlycon.options); } + else if (con_type) + { + LOG_I("Earlycon: %s (options '%s')", con_type, fdt_earlycon.options); + } return err; } From 4473ae37e29824f2cc077d08f659eb855c5b1e77 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Tue, 2 Dec 2025 13:47:55 +0800 Subject: [PATCH 4/5] [DM][OFW] Find the console device when using "stdout-path" "stdout-path" has path and option, we should find the console device by dts path. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/ofw/ofw.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/components/drivers/ofw/ofw.c b/components/drivers/ofw/ofw.c index b743700ebc7..4e18de790ed 100644 --- a/components/drivers/ofw/ofw.c +++ b/components/drivers/ofw/ofw.c @@ -307,7 +307,26 @@ rt_err_t rt_ofw_console_setup(void) if (err == -RT_ENOSYS && !rt_ofw_prop_read_string(ofw_node_chosen, "stdout-path", &stdout_path)) { - struct rt_ofw_node *stdout_np = rt_ofw_find_node_by_path(stdout_path); + struct rt_ofw_node *stdout_np; + + if (*stdout_path != '/' && ofw_node_aliases) + { + int alias_len; + struct rt_ofw_prop *prop; + + alias_len = strchrnul(stdout_path, ':') - stdout_path; + + rt_ofw_foreach_prop(ofw_node_aliases, prop) + { + if (!rt_strncmp(prop->name, stdout_path, alias_len)) + { + stdout_path = prop->value; + break; + } + } + } + + stdout_np = rt_ofw_find_node_by_path(stdout_path); if (stdout_np && (ofw_name = ofw_console_serial_find(con_name, stdout_np))) { From a38cfe3420ed8b420d59e508b0ab50b8da609fff Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Tue, 9 Dec 2025 17:52:03 +0800 Subject: [PATCH 5/5] [DM/OFW] Request a PIC platform device when no init Some device is not a PIC driver but platform driver. We should request it auto. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/ofw/irq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/drivers/ofw/irq.c b/components/drivers/ofw/irq.c index f15c511dc05..bd88572c743 100755 --- a/components/drivers/ofw/irq.c +++ b/components/drivers/ofw/irq.c @@ -14,6 +14,7 @@ #include #include #include +#include #define DBG_TAG "rtdm.ofw" #define DBG_LVL DBG_INFO @@ -525,8 +526,15 @@ struct rt_ofw_node *rt_ofw_find_irq_parent(struct rt_ofw_node *np, int *out_inte static int ofw_map_irq(struct rt_ofw_cell_args *irq_args) { int irq; + struct rt_pic *pic; struct rt_ofw_node *ic_np = irq_args->data; - struct rt_pic *pic = rt_pic_dynamic_cast(rt_ofw_data(ic_np)); + + if (!rt_ofw_data(ic_np)) + { + rt_platform_ofw_request(ic_np); + } + + pic = rt_pic_dynamic_cast(rt_ofw_data(ic_np)); /* args.data is "interrupt-controller" */ if (pic)