Skip to content

[powersave] MIPI CSI PHY missing runtime PM

If you look at /sys/kernel/debug/pm_genpd/pm_genpd_summary with the MIPI CSI patches from here, the csiphy is preventing cam_cc_titan_top_gdsc from turning off.

My diff to make it work:

diff --git a/drivers/phy/qualcomm/phy-qcom-mipi-csi2-core.c b/drivers/phy/qualcomm/phy-qcom-mipi-csi2-core.c
index 1def2d1258..1faf642afb 100644
--- a/drivers/phy/qualcomm/phy-qcom-mipi-csi2-core.c
+++ b/drivers/phy/qualcomm/phy-qcom-mipi-csi2-core.c
@@ -138,10 +138,14 @@
 	struct device *dev = &phy->dev;
 	int ret;
 
+	ret = pm_runtime_resume_and_get(csi2phy->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = regulator_bulk_enable(csi2phy->soc_cfg->num_supplies,
 				    csi2phy->supplies);
 	if (ret)
-		return ret;
+		goto rpm_put;
 
 	ret = phy_qcom_mipi_csi2_set_clock_rates(csi2phy, csi2phy->stream_cfg.link_freq);
 	if (ret)
@@ -162,6 +166,9 @@
 	regulator_bulk_disable(csi2phy->soc_cfg->num_supplies,
 			       csi2phy->supplies);
 
+rpm_put:
+	pm_runtime_put(csi2phy->dev);
+
 	return ret;
 }
 
@@ -173,6 +180,7 @@
 				   csi2phy->clks);
 	regulator_bulk_disable(csi2phy->soc_cfg->num_supplies,
 			       csi2phy->supplies);
+	pm_runtime_put(csi2phy->dev);
 
 	return 0;
 }
@@ -199,6 +207,7 @@
 
 	csi2phy->dev = dev;
 	csi2phy->soc_cfg = device_get_match_data(&pdev->dev);
+	platform_set_drvdata(pdev, csi2phy);
 
 	if (!csi2phy->soc_cfg)
 		return -EINVAL;
@@ -252,14 +261,22 @@
 	phy_set_drvdata(generic_phy, csi2phy);
 
 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	if (!IS_ERR(phy_provider))
+	if (!IS_ERR(phy_provider)) {
 		dev_dbg(dev, "Registered MIPI CSI2 PHY device\n");
-	else
-		pm_runtime_disable(dev);
+		pm_runtime_enable(dev);
+	}
 
 	return PTR_ERR_OR_ZERO(phy_provider);
 }
 
+static void phy_qcom_mipi_csi2_remove(struct platform_device *pdev)
+{
+	struct mipi_csi2phy_device *csi2phy = platform_get_drvdata(pdev);
+
+	pm_runtime_disable(csi2phy->dev);
+}
+
+
 static const struct of_device_id phy_qcom_mipi_csi2_of_match_table[] = {
 	{ .compatible	= "qcom,x1e80100-mipi-csi2-combo-phy", .data = &mipi_csi2_dphy_4nm_x1e },
 	{ }
@@ -268,6 +285,7 @@
 
 static struct platform_driver phy_qcom_mipi_csi2_driver = {
 	.probe		= phy_qcom_mipi_csi2_probe,
+	.remove		= phy_qcom_mipi_csi2_remove,
 	.driver = {
 		.name	= "qcom-mipi-csi2-phy",
 		.of_match_table = phy_qcom_mipi_csi2_of_match_table,

but I'm not 100% sure if this is the correct way to do it, and if remove handling is necessary etc.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information