Skip to content

Commit f39a862

Browse files
authored
[drivers][ofw] Update OFW #11004
Fixup fdt address reg and cells parse. Support only option name way for earlycon. Find the console device when using "stdout-path".
1 parent d9ca9c4 commit f39a862

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

components/drivers/ofw/base.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,6 @@ const char *rt_ofw_get_prop_fuzzy_name(const struct rt_ofw_node *np, const char
17631763
return propname;
17641764
}
17651765

1766-
17671766
struct rt_ofw_prop *rt_ofw_get_prop(const struct rt_ofw_node *np, const char *name, rt_ssize_t *out_length)
17681767
{
17691768
struct rt_ofw_prop *prop = RT_NULL;

components/drivers/ofw/fdt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,11 @@ rt_err_t rt_fdt_scan_chosen_stdout(void)
692692

693693
if (*options)
694694
{
695+
int type_len_no_option;
696+
695697
type_len = strchrnul(options, ',') - options;
698+
type_len_no_option = strchrnul(options, ' ') - options;
699+
type_len = rt_min(type_len, type_len_no_option);
696700
}
697701
}
698702

@@ -795,6 +799,10 @@ rt_err_t rt_fdt_scan_chosen_stdout(void)
795799
LOG_I("Earlycon: %s at MMIO/PIO %p (options '%s')",
796800
con_type, fdt_earlycon.mmio, fdt_earlycon.options);
797801
}
802+
else if (con_type)
803+
{
804+
LOG_I("Earlycon: %s (options '%s')", con_type, fdt_earlycon.options);
805+
}
798806

799807
return err;
800808
}

components/drivers/ofw/io.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ rt_err_t rt_ofw_get_address(struct rt_ofw_node *np, int index, rt_uint64_t *out_
155155

156156
static rt_err_t ofw_get_address_by_name(struct rt_ofw_node *np, const char *name,
157157
rt_uint64_t *out_address, rt_uint64_t *out_size)
158-
159158
{
160159
int index = 0;
161160
rt_err_t err = -RT_EEMPTY;

components/drivers/ofw/irq.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <drivers/ofw.h>
1515
#include <drivers/ofw_io.h>
1616
#include <drivers/ofw_irq.h>
17+
#include <drivers/platform.h>
1718

1819
#define DBG_TAG "rtdm.ofw"
1920
#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
525526
static int ofw_map_irq(struct rt_ofw_cell_args *irq_args)
526527
{
527528
int irq;
529+
struct rt_pic *pic;
528530
struct rt_ofw_node *ic_np = irq_args->data;
529-
struct rt_pic *pic = rt_pic_dynamic_cast(rt_ofw_data(ic_np));
531+
532+
if (!rt_ofw_data(ic_np))
533+
{
534+
rt_platform_ofw_request(ic_np);
535+
}
536+
537+
pic = rt_pic_dynamic_cast(rt_ofw_data(ic_np));
530538

531539
/* args.data is "interrupt-controller" */
532540
if (pic)

components/drivers/ofw/ofw.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,26 @@ rt_err_t rt_ofw_console_setup(void)
307307

308308
if (err == -RT_ENOSYS && !rt_ofw_prop_read_string(ofw_node_chosen, "stdout-path", &stdout_path))
309309
{
310-
struct rt_ofw_node *stdout_np = rt_ofw_find_node_by_path(stdout_path);
310+
struct rt_ofw_node *stdout_np;
311+
312+
if (*stdout_path != '/' && ofw_node_aliases)
313+
{
314+
int alias_len;
315+
struct rt_ofw_prop *prop;
316+
317+
alias_len = strchrnul(stdout_path, ':') - stdout_path;
318+
319+
rt_ofw_foreach_prop(ofw_node_aliases, prop)
320+
{
321+
if (!rt_strncmp(prop->name, stdout_path, alias_len))
322+
{
323+
stdout_path = prop->value;
324+
break;
325+
}
326+
}
327+
}
328+
329+
stdout_np = rt_ofw_find_node_by_path(stdout_path);
311330

312331
if (stdout_np && (ofw_name = ofw_console_serial_find(con_name, stdout_np)))
313332
{

components/drivers/ofw/raw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ int fdt_io_addr_cells(void *fdt, int nodeoffset)
9393
if (cells_tmp)
9494
{
9595
cells = fdt32_to_cpu(*cells_tmp);
96+
break;
9697
}
9798
}
9899

@@ -116,6 +117,7 @@ int fdt_io_size_cells(void *fdt, int nodeoffset)
116117
if (cells_tmp)
117118
{
118119
cells = fdt32_to_cpu(*cells_tmp);
120+
break;
119121
}
120122
}
121123

0 commit comments

Comments
 (0)