summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChen Guanqiao <chenguanqiao@kuaishou.com>2021-04-12 14:51:11 +0800
committerSimon Glass <sjg@chromium.org>2021-04-29 03:23:39 -0700
commitaa351a14bd0a78221014719d190b565be60cb4ce (patch)
treebb9c83d868e56ef811ef06229978ba2ac3b81628 /include
parentf1a83abe60b4ef8b2652e4c8e1d11a9afc909b71 (diff)
downloadu-boot-aa351a14bd0a78221014719d190b565be60cb4ce.tar.gz
u-boot-aa351a14bd0a78221014719d190b565be60cb4ce.tar.xz
u-boot-aa351a14bd0a78221014719d190b565be60cb4ce.zip
dm: core: Add size operations on device tree references
Add functions to add size of addresses in the device tree using ofnode references. If the size is not set, return FDT_SIZE_T_NONE. Signed-off-by: Chen Guanqiao <chenguanqiao@kuaishou.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/dm/ofnode.h10
-rw-r--r--include/fdtdec.h5
2 files changed, 13 insertions, 2 deletions
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 2c0597c407..8a69fd87da 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -511,6 +511,16 @@ phys_addr_t ofnode_get_addr_index(ofnode node, int index);
phys_addr_t ofnode_get_addr(ofnode node);
/**
+ * ofnode_get_size() - get size from a node
+ *
+ * This reads the register size from a node
+ *
+ * @node: node to read from
+ * @return size of the address, or FDT_SIZE_T_NONE if not present or invalid
+ */
+fdt_size_t ofnode_get_size(ofnode node);
+
+/**
* ofnode_stringlist_search() - find a string in a string list and return index
*
* Note that it is possible for this function to succeed on property values
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 62d1660973..e0a49b1e57 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -24,15 +24,16 @@
typedef phys_addr_t fdt_addr_t;
typedef phys_size_t fdt_size_t;
-#ifdef CONFIG_PHYS_64BIT
#define FDT_ADDR_T_NONE (-1U)
+#define FDT_SIZE_T_NONE (-1U)
+
+#ifdef CONFIG_PHYS_64BIT
#define fdt_addr_to_cpu(reg) be64_to_cpu(reg)
#define fdt_size_to_cpu(reg) be64_to_cpu(reg)
#define cpu_to_fdt_addr(reg) cpu_to_be64(reg)
#define cpu_to_fdt_size(reg) cpu_to_be64(reg)
typedef fdt64_t fdt_val_t;
#else
-#define FDT_ADDR_T_NONE (-1U)
#define fdt_addr_to_cpu(reg) be32_to_cpu(reg)
#define fdt_size_to_cpu(reg) be32_to_cpu(reg)
#define cpu_to_fdt_addr(reg) cpu_to_be32(reg)