ARM: OMAP2+: DT 'compatible' tweak for displays
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 19 Dec 2013 10:34:19 +0000 (12:34 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 19 Mar 2014 09:02:46 +0000 (11:02 +0200)
As there is no common panel framework in the kernel, we have OMAP
specific panel drivers. However, the DT data should be generic. This
brings the issue that some other platform could use the same panels, and
would need to create a driver with the same 'compatible' string as the
OMAP driver.

In the long run, we have to get a common panel framework. For the time
being, this patch solves the issue:

At early boot time, we go through the DT nodes looking for the panels
the kernel supports for OMAP. For each found node, the 'compatible'
string is prepended with "omapdss,", i.e. "sony,acx565akm" becomes
"omapdss,sony,acx565akm". The OMAP display drivers all have "omapdss,"
at the beginning of their compatible field.

This allows us to have generic DT data, but OMAP specific display
drivers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Archit Taneja <archit@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/board-generic.c
arch/arm/mach-omap2/common.h
arch/arm/mach-omap2/display.c

index fcb7f5c271c95d43870cc70573646595fb3579f3..0db371a88e5ecef7c6cc26639db4f7950bb8651e 100644 (file)
@@ -35,6 +35,8 @@ static struct of_device_id omap_dt_match_table[] __initdata = {
 
 static void __init omap_generic_init(void)
 {
+       omapdss_early_init_of();
+
        pdata_quirks_init(omap_dt_match_table);
 
        omapdss_init_of();
index 1864282dbddf93eb8330acfcc309bde97f2d52e5..d88aff7baff8d5e7adcc865836649ca5ce1fb4b8 100644 (file)
@@ -316,6 +316,7 @@ extern int omap_dss_reset(struct omap_hwmod *);
 int omap_clk_init(void);
 
 int __init omapdss_init_of(void);
+void __init omapdss_early_init_of(void);
 
 #endif /* __ASSEMBLER__ */
 #endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */
index a83ada38cae2150baaaedbfa21e11551209ffbc9..cf0cb35fa97287fe7cfa5c195b9fe76191f42234 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/delay.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 
 #include <video/omapdss.h>
 #include "omap_hwmod.h"
@@ -555,6 +556,67 @@ int omap_dss_reset(struct omap_hwmod *oh)
        return r;
 }
 
+/* list of 'compatible' nodes to convert to omapdss specific */
+static const char * const dss_compat_conv_list[] __initconst = {
+       "composite-connector",
+       "dvi-connector",
+       "hdmi-connector",
+       "panel-dpi",
+       "panel-dsi-cm",
+       "sony,acx565akm",
+       "svideo-connector",
+       "ti,tfp410",
+       "ti,tpd12s015",
+};
+
+/* prepend compatible string with "omapdss," */
+static __init void omapdss_omapify_node(struct device_node *node,
+       const char *compat)
+{
+       char *new_compat;
+       struct property *prop;
+
+       new_compat = kasprintf(GFP_KERNEL, "omapdss,%s", compat);
+
+       prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+
+       if (!prop) {
+               pr_err("omapdss_omapify_node: kzalloc failed\n");
+               return;
+       }
+
+       prop->name = "compatible";
+       prop->value = new_compat;
+       prop->length = strlen(new_compat) + 1;
+
+       of_update_property(node, prop);
+}
+
+/*
+ * As omapdss panel drivers are omapdss specific, but we want to define the
+ * DT-data in generic manner, we convert the compatible strings of the panel
+ * nodes from "panel-foo" to "omapdss,panel-foo". This way we can have both
+ * correct DT data and omapdss specific drivers.
+ *
+ * When we get generic panel drivers to the kernel, this will be removed.
+ */
+void __init omapdss_early_init_of(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(dss_compat_conv_list); ++i) {
+               const char *compat = dss_compat_conv_list[i];
+               struct device_node *node = NULL;
+
+               while ((node = of_find_compatible_node(node, NULL, compat))) {
+                       if (!of_device_is_available(node))
+                               continue;
+
+                       omapdss_omapify_node(node, compat);
+               }
+       }
+}
+
 struct device_node * __init omapdss_find_dss_of_node(void)
 {
        struct device_node *node;
This page took 0.027461 seconds and 5 git commands to generate.