All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Deepak M <m.deepak@intel.com>, jani.nikula@intel.com
Subject: [PATCH v2 8/9] drm/i915/dsi: add support for gpio elements on CHV
Date: Fri, 18 Mar 2016 13:11:16 +0200	[thread overview]
Message-ID: <c5be1dfa0a99e04ce7076b8b2c983d3a53d6cdac.1458299160.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1458299160.git.jani.nikula@intel.com>
In-Reply-To: <cover.1458299160.git.jani.nikula@intel.com>

From: Yogesh Mohan Marimuthu <yogesh.mohan.marimuthu@intel.com>

Add support for CHV gpio programming in DSI gpio elements.

XXX: I'd like to have a gpio table for chv as well as others.

[Rewritten by Jani, based on earlier work by Yogesh and Deepak.]

Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohan.marimuthu@intel.com>
Signed-off-by: Deepak M <m.deepak@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 66 ++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
index ca48f7aa6a05..f8d3f608e9c8 100644
--- a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
+++ b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
@@ -97,6 +97,23 @@ static struct vlv_gpio_map vlv_gpio_table[] = {
 	{ 11, IOSF_PORT_GPIO_NC, VLV_GPIO_NC_11_PCONF0 },
 };
 
+#define CHV_MAX_GPIO_NUM_N		72
+#define CHV_MAX_GPIO_NUM_SE		99
+#define CHV_MAX_GPIO_NUM_SW		197
+#define CHV_MIN_GPIO_NUM_SE		73
+#define CHV_MIN_GPIO_NUM_SW		100
+#define CHV_MIN_GPIO_NUM_E		198
+
+#define CHV_PAD_FMLY_BASE		0x4400
+#define CHV_PAD_FMLY_SIZE		0x400
+#define CHV_PAD_CFG_0_1_REG_SIZE	0x8
+#define CHV_PAD_CFG_REG_SIZE		0x4
+#define CHV_VBT_MAX_PINS_PER_FMLY	15
+
+#define CHV_GPIO_CFG_UNLOCK		0x00000000
+#define CHV_GPIO_CFG_HIZ		0x00008100
+#define CHV_GPIO_CFG_TX_STATE_SHIFT	1
+
 static inline enum port intel_dsi_seq_port_to_port(u8 port)
 {
 	return port ? PORT_C : PORT_A;
@@ -241,6 +258,53 @@ static void vlv_exec_gpio(struct drm_i915_private *dev_priv,
 	mutex_unlock(&dev_priv->sb_lock);
 }
 
+static void chv_exec_gpio(struct drm_i915_private *dev_priv,
+			  u8 gpio_source, u8 gpio_index, u8 action)
+{
+	u16 pconf0, padval;
+	u16 family_num;
+	u8 port;
+
+	/* XXX: add a table similar to vlv for checking gpio indexes */
+	if (dev_priv->vbt.dsi.seq_version >= 3) {
+		if (gpio_index <= CHV_MAX_GPIO_NUM_N) {
+			port = CHV_IOSF_PORT_GPIO_N;
+		} else if (gpio_index <= CHV_MAX_GPIO_NUM_SE) {
+			port = CHV_IOSF_PORT_GPIO_SE;
+			gpio_index = gpio_index - CHV_MIN_GPIO_NUM_SE;
+		} else if (gpio_index <= CHV_MAX_GPIO_NUM_SW) {
+			port = CHV_IOSF_PORT_GPIO_SW;
+			gpio_index = gpio_index - CHV_MIN_GPIO_NUM_SW;
+		} else {
+			port = CHV_IOSF_PORT_GPIO_E;
+			gpio_index = gpio_index - CHV_MIN_GPIO_NUM_E;
+		}
+	} else if (dev_priv->vbt.dsi.seq_version == 2) {
+		if (gpio_source == 0) {
+			port = IOSF_PORT_GPIO_NC;
+		} else if (gpio_source == 1) {
+			port = IOSF_PORT_GPIO_SC;
+		} else {
+			DRM_DEBUG_KMS("unknown gpio source %u\n", gpio_source);
+			return;
+		}
+	} else {
+		port = IOSF_PORT_GPIO_NC;
+	}
+
+	family_num = gpio_index / CHV_VBT_MAX_PINS_PER_FMLY;
+	gpio_index = gpio_index - (family_num * CHV_VBT_MAX_PINS_PER_FMLY);
+	padval = CHV_PAD_FMLY_BASE + (family_num * CHV_PAD_FMLY_SIZE) +
+		(((u16)gpio_index) * CHV_PAD_CFG_0_1_REG_SIZE);
+	pconf0 = padval + CHV_PAD_CFG_REG_SIZE;
+
+	mutex_lock(&dev_priv->sb_lock);
+	vlv_iosf_sb_write(dev_priv, port, pconf0, CHV_GPIO_CFG_UNLOCK);
+	vlv_iosf_sb_write(dev_priv, port, padval, CHV_GPIO_CFG_HIZ |
+			  (action << CHV_GPIO_CFG_TX_STATE_SHIFT));
+	mutex_unlock(&dev_priv->sb_lock);
+}
+
 static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 {
 	struct drm_device *dev = intel_dsi->base.base.dev;
@@ -263,6 +327,8 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 
 	if (IS_VALLEYVIEW(dev_priv))
 		vlv_exec_gpio(dev_priv, gpio_source, gpio_index, action);
+	else if (IS_CHERRYVIEW(dev_priv))
+		chv_exec_gpio(dev_priv, gpio_source, gpio_index, action);
 	else
 		DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-03-18 11:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 11:11 [PATCH v2 0/9] drm/i915/dsi: improved gpio element support for vlv/chv/bxt Jani Nikula
2016-03-18 11:11 ` [PATCH v2 1/9] drm/i915/dsi: refer to gpio index instead of gpio to avoid confusion Jani Nikula
2016-03-24 11:57   ` Mika Kahola
2016-04-01 11:53     ` Jani Nikula
2016-03-18 11:11 ` [PATCH v2 2/9] drm/i915/dsi: add support for DSI sequence block v2 gpio element Jani Nikula
2016-04-04 16:19   ` Ville Syrjälä
2016-04-05  7:33     ` Jani Nikula
2016-03-18 11:11 ` [PATCH v2 3/9] drm/i915/dsi: clean up vlv gpio table and definitions Jani Nikula
2016-04-04 17:07   ` Ville Syrjälä
2016-03-18 11:11 ` [PATCH v2 4/9] drm/i915/dsi: add gpio indexes to the gpio table Jani Nikula
2016-04-04 17:37   ` Ville Syrjälä
2016-03-18 11:11 ` [PATCH v2 5/9] drm/i915/dsi: abstract VLV gpio element execution to a separate function Jani Nikula
2016-03-18 11:11 ` [PATCH v2 6/9] drm/i915/dsi: add support for sequence block v3 gpio for VLV Jani Nikula
2016-03-18 11:11 ` [PATCH v2 7/9] drm/i915/chv: add more IOSF port definitions Jani Nikula
2016-04-04 17:43   ` Ville Syrjälä
2016-04-05  7:34     ` Jani Nikula
2016-03-18 11:11 ` Jani Nikula [this message]
2016-04-04 18:11   ` [PATCH v2 8/9] drm/i915/dsi: add support for gpio elements on CHV Ville Syrjälä
2016-03-18 11:11 ` [PATCH v2 9/9] drm/i915/bxt: add bxt dsi gpio element support Jani Nikula
2016-03-23 10:55   ` Mika Kahola
2016-03-23 11:19     ` Jani Nikula
2016-04-04 17:46   ` Ville Syrjälä
2016-03-21  8:52 ` ✗ Fi.CI.BAT: warning for drm/i915/dsi: improved gpio element support for vlv/chv/bxt Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5be1dfa0a99e04ce7076b8b2c983d3a53d6cdac.1458299160.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=m.deepak@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.