Re: [PATCH 08/13] hw/riscv/fdt-common, virt.c, tt_atlantis.c: add create_fdt_uart()
Daniel Henrique Barboza <[email protected]>
| Newsgroups | org.nongnu.qemu-riscv,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
On 8/26/2026 11:53 AM, Anirudh Srinivasan wrote: > Hi Daniel, > > On Tue, Aug 25, 2026 at 4:24 PM Daniel Henrique Barboza > <[email protected]> wrote: >> >> Add a common uart FDT helper to be used by 'virt' and 'tt-atlantis'. >> >> To accomodate both boards the helper is doing the following: >> - an 'additional_reg_props' flag is used to control whether we want >> 'reg-shift' and 'reg-io-width' elements added. OpenSBI won't boot >> with the tt-atlantis board without them, but 'virt' can't deal with >> them being added unconditionally either. >> - an 'is_serial0' flag is added to control whether we need to set >> additional properties related to the first serial. This is required >> because the 'virt' board adds two uarts in the FDT. >> >> No FDT changes intended. >> >> Signed-off-by: Daniel Henrique Barboza <[email protected]> >> --- >> hw/riscv/fdt-common.c | 39 +++++++++++++++++++++++++++++++ >> hw/riscv/tt_atlantis.c | 21 +---------------- >> hw/riscv/virt.c | 44 +++++++---------------------------- >> include/hw/riscv/fdt-common.h | 4 ++++ >> 4 files changed, 52 insertions(+), 56 deletions(-) >> >> diff --git a/hw/riscv/fdt-common.c b/hw/riscv/fdt-common.c >> index f31cc9d3cc..b3f3af3762 100644 >> --- a/hw/riscv/fdt-common.c >> +++ b/hw/riscv/fdt-common.c >> @@ -791,3 +791,42 @@ void create_fdt_socket_aclint(void *fdt, ACLINTFdtProps *props, >> g_free(name); >> } >> } >> + >> +void create_fdt_uart(void *fdt, const MemMapEntry *uart_mem, >> + int uart_irq, int aia_type, >> + bool additional_reg_props, bool is_serial0, >> + uint32_t irq_mmio_phandle) >> +{ >> + g_autofree char *name = NULL; >> + >> + name = g_strdup_printf("/soc/serial@%"HWADDR_PRIx, uart_mem->base); >> + qemu_fdt_add_subnode(fdt, name); >> + qemu_fdt_setprop_string(fdt, name, "compatible", "ns16550a"); >> + qemu_fdt_setprop_sized_cells(fdt, name, "reg", >> + 2, uart_mem->base, >> + 2, uart_mem->size); >> + >> + /* >> + * The tt-atlantis board requires these extra props in the >> + * DT, but adding them unconditionally will break OpenSBI >> + * for 'virt'. >> + */ >> + if (additional_reg_props) { >> + qemu_fdt_setprop_cell(fdt, name, "reg-shift", 2); >> + qemu_fdt_setprop_cell(fdt, name, "reg-io-width", 4); >> + } > > I think the issue is that atlantis uses a uart that has 32 bit > register spacing (0x0, 0x4, 0x8, 0xc....) rather than 8 bit spacing > (0x0, 0x1, 0x2...). So rather than "additional_reg_props", would a > name like "word_addressing" or "32_bit_spacing" make sense? Works for me. I'll rename it in v2. Thanks, Daniel > > Regards > Anirudh Srinivasan