]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fdt: add new fdt_fixup_display function to configure display
authorTim Harvey <tharvey@gateworks.com>
Wed, 8 Apr 2015 18:45:39 +0000 (11:45 -0700)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 12:42:47 +0000 (14:42 +0200)
Add 'fdt_fixup_display' function to fixup device-tree native-mode property
of display-timings node to select timings for a specific display.
This is useful if a device-tree has configurations for multiple
display timings for undetectable displays.

see kernel Documentation/devicetree/bindings/video/display-timing.txt

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Acked-by: Simon Glass <sjg@chromium.org>
common/fdt_support.c
include/fdt_support.h

index 8fbe6b5132c0c98c785f32a54f31e1c17fe3ae54..8011083807639fa328d93932434759e6ad90f040 100644 (file)
@@ -1576,3 +1576,32 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
 
        return 0;
 }
+
+/*
+ * Update native-mode in display-timings from display environment variable.
+ * The node to update are specified by path.
+ */
+int fdt_fixup_display(void *blob, const char *path, const char *display)
+{
+       int off, toff;
+
+       if (!display || !path)
+               return -FDT_ERR_NOTFOUND;
+
+       toff = fdt_path_offset(blob, path);
+       if (toff >= 0)
+               toff = fdt_subnode_offset(blob, toff, "display-timings");
+       if (toff < 0)
+               return toff;
+
+       for (off = fdt_first_subnode(blob, toff);
+            off >= 0;
+            off = fdt_next_subnode(blob, off)) {
+               uint32_t h = fdt_get_phandle(blob, off);
+               debug("%s:0x%x\n", fdt_get_name(blob, off, NULL),
+                     fdt32_to_cpu(h));
+               if (strcasecmp(fdt_get_name(blob, off, NULL), display) == 0)
+                       return fdt_setprop_u32(blob, toff, "native-mode", h);
+       }
+       return toff;
+}
index dc51e28171065d1f4a0c1b253d03274d8c9163cd..86c203ceb3bc751fe4dc45c2490850cfc134dd57 100644 (file)
@@ -47,7 +47,19 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
                         const void *val, int len, int create);
 void fdt_fixup_qe_firmware(void *fdt);
 
-#if defined(__UBOOT__)
+/**
+ * Update native-mode property of display-timings node to the phandle
+ * of the timings matching a display by name (case insensitive).
+ *
+ * see kernel Documentation/devicetree/bindings/video/display-timing.txt
+ *
+ * @param blob         FDT blob to update
+ * @param path         path within dt
+ * @param display      name of display timing to match
+ * @return 0 if ok, or -FDT_ERR_... on error
+ */
+int fdt_fixup_display(void *blob, const char *path, const char *display);
+
 #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)
 void fdt_fixup_dr_usb(void *blob, bd_t *bd);
 #else