Skip to contentSkip to conversation

media: qcom: camss: Report CAMSS hardware version via media controller

PATCH Superseded Loic Poulain 3 participants 13 messages Jul 17 – Jul 30

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Loic Poulain

author reviewer
#0 lore raw

cover media: qcom: camss: Report CAMSS hardware version via media controller

This series lets user space discover the exact CAMSS hardware variant by reporting the top-level CAMSS hardware version register through the media controller (media_dev.hw_revision), queryable via media-ctl -p or MEDIA_IOC_DEVICE_INFO. This helps identify the platform variant and adapt behaviour accordingly, for example allowing libcamera to apply quirks or enable features that cannot be discovered through standard V4L2 or media-controller APIs.

The version register is exposed by some platforms through the top-level "top" (or "cpas-top") reg region at offset 0. Accessing it requires the AHB bus to be clocked. To make this possible at probe time, the series first moves the shared CAMSS clocks (top_ahb, ahb, axi on QCM2290) into the PM clock framework, so they are managed by runtime PM at the CAMSS instance level rather than by each individual sub-block (VFE, CSID, ...).

For now, only Agatti is supported. But support for other platforms like TITAN-based ones will be introduced in a follow-up series.

Reported media info on Agatti/CM2290 (Spectra 520):
Media Driver Info:

        Driver name      : qcom-camss
        Model            : Qualcomm Camera Subsystem
        Bus info         : platform:5c11000.camss
        Hardware revision: 0x00050200 (328192)

---
Loic Poulain (4):
media: qcom: camss: Add PM clock support and integrate with runtime PM
media: qcom: camss: Add PM clock definitions for QCM2290
media: qcom: camss: Drop top_ahb/ahb/axi from QCM2290 subdevice clocks
media: qcom: camss: Report hardware version via media controller

 drivers/media/platform/qcom/camss/camss.c | 113 +++++++++++++++++++++++-------
 drivers/media/platform/qcom/camss/camss.h |   2 +
 2 files changed, 88 insertions(+), 27 deletions(-)

---
base-commit: fce2dfa773ced15f27dd27cd0b482a7473cdcf2a
change-id: 20260717-camss-version-a8ea61dfae5d

Best regards,

Signature · 1 line
Loic Poulain <[email protected]>
author reviewer
#1 lore raw

PATCH 1/4 media: qcom: camss: Add PM clock support and integrate with runtime PM

Add optional PM clock support to the CAMSS driver using the PM clock framework. This allows CAMSS clocks to be registered once and automatically managed during runtime suspend and resume.

This is especially useful for global CAMSS clocks that are shared across multiple CAMSS subblocks.

This avoids the need for each subblock to reference and manage the shared clocks individually. A typical example is the set of clocks in the top_group, which may be used by CSID, PHY, CCI, and other CAMSS blocks.

Introduce a small PM clock descriptor table in the CAMSS resources structure to describe clocks and their optional rates. Initialize these clocks at probe time and delegate clock ownership to the PM core.

Hook PM clock handling into the runtime PM callbacks to ensure clocks are properly suspended and resumed alongside power domains and ICC paths.

---
 drivers/media/platform/qcom/camss/camss.c | 40 ++++++++++++++++++++++++++++++-
 drivers/media/platform/qcom/camss/camss.h |  1 +
 2 files changed, 40 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss.c +39 -1
index 2123f6388e3d7eafe669efd6b033e22d8eb5cf79..6a2bf3373e8755805c8cd0f8fe5037b788d68fa2 100644
@@ -18,6 +18,7 @@
 #include <linux/of_graph.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_domain.h>
+#include <linux/pm_clock.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 
@@ -5346,6 +5347,35 @@ static void camss_genpd_cleanup(struct camss *camss)
 	dev_pm_domain_detach(camss->genpd, true);
 }
 
+/*
+ * camss_init_pm_clks - register shared CAMSS clocks with the PM clock framework
+ *
+ * Clocks listed in res->pm_clks are shared across all CAMSS sub-devices (e.g.
+ * top_ahb, axi). They are managed automatically by the PM framework.
+ */
+static int camss_init_pm_clks(struct camss *camss)
+{
+	struct device *dev = camss->dev;
+	unsigned int i;
+	int ret;
+
+	if (!camss->res->pm_clks[0])
+		return 0;
+
+	ret = devm_pm_clk_create(dev);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < CAMSS_RES_MAX && camss->res->pm_clks[i]; i++) {
+		ret = pm_clk_add(dev, camss->res->pm_clks[i]);
+		if (ret)
+			dev_warn(dev, "failed to add pm_clk %s: %d\n",
+				 camss->res->pm_clks[i], ret);
+	}
+
+	return 0;
+}
+
 /*
  * camss_probe - Probe CAMSS platform device
  * @pdev: Pointer to CAMSS platform device
@@ -5434,6 +5464,10 @@ static int camss_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(dev);
 
+	ret = camss_init_pm_clks(camss);
+	if (ret)
+		goto err_v4l2_device_unregister;
+
 	ret = camss_parse_ports(camss);
 	if (ret < 0)
 		goto err_v4l2_device_unregister;
@@ -5775,7 +5809,7 @@ static int __maybe_unused camss_runtime_suspend(struct device *dev)
 			return ret;
 	}
 
-	return 0;
+	return pm_clk_suspend(dev);
 }
 
 static int __maybe_unused camss_runtime_resume(struct device *dev)
@@ -5785,6 +5819,10 @@ static int __maybe_unused camss_runtime_resume(struct device *dev)
 	int i;
 	int ret;
 
+	ret = pm_clk_resume(dev);
+	if (ret)
+		return ret;
+
 	for (i = 0; i < camss->res->icc_path_num; i++) {
 		ret = icc_set_bw(camss->icc_path[i],
 				 icc_res[i].icc_bw_tbl.avg,
drivers/media/platform/qcom/camss/camss.h +1 -0
index 93d691c8ac63b2a47dbb234856b627d8911a1851..fe5fe25d5f18d8a3ce35b48077a975f1453c341f 100644
@@ -107,6 +107,7 @@ enum icc_count {
 struct camss_resources {
 	enum camss_version version;
 	const char *pd_name;
+	const char *pm_clks[CAMSS_RES_MAX];
 	const struct camss_subdev_resources *csiphy_res;
 	const struct camss_subdev_resources *tpg_res;
 	const struct camss_subdev_resources *csid_res;
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH 1/4] media: qcom: camss: Add PM clock support and integrate with runtime PM

Quoted 57 lines · Loic Poulain

Add optional PM clock support to the CAMSS driver using the PM clock framework. This allows CAMSS clocks to be registered once and automatically managed during runtime suspend and resume.

This is especially useful for global CAMSS clocks that are shared across multiple CAMSS subblocks.

This avoids the need for each subblock to reference and manage the shared clocks individually. A typical example is the set of clocks in the top_group, which may be used by CSID, PHY, CCI, and other CAMSS blocks.

Introduce a small PM clock descriptor table in the CAMSS resources structure to describe clocks and their optional rates. Initialize these clocks at probe time and delegate clock ownership to the PM core.

Hook PM clock handling into the runtime PM callbacks to ensure clocks are properly suspended and resumed alongside power domains and ICC paths.

---
  drivers/media/platform/qcom/camss/camss.c | 40 ++++++++++++++++++++++++++++++-
  drivers/media/platform/qcom/camss/camss.h |  1 +
  2 files changed, 40 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss.c +15 -0
index 2123f6388e3d7eafe669efd6b033e22d8eb5cf79..6a2bf3373e8755805c8cd0f8fe5037b788d68fa2 100644
@@ -18,6 +18,7 @@
  #include <linux/of_graph.h>
  #include <linux/pm_runtime.h>
  #include <linux/pm_domain.h>
+#include <linux/pm_clock.h>
  #include <linux/slab.h>
  #include <linux/videodev2.h>
 
@@ -5346,6 +5347,35 @@ static void camss_genpd_cleanup(struct camss *camss)
  	dev_pm_domain_detach(camss->genpd, true);
  }
 
+/*
+ * camss_init_pm_clks - register shared CAMSS clocks with the PM clock framework
+ *
+ * Clocks listed in res->pm_clks are shared across all CAMSS sub-devices (e.g.
+ * top_ahb, axi). They are managed automatically by the PM framework.
+ */
+static int camss_init_pm_clks(struct camss *camss)
+{
+	struct device *dev = camss->dev;
+	unsigned int i;
+	int ret;
+
+	if (!camss->res->pm_clks[0])
+		return 0;

drivers/media/platform/qcom/camss/camss.c static void camss_genpd_cleanup(struct camss *camss) · line 5373

Quoted 10 lines
drivers/media/platform/qcom/camss/camss.c +10 -0
+
+	ret = devm_pm_clk_create(dev);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < CAMSS_RES_MAX && camss->res->pm_clks[i]; i++) {
+		ret = pm_clk_add(dev, camss->res->pm_clks[i]);
+		if (ret)
+			dev_warn(dev, "failed to add pm_clk %s: %d\n",
+				 camss->res->pm_clks[i], ret);

return ret;

---
bod

maintainer
#3 lore raw

Re: [PATCH 1/4] media: qcom: camss: Add PM clock support and integrate with runtime PM

In reply to Loic Poulain
Quoted 87 lines · Loic Poulain

Add optional PM clock support to the CAMSS driver using the PM clock framework. This allows CAMSS clocks to be registered once and automatically managed during runtime suspend and resume.

This is especially useful for global CAMSS clocks that are shared across multiple CAMSS subblocks.

This avoids the need for each subblock to reference and manage the shared clocks individually. A typical example is the set of clocks in the top_group, which may be used by CSID, PHY, CCI, and other CAMSS blocks.

Introduce a small PM clock descriptor table in the CAMSS resources structure to describe clocks and their optional rates. Initialize these clocks at probe time and delegate clock ownership to the PM core.

Hook PM clock handling into the runtime PM callbacks to ensure clocks are properly suspended and resumed alongside power domains and ICC paths.

---
  drivers/media/platform/qcom/camss/camss.c | 40 ++++++++++++++++++++++++++++++-
  drivers/media/platform/qcom/camss/camss.h |  1 +
  2 files changed, 40 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss.c +34 -0
index 2123f6388e3d7eafe669efd6b033e22d8eb5cf79..6a2bf3373e8755805c8cd0f8fe5037b788d68fa2 100644
@@ -18,6 +18,7 @@
  #include <linux/of_graph.h>
  #include <linux/pm_runtime.h>
  #include <linux/pm_domain.h>
+#include <linux/pm_clock.h>
  #include <linux/slab.h>
  #include <linux/videodev2.h>
 
@@ -5346,6 +5347,35 @@ static void camss_genpd_cleanup(struct camss *camss)
  	dev_pm_domain_detach(camss->genpd, true);
  }
 
+/*
+ * camss_init_pm_clks - register shared CAMSS clocks with the PM clock framework
+ *
+ * Clocks listed in res->pm_clks are shared across all CAMSS sub-devices (e.g.
+ * top_ahb, axi). They are managed automatically by the PM framework.
+ */
+static int camss_init_pm_clks(struct camss *camss)
+{
+	struct device *dev = camss->dev;
+	unsigned int i;
+	int ret;
+
+	if (!camss->res->pm_clks[0])
+		return 0;
+
+	ret = devm_pm_clk_create(dev);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < CAMSS_RES_MAX && camss->res->pm_clks[i]; i++) {
+		ret = pm_clk_add(dev, camss->res->pm_clks[i]);
+		if (ret)
+			dev_warn(dev, "failed to add pm_clk %s: %d\n",
+				 camss->res->pm_clks[i], ret);
+	}
+
+	return 0;
+}
+
  /*
   * camss_probe - Probe CAMSS platform device
   * @pdev: Pointer to CAMSS platform device
@@ -5434,6 +5464,10 @@ static int camss_probe(struct platform_device *pdev)
 
  	pm_runtime_enable(dev);
 
+	ret = camss_init_pm_clks(camss);
+	if (ret)
+		goto err_v4l2_device_unregister;
+
  	ret = camss_parse_ports(camss);
  	if (ret < 0)
  		goto err_v4l2_device_unregister;

drivers/media/platform/qcom/camss/camss.c static int __maybe_unused camss_runtime_suspend(struct device *dev) · line 5812

Quoted 5 lines
drivers/media/platform/qcom/camss/camss.c +1 -1
@@ -5775,7 +5809,7 @@ static int __maybe_unused camss_runtime_suspend(struct device *dev)
  			return ret;
  	}
 
-	return 0;
+	return pm_clk_suspend(dev);
  CC      drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.o
  CC      drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.o
  AR      drivers/staging/media/ipu7/built-in.a
In file included from ./include/uapi/linux/posix_types.h:5,
                 from ./include/uapi/linux/types.h:14,
                 from ./include/linux/types.h:5,
                 from ./include/linux/kasan-checks.h:5,
                 from ./include/asm-generic/rwonce.h:26,
                 from ./arch/x86/include/generated/asm/rwonce.h:1,
                 from ./include/linux/compiler.h:369,
                 from ./include/linux/err.h:5,
                 from ./include/linux/clk.h:12,
                 from drivers/media/platform/qcom/camss/camss.c:10:
drivers/media/platform/qcom/camss/camss.c: In function ‘camss_runtime_suspend’:
./include/linux/stddef.h:8:14: error: called object is not a function or function pointer
    8 | #define NULL ((void *)0)
      |              ^
./include/linux/pm_clock.h:77:25: note: in expansion of macro ‘NULL’
   77 | #define pm_clk_suspend  NULL
      |                         ^~~~
drivers/media/platform/qcom/camss/camss.c:5841:16: note: in expansion of macro ‘pm_clk_suspend’
 5841 |         return pm_clk_suspend(dev);
      |                ^~~~~~~~~~~~~~
drivers/media/platform/qcom/camss/camss.c: In function ‘camss_runtime_resume’:
./include/linux/stddef.h:8:14: error: called object is not a function or function pointer
    8 | #define NULL ((void *)0)
      |              ^
./include/linux/pm_clock.h:78:25: note: in expansion of macro ‘NULL’
   78 | #define pm_clk_resume   NULL
      |                         ^~~~
drivers/media/platform/qcom/camss/camss.c:5851:15: note: in expansion of macro ‘pm_clk_resume’
 5851 |         ret = pm_clk_resume(dev);
      |               ^~~~~~~~~~~~~

make[7]: *** [scripts/Makefile.build:289: drivers/media/platform/qcom/camss/camss.o] Error 1 make[7]: *** Waiting for unfinished jobs....
CC drivers/media/usb/pwc/pwc-misc.o

Please fix.

---
bod

author reviewer
#4 lore raw

Re: [PATCH 1/4] media: qcom: camss: Add PM clock support and integrate with runtime PM

Hi Bryan,

Quoted 133 lines · Bryan O'Donoghue
Quoted 87 lines · Loic Poulain

Add optional PM clock support to the CAMSS driver using the PM clock framework. This allows CAMSS clocks to be registered once and automatically managed during runtime suspend and resume.

This is especially useful for global CAMSS clocks that are shared across multiple CAMSS subblocks.

This avoids the need for each subblock to reference and manage the shared clocks individually. A typical example is the set of clocks in the top_group, which may be used by CSID, PHY, CCI, and other CAMSS blocks.

Introduce a small PM clock descriptor table in the CAMSS resources structure to describe clocks and their optional rates. Initialize these clocks at probe time and delegate clock ownership to the PM core.

Hook PM clock handling into the runtime PM callbacks to ensure clocks are properly suspended and resumed alongside power domains and ICC paths.

---
  drivers/media/platform/qcom/camss/camss.c | 40 ++++++++++++++++++++++++++++++-
  drivers/media/platform/qcom/camss/camss.h |  1 +
  2 files changed, 40 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss.c +34 -0
index 2123f6388e3d7eafe669efd6b033e22d8eb5cf79..6a2bf3373e8755805c8cd0f8fe5037b788d68fa2 100644
@@ -18,6 +18,7 @@
  #include <linux/of_graph.h>
  #include <linux/pm_runtime.h>
  #include <linux/pm_domain.h>
+#include <linux/pm_clock.h>
  #include <linux/slab.h>
  #include <linux/videodev2.h>
 
@@ -5346,6 +5347,35 @@ static void camss_genpd_cleanup(struct camss *camss)
      dev_pm_domain_detach(camss->genpd, true);
  }
 
+/*
+ * camss_init_pm_clks - register shared CAMSS clocks with the PM clock framework
+ *
+ * Clocks listed in res->pm_clks are shared across all CAMSS sub-devices (e.g.
+ * top_ahb, axi). They are managed automatically by the PM framework.
+ */
+static int camss_init_pm_clks(struct camss *camss)
+{
+     struct device *dev = camss->dev;
+     unsigned int i;
+     int ret;
+
+     if (!camss->res->pm_clks[0])
+             return 0;
+
+     ret = devm_pm_clk_create(dev);
+     if (ret)
+             return ret;
+
+     for (i = 0; i < CAMSS_RES_MAX && camss->res->pm_clks[i]; i++) {
+             ret = pm_clk_add(dev, camss->res->pm_clks[i]);
+             if (ret)
+                     dev_warn(dev, "failed to add pm_clk %s: %d\n",
+                              camss->res->pm_clks[i], ret);
+     }
+
+     return 0;
+}
+
  /*
   * camss_probe - Probe CAMSS platform device
   * @pdev: Pointer to CAMSS platform device
@@ -5434,6 +5464,10 @@ static int camss_probe(struct platform_device *pdev)
 
      pm_runtime_enable(dev);
 
+     ret = camss_init_pm_clks(camss);
+     if (ret)
+             goto err_v4l2_device_unregister;
+
      ret = camss_parse_ports(camss);
      if (ret < 0)
              goto err_v4l2_device_unregister;

drivers/media/platform/qcom/camss/camss.c static int __maybe_unused camss_runtime_suspend(struct device *dev) · line 5812

Quoted 5 lines
drivers/media/platform/qcom/camss/camss.c +1 -1
@@ -5775,7 +5809,7 @@ static int __maybe_unused camss_runtime_suspend(struct device *dev)
                      return ret;
      }
 
-     return 0;
+     return pm_clk_suspend(dev);
   CC      drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.o
   CC      drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.o
   AR      drivers/staging/media/ipu7/built-in.a
In file included from ./include/uapi/linux/posix_types.h:5,
                  from ./include/uapi/linux/types.h:14,
                  from ./include/linux/types.h:5,
                  from ./include/linux/kasan-checks.h:5,
                  from ./include/asm-generic/rwonce.h:26,
                  from ./arch/x86/include/generated/asm/rwonce.h:1,
                  from ./include/linux/compiler.h:369,
                  from ./include/linux/err.h:5,
                  from ./include/linux/clk.h:12,
                  from drivers/media/platform/qcom/camss/camss.c:10:

drivers/media/platform/qcom/camss/camss.c: In function ‘camss_runtime_suspend’:
./include/linux/stddef.h:8:14: error: called object is not a function or function pointer

     8 | #define NULL ((void *)0)
       |              ^
./include/linux/pm_clock.h:77:25: note: in expansion of macro ‘NULL’
    77 | #define pm_clk_suspend  NULL
       |                         ^~~~
drivers/media/platform/qcom/camss/camss.c:5841:16: note: in expansion of
macro ‘pm_clk_suspend’
  5841 |         return pm_clk_suspend(dev);
       |                ^~~~~~~~~~~~~~

drivers/media/platform/qcom/camss/camss.c: In function ‘camss_runtime_resume’:
./include/linux/stddef.h:8:14: error: called object is not a function or function pointer

     8 | #define NULL ((void *)0)
       |              ^
./include/linux/pm_clock.h:78:25: note: in expansion of macro ‘NULL’
    78 | #define pm_clk_resume   NULL
       |                         ^~~~
drivers/media/platform/qcom/camss/camss.c:5851:15: note: in expansion of
macro ‘pm_clk_resume’
  5851 |         ret = pm_clk_resume(dev);
       |               ^~~~~~~~~~~~~
Quoted 6 lines

make[7]: *** [scripts/Makefile.build:289:
drivers/media/platform/qcom/camss/camss.o] Error 1 make[7]: *** Waiting for unfinished jobs....
CC drivers/media/usb/pwc/pwc-misc.o

Please fix.

Thanks, I submitted a v3 with this fixed.

Regards,
Loic

author reviewer
#5 lore raw

PATCH 2/4 media: qcom: camss: Add PM clock definitions for QCM2290

In reply to Loic Poulain

Provide the required CAMSS PM clock descriptors for the QCM2290 platform. Register the top_ahb, ahb and axi clocks so they can be managed automatically through the PM clock framework (they are part of the camss-top group).

---
 drivers/media/platform/qcom/camss/camss.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/camss/camss.c +1 -0
index 6a2bf3373e8755805c8cd0f8fe5037b788d68fa2..04b5601eb0b53110ce1b94248323dad1c08da9ca 100644
@@ -5589,6 +5589,7 @@ static const struct camss_resources msm8996_resources = {
 
 static const struct camss_resources qcm2290_resources = {
 	.version = CAMSS_2290,
+	.pm_clks = { "top_ahb", "ahb", "axi" },
 	.csiphy_res = csiphy_res_2290,
 	.csid_res = csid_res_2290,
 	.vfe_res = vfe_res_2290,
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 2/4
#6 lore raw

Re: [PATCH 2/4] media: qcom: camss: Add PM clock definitions for QCM2290

Quoted 16 lines · Loic Poulain

Provide the required CAMSS PM clock descriptors for the QCM2290 platform. Register the top_ahb, ahb and axi clocks so they can be managed automatically through the PM clock framework (they are part of the camss-top group).

---
  drivers/media/platform/qcom/camss/camss.c | 1 +
  1 file changed, 1 insertion(+)
drivers/media/platform/qcom/camss/camss.c +0 -0
index 6a2bf3373e8755805c8cd0f8fe5037b788d68fa2..04b5601eb0b53110ce1b94248323dad1c08da9ca 100644

drivers/media/platform/qcom/camss/camss.c static const struct camss_resources msm8996_resources = { · line 5595

Quoted 7 lines
drivers/media/platform/qcom/camss/camss.c +1 -0
@@ -5589,6 +5589,7 @@ static const struct camss_resources msm8996_resources = {
 
  static const struct camss_resources qcm2290_resources = {
  	.version = CAMSS_2290,
+	.pm_clks = { "top_ahb", "ahb", "axi" },
  	.csiphy_res = csiphy_res_2290,
  	.csid_res = csid_res_2290,
  	.vfe_res = vfe_res_2290,
author reviewer
#7 lore raw

PATCH 3/4 media: qcom: camss: Drop top_ahb/ahb/axi from QCM2290 subdevice clocks

In reply to Loic Poulain

Remove the top_ahb, ahb and axi clocks from QCM2290 subdevice clock lists. These clocks are now handled centrally as global CAMSS PM clocks and are automatically enabled when CAMSS is runtime resumed.

This avoids redundant clock references in individual subdevices and ensures consistent clock management across the CAMSS pipeline.

---
 drivers/media/platform/qcom/camss/camss.c | 38 ++++++++++---------------------
 1 file changed, 12 insertions(+), 26 deletions(-)
drivers/media/platform/qcom/camss/camss.c +12 -26
index 04b5601eb0b53110ce1b94248323dad1c08da9ca..1e97b0b7ec463f1fa2615704d09ce465a8964176 100644
@@ -688,10 +688,8 @@ static const struct camss_subdev_resources csiphy_res_2290[] = {
 			{ .supply = "vdd-csiphy-1p2", .init_load_uA = 26700 },
 			{ .supply = "vdd-csiphy-1p8", .init_load_uA = 2600 }
 		},
-		.clock = { "top_ahb", "ahb", "csiphy0", "csiphy0_timer" },
-		.clock_rate = { { 0 },
-				{ 0 },
-				{ 240000000, 341330000, 384000000 },
+		.clock = { "csiphy0", "csiphy0_timer" },
+		.clock_rate = { { 240000000, 341330000, 384000000 },
 				{ 100000000, 200000000, 268800000 }  },
 		.reg = { "csiphy0" },
 		.interrupt = { "csiphy0" },
@@ -708,10 +706,8 @@ static const struct camss_subdev_resources csiphy_res_2290[] = {
 			{ .supply = "vdd-csiphy-1p2", .init_load_uA = 26700 },
 			{ .supply = "vdd-csiphy-1p8", .init_load_uA = 2600 }
 		},
-		.clock = { "top_ahb", "ahb", "csiphy1", "csiphy1_timer" },
-		.clock_rate = { { 0 },
-				{ 0 },
-				{ 240000000, 341330000, 384000000 },
+		.clock = { "csiphy1", "csiphy1_timer" },
+		.clock_rate = { { 240000000, 341330000, 384000000 },
 				{ 100000000, 200000000, 268800000 }  },
 		.reg = { "csiphy1" },
 		.interrupt = { "csiphy1" },
@@ -727,10 +723,8 @@ static const struct camss_subdev_resources csid_res_2290[] = {
 	/* CSID0 */
 	{
 		.regulators = {},
-		.clock = { "top_ahb", "ahb", "csi0", "vfe0_cphy_rx", "vfe0" },
-		.clock_rate = { { 0 },
-				{ 0 },
-				{ 192000000, 240000000, 384000000, 426400000 },
+		.clock = { "csi0", "vfe0_cphy_rx", "vfe0" },
+		.clock_rate = { { 192000000, 240000000, 384000000, 426400000 },
 				{ 0 },
 				{ 0 } },
 		.reg = { "csid0" },
@@ -745,10 +739,8 @@ static const struct camss_subdev_resources csid_res_2290[] = {
 	/* CSID1 */
 	{
 		.regulators = {},
-		.clock = { "top_ahb", "ahb", "csi1", "vfe1_cphy_rx", "vfe1" },
-		.clock_rate = { { 0 },
-				{ 0 },
-				{ 192000000, 240000000, 384000000, 426400000 },
+		.clock = { "csi1", "vfe1_cphy_rx", "vfe1" },
+		.clock_rate = { { 192000000, 240000000, 384000000, 426400000 },
 				{ 0 },
 				{ 0 } },
 		.reg = { "csid1" },
@@ -765,11 +757,8 @@ static const struct camss_subdev_resources vfe_res_2290[] = {
 	/* VFE0 */
 	{
 		.regulators = {},
-		.clock = { "top_ahb", "ahb", "axi", "vfe0", "camnoc_rt_axi", "camnoc_nrt_axi" },
-		.clock_rate = { { 0 },
-				{ 0 },
-				{ 0 },
-				{ 19200000, 153600000, 192000000, 256000000, 384000000, 460800000 },
+		.clock = { "vfe0", "camnoc_rt_axi", "camnoc_nrt_axi" },
+		.clock_rate = { { 19200000, 153600000, 192000000, 256000000, 384000000, 460800000 },
 				{ 0 },
 				{ 0 }, },
 		.reg = { "vfe0" },
@@ -785,11 +774,8 @@ static const struct camss_subdev_resources vfe_res_2290[] = {
 	/* VFE1 */
 	{
 		.regulators = {},
-		.clock = { "top_ahb", "ahb", "axi", "vfe1", "camnoc_rt_axi", "camnoc_nrt_axi" },
-		.clock_rate = { { 0 },
-				{ 0 },
-				{ 0 },
-				{ 19200000, 153600000, 192000000, 256000000, 384000000, 460800000 },
+		.clock = { "vfe1", "camnoc_rt_axi", "camnoc_nrt_axi" },
+		.clock_rate = { { 19200000, 153600000, 192000000, 256000000, 384000000, 460800000 },
 				{ 0 },
 				{ 0 }, },
 		.reg = { "vfe1" },
Signature · 1 line
2.34.1
author reviewer
#8 lore raw

PATCH 4/4 media: qcom: camss: Report hardware version via media controller

In reply to Loic Poulain

Populate media_dev.hw_revision with the top-level CAMSS hardware version so that user space can query the exact hardware variant through the media controller (e.g. via media-ctl or MEDIA_IOC_DEVICE_INFO). This can help identify the platform variant and adapt behaviour accordingly, for example allowing libcamera to apply quirks or enable features that cannot be discovered through standard V4L2 or media-controller APIs.

The version register is exposed by some platforms through the top-level "top" reg region (offset 0). When present, map it and read the version once at probe. This is a no-op on platforms not mapping the region (yet).

Reported media info on Agatti/CM2290 (Spectra 520):
Media Driver Info:

        Driver name      : qcom-camss
        Model            : Qualcomm Camera Subsystem
        Bus info         : platform:5c11000.camss
        Hardware revision: 0x00050200 (328192)
---
 drivers/media/platform/qcom/camss/camss.c | 34 +++++++++++++++++++++++++++++++
 drivers/media/platform/qcom/camss/camss.h |  1 +
 2 files changed, 35 insertions(+)
drivers/media/platform/qcom/camss/camss.c +34 -0
index 1e97b0b7ec463f1fa2615704d09ce465a8964176..2caa253fc4ad48f7f04580417d15553a710cbc6f 100644
@@ -33,6 +33,9 @@
 #define CAMSS_CLOCK_MARGIN_NUMERATOR 105
 #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
 
+/* Top-level CAMSS version register */
+#define CAMSS_HW_VERSION		0x0
+
 static const struct parent_dev_ops vfe_parent_dev_ops;
 
 static const struct camss_subdev_resources csiphy_res_8x16[] = {
@@ -4677,6 +4680,25 @@ void camss_pm_domain_off(struct camss *camss, int id)
 	}
 }
 
+static void camss_read_version(struct camss *camss)
+{
+	u32 hw_version;
+
+	if (!camss->top_base || !camss->res->pm_clks[0])
+		return;
+
+	if (pm_runtime_resume_and_get(camss->dev))
+		return;
+
+	hw_version = readl_relaxed(camss->top_base + CAMSS_HW_VERSION);
+
+	pm_runtime_put_sync(camss->dev);
+
+	dev_dbg(camss->dev, "CAMSS HW Version = 0x%08x\n", hw_version);
+
+	camss->media_dev.hw_revision = hw_version;
+}
+
 static int vfe_parent_dev_ops_get(struct camss *camss, int id)
 {
 	int ret = -EINVAL;
@@ -4866,6 +4888,16 @@ static int camss_init_subdevices(struct camss *camss)
 		camss->csid_wrapper_base = base;
 	}
 
+	/* Optional top register for hardware version info */
+	if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "top")) {
+		void __iomem *base;
+
+		base = devm_platform_ioremap_resource_byname(pdev, "top");
+		if (IS_ERR(base))
+			return PTR_ERR(base);
+		camss->top_base = base;
+	}
+
 	for (i = 0; i < camss->res->csid_num; i++) {
 		ret = msm_csid_subdev_init(camss, &camss->csid[i],
 					   &res->csid_res[i], i);
@@ -5454,6 +5486,8 @@ static int camss_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_v4l2_device_unregister;
 
+	camss_read_version(camss);
+
 	ret = camss_parse_ports(camss);
 	if (ret < 0)
 		goto err_v4l2_device_unregister;
drivers/media/platform/qcom/camss/camss.h +1 -0
index fe5fe25d5f18d8a3ce35b48077a975f1453c341f..cce79e56f58c8bdc0097f4a1702df22c4248f2fa 100644
@@ -133,6 +133,7 @@ struct camss {
 	struct ispif_device *ispif;
 	struct vfe_device *vfe;
 	void __iomem *csid_wrapper_base;
+	void __iomem *top_base;
 	atomic_t ref_count;
 	int genpd_num;
 	struct device *genpd;
Signature · 1 line
2.34.1
Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH 4/4] media: qcom: camss: Report hardware version via media controller

Quoted 6 lines · Loic Poulain

Populate media_dev.hw_revision with the top-level CAMSS hardware version so that user space can query the exact hardware variant through the media controller (e.g. via media-ctl or MEDIA_IOC_DEVICE_INFO). This can help identify the platform variant and adapt behaviour accordingly, for example allowing libcamera to apply quirks or enable features that cannot be discovered through standard V4L2 or media-controller APIs.

[...]

drivers/media/platform/qcom/camss/camss.c void camss_pm_domain_off(struct camss *camss, int id) · line 4695

Quoted 13 lines
drivers/media/platform/qcom/camss/camss.c +13 -0
+static void camss_read_version(struct camss *camss)
+{
+	u32 hw_version;
+
+	if (!camss->top_base || !camss->res->pm_clks[0])
+		return;
+
+	if (pm_runtime_resume_and_get(camss->dev))
+		return;
+
+	hw_version = readl_relaxed(camss->top_base + CAMSS_HW_VERSION);
+
+	pm_runtime_put_sync(camss->dev);

I think non-sync is fine here

TOP+0x0 seems to hold on TITAN, MSM8916 and MSM8996

Konrad

author reviewer
#10 lore raw

Re: [PATCH 4/4] media: qcom: camss: Report hardware version via media controller

Quoted 11 lines · Konrad Dybcio
Quoted 6 lines · Loic Poulain

Populate media_dev.hw_revision with the top-level CAMSS hardware version so that user space can query the exact hardware variant through the media controller (e.g. via media-ctl or MEDIA_IOC_DEVICE_INFO). This can help identify the platform variant and adapt behaviour accordingly, for example allowing libcamera to apply quirks or enable features that cannot be discovered through standard V4L2 or media-controller APIs.

[...]

Quoted 15 lines

drivers/media/platform/qcom/camss/camss.c void camss_pm_domain_off(struct camss *camss, int id) · line 4695

Quoted 13 lines
drivers/media/platform/qcom/camss/camss.c +13 -0
+static void camss_read_version(struct camss *camss)
+{
+     u32 hw_version;
+
+     if (!camss->top_base || !camss->res->pm_clks[0])
+             return;
+
+     if (pm_runtime_resume_and_get(camss->dev))
+             return;
+
+     hw_version = readl_relaxed(camss->top_base + CAMSS_HW_VERSION);
+
+     pm_runtime_put_sync(camss->dev);

I think non-sync is fine here

Using asynchronous PM may result in the runtime suspend ("work") never being executed if the probe function fails later (read version called from probe). From my understanding, a subsequent pm_runtime_disable() in the error path would cancel the pending suspend request, leaving the runtime PM state in a non-symmetrical (unbalanced) state.

Regards,
Loic

Quoted 6 lines

TOP+0x0 seems to hold on TITAN, MSM8916 and MSM8996

Konrad

#11 lore raw

Re: [PATCH 4/4] media: qcom: camss: Report hardware version via media controller

Quoted 29 lines · Loic Poulain
Quoted 11 lines · Konrad Dybcio
Quoted 6 lines · Loic Poulain

Populate media_dev.hw_revision with the top-level CAMSS hardware version so that user space can query the exact hardware variant through the media controller (e.g. via media-ctl or MEDIA_IOC_DEVICE_INFO). This can help identify the platform variant and adapt behaviour accordingly, for example allowing libcamera to apply quirks or enable features that cannot be discovered through standard V4L2 or media-controller APIs.

[...]

Quoted 15 lines

drivers/media/platform/qcom/camss/camss.c void camss_pm_domain_off(struct camss *camss, int id) · line 4695

Quoted 13 lines
drivers/media/platform/qcom/camss/camss.c +13 -0
+static void camss_read_version(struct camss *camss)
+{
+     u32 hw_version;
+
+     if (!camss->top_base || !camss->res->pm_clks[0])
+             return;
+
+     if (pm_runtime_resume_and_get(camss->dev))
+             return;
+
+     hw_version = readl_relaxed(camss->top_base + CAMSS_HW_VERSION);
+
+     pm_runtime_put_sync(camss->dev);

I think non-sync is fine here

Quoted 5 lines

Using asynchronous PM may result in the runtime suspend ("work") never being executed if the probe function fails later (read version called from probe). From my understanding, a subsequent pm_runtime_disable() in the error path would cancel the pending suspend request, leaving the runtime PM state in a non-symmetrical (unbalanced) state.

Got it

Konrad

maintainer
#12 lore raw

Re: [PATCH 4/4] media: qcom: camss: Report hardware version via media controller

In reply to Loic Poulain
Quoted 41 lines · Loic Poulain

Populate media_dev.hw_revision with the top-level CAMSS hardware version so that user space can query the exact hardware variant through the media controller (e.g. via media-ctl or MEDIA_IOC_DEVICE_INFO). This can help identify the platform variant and adapt behaviour accordingly, for example allowing libcamera to apply quirks or enable features that cannot be discovered through standard V4L2 or media-controller APIs.

The version register is exposed by some platforms through the top-level "top" reg region (offset 0). When present, map it and read the version once at probe. This is a no-op on platforms not mapping the region (yet).

Reported media info on Agatti/CM2290 (Spectra 520):
Media Driver Info:

         Driver name      : qcom-camss
         Model            : Qualcomm Camera Subsystem
         Bus info         : platform:5c11000.camss
         Hardware revision: 0x00050200 (328192)
---
  drivers/media/platform/qcom/camss/camss.c | 34 +++++++++++++++++++++++++++++++
  drivers/media/platform/qcom/camss/camss.h |  1 +
  2 files changed, 35 insertions(+)
drivers/media/platform/qcom/camss/camss.c +3 -0
index 1e97b0b7ec463f1fa2615704d09ce465a8964176..2caa253fc4ad48f7f04580417d15553a710cbc6f 100644
@@ -33,6 +33,9 @@
  #define CAMSS_CLOCK_MARGIN_NUMERATOR 105
  #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
 
+/* Top-level CAMSS version register */
+#define CAMSS_HW_VERSION		0x0
+
  static const struct parent_dev_ops vfe_parent_dev_ops;
 
  static const struct camss_subdev_resources csiphy_res_8x16[] = {
@@ -4677,6 +4680,25 @@ void camss_pm_domain_off(struct camss *camss, int id)
  	}
  }

drivers/media/platform/qcom/camss/camss.c void camss_pm_domain_off(struct camss *camss, int id) · line 4691

Quoted 10 lines
drivers/media/platform/qcom/camss/camss.c +9 -0
 
+static void camss_read_version(struct camss *camss)
+{
+	u32 hw_version;
+
+	if (!camss->top_base || !camss->res->pm_clks[0])
+		return;
+
+	if (pm_runtime_resume_and_get(camss->dev))
+		return;

If this fails, you're in real trouble.

Surely this wants to be a return -EBADSTUFF;

Quoted 31 lines
drivers/media/platform/qcom/camss/camss.c +20 -0
+
+	hw_version = readl_relaxed(camss->top_base + CAMSS_HW_VERSION);
+
+	pm_runtime_put_sync(camss->dev);
+
+	dev_dbg(camss->dev, "CAMSS HW Version = 0x%08x\n", hw_version);
+
+	camss->media_dev.hw_revision = hw_version;
+}
+
  static int vfe_parent_dev_ops_get(struct camss *camss, int id)
  {
  	int ret = -EINVAL;
@@ -4866,6 +4888,16 @@ static int camss_init_subdevices(struct camss *camss)
  		camss->csid_wrapper_base = base;
  	}
 
+	/* Optional top register for hardware version info */
+	if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "top")) {
+		void __iomem *base;
+
+		base = devm_platform_ioremap_resource_byname(pdev, "top");
+		if (IS_ERR(base))
+			return PTR_ERR(base);
+		camss->top_base = base;
+	}
+
  	for (i = 0; i < camss->res->csid_num; i++) {
  		ret = msm_csid_subdev_init(camss, &camss->csid[i],
  					   &res->csid_res[i], i);

drivers/media/platform/qcom/camss/camss.c static int camss_probe(struct platform_device *pdev) · line 5490

Quoted 5 lines
drivers/media/platform/qcom/camss/camss.c +2 -0
@@ -5454,6 +5486,8 @@ static int camss_probe(struct platform_device *pdev)
  	if (ret)
  		goto err_v4l2_device_unregister;
 
+	camss_read_version(camss);
+

Make it an int a bug out if it fails.

Quoted 16 lines
drivers/media/platform/qcom/camss/camss.c +0 -0
  	ret = camss_parse_ports(camss);
  	if (ret < 0)
  		goto err_v4l2_device_unregister;
drivers/media/platform/qcom/camss/camss.h +1 -0
index fe5fe25d5f18d8a3ce35b48077a975f1453c341f..cce79e56f58c8bdc0097f4a1702df22c4248f2fa 100644
@@ -133,6 +133,7 @@ struct camss {
  	struct ispif_device *ispif;
  	struct vfe_device *vfe;
  	void __iomem *csid_wrapper_base;
+	void __iomem *top_base;
  	atomic_t ref_count;
  	int genpd_num;
  	struct device *genpd;