Skip to contentSkip to conversation

Add eDP support for RK3576

PATCH Applied Damon Ding 4 participants 19 messages Jun 1 – Jul 30

Subsystems (6)

v10 of 11 Applied Latest is v11 →

lore
Share & tools
lore

Damon Ding

author
#0 lore raw

v10 cover Add eDP support for RK3576

Patch 1-5 are to add missing clock "hclk" for RK3588 eDP nodes. Patch 6 is to use automatic cleanup to fix OF node reference leak
reported by Sashiko.
Patch 7-8 are to add the RK3576 eDP node.
Patch 9-11 are to support the RK3576 Analogix DP controller.

Damon Ding (11):
dt-bindings: display: rockchip: analogix-dp: Fix hclk as third clock

    for RK3588

dt-bindings: display: rockchip: analogix-dp: Add per-clock
descriptions
arm64: dts: rockchip: Add missing hclk for RK3588 eDP0
arm64: dts: rockchip: Add missing hclk for RK3588 eDP1 drm/rockchip: analogix_dp: Enable hclk for RK3588 drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup
dt-bindings: display: rockchip: analogix-dp: Add support for RK3576
arm64: dts: rockchip: Add eDP node for RK3576
drm/bridge: analogix_dp: Rename and simplify is_rockchip() drm/bridge: analogix_dp: Add support for RK3576 drm/rockchip: analogix_dp: Add support for RK3576

 .../rockchip/rockchip,analogix-dp.yaml        | 47 ++++++++++++++++++-
 arch/arm64/boot/dts/rockchip/rk3576.dtsi      | 28 +++++++++++
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi |  4 +-
 .../arm64/boot/dts/rockchip/rk3588-extra.dtsi |  4 +-
 .../drm/bridge/analogix/analogix_dp_core.c    |  3 +-
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 18 +++----
 .../gpu/drm/rockchip/analogix_dp-rockchip.c   | 31 +++++++++---
 include/drm/bridge/analogix_dp.h              | 13 ++++-
 8 files changed, 124 insertions(+), 24 deletions(-)

---

Changes in v2:
- Split out separate patches to add the "hclk" clock reference.
- Split out separate patches to enable the "hclk" clock.
- Add Reviewed-by tag.

Changes in v3:
- Add a patch to expand descriptions for clocks of the eDP node.
- Add Reviewed-by tag.

Changes in v4:
- Modify commit msg.

Changes in v5:
- Enforce the correct third clock name on a per-compatible basis.
- Modify the commit msg simultaneously.
- Add Acked-by tag.

Changes in v6:
- Expand more detail commit msg about using hclk instead of grf clock.

Changes in v7:
- List all valid clock names at the top level, and constrain the clock count for each platform with minItems/maxItems in allOf.

Changes in v8:
- Fix indentation to 10 for enum in clock-names property.

Changes in v9:
- Restore the explicit clock-names for RK3399 and RK3588 eDP dt-bindings.

Changes in v10:
- Use automatic cleanup to fix OF node reference leak reported by Sashiko.

Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v10 1/11 dt-bindings: display: rockchip: analogix-dp: Fix hclk as third clock for RK3588

RK3588 eDP controller requires HCLK_VO1 to access the VO1 GRF registers and enable the video datapath.

Previously, the clock was enabled implicitly via the 'rockchip,vo-grf' phandle reference, which allowed the eDP to work without explicitly managing the hclk_vo1 clock. However, this is not safe or explicit.

To make the clock dependency explicit, enforce per-SoC clock-names requirements:
- RK3288: 2 clocks (dp, pclk)
- RK3399: 3 clocks (dp, pclk, grf)
- RK3588: 3 clocks (dp, pclk, hclk)

Do not reuse the 'grf' clock name for RK3588 because it represents a different clock with distinct control logic:
- The 'grf' clock is only for GRF register access and is toggled dynamically during register access.
- The 'hclk' clock controls both GRF access and video datapath gating, and must remain enabled during probe.

Fixes f855146263b1 ("dt-bindings: display: rockchip: analogix-dp: Add support for RK3588")

---

Changes in v4:
- Modify the commit msg.

Changes in v5:
- Enforce the correct third clock name on a per-compatible basis.
- Modify the commit msg simultaneously.

Changes in v6:
- Expand more detail commit msg about using hclk instead of grf clock.

Changes in v7:
- List all valid clock names at the top level, and constrain the clock count for each platform with minItems/maxItems in allOf.

Changes in v8:
- Fix indentation to 10 for enum in clock-names property.

Changes in v9:
- Restore the explicit clock-names for RK3399 and RK3588.

---
 .../rockchip/rockchip,analogix-dp.yaml        | 40 ++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml +39 -1
index d99b23b88cc5..6643889f2a9c 100644
@@ -26,7 +26,9 @@ properties:
     items:
       - const: dp
       - const: pclk
-      - const: grf
+      - enum:
+          - grf
+          - hclk
 
   power-domains:
     maxItems: 1
@@ -60,6 +62,35 @@ required:
 allOf:
   - $ref: /schemas/display/bridge/analogix,dp.yaml#
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - rockchip,rk3288-dp
+    then:
+      properties:
+        clocks:
+          maxItems: 2
+        clock-names:
+          maxItems: 2
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - rockchip,rk3399-edp
+    then:
+      properties:
+        clocks:
+          minItems: 3
+        clock-names:
+          items:
+            - const: dp
+            - const: pclk
+            - const: grf
+
   - if:
       properties:
         compatible:
@@ -68,6 +99,13 @@ allOf:
               - rockchip,rk3588-edp
     then:
       properties:
+        clocks:
+          minItems: 3
+        clock-names:
+          items:
+            - const: dp
+            - const: pclk
+            - const: hclk
         resets:
           minItems: 2
         reset-names:
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH v10 2/11 dt-bindings: display: rockchip: analogix-dp: Add per-clock descriptions

In reply to Damon Ding

Supplement dedicated description for each clock in the clocks property, clarifying the function of each clock input for the Analogix DP controller binding.

---

Changes in v4:
- Modify the commit msg.

Changes in v5:
- Add Acked-by tag.

---
 .../bindings/display/rockchip/rockchip,analogix-dp.yaml      | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml +4 -1
index 6643889f2a9c..1ef1d56ef6e2 100644
@@ -19,7 +19,10 @@ properties:
 
   clocks:
     minItems: 2
-    maxItems: 3
+    items:
+      - description: Reference clock
+      - description: APB bus clock
+      - description: GRF or AHB bus clock
 
   clock-names:
     minItems: 2
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH v10 3/11 arm64: dts: rockchip: Add missing hclk for RK3588 eDP0

In reply to Damon Ding

Add the required HCLK_VO1 bus clock to RK3588 eDP0 node with corresponding clock-name "hclk". This clock is necessary for the eDP controller to access video output GRF and work properly.

Previously the clock was enabled implicitly via GRF phandle reference. Add it explicitly now to align with updated binding.

Fixes dc79d3d5e7c7 ("arm64: dts: rockchip: Add eDP0 node for RK3588")

---

Changes in v4:
- Modify the commit msg.

---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +2 -2
index 4fb8888c281c..24a5ccbac08c 100644
@@ -1712,8 +1712,8 @@ hdmi0_out: port@1 {
 	edp0: edp@fdec0000 {
 		compatible = "rockchip,rk3588-edp";
 		reg = <0x0 0xfdec0000 0x0 0x1000>;
-		clocks = <&cru CLK_EDP0_24M>, <&cru PCLK_EDP0>;
-		clock-names = "dp", "pclk";
+		clocks = <&cru CLK_EDP0_24M>, <&cru PCLK_EDP0>, <&cru HCLK_VO1>;
+		clock-names = "dp", "pclk", "hclk";
 		interrupts = <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH 0>;
 		phys = <&hdptxphy0>;
 		phy-names = "dp";
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH v10 4/11 arm64: dts: rockchip: Add missing hclk for RK3588 eDP1

In reply to Damon Ding

Add the required HCLK_VO1 bus clock to RK3588 eDP1 node with corresponding clock-name "hclk". This clock is necessary for the eDP controller to access video output GRF and work properly.

Previously the clock was enabled implicitly via GRF phandle reference. Add it explicitly now to align with updated binding.

Fixes a481bb0b1ad9 ("arm64: dts: rockchip: Add eDP1 dt node for rk3588")

---

Changes in v4:
- Modify the commit msg.

---
 arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi +2 -2
index a2640014ee04..b251bb129cdb 100644
@@ -285,8 +285,8 @@ hdmi1_out: port@1 {
 	edp1: edp@fded0000 {
 		compatible = "rockchip,rk3588-edp";
 		reg = <0x0 0xfded0000 0x0 0x1000>;
-		clocks = <&cru CLK_EDP1_24M>, <&cru PCLK_EDP1>;
-		clock-names = "dp", "pclk";
+		clocks = <&cru CLK_EDP1_24M>, <&cru PCLK_EDP1>, <&cru HCLK_VO1>;
+		clock-names = "dp", "pclk", "hclk";
 		interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH 0>;
 		phys = <&hdptxphy1>;
 		phy-names = "dp";
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH v10 5/11 drm/rockchip: analogix_dp: Enable hclk for RK3588

In reply to Damon Ding

Acquire and enable the HCLK_VO1 bus clock explicitly for RK3588 eDP controller to guarantee register and datapath access.

The clock was previously enabled implicitly via rockchip,vo-grf phandle reference, which relies on side effect and is fragile.

Fetch optional "hclk" clock in driver to align with updated device tree binding and keep consistent with hardware clock dependency.

Fixes 729f8eefdcad ("drm/rockchip: analogix_dp: Add support for RK3588")

---

Changes in v4:
- Modify the commit msg.

---
 drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +6 -0
index 06072efd7fca..d2af5eb29dbb 100644
@@ -311,6 +311,7 @@ static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
 {
 	struct device *dev = dp->dev;
 	struct device_node *np = dev->of_node;
+	struct clk *clk;
 
 	dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
 	if (IS_ERR(dp->grf))
@@ -327,6 +328,11 @@ static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
 		return dev_err_probe(dev, PTR_ERR(dp->pclk),
 				     "failed to get pclk property\n");
 
+	clk = devm_clk_get_optional_enabled(dev, "hclk");
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk),
+				     "failed to get hclk property\n");
+
 	dp->rst = devm_reset_control_get(dev, "dp");
 	if (IS_ERR(dp->rst))
 		return dev_err_probe(dev, PTR_ERR(dp->rst),
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v10 05/11] drm/rockchip: analogix_dp: Enable hclk for RK3588

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing analogix_dp_unbind() on error path in rockchip_dp_bind() causes resource leak and Use-After-Free risk.
- [High] Use-after-free risk via unreferenced device node pointer endpoint.local_node.
--

commit 9a213026e9dc13c601798dee6df75e3fbf1fabb3
Author: Damon Ding <[email protected]>

drm/rockchip: analogix_dp: Enable hclk for RK3588

Acquire and enable the HCLK_VO1 bus clock explicitly for RK3588 eDP controller to guarantee register and datapath access.

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c

Quoted 4 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +0 -0
index 06072efd7fca3..d2af5eb29dbb5 100644

[ ... ]

[Severity: High]
This is a pre-existing issue, but does rockchip_dp_bind() leak the AUX device registration on this error path?

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c:rockchip_dp_bind() {
...
err_cleanup_encoder:

	dp->encoder.encoder.funcs->destroy(&dp->encoder.encoder);
	return ret;
}

If analogix_dp_bind() succeeds but the subsequent drm_bridge_connector_init() fails, the code jumps to err_cleanup_encoder. This path destroys the encoder but fails to call analogix_dp_unbind(dp->adp).

Because analogix_dp_bind() successfully registered the DRM DP AUX device, failing to unregister it leaves the adapter active in the I2C subsystem. If the driver is unbound, devm will free the memory containing the drm_dp_aux structure, potentially leading to a use-after-free crash in the I2C subsystem during any subsequent access.

[Severity: High]
This isn't a bug introduced by this patch, but is there a use-after-free risk when accessing endpoint.local_node?

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c:rockchip_dp_drm_encoder_enable() {
...

	ret = drm_of_encoder_active_endpoint(dp->dev->of_node, encoder, &endpoint);
	if (ret < 0)
		return;

	remote_port_parent = of_graph_get_remote_port_parent(endpoint.local_node);

...
}

Inside drm_of_encoder_active_endpoint(), of_node_put() drops the reference on the local endpoint node before returning.

Since the reference is already dropped, could passing endpoint.local_node to of_graph_get_remote_port_parent() result in a use-after-free if a device tree overlay containing the node is removed concurrently?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
author
#8 lore raw

PATCH v10 6/11 drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup

In reply to Damon Ding

Sashiko reported a reference leak in rockchip_dp_drm_encoder_enable(), the of_get_child_by_name() function does not call of_node_put() in a symmetrical way [1].

Fix the device node reference leak by using __free(device_node) to automatically manage of_node_put() for all device nodes.

Fixes 729f8eefdcad ("drm/rockchip: analogix_dp: Add support for RK3588")
---
 drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +10 -6
index d2af5eb29dbb..b1ed25cefe5e 100644
@@ -8,6 +8,7 @@
  *         Jeff Chen <[email protected]>
  */
 
+#include <linux/cleanup.h>
 #include <linux/component.h>
 #include <linux/mfd/syscon.h>
 #include <linux/of.h>
@@ -206,7 +207,6 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
 	struct of_endpoint endpoint;
-	struct device_node *remote_port, *remote_port_parent;
 	char name[32];
 	u32 port_id;
 	int ret;
@@ -230,18 +230,22 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
 	if (ret < 0)
 		return;
 
-	remote_port_parent = of_graph_get_remote_port_parent(endpoint.local_node);
+	struct device_node *remote_port_parent __free(device_node) =
+		of_graph_get_remote_port_parent(endpoint.local_node);
 	if (remote_port_parent) {
-		if (of_get_child_by_name(remote_port_parent, "ports")) {
-			remote_port = of_graph_get_remote_port(endpoint.local_node);
+		struct device_node *ports __free(device_node) =
+			of_get_child_by_name(remote_port_parent, "ports");
+
+		if (ports) {
+			struct device_node *remote_port __free(device_node) =
+				of_graph_get_remote_port(endpoint.local_node);
+
 			of_property_read_u32(remote_port, "reg", &port_id);
-			of_node_put(remote_port);
 			sprintf(name, "%s vp%d", remote_port_parent->full_name, port_id);
 		} else {
 			sprintf(name, "%s %s",
 				remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb");
 		}
-		of_node_put(remote_port_parent);
 
 		DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
 	}
Signature · 1 line
2.34.1
#9 lore raw

Re: [PATCH v10 06/11] drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Pre-existing issues:
- [High] Stack buffer overflow caused by formatting an unbounded device tree node name into a fixed-size array, with the resulting string being completely unused.
- [High] Uninitialized variable port_id is read if of_property_read_u32() fails.
- [High] drm_of_encoder_active_endpoint returns an endpoint structure containing a dangling device_node pointer, causing a Use-After-Free.
- [High] The function calls clk_prepare_enable() and clk_disable_unprepare(), which can sleep, from within an atomic context.
--

commit 64019e228c078284dbae98e48cc02de08453152c
Author: Damon Ding <[email protected]>

drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup

This patch converts the device node reference management in rockchip_dp_drm_encoder_enable() to use the __free(device_node) auto-cleanup helper. It aims to fix a reference leak where of_node_put() was missed in early return paths.

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,

Quoted 4 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +0 -0
@@ -206,7 +207,6 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,

[Severity: High]
This is a pre-existing issue, but does this function call sleeping functions from an atomic context?

As the atomic_enable callback for the DRM encoder, this executes in an atomic context where sleeping is forbidden. However, rockchip_dp_drm_encoder_enable() calls clk_prepare_enable() and clk_disable_unprepare(). Both clock APIs acquire a mutex internally and can sleep, which could cause kernel warnings or deadlocks.

Quoted 3 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +0 -0
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
 	struct of_endpoint endpoint;

[ ... ]

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder, · line 234

Quoted 7 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +2 -1
@@ -230,18 +230,22 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
 	if (ret < 0)
 		return;
 
-	remote_port_parent = of_graph_get_remote_port_parent(endpoint.local_node);
+	struct device_node *remote_port_parent __free(device_node) =
+		of_graph_get_remote_port_parent(endpoint.local_node);

[Severity: High]
This isn't a bug introduced by this patch, but does the earlier call to drm_of_encoder_active_endpoint() leave endpoint.local_node as a dangling pointer?

Looking at drm_of_encoder_active_endpoint(), it parses the endpoint and drops the reference before returning:

    ret = of_graph_parse_endpoint(ep, endpoint);
    of_node_put(ep);
    return ret;

When we pass endpoint.local_node to of_graph_get_remote_port_parent() here, could this result in a use-after-free since the node's reference count was already decremented?

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder, · line 243

Quoted 11 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +7 -2
 	if (remote_port_parent) {
-		if (of_get_child_by_name(remote_port_parent, "ports")) {
-			remote_port = of_graph_get_remote_port(endpoint.local_node);
+		struct device_node *ports __free(device_node) =
+			of_get_child_by_name(remote_port_parent, "ports");
+
+		if (ports) {
+			struct device_node *remote_port __free(device_node) =
+				of_graph_get_remote_port(endpoint.local_node);
+
 			of_property_read_u32(remote_port, "reg", &port_id);

[Severity: High]
This is a pre-existing issue, but can port_id be left uninitialized if of_property_read_u32() fails?

The port_id variable is declared on the stack without initialization. If the "reg" property is missing or remote_port is NULL, port_id is never updated.

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder, · line 244

Quoted 2 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +0 -1
-			of_node_put(remote_port);
 			sprintf(name, "%s vp%d", remote_port_parent->full_name, port_id);

[Severity: High]
This isn't a bug introduced by this patch, but does this sprintf() write potentially unbounded string data into the 32-byte name array?

Device tree node names (like remote_port_parent->full_name) can exceed 32 characters, which would cause a stack buffer overflow. Additionally, if port_id was left uninitialized in the previous call, random integers could be appended here.

Furthermore, is the populated name buffer ever used? The subsequent debug print ignores it entirely:

    DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");

Can this sprintf() and the name array be removed entirely?

Quoted 8 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +0 -1
 		} else {
 			sprintf(name, "%s %s",
 				remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb");
 		}
-		of_node_put(remote_port_parent);
 
 		DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
 	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
author
#10 lore raw

PATCH v10 7/11 dt-bindings: display: rockchip: analogix-dp: Add support for RK3576

In reply to Damon Ding

RK3576 integrates an eDP TX controller compatible with the existing RK3588 hardware design, reuse the same binding configuration directly.

---

Changes in v2:
- Split out a separate patch to add the "hclk" clock reference.

Chanegs in v4:
- Modify the commit msg.

Changes in v5:
- Add Acked-by tag.

---
 .../bindings/display/rockchip/rockchip,analogix-dp.yaml         | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml +2 -0
index 1ef1d56ef6e2..6548f157fd96 100644
@@ -15,6 +15,7 @@ properties:
     enum:
       - rockchip,rk3288-dp
       - rockchip,rk3399-edp
+      - rockchip,rk3576-edp
       - rockchip,rk3588-edp
 
   clocks:
@@ -99,6 +100,7 @@ allOf:
         compatible:
           contains:
             enum:
+              - rockchip,rk3576-edp
               - rockchip,rk3588-edp
     then:
       properties:
Signature · 1 line
2.34.1
author
#11 lore raw

PATCH v10 8/11 arm64: dts: rockchip: Add eDP node for RK3576

In reply to Damon Ding

Add full device tree definition for the integrated eDP controller on RK3576, following the existing RK3588 hardware layout.

Configure required register range, clocks, interrupt, phy, power domain, reset and grf properties to fully describe the controller.

---

Changes in v2:
- Add Reviewed-by tag.

Changes in v4:
- Modify the commit msg.

---
 arch/arm64/boot/dts/rockchip/rk3576.dtsi | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
arch/arm64/boot/dts/rockchip/rk3576.dtsi +28 -0
index 28175d8200d5..733449cb88b1 100644
@@ -1496,6 +1496,34 @@ hdmi_out: port@1 {
 			};
 		};
 
+		edp: edp@27dc0000 {
+			compatible = "rockchip,rk3576-edp";
+			reg = <0x0 0x27dc0000 0x0 0x1000>;
+			clocks = <&cru CLK_EDP0_24M>, <&cru PCLK_EDP0>, <&cru HCLK_VO0_ROOT>;
+			clock-names = "dp", "pclk", "hclk";
+			interrupts = <GIC_SPI 365 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&hdptxphy>;
+			phy-names = "dp";
+			power-domains = <&power RK3576_PD_VO0>;
+			resets = <&cru SRST_EDP0_24M>, <&cru SRST_P_EDP0>;
+			reset-names = "dp", "apb";
+			rockchip,grf = <&vo0_grf>;
+			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				edp_in: port@0 {
+					reg = <0>;
+				};
+
+				edp_out: port@1 {
+					reg = <1>;
+				};
+			};
+		};
+
 		dp: dp@27e40000 {
 			compatible = "rockchip,rk3576-dp";
 			reg = <0x0 0x27e40000 0x0 0x30000>;
Signature · 1 line
2.34.1
author
#12 lore raw

PATCH v10 9/11 drm/bridge: analogix_dp: Rename and simplify is_rockchip()

In reply to Damon Ding

Rename inline helper is_rockchip() to analogix_dp_is_rockchip() to follow driver namespace convention consistently across code.

Replace chained equality comparisons with switch-case layout to improve readability and simplify adding new SoC entries later.

---

Changes in v3:
- Add Reviewed-by tag.

Changes in v4:
- Modify the commit msg.

---
 .../gpu/drm/bridge/analogix/analogix_dp_core.c |  2 +-
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c  | 18 +++++++++---------
 include/drm/bridge/analogix_dp.h               | 11 +++++++++--
 3 files changed, 19 insertions(+), 12 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1 -1
index 8cf6b73bceac..116de3bd83a3 100644
@@ -870,7 +870,7 @@ static int analogix_dp_bridge_atomic_check(struct drm_bridge *bridge,
 	struct drm_display_info *di = &conn_state->connector->display_info;
 	u32 mask = BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444) | BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422);
 
-	if (is_rockchip(dp->plat_data->dev_type)) {
+	if (analogix_dp_is_rockchip(dp->plat_data->dev_type)) {
 		if ((di->color_formats & mask)) {
 			DRM_DEBUG_KMS("Swapping display color format from YUV to RGB\n");
 			di->color_formats &= ~mask;
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +9 -9
index 38fd8d5014d2..6207ded7ffd5 100644
@@ -72,7 +72,7 @@ void analogix_dp_init_analog_param(struct analogix_dp_device *dp)
 	reg = SEL_24M | TX_DVDD_BIT_1_0625V;
 	writel(reg, dp->reg_base + ANALOGIX_DP_ANALOG_CTL_2);
 
-	if (dp->plat_data && is_rockchip(dp->plat_data->dev_type)) {
+	if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type)) {
 		reg = REF_CLK_24M;
 		if (dp->plat_data->dev_type == RK3288_DP)
 			reg ^= REF_CLK_MASK;
@@ -123,7 +123,7 @@ void analogix_dp_reset(struct analogix_dp_device *dp)
 	analogix_dp_stop_video(dp);
 	analogix_dp_enable_video_mute(dp, 0);
 
-	if (dp->plat_data && is_rockchip(dp->plat_data->dev_type))
+	if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type))
 		reg = RK_VID_CAP_FUNC_EN_N | RK_VID_FIFO_FUNC_EN_N |
 			SW_FUNC_EN_N;
 	else
@@ -233,7 +233,7 @@ void analogix_dp_set_pll_power_down(struct analogix_dp_device *dp, bool enable)
 	u32 mask = DP_PLL_PD;
 	u32 pd_addr = ANALOGIX_DP_PLL_CTL;
 
-	if (dp->plat_data && is_rockchip(dp->plat_data->dev_type)) {
+	if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type)) {
 		pd_addr = ANALOGIX_DP_PD;
 		mask = RK_PLL_PD;
 	}
@@ -254,12 +254,12 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp,
 	u32 phy_pd_addr = ANALOGIX_DP_PHY_PD;
 	u32 mask;
 
-	if (dp->plat_data && is_rockchip(dp->plat_data->dev_type))
+	if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type))
 		phy_pd_addr = ANALOGIX_DP_PD;
 
 	switch (block) {
 	case AUX_BLOCK:
-		if (dp->plat_data && is_rockchip(dp->plat_data->dev_type))
+		if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type))
 			mask = RK_AUX_PD;
 		else
 			mask = AUX_PD;
@@ -317,7 +317,7 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp,
 		 * to power off everything instead of DP_PHY_PD in
 		 * Rockchip
 		 */
-		if (dp->plat_data && is_rockchip(dp->plat_data->dev_type))
+		if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type))
 			mask = DP_INC_BG;
 		else
 			mask = DP_PHY_PD;
@@ -329,7 +329,7 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp,
 			reg &= ~mask;
 
 		writel(reg, dp->reg_base + phy_pd_addr);
-		if (dp->plat_data && is_rockchip(dp->plat_data->dev_type))
+		if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type))
 			usleep_range(10, 15);
 		break;
 	case POWER_ALL:
@@ -465,7 +465,7 @@ void analogix_dp_init_aux(struct analogix_dp_device *dp)
 	analogix_dp_reset_aux(dp);
 
 	/* AUX_BIT_PERIOD_EXPECTED_DELAY doesn't apply to Rockchip IP */
-	if (dp->plat_data && is_rockchip(dp->plat_data->dev_type))
+	if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type))
 		reg = 0;
 	else
 		reg = AUX_BIT_PERIOD_EXPECTED_DELAY(3);
@@ -837,7 +837,7 @@ void analogix_dp_config_video_slave_mode(struct analogix_dp_device *dp)
 	u32 reg;
 
 	reg = readl(dp->reg_base + ANALOGIX_DP_FUNC_EN_1);
-	if (dp->plat_data && is_rockchip(dp->plat_data->dev_type)) {
+	if (dp->plat_data && analogix_dp_is_rockchip(dp->plat_data->dev_type)) {
 		reg &= ~(RK_VID_CAP_FUNC_EN_N | RK_VID_FIFO_FUNC_EN_N);
 	} else {
 		reg &= ~(MASTER_VID_FUNC_EN_N | SLAVE_VID_FUNC_EN_N);
include/drm/bridge/analogix_dp.h +9 -2
index 854af692229b..7b670dd769e9 100644
@@ -19,9 +19,16 @@ enum analogix_dp_devtype {
 	RK3588_EDP,
 };
 
-static inline bool is_rockchip(enum analogix_dp_devtype type)
+static inline bool analogix_dp_is_rockchip(enum analogix_dp_devtype type)
 {
-	return type == RK3288_DP || type == RK3399_EDP || type == RK3588_EDP;
+	switch (type) {
+	case RK3288_DP:
+	case RK3399_EDP:
+	case RK3588_EDP:
+		return true;
+	default:
+		return false;
+	}
 }
 
 struct analogix_dp_plat_data {
Signature · 1 line
2.34.1
author
#13 lore raw

PATCH v10 10/11 drm/bridge: analogix_dp: Add support for RK3576

In reply to Damon Ding

Add RK3576_EDP device type entry and extend Rockchip check to match existing hardware capabilities shared with RK3588.

Set identical maximum link rate and lane count parameters for RK3576 eDP controller to reuse existing RK3588 config.

---

Changes in v3:
- Add Reviewed-by tag.

Changes in v4:
- Modify the commit msg.

---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
 include/drm/bridge/analogix_dp.h                   | 2 ++
 2 files changed, 3 insertions(+)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1 -0
index 116de3bd83a3..c8eb3511f92a 100644
@@ -1249,6 +1249,7 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)
 		video_info->max_link_rate = 0x0A;
 		video_info->max_lane_count = 0x04;
 		break;
+	case RK3576_EDP:
 	case RK3588_EDP:
 		video_info->max_link_rate = 0x14;
 		video_info->max_lane_count = 0x04;
include/drm/bridge/analogix_dp.h +2 -0
index 7b670dd769e9..0e0b87abee59 100644
@@ -16,6 +16,7 @@ enum analogix_dp_devtype {
 	EXYNOS_DP,
 	RK3288_DP,
 	RK3399_EDP,
+	RK3576_EDP,
 	RK3588_EDP,
 };
 
@@ -24,6 +25,7 @@ static inline bool analogix_dp_is_rockchip(enum analogix_dp_devtype type)
 	switch (type) {
 	case RK3288_DP:
 	case RK3399_EDP:
+	case RK3576_EDP:
 	case RK3588_EDP:
 		return true;
 	default:
Signature · 1 line
2.34.1
author
#14 lore raw

PATCH v10 11/11 drm/rockchip: analogix_dp: Add support for RK3576

In reply to Damon Ding

RK3576 integrates Analogix eDP 1.3 TX and Samsung combo PHY hardware blocks that fully match the proven RK3588 design.

Add dedicated chip data table and device tree matching entry to bring up basic eDP functionality for the RK3576 platform.

Support is limited to RGB output up to 4K@60Hz for now; audio, PSR and other advanced eDP 1.3 features remain unvalidated.

---

Changes in v2:
- Split out a separate patch to enable the "hclk" clock.
- Add Reviewed-by tag.

Changes in v3:
- Add Reviewed-by tag.

Changes in v4:
- Modify the commit msg.

---
 drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +9 -0
index b1ed25cefe5e..776954c7d052 100644
@@ -526,6 +526,14 @@ static const struct rockchip_dp_chip_data rk3288_dp[] = {
 	{ /* sentinel */ }
 };
 
+static const struct rockchip_dp_chip_data rk3576_edp[] = {
+	{
+		.chip_type = RK3576_EDP,
+		.reg = 0x27dc0000,
+	},
+	{ /* sentinel */ }
+};
+
 static const struct rockchip_dp_chip_data rk3588_edp[] = {
 	{
 		.edp_mode = GRF_REG_FIELD(0x0000, 0, 0),
@@ -543,6 +551,7 @@ static const struct rockchip_dp_chip_data rk3588_edp[] = {
 static const struct of_device_id rockchip_dp_dt_ids[] = {
 	{.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
 	{.compatible = "rockchip,rk3399-edp", .data = &rk3399_edp },
+	{.compatible = "rockchip,rk3576-edp", .data = &rk3576_edp },
 	{.compatible = "rockchip,rk3588-edp", .data = &rk3588_edp },
 	{}
 };
Signature · 1 line
2.34.1
#15 lore raw

Re: [PATCH v10 11/11] drm/rockchip: analogix_dp: Add support for RK3576

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Ignoring the return value of dp->plat_data->power_on() in analogix_dp_resume() leads to a bus hang and kernel panic if power-on fails. --

commit 16c45b0fec5cc5f41b6c562365dd00c24ea63ad5
Author: Damon Ding <[email protected]>

drm/rockchip: analogix_dp: Add support for RK3576

RK3576 integrates Analogix eDP 1.3 TX and Samsung combo PHY hardware blocks that fully match the proven RK3588 design. Add dedicated chip data table and device tree matching entry to bring up basic eDP functionality for the RK3576 platform.

Quoted 4 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +0 -0
index b1ed25cefe5ed..776954c7d0525 100644

[ ... ]

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c static const struct rockchip_dp_chip_data rk3588_edp[] = { · line 554

Quoted 5 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +1 -0
@@ -543,6 +551,7 @@ static const struct rockchip_dp_chip_data rk3588_edp[] = {
 static const struct of_device_id rockchip_dp_dt_ids[] = {
 	{.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
 	{.compatible = "rockchip,rk3399-edp", .data = &rk3399_edp },
+	{.compatible = "rockchip,rk3576-edp", .data = &rk3576_edp },

[Severity: High]
This is a pre-existing issue, but adding a new platform here raises a question about how power-on failures are handled.

Does this platform risk a bus hang and kernel panic if power-on fails during resume?

If rockchip_dp_poweron() fails (e.g., if rockchip_dp_pre_init() fails), it disables dp->pclk:

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c:rockchip_dp_poweron() {
    ...
	ret = rockchip_dp_pre_init(dp);
	if (ret < 0) {
		DRM_DEV_ERROR(dp->dev, "failed to dp pre init %d\n", ret);
		clk_disable_unprepare(dp->pclk);
		return ret;
	}
    ...
}

However, the core driver ignores the return value of power_on() and continues to access memory-mapped registers via analogix_dp_init_dp():

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c:analogix_dp_resume() {
    ...
	if (dp->plat_data->power_on)
		dp->plat_data->power_on(dp->plat_data);

	phy_set_mode(dp->phy, PHY_MODE_DP);
	phy_power_on(dp->phy);

	analogix_dp_init_dp(dp);
    ...
}

Since attempting to read or write memory-mapped I/O registers when the APB bus clock (pclk) is disabled causes a synchronous external abort on ARM platforms, could this cause a kernel panic if power-on fails?

Quoted 3 lines
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +0 -0
 	{.compatible = "rockchip,rk3588-edp", .data = &rk3588_edp },
 	{}
 };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
maintainer Applied
#16 lore raw

Re: (subset) [PATCH v10 00/11] Add eDP support for RK3576

In reply to Damon Ding
Quoted 21 lines · Damon Ding

Patch 1-5 are to add missing clock "hclk" for RK3588 eDP nodes. Patch 6 is to use automatic cleanup to fix OF node reference leak
reported by Sashiko.
Patch 7-8 are to add the RK3576 eDP node.
Patch 9-11 are to support the RK3576 Analogix DP controller.

Damon Ding (11):
dt-bindings: display: rockchip: analogix-dp: Fix hclk as third clock

    for RK3588

dt-bindings: display: rockchip: analogix-dp: Add per-clock
descriptions
arm64: dts: rockchip: Add missing hclk for RK3588 eDP0
arm64: dts: rockchip: Add missing hclk for RK3588 eDP1 drm/rockchip: analogix_dp: Enable hclk for RK3588 drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup
dt-bindings: display: rockchip: analogix-dp: Add support for RK3576
arm64: dts: rockchip: Add eDP node for RK3576
drm/bridge: analogix_dp: Rename and simplify is_rockchip() drm/bridge: analogix_dp: Add support for RK3576 drm/rockchip: analogix_dp: Add support for RK3576

Quoted 1 line

[...]

Applied, thanks!

[01/11] dt-bindings: display: rockchip: analogix-dp: Fix hclk as third clock for RK3588

        commit: 826ab13cf73e7bd5b268085c9594850f6a7fc7fd
[02/11] dt-bindings: display: rockchip: analogix-dp: Add per-clock descriptions
        commit: 38f41d4e704c2a9bfc025bb17594d53be010a629
[05/11] drm/rockchip: analogix_dp: Enable hclk for RK3588
        commit: 104f20616d72825fdcf56cfdc5f89f4e96fd8dbe
[06/11] drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup
        commit: 87e060521371257ddbb77964b66e60d80afcc7b2

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>
maintainer Applied
#17 lore raw

Re: (subset) [PATCH v10 00/11] Add eDP support for RK3576

In reply to Damon Ding
Quoted 21 lines · Damon Ding

Patch 1-5 are to add missing clock "hclk" for RK3588 eDP nodes. Patch 6 is to use automatic cleanup to fix OF node reference leak
reported by Sashiko.
Patch 7-8 are to add the RK3576 eDP node.
Patch 9-11 are to support the RK3576 Analogix DP controller.

Damon Ding (11):
dt-bindings: display: rockchip: analogix-dp: Fix hclk as third clock

    for RK3588

dt-bindings: display: rockchip: analogix-dp: Add per-clock
descriptions
arm64: dts: rockchip: Add missing hclk for RK3588 eDP0
arm64: dts: rockchip: Add missing hclk for RK3588 eDP1 drm/rockchip: analogix_dp: Enable hclk for RK3588 drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup
dt-bindings: display: rockchip: analogix-dp: Add support for RK3576
arm64: dts: rockchip: Add eDP node for RK3576
drm/bridge: analogix_dp: Rename and simplify is_rockchip() drm/bridge: analogix_dp: Add support for RK3576 drm/rockchip: analogix_dp: Add support for RK3576

Quoted 1 line

[...]

Applied, thanks!

[07/11] dt-bindings: display: rockchip: analogix-dp: Add support for RK3576

        commit: 473e50b27b0020ade5fd97ca04d941e448c5659a
[09/11] drm/bridge: analogix_dp: Rename and simplify is_rockchip()
        commit: 709445fb6fc57aa96d48c8492e84ed4b2a9a4b5e
[10/11] drm/bridge: analogix_dp: Add support for RK3576
        commit: 5442cdc38470ecd6b51562d378b6ed852a4d9d45
[11/11] drm/rockchip: analogix_dp: Add support for RK3576
        commit: 7e60c4e19fd3d3f1203fbb1fdd9b2bb1a1201e65

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>
maintainer
#18 lore raw
In reply to Damon Ding

Am Montag, 1. Juni 2026, 08:50:49 Mitteleuropäische Sommerzeit schrieb Damon Ding:

Quoted 5 lines

Patch 1-5 are to add missing clock "hclk" for RK3588 eDP nodes. Patch 6 is to use automatic cleanup to fix OF node reference leak
reported by Sashiko.
Patch 7-8 are to add the RK3576 eDP node.
Patch 9-11 are to support the RK3576 Analogix DP controller.

Not sure what happened, but I don't see an applied mail about the DTS patches (3+4+8) in my own mail archive, nor on lore.

Nevertheless I did apply them to my dts64 branch [0] on july the 24th as [03/11] ede2ee37f0a445cacbf24760f53befa10f64994a
[04/11] 09820811c549ee2c408defe36b210b13c7a85fcf
[08/11] a41687b89005f50909e59130a4c0b08e82996739

Heiko

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git/log/?h=v7.3-armsoc/dts64