Skip to contentSkip to conversation

drm/i915/bxt: add bxt dsi gpio element support

PATCH In review Jani Nikula 2 participants 3 messages Nov 15, 2016 – Dec 2, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 38 +++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +32 -6
index 9f279a3d0f74..41e0eeac97f4 100644
@@ -29,6 +29,7 @@
 #include <drm/drm_edid.h>
 #include <drm/i915_drm.h>
 #include <drm/drm_panel.h>
+#include <linux/gpio/consumer.h>
 #include <linux/slab.h>
 #include <video/mipi_display.h>
 #include <asm/intel-mid.h>
@@ -304,19 +305,44 @@ static void chv_exec_gpio(struct drm_i915_private *dev_priv,
 	mutex_unlock(&dev_priv->sb_lock);
 }
 
+static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
+			  u8 gpio_source, u8 gpio_index, bool value)
+{
+	/* XXX: this table is a quick ugly hack. */
+	static struct gpio_desc *bxt_gpio_table[U8_MAX + 1];
+	struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index];
+
+	if (!gpio_desc) {
+		gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
+						 NULL, gpio_index,
+						 value ? GPIOD_OUT_LOW :
+						 GPIOD_OUT_HIGH);
+
+		if (IS_ERR_OR_NULL(gpio_desc)) {
+			DRM_ERROR("GPIO index %u request failed (%ld)\n",
+				  gpio_index, PTR_ERR(gpio_desc));
+			return;
+		}
+
+		bxt_gpio_table[gpio_index] = gpio_desc;
+	}
+
+	gpiod_set_value(gpio_desc, value);
+}
+
 static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 {
 	struct drm_device *dev = intel_dsi->base.base.dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	u8 gpio_source, gpio_index;
+	u8 gpio_source, gpio_index = 0, gpio_number;
 	bool value;
 
 	DRM_DEBUG_KMS("\n");
 
 	if (dev_priv->vbt.dsi.seq_version >= 3)
-		data++;
+		gpio_index = *data++;
 
-	gpio_index = *data++;
+	gpio_number = *data++;
 
 	/* gpio source in sequence v2 only */
 	if (dev_priv->vbt.dsi.seq_version == 2)
@@ -328,11 +354,11 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 	value = *data++ & 1;
 
 	if (IS_VALLEYVIEW(dev_priv))
-		vlv_exec_gpio(dev_priv, gpio_source, gpio_index, value);
+		vlv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
 	else if (IS_CHERRYVIEW(dev_priv))
-		chv_exec_gpio(dev_priv, gpio_source, gpio_index, value);
+		chv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
 	else
-		DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
+		bxt_exec_gpio(dev_priv, gpio_source, gpio_index, value);
 
 	return data;
 }
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 31 lines · Jani Nikula

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.

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 38
+++++++++++++++++++++++++-----

 1 file changed, 32 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
index 9f279a3d0f74..41e0eeac97f4 100644
@@ -29,6 +29,7 @@
  #include <drm/drm_edid.h>
  #include <drm/i915_drm.h>
  #include <drm/drm_panel.h>
+#include <linux/gpio/consumer.h>
  #include <linux/slab.h>
  #include <video/mipi_display.h>
  #include <asm/intel-mid.h>
@@ -304,19 +305,44 @@ static void chv_exec_gpio(struct
 drm_i915_private *dev_priv,
  	mutex_unlock(&dev_priv->sb_lock);
  }

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static void chv_exec_gpio(struct drm_i915_private *dev_priv, · line 317

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +10 -0
+static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
+			  u8 gpio_source, u8 gpio_index, bool value)
+{
+	/* XXX: this table is a quick ugly hack. */
+	static struct gpio_desc *bxt_gpio_table[U8_MAX + 1];
+	struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index];
+
+	if (!gpio_desc) {
+		gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
+						 NULL, gpio_index,

This patch works better with *NULL* replaced by *"panel"*. With this change we can access GPIO's without GPIO index request failures.

Quoted 59 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+						 value ?

GPIOD_OUT_LOW :

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
+						 GPIOD_OUT_HIGH);
+
+		if (IS_ERR_OR_NULL(gpio_desc)) {
+			DRM_ERROR("GPIO index %u request failed

(%ld)\n",

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +10 -0
+				  gpio_index, PTR_ERR(gpio_desc));
+			return;
+		}
+
+		bxt_gpio_table[gpio_index] = gpio_desc;
+	}
+
+	gpiod_set_value(gpio_desc, value);
+}
+

 static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 {
  struct drm_device *dev = intel_dsi->base.base.dev; struct drm_i915_private *dev_priv = to_i915(dev);

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -1
-	u8 gpio_source, gpio_index;
+	u8 gpio_source, gpio_index = 0, gpio_number;

  bool value;

  DRM_DEBUG_KMS("\n");

  if (dev_priv->vbt.dsi.seq_version >= 3)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -1
-		data++;
+		gpio_index = *data++;

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -1
-	gpio_index = *data++;
+	gpio_number = *data++;


  /* gpio source in sequence v2 only */
  if (dev_priv->vbt.dsi.seq_version == 2)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
@@ -328,11 +354,11 @@ static const u8 *mipi_exec_gpio(struct
 intel_dsi *intel_dsi, const u8 *data)
  	value = *data++ & 1;


  if (IS_VALLEYVIEW(dev_priv))

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
-		vlv_exec_gpio(dev_priv, gpio_source, gpio_index,

value);

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+		vlv_exec_gpio(dev_priv, gpio_source, gpio_number,

value);
  else if (IS_CHERRYVIEW(dev_priv))

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
-		chv_exec_gpio(dev_priv, gpio_source, gpio_index,

value);

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+		chv_exec_gpio(dev_priv, gpio_source, gpio_number,

value);
  else

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
-		DRM_DEBUG_KMS("GPIO element not supported on this

platform\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+		bxt_exec_gpio(dev_priv, gpio_source, gpio_index,

value);

  return data;
 }

Signature · 6 lines
Mika Kahola - Intel OTC

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 36 lines · Mika Kahola
Quoted 35 lines · Jani Nikula

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.

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 38
+++++++++++++++++++++++++-----

 1 file changed, 32 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
index 9f279a3d0f74..41e0eeac97f4 100644
@@ -29,6 +29,7 @@
  #include <drm/drm_edid.h>
  #include <drm/i915_drm.h>
  #include <drm/drm_panel.h>
+#include <linux/gpio/consumer.h>
  #include <linux/slab.h>
  #include <video/mipi_display.h>
  #include <asm/intel-mid.h>
@@ -304,19 +305,44 @@ static void chv_exec_gpio(struct
 drm_i915_private *dev_priv,
  	mutex_unlock(&dev_priv->sb_lock);
  }

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
+static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
+			  u8 gpio_source, u8 gpio_index, bool value)
+{
+	/* XXX: this table is a quick ugly hack. */
Quoted 8 lines

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static void chv_exec_gpio(struct drm_i915_private *dev_priv, · line 317

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -0
+	static struct gpio_desc *bxt_gpio_table[U8_MAX + 1];
+	struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index];
+
+	if (!gpio_desc) {
+		gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
+						 NULL, gpio_index,

This patch works better with *NULL* replaced by *"panel"*. With this change we can access GPIO's without GPIO index request failures.

Oh, nice find. Can you resend the patch with that fixed, please?

BR,
Jani.

Quoted 60 lines
Quoted 60 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+						 value ?

GPIOD_OUT_LOW :

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
+						 GPIOD_OUT_HIGH);
+
+		if (IS_ERR_OR_NULL(gpio_desc)) {
+			DRM_ERROR("GPIO index %u request failed

(%ld)\n",

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +10 -0
+				  gpio_index, PTR_ERR(gpio_desc));
+			return;
+		}
+
+		bxt_gpio_table[gpio_index] = gpio_desc;
+	}
+
+	gpiod_set_value(gpio_desc, value);
+}
+

 static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 {
  struct drm_device *dev = intel_dsi->base.base.dev; struct drm_i915_private *dev_priv = to_i915(dev);

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -1
-	u8 gpio_source, gpio_index;
+	u8 gpio_source, gpio_index = 0, gpio_number;

  bool value;

  DRM_DEBUG_KMS("\n");

  if (dev_priv->vbt.dsi.seq_version >= 3)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -1
-		data++;
+		gpio_index = *data++;

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -1
-	gpio_index = *data++;
+	gpio_number = *data++;


  /* gpio source in sequence v2 only */
  if (dev_priv->vbt.dsi.seq_version == 2)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
@@ -328,11 +354,11 @@ static const u8 *mipi_exec_gpio(struct
 intel_dsi *intel_dsi, const u8 *data)
  	value = *data++ & 1;


  if (IS_VALLEYVIEW(dev_priv))

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
-		vlv_exec_gpio(dev_priv, gpio_source, gpio_index,

value);

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+		vlv_exec_gpio(dev_priv, gpio_source, gpio_number,

value);
  else if (IS_CHERRYVIEW(dev_priv))

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
-		chv_exec_gpio(dev_priv, gpio_source, gpio_index,

value);

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+		chv_exec_gpio(dev_priv, gpio_source, gpio_number,

value);
  else

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
-		DRM_DEBUG_KMS("GPIO element not supported on this

platform\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+		bxt_exec_gpio(dev_priv, gpio_source, gpio_index,

value);

  return data;
 }

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx