Skip to contentSkip to conversation

drm/i915: add bunit read/write routines

PATCH In review Jesse Barnes 3 participants 14 messages Nov 1, 2013 – Nov 4, 2013

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

PATCH 1/4 drm/i915: add bunit read/write routines

For modifying self-refresh exit latency.

---
 drivers/gpu/drm/i915/i915_drv.h       |  2 ++
 drivers/gpu/drm/i915/i915_reg.h       |  1 +
 drivers/gpu/drm/i915/intel_sideband.c | 16 ++++++++++++++++
 3 files changed, 19 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index cc40cbf..5edf9bb 100644
@@ -2403,6 +2403,8 @@ u32 vlv_cck_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_cck_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_ccu_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_ccu_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
+u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg);
+void vlv_bunit_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_gps_core_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_gps_core_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_dpio_read(struct drm_i915_private *dev_priv, enum pipe pipe, int reg);
drivers/gpu/drm/i915/i915_reg.h +1 -0
index de58947..737d8a3 100644
@@ -349,6 +349,7 @@
 #define   IOSF_BYTE_ENABLES_SHIFT		4
 #define   IOSF_BAR_SHIFT			1
 #define   IOSF_SB_BUSY				(1<<0)
+#define   IOSF_PORT_BUNIT			0x3
 #define   IOSF_PORT_PUNIT			0x4
 #define   IOSF_PORT_NC				0x11
 #define   IOSF_PORT_DPIO			0x12
drivers/gpu/drm/i915/intel_sideband.c +16 -0
index 9944d81..d43e457 100644
@@ -90,6 +90,22 @@ void vlv_punit_write(struct drm_i915_private *dev_priv, u8 addr, u32 val)
 	mutex_unlock(&dev_priv->dpio_lock);
 }
 
+u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg)
+{
+	u32 val = 0;
+
+	vlv_sideband_rw(dev_priv, PCI_DEVFN(2, 0), IOSF_PORT_BUNIT,
+			PUNIT_OPCODE_REG_READ, reg, &val);
+
+	return val;
+}
+
+void vlv_bunit_write(struct drm_i915_private *dev_priv, u32 reg, u32 val)
+{
+	vlv_sideband_rw(dev_priv, PCI_DEVFN(2, 0), IOSF_PORT_BUNIT,
+			PUNIT_OPCODE_REG_WRITE, reg, &val);
+}
+
 u32 vlv_nc_read(struct drm_i915_private *dev_priv, u8 addr)
 {
 	u32 val = 0;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/4 drm/i915: move VLV DDR freq fetch into init_clock_gating

We don't want it delayed with the RPS work.

---
 drivers/gpu/drm/i915/intel_pm.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +18 -13
index a0c907f..2e7072e 100644
@@ -4064,19 +4064,6 @@ static void valleyview_enable_rps(struct drm_device *dev)
 	I915_WRITE(GEN6_RC_CONTROL, rc6_mode);
 
 	val = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
-	switch ((val >> 6) & 3) {
-	case 0:
-	case 1:
-		dev_priv->mem_freq = 800;
-		break;
-	case 2:
-		dev_priv->mem_freq = 1066;
-		break;
-	case 3:
-		dev_priv->mem_freq = 1333;
-		break;
-	}
-	DRM_DEBUG_DRIVER("DDR speed: %d MHz", dev_priv->mem_freq);
 
 	DRM_DEBUG_DRIVER("GPLL enabled? %s\n", val & 0x10 ? "yes" : "no");
 	DRM_DEBUG_DRIVER("GPU status: 0x%08x\n", val);
@@ -5325,6 +5312,24 @@ static void ivybridge_init_clock_gating(struct drm_device *dev)
 static void valleyview_init_clock_gating(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 val;
+
+	mutex_lock(&dev_priv->rps.hw_lock);
+	val = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
+	mutex_unlock(&dev_priv->rps.hw_lock);
+	switch ((val >> 6) & 3) {
+	case 0:
+	case 1:
+		dev_priv->mem_freq = 800;
+		break;
+	case 2:
+		dev_priv->mem_freq = 1066;
+		break;
+	case 3:
+		dev_priv->mem_freq = 1333;
+		break;
+	}
+	DRM_DEBUG_DRIVER("DDR speed: %d MHz", dev_priv->mem_freq);
 
 	I915_WRITE(DSPCLK_GATE_D, VRHUNIT_CLOCK_GATE_DISABLE);
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 3/4 drm/i915: add modeset_global_pipes callback for global config adjustments

In reply to Jesse Barnes

In some cases we may need to turn off more pipes than just the ones affected by a connector or encoder change, probably due to modifying some global resource that requires all pipes to shut down. Add a hook for this purpose to allow platform code to adjust the prepare_pipes mask, which allows otherwise active pipes to get shut down for the duration of the mode set, then restored at the end.

---
 drivers/gpu/drm/i915/i915_drv.h      | 12 ++++++++++++
 drivers/gpu/drm/i915/intel_display.c |  7 +++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +12 -0
index 5edf9bb..7530cd4 100644
@@ -380,6 +380,18 @@ struct drm_i915_display_funcs {
 				 struct drm_crtc *crtc,
 				 uint32_t sprite_width, int pixel_size,
 				 bool enable, bool scaled);
+	/**
+	 * modeset_global_pipes - figure out which pipes need to be disabled
+	 * @dev: drm device
+	 * @prepare_pipes: bitmask of pipes to disable
+	 *
+	 * In some cases, adjusting a global resource may require shutting
+	 * down seemingly unrelated pipes on a mode set.  This function
+	 * should determine that and adjust the prepare_pipes bitmask
+	 * as needed.
+	 */
+	void (*modeset_global_pipes)(struct drm_device *dev,
+				     unsigned *prepare_pipes);
 	void (*modeset_global_resources)(struct drm_device *dev);
 	/* Returns the active state of the crtc, and if the crtc is active,
 	 * fills out the pipe-config with the hw state. */
drivers/gpu/drm/i915/intel_display.c +7 -0
index 606a594..faa7548 100644
@@ -9298,6 +9298,13 @@ static int __intel_set_mode(struct drm_crtc *crtc,
 	intel_modeset_affected_pipes(crtc, &modeset_pipes,
 				     &prepare_pipes, &disable_pipes);
 
+	/*
+	 * See if the config requires any additional preparation, e.g.
+	 * to adjust global state with pipes off.
+	 */
+	if (dev_priv->display.modeset_global_pipes)
+		dev_priv->display.modeset_global_pipes(dev, &prepare_pipes);
+
 	*saved_hwmode = crtc->hwmode;
 	*saved_mode = crtc->mode;
 
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [PATCH 3/4] drm/i915: add modeset_global_pipes callback for global config adjustments

Quoted 41 lines · Jesse Barnes

In some cases we may need to turn off more pipes than just the ones affected by a connector or encoder change, probably due to modifying some global resource that requires all pipes to shut down. Add a hook for this purpose to allow platform code to adjust the prepare_pipes mask, which allows otherwise active pipes to get shut down for the duration of the mode set, then restored at the end.

---
 drivers/gpu/drm/i915/i915_drv.h      | 12 ++++++++++++
 drivers/gpu/drm/i915/intel_display.c |  7 +++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +12 -0
index 5edf9bb..7530cd4 100644
@@ -380,6 +380,18 @@ struct drm_i915_display_funcs {
 				 struct drm_crtc *crtc,
 				 uint32_t sprite_width, int pixel_size,
 				 bool enable, bool scaled);
+	/**
+	 * modeset_global_pipes - figure out which pipes need to be disabled
+	 * @dev: drm device
+	 * @prepare_pipes: bitmask of pipes to disable
+	 *
+	 * In some cases, adjusting a global resource may require shutting
+	 * down seemingly unrelated pipes on a mode set.  This function
+	 * should determine that and adjust the prepare_pipes bitmask
+	 * as needed.
+	 */
+	void (*modeset_global_pipes)(struct drm_device *dev,
+				     unsigned *prepare_pipes);
 	void (*modeset_global_resources)(struct drm_device *dev);
 	/* Returns the active state of the crtc, and if the crtc is active,
 	 * fills out the pipe-config with the hw state. */
drivers/gpu/drm/i915/intel_display.c +0 -0
index 606a594..faa7548 100644

drivers/gpu/drm/i915/intel_display.c static int __intel_set_mode(struct drm_crtc *crtc, · line 9306

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +6 -0
@@ -9298,6 +9298,13 @@ static int __intel_set_mode(struct drm_crtc *crtc,
 	intel_modeset_affected_pipes(crtc, &modeset_pipes,
 				     &prepare_pipes, &disable_pipes);
 
+	/*
+	 * See if the config requires any additional preparation, e.g.
+	 * to adjust global state with pipes off.
+	 */
+	if (dev_priv->display.modeset_global_pipes)
+		dev_priv->display.modeset_global_pipes(dev, &prepare_pipes);

tbh I'd have just added a small callback here - as long as all the global modeset config stuff is still in flux I wouldn't bother with fancy-looking callbacks which we need to change later on anyway. And avoiding the vfunc helps with following the code a bit ...
-Daniel

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
+
 	*saved_hwmode = crtc->hwmode;
 	*saved_mode = crtc->mode;
 
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#4 lore raw

PATCH 4/4 drm/i915/vlv: modeset_global_* for VLV

In reply to Jesse Barnes

On VLV/BYT, we can adjust the CDclk frequency up or down based on the max pixel clock we need to drive. Lowering it can save power, while raising it is necessary to support high resolution.

Add proper modeset_global_pipes and modeset_global_resources support to perform this adjustment as necessary.

---
 drivers/gpu/drm/i915/i915_reg.h      |   2 +
 drivers/gpu/drm/i915/intel_display.c | 151 +++++++++++++++++++++++++++++++++++
 2 files changed, 153 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 737d8a3..9de4adb 100644
@@ -1453,6 +1453,8 @@
 #define   CZCLK_FREQ_MASK	0xf
 #define GMBUSFREQ_VLV		(VLV_DISPLAY_BASE + 0x6510)
 
+#define CZCLK_CDCLK_FREQ_RATIO	(VLV_DISPLAY_BASE + 0x6508)
+
 /*
  * Palette regs
  */
drivers/gpu/drm/i915/intel_display.c +151 -0

163 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 1/1 drm/i915/vlv: modeset_global_* for VLV v2

On VLV/BYT, we can adjust the CDclk frequency up or down based on the max pixel clock we need to drive. Lowering it can save power, while raising it is necessary to support high resolution.

Add proper modeset_global_pipes and modeset_global_resources support to perform this adjustment as necessary.

v2: use punit interface for 320 and 266 MHz CDclk adjustments (Ville)

---
 drivers/gpu/drm/i915/i915_reg.h      |   7 ++
 drivers/gpu/drm/i915/intel_display.c | 175 +++++++++++++++++++++++++++++++++++
 2 files changed, 182 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 737d8a3..8a34dcc 100644
@@ -363,6 +363,11 @@
 #define PUNIT_OPCODE_REG_READ			6
 #define PUNIT_OPCODE_REG_WRITE			7
 
+#define PUNIT_REG_DSPFREQ			0x36
+#define   DSPFREQSTAT_SHIFT			30
+#define   DSPFREQSTAT_MASK			(0x3 << DSPFREQSTAT_SHIFT)
+#define   DSPFREQGUAR_SHIFT			14
+#define   DSPFREQGUAR_MASK			(0x3 << DSPFREQGUAR_SHIFT)
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define	  PUNIT_CLK_GATE			1
@@ -1453,6 +1458,8 @@
 #define   CZCLK_FREQ_MASK	0xf
 #define GMBUSFREQ_VLV		(VLV_DISPLAY_BASE + 0x6510)
 
+#define CZCLK_CDCLK_FREQ_RATIO	(VLV_DISPLAY_BASE + 0x6508)
+
 /*
  * Palette regs
  */
drivers/gpu/drm/i915/intel_display.c +175 -0

187 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 1/1 drm/i915/vlv: modeset_global_* for VLV v3

On VLV/BYT, we can adjust the CDclk frequency up or down based on the max pixel clock we need to drive. Lowering it can save power, while raising it is necessary to support high resolution.

Add proper modeset_global_pipes and modeset_global_resources support to perform this adjustment as necessary.

v2: use punit interface for 320 and 266 MHz CDclk adjustments (Ville)
v3: reset GMBUS dividers too, since we changed CDclk (Ville)

---
 drivers/gpu/drm/i915/i915_reg.h      |   7 ++
 drivers/gpu/drm/i915/intel_display.c | 178 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_i2c.c     |   4 -
 3 files changed, 185 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 737d8a3..8a34dcc 100644
@@ -363,6 +363,11 @@
 #define PUNIT_OPCODE_REG_READ			6
 #define PUNIT_OPCODE_REG_WRITE			7
 
+#define PUNIT_REG_DSPFREQ			0x36
+#define   DSPFREQSTAT_SHIFT			30
+#define   DSPFREQSTAT_MASK			(0x3 << DSPFREQSTAT_SHIFT)
+#define   DSPFREQGUAR_SHIFT			14
+#define   DSPFREQGUAR_MASK			(0x3 << DSPFREQGUAR_SHIFT)
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define	  PUNIT_CLK_GATE			1
@@ -1453,6 +1458,8 @@
 #define   CZCLK_FREQ_MASK	0xf
 #define GMBUSFREQ_VLV		(VLV_DISPLAY_BASE + 0x6510)
 
+#define CZCLK_CDCLK_FREQ_RATIO	(VLV_DISPLAY_BASE + 0x6508)
+
 /*
  * Palette regs
  */
drivers/gpu/drm/i915/intel_display.c +178 -0

190 lines not on this page · raw message

drivers/gpu/drm/i915/intel_i2c.c +0 -4
index 2ca17b1..1263409 100644
@@ -87,10 +87,6 @@ static void gmbus_set_freq(struct drm_i915_private *dev_priv)
 
 	BUG_ON(!IS_VALLEYVIEW(dev_priv->dev));
 
-	/* Skip setting the gmbus freq if BIOS has already programmed it */
-	if (I915_READ(GMBUSFREQ_VLV) != 0xA0)
-		return;
-
 	/* Obtain SKU information */
 	mutex_lock(&dev_priv->dpio_lock);
 	hpll_freq =
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 1/1 drm/i915: add modeset_global_pipes callback for global config adjustments

In some cases we may need to turn off more pipes than just the ones affected by a connector or encoder change, probably due to modifying some global resource that requires all pipes to shut down. Add a hook for this purpose to allow platform code to adjust the prepare_pipes mask, which allows otherwise active pipes to get shut down for the duration of the mode set, then restored at the end.

---
 drivers/gpu/drm/i915/i915_drv.h      | 12 ++++++++++++
 drivers/gpu/drm/i915/intel_display.c |  7 +++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +12 -0
index 5edf9bb..7530cd4 100644
@@ -380,6 +380,18 @@ struct drm_i915_display_funcs {
 				 struct drm_crtc *crtc,
 				 uint32_t sprite_width, int pixel_size,
 				 bool enable, bool scaled);
+	/**
+	 * modeset_global_pipes - figure out which pipes need to be disabled
+	 * @dev: drm device
+	 * @prepare_pipes: bitmask of pipes to disable
+	 *
+	 * In some cases, adjusting a global resource may require shutting
+	 * down seemingly unrelated pipes on a mode set.  This function
+	 * should determine that and adjust the prepare_pipes bitmask
+	 * as needed.
+	 */
+	void (*modeset_global_pipes)(struct drm_device *dev,
+				     unsigned *prepare_pipes);
 	void (*modeset_global_resources)(struct drm_device *dev);
 	/* Returns the active state of the crtc, and if the crtc is active,
 	 * fills out the pipe-config with the hw state. */
drivers/gpu/drm/i915/intel_display.c +7 -0
index 606a594..faa7548 100644
@@ -9298,6 +9298,13 @@ static int __intel_set_mode(struct drm_crtc *crtc,
 	intel_modeset_affected_pipes(crtc, &modeset_pipes,
 				     &prepare_pipes, &disable_pipes);
 
+	/*
+	 * See if the config requires any additional preparation, e.g.
+	 * to adjust global state with pipes off.
+	 */
+	if (dev_priv->display.modeset_global_pipes)
+		dev_priv->display.modeset_global_pipes(dev, &prepare_pipes);
+
 	*saved_hwmode = crtc->hwmode;
 	*saved_mode = crtc->mode;
 
Signature · 1 line
1.8.3.1
#8 lore raw

Re: [PATCH] drm/i915: add modeset_global_pipes callback for global config adjustments

Quoted 8 lines · On Fri, 1 Nov 2013 12:24:06 -0700 Jesse Barnes <[email protected]>…

In some cases we may need to turn off more pipes than just the ones affected by a connector or encoder change, probably due to modifying some global resource that requires all pipes to shut down. Add a hook for this purpose to allow platform code to adjust the prepare_pipes mask, which allows otherwise active pipes to get shut down for the duration of the mode set, then restored at the end.

Oops just went back in time with the wrong commit... will resend yet again.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#9 lore raw

PATCH 1/1 drm/i915/vlv: modeset_global_* for VLV v4

In reply to Jesse Barnes

On VLV/BYT, we can adjust the CDclk frequency up or down based on the max pixel clock we need to drive. Lowering it can save power, while raising it is necessary to support high resolution.

Add proper modeset_global_pipes and modeset_global_resources support to perform this adjustment as necessary.

v2: use punit interface for 320 and 266 MHz CDclk adjustments (Ville)
v3: reset GMBUS dividers too, since we changed CDclk (Ville)
v4: jump to highest voltage when going to 400MHz CDclk (Jesse)

---
 drivers/gpu/drm/i915/i915_reg.h      |   7 ++
 drivers/gpu/drm/i915/intel_display.c | 176 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_i2c.c     |   4 -
 3 files changed, 183 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 737d8a3..8a34dcc 100644
@@ -363,6 +363,11 @@
 #define PUNIT_OPCODE_REG_READ			6
 #define PUNIT_OPCODE_REG_WRITE			7
 
+#define PUNIT_REG_DSPFREQ			0x36
+#define   DSPFREQSTAT_SHIFT			30
+#define   DSPFREQSTAT_MASK			(0x3 << DSPFREQSTAT_SHIFT)
+#define   DSPFREQGUAR_SHIFT			14
+#define   DSPFREQGUAR_MASK			(0x3 << DSPFREQGUAR_SHIFT)
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define	  PUNIT_CLK_GATE			1
@@ -1453,6 +1458,8 @@
 #define   CZCLK_FREQ_MASK	0xf
 #define GMBUSFREQ_VLV		(VLV_DISPLAY_BASE + 0x6510)
 
+#define CZCLK_CDCLK_FREQ_RATIO	(VLV_DISPLAY_BASE + 0x6508)
+
 /*
  * Palette regs
  */
drivers/gpu/drm/i915/intel_display.c +176 -0

188 lines not on this page · raw message

drivers/gpu/drm/i915/intel_i2c.c +0 -4
index 2ca17b1..1263409 100644
@@ -87,10 +87,6 @@ static void gmbus_set_freq(struct drm_i915_private *dev_priv)
 
 	BUG_ON(!IS_VALLEYVIEW(dev_priv->dev));
 
-	/* Skip setting the gmbus freq if BIOS has already programmed it */
-	if (I915_READ(GMBUSFREQ_VLV) != 0xA0)
-		return;
-
 	/* Obtain SKU information */
 	mutex_lock(&dev_priv->dpio_lock);
 	hpll_freq =
Signature · 1 line
1.8.3.1
#10 lore raw

Re: [PATCH] drm/i915/vlv: modeset_global_* for VLV v4

Quoted 35 lines · Jesse Barnes

On VLV/BYT, we can adjust the CDclk frequency up or down based on the max pixel clock we need to drive. Lowering it can save power, while raising it is necessary to support high resolution.

Add proper modeset_global_pipes and modeset_global_resources support to perform this adjustment as necessary.

v2: use punit interface for 320 and 266 MHz CDclk adjustments (Ville)
v3: reset GMBUS dividers too, since we changed CDclk (Ville)
v4: jump to highest voltage when going to 400MHz CDclk (Jesse)

---
 drivers/gpu/drm/i915/i915_reg.h      |   7 ++
 drivers/gpu/drm/i915/intel_display.c | 176 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_i2c.c     |   4 -
 3 files changed, 183 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +5 -0
index 737d8a3..8a34dcc 100644
@@ -363,6 +363,11 @@
 #define PUNIT_OPCODE_REG_READ			6
 #define PUNIT_OPCODE_REG_WRITE			7
 
+#define PUNIT_REG_DSPFREQ			0x36
+#define   DSPFREQSTAT_SHIFT			30
+#define   DSPFREQSTAT_MASK			(0x3 << DSPFREQSTAT_SHIFT)
+#define   DSPFREQGUAR_SHIFT			14
+#define   DSPFREQGUAR_MASK			(0x3 << DSPFREQGUAR_SHIFT)
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define	  PUNIT_CLK_GATE			1

drivers/gpu/drm/i915/i915_reg.h line 1462

Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
@@ -1453,6 +1458,8 @@
 #define   CZCLK_FREQ_MASK	0xf
 #define GMBUSFREQ_VLV		(VLV_DISPLAY_BASE + 0x6510)
 
+#define CZCLK_CDCLK_FREQ_RATIO	(VLV_DISPLAY_BASE + 0x6508)
+

It's already there a few lines above, w/ fancy names for the bits and everything.

Quoted 20 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * Palette regs
  */
drivers/gpu/drm/i915/intel_display.c +9 -0
index faa7548..2ff2a29 100644
@@ -3894,6 +3894,177 @@ static void i9xx_pfit_enable(struct intel_crtc *crtc)
 	I915_WRITE(BCLRPAT(crtc->pipe), 0);
 }
 
+static int valleyview_get_vco(struct drm_i915_private *dev_priv)
+{
+	int vco;
+
+	switch (dev_priv->mem_freq) {
+	default:
+	case 800:
+		vco = 800;
+		break;

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 3915

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+	case 1066:
+		vco = 1600;
+		break;
+	case 1333:
+		vco = 2000;
+		break;
+	}
+
+	return vco;
+}

We have two ways to get this information now. The other is in intel_i2c.c. Maybe we should unify a bit.

Quoted 22 lines
drivers/gpu/drm/i915/intel_display.c +22 -0
+
+/* Adjust CDclk dividers to allow high res or save power if possible */
+static void valleyview_set_cdclk(struct drm_device *dev, int cdclk)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 val, cmd;
+
+	if (cdclk >= 320) /* jump to highest voltage for 400MHz too */
+		cmd = 2;
+	else if (cdclk == 266)
+		cmd = 1;
+	else
+		cmd = 0;
+
+	mutex_lock(&dev_priv->rps.hw_lock);
+	val = vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ);
+	val &= ~DSPFREQGUAR_MASK;
+	val |= (cmd << DSPFREQGUAR_SHIFT);
+	vlv_punit_write(dev_priv, PUNIT_REG_DSPFREQ, val);
+	if (wait_for((vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ) &
+		      DSPFREQSTAT_MASK) == (cmd << DSPFREQSTAT_SHIFT),
+		     50)) {

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 3947

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+		DRM_ERROR("timed out waiting for CDclk change\n");
+	}
+	mutex_unlock(&dev_priv->rps.hw_lock);
+
+	if (cdclk == 400) {
+		u32 divider, vco;
+
+		vco = valleyview_get_vco(dev_priv);
+		divider = (vco * 10) / cdclk;
+		divider = ((divider * 2) / 10) - 1;

Why the *10/10?

Just this should do:
divider = (vco << 1) / cdclk - 1

Quoted 35 lines
drivers/gpu/drm/i915/intel_display.c +35 -0
+
+		mutex_lock(&dev_priv->dpio_lock);
+		/* adjust cdclk divider */
+		val = vlv_cck_read(dev_priv, 0x6b);
+		val &= ~0xf;
+		val |= divider;
+		vlv_cck_write(dev_priv, 0x6b, val);
+		mutex_unlock(&dev_priv->dpio_lock);
+	}
+
+	mutex_lock(&dev_priv->dpio_lock);
+	/* adjust self-refresh exit latency value */
+	val = vlv_bunit_read(dev_priv, 0x11);
+	val &= ~0x7f;
+
+	/*
+	 * For high bandwidth configs, we set a higher latency in the bunit
+	 * so that the core display fetch happens in time to avoid underruns.
+	 */
+	if (cdclk == 400)
+		val |= 0x12;
+	else
+		val |= 0xc;
+	vlv_bunit_write(dev_priv, 0x11, val);
+	mutex_unlock(&dev_priv->dpio_lock);
+
+	/* Since we changed the CDclk, we need to update the GMBUSFREQ too */
+	intel_i2c_reset(dev);
+}
+
+static int valleyview_cur_cdclk(struct drm_i915_private *dev_priv)
+{
+	int cur_cdclk, vco;
+	int divider;
+

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 3992

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+	vco = valleyview_get_vco(dev_priv);
+
+	mutex_lock(&dev_priv->dpio_lock);
+	divider = vlv_cck_read(dev_priv, 0x6b);
+	mutex_unlock(&dev_priv->dpio_lock);
+
+	divider &= 0xf;
+	divider = ((divider + 1) * 10) / 2;
+
+	cur_cdclk = (vco * 10) / divider;

Again *10/10 seems useless.
Just 'cur_cdclk = (vco << 1) / (divider + 1)'

But again we have a bit of code duplication w/ intel_i2c.c.

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +13 -0
+
+	return cur_cdclk;
+}
+
+static int valleyview_calc_cdclk(struct drm_i915_private *dev_priv,
+				 int max_pixclk)
+{
+	int cur_cdclk;
+
+	cur_cdclk = valleyview_cur_cdclk(dev_priv);
+
+	/*
+	 * Really only a few cases to deal with, as only 4 CDclks are supported:

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4015

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+	 *   200MHz
+	 *   267MHz
+	 *   320MHz
+	 *   400MHz
+	 * So we check to see whether we're above 90% of the lower bin and
+	 * adjust if needed.
+	 */
+	if (max_pixclk > 288000) {
+		return 400;
+	} else if (max_pixclk <= 288000 && max_pixclk > 240300) {

Assuming the 267 mhz is in fact 266.666... that would be just 240000.

Also the <= check is useless. Just > is enough.

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4019

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+		return 320;
+	} else
+		return 266;
+	/* Looks like the 200MHz CDclk freq doesn't work on some configs */

Too bad. But I guess we just need to avoid it for now. Maybe we can get it working later.

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+}
+
+static int intel_mode_max_pixclk(struct drm_i915_private *dev_priv)
+{
+	struct drm_device *dev = dev_priv->dev;

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4034

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+	struct intel_crtc *intel_crtc;
+	int max_pixclk = 0;
+
+	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
+			    base.head) {
+		if (!intel_crtc->base.enabled)
+			continue;
+
+		if (max_pixclk < intel_crtc->config.adjusted_mode.clock)
+			max_pixclk = intel_crtc->config.adjusted_mode.clock;

Should be .crtc_clock actually.

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +9 -0
+	}
+
+	return max_pixclk;
+}
+
+static void valleyview_modeset_global_pipes(struct drm_device *dev,
+					    unsigned *prepare_pipes)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4053

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+	struct intel_crtc *intel_crtc;
+	int max_pixclk = intel_mode_max_pixclk(dev_priv);
+	int cur_cdclk = valleyview_cur_cdclk(dev_priv);
+
+	if (valleyview_calc_cdclk(dev_priv, max_pixclk) == cur_cdclk)
+		return;
+
+	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
+			    base.head)
+		if (intel_crtc->base.enabled)

intel_crtc->active maybe? Although I guess they should be the same when this gets called.

Quoted 51 lines
drivers/gpu/drm/i915/intel_display.c +19 -0
+			*prepare_pipes |= (1 << intel_crtc->pipe);
+}
+
+static void valleyview_modeset_global_resources(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int max_pixclk = intel_mode_max_pixclk(dev_priv);
+	int cur_cdclk = valleyview_cur_cdclk(dev_priv);
+	int req_cdclk = valleyview_calc_cdclk(dev_priv, max_pixclk);
+
+	if (req_cdclk != cur_cdclk)
+		valleyview_set_cdclk(dev, req_cdclk);
+}
+
 static void valleyview_crtc_enable(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -10336,6 +10507,11 @@ static void intel_init_display(struct drm_device *dev)
 		}
 	} else if (IS_G4X(dev)) {
 		dev_priv->display.write_eld = g4x_write_eld;
+	} else if (IS_VALLEYVIEW(dev)) {
+		dev_priv->display.modeset_global_resources =
+			valleyview_modeset_global_resources;
+		dev_priv->display.modeset_global_pipes =
+			valleyview_modeset_global_pipes;
 	}
 
 	/* Default just returns -ENODEV to indicate unsupported */
drivers/gpu/drm/i915/intel_i2c.c +0 -4
index 2ca17b1..1263409 100644
@@ -87,10 +87,6 @@ static void gmbus_set_freq(struct drm_i915_private *dev_priv)
 
 	BUG_ON(!IS_VALLEYVIEW(dev_priv->dev));
 
-	/* Skip setting the gmbus freq if BIOS has already programmed it */
-	if (I915_READ(GMBUSFREQ_VLV) != 0xA0)
-		return;
-
 	/* Obtain SKU information */
 	mutex_lock(&dev_priv->dpio_lock);
 	hpll_freq =
Signature · 6 lines
1.8.3.1

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

Re: [PATCH] drm/i915/vlv: modeset_global_* for VLV v4

Quoted 9 lines · Ville Syrjälä
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +9 -0
+static void valleyview_modeset_global_pipes(struct drm_device *dev,
+                                         unsigned *prepare_pipes)
+{
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct intel_crtc *intel_crtc;
+     int max_pixclk = intel_mode_max_pixclk(dev_priv);
+     int cur_cdclk = valleyview_cur_cdclk(dev_priv);
+
+     if (valleyview_calc_cdclk(dev_priv, max_pixclk) == cur_cdclk)
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4053

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+             return;
+
+     list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
+                         base.head)
+             if (intel_crtc->base.enabled)

intel_crtc->active maybe? Although I guess they should be the same when this gets called.

A WARN_ON(intel_crtc->active) might be useful here to double-check that the separet logic to frob prepare_pipes actually did it's job correctly. It's always good to be paranoid when the logic needs to be splattered over disparate pieces of code.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#12 lore raw

Re: [PATCH] drm/i915/vlv: modeset_global_* for VLV v4

In reply to Ville Syrjälä
Quoted 39 lines · On Fri, 1 Nov 2013 21:52:44 +0200 Ville Syrjälä…
Quoted 38 lines · Jesse Barnes

On VLV/BYT, we can adjust the CDclk frequency up or down based on the max pixel clock we need to drive. Lowering it can save power, while raising it is necessary to support high resolution.

Add proper modeset_global_pipes and modeset_global_resources support to perform this adjustment as necessary.

v2: use punit interface for 320 and 266 MHz CDclk adjustments (Ville)
v3: reset GMBUS dividers too, since we changed CDclk (Ville)
v4: jump to highest voltage when going to 400MHz CDclk (Jesse)

---
 drivers/gpu/drm/i915/i915_reg.h      |   7 ++
 drivers/gpu/drm/i915/intel_display.c | 176 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_i2c.c     |   4 -
 3 files changed, 183 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +5 -0
index 737d8a3..8a34dcc 100644
@@ -363,6 +363,11 @@
 #define PUNIT_OPCODE_REG_READ			6
 #define PUNIT_OPCODE_REG_WRITE			7
 
+#define PUNIT_REG_DSPFREQ			0x36
+#define   DSPFREQSTAT_SHIFT			30
+#define   DSPFREQSTAT_MASK			(0x3 << DSPFREQSTAT_SHIFT)
+#define   DSPFREQGUAR_SHIFT			14
+#define   DSPFREQGUAR_MASK			(0x3 << DSPFREQGUAR_SHIFT)
 #define PUNIT_REG_PWRGT_CTRL			0x60
 #define PUNIT_REG_PWRGT_STATUS			0x61
 #define	  PUNIT_CLK_GATE			1
@@ -1453,6 +1458,8 @@
 #define   CZCLK_FREQ_MASK	0xf
 #define GMBUSFREQ_VLV		(VLV_DISPLAY_BASE + 0x6510)
 
Quoted 5 lines

drivers/gpu/drm/i915/i915_reg.h line 1462

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define CZCLK_CDCLK_FREQ_RATIO	(VLV_DISPLAY_BASE + 0x6508)
+

It's already there a few lines above, w/ fancy names for the bits and everything.

Oh missed that obviously, will drop and use the existing bits. Should have known since gmbus uses this...

Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
 /*
  * Palette regs
  */
drivers/gpu/drm/i915/intel_display.c +14 -0
index faa7548..2ff2a29 100644
@@ -3894,6 +3894,177 @@ static void i9xx_pfit_enable(struct intel_crtc *crtc)
 	I915_WRITE(BCLRPAT(crtc->pipe), 0);
 }
 
+static int valleyview_get_vco(struct drm_i915_private *dev_priv)
+{
+	int vco;
+
+	switch (dev_priv->mem_freq) {
+	default:
+	case 800:
+		vco = 800;
+		break;
+	case 1066:
+		vco = 1600;
+		break;
+	case 1333:
+		vco = 2000;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 3915

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+		break;
+	}
+
+	return vco;
+}

We have two ways to get this information now. The other is in intel_i2c.c. Maybe we should unify a bit.

I'll take a look when I fix up the register define duplication.

Quoted 36 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_display.c +22 -0
+
+/* Adjust CDclk dividers to allow high res or save power if possible */
+static void valleyview_set_cdclk(struct drm_device *dev, int cdclk)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 val, cmd;
+
+	if (cdclk >= 320) /* jump to highest voltage for 400MHz too */
+		cmd = 2;
+	else if (cdclk == 266)
+		cmd = 1;
+	else
+		cmd = 0;
+
+	mutex_lock(&dev_priv->rps.hw_lock);
+	val = vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ);
+	val &= ~DSPFREQGUAR_MASK;
+	val |= (cmd << DSPFREQGUAR_SHIFT);
+	vlv_punit_write(dev_priv, PUNIT_REG_DSPFREQ, val);
+	if (wait_for((vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ) &
+		      DSPFREQSTAT_MASK) == (cmd << DSPFREQSTAT_SHIFT),
+		     50)) {

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 3947

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+		DRM_ERROR("timed out waiting for CDclk change\n");
+	}
+	mutex_unlock(&dev_priv->rps.hw_lock);
+
+	if (cdclk == 400) {
+		u32 divider, vco;
+
+		vco = valleyview_get_vco(dev_priv);
+		divider = (vco * 10) / cdclk;
+		divider = ((divider * 2) / 10) - 1;

Why the *10/10?

Quoted 2 lines

Just this should do:
divider = (vco << 1) / cdclk - 1

Yeah *2 would be sufficient here. I just liked the 10 since I used it elsewhere for fixed point bits.

Quoted 50 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_display.c +35 -0
+
+		mutex_lock(&dev_priv->dpio_lock);
+		/* adjust cdclk divider */
+		val = vlv_cck_read(dev_priv, 0x6b);
+		val &= ~0xf;
+		val |= divider;
+		vlv_cck_write(dev_priv, 0x6b, val);
+		mutex_unlock(&dev_priv->dpio_lock);
+	}
+
+	mutex_lock(&dev_priv->dpio_lock);
+	/* adjust self-refresh exit latency value */
+	val = vlv_bunit_read(dev_priv, 0x11);
+	val &= ~0x7f;
+
+	/*
+	 * For high bandwidth configs, we set a higher latency in the bunit
+	 * so that the core display fetch happens in time to avoid underruns.
+	 */
+	if (cdclk == 400)
+		val |= 0x12;
+	else
+		val |= 0xc;
+	vlv_bunit_write(dev_priv, 0x11, val);
+	mutex_unlock(&dev_priv->dpio_lock);
+
+	/* Since we changed the CDclk, we need to update the GMBUSFREQ too */
+	intel_i2c_reset(dev);
+}
+
+static int valleyview_cur_cdclk(struct drm_i915_private *dev_priv)
+{
+	int cur_cdclk, vco;
+	int divider;
+

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 3992

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+	vco = valleyview_get_vco(dev_priv);
+
+	mutex_lock(&dev_priv->dpio_lock);
+	divider = vlv_cck_read(dev_priv, 0x6b);
+	mutex_unlock(&dev_priv->dpio_lock);
+
+	divider &= 0xf;
+	divider = ((divider + 1) * 10) / 2;
+
+	cur_cdclk = (vco * 10) / divider;

Again *10/10 seems useless.
Just 'cur_cdclk = (vco << 1) / (divider + 1)'

Quoted 1 line

But again we have a bit of code duplication w/ intel_i2c.c.

Yeah and the reg contents should match the CCK read, so these could be unified.

Quoted 27 lines
Quoted 14 lines
drivers/gpu/drm/i915/intel_display.c +13 -0
+
+	return cur_cdclk;
+}
+
+static int valleyview_calc_cdclk(struct drm_i915_private *dev_priv,
+				 int max_pixclk)
+{
+	int cur_cdclk;
+
+	cur_cdclk = valleyview_cur_cdclk(dev_priv);
+
+	/*
+	 * Really only a few cases to deal with, as only 4 CDclks are supported:

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4015

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+	 *   200MHz
+	 *   267MHz
+	 *   320MHz
+	 *   400MHz
+	 * So we check to see whether we're above 90% of the lower bin and
+	 * adjust if needed.
+	 */
+	if (max_pixclk > 288000) {
+		return 400;
+	} else if (max_pixclk <= 288000 && max_pixclk > 240300) {

Assuming the 267 mhz is in fact 266.666... that would be just 240000.

Quoted 1 line

Also the <= check is useless. Just > is enough.

I just liked documenting the range. But I can drop that.

Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4019

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+		return 320;
+	} else
+		return 266;
+	/* Looks like the 200MHz CDclk freq doesn't work on some configs */

Too bad. But I guess we just need to avoid it for now. Maybe we can get it working later.

Yeah if we can do some more testing and figure out the limitations we might be able to enable it. Should save a bit more power, especially if we can drop the voltage even further for the 200MHz clock.

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +9 -0
+}
+
+static int intel_mode_max_pixclk(struct drm_i915_private *dev_priv)
+{
+	struct drm_device *dev = dev_priv->dev;
+	struct intel_crtc *intel_crtc;
+	int max_pixclk = 0;
+
+	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4034

Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +6 -0
+			    base.head) {
+		if (!intel_crtc->base.enabled)
+			continue;
+
+		if (max_pixclk < intel_crtc->config.adjusted_mode.clock)
+			max_pixclk = intel_crtc->config.adjusted_mode.clock;

Should be .crtc_clock actually.

will fix.

Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/i915/intel_display.c +14 -0
+	}
+
+	return max_pixclk;
+}
+
+static void valleyview_modeset_global_pipes(struct drm_device *dev,
+					    unsigned *prepare_pipes)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc;
+	int max_pixclk = intel_mode_max_pixclk(dev_priv);
+	int cur_cdclk = valleyview_cur_cdclk(dev_priv);
+
+	if (valleyview_calc_cdclk(dev_priv, max_pixclk) == cur_cdclk)
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void i9xx_pfit_enable(struct intel_crtc *crtc) · line 4053

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+		return;
+
+	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
+			    base.head)
+		if (intel_crtc->base.enabled)

intel_crtc->active maybe? Although I guess they should be the same when this gets called.

Either works, I was looking at the other global_resources and mode setting code for this.

Thanks for the review, will re-post.

Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/4
#13 lore raw
In reply to Jesse Barnes
Quoted 3 lines · Jesse Barnes

For modifying self-refresh exit latency.

Quoted 65 lines
---
 drivers/gpu/drm/i915/i915_drv.h       |  2 ++
 drivers/gpu/drm/i915/i915_reg.h       |  1 +
 drivers/gpu/drm/i915/intel_sideband.c | 16 ++++++++++++++++
 3 files changed, 19 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index cc40cbf..5edf9bb 100644
@@ -2403,6 +2403,8 @@ u32 vlv_cck_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_cck_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_ccu_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_ccu_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
+u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg);
+void vlv_bunit_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_gps_core_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_gps_core_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_dpio_read(struct drm_i915_private *dev_priv, enum pipe pipe, int reg);
drivers/gpu/drm/i915/i915_reg.h +1 -0
index de58947..737d8a3 100644
@@ -349,6 +349,7 @@
 #define   IOSF_BYTE_ENABLES_SHIFT		4
 #define   IOSF_BAR_SHIFT			1
 #define   IOSF_SB_BUSY				(1<<0)
+#define   IOSF_PORT_BUNIT			0x3
 #define   IOSF_PORT_PUNIT			0x4
 #define   IOSF_PORT_NC				0x11
 #define   IOSF_PORT_DPIO			0x12
drivers/gpu/drm/i915/intel_sideband.c +16 -0
index 9944d81..d43e457 100644
@@ -90,6 +90,22 @@ void vlv_punit_write(struct drm_i915_private *dev_priv, u8 addr, u32 val)
 	mutex_unlock(&dev_priv->dpio_lock);
 }
 
+u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg)
+{
+	u32 val = 0;
+
+	vlv_sideband_rw(dev_priv, PCI_DEVFN(2, 0), IOSF_PORT_BUNIT,
+			PUNIT_OPCODE_REG_READ, reg, &val);
+
+	return val;
+}
+
+void vlv_bunit_write(struct drm_i915_private *dev_priv, u32 reg, u32 val)
+{
+	vlv_sideband_rw(dev_priv, PCI_DEVFN(2, 0), IOSF_PORT_BUNIT,
+			PUNIT_OPCODE_REG_WRITE, reg, &val);
+}
+
 u32 vlv_nc_read(struct drm_i915_private *dev_priv, u8 addr)
 {
 	u32 val = 0;
Signature · 6 lines
1.8.3.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC