drm/i915: Use the CRC gpio for panel enable/disable
authorShobhit Kumar <shobhit.kumar@intel.com>
Fri, 26 Jun 2015 09:02:09 +0000 (14:32 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 21 Jul 2015 07:22:43 +0000 (09:22 +0200)
The CRC (Crystal Cove) PMIC, controls the panel enable and disable
signals for BYT for dsi panels. This is indicated in the VBT fields. Use
that to initialize and use GPIO based control for these signals.

v2: Use the newer gpiod interface(Alexandre)
v3: Remove the redundant checks and unused code (Ville)
v4: Moved PWM vs SoC backlight #defines to intel_bios.h (Jani)

CC: Samuel Ortiz <sameo@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_bios.h
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_dsi.h

index af0b476527526c18a8d2fde082e3a7840b8036fb..f7ad6a585129a311ec003392e5de46c887f303a8 100644 (file)
@@ -778,6 +778,13 @@ int intel_parse_bios(struct drm_device *dev);
 #define MIPI_DSI_UNDEFINED_PANEL_ID    0
 #define MIPI_DSI_GENERIC_PANEL_ID      1
 
+/*
+ * PMIC vs SoC Backlight support specified in pwm_blc
+ * field in mipi_config block below.
+*/
+#define PPS_BLC_PMIC   0
+#define PPS_BLC_SOC    1
+
 struct mipi_config {
        u16 panel_id;
 
index b5a5558ecd6314c9014687125e4b6d5f671ab78b..c4db74a5e4e7bc9d7b7c340d65b34b4a6d88a342 100644 (file)
@@ -31,6 +31,7 @@
 #include <drm/drm_panel.h>
 #include <drm/drm_mipi_dsi.h>
 #include <linux/slab.h>
+#include <linux/gpio/consumer.h>
 #include "i915_drv.h"
 #include "intel_drv.h"
 #include "intel_dsi.h"
@@ -415,6 +416,12 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
        DRM_DEBUG_KMS("\n");
 
+       /* Panel Enable over CRC PMIC */
+       if (intel_dsi->gpio_panel)
+               gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
+
+       msleep(intel_dsi->panel_on_delay);
+
        /* Disable DPOunit clock gating, can stall pipe
         * and we need DPLL REFA always enabled */
        tmp = I915_READ(DPLL(pipe));
@@ -432,8 +439,6 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
        /* put device in ready state */
        intel_dsi_device_ready(encoder);
 
-       msleep(intel_dsi->panel_on_delay);
-
        drm_panel_prepare(intel_dsi->panel);
 
        for_each_dsi_port(port, intel_dsi->ports)
@@ -576,6 +581,10 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
        msleep(intel_dsi->panel_off_delay);
        msleep(intel_dsi->panel_pwr_cycle_delay);
+
+       /* Panel Disable over CRC PMIC */
+       if (intel_dsi->gpio_panel)
+               gpiod_set_value_cansleep(intel_dsi->gpio_panel, 0);
 }
 
 static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
@@ -955,6 +964,11 @@ static void intel_dsi_encoder_destroy(struct drm_encoder *encoder)
                /* XXX: Logically this call belongs in the panel driver. */
                drm_panel_remove(intel_dsi->panel);
        }
+
+       /* dispose of the gpios */
+       if (intel_dsi->gpio_panel)
+               gpiod_put(intel_dsi->gpio_panel);
+
        intel_encoder_destroy(encoder);
 }
 
@@ -1071,6 +1085,20 @@ void intel_dsi_init(struct drm_device *dev)
                goto err;
        }
 
+       /*
+        * In case of BYT with CRC PMIC, we need to use GPIO for
+        * Panel control.
+        */
+       if (dev_priv->vbt.dsi.config->pwm_blc == PPS_BLC_PMIC) {
+               intel_dsi->gpio_panel =
+                       gpiod_get(dev->dev, "panel", GPIOD_OUT_HIGH);
+
+               if (IS_ERR(intel_dsi->gpio_panel)) {
+                       DRM_ERROR("Failed to own gpio for panel control\n");
+                       intel_dsi->gpio_panel = NULL;
+               }
+       }
+
        intel_encoder->type = INTEL_OUTPUT_DSI;
        intel_encoder->cloneable = 0;
        drm_connector_init(dev, connector, &intel_dsi_connector_funcs,
index 2784ac442368a6a37e2f3d516406a38a63570e8d..42a68593e32aac97b8a0c43dcae13c9a5fcafcb7 100644 (file)
@@ -42,6 +42,9 @@ struct intel_dsi {
        struct drm_panel *panel;
        struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS];
 
+       /* GPIO Desc for CRC based Panel control */
+       struct gpio_desc *gpio_panel;
+
        struct intel_connector *attached_connector;
 
        /* bit mask of ports being driven */