summaryrefslogtreecommitdiff
path: root/include/fdtdec.h
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2019-03-21 19:10:00 +0100
committerSimon Glass <sjg@chromium.org>2019-04-11 20:10:50 -0600
commit4f253ad064689bc55eaba1c3e7d42f0f358a72c3 (patch)
tree0b4f87476ac601f441ec6294b42faf4da32a1748 /include/fdtdec.h
parent155d0a08fb9bf0ab39c3db8961bd618f49897630 (diff)
fdtdec: Add fdt_{addr, size}_unpack() helpers
These helpers can be used to unpack variables of type fdt_addr_t and fdt_size_t into a pair of 32-bit variables. This is useful in cases where such variables need to be written to properties (such as "reg") of a device tree node where they need to be split into cells. Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'include/fdtdec.h')
-rw-r--r--include/fdtdec.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/fdtdec.h b/include/fdtdec.h
index be34dca756..3f7538734a 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -23,6 +23,31 @@
*/
typedef phys_addr_t fdt_addr_t;
typedef phys_size_t fdt_size_t;
+
+static inline fdt32_t fdt_addr_unpack(fdt_addr_t addr, fdt32_t *upper)
+{
+ if (upper)
+#ifdef CONFIG_PHYS_64BIT
+ *upper = addr >> 32;
+#else
+ *upper = 0;
+#endif
+
+ return addr;
+}
+
+static inline fdt32_t fdt_size_unpack(fdt_size_t size, fdt32_t *upper)
+{
+ if (upper)
+#ifdef CONFIG_PHYS_64BIT
+ *upper = size >> 32;
+#else
+ *upper = 0;
+#endif
+
+ return size;
+}
+
#ifdef CONFIG_PHYS_64BIT
#define FDT_ADDR_T_NONE (-1U)
#define fdt_addr_to_cpu(reg) be64_to_cpu(reg)