On Thu, 27 Aug 2026 at 07:16, Daniel Henrique Barboza <[email protected]> wrote: > > Add a common helper to create a cfi-flash compatible flash subnode. > > This change only affects the existing 'virt' board for now but it will > be used by the future 'riscv-server-ref' board in the future.
Why do we have two flash devices? (I know why ARM does, where the code was copied from, but why does RISC-V?) > > No FDT changes intended. > > Signed-off-by: Daniel Henrique Barboza <[email protected]> > Reviewed-by: Philippe Mathieu-Daudé <[email protected]> > --- > hw/riscv/fdt-common.c | 12 ++++++++++++ > hw/riscv/virt.c | 18 ++---------------- > include/hw/riscv/fdt-common.h | 1 + > 3 files changed, 15 insertions(+), 16 deletions(-) > > diff --git a/hw/riscv/fdt-common.c b/hw/riscv/fdt-common.c > index 3a8da03cfb..6fcc1ce21f 100644 > --- a/hw/riscv/fdt-common.c > +++ b/hw/riscv/fdt-common.c > @@ -283,3 +283,15 @@ void riscv_pmu_generate_fdt_node(void *fdt, uint32_t > cmask, char *pmu_name) > qemu_fdt_setprop(fdt, pmu_name, "riscv,event-to-mhpmcounters", > fdt_event_ctr_map, sizeof(fdt_event_ctr_map)); > } > + > +void riscv_create_fdt_flash(void *fdt, hwaddr flashbase, hwaddr flashsize) > +{ > + g_autofree char *name = g_strdup_printf("/flash@%" PRIx64, flashbase); > + > + qemu_fdt_add_subnode(fdt, name); > + qemu_fdt_setprop_string(fdt, name, "compatible", "cfi-flash"); > + qemu_fdt_setprop_sized_cells(fdt, name, "reg", > + 2, flashbase, 2, flashsize, > + 2, flashbase + flashsize, 2, flashsize); > + qemu_fdt_setprop_cell(fdt, name, "bank-width", 4); > +} This is a copy of the code in hw/arm/virt.c, which was also copied by hw/loongarch/virt-fdt-build.c.
