]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/panel/panel-simple.c
drm/panel: simple: add support for overriding the pixel clock polarity
[karo-tx-linux.git] / drivers / gpu / drm / panel / panel-simple.c
index f356a7b32f08db68af20c542e251653d91725404..7bbb752332ff4651ee1b132fd270759de327c91d 100644 (file)
@@ -89,6 +89,12 @@ struct panel_simple {
        struct gpio_desc *enable_gpio;
 
        u32 bus_fmt_override;
+       u32 quirks;
+};
+
+enum {
+       PANEL_QUIRK_PIXDATA_NEGEDGE = BIT(0),
+       PANEL_QUIRK_PIXDATA_POSEDGE = BIT(1),
 };
 
 #define SP_DISPLAY_MODE(freq, ha, hfp, hs, hbp, va, vfp, vs, vbp, vr, flgs) { \
@@ -110,6 +116,15 @@ static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
        return container_of(panel, struct panel_simple, base);
 }
 
+static inline void panel_simple_apply_quirks(struct panel_simple *panel,
+                                            struct drm_display_info *info)
+{
+       if (panel->quirks & PANEL_QUIRK_PIXDATA_NEGEDGE)
+               info->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
+       if (panel->quirks & PANEL_QUIRK_PIXDATA_POSEDGE)
+               info->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
+}
+
 static int panel_simple_get_fixed_modes(struct panel_simple *panel)
 {
        struct drm_connector *connector = panel->base.connector;
@@ -175,6 +190,8 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel)
                drm_display_info_set_bus_formats(&connector->display_info,
                                                 &panel->desc->bus_format, 1);
        connector->display_info.bus_flags = panel->desc->bus_flags;
+       if (panel->quirks)
+               panel_simple_apply_quirks(panel, &connector->display_info);
 
        return num;
 }
@@ -308,6 +325,7 @@ static inline int panel_simple_check_quirks(struct device *dev,
                                            struct panel_simple *p)
 {
        const char *bus_fmt;
+       u32 clkpol;
 
        if (of_property_read_string(dev->of_node, "bus-format-override",
                                    &bus_fmt) == 0) {
@@ -329,6 +347,18 @@ static inline int panel_simple_check_quirks(struct device *dev,
                                bus_fmt);
                return p->bus_fmt_override ? 0 : -EINVAL;
        }
+
+       if (of_property_read_u32(dev->of_node, "pixelclk-active",
+                                &clkpol) == 0) {
+               if (clkpol & ~1) {
+                       dev_err(dev,
+                               "Invalid value for pixelclk-active: '%u' (should be <0> or <1>)\n",
+                               clkpol);
+                       return -EINVAL;
+               }
+               p->quirks |= clkpol ? PANEL_QUIRK_PIXDATA_POSEDGE :
+                       PANEL_QUIRK_PIXDATA_NEGEDGE;
+       }
        return 0;
 }