]> git.sur5r.net Git - u-boot/commitdiff
Add additional fdt fixup helper functions
authorKumar Gala <galak@kernel.crashing.org>
Wed, 21 Nov 2007 19:30:15 +0000 (13:30 -0600)
committerKumar Gala <galak@kernel.crashing.org>
Wed, 21 Nov 2007 21:11:58 +0000 (15:11 -0600)
Added the following fdt fixup helpers:
 * do_fixup_by_prop{_u32} - Find matching nodes by property name/value
 * do_fixup_by_compat{_u32} - Find matching nodes by compat

The _u32 variants work the same only the property they are setting
is know to be a 32-bit integer instead of a byte buffer.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
common/fdt_support.c
include/fdt_support.h

index e848386fbef8344112d990ec9c3390e56a94fdb8..c67bb3d390f4f4524679bbec4c450b605c347a2a 100644 (file)
@@ -386,6 +386,61 @@ void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,
        do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
 }
 
+void do_fixup_by_prop(void *fdt,
+                     const char *pname, const void *pval, int plen,
+                     const char *prop, const void *val, int len,
+                     int create)
+{
+       int off;
+#if defined(DEBUG)
+       int i;
+       debug("Updating property '%s/%s' = ", node, prop);
+       for (i = 0; i < len; i++)
+               debug(" %.2x", *(u8*)(val+i));
+       debug("\n");
+#endif
+       off = fdt_node_offset_by_prop_value(fdt, -1, pname, pval, plen);
+       while (off != -FDT_ERR_NOTFOUND) {
+               if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
+                       fdt_setprop(fdt, off, prop, val, len);
+               off = fdt_node_offset_by_prop_value(fdt, off, pname, pval, plen);
+       }
+}
+
+void do_fixup_by_prop_u32(void *fdt,
+                         const char *pname, const void *pval, int plen,
+                         const char *prop, u32 val, int create)
+{
+       val = cpu_to_fdt32(val);
+       do_fixup_by_prop(fdt, pname, pval, plen, prop, &val, 4, create);
+}
+
+void do_fixup_by_compat(void *fdt, const char *compat,
+                       const char *prop, const void *val, int len, int create)
+{
+       int off = -1;
+#if defined(DEBUG)
+       int i;
+       debug("Updating property '%s/%s' = ", node, prop);
+       for (i = 0; i < len; i++)
+               debug(" %.2x", *(u8*)(val+i));
+       debug("\n");
+#endif
+       off = fdt_node_offset_by_compatible(fdt, -1, compat);
+       while (off != -FDT_ERR_NOTFOUND) {
+               if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
+                       fdt_setprop(fdt, off, prop, val, len);
+               off = fdt_node_offset_by_compatible(fdt, off, compat);
+       }
+}
+
+void do_fixup_by_compat_u32(void *fdt, const char *compat,
+                           const char *prop, u32 val, int create)
+{
+       val = cpu_to_fdt32(val);
+       do_fixup_by_compat(fdt, compat, prop, &val, 4, create);
+}
+
 void fdt_fixup_ethernet(void *fdt, bd_t *bd)
 {
        int node;
index 150dd2b22fc6bd622ea29f3c2c1d8efb96236a4c..8f781d4405bf59f15f923949ead5d7ab1533887a 100644 (file)
@@ -33,6 +33,17 @@ void do_fixup_by_path(void *fdt, const char *path, const char *prop,
                      const void *val, int len, int create);
 void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,
                          u32 val, int create);
+void do_fixup_by_prop(void *fdt,
+                     const char *pname, const void *pval, int plen,
+                     const char *prop, const void *val, int len,
+                     int create);
+void do_fixup_by_prop_u32(void *fdt,
+                         const char *pname, const void *pval, int plen,
+                         const char *prop, u32 val, int create);
+void do_fixup_by_compat(void *fdt, const char *compat,
+                       const char *prop, const void *val, int len, int create);
+void do_fixup_by_compat_u32(void *fdt, const char *compat,
+                           const char *prop, u32 val, int create);
 void fdt_fixup_ethernet(void *fdt, bd_t *bd);
 
 #ifdef CONFIG_OF_HAS_UBOOT_ENV