aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding2019-03-21 19:10:01 +0100
committerSimon Glass2019-04-11 20:10:50 -0600
commit8153d53b9340e652f78efbf99979d951ba853458 (patch)
treed6b40768826194ba248e97cd35e0ab905e7021bb
parent4f253ad064689bc55eaba1c3e7d42f0f358a72c3 (diff)
fdtdec: Implement fdtdec_set_phandle()
This function can be used to set a phandle for a given node. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--include/fdtdec.h11
-rw-r--r--lib/fdtdec.c7
2 files changed, 18 insertions, 0 deletions
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 3f7538734a0..ba7f873b89e 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1021,6 +1021,17 @@ int fdtdec_setup_memory_banksize_fdt(const void *blob);
int fdtdec_setup_memory_banksize(void);
/**
+ * fdtdec_set_phandle() - sets the phandle of a given node
+ *
+ * @param blob FDT blob
+ * @param node offset in the FDT blob of the node whose phandle is to
+ * be set
+ * @param phandle phandle to set for the given node
+ * @return 0 on success or a negative error code on failure
+ */
+int fdtdec_set_phandle(void *blob, int node, uint32_t phandle);
+
+/**
* Set up the device tree ready for use
*/
int fdtdec_setup(void);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index a51dc5e9867..079a9b18aaa 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1261,6 +1261,13 @@ __weak void *board_fdt_blob_setup(void)
}
#endif
+int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
+{
+ fdt32_t value = cpu_to_fdt32(phandle);
+
+ return fdt_setprop(blob, node, "phandle", &value, sizeof(value));
+}
+
int fdtdec_setup(void)
{
#if CONFIG_IS_ENABLED(OF_CONTROL)