Skip to content

Commit

Permalink
drm/i915: Use the CRC gpio for panel enable/disable
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Alexandre Courbot <[email protected]>
Cc: Thierry Reding <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Reviewed-by: Jani Nikula <[email protected]>
Tested-by: Ville Syrjälä <[email protected]>
Signed-off-by: Shobhit Kumar <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
  • Loading branch information
Shobhit Kumar authored and danvet committed Jul 21, 2015
1 parent a3f37a1 commit fc45e82
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
7 changes: 7 additions & 0 deletions drivers/gpu/drm/i915/intel_bios.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
32 changes: 30 additions & 2 deletions drivers/gpu/drm/i915/intel_dsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/intel_dsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit fc45e82

Please sign in to comment.