qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/4] device_tree: add qemu_fdt_setprop_reg64_map helper


From: Ben Dooks
Subject: [PATCH 1/4] device_tree: add qemu_fdt_setprop_reg64_map helper
Date: Sat, 18 Jun 2022 21:14:30 +0100

Add a macro qemu_fdt_setprop_reg64_map() 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>
--
v2:
- changed qemu_fdt_setprop_reg64 to qemu_fdt_setprop_reg64_map
---
 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..79ce009a22 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_map:
+ * @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_map(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);
 
 /**
-- 
2.35.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]