Skip to contentSkip to conversation

drm/bridge: analogix_dp: use devm_phy_optional_get() for the DP PHY

PATCH Superseded Jun Yan 2 participants 4 messages Sep 24

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Jun Yan

author
#0 lore raw

PATCH 1/1 drm/bridge: analogix_dp: use devm_phy_optional_get() for the DP PHY

The DP PHY is optional: the Rockchip RK3399 eDP controller (used as the internal eDP port) has no separate PHY device and relies on its built-in PHY, which is programmed directly through the GRF registers, so its DT node carries no "phys"/"phy-names" property.

Requesting the PHY with devm_phy_get() therefore returns -ENODEV (or -ENOSYS when CONFIG_GENERIC_PHY is disabled) and the driver logs a misleading "no DP phy configured" error at probe time before falling back to a NULL phy.

Use devm_phy_optional_get() instead, which returns NULL when the PHY is absent and otherwise behaves identically, and drop the manual -ENODEV/ -ENOSYS handling. This also removes the spurious error message.

Assisted-by Claude:deepseek-v4-flash
---
 .../gpu/drm/bridge/analogix/analogix_dp_core.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3 -15
index 18e76d1e78e1..28eb668d3e3f 100644
@@ -1427,21 +1427,9 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
 	if (ret)
 		return ERR_PTR(ret);
 
-	dp->phy = devm_phy_get(dp->dev, "dp");
-	if (IS_ERR(dp->phy)) {
-		dev_err(dp->dev, "no DP phy configured\n");
-		ret = PTR_ERR(dp->phy);
-		if (ret) {
-			/*
-			 * phy itself is not enabled, so we can move forward
-			 * assigning NULL to phy pointer.
-			 */
-			if (ret == -ENOSYS || ret == -ENODEV)
-				dp->phy = NULL;
-			else
-				return ERR_PTR(ret);
-		}
-	}
+	dp->phy = devm_phy_optional_get(dp->dev, "dp");
+	if (IS_ERR(dp->phy))
+		return ERR_CAST(dp->phy);
 
 	dp->clock = devm_clk_get(&pdev->dev, "dp");
 	if (IS_ERR(dp->clock)) {
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Jun,

Quoted 33 lines · Jun Yan

The DP PHY is optional: the Rockchip RK3399 eDP controller (used as the internal eDP port) has no separate PHY device and relies on its built-in PHY, which is programmed directly through the GRF registers, so its DT node carries no "phys"/"phy-names" property.

Requesting the PHY with devm_phy_get() therefore returns -ENODEV (or -ENOSYS when CONFIG_GENERIC_PHY is disabled) and the driver logs a misleading "no DP phy configured" error at probe time before falling back to a NULL phy.

Use devm_phy_optional_get() instead, which returns NULL when the PHY is absent and otherwise behaves identically, and drop the manual -ENODEV/ -ENOSYS handling. This also removes the spurious error message.

Assisted-by Claude:deepseek-v4-flash
---
  .../gpu/drm/bridge/analogix/analogix_dp_core.c | 18 +++---------------
  1 file changed, 3 insertions(+), 15 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0 -5
index 18e76d1e78e1..28eb668d3e3f 100644
@@ -1427,21 +1427,9 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
  	if (ret)
  		return ERR_PTR(ret);
 
-	dp->phy = devm_phy_get(dp->dev, "dp");
-	if (IS_ERR(dp->phy)) {
-		dev_err(dp->dev, "no DP phy configured\n");
-		ret = PTR_ERR(dp->phy);
-		if (ret) {

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · line 1444

Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0 -10
-			/*
-			 * phy itself is not enabled, so we can move forward
-			 * assigning NULL to phy pointer.
-			 */
-			if (ret == -ENOSYS || ret == -ENODEV)
-				dp->phy = NULL;
-			else
-				return ERR_PTR(ret);
-		}
-	}

It should be better to add some comments here:

/*
* Exynos5/RK3288/RK3399 use Analogix DP controller built-in PHY,
* no separate PHY configuration is needed.
*/

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · line 1435

Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3 -0
+	dp->phy = devm_phy_optional_get(dp->dev, "dp");
+	if (IS_ERR(dp->phy))
+		return ERR_CAST(dp->phy);
 
  	dp->clock = devm_clk_get(&pdev->dev, "dp");
  	if (IS_ERR(dp->clock)) {

With the comment added:

Best regards,
Damon

#2 lore raw
Quoted 49 lines · Damon Ding

Hi Jun,

Quoted 33 lines · Jun Yan

The DP PHY is optional: the Rockchip RK3399 eDP controller (used as the internal eDP port) has no separate PHY device and relies on its built-in PHY, which is programmed directly through the GRF registers, so its DT node carries no "phys"/"phy-names" property.

Requesting the PHY with devm_phy_get() therefore returns -ENODEV (or -ENOSYS when CONFIG_GENERIC_PHY is disabled) and the driver logs a misleading "no DP phy configured" error at probe time before falling back to a NULL phy.

Use devm_phy_optional_get() instead, which returns NULL when the PHY is absent and otherwise behaves identically, and drop the manual -ENODEV/ -ENOSYS handling. This also removes the spurious error message.

Assisted-by Claude:deepseek-v4-flash

---
  .../gpu/drm/bridge/analogix/analogix_dp_core.c | 18 +++---------------

  1 file changed, 3 insertions(+), 15 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0 -5
index 18e76d1e78e1..28eb668d3e3f 100644
@@ -1427,21 +1427,9 @@ analogix_dp_probe(struct device *dev, struct 
 analogix_dp_plat_data *plat_data)
       if (ret)
           return ERR_PTR(ret);
-    dp->phy = devm_phy_get(dp->dev, "dp");
-    if (IS_ERR(dp->phy)) {
-        dev_err(dp->dev, "no DP phy configured\n");
-        ret = PTR_ERR(dp->phy);
-        if (ret) {

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct · line 1444

Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0 -10
-            /*
-             * phy itself is not enabled, so we can move forward
-             * assigning NULL to phy pointer.
-             */
-            if (ret == -ENOSYS || ret == -ENODEV)
-                dp->phy = NULL;
-            else
-                return ERR_PTR(ret);
-        }
-    }

It should be better to add some comments here:

Quoted 4 lines

/*
 * Exynos5/RK3288/RK3399 use Analogix DP controller built-in PHY,
 * no separate PHY configuration is needed.
 */

Well, I think it should be fixed to:

/*
* RK3288/RK3399 use Analogix DP controller built-in PHY,
* no extra PHY configuration is required.
*/

The Exynos5xxx case may be more complex.

Quoted 13 lines

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · line 1435

Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3 -0
+    dp->phy = devm_phy_optional_get(dp->dev, "dp");
+    if (IS_ERR(dp->phy))
+        return ERR_CAST(dp->phy);
       dp->clock = devm_clk_get(&pdev->dev, "dp");
       if (IS_ERR(dp->clock)) {

With the comment added:

Best regards,
Damon

author
#3 lore raw
Quoted 56 lines · Damon Ding
Quoted 50 lines

Hi Jun,

Quoted 34 lines · Jun Yan

The DP PHY is optional: the Rockchip RK3399 eDP controller (used as the internal eDP port) has no separate PHY device and relies on its built-in PHY, which is programmed directly through the GRF registers, so its DT node carries no "phys"/"phy-names" property.

Requesting the PHY with devm_phy_get() therefore returns -ENODEV (or -ENOSYS when CONFIG_GENERIC_PHY is disabled) and the driver logs a misleading "no DP phy configured" error at probe time before falling back to a NULL phy.

Use devm_phy_optional_get() instead, which returns NULL when the PHY is absent and otherwise behaves identically, and drop the manual -ENODEV/ -ENOSYS handling. This also removes the spurious error message.

Assisted-by Claude:deepseek-v4-flash

---
  .../gpu/drm/bridge/analogix/analogix_dp_core.c | 18 +++---------------

  1 file changed, 3 insertions(+), 15 deletions(-)
(quoted diff) renamed from drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0 -0

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index 18e76d1e78e1..28eb668d3e3f 100644

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0 -5
@@ -1427,21 +1427,9 @@ analogix_dp_probe(struct device *dev, struct 
 analogix_dp_plat_data *plat_data)
       if (ret)
           return ERR_PTR(ret);
-    dp->phy = devm_phy_get(dp->dev, "dp");
-    if (IS_ERR(dp->phy)) {
-        dev_err(dp->dev, "no DP phy configured\n");
-        ret = PTR_ERR(dp->phy);
-        if (ret) {

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct · line 1444

Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0 -10
-            /*
-             * phy itself is not enabled, so we can move forward
-             * assigning NULL to phy pointer.
-             */
-            if (ret == -ENOSYS || ret == -ENODEV)
-                dp->phy = NULL;
-            else
-                return ERR_PTR(ret);
-        }
-    }

It should be better to add some comments here:

Quoted 4 lines

/*
 * Exynos5/RK3288/RK3399 use Analogix DP controller built-in PHY,
 * no separate PHY configuration is needed.
 */

Quoted 9 lines

Well, I think it should be fixed to:

/*
* RK3288/RK3399 use Analogix DP controller built-in PHY,
* no extra PHY configuration is required.
*/

The Exynos5xxx case may be more complex.

Thanks for the review. I will add the comments in the patch and send v2 soon.

Quoted 13 lines
Quoted 13 lines

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · line 1435

Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3 -0
+    dp->phy = devm_phy_optional_get(dp->dev, "dp");
+    if (IS_ERR(dp->phy))
+        return ERR_CAST(dp->phy);
       dp->clock = devm_clk_get(&pdev->dev, "dp");
       if (IS_ERR(dp->clock)) {

With the comment added:

Best regards,
Damon