]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fdt: introduce fdt_create_phandle()
authorGerald Van Baren <gvb@unssw.com>
Fri, 15 Jul 2011 01:40:10 +0000 (21:40 -0400)
committerGerald Van Baren <gvb@unssw.com>
Fri, 15 Jul 2011 01:43:45 +0000 (21:43 -0400)
The ePAPR specification says that phandle properties should be called
"phandle", and not "linux,phandle".  To facilitate the migration from
"linux,phandle" to "phandle", introduce function fdt_create_phandle(),
which creates a phandle in a given node.  For now, we create both the
"phandle" and "linux,phandle" properties.  A later version of this
function will remove support for "linux,phandle".

Signed-off-by: Timur Tabi <timur@freescale.com>
common/fdt_support.c
include/fdt_support.h

index 150a3c5a591dadacf72e8daafc77b199a43c47d7..19b2ef6ea4bc18ccf961fe0ed075e9c5a12fa0f2 100644 (file)
@@ -1195,6 +1195,46 @@ int fdt_alloc_phandle(void *blob)
        return phandle + 1;
 }
 
+/*
+ * fdt_create_phandle: Create a phandle property for the given node
+ *
+ * @fdt: ptr to device tree
+ * @nodeoffset: node to update
+ * @phandle: phandle value to set (must be unique)
+*/
+int fdt_create_phandle(void *fdt, int nodeoffset, uint32_t phandle)
+{
+       int ret;
+
+#ifdef DEBUG
+       int off = fdt_node_offset_by_phandle(fdt, phandle);
+
+       if ((off >= 0) && (off != nodeoffset)) {
+               char buf[64];
+
+               fdt_get_path(fdt, nodeoffset, buf, sizeof(buf));
+               printf("Trying to update node %s with phandle %u ",
+                      buf, phandle);
+
+               fdt_get_path(fdt, off, buf, sizeof(buf));
+               printf("that already exists in node %s.\n", buf);
+               return -FDT_ERR_BADPHANDLE;
+       }
+#endif
+
+       ret = fdt_setprop_cell(fdt, nodeoffset, "phandle", phandle);
+       if (ret < 0)
+               return ret;
+
+       /*
+        * For now, also set the deprecated "linux,phandle" property, so that we
+        * don't break older kernels.
+        */
+       ret = fdt_setprop_cell(fdt, nodeoffset, "linux,phandle", phandle);
+
+       return ret;
+}
+
 #if defined(CONFIG_VIDEO)
 int fdt_add_edid(void *blob, const char *compat, unsigned char *edid_buf)
 {
index 382f63221ddf7092a983c7c74e007e48dfa24168..863024ff775d4264c2d90695d3006b217bcc7166 100644 (file)
@@ -89,6 +89,7 @@ u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr);
 int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
                                        phys_addr_t compat_off);
 int fdt_alloc_phandle(void *blob);
+int fdt_create_phandle(void *fdt, int nodeoffset, uint32_t phandle);
 int fdt_add_edid(void *blob, const char *compat, unsigned char *buf);
 
 int fdt_verify_alias_address(void *fdt, int anode, const char *alias,