Skip to contentSkip to conversation

dt-bindings: display: bridge: tc358867: Document default DP preemphasis

PATCH Superseded Marek Vasut 2 participants 6 messages Jun 21, 2024 – Jun 24, 2024

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 dt-bindings: display: bridge: tc358867: Document default DP preemphasis

Document default DP port preemphasis configurable via new DT property "toshiba,pre-emphasis". This is useful in case the DP link properties are known and starting link training from preemphasis setting of 0 dB is not useful. The preemphasis can be set separately for both DP lanes in range 0=0dB, 1=3.5dB, 2=6dB .

---
Cc: Andrzej Hajda <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix the type to u8 array
- Fix the enum items to match what they represent

---
 .../display/bridge/toshiba,tc358767.yaml       | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +18 -0
index 2ad0cd6dd49e0..6287eb2b40908 100644
@@ -98,6 +98,24 @@ properties:
             reference to a valid eDP panel input endpoint node. This port is
             optional, treated as DP panel if not defined
 
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
+            unevaluatedProperties: false
+
+            properties:
+              toshiba,pre-emphasis:
+                description:
+                  Display port output Pre-Emphasis settings for both ports.
+                $ref: /schemas/types.yaml#/definitions/uint8-array
+                minItems: 2
+                maxItems: 2
+                items:
+                  enum:
+                    - 0 # No pre-emphasis
+                    - 1 # 3.5dB pre-emphasis
+                    - 2 # 6dB pre-emphasis
+
     oneOf:
       - required:
           - port@0
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 2/2 drm/bridge: tc358767: Add configurable default preemphasis

Make the default DP port preemphasis configurable via new DT property "toshiba,pre-emphasis". This is useful in case the DP link properties are known and starting link training from preemphasis setting of 0 dB is not useful. The preemphasis can be set separately for both DP lanes in range 0=0dB, 1=3.5dB, 2=6dB .

---
Cc: Andrzej Hajda <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Parse toshiba,pre-emphasis property out of an endpoint of port 2 (the DP port)

---
 drivers/gpu/drm/bridge/tc358767.c | 45 ++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/tc358767.c +38 -7
index 2b035a136a6e5..8f81fc960d0fa 100644
@@ -241,6 +241,10 @@
 
 /* Link Training */
 #define DP0_SRCCTRL		0x06a0
+#define DP0_SRCCTRL_PRE1		GENMASK(29, 28)
+#define DP0_SRCCTRL_SWG1		GENMASK(25, 24)
+#define DP0_SRCCTRL_PRE0		GENMASK(21, 20)
+#define DP0_SRCCTRL_SWG0		GENMASK(17, 16)
 #define DP0_SRCCTRL_SCRMBLDIS		BIT(13)
 #define DP0_SRCCTRL_EN810B		BIT(12)
 #define DP0_SRCCTRL_NOTP		(0 << 8)
@@ -278,6 +282,8 @@
 #define AUDIFDATA6		0x0720	/* DP0 Audio Info Frame Bytes 27 to 24 */
 
 #define DP1_SRCCTRL		0x07a0	/* DP1 Control Register */
+#define DP1_SRCCTRL_PRE			GENMASK(21, 20)
+#define DP1_SRCCTRL_SWG			GENMASK(17, 16)
 
 /* PHY */
 #define DP_PHY_CTRL		0x0800
@@ -369,6 +375,7 @@ struct tc_data {
 
 	u32			rev;
 	u8			assr;
+	u8			pre_emphasis[2];
 
 	struct gpio_desc	*sd_gpio;
 	struct gpio_desc	*reset_gpio;
@@ -1090,13 +1097,17 @@ static int tc_main_link_enable(struct tc_data *tc)
 			return ret;
 	}
 
-	ret = regmap_write(tc->regmap, DP0_SRCCTRL, tc_srcctrl(tc));
+	ret = regmap_write(tc->regmap, DP0_SRCCTRL,
+			   tc_srcctrl(tc) |
+			   FIELD_PREP(DP0_SRCCTRL_PRE0, tc->pre_emphasis[0]) |
+			   FIELD_PREP(DP0_SRCCTRL_PRE1, tc->pre_emphasis[1]));
 	if (ret)
 		return ret;
 	/* SSCG and BW27 on DP1 must be set to the same as on DP0 */
 	ret = regmap_write(tc->regmap, DP1_SRCCTRL,
 		 (tc->link.spread ? DP0_SRCCTRL_SSCG : 0) |
-		 ((tc->link.rate != 162000) ? DP0_SRCCTRL_BW27 : 0));
+		 ((tc->link.rate != 162000) ? DP0_SRCCTRL_BW27 : 0) |
+		 FIELD_PREP(DP1_SRCCTRL_PRE, tc->pre_emphasis[1]));
 	if (ret)
 		return ret;
 
@@ -1188,8 +1199,10 @@ static int tc_main_link_enable(struct tc_data *tc)
 		goto err_dpcd_write;
 
 	/* Reset voltage-swing & pre-emphasis */
-	tmp[0] = tmp[1] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 |
-			  DP_TRAIN_PRE_EMPH_LEVEL_0;
+	tmp[0] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 |
+		 FIELD_PREP(DP_TRAIN_PRE_EMPHASIS_MASK, tc->pre_emphasis[0]);
+	tmp[1] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 |
+		 FIELD_PREP(DP_TRAIN_PRE_EMPHASIS_MASK, tc->pre_emphasis[1]);
 	ret = drm_dp_dpcd_write(aux, DP_TRAINING_LANE0_SET, tmp, 2);
 	if (ret < 0)
 		goto err_dpcd_write;
@@ -1213,7 +1226,9 @@ static int tc_main_link_enable(struct tc_data *tc)
 	ret = regmap_write(tc->regmap, DP0_SRCCTRL,
 			   tc_srcctrl(tc) | DP0_SRCCTRL_SCRMBLDIS |
 			   DP0_SRCCTRL_AUTOCORRECT |
-			   DP0_SRCCTRL_TP1);
+			   DP0_SRCCTRL_TP1 |
+			   FIELD_PREP(DP0_SRCCTRL_PRE0, tc->pre_emphasis[0]) |
+			   FIELD_PREP(DP0_SRCCTRL_PRE1, tc->pre_emphasis[1]));
 	if (ret)
 		return ret;
 
@@ -1248,7 +1263,9 @@ static int tc_main_link_enable(struct tc_data *tc)
 	ret = regmap_write(tc->regmap, DP0_SRCCTRL,
 			   tc_srcctrl(tc) | DP0_SRCCTRL_SCRMBLDIS |
 			   DP0_SRCCTRL_AUTOCORRECT |
-			   DP0_SRCCTRL_TP2);
+			   DP0_SRCCTRL_TP2 |
+			   FIELD_PREP(DP0_SRCCTRL_PRE0, tc->pre_emphasis[0]) |
+			   FIELD_PREP(DP0_SRCCTRL_PRE1, tc->pre_emphasis[1]));
 	if (ret)
 		return ret;
 
@@ -1274,7 +1291,9 @@ static int tc_main_link_enable(struct tc_data *tc)
 
 	/* Clear Training Pattern, set AutoCorrect Mode = 1 */
 	ret = regmap_write(tc->regmap, DP0_SRCCTRL, tc_srcctrl(tc) |
-			   DP0_SRCCTRL_AUTOCORRECT);
+			   DP0_SRCCTRL_AUTOCORRECT |
+			   FIELD_PREP(DP0_SRCCTRL_PRE0, tc->pre_emphasis[0]) |
+			   FIELD_PREP(DP0_SRCCTRL_PRE1, tc->pre_emphasis[1]));
 	if (ret)
 		return ret;
 
@@ -2408,6 +2427,18 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc)
 			return -EINVAL;
 		}
 		mode |= BIT(endpoint.port);
+		if (endpoint.port != 2)
+			continue;
+
+		of_property_read_u8_array(node, "toshiba,pre-emphasis",
+					  tc->pre_emphasis,
+					  ARRAY_SIZE(tc->pre_emphasis));
+
+		if (tc->pre_emphasis[0] < 0 || tc->pre_emphasis[0] > 2 ||
+		    tc->pre_emphasis[1] < 0 || tc->pre_emphasis[1] > 2) {
+			dev_err(dev, "Incorrect Pre-Emphasis setting, use either 0=0dB 1=3.5dB 2=6dB\n");
+			return -EINVAL;
+		}
 	}
 
 	if (mode == mode_dpi_to_edp || mode == mode_dpi_to_dp) {
Signature · 1 line
2.43.0
#2 lore raw
In reply to Marek Vasut
Quoted 40 lines · Marek Vasut

Document default DP port preemphasis configurable via new DT property "toshiba,pre-emphasis". This is useful in case the DP link properties are known and starting link training from preemphasis setting of 0 dB is not useful. The preemphasis can be set separately for both DP lanes in range 0=0dB, 1=3.5dB, 2=6dB .

---
Cc: Andrzej Hajda <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix the type to u8 array
- Fix the enum items to match what they represent

---
 .../display/bridge/toshiba,tc358767.yaml       | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +0 -0
index 2ad0cd6dd49e0..6287eb2b40908 100644
@@ -98,6 +98,24 @@ properties:
             reference to a valid eDP panel input endpoint node. This port is
             optional, treated as DP panel if not defined

Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml properties: · line 109

Quoted 10 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +9 -0
 
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
+            unevaluatedProperties: false
+
+            properties:
+              toshiba,pre-emphasis:
+                description:
+                  Display port output Pre-Emphasis settings for both ports.

Why here and not in the port nodes?

Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml properties: · line 117

Quoted 8 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +8 -0
+                $ref: /schemas/types.yaml#/definitions/uint8-array
+                minItems: 2
+                maxItems: 2
+                items:
+                  enum:
+                    - 0 # No pre-emphasis
+                    - 1 # 3.5dB pre-emphasis
+                    - 2 # 6dB pre-emphasis

I'd love to say please make this -bB and put this in units, but that'd require it being a string..

Quoted 7 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +1 -0
+
     oneOf:
       - required:
           - port@0
Signature · 1 line
2.43.0
#3 lore raw
Quoted 23 lines · Conor Dooley
Quoted 22 lines · Marek Vasut

Document default DP port preemphasis configurable via new DT property "toshiba,pre-emphasis". This is useful in case the DP link properties are known and starting link training from preemphasis setting of 0 dB is not useful. The preemphasis can be set separately for both DP lanes in range 0=0dB, 1=3.5dB, 2=6dB .

---
V2: - Fix the type to u8 array
- Fix the enum items to match what they represent

---
  .../display/bridge/toshiba,tc358767.yaml       | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +0 -0
index 2ad0cd6dd49e0..6287eb2b40908 100644
@@ -98,6 +98,24 @@ properties:
              reference to a valid eDP panel input endpoint node. This port is
              optional, treated as DP panel if not defined
 
Quoted 11 lines

Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml properties: · line 109

Quoted 9 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +9 -0
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
+            unevaluatedProperties: false
+
+            properties:
+              toshiba,pre-emphasis:
+                description:
+                  Display port output Pre-Emphasis settings for both ports.

Why here and not in the port nodes?

There was a short discussion about that in V1:

https://lore.kernel.org/all/[email protected]/

"
Let's keep it in the endpoint node.

There is some mention in the TC9595 datasheet that the DP might operate in some split mode, where each DP lane is used to feed one display (?), so I assume in that case there might be two endpoints (?), but that is not supported right now.

If that is ever needed, I guess this array would have minItems 1 and maxItems 2 and another endpoint would be added to the schema for this port 2.
"

Quoted 11 lines

Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml properties: · line 117

Quoted 8 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +8 -0
+                $ref: /schemas/types.yaml#/definitions/uint8-array
+                minItems: 2
+                maxItems: 2
+                items:
+                  enum:
+                    - 0 # No pre-emphasis
+                    - 1 # 3.5dB pre-emphasis
+                    - 2 # 6dB pre-emphasis

I'd love to say please make this -bB and put this in units, but that'd require it being a string..

I can do that. Do you think that's worth it ?

#4 lore raw
Quoted 47 lines · Marek Vasut
Quoted 25 lines · Conor Dooley
Quoted 24 lines · Marek Vasut

Document default DP port preemphasis configurable via new DT property "toshiba,pre-emphasis". This is useful in case the DP link properties are known and starting link training from preemphasis setting of 0 dB is not useful. The preemphasis can be set separately for both DP lanes in range 0=0dB, 1=3.5dB, 2=6dB .

---
V2: - Fix the type to u8 array
- Fix the enum items to match what they represent

---
  .../display/bridge/toshiba,tc358767.yaml       | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +3 -0
index 2ad0cd6dd49e0..6287eb2b40908 100644
@@ -98,6 +98,24 @@ properties:
              reference to a valid eDP panel input endpoint node. This port is
              optional, treated as DP panel if not defined
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
Quoted 8 lines

Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml properties: · line 109

Quoted 6 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +6 -0
+            unevaluatedProperties: false
+
+            properties:
+              toshiba,pre-emphasis:
+                description:
+                  Display port output Pre-Emphasis settings for both ports.

Why here and not in the port nodes?

There was a short discussion about that in V1:

https://lore.kernel.org/all/[email protected]/

"
Let's keep it in the endpoint node.

There is some mention in the TC9595 datasheet that the DP might operate in some split mode, where each DP lane is used to feed one display (?), so I assume in that case there might be two endpoints (?), but that is not supported right now.

Quoted 4 lines

If that is ever needed, I guess this array would have minItems 1 and maxItems 2 and another endpoint would be added to the schema for this port 2.
"

Can this be put in the commit message please?

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +8 -0
+                $ref: /schemas/types.yaml#/definitions/uint8-array
+                minItems: 2
+                maxItems: 2
+                items:
+                  enum:
+                    - 0 # No pre-emphasis
+                    - 1 # 3.5dB pre-emphasis
+                    - 2 # 6dB pre-emphasis
Quoted 4 lines
Quoted 2 lines

I'd love to say please make this -bB and put this in units, but that'd require it being a string..

I can do that. Do you think that's worth it ?

I dunno, I'd advocate for it for any other unit cos I would ask for the unit to be changed into something that didn't require fractions. But for decibels, that just going to be confusing given how it works. I think for dB it's just not worth it.

#5 lore raw
Quoted 48 lines · Conor Dooley
Quoted 47 lines · Marek Vasut
Quoted 25 lines · Conor Dooley
Quoted 24 lines · Marek Vasut

Document default DP port preemphasis configurable via new DT property "toshiba,pre-emphasis". This is useful in case the DP link properties are known and starting link training from preemphasis setting of 0 dB is not useful. The preemphasis can be set separately for both DP lanes in range 0=0dB, 1=3.5dB, 2=6dB .

---
V2: - Fix the type to u8 array
- Fix the enum items to match what they represent

---
   .../display/bridge/toshiba,tc358767.yaml       | 18 ++++++++++++++++++
   1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +3 -0
index 2ad0cd6dd49e0..6287eb2b40908 100644
@@ -98,6 +98,24 @@ properties:
               reference to a valid eDP panel input endpoint node. This port is
               optional, treated as DP panel if not defined
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
Quoted 8 lines

Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml properties: · line 109

Quoted 6 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +6 -0
+            unevaluatedProperties: false
+
+            properties:
+              toshiba,pre-emphasis:
+                description:
+                  Display port output Pre-Emphasis settings for both ports.

Why here and not in the port nodes?

There was a short discussion about that in V1:

https://lore.kernel.org/all/[email protected]/

"
Let's keep it in the endpoint node.

There is some mention in the TC9595 datasheet that the DP might operate in some split mode, where each DP lane is used to feed one display (?), so I assume in that case there might be two endpoints (?), but that is not supported right now.

Quoted 6 lines
Quoted 4 lines

If that is ever needed, I guess this array would have minItems 1 and maxItems 2 and another endpoint would be added to the schema for this port 2.
"

Can this be put in the commit message please?

Will do.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml properties: · line 117

Quoted 8 lines
Documentation/devicetree/bindings/display/bridge/toshiba,tc358767.yaml +8 -0
+                $ref: /schemas/types.yaml#/definitions/uint8-array
+                minItems: 2
+                maxItems: 2
+                items:
+                  enum:
+                    - 0 # No pre-emphasis
+                    - 1 # 3.5dB pre-emphasis
+                    - 2 # 6dB pre-emphasis

I'd love to say please make this -bB and put this in units, but that'd require it being a string..

Quoted 6 lines
Quoted 1 line

I can do that. Do you think that's worth it ?

I dunno, I'd advocate for it for any other unit cos I would ask for the unit to be changed into something that didn't require fractions. But for decibels, that just going to be confusing given how it works. I think for dB it's just not worth it.

All right then.