diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2023-09-19 14:50:26 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2023-09-19 14:50:26 +0100 |
commit | db21663150813a4fd0e572c2dcd5badde1620581 (patch) | |
tree | 47d8e0c92cd67d0f79fc57dd031200575aa35bd7 | |
parent | b1256560747cf084a7ee27f406fba6a938f32803 (diff) |
serial aliases in dtb
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | hw/arm/virt.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/arm/virt.c b/hw/arm/virt.c index c89faf2ca7..fb3559701e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -280,6 +280,8 @@ static void create_fdt(VirtMachineState *vms) } } + qemu_fdt_add_subnode(fdt, "/aliases"); + /* Clock node, for the benefit of the UART. The kernel device tree * binding documentation claims the PL011 node clock properties are * optional but in practice if you omit them the kernel refuses to @@ -907,11 +909,18 @@ static void create_uart(const VirtMachineState *vms, int uart, qemu_fdt_setprop(ms->fdt, nodename, "clock-names", clocknames, sizeof(clocknames)); + /* + * We set the serial0, serial1 aliases so that Linux reliably + * assigns them to ttyAMA0, ttyAMA1 regardless of the order of the + * nodes in the dtb or any future changes to Linux's dtb parsing. + */ switch(uart) { case VIRT_UART0: qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodename); + qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial0", nodename); break; case VIRT_UART1: + qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial1", nodename); if (vms->secure) { qemu_fdt_setprop_string(ms->fdt, nodename, "status", "disabled"); qemu_fdt_setprop_string(ms->fdt, nodename, "secure-status", "okay"); |