From: Ruslan Ruslichenko <[email protected]> The patch adds proper handling and registration for serial devices instantiated via FDT.
The devices with 'chardev' properties are connected to serial backends, if corresponding dts property serial id number is set. Signed-off-by: Ruslan Ruslichenko <[email protected]> --- hw/core/fdt_generic_util.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/core/fdt_generic_util.c b/hw/core/fdt_generic_util.c index 3179248142..c58a9ccdc7 100644 --- a/hw/core/fdt_generic_util.c +++ b/hw/core/fdt_generic_util.c @@ -36,6 +36,7 @@ #include "system/system.h" #include "system/reset.h" #include "qemu/cutils.h" +#include "chardev/char.h" #include "qemu/log.h" #include "qemu/config-file.h" #include "hw/core/boards.h" @@ -1216,6 +1217,7 @@ static int fdt_init_qdev(char *node_path, FDTMachineInfo *fdti, char *compat) props = qemu_devtree_get_props(fdti->fdt, node_path); for (prop = props; prop->name; prop++) { const char *propname = trim_vendor(prop->name); + int len = prop->len; ObjectProperty *p = NULL; p = object_property_find(OBJECT(dev), propname); @@ -1235,6 +1237,13 @@ static int fdt_init_qdev(char *node_path, FDTMachineInfo *fdti, char *compat) continue; } + /* Special case for chardevs. */ + if (!strcmp(propname, "chardev") && !strcmp(p->type, "str")) { + qdev_prop_set_chr(DEVICE(dev), "chardev", + serial_hd(get_int_be(prop->value, len))); + continue; + } + fdt_init_qdev_scalar_prop(OBJECT(dev), p, fdti, node_path, prop); } -- 2.43.0
