* [PATCH v7 1/5] dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint
2026-08-19 7:52 [PATCH v7 0/5] Add eDP lane mapping support Damon Ding
@ 2026-08-19 7:52 ` Damon Ding
2026-08-19 12:54 ` Luca Ceresoli
2026-08-19 7:52 ` [PATCH v7 2/5] drm/dp: Add helper to validate DP lane counts Damon Ding
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Damon Ding @ 2026-08-19 7:52 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan
Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
Dmitry Baryshkov, Marek Szyprowski, Sebastian Reichel, dri-devel,
devicetree, linux-kernel, linux-rockchip, linux-arm-kernel,
Damon Ding, Conor Dooley
Add data-lanes property support to the port@1 endpoint for physical
lane mapping configuration.
Lane mapping is mainly used for below scenarios:
1. Correct PCB lane swap and differential line routing crossover
without hardware changes;
2. Adapt mismatched lane pin definitions between SoC and eDP panel;
3. Support multiple panel hardware variants on the same board
by configuring data-lanes in device tree only.
Additionally, add data-lanes setting in Rockchip eDP DT node example
to show actual lane mapping usage.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
---
Changes in v2:
- Add lane mapping application scenarios in commit message.
- Remove redundant deprecated property 'data-lanes' for eDP node.
- Update port@1 $ref to /schemas/graph.yaml#/$defs/port-base.
Changes in v3:
- Squash data-lanes adjustment of Rockchip eDP DT example into this
commit.
- Add unevaluatedProperties: false to both the port@1 and endpoint
nodes.
Changes in v5
- Add Acked-by and Reviewed-by tags.
---
.../bindings/display/bridge/analogix,dp.yaml | 19 ++++++++++++++-----
.../rockchip/rockchip,analogix-dp.yaml | 1 +
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/display/bridge/analogix,dp.yaml b/Documentation/devicetree/bindings/display/bridge/analogix,dp.yaml
index 62f0521b0924..ecf206871cdd 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,dp.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,dp.yaml
@@ -42,13 +42,22 @@ properties:
properties:
port@0:
$ref: /schemas/graph.yaml#/properties/port
- description:
- Input node to receive pixel data.
+ description: Input node to receive pixel data.
port@1:
- $ref: /schemas/graph.yaml#/properties/port
- description:
- Port node with one endpoint connected to a dp-connector node.
+ $ref: /schemas/graph.yaml#/$defs/port-base
+ unevaluatedProperties: false
+ description: Port node with one endpoint connected to sink device node.
+ properties:
+ endpoint:
+ $ref: /schemas/media/video-interfaces.yaml#
+ unevaluatedProperties: false
+ properties:
+ data-lanes:
+ minItems: 1
+ maxItems: 4
+ items:
+ enum: [ 0, 1, 2, 3 ]
required:
- port@0
diff --git a/Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml b/Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml
index 6548f157fd96..39dafe75a680 100644
--- a/Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml
+++ b/Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml
@@ -160,6 +160,7 @@ examples:
reg = <1>;
edp_out_panel: endpoint {
+ data-lanes = <0 1>;
remote-endpoint = <&panel_in_edp>;
};
};
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH v7 1/5] dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint
2026-08-19 7:52 ` [PATCH v7 1/5] dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint Damon Ding
@ 2026-08-19 12:54 ` Luca Ceresoli
0 siblings, 0 replies; 12+ messages in thread
From: Luca Ceresoli @ 2026-08-19 12:54 UTC (permalink / raw)
To: Damon Ding
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Luca Ceresoli, Dmitry Baryshkov, Marek Szyprowski,
Sebastian Reichel, dri-devel, devicetree, linux-kernel,
linux-rockchip, linux-arm-kernel, Conor Dooley
On Wed, 19 Aug 2026 15:52:34 +0800, Damon Ding <damon.ding@rock-chips.com> wrote:
> Add data-lanes property support to the port@1 endpoint for physical
> lane mapping configuration.
>
> Lane mapping is mainly used for below scenarios:
> 1. Correct PCB lane swap and differential line routing crossover
> without hardware changes;
> 2. Adapt mismatched lane pin definitions between SoC and eDP panel;
> 3. Support multiple panel hardware variants on the same board
> by configuring data-lanes in device tree only.
>
> [...]
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v7 2/5] drm/dp: Add helper to validate DP lane counts
2026-08-19 7:52 [PATCH v7 0/5] Add eDP lane mapping support Damon Ding
2026-08-19 7:52 ` [PATCH v7 1/5] dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint Damon Ding
@ 2026-08-19 7:52 ` Damon Ding
2026-08-19 7:52 ` [PATCH v7 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties Damon Ding
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Damon Ding @ 2026-08-19 7:52 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan
Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
Dmitry Baryshkov, Marek Szyprowski, Sebastian Reichel, dri-devel,
devicetree, linux-kernel, linux-rockchip, linux-arm-kernel,
Damon Ding
Add a generic helper function drm_dp_lane_count_is_valid() to check
if a DisplayPort lane count is valid. According to the DP specification,
only 1, 2, or 4 lanes are supported.
This helper avoids duplicating DP lane count validation logic across
individual DisplayPort drivers.
Suggested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
---
Changes in v6:
- Add Reviewed-by tag.
---
include/drm/display/drm_dp_helper.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
index ab16c1be3900..5b05a7fbe174 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -139,6 +139,12 @@ bool drm_dp_as_sdp_supported(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_C
int drm_dp_psr_setup_time(const u8 psr_cap[EDP_PSR_RECEIVER_CAP_SIZE]);
+static inline bool
+drm_dp_lane_count_is_valid(int lane_count)
+{
+ return lane_count == 1 || lane_count == 2 || lane_count == 4;
+}
+
static inline int
drm_dp_max_link_rate(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
{
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v7 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
2026-08-19 7:52 [PATCH v7 0/5] Add eDP lane mapping support Damon Ding
2026-08-19 7:52 ` [PATCH v7 1/5] dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint Damon Ding
2026-08-19 7:52 ` [PATCH v7 2/5] drm/dp: Add helper to validate DP lane counts Damon Ding
@ 2026-08-19 7:52 ` Damon Ding
2026-08-19 12:54 ` Luca Ceresoli
2026-08-19 7:52 ` [PATCH v7 4/5] drm/bridge: analogix_dp: Add validation for samsung,lane-count property Damon Ding
2026-08-19 7:52 ` [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
4 siblings, 1 reply; 12+ messages in thread
From: Damon Ding @ 2026-08-19 7:52 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan
Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
Dmitry Baryshkov, Marek Szyprowski, Sebastian Reichel, dri-devel,
devicetree, linux-kernel, linux-rockchip, linux-arm-kernel,
Damon Ding
Revert the change that made samsung,link-rate and samsung,lane-count
optional for Exynos DP. Add error checking to fail probe early if the
required DT properties are missing.
If these properties are zero, &link_train.link_rate and
&link_train.lane_count used in the subsequent link training flow will
also be zero, resulting in link training failure. Although all existing
Exynos DP DT nodes already contain these two properties, this potential
logic issue still needs to be fixed.
Fixes: 0d0abd894ead ("drm: bridge: analogix/dp: add max link rate and lane count limit for RK3288")
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
---
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 566f1e5eb8cd..ddb15d6de05f 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1248,6 +1248,7 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)
{
struct device_node *dp_node = dp->dev->of_node;
struct video_info *video_info = &dp->video_info;
+ u32 val;
switch (dp->plat_data->dev_type) {
case RK3288_DP:
@@ -1269,10 +1270,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)
* NOTE: those property parseing code is used for
* providing backward compatibility for samsung platform.
*/
- of_property_read_u32(dp_node, "samsung,link-rate",
- &video_info->max_link_rate);
- of_property_read_u32(dp_node, "samsung,lane-count",
- &video_info->max_lane_count);
+ if (of_property_read_u32(dp_node, "samsung,link-rate", &val))
+ return dev_err_probe(dp->dev, -EINVAL,
+ "Failed to get samsung,link-rate\n");
+ video_info->max_link_rate = val;
+ if (of_property_read_u32(dp_node, "samsung,lane-count", &val))
+ return dev_err_probe(dp->dev, -EINVAL,
+ "Failed to get samsung,lane-count\n");
+ video_info->max_lane_count = val;
break;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH v7 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
2026-08-19 7:52 ` [PATCH v7 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties Damon Ding
@ 2026-08-19 12:54 ` Luca Ceresoli
0 siblings, 0 replies; 12+ messages in thread
From: Luca Ceresoli @ 2026-08-19 12:54 UTC (permalink / raw)
To: Damon Ding
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Luca Ceresoli, Dmitry Baryshkov, Marek Szyprowski,
Sebastian Reichel, dri-devel, devicetree, linux-kernel,
linux-rockchip, linux-arm-kernel
> Revert the change that made samsung,link-rate and samsung,lane-count
> optional for Exynos DP. Add error checking to fail probe early if the
> required DT properties are missing.
>
> If these properties are zero, &link_train.link_rate and
> &link_train.lane_count used in the subsequent link training flow will
> also be zero, resulting in link training failure. Although all existing
> Exynos DP DT nodes already contain these two properties, this potential
> logic issue still needs to be fixed.
>
> Fixes: 0d0abd894ead ("drm: bridge: analogix/dp: add max link rate and lane count limit for RK3288")
If it's a fix, please add 'Cc: stable' too.
Also please add to the commit message the detailed analysis you wrote in
the v6 discussion, so that it will easy to find in the git history, in case
it's needed in the future.
With that added you can add: Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v7 4/5] drm/bridge: analogix_dp: Add validation for samsung,lane-count property
2026-08-19 7:52 [PATCH v7 0/5] Add eDP lane mapping support Damon Ding
` (2 preceding siblings ...)
2026-08-19 7:52 ` [PATCH v7 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties Damon Ding
@ 2026-08-19 7:52 ` Damon Ding
2026-08-19 7:52 ` [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
4 siblings, 0 replies; 12+ messages in thread
From: Damon Ding @ 2026-08-19 7:52 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan
Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
Dmitry Baryshkov, Marek Szyprowski, Sebastian Reichel, dri-devel,
devicetree, linux-kernel, linux-rockchip, linux-arm-kernel,
Damon Ding
Add validity check for samsung,lane-count to ensure DT-provided
lane count values are specification-compliant.
Suggested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
---
Changes in v5:
- Apply DRM DP helper API to check the validity of DP lane count.
Changes in v6:
- Rebase after the new commit for restoring mandatory properties
samsung,link-rate and samsung,lane-count.
Changes in v7:
- Add Reviewed-by tag.
---
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index ddb15d6de05f..a74c855936b2 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1274,7 +1274,8 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)
return dev_err_probe(dp->dev, -EINVAL,
"Failed to get samsung,link-rate\n");
video_info->max_link_rate = val;
- if (of_property_read_u32(dp_node, "samsung,lane-count", &val))
+ if (of_property_read_u32(dp_node, "samsung,lane-count", &val) ||
+ !drm_dp_lane_count_is_valid(val))
return dev_err_probe(dp->dev, -EINVAL,
"Failed to get samsung,lane-count\n");
video_info->max_lane_count = val;
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
2026-08-19 7:52 [PATCH v7 0/5] Add eDP lane mapping support Damon Ding
` (3 preceding siblings ...)
2026-08-19 7:52 ` [PATCH v7 4/5] drm/bridge: analogix_dp: Add validation for samsung,lane-count property Damon Ding
@ 2026-08-19 7:52 ` Damon Ding
2026-08-19 8:04 ` sashiko-bot
2026-08-19 12:54 ` Luca Ceresoli
4 siblings, 2 replies; 12+ messages in thread
From: Damon Ding @ 2026-08-19 7:52 UTC (permalink / raw)
To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan
Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
Dmitry Baryshkov, Marek Szyprowski, Sebastian Reichel, dri-devel,
devicetree, linux-kernel, linux-rockchip, linux-arm-kernel,
Damon Ding
Parse the optional 'data-lanes' device tree property to support
custom physical lane mapping configuration.
If no valid configuration is found, fall back to the default
lane map (0, 1, 2, 3) automatically and keep the driver running.
Lane mapping is mainly used for below scenarios:
1. Correct PCB lane swap and differential line routing crossover
without hardware changes;
2. Adapt mismatched lane pin definitions between SoC and eDP panel;
3. Support multiple panel hardware variants on the same board
by configuring data-lanes in device tree only.
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
---
Changes in v2:
- Add lane mapping application scenarios in commit message.
Changes in v5:
- Add Reviewed-by tag.
---
.../drm/bridge/analogix/analogix_dp_core.c | 56 +++++++++++++++++++
.../drm/bridge/analogix/analogix_dp_core.h | 4 +-
.../gpu/drm/bridge/analogix/analogix_dp_reg.c | 15 +++--
.../gpu/drm/bridge/analogix/analogix_dp_reg.h | 4 ++
4 files changed, 70 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index a74c855936b2..39cb76a1913f 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1244,6 +1244,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
.detect = analogix_dp_bridge_detect,
};
+static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
+{
+ struct video_info *video_info = &dp->video_info;
+ struct device_node *endpoint;
+ u32 tmp[LANE_COUNT4];
+ u32 map[LANE_COUNT4] = {0, 1, 2, 3};
+ bool used[LANE_COUNT4] = {false};
+ int num_lanes;
+ int ret, i;
+
+ memcpy(video_info->lane_map, map, sizeof(map));
+
+ num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
+ video_info->max_lane_count);
+ if (num_lanes < 0)
+ return -EINVAL;
+
+ endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
+ if (!endpoint)
+ return -EINVAL;
+
+ ret = of_property_read_u32_array(endpoint, "data-lanes", tmp, num_lanes);
+ of_node_put(endpoint);
+ if (ret)
+ return -EINVAL;
+
+ for (i = 0; i < num_lanes; i++) {
+ if (tmp[i] >= LANE_COUNT4) {
+ dev_dbg(dp->dev, "data-lanes[%d] = %u is out of range\n", i, tmp[i]);
+ return -EINVAL;
+ }
+
+ if (used[tmp[i]]) {
+ dev_dbg(dp->dev, "data-lanes[%d] = %u is duplicate\n", i, tmp[i]);
+ return -EINVAL;
+ }
+
+ used[tmp[i]] = true;
+ map[i] = tmp[i];
+ }
+
+ for (i = 0; i < LANE_COUNT4 && num_lanes < LANE_COUNT4; i++) {
+ if (!used[i])
+ map[num_lanes++] = i;
+ }
+
+ dev_dbg(dp->dev, "Using parsed lane map: <%u %u %u %u>\n", map[0], map[1], map[2], map[3]);
+
+ memcpy(video_info->lane_map, map, sizeof(map));
+
+ return 0;
+}
+
static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)
{
struct device_node *dp_node = dp->dev->of_node;
@@ -1282,6 +1335,9 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)
break;
}
+ if (analogix_dp_dt_parse_lanes_map(dp))
+ dev_dbg(dp->dev, "No valid data-lanes found, using default lane map\n");
+
return 0;
}
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index c7997677a286..4560597604ad 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -137,6 +137,8 @@ struct video_info {
int max_link_rate;
enum link_lane_count_type max_lane_count;
+
+ u32 lane_map[LANE_COUNT4];
};
struct link_train {
@@ -177,7 +179,7 @@ struct analogix_dp_device {
/* analogix_dp_reg.c */
void analogix_dp_enable_video_mute(struct analogix_dp_device *dp, bool enable);
void analogix_dp_stop_video(struct analogix_dp_device *dp);
-void analogix_dp_lane_swap(struct analogix_dp_device *dp, bool enable);
+void analogix_dp_lane_mapping(struct analogix_dp_device *dp);
void analogix_dp_init_analog_param(struct analogix_dp_device *dp);
void analogix_dp_init_interrupt(struct analogix_dp_device *dp);
void analogix_dp_reset(struct analogix_dp_device *dp);
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
index ea8401293a23..c1344a3f013a 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -48,16 +48,15 @@ void analogix_dp_stop_video(struct analogix_dp_device *dp)
writel(reg, dp->reg_base + ANALOGIX_DP_VIDEO_CTL_1);
}
-void analogix_dp_lane_swap(struct analogix_dp_device *dp, bool enable)
+void analogix_dp_lane_mapping(struct analogix_dp_device *dp)
{
+ u32 *lane_map = dp->video_info.lane_map;
u32 reg;
- if (enable)
- reg = LANE3_MAP_LOGIC_LANE_0 | LANE2_MAP_LOGIC_LANE_1 |
- LANE1_MAP_LOGIC_LANE_2 | LANE0_MAP_LOGIC_LANE_3;
- else
- reg = LANE3_MAP_LOGIC_LANE_3 | LANE2_MAP_LOGIC_LANE_2 |
- LANE1_MAP_LOGIC_LANE_1 | LANE0_MAP_LOGIC_LANE_0;
+ reg = lane_map[0] << LANE0_MAP_SHIFT;
+ reg |= lane_map[1] << LANE1_MAP_SHIFT;
+ reg |= lane_map[2] << LANE2_MAP_SHIFT;
+ reg |= lane_map[3] << LANE3_MAP_SHIFT;
writel(reg, dp->reg_base + ANALOGIX_DP_LANE_MAP);
}
@@ -140,7 +139,7 @@ void analogix_dp_reset(struct analogix_dp_device *dp)
usleep_range(20, 30);
- analogix_dp_lane_swap(dp, 0);
+ analogix_dp_lane_mapping(dp);
writel(0x0, dp->reg_base + ANALOGIX_DP_SYS_CTL_1);
writel(0x40, dp->reg_base + ANALOGIX_DP_SYS_CTL_2);
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h
index 12735139046c..ac914e37089b 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h
@@ -209,6 +209,10 @@
#define LANE0_MAP_LOGIC_LANE_1 (0x1 << 0)
#define LANE0_MAP_LOGIC_LANE_2 (0x2 << 0)
#define LANE0_MAP_LOGIC_LANE_3 (0x3 << 0)
+#define LANE3_MAP_SHIFT (6)
+#define LANE2_MAP_SHIFT (4)
+#define LANE1_MAP_SHIFT (2)
+#define LANE0_MAP_SHIFT (0)
/* ANALOGIX_DP_ANALOG_CTL_1 */
#define TX_TERMINAL_CTRL_50_OHM (0x1 << 4)
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
2026-08-19 7:52 ` [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
@ 2026-08-19 8:04 ` sashiko-bot
2026-08-19 8:53 ` Damon Ding
2026-08-19 12:54 ` Luca Ceresoli
1 sibling, 1 reply; 12+ messages in thread
From: sashiko-bot @ 2026-08-19 8:04 UTC (permalink / raw)
To: Damon Ding; +Cc: robh, conor+dt, devicetree, dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Logic error in hardware lane mapping configuration causes inverted assignments for non-symmetric maps.
- [Low] Device Tree endpoint lookup inconsistency when querying lane counts versus reading properties.
--
--- Patch [5]: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping ---
commit 1c15eb6132eedc3d606168644e5f97918c8e3651
Author: Damon Ding <damon.ding@rock-chips.com>
drm/bridge: analogix_dp: Add support for optional data-lanes mapping
Parse the optional 'data-lanes' device tree property to support
custom physical lane mapping configuration. If no valid configuration
is found, fall back to the default lane map automatically.
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 039e076d2b8ab..cb06347196cef 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
[ ... ]
> @@ -1240,6 +1240,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
> .detect = analogix_dp_bridge_detect,
> };
>
> +static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
> +{
[ ... ]
> + num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
> + video_info->max_lane_count);
> + if (num_lanes < 0)
> + return -EINVAL;
> +
> + endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
[Severity: Low]
Does passing -1 here potentially retrieve a different endpoint from the one
validated with reg=0 above?
If multiple endpoints exist on the DP port and the target endpoint is not
positionally first, could this mismatch result in reading the data-lanes
property from the wrong endpoint?
> + if (!endpoint)
> + return -EINVAL;
> +
> + ret = of_property_read_u32_array(endpoint, "data-lanes", tmp, num_lanes);
> + of_node_put(endpoint);
[ ... ]
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
> index ea8401293a23a..c1344a3f013ab 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
[ ... ]
> @@ -48,16 +48,15 @@ void analogix_dp_stop_video(struct analogix_dp_device *dp)
> writel(reg, dp->reg_base + ANALOGIX_DP_VIDEO_CTL_1);
> }
>
> -void analogix_dp_lane_swap(struct analogix_dp_device *dp, bool enable)
> +void analogix_dp_lane_mapping(struct analogix_dp_device *dp)
> {
> + u32 *lane_map = dp->video_info.lane_map;
> u32 reg;
>
> - if (enable)
> - reg = LANE3_MAP_LOGIC_LANE_0 | LANE2_MAP_LOGIC_LANE_1 |
> - LANE1_MAP_LOGIC_LANE_2 | LANE0_MAP_LOGIC_LANE_3;
> - else
> - reg = LANE3_MAP_LOGIC_LANE_3 | LANE2_MAP_LOGIC_LANE_2 |
> - LANE1_MAP_LOGIC_LANE_1 | LANE0_MAP_LOGIC_LANE_0;
> + reg = lane_map[0] << LANE0_MAP_SHIFT;
> + reg |= lane_map[1] << LANE1_MAP_SHIFT;
> + reg |= lane_map[2] << LANE2_MAP_SHIFT;
> + reg |= lane_map[3] << LANE3_MAP_SHIFT;
[Severity: High]
Does this logic incorrectly assign the physical lane value to the logical
lane's field?
By shifting the physical lane index (lane_map[i]) into the register field
assigned to the logical lane index (LANE<i>_MAP_SHIFT), it appears this
inherently applies the inverse of the requested mapping.
While this silently succeeds for symmetric maps (e.g., swapping 0<->3, 1<->2),
will it fail for any non-symmetric map (e.g., <1 2 3 0>) by causing physical
lanes to carry the wrong logical lanes?
Should the bitwise construction instead be reg |= i << (lane_map[i] * 2)?
>
> writel(reg, dp->reg_base + ANALOGIX_DP_LANE_MAP);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819075238.3007087-1-damon.ding@rock-chips.com?part=5
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
2026-08-19 8:04 ` sashiko-bot
@ 2026-08-19 8:53 ` Damon Ding
2026-08-19 12:58 ` Luca Ceresoli
0 siblings, 1 reply; 12+ messages in thread
From: Damon Ding @ 2026-08-19 8:53 UTC (permalink / raw)
To: sashiko-reviews; +Cc: robh, conor+dt, devicetree, dri-devel, Luca Ceresoli
On 8/19/2026 4:04 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] Logic error in hardware lane mapping configuration causes inverted assignments for non-symmetric maps.
> - [Low] Device Tree endpoint lookup inconsistency when querying lane counts versus reading properties.
> --
>
> --- Patch [5]: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping ---
> commit 1c15eb6132eedc3d606168644e5f97918c8e3651
> Author: Damon Ding <damon.ding@rock-chips.com>
>
> drm/bridge: analogix_dp: Add support for optional data-lanes mapping
>
> Parse the optional 'data-lanes' device tree property to support
> custom physical lane mapping configuration. If no valid configuration
> is found, fall back to the default lane map automatically.
>
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> index 039e076d2b8ab..cb06347196cef 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> [ ... ]
>> @@ -1240,6 +1240,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
>> .detect = analogix_dp_bridge_detect,
>> };
>>
>> +static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
>> +{
> [ ... ]
>> + num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
>> + video_info->max_lane_count);
>> + if (num_lanes < 0)
>> + return -EINVAL;
>> +
>> + endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
>
Hi Luca,
Thanks for taking a look at previous v6 patch series. This Sashiko
warning was also present in v6. Sorry for CC'ing you out‑of‑the‑blue
without prior heads‑up.
> [Severity: Low]
> Does passing -1 here potentially retrieve a different endpoint from the one
> validated with reg=0 above?
>
> If multiple endpoints exist on the DP port and the target endpoint is not
> positionally first, could this mismatch result in reading the data-lanes
> property from the wrong endpoint?
>
For Analogix DP, port@1 will only ever have a single endpoint.
Multi‑output configurations are not supported by the hardware, so
passing -1 cannot select a mismatched endpoint. There is no risk of
retrieving the 'data‑lanes' property from an unintended endpoint.
>> + if (!endpoint)
>> + return -EINVAL;
>> +
>> + ret = of_property_read_u32_array(endpoint, "data-lanes", tmp, num_lanes);
>> + of_node_put(endpoint);
> [ ... ]
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
>> index ea8401293a23a..c1344a3f013ab 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
> [ ... ]
>> @@ -48,16 +48,15 @@ void analogix_dp_stop_video(struct analogix_dp_device *dp)
>> writel(reg, dp->reg_base + ANALOGIX_DP_VIDEO_CTL_1);
>> }
>>
>> -void analogix_dp_lane_swap(struct analogix_dp_device *dp, bool enable)
>> +void analogix_dp_lane_mapping(struct analogix_dp_device *dp)
>> {
>> + u32 *lane_map = dp->video_info.lane_map;
>> u32 reg;
>>
>> - if (enable)
>> - reg = LANE3_MAP_LOGIC_LANE_0 | LANE2_MAP_LOGIC_LANE_1 |
>> - LANE1_MAP_LOGIC_LANE_2 | LANE0_MAP_LOGIC_LANE_3;
>> - else
>> - reg = LANE3_MAP_LOGIC_LANE_3 | LANE2_MAP_LOGIC_LANE_2 |
>> - LANE1_MAP_LOGIC_LANE_1 | LANE0_MAP_LOGIC_LANE_0;
>> + reg = lane_map[0] << LANE0_MAP_SHIFT;
>> + reg |= lane_map[1] << LANE1_MAP_SHIFT;
>> + reg |= lane_map[2] << LANE2_MAP_SHIFT;
>> + reg |= lane_map[3] << LANE3_MAP_SHIFT;
>
> [Severity: High]
> Does this logic incorrectly assign the physical lane value to the logical
> lane's field?
>
> By shifting the physical lane index (lane_map[i]) into the register field
> assigned to the logical lane index (LANE<i>_MAP_SHIFT), it appears this
> inherently applies the inverse of the requested mapping.
>
> While this silently succeeds for symmetric maps (e.g., swapping 0<->3, 1<->2),
> will it fail for any non-symmetric map (e.g., <1 2 3 0>) by causing physical
> lanes to carry the wrong logical lanes?
>
> Should the bitwise construction instead be reg |= i << (lane_map[i] * 2)?
>
>>
>> writel(reg, dp->reg_base + ANALOGIX_DP_LANE_MAP);
>> }
>
lane_map[] uses index as physical lane, value as logical lane.
This matches training_lane[] / cr_loop[] in struct link_train, whose
indexes are physical lanes for DPCD access during link training.
LANE<i>_MAP_SHIFT configures which logical lane is routed onto physical
lane i, so current register logic is correct.
Best regards,
Damon
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
2026-08-19 8:53 ` Damon Ding
@ 2026-08-19 12:58 ` Luca Ceresoli
0 siblings, 0 replies; 12+ messages in thread
From: Luca Ceresoli @ 2026-08-19 12:58 UTC (permalink / raw)
To: Damon Ding, sashiko-reviews
Cc: robh, conor+dt, devicetree, dri-devel, Luca Ceresoli
Hello,
On Wed Aug 19, 2026 at 10:53 AM CEST, Damon Ding wrote:
> On 8/19/2026 4:04 PM, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>> - [High] Logic error in hardware lane mapping configuration causes inverted assignments for non-symmetric maps.
>> - [Low] Device Tree endpoint lookup inconsistency when querying lane counts versus reading properties.
>> --
>>
>> --- Patch [5]: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping ---
>> commit 1c15eb6132eedc3d606168644e5f97918c8e3651
>> Author: Damon Ding <damon.ding@rock-chips.com>
>>
>> drm/bridge: analogix_dp: Add support for optional data-lanes mapping
>>
>> Parse the optional 'data-lanes' device tree property to support
>> custom physical lane mapping configuration. If no valid configuration
>> is found, fall back to the default lane map automatically.
>>
>>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>>> index 039e076d2b8ab..cb06347196cef 100644
>>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> [ ... ]
>>> @@ -1240,6 +1240,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
>>> .detect = analogix_dp_bridge_detect,
>>> };
>>>
>>> +static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
>>> +{
>> [ ... ]
>>> + num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
>>> + video_info->max_lane_count);
>>> + if (num_lanes < 0)
>>> + return -EINVAL;
>>> +
>>> + endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
>>
>
> Hi Luca,
>
> Thanks for taking a look at previous v6 patch series. This Sashiko
> warning was also present in v6. Sorry for CC'ing you out‑of‑the‑blue
> without prior heads‑up.
>
>> [Severity: Low]
>> Does passing -1 here potentially retrieve a different endpoint from the one
>> validated with reg=0 above?
>>
>> If multiple endpoints exist on the DP port and the target endpoint is not
>> positionally first, could this mismatch result in reading the data-lanes
>> property from the wrong endpoint?
>>
>
> For Analogix DP, port@1 will only ever have a single endpoint.
> Multi‑output configurations are not supported by the hardware, so
> passing -1 cannot select a mismatched endpoint. There is no risk of
> retrieving the 'data‑lanes' property from an unintended endpoint.
I understand (1, 0) and (1, -1) will always return the same node in the
real cases, but why doing it? Use the same indices both times and avoid
future readers scratch their head thinking why it's different and whether
they might report a different node in a future case. Also, if parsing a
broken device tree, you may point at two different nodes here. Keep things
simple, readable and reliable.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
2026-08-19 7:52 ` [PATCH v7 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping Damon Ding
2026-08-19 8:04 ` sashiko-bot
@ 2026-08-19 12:54 ` Luca Ceresoli
1 sibling, 0 replies; 12+ messages in thread
From: Luca Ceresoli @ 2026-08-19 12:54 UTC (permalink / raw)
To: Damon Ding
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sandy Huang,
Heiko Stuebner, Andy Yan, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Luca Ceresoli, Dmitry Baryshkov, Marek Szyprowski,
Sebastian Reichel, dri-devel, devicetree, linux-kernel,
linux-rockchip, linux-arm-kernel
Hello,
> Parse the optional 'data-lanes' device tree property to support
> custom physical lane mapping configuration.
>
> If no valid configuration is found, fall back to the default
> lane map (0, 1, 2, 3) automatically and keep the driver running.
>
> Lane mapping is mainly used for below scenarios:
> 1. Correct PCB lane swap and differential line routing crossover
> without hardware changes;
> 2. Adapt mismatched lane pin definitions between SoC and eDP panel;
> 3. Support multiple panel hardware variants on the same board
> by configuring data-lanes in device tree only.
>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 117448b854db..4aa444858bb6 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1240,6 +1240,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
> .detect = analogix_dp_bridge_detect,
> };
>
> +static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
> +{
> + struct video_info *video_info = &dp->video_info;
> + struct device_node *endpoint;
> + u32 tmp[LANE_COUNT4];
The 'tmp' name is not very useful to understand what it's for. Based on the
code I'd say it stores a lane index, so what about 'lane_idx', unless you
can propose a better name.
> + u32 map[LANE_COUNT4] = {0, 1, 2, 3};
> + bool used[LANE_COUNT4] = {false};
> + int num_lanes;
> + int ret, i;
> +
> + memcpy(video_info->lane_map, map, sizeof(map));
> +
> + num_lanes = drm_of_get_data_lanes_count_ep(dp->dev->of_node, 1, 0, 1,
> + video_info->max_lane_count);
> + if (num_lanes < 0)
> + return -EINVAL;
> +
> + endpoint = of_graph_get_endpoint_by_regs(dp->dev->of_node, 1, -1);
> + if (!endpoint)
> + return -EINVAL;
> +
> + ret = of_property_read_u32_array(endpoint, "data-lanes", tmp, num_lanes);
> + of_node_put(endpoint);
> + if (ret)
> + return -EINVAL;
> +
> + for (i = 0; i < num_lanes; i++) {
> + if (tmp[i] >= LANE_COUNT4) {
> + dev_dbg(dp->dev, "data-lanes[%d] = %u is out of range\n", i, tmp[i]);
> + return -EINVAL;
> + }
> +
> + if (used[tmp[i]]) {
> + dev_dbg(dp->dev, "data-lanes[%d] = %u is duplicate\n", i, tmp[i]);
> + return -EINVAL;
> + }
> +
> + used[tmp[i]] = true;
> + map[i] = tmp[i];
> + }
> +
> + for (i = 0; i < LANE_COUNT4 && num_lanes < LANE_COUNT4; i++) {
> + if (!used[i])
> + map[num_lanes++] = i;
> + }
This loop is a bit obscure to me. After reading it a few times I _think_ it
does the following:
/*
* Fill the unused map[] entries with the unused lane indices <reason?>. E.g.:
* used[] values = {0,1,0,1} // Only lanes 1 and 3 are used
* map[] before = {3,1,x,x} // x = unassigned
* map[] after = {3,1,0,2} // filled last 2 entries with the unused lane indices
*/
Is my understanding correct? If it is, please fill <reason?> and add the
above comment (possibly improved) before the loop.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 12+ messages in thread