Message ID | 20220416193034.538161-2-qemu@ben.fluff.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/4] device_tree: add qemu_fdt_setprop_reg64 helper | expand |
On Mon, Apr 18, 2022 at 7:15 AM Ben Dooks <qemu@ben.fluff.org> wrote: > > Add a macro qemu_fdt_setprop_reg64() to set the given > node's reg property directly from the memory map entry > to avoid open coding of the following: > > qemu_fdt_setprop_cells(fdt, nodename, "reg", > 0x0, memmap[SIFIVE_U_DEV_OTP].base, > 0x0, memmap[SIFIVE_U_DEV_OTP].size); > > Signed-off-by: Ben Dooks <qemu@ben.fluff.org> > --- > include/sysemu/device_tree.h | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h > index ef060a9759..28352e7fcb 100644 > --- a/include/sysemu/device_tree.h > +++ b/include/sysemu/device_tree.h > @@ -135,6 +135,21 @@ int qemu_fdt_add_path(void *fdt, const char *path); > sizeof(qdt_tmp)); \ > } while (0) > > +/** > + * qemu_fdt_setprop_reg64: > + * @fdt: the device tree path > + * @node_path: node to set property on > + * @map: the map entry to set the reg from > + * > + * A helper tp set the 'reg' node on the specified node from the given map > + * entry. > + */ > +#define qemu_fdt_setprop_reg64(fdt, path, map) \ Maybe the name should include memmap? qemu_fdt_setprop_reg64_memmap() ? Alistair > + qemu_fdt_setprop_cells(fdt, path, "reg", \ > + (map)->base >> 32, (map)->base, \ > + (map)->size >> 32, (map)->size) > + > + > void qemu_fdt_dumpdtb(void *fdt, int size); > > /** > -- > 2.35.1 > >
diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index ef060a9759..28352e7fcb 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -135,6 +135,21 @@ int qemu_fdt_add_path(void *fdt, const char *path); sizeof(qdt_tmp)); \ } while (0) +/** + * qemu_fdt_setprop_reg64: + * @fdt: the device tree path + * @node_path: node to set property on + * @map: the map entry to set the reg from + * + * A helper tp set the 'reg' node on the specified node from the given map + * entry. + */ +#define qemu_fdt_setprop_reg64(fdt, path, map) \ + qemu_fdt_setprop_cells(fdt, path, "reg", \ + (map)->base >> 32, (map)->base, \ + (map)->size >> 32, (map)->size) + + void qemu_fdt_dumpdtb(void *fdt, int size); /**
Add a macro qemu_fdt_setprop_reg64() to set the given node's reg property directly from the memory map entry to avoid open coding of the following: qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_DEV_OTP].base, 0x0, memmap[SIFIVE_U_DEV_OTP].size); Signed-off-by: Ben Dooks <qemu@ben.fluff.org> --- include/sysemu/device_tree.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)