Skip to contentSkip to conversation

hw/riscv/virt: Add serial alias in DTB

RFC PATCH Superseded Vasilis Liaskovitis 2 participants 3 messages Jan 16, 2025 RISC-V

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 hw/riscv/virt: Add serial alias in DTB

This patch adds an "aliases" node with a "serial0" entry for the single UART in the riscv64 virt machine.

This was requested in Gitlab #2774. However, since the machine only has one UART at the moment, it's not clear that this addition makes sense.

---
 hw/riscv/virt.c | 2 ++
 1 file changed, 2 insertions(+)
hw/riscv/virt.c +2 -0
index 2bc5a9dd98..67b80e9430 100644
@@ -971,6 +971,8 @@ static void create_fdt_uart(RISCVVirtState *s, const MemMapEntry *memmap,
     }
 
     qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", name);
+    qemu_fdt_add_subnode(ms->fdt, "/aliases");
+    qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial0", name);
 }
 
 static void create_fdt_rtc(RISCVVirtState *s, const MemMapEntry *memmap,
Signature · 1 line
2.46.0
#1 lore raw
Quoted 8 lines · Vasilis Liaskovitis

This patch adds an "aliases" node with a "serial0" entry for the single UART in the riscv64 virt machine.

This was requested in Gitlab #2774. However, since the machine only has one UART at the moment, it's not clear that this addition makes sense.

s/Fixes/Resolves/ (see docs/devel/submitting-a-patch.rst)

Quoted 10 lines
---
 hw/riscv/virt.c | 2 ++
 1 file changed, 2 insertions(+)
hw/riscv/virt.c +0 -0
index 2bc5a9dd98..67b80e9430 100644

hw/riscv/virt.c static void create_fdt_uart(RISCVVirtState *s, const MemMapEntry *memmap, · line 974

Quoted 4 lines
hw/riscv/virt.c +1 -0
@@ -971,6 +971,8 @@ static void create_fdt_uart(RISCVVirtState *s, const MemMapEntry *memmap,
     }
 
     qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", name);
+    qemu_fdt_add_subnode(ms->fdt, "/aliases");

create_fdt_uart() is called at machine-done time, so we should create the /aliases node in create_fdt() in case we ever have other uses for it.

Quoted 7 lines
hw/riscv/virt.c +1 -0
+    qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial0", name);
 }
 
 static void create_fdt_rtc(RISCVVirtState *s, const MemMapEntry *memmap,
Signature · 1 line
2.46.0

Thanks,
drew

#2 lore raw
Quoted 3 lines · Andrew Jones

s/Fixes/Resolves/ (see docs/devel/submitting-a-patch.rst)

[..]

Quoted 5 lines
Quoted 2 lines
     qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", name);

+ qemu_fdt_add_subnode(ms->fdt, "/aliases");

create_fdt_uart() is called at machine-done time, so we should create the /aliases node in create_fdt() in case we ever have other uses for it.

thanks for the review, I am sending a v2 with the changes.

- Vasilis