Skip to contentSkip to conversation

Broxton ddi phy refactoring

PATCH Superseded Ander Conselvan de Oliveira 4 participants 18 messages Oct 5, 2016 – Oct 6, 2016

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Broxton ddi phy refactoring

Hi,

This is a small refactoring of the broxton ddi phy code that splits the knowledge of each phy's configuration from the code itself and makes the connection between the ports and the channels in the phy more obvious.

I took the oppurtunity to move the code to intel_dpio_phy.c, since there are a lot of similarities between the bxt and chv phys, as evidenced by the documentation.

Thanks,
Ander

Ander Conselvan de Oliveira (9):
drm/i915: Rename struct i915_power_well field data to id drm/i915: Explicitly map broxton DPIO power wells to phys drm/i915: Pass lane count to bxt_ddi_phy_calc_lane_optmin_mask() drm/i915: Move broxton phy code to intel_dpio_phy.c drm/i915: Move DPIO phy documentation section to intel_dpio_phy.c drm/i915: Move broxton vswing sequence to intel_dpio_phy.c drm/i915: Create a struct to hold information about the broxton phys drm/i915: Add location of the Rcomp resistor to bxt_ddi_phy_info drm/i915: Address broxton phy registers based on phy and channel
number

 Documentation/gpu/i915.rst              |   2 +-
 drivers/gpu/drm/i915/i915_drv.h         |  23 ++
 drivers/gpu/drm/i915/i915_reg.h         | 303 +++++-----------
 drivers/gpu/drm/i915/intel_ddi.c        | 362 +------------------
 drivers/gpu/drm/i915/intel_dpio_phy.c   | 597 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dpll_mgr.c   |  84 +++--
 drivers/gpu/drm/i915/intel_drv.h        |   6 -
 drivers/gpu/drm/i915/intel_runtime_pm.c | 145 ++++----
 8 files changed, 821 insertions(+), 701 deletions(-)
Signature · 6 lines
2.5.5

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

PATCH 1/9 drm/i915: Rename struct i915_power_well field data to id

Calling it data seems to imply arbitrary data can be associated with the power well. However, that field is used for look ups and expected to be unique, so rename it.

---
 drivers/gpu/drm/i915/i915_drv.h         |   3 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c | 112 ++++++++++++++++----------------
 2 files changed, 58 insertions(+), 57 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 4613f03..5bd3f59 100644
@@ -1316,7 +1316,8 @@ struct i915_power_well {
 	/* cached hw enabled state */
 	bool hw_enabled;
 	unsigned long domains;
-	unsigned long data;
+	/* unique identifier for this power well */
+	unsigned long id;
 	const struct i915_power_well_ops *ops;
 };
 
drivers/gpu/drm/i915/intel_runtime_pm.c +56 -56

396 lines not on this page · raw message

Signature · 6 lines
2.5.5

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

PATCH 2/9 drm/i915: Explicitly map broxton DPIO power wells to phys

In reply to Ander Conselvan de Oliveira

The mapping from the BXT_DPIO_CMN_* power wells to their respective phys required a detour implemented in the bxt_power_well_to_phy() function. Instead, embed that information directly into the power_well struct, by resurrecting the data field.

---
 drivers/gpu/drm/i915/i915_drv.h         |  5 +++++
 drivers/gpu/drm/i915/intel_runtime_pm.c | 22 +++++++---------------
 2 files changed, 12 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -0
index 5bd3f59..93c90b9 100644
@@ -1318,6 +1318,11 @@ struct i915_power_well {
 	unsigned long domains;
 	/* unique identifier for this power well */
 	unsigned long id;
+	/*
+	 * Arbitraty data associated with this power well. Platform and power
+	 * well specific.
+	 */
+	unsigned long data;
 	const struct i915_power_well_ops *ops;
 };
 
drivers/gpu/drm/i915/intel_runtime_pm.c +7 -15
index 4ecaf6a..d41fd46 100644
@@ -846,13 +846,6 @@ static void skl_power_well_disable(struct drm_i915_private *dev_priv,
 	skl_set_power_well(dev_priv, power_well, false);
 }
 
-static enum dpio_phy bxt_power_well_to_phy(struct i915_power_well *power_well)
-{
-	enum skl_disp_power_wells power_well_id = power_well->id;
-
-	return power_well_id == BXT_DPIO_CMN_A ? DPIO_PHY1 : DPIO_PHY0;
-}
-
 static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv,
 					   struct i915_power_well *power_well)
 {
@@ -868,7 +861,7 @@ static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv,
 		intel_power_well_get(dev_priv, cmn_a_well);
 	}
 
-	bxt_ddi_phy_init(dev_priv, bxt_power_well_to_phy(power_well));
+	bxt_ddi_phy_init(dev_priv, power_well->data);
 
 	if (cmn_a_well)
 		intel_power_well_put(dev_priv, cmn_a_well);
@@ -877,14 +870,13 @@ static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv,
 static void bxt_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv,
 					    struct i915_power_well *power_well)
 {
-	bxt_ddi_phy_uninit(dev_priv, bxt_power_well_to_phy(power_well));
+	bxt_ddi_phy_uninit(dev_priv, power_well->data);
 }
 
 static bool bxt_dpio_cmn_power_well_enabled(struct drm_i915_private *dev_priv,
 					    struct i915_power_well *power_well)
 {
-	return bxt_ddi_phy_is_enabled(dev_priv,
-				      bxt_power_well_to_phy(power_well));
+	return bxt_ddi_phy_is_enabled(dev_priv, power_well->data);
 }
 
 static void bxt_dpio_cmn_power_well_sync_hw(struct drm_i915_private *dev_priv,
@@ -903,13 +895,11 @@ static void bxt_verify_ddi_phy_power_wells(struct drm_i915_private *dev_priv)
 
 	power_well = lookup_power_well(dev_priv, BXT_DPIO_CMN_A);
 	if (power_well->count > 0)
-		bxt_ddi_phy_verify_state(dev_priv,
-					 bxt_power_well_to_phy(power_well));
+		bxt_ddi_phy_verify_state(dev_priv, power_well->data);
 
 	power_well = lookup_power_well(dev_priv, BXT_DPIO_CMN_BC);
 	if (power_well->count > 0)
-		bxt_ddi_phy_verify_state(dev_priv,
-					 bxt_power_well_to_phy(power_well));
+		bxt_ddi_phy_verify_state(dev_priv, power_well->data);
 }
 
 static bool gen9_dc_off_power_well_enabled(struct drm_i915_private *dev_priv,
@@ -2163,12 +2153,14 @@ static struct i915_power_well bxt_power_wells[] = {
 		.domains = BXT_DPIO_CMN_A_POWER_DOMAINS,
 		.ops = &bxt_dpio_cmn_power_well_ops,
 		.id = BXT_DPIO_CMN_A,
+		.data = DPIO_PHY1,
 	},
 	{
 		.name = "dpio-common-bc",
 		.domains = BXT_DPIO_CMN_BC_POWER_DOMAINS,
 		.ops = &bxt_dpio_cmn_power_well_ops,
 		.id = BXT_DPIO_CMN_BC,
+		.data = DPIO_PHY0,
 	},
 };
 
Signature · 6 lines
2.5.5

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

PATCH 3/9 drm/i915: Pass lane count to bxt_ddi_phy_calc_lane_optmin_mask()

In reply to Ander Conselvan de Oliveira

Pass lane count to bxt_ddi_phy_calc_lane_optmin_mask() instead of having it extract that number from a pipe_config to decouple the phy code from intel_crtc_state.

---
 drivers/gpu/drm/i915/intel_ddi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +4 -4
index 35f0b7c..1dc7543 100644
@@ -2120,9 +2120,9 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
 
 static uint8_t
 bxt_ddi_phy_calc_lane_lat_optim_mask(struct intel_encoder *encoder,
-				     struct intel_crtc_state *pipe_config)
+				     uint8_t lane_count)
 {
-	switch (pipe_config->lane_count) {
+	switch (lane_count) {
 	case 1:
 		return 0;
 	case 2:
@@ -2130,7 +2130,7 @@ bxt_ddi_phy_calc_lane_lat_optim_mask(struct intel_encoder *encoder,
 	case 4:
 		return BIT(3) | BIT(2) | BIT(0);
 	default:
-		MISSING_CASE(pipe_config->lane_count);
+		MISSING_CASE(lane_count);
 
 		return 0;
 	}
@@ -2347,7 +2347,7 @@ static bool intel_ddi_compute_config(struct intel_encoder *encoder,
 	if (IS_BROXTON(dev_priv) && ret)
 		pipe_config->lane_lat_optim_mask =
 			bxt_ddi_phy_calc_lane_lat_optim_mask(encoder,
-							     pipe_config);
+							     pipe_config->lane_count);
 
 	return ret;
 
Signature · 6 lines
2.5.5

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

PATCH 4/9 drm/i915: Move broxton phy code to intel_dpio_phy.c

In reply to Ander Conselvan de Oliveira

The phy in broxton is also a dpio phy, similar to cherryview but with programming through MMIO. So move the code together with the other similar phys.

---
 drivers/gpu/drm/i915/i915_drv.h       |  12 ++
 drivers/gpu/drm/i915/intel_ddi.c      | 322 +--------------------------------
 drivers/gpu/drm/i915/intel_dpio_phy.c | 327 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h      |   6 -
 4 files changed, 341 insertions(+), 326 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +12 -0
index 93c90b9..8bdbbb5 100644
@@ -3735,6 +3735,18 @@ u32 vlv_flisdsi_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_flisdsi_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 
 /* intel_dpio_phy.c */
+void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy);
+void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy);
+bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
+			    enum dpio_phy phy);
+bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
+			      enum dpio_phy phy);
+uint8_t bxt_ddi_phy_calc_lane_lat_optim_mask(struct intel_encoder *encoder,
+					     uint8_t lane_count);
+void bxt_ddi_phy_set_lane_optim_mask(struct intel_encoder *encoder,
+				     uint8_t lane_lat_optim_mask);
+uint8_t bxt_ddi_phy_get_lane_lat_optim_mask(struct intel_encoder *encoder);
+
 void chv_set_phy_signal_level(struct intel_encoder *encoder,
 			      u32 deemph_reg_value, u32 margin_reg_value,
 			      bool uniq_trans_scale);
drivers/gpu/drm/i915/intel_ddi.c +2 -320

334 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dpio_phy.c +327 -0

333 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +0 -6
index f48e79a..c150807 100644
@@ -1328,12 +1328,6 @@ void hsw_enable_pc8(struct drm_i915_private *dev_priv);
 void hsw_disable_pc8(struct drm_i915_private *dev_priv);
 void bxt_init_cdclk(struct drm_i915_private *dev_priv);
 void bxt_uninit_cdclk(struct drm_i915_private *dev_priv);
-void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy);
-void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy);
-bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
-			    enum dpio_phy phy);
-bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
-			      enum dpio_phy phy);
 void gen9_sanitize_dc_state(struct drm_i915_private *dev_priv);
 void bxt_enable_dc9(struct drm_i915_private *dev_priv);
 void bxt_disable_dc9(struct drm_i915_private *dev_priv);
Signature · 6 lines
2.5.5

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

PATCH 5/9 drm/i915: Move DPIO phy documentation section to intel_dpio_phy.c

In reply to Ander Conselvan de Oliveira

Move the DPIO phy documentation section to intel_dpio_phy.c, since that is a more suitable place now that there is a source file dedicated for those phys.

---
 Documentation/gpu/i915.rst            |  2 +-
 drivers/gpu/drm/i915/i915_reg.h       | 91 +----------------------------------
 drivers/gpu/drm/i915/intel_dpio_phy.c | 91 +++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 91 deletions(-)
Documentation/gpu/i915.rst +1 -1
index 87aaffc..8cecae1 100644
@@ -180,7 +180,7 @@ Display Refresh Rate Switching (DRRS)
 DPIO
 ----
 
-.. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
+.. kernel-doc:: drivers/gpu/drm/i915/intel_dpio_phy.c
    :doc: DPIO
 
 CSR firmware support for DMC
drivers/gpu/drm/i915/i915_reg.h +1 -90

97 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dpio_phy.c +91 -0

97 lines not on this page · raw message

Signature · 6 lines
2.5.5

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

PATCH 6/9 drm/i915: Move broxton vswing sequence to intel_dpio_phy.c

In reply to Ander Conselvan de Oliveira

The vswing sequence is related to the DPIO phy, so move it closer to the rest of DPIO phy related code.

---
 drivers/gpu/drm/i915/i915_drv.h       |  3 +++
 drivers/gpu/drm/i915/intel_ddi.c      | 38 +++++-----------------------------
 drivers/gpu/drm/i915/intel_dpio_phy.c | 39 +++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 33 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 8bdbbb5..77f1374 100644
@@ -3735,6 +3735,9 @@ u32 vlv_flisdsi_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_flisdsi_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 
 /* intel_dpio_phy.c */
+void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
+				  enum port port, u32 margin, u32 scale,
+				  u32 enable, u32 deemphasis);
 void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy);
 void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy);
 bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_ddi.c +5 -33
index d69d231..f27cd67 100644
@@ -1477,7 +1477,6 @@ static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv,
 {
 	const struct bxt_ddi_buf_trans *ddi_translations;
 	u32 n_entries, i;
-	uint32_t val;
 
 	if (type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp.low_vswing) {
 		n_entries = ARRAY_SIZE(bxt_ddi_translations_edp);
@@ -1506,38 +1505,11 @@ static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv,
 		}
 	}
 
-	/*
-	 * While we write to the group register to program all lanes at once we
-	 * can read only lane registers and we pick lanes 0/1 for that.
-	 */
-	val = I915_READ(BXT_PORT_PCS_DW10_LN01(port));
-	val &= ~(TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT);
-	I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val);
-
-	val = I915_READ(BXT_PORT_TX_DW2_LN0(port));
-	val &= ~(MARGIN_000 | UNIQ_TRANS_SCALE);
-	val |= ddi_translations[level].margin << MARGIN_000_SHIFT |
-	       ddi_translations[level].scale << UNIQ_TRANS_SCALE_SHIFT;
-	I915_WRITE(BXT_PORT_TX_DW2_GRP(port), val);
-
-	val = I915_READ(BXT_PORT_TX_DW3_LN0(port));
-	val &= ~SCALE_DCOMP_METHOD;
-	if (ddi_translations[level].enable)
-		val |= SCALE_DCOMP_METHOD;
-
-	if ((val & UNIQUE_TRANGE_EN_METHOD) && !(val & SCALE_DCOMP_METHOD))
-		DRM_ERROR("Disabled scaling while ouniqetrangenmethod was set");
-
-	I915_WRITE(BXT_PORT_TX_DW3_GRP(port), val);
-
-	val = I915_READ(BXT_PORT_TX_DW4_LN0(port));
-	val &= ~DE_EMPHASIS;
-	val |= ddi_translations[level].deemphasis << DEEMPH_SHIFT;
-	I915_WRITE(BXT_PORT_TX_DW4_GRP(port), val);
-
-	val = I915_READ(BXT_PORT_PCS_DW10_LN01(port));
-	val |= TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT;
-	I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val);
+	bxt_ddi_phy_set_signal_level(dev_priv, port,
+				     ddi_translations[level].margin,
+				     ddi_translations[level].scale,
+				     ddi_translations[level].enable,
+				     ddi_translations[level].deemphasis);
 }
 
 static uint32_t translate_signal_level(int signal_levels)
drivers/gpu/drm/i915/intel_dpio_phy.c +39 -0
index 6806296..2a18724 100644
@@ -114,6 +114,45 @@
  *     -----------------
  */
 
+void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
+				  enum port port, u32 margin, u32 scale,
+				  u32 enable, u32 deemphasis)
+{
+	u32 val;
+
+	/*
+	 * While we write to the group register to program all lanes at once we
+	 * can read only lane registers and we pick lanes 0/1 for that.
+	 */
+	val = I915_READ(BXT_PORT_PCS_DW10_LN01(port));
+	val &= ~(TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT);
+	I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val);
+
+	val = I915_READ(BXT_PORT_TX_DW2_LN0(port));
+	val &= ~(MARGIN_000 | UNIQ_TRANS_SCALE);
+	val |= margin << MARGIN_000_SHIFT | scale << UNIQ_TRANS_SCALE_SHIFT;
+	I915_WRITE(BXT_PORT_TX_DW2_GRP(port), val);
+
+	val = I915_READ(BXT_PORT_TX_DW3_LN0(port));
+	val &= ~SCALE_DCOMP_METHOD;
+	if (enable)
+		val |= SCALE_DCOMP_METHOD;
+
+	if ((val & UNIQUE_TRANGE_EN_METHOD) && !(val & SCALE_DCOMP_METHOD))
+		DRM_ERROR("Disabled scaling while ouniqetrangenmethod was set");
+
+	I915_WRITE(BXT_PORT_TX_DW3_GRP(port), val);
+
+	val = I915_READ(BXT_PORT_TX_DW4_LN0(port));
+	val &= ~DE_EMPHASIS;
+	val |= deemphasis << DEEMPH_SHIFT;
+	I915_WRITE(BXT_PORT_TX_DW4_GRP(port), val);
+
+	val = I915_READ(BXT_PORT_PCS_DW10_LN01(port));
+	val |= TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT;
+	I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val);
+}
+
 bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
 			    enum dpio_phy phy)
 {
Signature · 6 lines
2.5.5

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

PATCH 7/9 drm/i915: Create a struct to hold information about the broxton phys

In reply to Ander Conselvan de Oliveira

Information about which phy is dual channel is hardcoded in the phy init sequence. Split that to a separate struct so the init sequence is more generic.

---
 drivers/gpu/drm/i915/i915_reg.h       |  9 +++--
 drivers/gpu/drm/i915/intel_dpio_phy.c | 63 +++++++++++++++++++++++++++++------
 2 files changed, 60 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +7 -2
index f6d29fb..d3802c6 100644
@@ -1308,8 +1308,13 @@ enum skl_disp_power_wells {
 #define BXT_PORT_CL1CM_DW30(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW30_BC, \
 							_PORT_CL1CM_DW30_A)
 
-/* Defined for PHY0 only */
-#define BXT_PORT_CL2CM_DW6_BC		_MMIO(0x6C358)
+/* The spec defines this only for BXT PHY0, but lets assume that this
+ * would exist for PHY1 too if it had a second channel.
+ */
+#define _PORT_CL2CM_DW6_A		0x162358
+#define _PORT_CL2CM_DW6_BC		0x6C358
+#define BXT_PORT_CL2CM_DW6(phy)		_BXT_PHY((phy), _PORT_CL2CM_DW6_BC, \
+							_PORT_CL2CM_DW6_A)
 #define   DW6_OLDO_DYN_PWR_DOWN_EN	(1 << 28)
 
 /* BXT PHY Ref registers */
drivers/gpu/drm/i915/intel_dpio_phy.c +53 -10

107 lines not on this page · raw message

Signature · 6 lines
2.5.5

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

Re: [PATCH 7/9] drm/i915: Create a struct to hold information about the broxton phys

Quoted 67 lines · Ander Conselvan de Oliveira

Information about which phy is dual channel is hardcoded in the phy init sequence. Split that to a separate struct so the init sequence is more generic.

Signed-off-by Ander Conselvan de Oliveira

---
 drivers/gpu/drm/i915/i915_reg.h       |  9 +++-- drivers/gpu/drm/i915/intel_dpio_phy.c | 63 +++++++++++++++++++++++++++++------

 2 files changed, 60 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index f6d29fb..d3802c6 100644
@@ -1308,8 +1308,13 @@ enum skl_disp_power_wells {
  #define BXT_PORT_CL1CM_DW30(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW30_BC, \
  							_PORT_CL1CM_DW30_A)

drivers/gpu/drm/i915/i915_reg.h +7 -2
-/* Defined for PHY0 only */
-#define BXT_PORT_CL2CM_DW6_BC		_MMIO(0x6C358)
+/* The spec defines this only for BXT PHY0, but lets assume that this
+ * would exist for PHY1 too if it had a second channel.
+ */
+#define _PORT_CL2CM_DW6_A		0x162358
+#define _PORT_CL2CM_DW6_BC		0x6C358
+#define BXT_PORT_CL2CM_DW6(phy)		_BXT_PHY((phy), _PORT_CL2CM_DW6_BC, \
+							_PORT_CL2CM_DW6_A)

 #define   DW6_OLDO_DYN_PWR_DOWN_EN (1 << 28)

 /* BXT PHY Ref registers */

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
index 2a18724..66d750a 100644
@@ -114,6 +114,49 @@
   *     -----------------
   */

drivers/gpu/drm/i915/intel_dpio_phy.c +29 -0
+/**
+ * struct bxt_ddi_phy_info - Hold info for a broxton DDI phy
+ */
+struct bxt_ddi_phy_info {
+	/**
+	 * @dual_channel: true if this phy has a second channel.
+	 */
+	bool dual_channel;
+
+	/**
+	 * @channel: struct containing per channel information.
+	 */
+	struct {
+		/**
+		 * @port: which port maps to this channel.
+		 */
+		enum port port;
+	} channel[2];
+};
+
+static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
+	[DPIO_PHY0] = {
+		.dual_channel = true,
+
+		.channel = {
+			[DPIO_CH0] = { .port = PORT_B },
+			[DPIO_CH1] = { .port = PORT_C },
+		}
+	},

drivers/gpu/drm/i915/intel_dpio_phy.c line 155

Quoted 10 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +10 -0
+	[DPIO_PHY1] = {
+		.dual_channel = false,
+
+		.channel = {
+			[DPIO_CH0] = { .port = PORT_A },
+		}
+	},
+};
+
+{

Missing part above, got mangled into the next patch.

Quoted 68 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +4 -0
+	return (phy_info->dual_channel * BIT(phy_info->channel[DPIO_CH1].port)) |
+		BIT(phy_info->channel[DPIO_CH0].port);
+}
+

 void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv, enum port port, u32 margin, u32 scale, u32 enable, u32 deemphasis)

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -183,9 +226,7 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  		return false;
  	}

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -3
-	for_each_port_masked(port,
-			     phy == DPIO_PHY0 ? BIT(PORT_B) | BIT(PORT_C) :
-						BIT(PORT_A)) {
+	for_each_port_masked(port, bxt_phy_port_mask(phy_info)) {

  u32 tmp = I915_READ(BXT_PHY_CTL(port));
  if (tmp & BXT_PHY_CMNLANE_POWERDOWN_ACK) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -220,6 +261,7 @@ static void bxt_phy_wait_grc_done(struct drm_i915_private *dev_priv,


 void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy) {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];

  u32 val;

  if (bxt_ddi_phy_is_enabled(dev_priv, phy)) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -272,10 +314,10 @@ void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
  		SUS_CLK_CONFIG;
  	I915_WRITE(BXT_PORT_CL1CM_DW28(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-	if (phy == DPIO_PHY0) {
-		val = I915_READ(BXT_PORT_CL2CM_DW6_BC);
+	if (phy_info->dual_channel) {
+		val = I915_READ(BXT_PORT_CL2CM_DW6(phy));

  val |= DW6_OLDO_DYN_PWR_DOWN_EN;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_CL2CM_DW6_BC, val);
+		I915_WRITE(BXT_PORT_CL2CM_DW6(phy), val);

  }

  val = I915_READ(BXT_PORT_CL1CM_DW30(phy));

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
@@ -290,7 +332,7 @@ void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
  	 * FIXME: Clarify programming of the following, the register is
  	 * read-only with bit 6 fixed at 0 at least in stepping A.
  	 */
-	if (phy == DPIO_PHY1)
+	if (!phy_info->dual_channel)
  		val |= OCL2_LDOFUSE_PWR_DIS;
  	I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -363,6 +405,7 @@ __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy,
  bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  			      enum dpio_phy phy)
  {
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
  	uint32_t mask;
  	bool ok;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -388,10 +431,10 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  	ok &= _CHK(BXT_PORT_CL1CM_DW28(phy), mask, mask,
  		    "BXT_PORT_CL1CM_DW28(%d)", phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-	if (phy == DPIO_PHY0)
-		ok &= _CHK(BXT_PORT_CL2CM_DW6_BC,
+	if (phy_info->dual_channel)
+		ok &= _CHK(BXT_PORT_CL2CM_DW6(phy),

     DW6_OLDO_DYN_PWR_DOWN_EN, DW6_OLDO_DYN_PWR_DOWN_EN,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-			   "BXT_PORT_CL2CM_DW6_BC");
+			   "BXT_PORT_CL2CM_DW6(%d)", phy);
Quoted 3 lines


  /*
   * TODO: Verify BXT_PORT_CL1CM_DW30 bit OCL2_LDOFUSE_PWR_DIS,

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

Reviewed-by on v1 7/9
#9 lore raw

Re: [PATCH 7/9] drm/i915: Create a struct to hold information about the broxton phys

In reply to Ander Conselvan de Oliveira
Quoted 46 lines · Ander Conselvan de Oliveira

Information about which phy is dual channel is hardcoded in the phy init sequence. Split that to a separate struct so the init sequence is more generic.

Signed-off-by Ander Conselvan de Oliveira

---
 drivers/gpu/drm/i915/i915_reg.h       |  9 +++-- drivers/gpu/drm/i915/intel_dpio_phy.c | 63 +++++++++++++++++++++++++++++------

 2 files changed, 60 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index f6d29fb..d3802c6 100644
@@ -1308,8 +1308,13 @@ enum skl_disp_power_wells {
  #define BXT_PORT_CL1CM_DW30(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW30_BC, \
  							_PORT_CL1CM_DW30_A)

drivers/gpu/drm/i915/i915_reg.h +7 -2
-/* Defined for PHY0 only */
-#define BXT_PORT_CL2CM_DW6_BC		_MMIO(0x6C358)
+/* The spec defines this only for BXT PHY0, but lets assume that this
+ * would exist for PHY1 too if it had a second channel.
+ */
+#define _PORT_CL2CM_DW6_A		0x162358
+#define _PORT_CL2CM_DW6_BC		0x6C358
+#define BXT_PORT_CL2CM_DW6(phy)		_BXT_PHY((phy), _PORT_CL2CM_DW6_BC, \
+							_PORT_CL2CM_DW6_A)

 #define   DW6_OLDO_DYN_PWR_DOWN_EN (1 << 28)

 /* BXT PHY Ref registers */

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
index 2a18724..66d750a 100644
@@ -114,6 +114,49 @@
   *     -----------------
   */

drivers/gpu/drm/i915/intel_dpio_phy.c +8 -0
+/**
+ * struct bxt_ddi_phy_info - Hold info for a broxton DDI phy
+ */
+struct bxt_ddi_phy_info {
+	/**
+	 * @dual_channel: true if this phy has a second channel.
+	 */
+	bool dual_channel;

drivers/gpu/drm/i915/intel_dpio_phy.c line 134

Quoted 10 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +10 -0
+
+	/**
+	 * @channel: struct containing per channel information.
+	 */
+	struct {
+		/**
+		 * @port: which port maps to this channel.
+		 */
+		enum port port;
+	} channel[2];

Nitpick: could this be just a port mask?

Patches 1-8 look good to me, with or without the nit changes on those:

Quoted 89 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +25 -0
+};
+
+static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
+	[DPIO_PHY0] = {
+		.dual_channel = true,
+
+		.channel = {
+			[DPIO_CH0] = { .port = PORT_B },
+			[DPIO_CH1] = { .port = PORT_C },
+		}
+	},
+	[DPIO_PHY1] = {
+		.dual_channel = false,
+
+		.channel = {
+			[DPIO_CH0] = { .port = PORT_A },
+		}
+	},
+};
+
+{
+	return (phy_info->dual_channel * BIT(phy_info->channel[DPIO_CH1].port)) |
+		BIT(phy_info->channel[DPIO_CH0].port);
+}
+

 void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv, enum port port, u32 margin, u32 scale, u32 enable, u32 deemphasis)

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -183,9 +226,7 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  		return false;
  	}

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -3
-	for_each_port_masked(port,
-			     phy == DPIO_PHY0 ? BIT(PORT_B) | BIT(PORT_C) :
-						BIT(PORT_A)) {
+	for_each_port_masked(port, bxt_phy_port_mask(phy_info)) {

  u32 tmp = I915_READ(BXT_PHY_CTL(port));
  if (tmp & BXT_PHY_CMNLANE_POWERDOWN_ACK) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -220,6 +261,7 @@ static void bxt_phy_wait_grc_done(struct drm_i915_private *dev_priv,


 void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy) {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];

  u32 val;

  if (bxt_ddi_phy_is_enabled(dev_priv, phy)) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -272,10 +314,10 @@ void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
  		SUS_CLK_CONFIG;
  	I915_WRITE(BXT_PORT_CL1CM_DW28(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-	if (phy == DPIO_PHY0) {
-		val = I915_READ(BXT_PORT_CL2CM_DW6_BC);
+	if (phy_info->dual_channel) {
+		val = I915_READ(BXT_PORT_CL2CM_DW6(phy));

  val |= DW6_OLDO_DYN_PWR_DOWN_EN;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_CL2CM_DW6_BC, val);
+		I915_WRITE(BXT_PORT_CL2CM_DW6(phy), val);

  }

  val = I915_READ(BXT_PORT_CL1CM_DW30(phy));

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
@@ -290,7 +332,7 @@ void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
  	 * FIXME: Clarify programming of the following, the register is
  	 * read-only with bit 6 fixed at 0 at least in stepping A.
  	 */
-	if (phy == DPIO_PHY1)
+	if (!phy_info->dual_channel)
  		val |= OCL2_LDOFUSE_PWR_DIS;
  	I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -363,6 +405,7 @@ __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy,
  bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  			      enum dpio_phy phy)
  {
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
  	uint32_t mask;
  	bool ok;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -388,10 +431,10 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  	ok &= _CHK(BXT_PORT_CL1CM_DW28(phy), mask, mask,
  		    "BXT_PORT_CL1CM_DW28(%d)", phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-	if (phy == DPIO_PHY0)
-		ok &= _CHK(BXT_PORT_CL2CM_DW6_BC,
+	if (phy_info->dual_channel)
+		ok &= _CHK(BXT_PORT_CL2CM_DW6(phy),

     DW6_OLDO_DYN_PWR_DOWN_EN, DW6_OLDO_DYN_PWR_DOWN_EN,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-			   "BXT_PORT_CL2CM_DW6_BC");
+			   "BXT_PORT_CL2CM_DW6(%d)", phy);
Quoted 3 lines


  /*
   * TODO: Verify BXT_PORT_CL1CM_DW30 bit OCL2_LDOFUSE_PWR_DIS,

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

#10 lore raw

Re: [PATCH 7/9] drm/i915: Create a struct to hold information about the broxton phys

Quoted 61 lines · Imre Deak
Quoted 60 lines · Ander Conselvan de Oliveira

Information about which phy is dual channel is hardcoded in the phy init
sequence. Split that to a separate struct so the init sequence is more
generic.

Signed-off-by Ander Conselvan de Oliveira

---
 drivers/gpu/drm/i915/i915_reg.h       |  9 +++--
 drivers/gpu/drm/i915/intel_dpio_phy.c | 63
+++++++++++++++++++++++++++++------

 2 files changed, 60 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +0 -0
index f6d29fb..d3802c6 100644
@@ -1308,8 +1308,13 @@ enum skl_disp_power_wells {
  #define BXT_PORT_CL1CM_DW30(phy)	_BXT_PHY((phy),
 _PORT_CL1CM_DW30_BC, \

  _PORT_CL1C M_DW30_A)

drivers/gpu/drm/i915/i915_reg.h +1 -2
-/* Defined for PHY0 only */
-#define BXT_PORT_CL2CM_DW6_BC		_MMIO(0x6C358)
+/* The spec defines this only for BXT PHY0, but lets assume that

this
+ * would exist for PHY1 too if it had a second channel.
+ */

drivers/gpu/drm/i915/i915_reg.h +3 -0
+#define _PORT_CL2CM_DW6_A		0x162358
+#define _PORT_CL2CM_DW6_BC		0x6C358
+#define BXT_PORT_CL2CM_DW6(phy)		_BXT_PHY((phy),

_PORT_CL2CM_DW6_BC, \

drivers/gpu/drm/i915/i915_reg.h +1 -0
+							_PORT_CL2C

M_DW6_A)
 #define   DW6_OLDO_DYN_PWR_DOWN_EN (1 << 28)

 /* BXT PHY Ref registers */

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
index 2a18724..66d750a 100644
@@ -114,6 +114,49 @@
   *     -----------------
   */

drivers/gpu/drm/i915/intel_dpio_phy.c +12 -0
+/**
+ * struct bxt_ddi_phy_info - Hold info for a broxton DDI phy
+ */
+struct bxt_ddi_phy_info {
+	/**
+	 * @dual_channel: true if this phy has a second channel.
+	 */
+	bool dual_channel;
+
+	/**
+	 * @channel: struct containing per channel information.
+	 */
Quoted 8 lines

drivers/gpu/drm/i915/intel_dpio_phy.c line 134

Quoted 6 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +6 -0
+	struct {
+		/**
+		 * @port: which port maps to this channel.
+		 */
+		enum port port;
+	} channel[2];

Nitpick: could this be just a port mask?

Ah, just noticed in patch 9 that it cannot, so ignore the above.

Quoted 109 lines

Patches 1-8 look good to me, with or without the nit changes on those:

Quoted 104 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +22 -0
+};
+
+static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
+	[DPIO_PHY0] = {
+		.dual_channel = true,
+
+		.channel = {
+			[DPIO_CH0] = { .port = PORT_B },
+			[DPIO_CH1] = { .port = PORT_C },
+		}
+	},
+	[DPIO_PHY1] = {
+		.dual_channel = false,
+
+		.channel = {
+			[DPIO_CH0] = { .port = PORT_A },
+		}
+	},
+};
+
+{
+	return (phy_info->dual_channel * BIT(phy_info-
Quoted 1 line

channel[DPIO_CH1].port)) |

drivers/gpu/drm/i915/intel_dpio_phy.c +3 -0
+		BIT(phy_info->channel[DPIO_CH0].port);
+}
+

 void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
    enum port port, u32 margin, u32 scale,
    u32 enable, u32 deemphasis)

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -183,9 +226,7 @@ bool bxt_ddi_phy_is_enabled(struct
 drm_i915_private *dev_priv,
  		return false;
  	}

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -2
-	for_each_port_masked(port,
-			     phy == DPIO_PHY0 ? BIT(PORT_B) |

BIT(PORT_C) :

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-						BIT(PORT_A)) {
+	for_each_port_masked(port, bxt_phy_port_mask(phy_info)) {

  u32 tmp = I915_READ(BXT_PHY_CTL(port));
  if (tmp & BXT_PHY_CMNLANE_POWERDOWN_ACK) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -220,6 +261,7 @@ static void bxt_phy_wait_grc_done(struct
 drm_i915_private *dev_priv,


 void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
 {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+	const struct bxt_ddi_phy_info *phy_info =

&bxt_ddi_phy_info[phy];
  u32 val;

  if (bxt_ddi_phy_is_enabled(dev_priv, phy)) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -272,10 +314,10 @@ void bxt_ddi_phy_init(struct drm_i915_private
 *dev_priv, enum dpio_phy phy)
  		SUS_CLK_CONFIG;
  	I915_WRITE(BXT_PORT_CL1CM_DW28(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-	if (phy == DPIO_PHY0) {
-		val = I915_READ(BXT_PORT_CL2CM_DW6_BC);
+	if (phy_info->dual_channel) {
+		val = I915_READ(BXT_PORT_CL2CM_DW6(phy));

  val |= DW6_OLDO_DYN_PWR_DOWN_EN;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_CL2CM_DW6_BC, val);
+		I915_WRITE(BXT_PORT_CL2CM_DW6(phy), val);

  }

  val = I915_READ(BXT_PORT_CL1CM_DW30(phy));

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -290,7 +332,7 @@ void bxt_ddi_phy_init(struct drm_i915_private
 *dev_priv, enum dpio_phy phy)
  	 * FIXME: Clarify programming of the following, the

register is
   * read-only with bit 6 fixed at 0 at least in stepping A. */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if (phy == DPIO_PHY1)
+	if (!phy_info->dual_channel)

  val |= OCL2_LDOFUSE_PWR_DIS; I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -363,6 +405,7 @@ __phy_reg_verify_state(struct drm_i915_private
 *dev_priv, enum dpio_phy phy,
  bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  			      enum dpio_phy phy)
  {
+	const struct bxt_ddi_phy_info *phy_info =
 &bxt_ddi_phy_info[phy];
  	uint32_t mask;

  bool ok;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -388,10 +431,10 @@ bool bxt_ddi_phy_verify_state(struct
 drm_i915_private *dev_priv,
  	ok &= _CHK(BXT_PORT_CL1CM_DW28(phy), mask, mask,
  		    "BXT_PORT_CL1CM_DW28(%d)", phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-	if (phy == DPIO_PHY0)
-		ok &= _CHK(BXT_PORT_CL2CM_DW6_BC,
+	if (phy_info->dual_channel)
+		ok &= _CHK(BXT_PORT_CL2CM_DW6(phy),

     DW6_OLDO_DYN_PWR_DOWN_EN, DW6_OLDO_DYN_PWR_DOWN_EN,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-			   "BXT_PORT_CL2CM_DW6_BC");
+			   "BXT_PORT_CL2CM_DW6(%d)", phy);
Quoted 8 lines
Quoted 4 lines


  /*
   * TODO: Verify BXT_PORT_CL1CM_DW30 bit
OCL2_LDOFUSE_PWR_DIS,

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

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

#11 lore raw

PATCH 8/9 drm/i915: Add location of the Rcomp resistor to bxt_ddi_phy_info

In reply to Ander Conselvan de Oliveira

Use struct bxt_ddi_phy_info to hold information of where the Rcomp resistor is located, instead of hard coding it in the init sequence.

Note that this moves the enabling of the phy with the Rcomp resistor out of the power well enable code. That should be safe since bxt_ddi_phy_init() is called while the power domains lock is held, and that is the only way that function gets called, so there is no possibility of a concurrent phy enable caused by a power domain get call.

---
 drivers/gpu/drm/i915/intel_dpio_phy.c   | 76 +++++++++++++++++++++++++--------
 drivers/gpu/drm/i915/intel_runtime_pm.c | 15 -------
 2 files changed, 59 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/intel_dpio_phy.c +59 -17
index 66d750a..e8a75fd 100644
@@ -124,6 +124,13 @@ struct bxt_ddi_phy_info {
 	bool dual_channel;
 
 	/**
+	 * @rcomp_phy: If -1, indicates this phy has its own rcomp resistor.
+	 * Otherwise the GRC value will be copied from the phy indicated by
+	 * this field.
+	 */
+	enum dpio_phy rcomp_phy;
+
+	/**
 	 * @channel: struct containing per channel information.
 	 */
 	struct {
@@ -137,6 +144,7 @@ struct bxt_ddi_phy_info {
 static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
 	[DPIO_PHY0] = {
 		.dual_channel = true,
+		.rcomp_phy = DPIO_PHY1,
 
 		.channel = {
 			[DPIO_CH0] = { .port = PORT_B },
@@ -145,6 +153,7 @@ static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
 	},
 	[DPIO_PHY1] = {
 		.dual_channel = false,
+		.rcomp_phy = -1,
 
 		.channel = {
 			[DPIO_CH0] = { .port = PORT_A },
@@ -152,6 +161,7 @@ static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
 	},
 };
 
+static u32 bxt_phy_port_mask(const struct bxt_ddi_phy_info *phy_info)
 {
 	return (phy_info->dual_channel * BIT(phy_info->channel[DPIO_CH1].port)) |
 		BIT(phy_info->channel[DPIO_CH0].port);
@@ -199,6 +209,7 @@ void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
 bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
 			    enum dpio_phy phy)
 {
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
 	enum port port;
 
 	if (!(I915_READ(BXT_P_CR_GT_DISP_PWRON) & GT_DISPLAY_POWER_ON(phy)))
@@ -212,9 +223,10 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
 		return false;
 	}
 
-	if (phy == DPIO_PHY1 &&
-	    !(I915_READ(BXT_PORT_REF_DW3(DPIO_PHY1)) & GRC_DONE)) {
-		DRM_DEBUG_DRIVER("DDI PHY 1 powered, but GRC isn't done\n");
+	if (phy_info->rcomp_phy == -1 &&
+	    !(I915_READ(BXT_PORT_REF_DW3(phy)) & GRC_DONE)) {
+		DRM_DEBUG_DRIVER("DDI PHY %d powered, but GRC isn't done\n",
+				 phy);
 
 		return false;
 	}
@@ -259,14 +271,15 @@ static void bxt_phy_wait_grc_done(struct drm_i915_private *dev_priv,
 		DRM_ERROR("timeout waiting for PHY%d GRC\n", phy);
 }
 
-void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
+static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
+			      enum dpio_phy phy)
 {
 	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
 	u32 val;
 
 	if (bxt_ddi_phy_is_enabled(dev_priv, phy)) {
 		/* Still read out the GRC value for state verification */
-		if (phy == DPIO_PHY0)
+		if (phy_info->rcomp_phy != -1)
 			dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv, phy);
 
 		if (bxt_ddi_phy_verify_state(dev_priv, phy)) {
@@ -336,30 +349,32 @@ void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
 		val |= OCL2_LDOFUSE_PWR_DIS;
 	I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);
 
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {
 		uint32_t grc_code;
 		/*
 		 * PHY0 isn't connected to an RCOMP resistor so copy over
 		 * the corresponding calibrated value from PHY1, and disable
 		 * the automatic calibration on PHY0.
 		 */
-		val = dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv, DPIO_PHY1);
+		val = dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv,
+							  phy_info->rcomp_phy);
 		grc_code = val << GRC_CODE_FAST_SHIFT |
 			   val << GRC_CODE_SLOW_SHIFT |
 			   val;
-		I915_WRITE(BXT_PORT_REF_DW6(DPIO_PHY0), grc_code);
+		I915_WRITE(BXT_PORT_REF_DW6(phy), grc_code);
 
-		val = I915_READ(BXT_PORT_REF_DW8(DPIO_PHY0));
+		val = I915_READ(BXT_PORT_REF_DW8(phy));
 		val |= GRC_DIS | GRC_RDY_OVRD;
-		I915_WRITE(BXT_PORT_REF_DW8(DPIO_PHY0), val);
+		I915_WRITE(BXT_PORT_REF_DW8(phy), val);
 	}
 
 	val = I915_READ(BXT_PHY_CTL_FAMILY(phy));
 	val |= COMMON_RESET_DIS;
 	I915_WRITE(BXT_PHY_CTL_FAMILY(phy), val);
 
-	if (phy == DPIO_PHY1)
-		bxt_phy_wait_grc_done(dev_priv, DPIO_PHY1);
+	if (phy_info->rcomp_phy == -1)
+		bxt_phy_wait_grc_done(dev_priv, phy);
+
 }
 
 void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy)
@@ -375,6 +390,33 @@ void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy)
 	I915_WRITE(BXT_P_CR_GT_DISP_PWRON, val);
 }
 
+/* This function assumes it is called from an intel_display_power_get() call,
+ * which would serialize any other attempts to enable the phy with the Rcomp
+ * resistor.
+ */
+void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
+{
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
+	enum dpio_phy rcomp_phy = phy_info->rcomp_phy;
+	bool was_enabled;
+
+	if (rcomp_phy != -1) {
+		was_enabled = bxt_ddi_phy_is_enabled(dev_priv, rcomp_phy);
+
+		/*
+		 * We need to copy the GRC calibration value from rcomp_phy,
+		 * so make sure it's powered up.
+		 */
+		if (!was_enabled)
+			_bxt_ddi_phy_init(dev_priv, rcomp_phy);
+	}
+
+	_bxt_ddi_phy_init(dev_priv, phy);
+
+	if (rcomp_phy != -1 && !was_enabled)
+		bxt_ddi_phy_uninit(dev_priv, phy_info->rcomp_phy);
+}
+
 static bool __printf(6, 7)
 __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy,
 		       i915_reg_t reg, u32 mask, u32 expected,
@@ -441,7 +483,7 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
 	 * at least on stepping A this bit is read-only and fixed at 0.
 	 */
 
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {
 		u32 grc_code = dev_priv->bxt_phy_grc;
 
 		grc_code = grc_code << GRC_CODE_FAST_SHIFT |
@@ -449,12 +491,12 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
 			   grc_code;
 		mask = GRC_CODE_FAST_MASK | GRC_CODE_SLOW_MASK |
 		       GRC_CODE_NOM_MASK;
-		ok &= _CHK(BXT_PORT_REF_DW6(DPIO_PHY0), mask, grc_code,
-			    "BXT_PORT_REF_DW6(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW6(phy), mask, grc_code,
+			    "BXT_PORT_REF_DW6(%d)", phy);
 
 		mask = GRC_DIS | GRC_RDY_OVRD;
-		ok &= _CHK(BXT_PORT_REF_DW8(DPIO_PHY0), mask, mask,
-			    "BXT_PORT_REF_DW8(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW8(phy), mask, mask,
+			    "BXT_PORT_REF_DW8(%d)", phy);
 	}
 
 	return ok;
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -15
index d41fd46..3b38998 100644
@@ -849,22 +849,7 @@ static void skl_power_well_disable(struct drm_i915_private *dev_priv,
 static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv,
 					   struct i915_power_well *power_well)
 {
-	enum skl_disp_power_wells power_well_id = power_well->id;
-	struct i915_power_well *cmn_a_well = NULL;
-
-	if (power_well_id == BXT_DPIO_CMN_BC) {
-		/*
-		 * We need to copy the GRC calibration value from the eDP PHY,
-		 * so make sure it's powered up.
-		 */
-		cmn_a_well = lookup_power_well(dev_priv, BXT_DPIO_CMN_A);
-		intel_power_well_get(dev_priv, cmn_a_well);
-	}
-
 	bxt_ddi_phy_init(dev_priv, power_well->data);
-
-	if (cmn_a_well)
-		intel_power_well_put(dev_priv, cmn_a_well);
 }
 
 static void bxt_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv,
Signature · 6 lines
2.5.5

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

Re: [PATCH 8/9] drm/i915: Add location of the Rcomp resistor to bxt_ddi_phy_info

Quoted 141 lines · Ander Conselvan de Oliveira

Use struct bxt_ddi_phy_info to hold information of where the Rcomp resistor is located, instead of hard coding it in the init sequence.

Note that this moves the enabling of the phy with the Rcomp resistor out of the power well enable code. That should be safe since bxt_ddi_phy_init() is called while the power domains lock is held, and that is the only way that function gets called, so there is no possibility of a concurrent phy enable caused by a power domain get call.

Signed-off-by Ander Conselvan de Oliveira

---
 drivers/gpu/drm/i915/intel_dpio_phy.c   | 76 +++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_runtime_pm.c | 15 -------

 2 files changed, 59 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
index 66d750a..e8a75fd 100644
@@ -124,6 +124,13 @@ struct bxt_ddi_phy_info {
  	bool dual_channel;


  /**

drivers/gpu/drm/i915/intel_dpio_phy.c +7 -0
+	 * @rcomp_phy: If -1, indicates this phy has its own rcomp resistor.
+	 * Otherwise the GRC value will be copied from the phy indicated by
+	 * this field.
+	 */
+	enum dpio_phy rcomp_phy;
+
+	/**

   * @channel: struct containing per channel information. */
  struct {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -137,6 +144,7 @@ struct bxt_ddi_phy_info {
  static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
  	[DPIO_PHY0] = {
  		.dual_channel = true,
+		.rcomp_phy = DPIO_PHY1,


  .channel = {
  [DPIO_CH0] = { .port = PORT_B },

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -145,6 +153,7 @@ static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
  	},
  	[DPIO_PHY1] = {
  		.dual_channel = false,
+		.rcomp_phy = -1,


  .channel = {
  [DPIO_CH0] = { .port = PORT_A },

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -152,6 +161,7 @@ static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
  	},
  };


+static u32 bxt_phy_port_mask(const struct bxt_ddi_phy_info *phy_info) {
  return (phy_info->dual_channel * BIT(phy_info->channel[DPIO_CH1].port)) | BIT(phy_info->channel[DPIO_CH0].port);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -199,6 +209,7 @@ void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
  bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  			    enum dpio_phy phy)
  {
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
  	enum port port;


  if (!(I915_READ(BXT_P_CR_GT_DISP_PWRON) & GT_DISPLAY_POWER_ON(phy)))

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -212,9 +223,10 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  		return false;
  	}

drivers/gpu/drm/i915/intel_dpio_phy.c +4 -3
-	if (phy == DPIO_PHY1 &&
-	    !(I915_READ(BXT_PORT_REF_DW3(DPIO_PHY1)) & GRC_DONE)) {
-		DRM_DEBUG_DRIVER("DDI PHY 1 powered, but GRC isn't done\n");
+	if (phy_info->rcomp_phy == -1 &&
+	    !(I915_READ(BXT_PORT_REF_DW3(phy)) & GRC_DONE)) {
+		DRM_DEBUG_DRIVER("DDI PHY %d powered, but GRC isn't done\n",
+				 phy);


  return false;
  }

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -259,14 +271,15 @@ static void bxt_phy_wait_grc_done(struct drm_i915_private *dev_priv,
  		DRM_ERROR("timeout waiting for PHY%d GRC\n", phy);
  }

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -1
-void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
+static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
+			      enum dpio_phy phy)

 {
  const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy]; u32 val;

  if (bxt_ddi_phy_is_enabled(dev_priv, phy)) {
  /* Still read out the GRC value for state verification */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		if (phy == DPIO_PHY0)
+		if (phy_info->rcomp_phy != -1)

  dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv, phy);
  if (bxt_ddi_phy_verify_state(dev_priv, phy)) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -336,30 +349,32 @@ void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
  		val |= OCL2_LDOFUSE_PWR_DIS;
  	I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {

  uint32_t grc_code;
  /*
   * PHY0 isn't connected to an RCOMP resistor so copy over
   * the corresponding calibrated value from PHY1, and disable
   * the automatic calibration on PHY0.
   */

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -1
-		val = dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv, DPIO_PHY1);
+		val = dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv,
+							  phy_info->rcomp_phy);

  grc_code = val << GRC_CODE_FAST_SHIFT | val << GRC_CODE_SLOW_SHIFT | val;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_REF_DW6(DPIO_PHY0), grc_code);
+		I915_WRITE(BXT_PORT_REF_DW6(phy), grc_code);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		val = I915_READ(BXT_PORT_REF_DW8(DPIO_PHY0));
+		val = I915_READ(BXT_PORT_REF_DW8(phy));

  val |= GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_REF_DW8(DPIO_PHY0), val);
+		I915_WRITE(BXT_PORT_REF_DW8(phy), val);

  }

  val = I915_READ(BXT_PHY_CTL_FAMILY(phy));
  val |= COMMON_RESET_DIS;
  I915_WRITE(BXT_PHY_CTL_FAMILY(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +3 -2
-	if (phy == DPIO_PHY1)
-		bxt_phy_wait_grc_done(dev_priv, DPIO_PHY1);
+	if (phy_info->rcomp_phy == -1)
+		bxt_phy_wait_grc_done(dev_priv, phy);
+

 }

 void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy)

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -375,6 +390,33 @@ void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy)
  	I915_WRITE(BXT_P_CR_GT_DISP_PWRON, val);
  }
Quoted 5 lines


+/* This function assumes it is called from an intel_display_power_get() call,
+ * which would serialize any other attempts to enable the phy with the Rcomp
+ * resistor.
+ */

You could replace the above with a mutex locked assert.

Quoted 12 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +12 -0
+void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
+{
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
+	enum dpio_phy rcomp_phy = phy_info->rcomp_phy;
+	bool was_enabled;
+
+	if (rcomp_phy != -1) {
+		was_enabled = bxt_ddi_phy_is_enabled(dev_priv, rcomp_phy);
+
+		/*
+		 * We need to copy the GRC calibration value from rcomp_phy,
+		 * so make sure it's powered up.

drivers/gpu/drm/i915/intel_dpio_phy.c void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy) · line 418

Quoted 10 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +10 -0
+		 */
+		if (!was_enabled)
+			_bxt_ddi_phy_init(dev_priv, rcomp_phy);
+	}
+
+	_bxt_ddi_phy_init(dev_priv, phy);
+
+	if (rcomp_phy != -1 && !was_enabled)
+		bxt_ddi_phy_uninit(dev_priv, phy_info->rcomp_phy);
+}

Nitpick: An alternative would be to add the power well dependency as a custom power well field for the cmn power wells. We'd avoid the unnecessary HW access in bxt_ddi_phy_is_enabled().

Quoted 55 lines

+
 static bool __printf(6, 7)
 __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy, i915_reg_t reg, u32 mask, u32 expected,

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -441,7 +483,7 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  	 * at least on stepping A this bit is read-only and fixed at 0.
  	 */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {

  u32 grc_code = dev_priv->bxt_phy_grc;
  grc_code = grc_code << GRC_CODE_FAST_SHIFT |

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -449,12 +491,12 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  			   grc_code;

  mask = GRC_CODE_FAST_MASK | GRC_CODE_SLOW_MASK | GRC_CODE_NOM_MASK;

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-		ok &= _CHK(BXT_PORT_REF_DW6(DPIO_PHY0), mask, grc_code,
-			    "BXT_PORT_REF_DW6(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW6(phy), mask, grc_code,
+			    "BXT_PORT_REF_DW6(%d)", phy);


  mask = GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-		ok &= _CHK(BXT_PORT_REF_DW8(DPIO_PHY0), mask, mask,
-			    "BXT_PORT_REF_DW8(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW8(phy), mask, mask,
+			    "BXT_PORT_REF_DW8(%d)", phy);

  }

  return ok;

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -15
index d41fd46..3b38998 100644
@@ -849,22 +849,7 @@ static void skl_power_well_disable(struct drm_i915_private *dev_priv,
  static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv,
  					   struct i915_power_well *power_well)
  {
-	enum skl_disp_power_wells power_well_id = power_well->id;
-	struct i915_power_well *cmn_a_well = NULL;
-
-	if (power_well_id == BXT_DPIO_CMN_BC) {
-		/*
-		 * We need to copy the GRC calibration value from the eDP PHY,
-		 * so make sure it's powered up.
-		 */
-		cmn_a_well = lookup_power_well(dev_priv, BXT_DPIO_CMN_A);
-		intel_power_well_get(dev_priv, cmn_a_well);
-	}
-
  	bxt_ddi_phy_init(dev_priv, power_well->data);
-
-	if (cmn_a_well)
-		intel_power_well_put(dev_priv, cmn_a_well);
  }
Quoted 2 lines


 static void bxt_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv,

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

#13 lore raw

Re: [PATCH 8/9] drm/i915: Add location of the Rcomp resistor to bxt_ddi_phy_info

Quoted 161 lines · Imre Deak
Quoted 160 lines · Ander Conselvan de Oliveira

Use struct bxt_ddi_phy_info to hold information of where the Rcomp resistor is located, instead of hard coding it in the init sequence.

Note that this moves the enabling of the phy with the Rcomp resistor out of the power well enable code. That should be safe since bxt_ddi_phy_init() is called while the power domains lock is held, and that is the only way that function gets called, so there is no possibility of a concurrent phy enable caused by a power domain get call.

Signed-off-by Ander Conselvan de Oliveira

---
 drivers/gpu/drm/i915/intel_dpio_phy.c   | 76 +++++++++++++++++++++++++-----
---
 drivers/gpu/drm/i915/intel_runtime_pm.c | 15 -------

 2 files changed, 59 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
index 66d750a..e8a75fd 100644
@@ -124,6 +124,13 @@ struct bxt_ddi_phy_info {
  	bool dual_channel;


  /**

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+	 * @rcomp_phy: If -1, indicates this phy has its own rcomp

resistor.

drivers/gpu/drm/i915/intel_dpio_phy.c +6 -0
+	 * Otherwise the GRC value will be copied from the phy indicated by
+	 * this field.
+	 */
+	enum dpio_phy rcomp_phy;
+
+	/**

   * @channel: struct containing per channel information. */
  struct {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -137,6 +144,7 @@ struct bxt_ddi_phy_info {
  static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
  	[DPIO_PHY0] = {
  		.dual_channel = true,
+		.rcomp_phy = DPIO_PHY1,


  .channel = {
  [DPIO_CH0] = { .port = PORT_B },

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -145,6 +153,7 @@ static const struct bxt_ddi_phy_info bxt_ddi_phy_info[]
 = {
  	},
  	[DPIO_PHY1] = {
  		.dual_channel = false,
+		.rcomp_phy = -1,


  .channel = {
  [DPIO_CH0] = { .port = PORT_A },

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -152,6 +161,7 @@ static const struct bxt_ddi_phy_info bxt_ddi_phy_info[]
 = {
  	},
  };


+static u32 bxt_phy_port_mask(const struct bxt_ddi_phy_info *phy_info) {
  return (phy_info->dual_channel * BIT(phy_info-

Quoted 1 line

channel[DPIO_CH1].port)) |

  BIT(phy_info->channel[DPIO_CH0].port);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -199,6 +209,7 @@ void bxt_ddi_phy_set_signal_level(struct
 drm_i915_private *dev_priv,
  bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  			    enum dpio_phy phy)
  {
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
  	enum port port;


  if (!(I915_READ(BXT_P_CR_GT_DISP_PWRON) &
GT_DISPLAY_POWER_ON(phy)))

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -212,9 +223,10 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private
 *dev_priv,
  		return false;
  	}

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -3
-	if (phy == DPIO_PHY1 &&
-	    !(I915_READ(BXT_PORT_REF_DW3(DPIO_PHY1)) & GRC_DONE)) {
-		DRM_DEBUG_DRIVER("DDI PHY 1 powered, but GRC isn't

done\n");

drivers/gpu/drm/i915/intel_dpio_phy.c +3 -0
+	if (phy_info->rcomp_phy == -1 &&
+	    !(I915_READ(BXT_PORT_REF_DW3(phy)) & GRC_DONE)) {
+		DRM_DEBUG_DRIVER("DDI PHY %d powered, but GRC isn't

done\n",

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+				 phy);


  return false;
  }

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -259,14 +271,15 @@ static void bxt_phy_wait_grc_done(struct
 drm_i915_private *dev_priv,
  		DRM_ERROR("timeout waiting for PHY%d GRC\n", phy);
  }

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -1
-void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
+static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
+			      enum dpio_phy phy)

 {
  const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy]; u32 val;

  if (bxt_ddi_phy_is_enabled(dev_priv, phy)) {
  /* Still read out the GRC value for state verification */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		if (phy == DPIO_PHY0)
+		if (phy_info->rcomp_phy != -1)

  dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv, phy);
  if (bxt_ddi_phy_verify_state(dev_priv, phy)) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -336,30 +349,32 @@ void bxt_ddi_phy_init(struct drm_i915_private
 *dev_priv, enum dpio_phy phy)
  		val |= OCL2_LDOFUSE_PWR_DIS;
  	I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {

  uint32_t grc_code;
  /*
   * PHY0 isn't connected to an RCOMP resistor so copy over
   * the corresponding calibrated value from PHY1, and disable
   * the automatic calibration on PHY0.
   */

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -1
-		val = dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv,

DPIO_PHY1);

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -0
+		val = dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv,
+							  phy_info-
Quoted 1 line

rcomp_phy);

  grc_code = val << GRC_CODE_FAST_SHIFT | val << GRC_CODE_SLOW_SHIFT | val;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_REF_DW6(DPIO_PHY0), grc_code);
+		I915_WRITE(BXT_PORT_REF_DW6(phy), grc_code);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		val = I915_READ(BXT_PORT_REF_DW8(DPIO_PHY0));
+		val = I915_READ(BXT_PORT_REF_DW8(phy));

  val |= GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_REF_DW8(DPIO_PHY0), val);
+		I915_WRITE(BXT_PORT_REF_DW8(phy), val);

  }

  val = I915_READ(BXT_PHY_CTL_FAMILY(phy));
  val |= COMMON_RESET_DIS;
  I915_WRITE(BXT_PHY_CTL_FAMILY(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +3 -2
-	if (phy == DPIO_PHY1)
-		bxt_phy_wait_grc_done(dev_priv, DPIO_PHY1);
+	if (phy_info->rcomp_phy == -1)
+		bxt_phy_wait_grc_done(dev_priv, phy);
+

 }

 void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy)

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -375,6 +390,33 @@ void bxt_ddi_phy_uninit(struct drm_i915_private
 *dev_priv, enum dpio_phy phy)
  	I915_WRITE(BXT_P_CR_GT_DISP_PWRON, val);
  }
Quoted 8 lines
Quoted 7 lines


+/* This function assumes it is called from an intel_display_power_get() call,
+ * which would serialize any other attempts to enable the phy with the Rcomp
+ * resistor.
+ */

You could replace the above with a mutex locked assert.

I'll do that and resend.

Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +11 -0
+void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
+{
+	const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
+	enum dpio_phy rcomp_phy = phy_info->rcomp_phy;
+	bool was_enabled;
+
+	if (rcomp_phy != -1) {
+		was_enabled = bxt_ddi_phy_is_enabled(dev_priv, rcomp_phy);
+
+		/*
+		 * We need to copy the GRC calibration value from

rcomp_phy,

drivers/gpu/drm/i915/intel_dpio_phy.c +6 -0
+		 * so make sure it's powered up.
+		 */
+		if (!was_enabled)
+			_bxt_ddi_phy_init(dev_priv, rcomp_phy);
+	}
+
Quoted 8 lines

drivers/gpu/drm/i915/intel_dpio_phy.c void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy) · line 418

Quoted 5 lines
drivers/gpu/drm/i915/intel_dpio_phy.c +5 -0
+	_bxt_ddi_phy_init(dev_priv, phy);
+
+	if (rcomp_phy != -1 && !was_enabled)
+		bxt_ddi_phy_uninit(dev_priv, phy_info->rcomp_phy);
+}

Nitpick: An alternative would be to add the power well dependency as a custom power well field for the cmn power wells. We'd avoid the unnecessary HW access in bxt_ddi_phy_is_enabled().

Since you gave me the option, I'll choose to ignore this one. What I like about the current solution is that the dependency relationship between the phys is captured in a single place, so I'd like to avoid duplicating that information in the power well code.

I don't think the extra hardware access is performance critical, but if it were, maybe we could track whether the phy is enabled in the phy code too?

Ander

Quoted 60 lines
Quoted 60 lines

+
 static bool __printf(6, 7)
 __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy,
         i915_reg_t reg, u32 mask, u32 expected,

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -441,7 +483,7 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private
 *dev_priv,
  	 * at least on stepping A this bit is read-only and fixed at 0.
  	 */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {

  u32 grc_code = dev_priv->bxt_phy_grc;
  grc_code = grc_code << GRC_CODE_FAST_SHIFT |

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -449,12 +491,12 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private
 *dev_priv,
  			   grc_code;

  mask = GRC_CODE_FAST_MASK | GRC_CODE_SLOW_MASK | GRC_CODE_NOM_MASK;

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-		ok &= _CHK(BXT_PORT_REF_DW6(DPIO_PHY0), mask, grc_code,
-			    "BXT_PORT_REF_DW6(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW6(phy), mask, grc_code,
+			    "BXT_PORT_REF_DW6(%d)", phy);


  mask = GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-		ok &= _CHK(BXT_PORT_REF_DW8(DPIO_PHY0), mask, mask,
-			    "BXT_PORT_REF_DW8(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW8(phy), mask, mask,
+			    "BXT_PORT_REF_DW8(%d)", phy);

  }

  return ok;

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -0
index d41fd46..3b38998 100644
@@ -849,22 +849,7 @@ static void skl_power_well_disable(struct
 drm_i915_private *dev_priv,

 static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv,
     struct i915_power_well *power_well)
 {

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -6
-	enum skl_disp_power_wells power_well_id = power_well->id;
-	struct i915_power_well *cmn_a_well = NULL;
-
-	if (power_well_id == BXT_DPIO_CMN_BC) {
-		/*
-		 * We need to copy the GRC calibration value from the eDP

PHY,

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -6
-		 * so make sure it's powered up.
-		 */
-		cmn_a_well = lookup_power_well(dev_priv, BXT_DPIO_CMN_A);
-		intel_power_well_get(dev_priv, cmn_a_well);
-	}
-
Quoted 8 lines
Quoted 8 lines

  bxt_ddi_phy_init(dev_priv, power_well->data);

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -3
-
-	if (cmn_a_well)
-		intel_power_well_put(dev_priv, cmn_a_well);

 }

 static void bxt_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv,

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

#14 lore raw

Re: [PATCH 8/9] drm/i915: Add location of the Rcomp resistor to bxt_ddi_phy_info

Quoted 248 lines · Ander Conselvan De Oliveira
Quoted 194 lines · Imre Deak
Quoted 192 lines · Ander Conselvan de Oliveira

Use struct bxt_ddi_phy_info to hold information of where the Rcomp
resistor is located, instead of hard coding it in the init sequence.

Note that this moves the enabling of the phy with the Rcomp resistor out
of the power well enable code. That should be safe since bxt_ddi_phy_init() is called while the power domains lock is held, and
that is the only way that function gets called, so there is no possibility of a concurrent phy enable caused by a power domain get
call.

Signed-off-by Ander Conselvan de Oliveira

---
 drivers/gpu/drm/i915/intel_dpio_phy.c   | 76
+++++++++++++++++++++++++-----
---
 drivers/gpu/drm/i915/intel_runtime_pm.c | 15 -------

 2 files changed, 59 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
index 66d750a..e8a75fd 100644
@@ -124,6 +124,13 @@ struct bxt_ddi_phy_info {
  	bool dual_channel;


  /**

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+	 * @rcomp_phy: If -1, indicates this phy has its own

rcomp
resistor.

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+	 * Otherwise the GRC value will be copied from the phy

indicated by

drivers/gpu/drm/i915/intel_dpio_phy.c +5 -0
+	 * this field.
+	 */
+	enum dpio_phy rcomp_phy;
+
+	/**

   * @channel: struct containing per channel information. */
  struct {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -137,6 +144,7 @@ struct bxt_ddi_phy_info {
  static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
  	[DPIO_PHY0] = {
  		.dual_channel = true,
+		.rcomp_phy = DPIO_PHY1,


  .channel = {
  [DPIO_CH0] = { .port = PORT_B },

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -145,6 +153,7 @@ static const struct bxt_ddi_phy_info

bxt_ddi_phy_info[]
= {
  },
  [DPIO_PHY1] = {
  .dual_channel = false,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+		.rcomp_phy = -1,


  .channel = {
  [DPIO_CH0] = { .port = PORT_A },

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -152,6 +161,7 @@ static const struct bxt_ddi_phy_info

bxt_ddi_phy_info[]
= {
  },
 };

+static u32 bxt_phy_port_mask(const struct bxt_ddi_phy_info *phy_info)
 {
  return (phy_info->dual_channel * BIT(phy_info-

Quoted 1 line

channel[DPIO_CH1].port)) |

  BIT(phy_info->channel[DPIO_CH0].port);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -199,6 +209,7 @@ void bxt_ddi_phy_set_signal_level(struct
 drm_i915_private *dev_priv,
  bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  			    enum dpio_phy phy)
  {
+	const struct bxt_ddi_phy_info *phy_info =
 &bxt_ddi_phy_info[phy];
  	enum port port;


  if (!(I915_READ(BXT_P_CR_GT_DISP_PWRON) &
GT_DISPLAY_POWER_ON(phy)))

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -212,9 +223,10 @@ bool bxt_ddi_phy_is_enabled(struct

drm_i915_private
*dev_priv,
  return false;
  }

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -2
-	if (phy == DPIO_PHY1 &&
-	    !(I915_READ(BXT_PORT_REF_DW3(DPIO_PHY1)) &

GRC_DONE)) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -1
-		DRM_DEBUG_DRIVER("DDI PHY 1 powered, but GRC

isn't
done\n");

drivers/gpu/drm/i915/intel_dpio_phy.c +3 -0
+	if (phy_info->rcomp_phy == -1 &&
+	    !(I915_READ(BXT_PORT_REF_DW3(phy)) & GRC_DONE)) {
+		DRM_DEBUG_DRIVER("DDI PHY %d powered, but GRC

isn't
done\n",

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+				 phy);


  return false;
  }

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -259,14 +271,15 @@ static void bxt_phy_wait_grc_done(struct
 drm_i915_private *dev_priv,
  		DRM_ERROR("timeout waiting for PHY%d GRC\n",
 phy);
  }


-void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -0
+static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
+			      enum dpio_phy phy)

 {
  const struct bxt_ddi_phy_info *phy_info = &bxt_ddi_phy_info[phy];
  u32 val;

  if (bxt_ddi_phy_is_enabled(dev_priv, phy)) { /* Still read out the GRC value for state verification */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		if (phy == DPIO_PHY0)
+		if (phy_info->rcomp_phy != -1)

  dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv, phy);

  if (bxt_ddi_phy_verify_state(dev_priv, phy)) {

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -336,30 +349,32 @@ void bxt_ddi_phy_init(struct

drm_i915_private
*dev_priv, enum dpio_phy phy)
  val |= OCL2_LDOFUSE_PWR_DIS; I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {

  uint32_t grc_code;
  /*
   * PHY0 isn't connected to an RCOMP resistor so copy over
   * the corresponding calibrated value from PHY1, and
disable
   * the automatic calibration on PHY0. */

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -1
-		val = dev_priv->bxt_phy_grc =

bxt_get_grc(dev_priv,
DPIO_PHY1);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+		val = dev_priv->bxt_phy_grc =

bxt_get_grc(dev_priv,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+							  phy_in

fo-

Quoted 1 line

rcomp_phy);

  grc_code = val << GRC_CODE_FAST_SHIFT | val << GRC_CODE_SLOW_SHIFT | val;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -1
-		I915_WRITE(BXT_PORT_REF_DW6(DPIO_PHY0),

grc_code);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+		I915_WRITE(BXT_PORT_REF_DW6(phy), grc_code);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		val = I915_READ(BXT_PORT_REF_DW8(DPIO_PHY0));
+		val = I915_READ(BXT_PORT_REF_DW8(phy));

  val |= GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_REF_DW8(DPIO_PHY0), val);
+		I915_WRITE(BXT_PORT_REF_DW8(phy), val);

  }

  val = I915_READ(BXT_PHY_CTL_FAMILY(phy));
  val |= COMMON_RESET_DIS;
  I915_WRITE(BXT_PHY_CTL_FAMILY(phy), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +3 -2
-	if (phy == DPIO_PHY1)
-		bxt_phy_wait_grc_done(dev_priv, DPIO_PHY1);
+	if (phy_info->rcomp_phy == -1)
+		bxt_phy_wait_grc_done(dev_priv, phy);
+

 }

 void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy
phy)

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -375,6 +390,33 @@ void bxt_ddi_phy_uninit(struct

drm_i915_private
*dev_priv, enum dpio_phy phy)
  I915_WRITE(BXT_P_CR_GT_DISP_PWRON, val);
 }

+/* This function assumes it is called from an

Quoted 8 lines
Quoted 7 lines

intel_display_power_get()
call,
+ * which would serialize any other attempts to enable the phy with the
Rcomp
+ * resistor.
+ */

You could replace the above with a mutex locked assert.

I'll do that and resend.

Quoted 27 lines
Quoted 27 lines

+void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -0
+{
+	const struct bxt_ddi_phy_info *phy_info =

&bxt_ddi_phy_info[phy];

drivers/gpu/drm/i915/intel_dpio_phy.c +5 -0
+	enum dpio_phy rcomp_phy = phy_info->rcomp_phy;
+	bool was_enabled;
+
+	if (rcomp_phy != -1) {
+		was_enabled = bxt_ddi_phy_is_enabled(dev_priv,

rcomp_phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +3 -0
+
+		/*
+		 * We need to copy the GRC calibration value

from
rcomp_phy,

drivers/gpu/drm/i915/intel_dpio_phy.c +10 -0
+		 * so make sure it's powered up.
+		 */
+		if (!was_enabled)
+			_bxt_ddi_phy_init(dev_priv, rcomp_phy);
+	}
+
+	_bxt_ddi_phy_init(dev_priv, phy);
+
+	if (rcomp_phy != -1 && !was_enabled)
+		bxt_ddi_phy_uninit(dev_priv, phy_info-
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

rcomp_phy);

+}

Nitpick: An alternative would be to add the power well dependency as a
custom power well field for the cmn power wells. We'd avoid the unnecessary HW access in bxt_ddi_phy_is_enabled().

Since you gave me the option, I'll choose to ignore this one. What I like about
the current solution is that the dependency relationship between the phys is
captured in a single place, so I'd like to avoid duplicating that information in
the power well code.

Quoted 3 lines

I don't think the extra hardware access is performance critical, but if it were,
maybe we could track whether the phy is enabled in the phy code too?

No, I meant that we already track that in the power well code so checking for it here again would be redundant. But I'm also fine with your solution so let's go with that.

--Imre

Quoted 76 lines

Ander

Quoted 73 lines
Quoted 73 lines

+
 static bool __printf(6, 7) __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy
phy,
         i915_reg_t reg, u32 mask, u32 expected,

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -441,7 +483,7 @@ bool bxt_ddi_phy_verify_state(struct

drm_i915_private
*dev_priv,
   * at least on stepping A this bit is read-only and fixed at 0.
   */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if (phy == DPIO_PHY0) {
+	if (phy_info->rcomp_phy != -1) {

  u32 grc_code = dev_priv->bxt_phy_grc;
  grc_code = grc_code << GRC_CODE_FAST_SHIFT |

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -449,12 +491,12 @@ bool bxt_ddi_phy_verify_state(struct

drm_i915_private
*dev_priv,
     grc_code;
  mask = GRC_CODE_FAST_MASK | GRC_CODE_SLOW_MASK | GRC_CODE_NOM_MASK;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -1
-		ok &= _CHK(BXT_PORT_REF_DW6(DPIO_PHY0), mask,

grc_code,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-			    "BXT_PORT_REF_DW6(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW6(phy), mask,

grc_code,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+			    "BXT_PORT_REF_DW6(%d)", phy);


  mask = GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -1
-		ok &= _CHK(BXT_PORT_REF_DW8(DPIO_PHY0), mask,

mask,

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -1
-			    "BXT_PORT_REF_DW8(%d)", DPIO_PHY0);
+		ok &= _CHK(BXT_PORT_REF_DW8(phy), mask, mask,
+			    "BXT_PORT_REF_DW8(%d)", phy);

  }

  return ok;

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -0
index d41fd46..3b38998 100644
@@ -849,22 +849,7 @@ static void skl_power_well_disable(struct
 drm_i915_private *dev_priv,

 static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private
*dev_priv,
     struct i915_power_well
*power_well)
 {

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -1
-	enum skl_disp_power_wells power_well_id = power_well-
Quoted 1 line

id;

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -5
-	struct i915_power_well *cmn_a_well = NULL;
-
-	if (power_well_id == BXT_DPIO_CMN_BC) {
-		/*
-		 * We need to copy the GRC calibration value

from the eDP
PHY,

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -3
-		 * so make sure it's powered up.
-		 */
-		cmn_a_well = lookup_power_well(dev_priv,

BXT_DPIO_CMN_A);

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -3
-		intel_power_well_get(dev_priv, cmn_a_well);
-	}
-

  bxt_ddi_phy_init(dev_priv, power_well->data);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -3
-
-	if (cmn_a_well)
-		intel_power_well_put(dev_priv, cmn_a_well);

 }

 static void bxt_dpio_cmn_power_well_disable(struct drm_i915_private
*dev_priv,

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

#15 lore raw

PATCH 9/9 drm/i915: Address broxton phy registers based on phy and channel number

In reply to Ander Conselvan de Oliveira

The port registers related to the phys in broxton map to different channels and specific phys. Make that mapping explicit.

---
 drivers/gpu/drm/i915/i915_drv.h       |   2 +
 drivers/gpu/drm/i915/i915_reg.h       | 211 +++++++++++++---------------------
 drivers/gpu/drm/i915/intel_dpio_phy.c | 131 +++++++++++++++------
 drivers/gpu/drm/i915/intel_dpll_mgr.c |  84 ++++++++------
 4 files changed, 222 insertions(+), 206 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 77f1374..c3fa29a 100644
@@ -3735,6 +3735,8 @@ u32 vlv_flisdsi_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_flisdsi_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 
 /* intel_dpio_phy.c */
+void bxt_port_to_phy_channel(enum port port,
+			     u32 *phy, enum dpio_channel *ch);
 void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
 				  enum port port, u32 margin, u32 scale,
 				  u32 enable, u32 deemphasis);
drivers/gpu/drm/i915/i915_reg.h +81 -130

296 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dpio_phy.c +93 -38

295 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dpll_mgr.c +46 -38

188 lines not on this page · raw message

Signature · 6 lines
2.5.5

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

Re: [PATCH 9/9] drm/i915: Address broxton phy registers based on phy and channel number

Quoted 53 lines · Ander Conselvan de Oliveira

The port registers related to the phys in broxton map to different channels and specific phys. Make that mapping explicit.

Signed-off-by Ander Conselvan de Oliveira

---
 drivers/gpu/drm/i915/i915_drv.h       |   2 + drivers/gpu/drm/i915/i915_reg.h       | 211 +++++++++++++--------------------- drivers/gpu/drm/i915/intel_dpio_phy.c | 131 +++++++++++++++------ drivers/gpu/drm/i915/intel_dpll_mgr.c |  84 ++++++++------

 4 files changed, 222 insertions(+), 206 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 77f1374..c3fa29a 100644
@@ -3735,6 +3735,8 @@ u32 vlv_flisdsi_read(struct drm_i915_private *dev_priv, u32 reg);
  void vlv_flisdsi_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);


 /* intel_dpio_phy.c */

drivers/gpu/drm/i915/i915_drv.h +2 -0
+void bxt_port_to_phy_channel(enum port port,
+			     u32 *phy, enum dpio_channel *ch);

 void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv, enum port port, u32 margin, u32 scale, u32 enable, u32 deemphasis);

drivers/gpu/drm/i915/i915_reg.h +0 -0
index d3802c6..416cbb1 100644
@@ -1187,6 +1187,9 @@ enum skl_disp_power_wells {
  #define   DPIO_UPAR_SHIFT		30


 /* BXT PHY registers */

drivers/gpu/drm/i915/i915_reg.h +3 -0
+#define BXT_PHY1_BASE			0x162000
+#define BXT_PHY0_BASE			0x6C000
+

 #define _BXT_PHY(phy, a, b) _MMIO_PIPE((phy), (a), (b))

 #define BXT_P_CR_GT_DISP_PWRON _MMIO(0x138090)

drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -1216,31 +1219,26 @@ enum skl_disp_power_wells {
  #define   PORT_PLL_REF_SEL		(1 << 27)
  #define BXT_PORT_PLL_ENABLE(port)	_MMIO_PORT(port, _PORT_PLL_A, _PORT_PLL_B)

drivers/gpu/drm/i915/i915_reg.h +2 -3
-#define _PORT_PLL_EBB_0_A		0x162034
-#define _PORT_PLL_EBB_0_B		0x6C034
-#define _PORT_PLL_EBB_0_C		0x6C340
+#define _PORT_PLL_EBB_0_CH0		0x34
+#define _PORT_PLL_EBB_0_CH1		0x340

 #define   PORT_PLL_P1_SHIFT 13
 #define   PORT_PLL_P1_MASK (0x07 << PORT_PLL_P1_SHIFT)
 #define   PORT_PLL_P1(x) ((x)  << PORT_PLL_P1_SHIFT)
 #define   PORT_PLL_P2_SHIFT 8
 #define   PORT_PLL_P2_MASK (0x1f << PORT_PLL_P2_SHIFT)
 #define   PORT_PLL_P2(x) ((x)  << PORT_PLL_P2_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1231

Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +2 -3
-#define BXT_PORT_PLL_EBB_0(port)	_MMIO_PORT3(port, _PORT_PLL_EBB_0_A, \
-						_PORT_PLL_EBB_0_B,	\
-						_PORT_PLL_EBB_0_C)
+#define BXT_PORT_PLL_EBB_0(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_PLL_EBB_0_CH0, _PORT_PLL_EBB_0_CH1))

Passing the phy and calculating the base here would be more natural. Also we should try to preserve bspec reg names and addresses to make lookup easier. You could do that by using _PORT_PLL_EBB_0_B and _PORT_PLL_EBB_0_C here and adjusting the base by -BXT_PHY0_BASE. I'd also leave _PORT_PLL_EBB_0_A around for reference.

Quoted 782 lines

drivers/gpu/drm/i915/i915_reg.h +2 -3
-#define _PORT_PLL_EBB_4_A		0x162038
-#define _PORT_PLL_EBB_4_B		0x6C038
-#define _PORT_PLL_EBB_4_C		0x6C344
+#define _PORT_PLL_EBB_4_CH0		0x38
+#define _PORT_PLL_EBB_4_CH1		0x344

 #define   PORT_PLL_10BIT_CLK_ENABLE (1 << 13)
 #define   PORT_PLL_RECALIBRATE (1 << 14)

drivers/gpu/drm/i915/i915_reg.h +2 -3
-#define BXT_PORT_PLL_EBB_4(port)	_MMIO_PORT3(port, _PORT_PLL_EBB_4_A, \
-						_PORT_PLL_EBB_4_B,	\
-						_PORT_PLL_EBB_4_C)
+#define BXT_PORT_PLL_EBB_4(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_PLL_EBB_4_CH0, _PORT_PLL_EBB_4_CH1))

drivers/gpu/drm/i915/i915_reg.h +2 -3
-#define _PORT_PLL_0_A			0x162100
-#define _PORT_PLL_0_B			0x6C100
-#define _PORT_PLL_0_C			0x6C380
+#define _PORT_PLL_0_CH0			0x100
+#define _PORT_PLL_0_CH1			0x380

 /* PORT_PLL_0_A */
 #define   PORT_PLL_M2_MASK 0xFF
 /* PORT_PLL_1_A */

drivers/gpu/drm/i915/i915_reg.h +4 -4
@@ -1267,65 +1265,43 @@ enum skl_disp_power_wells {
  #define  PORT_PLL_DCO_AMP_DEFAULT	15
  #define  PORT_PLL_DCO_AMP_MASK		0x3c00
  #define  PORT_PLL_DCO_AMP(x)		((x)<<10)
-#define _PORT_PLL_BASE(port)		_PORT3(port, _PORT_PLL_0_A,	\
-						_PORT_PLL_0_B,		\
-						_PORT_PLL_0_C)
-#define BXT_PORT_PLL(port, idx)		_MMIO(_PORT_PLL_BASE(port) + (idx) * 4)
+#define _PORT_PLL_BASE(base, ch)	\
+	((base) + _PIPE((ch), _PORT_PLL_0_CH0, _PORT_PLL_0_CH1))
+#define BXT_PORT_PLL(base, ch, idx)	\
+	_MMIO(_PORT_PLL_BASE(base, ch) + (idx) * 4)


 /* BXT PHY common lane registers */

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_CL1CM_DW0_A		0x162000
-#define _PORT_CL1CM_DW0_BC		0x6C000
+#define BXT_PORT_CL1CM_DW0(base)	_MMIO((base) + 0x0)

 #define   PHY_POWER_GOOD (1 << 16)
 #define   PHY_RESERVED (1 << 7)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define BXT_PORT_CL1CM_DW0(phy)		_BXT_PHY((phy), _PORT_CL1CM_DW0_BC, \
-							_PORT_CL1CM_DW0_A)

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_CL1CM_DW9_A		0x162024
-#define _PORT_CL1CM_DW9_BC		0x6C024
+#define BXT_PORT_CL1CM_DW9(base)	_MMIO((base) + 0x24)

 #define   IREF0RC_OFFSET_SHIFT 8
 #define   IREF0RC_OFFSET_MASK (0xFF << IREF0RC_OFFSET_SHIFT)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define BXT_PORT_CL1CM_DW9(phy)		_BXT_PHY((phy), _PORT_CL1CM_DW9_BC, \
-							_PORT_CL1CM_DW9_A)

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_CL1CM_DW10_A		0x162028
-#define _PORT_CL1CM_DW10_BC		0x6C028
+#define BXT_PORT_CL1CM_DW10(base)	_MMIO((base) + 0x28)

 #define   IREF1RC_OFFSET_SHIFT 8
 #define   IREF1RC_OFFSET_MASK (0xFF << IREF1RC_OFFSET_SHIFT)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define BXT_PORT_CL1CM_DW10(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW10_BC, \
-							_PORT_CL1CM_DW10_A)

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_CL1CM_DW28_A		0x162070
-#define _PORT_CL1CM_DW28_BC		0x6C070
+#define BXT_PORT_CL1CM_DW28(base)	_MMIO((base) + 0x70)

 #define   OCL1_POWER_DOWN_EN (1 << 23)
 #define   DW28_OLDO_DYN_PWR_DOWN_EN (1 << 22)
 #define   SUS_CLK_CONFIG 0x3

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define BXT_PORT_CL1CM_DW28(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW28_BC, \
-							_PORT_CL1CM_DW28_A)

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_CL1CM_DW30_A		0x162078
-#define _PORT_CL1CM_DW30_BC		0x6C078
+#define BXT_PORT_CL1CM_DW30(base)	_MMIO((base) + 0x78)

 #define   OCL2_LDOFUSE_PWR_DIS (1 << 6)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define BXT_PORT_CL1CM_DW30(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW30_BC, \
-							_PORT_CL1CM_DW30_A)


 /* The spec defines this only for BXT PHY0, but lets assume that this
  * would exist for PHY1 too if it had a second channel.
  */

drivers/gpu/drm/i915/i915_reg.h +1 -4
-#define _PORT_CL2CM_DW6_A		0x162358
-#define _PORT_CL2CM_DW6_BC		0x6C358
-#define BXT_PORT_CL2CM_DW6(phy)		_BXT_PHY((phy), _PORT_CL2CM_DW6_BC, \
-							_PORT_CL2CM_DW6_A)
+#define BXT_PORT_CL2CM_DW6(base)	_MMIO((base) + 0x358)

 #define   DW6_OLDO_DYN_PWR_DOWN_EN (1 << 28)

 /* BXT PHY Ref registers */

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_REF_DW3_A			0x16218C
-#define _PORT_REF_DW3_BC		0x6C18C
+#define BXT_PORT_REF_DW3(base)		_MMIO((base) + 0x18c)

 #define   GRC_DONE (1 << 22)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define BXT_PORT_REF_DW3(phy)		_BXT_PHY((phy), _PORT_REF_DW3_BC, \
-							_PORT_REF_DW3_A)

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_REF_DW6_A			0x162198
-#define _PORT_REF_DW6_BC		0x6C198
+#define BXT_PORT_REF_DW6(base)		_MMIO((base) + 0x198)

 #define   GRC_CODE_SHIFT 24
 #define   GRC_CODE_MASK (0xFF << GRC_CODE_SHIFT)
 #define   GRC_CODE_FAST_SHIFT 16

drivers/gpu/drm/i915/i915_reg.h +0 -2
@@ -1333,113 +1309,88 @@ enum skl_disp_power_wells {
  #define   GRC_CODE_SLOW_SHIFT		8
  #define   GRC_CODE_SLOW_MASK		(0xFF << GRC_CODE_SLOW_SHIFT)
  #define   GRC_CODE_NOM_MASK		0xFF
-#define BXT_PORT_REF_DW6(phy)		_BXT_PHY((phy), _PORT_REF_DW6_BC,	\
-						      _PORT_REF_DW6_A)

drivers/gpu/drm/i915/i915_reg.h +1 -2
-#define _PORT_REF_DW8_A			0x1621A0
-#define _PORT_REF_DW8_BC		0x6C1A0
+#define BXT_PORT_REF_DW8(base)		_MMIO((base) + 0x1a0)

 #define   GRC_DIS (1 << 15)
 #define   GRC_RDY_OVRD (1 << 1)

drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define BXT_PORT_REF_DW8(phy)		_BXT_PHY((phy), _PORT_REF_DW8_BC,	\
-						      _PORT_REF_DW8_A)


 /* BXT PHY PCS registers */

drivers/gpu/drm/i915/i915_reg.h +4 -12
-#define _PORT_PCS_DW10_LN01_A		0x162428
-#define _PORT_PCS_DW10_LN01_B		0x6C428
-#define _PORT_PCS_DW10_LN01_C		0x6C828
-#define _PORT_PCS_DW10_GRP_A		0x162C28
-#define _PORT_PCS_DW10_GRP_B		0x6CC28
-#define _PORT_PCS_DW10_GRP_C		0x6CE28
-#define BXT_PORT_PCS_DW10_LN01(port)	_MMIO_PORT3(port, _PORT_PCS_DW10_LN01_A, \
-						     _PORT_PCS_DW10_LN01_B, \
-						     _PORT_PCS_DW10_LN01_C)
-#define BXT_PORT_PCS_DW10_GRP(port)	_MMIO_PORT3(port, _PORT_PCS_DW10_GRP_A,  \
-						     _PORT_PCS_DW10_GRP_B,  \
-						     _PORT_PCS_DW10_GRP_C)
+#define _PORT_PCS_DW10_LN01_CH0		0x428
+#define _PORT_PCS_DW10_LN01_CH1		0x828
+#define _PORT_PCS_DW10_GRP_CH0		0xC28
+#define _PORT_PCS_DW10_GRP_CH1		0xE28

 #define   TX2_SWING_CALC_INIT (1 << 31)
 #define   TX1_SWING_CALC_INIT (1 << 30)

drivers/gpu/drm/i915/i915_reg.h +13 -10
-
-#define _PORT_PCS_DW12_LN01_A		0x162430
-#define _PORT_PCS_DW12_LN01_B		0x6C430
-#define _PORT_PCS_DW12_LN01_C		0x6C830
-#define _PORT_PCS_DW12_LN23_A		0x162630
-#define _PORT_PCS_DW12_LN23_B		0x6C630
-#define _PORT_PCS_DW12_LN23_C		0x6CA30
-#define _PORT_PCS_DW12_GRP_A		0x162c30
-#define _PORT_PCS_DW12_GRP_B		0x6CC30
-#define _PORT_PCS_DW12_GRP_C		0x6CE30
+#define BXT_PORT_PCS_DW10_LN01(base, ch)	\
+	_MMIO((base) + _PIPE(ch, _PORT_PCS_DW10_LN01_CH0,		\
+			     _PORT_PCS_DW10_LN01_CH1))
+#define BXT_PORT_PCS_DW10_GRP(base, ch)	\
+	_MMIO((base) + _PIPE(ch, _PORT_PCS_DW10_GRP_CH0,		\
+			     _PORT_PCS_DW10_GRP_CH1))
+
+#define _PORT_PCS_DW12_LN01_CH0		0x430
+#define _PORT_PCS_DW12_LN01_CH1		0x830
+#define _PORT_PCS_DW12_LN23_CH0		0x630
+#define _PORT_PCS_DW12_LN23_CH1		0xA30
+#define _PORT_PCS_DW12_GRP_CH0		0xC30
+#define _PORT_PCS_DW12_GRP_CH1		0xE30

 #define   LANESTAGGER_STRAP_OVRD (1 << 6)
 #define   LANE_STAGGER_MASK 0x1F

drivers/gpu/drm/i915/i915_reg.h +6 -9
-#define BXT_PORT_PCS_DW12_LN01(port)	_MMIO_PORT3(port, _PORT_PCS_DW12_LN01_A, \
-						     _PORT_PCS_DW12_LN01_B, \
-						     _PORT_PCS_DW12_LN01_C)
-#define BXT_PORT_PCS_DW12_LN23(port)	_MMIO_PORT3(port, _PORT_PCS_DW12_LN23_A, \
-						     _PORT_PCS_DW12_LN23_B, \
-						     _PORT_PCS_DW12_LN23_C)
-#define BXT_PORT_PCS_DW12_GRP(port)	_MMIO_PORT3(port, _PORT_PCS_DW12_GRP_A, \
-						     _PORT_PCS_DW12_GRP_B, \
-						     _PORT_PCS_DW12_GRP_C)
+#define BXT_PORT_PCS_DW12_LN01(base, ch)	\
+	_MMIO((base) + _PIPE(ch, _PORT_PCS_DW12_LN01_CH0, _PORT_PCS_DW12_LN01_CH1))
+#define BXT_PORT_PCS_DW12_LN23(base, ch)	\
+	_MMIO((base) + _PIPE(ch, _PORT_PCS_DW12_LN23_CH0, _PORT_PCS_DW12_LN23_CH1))
+#define BXT_PORT_PCS_DW12_GRP(base, ch)	\
+	_MMIO((base) + _PIPE(ch, _PORT_PCS_DW12_GRP_CH0, _PORT_PCS_DW12_GRP_CH1))


 /* BXT PHY TX registers */
 #define _BXT_LANE_OFFSET(lane)           (((lane) >> 1) * 0x200 + \
    ((lane) & 1) * 0x80)

drivers/gpu/drm/i915/i915_reg.h +4 -12
-#define _PORT_TX_DW2_LN0_A		0x162508
-#define _PORT_TX_DW2_LN0_B		0x6C508
-#define _PORT_TX_DW2_LN0_C		0x6C908
-#define _PORT_TX_DW2_GRP_A		0x162D08
-#define _PORT_TX_DW2_GRP_B		0x6CD08
-#define _PORT_TX_DW2_GRP_C		0x6CF08
-#define BXT_PORT_TX_DW2_GRP(port)	_MMIO_PORT3(port, _PORT_TX_DW2_GRP_A,  \
-						     _PORT_TX_DW2_GRP_B,  \
-						     _PORT_TX_DW2_GRP_C)
-#define BXT_PORT_TX_DW2_LN0(port)	_MMIO_PORT3(port, _PORT_TX_DW2_LN0_A,  \
-						     _PORT_TX_DW2_LN0_B,  \
-						     _PORT_TX_DW2_LN0_C)
+#define _PORT_TX_DW2_LN0_CH0		0x508
+#define _PORT_TX_DW2_LN0_CH1		0x908
+#define _PORT_TX_DW2_GRP_CH0		0xD08
+#define _PORT_TX_DW2_GRP_CH1		0xF08

 #define   MARGIN_000_SHIFT 16
 #define   MARGIN_000 (0xFF << MARGIN_000_SHIFT)
 #define   UNIQ_TRANS_SCALE_SHIFT 8
 #define   UNIQ_TRANS_SCALE (0xFF << UNIQ_TRANS_SCALE_SHIFT)

drivers/gpu/drm/i915/i915_reg.h +9 -13
-
-#define _PORT_TX_DW3_LN0_A		0x16250C
-#define _PORT_TX_DW3_LN0_B		0x6C50C
-#define _PORT_TX_DW3_LN0_C		0x6C90C
-#define _PORT_TX_DW3_GRP_A		0x162D0C
-#define _PORT_TX_DW3_GRP_B		0x6CD0C
-#define _PORT_TX_DW3_GRP_C		0x6CF0C
-#define BXT_PORT_TX_DW3_GRP(port)	_MMIO_PORT3(port, _PORT_TX_DW3_GRP_A,  \
-						     _PORT_TX_DW3_GRP_B,  \
-						     _PORT_TX_DW3_GRP_C)
-#define BXT_PORT_TX_DW3_LN0(port)	_MMIO_PORT3(port, _PORT_TX_DW3_LN0_A,  \
-						     _PORT_TX_DW3_LN0_B,  \
-						     _PORT_TX_DW3_LN0_C)
+#define BXT_PORT_TX_DW2_GRP(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_TX_DW2_GRP_CH0, _PORT_TX_DW2_GRP_CH1))
+#define BXT_PORT_TX_DW2_LN0(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_TX_DW2_LN0_CH0, _PORT_TX_DW2_LN0_CH1))
+
+#define _PORT_TX_DW3_LN0_CH0		0x50C
+#define _PORT_TX_DW3_LN0_CH1		0x90C
+#define _PORT_TX_DW3_GRP_CH0		0xD0C
+#define _PORT_TX_DW3_GRP_CH1		0xF0C

 #define   SCALE_DCOMP_METHOD (1 << 26)
 #define   UNIQUE_TRANGE_EN_METHOD (1 << 27)

drivers/gpu/drm/i915/i915_reg.h +5 -0
+#define BXT_PORT_TX_DW3_GRP(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_TX_DW3_GRP_CH0, _PORT_TX_DW3_GRP_CH1))
+#define BXT_PORT_TX_DW3_LN0(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_TX_DW3_LN0_CH0, _PORT_TX_DW3_LN0_CH1))
+

drivers/gpu/drm/i915/i915_reg.h +4 -12
-#define _PORT_TX_DW4_LN0_A		0x162510
-#define _PORT_TX_DW4_LN0_B		0x6C510
-#define _PORT_TX_DW4_LN0_C		0x6C910
-#define _PORT_TX_DW4_GRP_A		0x162D10
-#define _PORT_TX_DW4_GRP_B		0x6CD10
-#define _PORT_TX_DW4_GRP_C		0x6CF10
-#define BXT_PORT_TX_DW4_LN0(port)	_MMIO_PORT3(port, _PORT_TX_DW4_LN0_A,  \
-						     _PORT_TX_DW4_LN0_B,  \
-						     _PORT_TX_DW4_LN0_C)
-#define BXT_PORT_TX_DW4_GRP(port)	_MMIO_PORT3(port, _PORT_TX_DW4_GRP_A,  \
-						     _PORT_TX_DW4_GRP_B,  \
-						     _PORT_TX_DW4_GRP_C)
+#define _PORT_TX_DW4_LN0_CH0		0x510
+#define _PORT_TX_DW4_LN0_CH1		0x910
+#define _PORT_TX_DW4_GRP_CH0		0xD10
+#define _PORT_TX_DW4_GRP_CH1		0xF10

 #define   DEEMPH_SHIFT 24
 #define   DE_EMPHASIS (0xFF << DEEMPH_SHIFT)

drivers/gpu/drm/i915/i915_reg.h +4 -0
+#define BXT_PORT_TX_DW4_GRP(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_TX_DW4_GRP_CH0, _PORT_TX_DW4_GRP_CH1))
+#define BXT_PORT_TX_DW4_LN0(base, ch)	\
+	_MMIO((base) + _PIPE((ch), _PORT_TX_DW4_LN0_CH0, _PORT_TX_DW4_LN0_CH1))

drivers/gpu/drm/i915/i915_reg.h +2 -3
-#define _PORT_TX_DW14_LN0_A		0x162538
-#define _PORT_TX_DW14_LN0_B		0x6C538
-#define _PORT_TX_DW14_LN0_C		0x6C938
+#define _PORT_TX_DW14_LN0_CH0		0x538
+#define _PORT_TX_DW14_LN0_CH1		0x938

 #define   LATENCY_OPTIM_SHIFT 30
 #define   LATENCY_OPTIM (1 << LATENCY_OPTIM_SHIFT)

drivers/gpu/drm/i915/i915_reg.h +4 -4
-#define BXT_PORT_TX_DW14_LN(port, lane)	_MMIO(_PORT3((port), _PORT_TX_DW14_LN0_A,   \
-							_PORT_TX_DW14_LN0_B,   \
-							_PORT_TX_DW14_LN0_C) + \
-					 _BXT_LANE_OFFSET(lane))
+#define BXT_PORT_TX_DW14_LN(base, ch, lane)	\
+	_MMIO((base) + _PIPE((ch), _PORT_TX_DW14_LN0_CH0,	\
+				   _PORT_TX_DW14_LN0_CH1) + 	\
+	      _BXT_LANE_OFFSET(lane))


 /* UAIMI scratch pad register 1 */
 #define UAIMI_SPR1 _MMIO(0x4F074)

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
index e8a75fd..07ef154 100644
@@ -124,6 +124,11 @@ struct bxt_ddi_phy_info {
  	bool dual_channel;


  /**

drivers/gpu/drm/i915/intel_dpio_phy.c +5 -0
+	 * @mmio_base: base addess for accessing this PHY through mmio.
+	 */
+	u32 mmio_base;
+
+	/**

   * @rcomp_phy: If -1, indicates this phy has its own rcomp resistor.
   * Otherwise the GRC value will be copied from the phy indicated by
   * this field.

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -143,6 +148,7 @@ struct bxt_ddi_phy_info {


 static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = { [DPIO_PHY0] = {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
+		.mmio_base = BXT_PHY0_BASE,

  .dual_channel = true,
  .rcomp_phy = DPIO_PHY1,

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -0
@@ -152,6 +158,7 @@ static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
  		}
  	},
  	[DPIO_PHY1] = {
+		.mmio_base = BXT_PHY1_BASE,
  		.dual_channel = false,
  		.rcomp_phy = -1,

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -167,26 +174,58 @@ static u32 bxt_phy_port_mask(const struct bxt_ddi_phy_info *phy_info)
  		BIT(phy_info->channel[DPIO_CH0].port);
  }

drivers/gpu/drm/i915/intel_dpio_phy.c +28 -0
+void bxt_port_to_phy_channel(enum port port,
+			     u32 *mmio_base, enum dpio_channel *ch)
+{
+	const struct bxt_ddi_phy_info *phy_info;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(bxt_ddi_phy_info); i++) {
+		phy_info = &bxt_ddi_phy_info[i];
+
+		if (port == phy_info->channel[DPIO_CH0].port) {
+			*mmio_base = phy_info->mmio_base;
+			*ch = DPIO_CH0;
+			return;
+		}
+
+		if (phy_info->dual_channel &&
+		    port == phy_info->channel[DPIO_CH1].port) {
+			*mmio_base = phy_info->mmio_base;
+			*ch = DPIO_CH1;
+			return;
+		}
+	}
+
+	WARN(1, "PHY not found for PORT %c", port_name(port));
+	*mmio_base = BXT_PHY0_BASE;
+	*ch = DPIO_CH0;
+}
+

 void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv, enum port port, u32 margin, u32 scale, u32 enable, u32 deemphasis) {
  u32 val;

drivers/gpu/drm/i915/intel_dpio_phy.c +4 -0
+	u32 phy;
+	enum dpio_channel ch;
+
+	bxt_port_to_phy_channel(port, &phy, &ch);


  /*
   * While we write to the group register to program all lanes at once we
   * can read only lane registers and we pick lanes 0/1 for that. */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_PCS_DW10_LN01(port));
+	val = I915_READ(BXT_PORT_PCS_DW10_LN01(phy, ch));

  val &= ~(TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val);
+	I915_WRITE(BXT_PORT_PCS_DW10_GRP(phy, ch), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_TX_DW2_LN0(port));
+	val = I915_READ(BXT_PORT_TX_DW2_LN0(phy, ch));

  val &= ~(MARGIN_000 | UNIQ_TRANS_SCALE);
  val |= margin << MARGIN_000_SHIFT | scale << UNIQ_TRANS_SCALE_SHIFT;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_TX_DW2_GRP(port), val);
+	I915_WRITE(BXT_PORT_TX_DW2_GRP(phy, ch), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_TX_DW3_LN0(port));
+	val = I915_READ(BXT_PORT_TX_DW3_LN0(phy, ch));

  val &= ~SCALE_DCOMP_METHOD;
  if (enable)
  val |= SCALE_DCOMP_METHOD;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -194,16 +233,16 @@ void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
  	if ((val & UNIQUE_TRANGE_EN_METHOD) && !(val & SCALE_DCOMP_METHOD))
  		DRM_ERROR("Disabled scaling while ouniqetrangenmethod was set");

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_TX_DW3_GRP(port), val);
+	I915_WRITE(BXT_PORT_TX_DW3_GRP(phy, ch), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_TX_DW4_LN0(port));
+	val = I915_READ(BXT_PORT_TX_DW4_LN0(phy, ch));

  val &= ~DE_EMPHASIS;
  val |= deemphasis << DEEMPH_SHIFT;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_TX_DW4_GRP(port), val);
+	I915_WRITE(BXT_PORT_TX_DW4_GRP(phy, ch), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_PCS_DW10_LN01(port));
+	val = I915_READ(BXT_PORT_PCS_DW10_LN01(phy, ch));

  val |= TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val);
+	I915_WRITE(BXT_PORT_PCS_DW10_GRP(phy, ch), val);

 }

 bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -215,7 +254,7 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  	if (!(I915_READ(BXT_P_CR_GT_DISP_PWRON) & GT_DISPLAY_POWER_ON(phy)))
  		return false;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	if ((I915_READ(BXT_PORT_CL1CM_DW0(phy)) &
+	if ((I915_READ(BXT_PORT_CL1CM_DW0(phy_info->mmio_base)) &

       (PHY_POWER_GOOD | PHY_RESERVED)) != PHY_POWER_GOOD) { DRM_DEBUG_DRIVER("DDI PHY %d powered, but power hasn't settled\n", phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -224,7 +263,7 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  	}


  if (phy_info->rcomp_phy == -1 &&

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	    !(I915_READ(BXT_PORT_REF_DW3(phy)) & GRC_DONE)) {
+	    !(I915_READ(BXT_PORT_REF_DW3(phy_info->mmio_base)) & GRC_DONE)) {

  DRM_DEBUG_DRIVER("DDI PHY %d powered, but GRC isn't done\n", phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -256,7 +295,11 @@ bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,


 static u32 bxt_get_grc(struct drm_i915_private *dev_priv, enum dpio_phy phy) {

drivers/gpu/drm/i915/intel_dpio_phy.c +5 -1
-	u32 val = I915_READ(BXT_PORT_REF_DW6(phy));
+	const struct bxt_ddi_phy_info *phy_info;
+	u32 val;
+
+	phy_info = &bxt_ddi_phy_info[phy];
+	val = I915_READ(BXT_PORT_REF_DW6(phy_info->mmio_base));


  return (val & GRC_CODE_MASK) >> GRC_CODE_SHIFT; }

drivers/gpu/drm/i915/intel_dpio_phy.c +6 -2
@@ -264,8 +307,12 @@ static u32 bxt_get_grc(struct drm_i915_private *dev_priv, enum dpio_phy phy)
  static void bxt_phy_wait_grc_done(struct drm_i915_private *dev_priv,
  				  enum dpio_phy phy)
  {
+	const struct bxt_ddi_phy_info *phy_info;
+
+	phy_info = &bxt_ddi_phy_info[phy];
+
  	if (intel_wait_for_register(dev_priv,
-				    BXT_PORT_REF_DW3(phy),
+				    BXT_PORT_REF_DW3(phy_info->mmio_base),
  				    GRC_DONE, GRC_DONE,
  				    10))
  		DRM_ERROR("timeout waiting for PHY%d GRC\n", phy);
@@ -305,35 +352,35 @@ static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
  	 * HW team confirmed that the time to reach phypowergood status is
  	 * anywhere between 50 us and 100us.
  	 */
-	if (wait_for_us(((I915_READ(BXT_PORT_CL1CM_DW0(phy)) &
+	if (wait_for_us(((I915_READ(BXT_PORT_CL1CM_DW0(phy_info->mmio_base)) &
  		(PHY_RESERVED | PHY_POWER_GOOD)) == PHY_POWER_GOOD), 100)) {
  		DRM_ERROR("timeout during PHY%d power on\n", phy);
  	}


  /* Program PLL Rcomp code offset */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_CL1CM_DW9(phy));
+	val = I915_READ(BXT_PORT_CL1CM_DW9(phy_info->mmio_base));

  val &= ~IREF0RC_OFFSET_MASK;
  val |= 0xE4 << IREF0RC_OFFSET_SHIFT;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_CL1CM_DW9(phy), val);
+	I915_WRITE(BXT_PORT_CL1CM_DW9(phy_info->mmio_base), val);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_CL1CM_DW10(phy));
+	val = I915_READ(BXT_PORT_CL1CM_DW10(phy_info->mmio_base));

  val &= ~IREF1RC_OFFSET_MASK;
  val |= 0xE4 << IREF1RC_OFFSET_SHIFT;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_CL1CM_DW10(phy), val);
+	I915_WRITE(BXT_PORT_CL1CM_DW10(phy_info->mmio_base), val);


  /* Program power gating */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_CL1CM_DW28(phy));
+	val = I915_READ(BXT_PORT_CL1CM_DW28(phy_info->mmio_base));

  val |= OCL1_POWER_DOWN_EN | DW28_OLDO_DYN_PWR_DOWN_EN | SUS_CLK_CONFIG;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	I915_WRITE(BXT_PORT_CL1CM_DW28(phy), val);
+	I915_WRITE(BXT_PORT_CL1CM_DW28(phy_info->mmio_base), val);


  if (phy_info->dual_channel) {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		val = I915_READ(BXT_PORT_CL2CM_DW6(phy));
+		val = I915_READ(BXT_PORT_CL2CM_DW6(phy_info->mmio_base));

  val |= DW6_OLDO_DYN_PWR_DOWN_EN;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_CL2CM_DW6(phy), val);
+		I915_WRITE(BXT_PORT_CL2CM_DW6(phy_info->mmio_base), val);

  }

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	val = I915_READ(BXT_PORT_CL1CM_DW30(phy));
+	val = I915_READ(BXT_PORT_CL1CM_DW30(phy_info->mmio_base));

  val &= ~OCL2_LDOFUSE_PWR_DIS;
  /*
   * On PHY1 disable power on the second channel, since no port is

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
@@ -347,7 +394,7 @@ static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
  	 */
  	if (!phy_info->dual_channel)
  		val |= OCL2_LDOFUSE_PWR_DIS;
-	I915_WRITE(BXT_PORT_CL1CM_DW30(phy), val);
+	I915_WRITE(BXT_PORT_CL1CM_DW30(phy_info->mmio_base), val);


  if (phy_info->rcomp_phy != -1) {
  uint32_t grc_code;

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -361,11 +408,11 @@ static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,

  grc_code = val << GRC_CODE_FAST_SHIFT | val << GRC_CODE_SLOW_SHIFT | val;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_REF_DW6(phy), grc_code);
+		I915_WRITE(BXT_PORT_REF_DW6(phy_info->mmio_base), grc_code);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		val = I915_READ(BXT_PORT_REF_DW8(phy));
+		val = I915_READ(BXT_PORT_REF_DW8(phy_info->mmio_base));

  val |= GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_REF_DW8(phy), val);
+		I915_WRITE(BXT_PORT_REF_DW8(phy_info->mmio_base), val);

  }

  val = I915_READ(BXT_PHY_CTL_FAMILY(phy));

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -461,20 +508,20 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  	ok = true;


  /* PLL Rcomp code offset */

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	ok &= _CHK(BXT_PORT_CL1CM_DW9(phy),
+	ok &= _CHK(BXT_PORT_CL1CM_DW9(phy_info->mmio_base),

      IREF0RC_OFFSET_MASK, 0xe4 << IREF0RC_OFFSET_SHIFT, "BXT_PORT_CL1CM_DW9(%d)", phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	ok &= _CHK(BXT_PORT_CL1CM_DW10(phy),
+	ok &= _CHK(BXT_PORT_CL1CM_DW10(phy_info->mmio_base),

      IREF1RC_OFFSET_MASK, 0xe4 << IREF1RC_OFFSET_SHIFT, "BXT_PORT_CL1CM_DW10(%d)", phy);

  /* Power gating */
  mask = OCL1_POWER_DOWN_EN | DW28_OLDO_DYN_PWR_DOWN_EN | SUS_CLK_CONFIG;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-	ok &= _CHK(BXT_PORT_CL1CM_DW28(phy), mask, mask,
+	ok &= _CHK(BXT_PORT_CL1CM_DW28(phy_info->mmio_base), mask, mask,

      "BXT_PORT_CL1CM_DW28(%d)", phy);
  if (phy_info->dual_channel)

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		ok &= _CHK(BXT_PORT_CL2CM_DW6(phy),
+		ok &= _CHK(BXT_PORT_CL2CM_DW6(phy_info->mmio_base),

     DW6_OLDO_DYN_PWR_DOWN_EN, DW6_OLDO_DYN_PWR_DOWN_EN, "BXT_PORT_CL2CM_DW6(%d)", phy);

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -491,11 +538,11 @@ bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  			   grc_code;

  mask = GRC_CODE_FAST_MASK | GRC_CODE_SLOW_MASK | GRC_CODE_NOM_MASK;

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -2
-		ok &= _CHK(BXT_PORT_REF_DW6(phy), mask, grc_code,
-			    "BXT_PORT_REF_DW6(%d)", phy);
+		ok &= _CHK(BXT_PORT_REF_DW6(phy_info->mmio_base), mask,
+			   grc_code, "BXT_PORT_REF_DW6(%d)", phy);


  mask = GRC_DIS | GRC_RDY_OVRD;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		ok &= _CHK(BXT_PORT_REF_DW8(phy), mask, mask,
+		ok &= _CHK(BXT_PORT_REF_DW8(phy_info->mmio_base), mask, mask,

      "BXT_PORT_REF_DW8(%d)", phy); }

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -0
@@ -527,10 +574,14 @@ void bxt_ddi_phy_set_lane_optim_mask(struct intel_encoder *encoder,
  	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
  	struct drm_i915_private *dev_priv = to_i915(dport->base.base.dev);
  	enum port port = dport->port;
+	u32 phy;
+	enum dpio_channel ch;
  	int lane;

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -0
+	bxt_port_to_phy_channel(port, &phy, &ch);
+

  for (lane = 0; lane < 4; lane++) {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		u32 val = I915_READ(BXT_PORT_TX_DW14_LN(port, lane));
+		u32 val = I915_READ(BXT_PORT_TX_DW14_LN(phy, ch, lane));


  /*
   * Note that on CHV this flag is called UPAR, but has

drivers/gpu/drm/i915/intel_dpio_phy.c +0 -0
@@ -540,7 +591,7 @@ void bxt_ddi_phy_set_lane_optim_mask(struct intel_encoder *encoder,
  		if (lane_lat_optim_mask & BIT(lane))
  			val |= LATENCY_OPTIM;

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		I915_WRITE(BXT_PORT_TX_DW14_LN(port, lane), val);
+		I915_WRITE(BXT_PORT_TX_DW14_LN(phy, ch, lane), val);

  }
 }

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -0
@@ -550,12 +601,16 @@ bxt_ddi_phy_get_lane_lat_optim_mask(struct intel_encoder *encoder)
  	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
  	struct drm_i915_private *dev_priv = to_i915(dport->base.base.dev);
  	enum port port = dport->port;
+	u32 phy;
+	enum dpio_channel ch;
  	int lane;
  	uint8_t mask;

drivers/gpu/drm/i915/intel_dpio_phy.c +2 -0
+	bxt_port_to_phy_channel(port, &phy, &ch);
+

  mask = 0;
  for (lane = 0; lane < 4; lane++) {

drivers/gpu/drm/i915/intel_dpio_phy.c +1 -1
-		u32 val = I915_READ(BXT_PORT_TX_DW14_LN(port, lane));
+		u32 val = I915_READ(BXT_PORT_TX_DW14_LN(phy, ch, lane));


  if (val & LATENCY_OPTIM)
  mask |= BIT(lane);

drivers/gpu/drm/i915/intel_dpll_mgr.c +0 -0
index 1c59ca5..a4a9f05 100644
@@ -1371,6 +1371,10 @@ static void bxt_ddi_pll_enable(struct drm_i915_private *dev_priv,
  {
  	uint32_t temp;

  enum port port = (enum port)pll->id; /* 1:1 port->PLL mapping */

drivers/gpu/drm/i915/intel_dpll_mgr.c +4 -0
+	u32 phy;
+	enum dpio_channel ch;
+
+	bxt_port_to_phy_channel(port, &phy, &ch);


  /* Non-SSC reference */
  temp = I915_READ(BXT_PORT_PLL_ENABLE(port));

drivers/gpu/drm/i915/intel_dpll_mgr.c +0 -0
@@ -1378,72 +1382,72 @@ static void bxt_ddi_pll_enable(struct drm_i915_private *dev_priv,
  	I915_WRITE(BXT_PORT_PLL_ENABLE(port), temp);


  /* Disable 10 bit clock */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL_EBB_4(port));
+	temp = I915_READ(BXT_PORT_PLL_EBB_4(phy, ch));

  temp &= ~PORT_PLL_10BIT_CLK_ENABLE;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL_EBB_4(port), temp);
+	I915_WRITE(BXT_PORT_PLL_EBB_4(phy, ch), temp);


  /* Write P1 & P2 */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL_EBB_0(port));
+	temp = I915_READ(BXT_PORT_PLL_EBB_0(phy, ch));

  temp &= ~(PORT_PLL_P1_MASK | PORT_PLL_P2_MASK); temp |= pll->config.hw_state.ebb0;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL_EBB_0(port), temp);
+	I915_WRITE(BXT_PORT_PLL_EBB_0(phy, ch), temp);


  /* Write M2 integer */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 0));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 0));

  temp &= ~PORT_PLL_M2_MASK;
  temp |= pll->config.hw_state.pll0;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 0), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 0), temp);


  /* Write N */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 1));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 1));

  temp &= ~PORT_PLL_N_MASK;
  temp |= pll->config.hw_state.pll1;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 1), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 1), temp);


  /* Write M2 fraction */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 2));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 2));

  temp &= ~PORT_PLL_M2_FRAC_MASK;
  temp |= pll->config.hw_state.pll2;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 2), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 2), temp);


  /* Write M2 fraction enable */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 3));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 3));

  temp &= ~PORT_PLL_M2_FRAC_ENABLE;
  temp |= pll->config.hw_state.pll3;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 3), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 3), temp);


  /* Write coeff */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 6));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 6));

  temp &= ~PORT_PLL_PROP_COEFF_MASK;
  temp &= ~PORT_PLL_INT_COEFF_MASK;
  temp &= ~PORT_PLL_GAIN_CTL_MASK;
  temp |= pll->config.hw_state.pll6;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 6), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 6), temp);


  /* Write calibration val */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 8));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 8));

  temp &= ~PORT_PLL_TARGET_CNT_MASK;
  temp |= pll->config.hw_state.pll8;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 8), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 8), temp);

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 9));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 9));

  temp &= ~PORT_PLL_LOCK_THRESHOLD_MASK;
  temp |= pll->config.hw_state.pll9;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 9), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 9), temp);

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL(port, 10));
+	temp = I915_READ(BXT_PORT_PLL(phy, ch, 10));

  temp &= ~PORT_PLL_DCO_AMP_OVR_EN_H;
  temp &= ~PORT_PLL_DCO_AMP_MASK;
  temp |= pll->config.hw_state.pll10;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL(port, 10), temp);
+	I915_WRITE(BXT_PORT_PLL(phy, ch, 10), temp);


  /* Recalibrate with new settings */

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	temp = I915_READ(BXT_PORT_PLL_EBB_4(port));
+	temp = I915_READ(BXT_PORT_PLL_EBB_4(phy, ch));

  temp |= PORT_PLL_RECALIBRATE;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL_EBB_4(port), temp);
+	I915_WRITE(BXT_PORT_PLL_EBB_4(phy, ch), temp);

  temp &= ~PORT_PLL_10BIT_CLK_ENABLE;
  temp |= pll->config.hw_state.ebb4;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	I915_WRITE(BXT_PORT_PLL_EBB_4(port), temp);
+	I915_WRITE(BXT_PORT_PLL_EBB_4(phy, ch), temp);


  /* Enable PLL */
  temp = I915_READ(BXT_PORT_PLL_ENABLE(port));

drivers/gpu/drm/i915/intel_dpll_mgr.c +2 -2
@@ -1459,11 +1463,11 @@ static void bxt_ddi_pll_enable(struct drm_i915_private *dev_priv,
  	 * While we write to the group register to program all lanes at once we
  	 * can read only lane registers and we pick lanes 0/1 for that.
  	 */
-	temp = I915_READ(BXT_PORT_PCS_DW12_LN01(port));
+	temp = I915_READ(BXT_PORT_PCS_DW12_LN01(phy, ch));
  	temp &= ~LANE_STAGGER_MASK;
  	temp &= ~LANESTAGGER_STRAP_OVRD;
  	temp |= pll->config.hw_state.pcsdw12;
-	I915_WRITE(BXT_PORT_PCS_DW12_GRP(port), temp);
+	I915_WRITE(BXT_PORT_PCS_DW12_GRP(phy, ch), temp);
  }


 static void bxt_ddi_pll_disable(struct drm_i915_private *dev_priv,

drivers/gpu/drm/i915/intel_dpll_mgr.c +0 -0
@@ -1485,6 +1489,10 @@ static bool bxt_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,

  enum port port = (enum port)pll->id; /* 1:1 port->PLL mapping */
  uint32_t val;
  bool ret;

drivers/gpu/drm/i915/intel_dpll_mgr.c +4 -0
+	u32 phy;
+	enum dpio_channel ch;
+
+	bxt_port_to_phy_channel(port, &phy, &ch);


  if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS)) return false;

drivers/gpu/drm/i915/intel_dpll_mgr.c +0 -0
@@ -1495,36 +1503,36 @@ static bool bxt_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
  	if (!(val & PORT_PLL_ENABLE))
  		goto out;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->ebb0 = I915_READ(BXT_PORT_PLL_EBB_0(port));
+	hw_state->ebb0 = I915_READ(BXT_PORT_PLL_EBB_0(phy, ch));

  hw_state->ebb0 &= PORT_PLL_P1_MASK | PORT_PLL_P2_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->ebb4 = I915_READ(BXT_PORT_PLL_EBB_4(port));
+	hw_state->ebb4 = I915_READ(BXT_PORT_PLL_EBB_4(phy, ch));

  hw_state->ebb4 &= PORT_PLL_10BIT_CLK_ENABLE;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll0 = I915_READ(BXT_PORT_PLL(port, 0));
+	hw_state->pll0 = I915_READ(BXT_PORT_PLL(phy, ch, 0));

  hw_state->pll0 &= PORT_PLL_M2_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll1 = I915_READ(BXT_PORT_PLL(port, 1));
+	hw_state->pll1 = I915_READ(BXT_PORT_PLL(phy, ch, 1));

  hw_state->pll1 &= PORT_PLL_N_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll2 = I915_READ(BXT_PORT_PLL(port, 2));
+	hw_state->pll2 = I915_READ(BXT_PORT_PLL(phy, ch, 2));

  hw_state->pll2 &= PORT_PLL_M2_FRAC_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll3 = I915_READ(BXT_PORT_PLL(port, 3));
+	hw_state->pll3 = I915_READ(BXT_PORT_PLL(phy, ch, 3));

  hw_state->pll3 &= PORT_PLL_M2_FRAC_ENABLE;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll6 = I915_READ(BXT_PORT_PLL(port, 6));
+	hw_state->pll6 = I915_READ(BXT_PORT_PLL(phy, ch, 6));

  hw_state->pll6 &= PORT_PLL_PROP_COEFF_MASK | PORT_PLL_INT_COEFF_MASK | PORT_PLL_GAIN_CTL_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll8 = I915_READ(BXT_PORT_PLL(port, 8));
+	hw_state->pll8 = I915_READ(BXT_PORT_PLL(phy, ch, 8));

  hw_state->pll8 &= PORT_PLL_TARGET_CNT_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll9 = I915_READ(BXT_PORT_PLL(port, 9));
+	hw_state->pll9 = I915_READ(BXT_PORT_PLL(phy, ch, 9));

  hw_state->pll9 &= PORT_PLL_LOCK_THRESHOLD_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
-	hw_state->pll10 = I915_READ(BXT_PORT_PLL(port, 10));
+	hw_state->pll10 = I915_READ(BXT_PORT_PLL(phy, ch, 10));

  hw_state->pll10 &= PORT_PLL_DCO_AMP_OVR_EN_H | PORT_PLL_DCO_AMP_MASK;

drivers/gpu/drm/i915/intel_dpll_mgr.c +3 -3
@@ -1533,11 +1541,11 @@ static bool bxt_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
  	 * can read only lane registers. We configure all lanes the same way, so
  	 * here just read out lanes 0/1 and output a note if lanes 2/3 differ.
  	 */
-	hw_state->pcsdw12 = I915_READ(BXT_PORT_PCS_DW12_LN01(port));
-	if (I915_READ(BXT_PORT_PCS_DW12_LN23(port)) != hw_state->pcsdw12)
+	hw_state->pcsdw12 = I915_READ(BXT_PORT_PCS_DW12_LN01(phy, ch));
+	if (I915_READ(BXT_PORT_PCS_DW12_LN23(phy, ch)) != hw_state->pcsdw12)
  		DRM_DEBUG_DRIVER("lane stagger config different for lane 01 (%08x) and 23 (%08x)\n",
  				 hw_state->pcsdw12,
-				 I915_READ(BXT_PORT_PCS_DW12_LN23(port)));
+				 I915_READ(BXT_PORT_PCS_DW12_LN23(phy, ch)));
  	hw_state->pcsdw12 &= LANE_STAGGER_MASK | LANESTAGGER_STRAP_OVRD;
Quoted 2 lines


  ret = true;

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

#17 lore raw

✗ Fi.CI.BAT: warning for Broxton ddi phy refactoring

In reply to Ander Conselvan de Oliveira
== Series Details ==

== Series Details ==

Series: Broxton ddi phy refactoring
URL : https://patchwork.freedesktop.org/series/13320/
State : warning

== Summary ==

Series 13320v1 Broxton ddi phy refactoring
https://patchwork.freedesktop.org/api/1.0/series/13320/revisions/1/mbox/

Test kms_pipe_crc_basic:

        Subgroup suspend-read-crc-pipe-a:
                dmesg-warn -> PASS       (fi-byt-j1900)
        Subgroup suspend-read-crc-pipe-b:
                pass       -> DMESG-WARN (fi-byt-j1900)
Test kms_psr_sink_crc:
        Subgroup psr_basic:
                dmesg-warn -> PASS       (fi-skl-6700hq)
fi-bdw-5557u     total:244  pass:229  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:244  pass:202  dwarn:0   dfail:0   fail:0   skip:42 
fi-bxt-t5700     total:244  pass:214  dwarn:0   dfail:0   fail:0   skip:30 
fi-byt-j1900     total:244  pass:211  dwarn:1   dfail:0   fail:1   skip:31 
fi-byt-n2820     total:244  pass:208  dwarn:0   dfail:0   fail:1   skip:35 
fi-hsw-4770      total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-hsw-4770r     total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-ilk-650       total:244  pass:182  dwarn:0   dfail:0   fail:2   skip:60 
fi-ivb-3520m     total:244  pass:219  dwarn:0   dfail:0   fail:0   skip:25 
fi-ivb-3770      total:244  pass:207  dwarn:0   dfail:0   fail:0   skip:37 
fi-kbl-7200u     total:244  pass:220  dwarn:0   dfail:0   fail:0   skip:24 
fi-skl-6260u     total:244  pass:230  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6700k     total:244  pass:219  dwarn:1   dfail:0   fail:0   skip:24 
fi-skl-6770hq    total:244  pass:228  dwarn:1   dfail:0   fail:1   skip:14 
fi-snb-2520m     total:244  pass:208  dwarn:0   dfail:0   fail:0   skip:36 
fi-snb-2600      total:244  pass:207  dwarn:0   dfail:0   fail:0   skip:37 

Results at /archive/results/CI_IGT_test/Patchwork_2628/

0ff41ae4e5f0bbbb83e3abcc170c1dab648f28b3 drm-intel-nightly: 2016y-10m-05d-09h-47m-15s UTC integration manifest dae03a4 drm/i915: Address broxton phy registers based on phy and channel number
474f0a2 drm/i915: Add location of the Rcomp resistor to bxt_ddi_phy_info
12bf891 drm/i915: Create a struct to hold information about the broxton phys
13a64e5 drm/i915: Move broxton vswing sequence to intel_dpio_phy.c
76d4a1d drm/i915: Move DPIO phy documentation section to intel_dpio_phy.c
88e0e98 drm/i915: Move broxton phy code to intel_dpio_phy.c
3cbc17f drm/i915: Pass lane count to bxt_ddi_phy_calc_lane_optmin_mask()
158e044 drm/i915: Explicitly map broxton DPIO power wells to phys
a7ca7d0 drm/i915: Rename struct i915_power_well field data to id

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