[PATCH v25 08/15] media: qcom: camss: Allow CSI2 PHY devices without CSIPHY resources

From: Hangxiang Ma

Date: Fri Nov 13 2026 - 01:18:37 EST


From: Vladimir Zapolskiy <vz@xxxxxxxxxx>

If CAMSS CSIPHYs are supported by the stand-alone CSI2 PHY driver only,
there is no need to provide description of legacy CSIPHY resources in
the CAMSS driver, therefore if CSIPHY resources are not given for some
supported platform, use CAMSS CSIPHY port numbers as CSIPHY identifiers.

Reviewed-by: Bryan O'Donoghue <bod@xxxxxxxxxx>
Reviewed-by: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
Signed-off-by: Vladimir Zapolskiy <vz@xxxxxxxxxx>
Signed-off-by: Hangxiang Ma <hangxiang.ma@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss-csiphy.c | 16 +++++++++++++---
drivers/media/platform/qcom/camss/camss.c | 8 ++++++--
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index cdb803843792..4db68aa2a7a7 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -793,6 +793,11 @@ int msm_csiphy_subdev_init_legacy(struct camss *camss,
return ret;
}

+/* Fallback to generic SDM845 compatible formats for non-legacy CSIPHYs */
+static const struct csiphy_subdev_resources csiphy_res_phy = {
+ .formats = &csiphy_formats_sdm845,
+};
+
/*
* msm_csiphy_subdev_init - Initialize CSIPHY device structure and resources
* @camss: CAMSS structure
@@ -802,7 +807,7 @@ int msm_csiphy_subdev_init_legacy(struct camss *camss,
*/
int msm_csiphy_subdev_init(struct camss *camss, u8 port)
{
- const struct camss_subdev_resources *res = &camss->res->csiphy_res[port];
+ const struct camss_subdev_resources *res = camss->res->csiphy_res;
struct csiphy_device *csiphy = &camss->csiphy[port];
struct device *dev = camss->dev;
struct device_node *ep, *remote;
@@ -830,8 +835,13 @@ int msm_csiphy_subdev_init(struct camss *camss, u8 port)
}

csiphy->camss = camss;
- csiphy->id = res->csiphy.id;
- csiphy->res = &res->csiphy;
+ if (res) {
+ csiphy->id = res[port].csiphy.id;
+ csiphy->res = &res[port].csiphy;
+ } else {
+ csiphy->id = port;
+ csiphy->res = &csiphy_res_phy;
+ }

snprintf(csiphy->name, ARRAY_SIZE(csiphy->name), "csi%d", csiphy->id);

diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index f7b9c71cf263..508fcecadb79 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -4808,7 +4808,10 @@ static void camss_detect_legacy_phy(struct camss *camss)
struct device_node *remote;
struct device_node *ep;

- camss->legacy_phy = true;
+ /* Legacy CSIPHY description implies the provided CSIPHY resources */
+ camss->legacy_phy = !!camss->res->csiphy_res;
+ if (!camss->legacy_phy)
+ goto done;

/* Find first remote-endpoint and determine if its a PHY */
for_each_endpoint_of_node(camss->dev->of_node, ep) {
@@ -4822,6 +4825,7 @@ static void camss_detect_legacy_phy(struct camss *camss)
break;
}

+done:
dev_dbg(camss->dev, "legacy phy mode %s\n",
camss->legacy_phy ? "true" : "false");
}
@@ -4853,7 +4857,7 @@ static int camss_init_subdevices(struct camss *camss)

if (ret < 0) {
dev_err(camss->dev, "csiphy %d init fail\n",
- res->csiphy_res[i].csiphy.id);
+ res->csiphy_res ? res->csiphy_res[i].csiphy.id : i);
return ret;
}
}

--
2.34.1