Skip to content

Commit 213e08a

Browse files
committed
drm/i915/bxt: add bxt dsi gpio element support
Request the GPIO by index through the consumer API. For now, use a quick hack to store the already requested ones, simply because I have no idea whether this actually works or not, and I have no way to test it. v2 by Mika: switch *NULL* to *"panel"* when requesting gpio for MIPI/DSI panel. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Mika Kahola <mika.kahola@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1480923034-21916-1-git-send-email-mika.kahola@intel.com
1 parent 731035f commit 213e08a

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

‎drivers/gpu/drm/i915/intel_dsi_panel_vbt.c‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <drm/drm_edid.h>
3030
#include <drm/i915_drm.h>
3131
#include <drm/drm_panel.h>
32+
#include <linux/gpio/consumer.h>
3233
#include <linux/slab.h>
3334
#include <video/mipi_display.h>
3435
#include <asm/intel-mid.h>
@@ -305,19 +306,44 @@ static void chv_exec_gpio(struct drm_i915_private *dev_priv,
305306
mutex_unlock(&dev_priv->sb_lock);
306307
}
307308

309+
static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
310+
u8 gpio_source, u8 gpio_index, bool value)
311+
{
312+
/* XXX: this table is a quick ugly hack. */
313+
static struct gpio_desc *bxt_gpio_table[U8_MAX + 1];
314+
struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index];
315+
316+
if (!gpio_desc) {
317+
gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
318+
"panel", gpio_index,
319+
value ? GPIOD_OUT_LOW :
320+
GPIOD_OUT_HIGH);
321+
322+
if (IS_ERR_OR_NULL(gpio_desc)) {
323+
DRM_ERROR("GPIO index %u request failed (%ld)\n",
324+
gpio_index, PTR_ERR(gpio_desc));
325+
return;
326+
}
327+
328+
bxt_gpio_table[gpio_index] = gpio_desc;
329+
}
330+
331+
gpiod_set_value(gpio_desc, value);
332+
}
333+
308334
static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
309335
{
310336
struct drm_device *dev = intel_dsi->base.base.dev;
311337
struct drm_i915_private *dev_priv = to_i915(dev);
312-
u8 gpio_source, gpio_index;
338+
u8 gpio_source, gpio_index = 0, gpio_number;
313339
bool value;
314340

315341
DRM_DEBUG_KMS("\n");
316342

317343
if (dev_priv->vbt.dsi.seq_version >= 3)
318-
data++;
344+
gpio_index = *data++;
319345

320-
gpio_index = *data++;
346+
gpio_number = *data++;
321347

322348
/* gpio source in sequence v2 only */
323349
if (dev_priv->vbt.dsi.seq_version == 2)
@@ -329,11 +355,11 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
329355
value = *data++ & 1;
330356

331357
if (IS_VALLEYVIEW(dev_priv))
332-
vlv_exec_gpio(dev_priv, gpio_source, gpio_index, value);
358+
vlv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
333359
else if (IS_CHERRYVIEW(dev_priv))
334-
chv_exec_gpio(dev_priv, gpio_source, gpio_index, value);
360+
chv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
335361
else
336-
DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
362+
bxt_exec_gpio(dev_priv, gpio_source, gpio_index, value);
337363

338364
return data;
339365
}

0 commit comments

Comments
 (0)