Skip to contentSkip to conversation

drm/i915/dsi: Added the generic gpio sequence support and gpio table

PATCH In review Deepak M 2 participants 6 messages Feb 24, 2016 – Feb 29, 2016

Subsystems (2)
lore
Share & tools
lore

Deepak M

author
#0 lore raw

PATCH 1/2 drm/i915/dsi: Added the generic gpio sequence support and gpio table

The generic gpio is sequence is parsed from the VBT and the GPIO table is updated with the North core, South core and SUS core elements.

v2: Move changes in sideband.c file to new patch(Jani), rebase
v3: Moved the Macro`s to intel_dsi_panel_vbt.c (Jani)

v3 by Jani
- rebase on previous patches
- don't return null on errors

v4 by Deepak
- rebase
- prefixed the VLV_ to all the GPIO macros

v5 by deepak
- readded the checks which were removed in the
earlier patchset (Jani)

---
 drivers/gpu/drm/i915/i915_reg.h            |   6 +
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 592 ++++++++++++++++++++++++++---
 2 files changed, 555 insertions(+), 43 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 3774870..606dc71 100644
@@ -620,10 +620,16 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
 #define   IOSF_PORT_FLISDSI			0x1b
 #define   IOSF_PORT_GPIO_SC			0x48
 #define   IOSF_PORT_GPIO_SUS			0xa8
+#define   IOSF_MAX_GPIO_NUM_NC			26
+#define   IOSF_MAX_GPIO_NUM_SC			128
+#define   IOSF_MAX_GPIO_NUM			172
 #define   IOSF_PORT_CCU				0xa9
 #define VLV_IOSF_DATA				_MMIO(VLV_DISPLAY_BASE + 0x2104)
 #define VLV_IOSF_ADDR				_MMIO(VLV_DISPLAY_BASE + 0x2108)
 
+#define VLV_GPIO_CFG				0x2000CC00
+#define VLV_GPIO_INPUT_DIS			0x04
+
 /* See configdb bunit SB addr map */
 #define BUNIT_REG_BISOC				0x11
 
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +549 -43

630 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#1 lore raw

PATCH 2/2 drm/i915: GPIO for CHT generic MIPI

From: Yogesh Mohan Marimuthu <[email protected]>

The GPIO configuration and register offsets are different from baytrail for cherrytrail. Port the gpio programming accordingly for cherrytrail in this patch.

v2: Removing the duplication of parsing

v3: Moved the macro def to panel_vbt.c file

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 123 +++++++++++++++++++++++------
 1 file changed, 98 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +98 -25
index 794bd1f..6b9a1f7 100644
@@ -58,6 +58,28 @@ static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel)
 
 #define NS_KHZ_RATIO 1000000
 
+#define CHV_IOSF_PORT_GPIO_N                 0x13
+#define CHV_IOSF_PORT_GPIO_SE                0x48
+#define CHV_IOSF_PORT_GPIO_SW                0xB2
+#define CHV_IOSF_PORT_GPIO_E                 0xA8
+#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
+
+
 #define VLV_HV_DDI0_HPD_GPIONC_0_PCONF0             0x4130
 #define VLV_HV_DDI0_HPD_GPIONC_0_PAD                0x4138
 #define VLV_HV_DDI0_DDC_SDA_GPIONC_1_PCONF0         0x4120
@@ -685,34 +707,13 @@ static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)
 	return data;
 }
 
-static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
+void vlv_program_gpio(struct intel_dsi *intel_dsi, u8 gpio, u8 action)
 {
-	u8 gpio, action;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	u16 function, pad;
 	u32 val;
 	u8 port;
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	DRM_DEBUG_DRIVER("MIPI: executing gpio element\n");
-
-	if (dev_priv->vbt.dsi.seq_version >= 3)
-		data++;
-
-	gpio = *data++;
-
-	/* pull up/down */
-	action = *data++ & 1;
-
-	if (gpio >= ARRAY_SIZE(gtable)) {
-		DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
-		goto out;
-	}
-
-	if (!IS_VALLEYVIEW(dev_priv)) {
-		DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
-		goto out;
-	}
 
 	if (dev_priv->vbt.dsi.seq_version >= 3) {
 		if (gpio <= IOSF_MAX_GPIO_NUM_NC) {
@@ -728,7 +729,7 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 			port = IOSF_PORT_GPIO_SUS;
 		} else {
 			DRM_ERROR("GPIO number is not present in the table\n");
-			goto out;
+			return;
 		}
 	} else {
 		port = IOSF_PORT_GPIO_NC;
@@ -750,6 +751,78 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 	/* pull up/down */
 	vlv_iosf_sb_write(dev_priv, port, pad, val);
 	mutex_unlock(&dev_priv->sb_lock);
+}
+
+void chv_program_gpio(struct intel_dsi *intel_dsi, u8 gpio, u8 action)
+{
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u16 function, pad;
+	u16 family_num;
+	u8 block;
+
+	if (dev_priv->vbt.dsi.seq_version >= 3) {
+		if (gpio <= CHV_MAX_GPIO_NUM_N) {
+			block = CHV_IOSF_PORT_GPIO_N;
+			DRM_DEBUG_DRIVER("GPIO is in the north Block\n");
+		} else if (gpio <= CHV_MAX_GPIO_NUM_SE) {
+			block = CHV_IOSF_PORT_GPIO_SE;
+			gpio = gpio - CHV_MIN_GPIO_NUM_SE;
+			DRM_DEBUG_DRIVER("GPIO is in the south east Block\n");
+		} else if (gpio <= CHV_MAX_GPIO_NUM_SW) {
+			block = CHV_IOSF_PORT_GPIO_SW;
+			gpio = gpio - CHV_MIN_GPIO_NUM_SW;
+			DRM_DEBUG_DRIVER("GPIO is in the south west Block\n");
+		} else {
+			block = CHV_IOSF_PORT_GPIO_E;
+			gpio = gpio - CHV_MIN_GPIO_NUM_E;
+			DRM_DEBUG_DRIVER("GPIO is in the east Block\n");
+		}
+	} else
+		block = IOSF_PORT_GPIO_NC;
+
+	family_num =  gpio / CHV_VBT_MAX_PINS_PER_FMLY;
+	gpio = gpio - (family_num * CHV_VBT_MAX_PINS_PER_FMLY);
+	pad = CHV_PAD_FMLY_BASE + (family_num * CHV_PAD_FMLY_SIZE) +
+		(((u16)gpio) * CHV_PAD_CFG_0_1_REG_SIZE);
+	function = pad + CHV_PAD_CFG_REG_SIZE;
+
+	mutex_lock(&dev_priv->sb_lock);
+	vlv_iosf_sb_write(dev_priv, block, function,
+			CHV_GPIO_CFG_UNLOCK);
+	vlv_iosf_sb_write(dev_priv, block, pad, 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)
+{
+	u8 gpio, action;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	DRM_DEBUG_DRIVER("MIPI: executing gpio element\n");
+
+	if (dev_priv->vbt.dsi.seq_version >= 3)
+		data++;
+
+	gpio = *data++;
+
+	/* pull up/down */
+	action = *data++ & 1;
+
+	if (gpio >= ARRAY_SIZE(gtable)) {
+		DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
+		goto out;
+	}
+
+	if (IS_VALLEYVIEW(dev))
+		vlv_program_gpio(intel_dsi, gpio, action);
+	else if (IS_CHERRYVIEW(dev))
+		chv_program_gpio(intel_dsi, gpio, action);
+	else
+		DRM_ERROR("GPIO programming missing for this platform.\n");
 
 out:
 	return data;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 23 lines · Deepak M

From: Yogesh Mohan Marimuthu <[email protected]>

The GPIO configuration and register offsets are different from baytrail for cherrytrail. Port the gpio programming accordingly for cherrytrail in this patch.

v2: Removing the duplication of parsing

v3: Moved the macro def to panel_vbt.c file

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 123 +++++++++++++++++++++++------
 1 file changed, 98 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 794bd1f..6b9a1f7 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 64

Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
@@ -58,6 +58,28 @@ static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel)
 
 #define NS_KHZ_RATIO 1000000
 
+#define CHV_IOSF_PORT_GPIO_N                 0x13
+#define CHV_IOSF_PORT_GPIO_SE                0x48
+#define CHV_IOSF_PORT_GPIO_SW                0xB2
+#define CHV_IOSF_PORT_GPIO_E                 0xA8

These should have remained where the other ports were defined.

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 70

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -0
+#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

I never got any explanation where the block sizes came from on VLV. IIRC when I checked them against configdb they didn't match the actual number of pins in the hardware block. And the same story continues here. Eg. if I check configfb the number of pins in each block is:
N 59, SE 55, SW 56, E 24.

So I can't review this until someone explains where this stuff comes from. And there should probably be a comment next to the defines to remind the next guy who gets totally confused by this.

Also I don't like the fact that VLV and CHV are now implemented in two totally different ways. Can you eliminate the massive gpio table from the VLV code to make it more similar to this?

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 76

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -0
+
+#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

I take it this magic 15 must be specified in some VBT spec or something?

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 79

Quoted 3 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +3 -0
+
+#define CHV_GPIO_CFG_UNLOCK                    0x00000000
+#define CHV_GPIO_CFG_HIZ                       0x00008100

That's not really hi-z is it? It's GPO mode actually w/ txstate=0. I would suggest adding separate defines for each bit so it's easier to see what is really set and what isn't.

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 80

Quoted 1 line
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+#define CHV_GPIO_CFG_TX_STATE_SHIFT            1

Could be something like
#define CHV_GPIO_CFG0_TX_STATE(state) ((state) << 1)

Quoted 78 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +28 -25
+
+
 #define VLV_HV_DDI0_HPD_GPIONC_0_PCONF0             0x4130
 #define VLV_HV_DDI0_HPD_GPIONC_0_PAD                0x4138
 #define VLV_HV_DDI0_DDC_SDA_GPIONC_1_PCONF0         0x4120
@@ -685,34 +707,13 @@ static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)
 	return data;
 }
 
-static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
+void vlv_program_gpio(struct intel_dsi *intel_dsi, u8 gpio, u8 action)
 {
-	u8 gpio, action;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	u16 function, pad;
 	u32 val;
 	u8 port;
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	DRM_DEBUG_DRIVER("MIPI: executing gpio element\n");
-
-	if (dev_priv->vbt.dsi.seq_version >= 3)
-		data++;
-
-	gpio = *data++;
-
-	/* pull up/down */
-	action = *data++ & 1;
-
-	if (gpio >= ARRAY_SIZE(gtable)) {
-		DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
-		goto out;
-	}
-
-	if (!IS_VALLEYVIEW(dev_priv)) {
-		DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
-		goto out;
-	}
 
 	if (dev_priv->vbt.dsi.seq_version >= 3) {
 		if (gpio <= IOSF_MAX_GPIO_NUM_NC) {
@@ -728,7 +729,7 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 			port = IOSF_PORT_GPIO_SUS;
 		} else {
 			DRM_ERROR("GPIO number is not present in the table\n");
-			goto out;
+			return;
 		}
 	} else {
 		port = IOSF_PORT_GPIO_NC;
@@ -750,6 +751,78 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 	/* pull up/down */
 	vlv_iosf_sb_write(dev_priv, port, pad, val);
 	mutex_unlock(&dev_priv->sb_lock);
+}
+
+void chv_program_gpio(struct intel_dsi *intel_dsi, u8 gpio, u8 action)
+{
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u16 function, pad;
+	u16 family_num;
+	u8 block;
+
+	if (dev_priv->vbt.dsi.seq_version >= 3) {
+		if (gpio <= CHV_MAX_GPIO_NUM_N) {
+			block = CHV_IOSF_PORT_GPIO_N;
+			DRM_DEBUG_DRIVER("GPIO is in the north Block\n");
+		} else if (gpio <= CHV_MAX_GPIO_NUM_SE) {
+			block = CHV_IOSF_PORT_GPIO_SE;
+			gpio = gpio - CHV_MIN_GPIO_NUM_SE;
+			DRM_DEBUG_DRIVER("GPIO is in the south east Block\n");
+		} else if (gpio <= CHV_MAX_GPIO_NUM_SW) {
+			block = CHV_IOSF_PORT_GPIO_SW;
+			gpio = gpio - CHV_MIN_GPIO_NUM_SW;
+			DRM_DEBUG_DRIVER("GPIO is in the south west Block\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 785

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +10 -0
+		} else {
+			block = CHV_IOSF_PORT_GPIO_E;
+			gpio = gpio - CHV_MIN_GPIO_NUM_E;
+			DRM_DEBUG_DRIVER("GPIO is in the east Block\n");
+		}
+	} else
+		block = IOSF_PORT_GPIO_NC;
+
+	family_num =  gpio / CHV_VBT_MAX_PINS_PER_FMLY;
+	gpio = gpio - (family_num * CHV_VBT_MAX_PINS_PER_FMLY);

Writing this second part with % might make it a bit more obvious.

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 787

Quoted 2 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +2 -0
+	pad = CHV_PAD_FMLY_BASE + (family_num * CHV_PAD_FMLY_SIZE) +
+		(((u16)gpio) * CHV_PAD_CFG_0_1_REG_SIZE);

That could be baked into a neat parametrized define eg.
#define CHV_GPIO_PAD_CFG0(family, gpio) (0x4400 + (family) * 0x400 + (gpio) * 8)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 788

Quoted 1 line
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+	function = pad + CHV_PAD_CFG_REG_SIZE;

ditto
#define CHV_GPIO_PAD_CFG1(family, gpio) ...

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 792

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
+
+	mutex_lock(&dev_priv->sb_lock);
+	vlv_iosf_sb_write(dev_priv, block, function,
+			CHV_GPIO_CFG_UNLOCK);

Is it OK to clear all the bits that default to 1? parkmode,hysctl etc.

Quoted 38 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +33 -0
+	vlv_iosf_sb_write(dev_priv, block, pad, 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)
+{
+	u8 gpio, action;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	DRM_DEBUG_DRIVER("MIPI: executing gpio element\n");
+
+	if (dev_priv->vbt.dsi.seq_version >= 3)
+		data++;
+
+	gpio = *data++;
+
+	/* pull up/down */
+	action = *data++ & 1;
+
+	if (gpio >= ARRAY_SIZE(gtable)) {
+		DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
+		goto out;
+	}
+
+	if (IS_VALLEYVIEW(dev))
+		vlv_program_gpio(intel_dsi, gpio, action);
+	else if (IS_CHERRYVIEW(dev))
+		chv_program_gpio(intel_dsi, gpio, action);
+	else
+		DRM_ERROR("GPIO programming missing for this platform.\n");
 
 out:
 	return data;
Signature · 1 line
1.9.1
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#3 lore raw

Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 62 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, February 25, 2016 9:07 PM
To: Deepak, M <[email protected]>
Cc: [email protected]; Mohan Marimuthu, Yogesh <[email protected]>; Nikula, Jani <[email protected]>
Subject: Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 26 lines · Deepak M

From: Yogesh Mohan Marimuthu <[email protected]>

The GPIO configuration and register offsets are different from baytrail for cherrytrail. Port the gpio programming accordingly for cherrytrail in this patch.

v2: Removing the duplication of parsing

v3: Moved the macro def to panel_vbt.c file

Cc: Ville Syrjälä <[email protected]>
Cc: Jani Nikula <[email protected]>
Signed-off-by: Yogesh Mohan Marimuthu
<[email protected]>

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 123
+++++++++++++++++++++++------
 1 file changed, 98 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 794bd1f..6b9a1f7 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct · line 65

Quoted 8 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
@@ -58,6 +58,28 @@ static inline struct vbt_panel *to_vbt_panel(struct
 drm_panel *panel)
 
 #define NS_KHZ_RATIO 1000000
 
+#define CHV_IOSF_PORT_GPIO_N                 0x13
+#define CHV_IOSF_PORT_GPIO_SE                0x48
+#define CHV_IOSF_PORT_GPIO_SW                0xB2
+#define CHV_IOSF_PORT_GPIO_E                 0xA8

These should have remained where the other ports were defined.

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 70

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -0
+#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

I never got any explanation where the block sizes came from on VLV. IIRC when I checked them against configdb they didn't match the actual number of pins in the hardware block. And the same story continues here. Eg. if I check configfb the number of pins in each block is:
N 59, SE 55, SW 56, E 24.

Quoted 8 lines

So I can't review this until someone explains where this stuff comes from. And there should probably be a comment next to the defines to remind the next guy who gets totally confused by this.

Also I don't like the fact that VLV and CHV are now implemented in two totally different ways. Can you eliminate the massive gpio table from the VLV code to make it more similar to this?

[Deepak, M] In CHV the GPIO numberings are sequential but in VLV that is not the case, hence the complete table is copied here. I have attached the VLV GPIO mapping table which can clear your doubts. Pfa,

Quoted 178 lines

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 76

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -0
+
+#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

I take it this magic 15 must be specified in some VBT spec or something?

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 79

Quoted 3 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +3 -0
+
+#define CHV_GPIO_CFG_UNLOCK                    0x00000000
+#define CHV_GPIO_CFG_HIZ                       0x00008100

That's not really hi-z is it? It's GPO mode actually w/ txstate=0. I would suggest adding separate defines for each bit so it's easier to see what is really set and what isn't.

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 80

Quoted 1 line
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+#define CHV_GPIO_CFG_TX_STATE_SHIFT            1

Could be something like
#define CHV_GPIO_CFG0_TX_STATE(state) ((state) << 1)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_delay(struct intel_dsi

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +2 -0
+
+
 #define VLV_HV_DDI0_HPD_GPIONC_0_PCONF0             0x4130
 #define VLV_HV_DDI0_HPD_GPIONC_0_PAD                0x4138

#define VLV_HV_DDI0_DDC_SDA_GPIONC_1_PCONF0 0x4120

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
@@ -685,34 +707,13 @@ static const u8 *mipi_exec_delay(struct intel_dsi

*intel_dsi, const u8 *data)

Quoted 24 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -12
 	return data;
 }
 
-static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8
 *data)
+void vlv_program_gpio(struct intel_dsi *intel_dsi, u8 gpio, u8
+action)
 {
-	u8 gpio, action;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	u16 function, pad;
 	u32 val;
 	u8 port;
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	DRM_DEBUG_DRIVER("MIPI: executing gpio element\n");
-
-	if (dev_priv->vbt.dsi.seq_version >= 3)
-		data++;
-
-	gpio = *data++;
-

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -10
-	/* pull up/down */
-	action = *data++ & 1;
-
-	if (gpio >= ARRAY_SIZE(gtable)) {
-		DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
-		goto out;
-	}
-
-	if (!IS_VALLEYVIEW(dev_priv)) {
-		DRM_DEBUG_KMS("GPIO element not supported on this

platform\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)

Quoted 5 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -2
-		goto out;
-	}
 
 	if (dev_priv->vbt.dsi.seq_version >= 3) {
 		if (gpio <= IOSF_MAX_GPIO_NUM_NC) { @@ -728,7 +729,7

@@ static

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)

Quoted 4 lines

const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
 			port = IOSF_PORT_GPIO_SUS;
 		} else {
 			DRM_ERROR("GPIO number is not present in the

table\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -1
-			goto out;
+			return;
 		}
 	} else {
 		port = IOSF_PORT_GPIO_NC;
@@ -750,6 +751,78 @@ static const u8 *mipi_exec_gpio(struct intel_dsi

*intel_dsi, const u8 *data)

Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
 	/* pull up/down */
 	vlv_iosf_sb_write(dev_priv, port, pad, val);
 	mutex_unlock(&dev_priv->sb_lock);
+}
+
+void chv_program_gpio(struct intel_dsi *intel_dsi, u8 gpio, u8
+action) {

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +10 -0
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u16 function, pad;
+	u16 family_num;
+	u8 block;
+
+	if (dev_priv->vbt.dsi.seq_version >= 3) {
+		if (gpio <= CHV_MAX_GPIO_NUM_N) {
+			block = CHV_IOSF_PORT_GPIO_N;
+			DRM_DEBUG_DRIVER("GPIO is in the north

Block\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
+		} else if (gpio <= CHV_MAX_GPIO_NUM_SE) {
+			block = CHV_IOSF_PORT_GPIO_SE;
+			gpio = gpio - CHV_MIN_GPIO_NUM_SE;
+			DRM_DEBUG_DRIVER("GPIO is in the south east

Block\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
+		} else if (gpio <= CHV_MAX_GPIO_NUM_SW) {
+			block = CHV_IOSF_PORT_GPIO_SW;
+			gpio = gpio - CHV_MIN_GPIO_NUM_SW;
+			DRM_DEBUG_DRIVER("GPIO is in the south west

Block\n");

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 785

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +10 -0
+		} else {
+			block = CHV_IOSF_PORT_GPIO_E;
+			gpio = gpio - CHV_MIN_GPIO_NUM_E;
+			DRM_DEBUG_DRIVER("GPIO is in the east Block\n");
+		}
+	} else
+		block = IOSF_PORT_GPIO_NC;
+
+	family_num =  gpio / CHV_VBT_MAX_PINS_PER_FMLY;
+	gpio = gpio - (family_num * CHV_VBT_MAX_PINS_PER_FMLY);

Writing this second part with % might make it a bit more obvious.

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi · line 786

Quoted 1 line
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+	pad = CHV_PAD_FMLY_BASE + (family_num * CHV_PAD_FMLY_SIZE)

+

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 787

Quoted 1 line
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+		(((u16)gpio) * CHV_PAD_CFG_0_1_REG_SIZE);

That could be baked into a neat parametrized define eg. #define CHV_GPIO_PAD_CFG0(family, gpio) (0x4400 + (family) * 0x400 + (gpio) * 8)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 788

Quoted 1 line
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
+	function = pad + CHV_PAD_CFG_REG_SIZE;

ditto
#define CHV_GPIO_PAD_CFG1(family, gpio) ...

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) · line 792

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
+
+	mutex_lock(&dev_priv->sb_lock);
+	vlv_iosf_sb_write(dev_priv, block, function,
+			CHV_GPIO_CFG_UNLOCK);

Is it OK to clear all the bits that default to 1? parkmode,hysctl etc.

Quoted 23 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +23 -0
+	vlv_iosf_sb_write(dev_priv, block, pad, 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) {
+	u8 gpio, action;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	DRM_DEBUG_DRIVER("MIPI: executing gpio element\n");
+
+	if (dev_priv->vbt.dsi.seq_version >= 3)
+		data++;
+
+	gpio = *data++;
+
+	/* pull up/down */
+	action = *data++ & 1;
+
+	if (gpio >= ARRAY_SIZE(gtable)) {

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +10 -0
+		DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
+		goto out;
+	}
+
+	if (IS_VALLEYVIEW(dev))
+		vlv_program_gpio(intel_dsi, gpio, action);
+	else if (IS_CHERRYVIEW(dev))
+		chv_program_gpio(intel_dsi, gpio, action);
+	else
+		DRM_ERROR("GPIO programming missing for this

platform.\n");

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

out:
return data;
--
1.9.1

--
Ville Syrjälä
Intel OTC

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 66 lines · On Mon, Feb 29, 2016 at 11:00:34AM +0000, Deepak, M wrote:
Quoted 66 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, February 25, 2016 9:07 PM
To: Deepak, M <[email protected]>
Cc: [email protected]; Mohan Marimuthu, Yogesh <[email protected]>; Nikula, Jani <[email protected]>
Subject: Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 26 lines · Deepak M

From: Yogesh Mohan Marimuthu <[email protected]>

The GPIO configuration and register offsets are different from baytrail for cherrytrail. Port the gpio programming accordingly for cherrytrail in this patch.

v2: Removing the duplication of parsing

v3: Moved the macro def to panel_vbt.c file

Cc: Ville Syrjälä <[email protected]>
Cc: Jani Nikula <[email protected]>
Signed-off-by: Yogesh Mohan Marimuthu
<[email protected]>

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 123
+++++++++++++++++++++++------
 1 file changed, 98 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 794bd1f..6b9a1f7 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct · line 65

Quoted 8 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
@@ -58,6 +58,28 @@ static inline struct vbt_panel *to_vbt_panel(struct
 drm_panel *panel)
 
 #define NS_KHZ_RATIO 1000000
 
+#define CHV_IOSF_PORT_GPIO_N                 0x13
+#define CHV_IOSF_PORT_GPIO_SE                0x48
+#define CHV_IOSF_PORT_GPIO_SW                0xB2
+#define CHV_IOSF_PORT_GPIO_E                 0xA8

These should have remained where the other ports were defined.

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 70

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -0
+#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

I never got any explanation where the block sizes came from on VLV. IIRC when I checked them against configdb they didn't match the actual number of pins in the hardware block. And the same story continues here. Eg. if I check configfb the number of pins in each block is:
N 59, SE 55, SW 56, E 24.

So I can't review this until someone explains where this stuff comes from. And there should probably be a comment next to the defines to remind the next guy who gets totally confused by this.

Quoted 5 lines
Quoted 4 lines

Also I don't like the fact that VLV and CHV are now implemented in two totally different ways. Can you eliminate the massive gpio table from the VLV code to make it more similar to this?

[Deepak, M] In CHV the GPIO numberings are sequential but in VLV that is not the case, hence the complete table is copied here. I have attached the VLV GPIO mapping table which can clear your doubts. Pfa,

Any chance someone could try to get this table included in the spec, or at least have a link to it? Having the information spread around this way is not productive.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#5 lore raw

Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 84 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Monday, February 29, 2016 7:20 PM
To: Deepak, M <[email protected]>
Cc: [email protected]; Mohan Marimuthu, Yogesh <[email protected]>; Nikula, Jani <[email protected]>
Subject: Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 11 lines · On Mon, Feb 29, 2016 at 11:00:34AM +0000, Deepak, M wrote:
Quoted 11 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, February 25, 2016 9:07 PM
To: Deepak, M <[email protected]>
Cc: [email protected]; Mohan Marimuthu, Yogesh <[email protected]>; Nikula, Jani <[email protected]>
Subject: Re: [PATCH 2/2] drm/i915: GPIO for CHT generic MIPI

Quoted 2 lines
Quoted 2 lines · Deepak M
Quoted 1 line

From: Yogesh Mohan Marimuthu

<[email protected]>

Quoted 36 lines
Quoted 36 lines
Quoted 25 lines

The GPIO configuration and register offsets are different from baytrail for cherrytrail. Port the gpio programming accordingly for cherrytrail in this patch.

v2: Removing the duplication of parsing

v3: Moved the macro def to panel_vbt.c file

Cc: Ville Syrjälä <[email protected]>
Cc: Jani Nikula <[email protected]>
Signed-off-by: Yogesh Mohan Marimuthu
<[email protected]>

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 123
+++++++++++++++++++++++------
 1 file changed, 98 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 794bd1f..6b9a1f7 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel · line 65

Quoted 8 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +4 -0
@@ -58,6 +58,28 @@ static inline struct vbt_panel
 *to_vbt_panel(struct drm_panel *panel)
 
 #define NS_KHZ_RATIO 1000000
 
+#define CHV_IOSF_PORT_GPIO_N                 0x13
+#define CHV_IOSF_PORT_GPIO_SE                0x48
+#define CHV_IOSF_PORT_GPIO_SW                0xB2
+#define CHV_IOSF_PORT_GPIO_E                 0xA8

These should have remained where the other ports were defined.

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) · line 70

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -0
+#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

I never got any explanation where the block sizes came from on VLV. IIRC when I checked them against configdb they didn't match the actual number of pins in the hardware block. And the same story

continues here.

Quoted 11 lines
Quoted 11 lines

Eg. if I check configfb the number of pins in each block is:
N 59, SE 55, SW 56, E 24.

So I can't review this until someone explains where this stuff comes from. And there should probably be a comment next to the defines to remind the next guy who gets totally confused by this.

Also I don't like the fact that VLV and CHV are now implemented in two totally different ways. Can you eliminate the massive gpio table from the VLV code to make it more similar to this?

Quoted 7 lines
Quoted 3 lines

[Deepak, M] In CHV the GPIO numberings are sequential but in VLV that is not the case, hence the complete table is copied here. I have attached the VLV GPIO mapping table which can clear your doubts. Pfa,

Any chance someone could try to get this table included in the spec, or at least have a link to it? Having the information spread around this way is not productive.

[Deepak, M] Sure, will try to put this doc in sharepoint.

Quoted 4 lines

--
Ville Syrjälä
Intel OTC

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx