public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms
@ 2026-03-01  0:51 David Heidelberg via B4 Relay
  2026-03-01  0:51 ` [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration David Heidelberg via B4 Relay
                   ` (9 more replies)
  0 siblings, 10 replies; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

Note: WIP tag added, as not everything from the previous review round has
been addressed.

# Short summary

This patch series extends the Qualcomm CAMSS (Camera Subsystem),
including CSID and CSIPHY components, to support C-PHY mode configuration.

# Background and motivation

Modern smartphone cameras increasingly rely on MIPI C-PHY rather than 
D-PHY, thanks to its higher data throughput and signal efficiency.
As a result, many OEMs adopt C-PHY interfaces for main (rear) cameras on
Qualcomm-based devices.

Until now, mainline Linux lacked C-PHY configuration support for Qualcomm
chipsets, preventing bring-up of primary camera sensors on several
Snapdragon platforms. This series closes that gap.

 - Introduces C-PHY configuration support for the CAMSS driver stack,
   covering both CSID and CSIPHY blocks.
 - Successfully enables C-PHY operation on the Snapdragon 845 platform.
 - Tested on OnePlus 6 and 6T phones running mainline Linux,
   using the Sony IMX519 main camera sensor.
 - The new configuration allows other chipsets versionsto enable C-PHY by
   simply adding corresponding sensor driver support and csiphy
   initialization data, following the example set for sdm845.

With this patch series, mainline Linux gains working C-PHY support for
Snapdragon 845, paving the way for improved main camera functionality
across many Qualcomm-based devices. The groundwork also simplifies
future enablement efforts for additional SoCs and sensors.

Until merged, the series will be also available at:
  https://codeberg.org/sdm845/linux/commits/branch/b4/qcom-cphy

Signed-off-by: David Heidelberg <david@ixit.cz>
---
Changes in v4:
- Documented cphy parametr to camss_get_link_freq.
- Use BIT() macro for lane_mask. (Bryan)
- Correct lane_mask calculation. (Kieran + me)
- Removed comment for the D/C-PHY sequences init. (Bryan)
- Pass &csid->phy for calculate freq. (Bryan)
- Added missing cphy description to camss_get_link_freq. (kernel test robot)
- Gen2 v1.1 MIPI CSI-2 CPHY init hex to lowercase.
- Added back missed commit with improved electrical for sdm845 3ph.
- NOT addressed yet:
  - Proliferating special cases in switch statements on a per-SoC basis is verboten. 
  - is it possible to set clock_lane to say 0xff in DT ? 
- Link to v3: https://lore.kernel.org/r/20260117-qcom-cphy-v3-0-8ce76a06f7db@ixit.cz

Changes in v3:
- Make lanes_enable return sucess or error, since I couldn't move the
  configuration to the _init.
- Dropped R-b tags on
  "media: qcom: camss: Initialize lanes after lane configuration is available"
  as I changed formatting.
- Link to v2: https://lore.kernel.org/r/20251204-qcom-cphy-v2-0-6b35ef8b071e@ixit.cz

Changes in v2:
- This is still WIP patch series, thus I wanted to publish already
  changed parts to get feedback regarding to the direction of patchset.
- When switch to using odd bits, zeroed val which was left unitialized in v1.
- Accidentally missed archs added back in the commit moving lane regs to
  new location.
- Remove commit with reverting check for only D-PHY is supported and
  adjusted the check to also account for C-PHY.
- Documented link frequency calculation with defines. (Casey)
- Changed the cphy boolean to phy_cfg enum in the camss/camss-csiphy.
  (Brian)
- Added patch for csiphy-3ph enablement for sm7280 from Luca as I'm
  meanwhile trying to bring up the C-PHY sensor on FairPhone 5.
- Merged these two commits together
    csiphy-3ph: Enable sdm845 C-PHY sequence
    csiphy-3ph: Add Gen2 v1.1 MIPI CSI-2 CPHY init
  merged R-b.
- Link to v1: https://lore.kernel.org/r/20251109-qcom-cphy-v1-0-165f7e79b0e1@ixit.cz

---
Casey Connolly (1):
      media: qcom: camss: csiphy-3ph: Add Gen2 v1.1 MIPI CSI-2 CPHY init

David Heidelberg (6):
      media: qcom: camss: csiphy: Introduce PHY configuration
      media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes
      media: qcom: camss: Prepare CSID for C-PHY support
      media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
      media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration
      media: qcom: camss: Account for C-PHY when calculating link frequency

Luca Weiss (1):
      media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init

Petr Hodina (1):
      media: qcom: camss: Initialize lanes after lane configuration is available

 .../media/platform/qcom/camss/camss-csid-gen2.c    |   1 +
 drivers/media/platform/qcom/camss/camss-csid.c     |  12 +-
 drivers/media/platform/qcom/camss/camss-csid.h     |   1 +
 .../platform/qcom/camss/camss-csiphy-2ph-1-0.c     |   8 +-
 .../platform/qcom/camss/camss-csiphy-3ph-1-0.c     | 336 ++++++++++++++++++---
 drivers/media/platform/qcom/camss/camss-csiphy.c   |  11 +-
 drivers/media/platform/qcom/camss/camss-csiphy.h   |   8 +-
 drivers/media/platform/qcom/camss/camss.c          |  36 ++-
 drivers/media/platform/qcom/camss/camss.h          |   2 +-
 9 files changed, 342 insertions(+), 73 deletions(-)
---
base-commit: 3fa5e5702a82d259897bd7e209469bc06368bf31
change-id: 20251109-qcom-cphy-bb8cbda1c644

Best regards,
-- 
David Heidelberg <david@ixit.cz>



^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03  9:48   ` Bryan O'Donoghue
  2026-03-01  0:51 ` [PATCH WIP v4 2/9] media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes David Heidelberg via B4 Relay
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: David Heidelberg <david@ixit.cz>

Read PHY configuration from the device-tree bus-type and save it into
the csiphy structure for later use.

For C-PHY, skip clock line configuration, as there is none.

Signed-off-by: David Heidelberg <david@ixit.cz>
---
 drivers/media/platform/qcom/camss/camss-csiphy.h |  2 ++
 drivers/media/platform/qcom/camss/camss.c        | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
index 2d5054819df7f..d198171700e73 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.h
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
@@ -28,11 +28,13 @@ struct csiphy_lane {
 
 /**
  * struct csiphy_lanes_cfg - CSIPHY lanes configuration
+ * @phy_cfg:  interface selection (C-PHY or D-PHY)
  * @num_data: number of data lanes
  * @data:     data lanes configuration
  * @clk:      clock lane configuration (only for D-PHY)
  */
 struct csiphy_lanes_cfg {
+	enum v4l2_mbus_type phy_cfg;
 	int num_data;
 	struct csiphy_lane *data;
 	struct csiphy_lane clk;
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 00b87fd9afbd8..ea0c8cf3cd806 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -4411,11 +4411,11 @@ static int camss_parse_endpoint_node(struct device *dev,
 	if (ret)
 		return ret;
 
-	/*
-	 * Most SoCs support both D-PHY and C-PHY standards, but currently only
-	 * D-PHY is supported in the driver.
-	 */
-	if (vep.bus_type != V4L2_MBUS_CSI2_DPHY) {
+	switch (vep.bus_type) {
+	case V4L2_MBUS_CSI2_CPHY:
+	case V4L2_MBUS_CSI2_DPHY:
+		break;
+	default:
 		dev_err(dev, "Unsupported bus type %d\n", vep.bus_type);
 		return -EINVAL;
 	}
@@ -4423,9 +4423,13 @@ static int camss_parse_endpoint_node(struct device *dev,
 	csd->interface.csiphy_id = vep.base.port;
 
 	mipi_csi2 = &vep.bus.mipi_csi2;
-	lncfg->clk.pos = mipi_csi2->clock_lane;
-	lncfg->clk.pol = mipi_csi2->lane_polarities[0];
 	lncfg->num_data = mipi_csi2->num_data_lanes;
+	lncfg->phy_cfg = vep.bus_type;
+
+	if (lncfg->phy_cfg != V4L2_MBUS_CSI2_CPHY) {
+		lncfg->clk.pos = mipi_csi2->clock_lane;
+		lncfg->clk.pol = mipi_csi2->lane_polarities[0];
+	}
 
 	lncfg->data = devm_kcalloc(dev,
 				   lncfg->num_data, sizeof(*lncfg->data),

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 2/9] media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
  2026-03-01  0:51 ` [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03  9:52   ` Bryan O'Donoghue
  2026-03-01  0:51 ` [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support David Heidelberg via B4 Relay
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: David Heidelberg <david@ixit.cz>

So far, only D-PHY mode was supported, which uses even bits when enabling
or masking lanes. For C-PHY configuration, the hardware instead requires
using the odd bits.

Since there can be unrecognized configuration allow returning failure.

Signed-off-by: David Heidelberg <david@ixit.cz>
---
 .../platform/qcom/camss/camss-csiphy-2ph-1-0.c     |  8 ++--
 .../platform/qcom/camss/camss-csiphy-3ph-1-0.c     | 49 +++++++++++++++++-----
 drivers/media/platform/qcom/camss/camss-csiphy.c   |  5 +--
 drivers/media/platform/qcom/camss/camss-csiphy.h   |  6 +--
 4 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c
index 9d67e7fa6366a..bb4b91f69616b 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c
@@ -94,9 +94,9 @@ static u8 csiphy_settle_cnt_calc(s64 link_freq, u32 timer_clk_rate)
 	return settle_cnt;
 }
 
-static void csiphy_lanes_enable(struct csiphy_device *csiphy,
-				struct csiphy_config *cfg,
-				s64 link_freq, u8 lane_mask)
+static int csiphy_lanes_enable(struct csiphy_device *csiphy,
+			       struct csiphy_config *cfg,
+			       s64 link_freq, u8 lane_mask)
 {
 	struct csiphy_lanes_cfg *c = &cfg->csi2->lane_cfg;
 	u8 settle_cnt;
@@ -132,6 +132,8 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy,
 		writel_relaxed(0x3f, csiphy->base +
 			       CAMSS_CSI_PHY_INTERRUPT_CLEARn(l));
 	}
+
+	return 0;
 }
 
 static void csiphy_lanes_disable(struct csiphy_device *csiphy,
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
index 4154832745525..cf83c9e062b81 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/media-bus-format.h>
 
 #define CSIPHY_3PH_LNn_CFG1(n)			(0x000 + 0x100 * (n))
 #define CSIPHY_3PH_LNn_CFG1_SWI_REC_DLY_PRG	(BIT(7) | BIT(6))
@@ -993,13 +994,22 @@ static void csiphy_gen2_config_lanes(struct csiphy_device *csiphy,
 
 static u8 csiphy_get_lane_mask(struct csiphy_lanes_cfg *lane_cfg)
 {
-	u8 lane_mask;
-	int i;
+	u8 lane_mask = 0;
 
-	lane_mask = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
+	switch (lane_cfg->phy_cfg) {
+	case V4L2_MBUS_CSI2_CPHY:
+		for (int i = 0; i < lane_cfg->num_data; i++)
+			lane_mask |= BIT(lane_cfg->data[i].pos + 1);
+		break;
+	case V4L2_MBUS_CSI2_DPHY:
+		lane_mask = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
 
-	for (i = 0; i < lane_cfg->num_data; i++)
-		lane_mask |= 1 << lane_cfg->data[i].pos;
+		for (int i = 0; i < lane_cfg->num_data; i++)
+			lane_mask |= BIT(lane_cfg->data[i].pos);
+		break;
+	default:
+		break;
+	}
 
 	return lane_mask;
 }
@@ -1027,10 +1037,11 @@ static bool csiphy_is_gen2(u32 version)
 	return ret;
 }
 
-static void csiphy_lanes_enable(struct csiphy_device *csiphy,
-				struct csiphy_config *cfg,
-				s64 link_freq, u8 lane_mask)
+static int csiphy_lanes_enable(struct csiphy_device *csiphy,
+			       struct csiphy_config *cfg,
+			       s64 link_freq, u8 lane_mask)
 {
+	struct device *dev = csiphy->camss->dev;
 	struct csiphy_lanes_cfg *c = &cfg->csi2->lane_cfg;
 	struct csiphy_device_regs *regs = csiphy->regs;
 	u8 settle_cnt;
@@ -1039,9 +1050,23 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy,
 
 	settle_cnt = csiphy_settle_cnt_calc(link_freq, csiphy->timer_clk_rate);
 
-	val = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
-	for (i = 0; i < c->num_data; i++)
-		val |= BIT(c->data[i].pos * 2);
+	val = 0;
+
+	switch (c->phy_cfg) {
+	case V4L2_MBUS_CSI2_CPHY:
+		for (i = 0; i < c->num_data; i++)
+			val |= BIT((c->data[i].pos * 2) + 1);
+		break;
+	case V4L2_MBUS_CSI2_DPHY:
+		val = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
+
+		for (i = 0; i < c->num_data; i++)
+			val |= BIT(c->data[i].pos * 2);
+		break;
+	default:
+		dev_err(dev, "Unsupported bus type %d\n", c->phy_cfg);
+		return -EINVAL;
+	}
 
 	writel_relaxed(val, csiphy->base +
 		       CSIPHY_3PH_CMN_CSI_COMMON_CTRLn(regs->offset, 5));
@@ -1068,6 +1093,8 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy,
 		writel_relaxed(0, csiphy->base +
 			       CSIPHY_3PH_CMN_CSI_COMMON_CTRLn(regs->offset, i));
 	}
+
+	return 0;
 }
 
 static void csiphy_lanes_disable(struct csiphy_device *csiphy,
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index 62623393f4144..938600f3defe1 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -265,6 +265,7 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
 static int csiphy_stream_on(struct csiphy_device *csiphy)
 {
 	struct csiphy_config *cfg = &csiphy->cfg;
+	const struct csiphy_hw_ops *ops = csiphy->res->hw_ops;
 	s64 link_freq;
 	u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg);
 	u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
@@ -295,9 +296,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
 		wmb();
 	}
 
-	csiphy->res->hw_ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
-
-	return 0;
+	return ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
 }
 
 /*
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
index d198171700e73..21cf2ce931c1d 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.h
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
@@ -73,9 +73,9 @@ struct csiphy_hw_ops {
 	void (*hw_version_read)(struct csiphy_device *csiphy,
 				struct device *dev);
 	void (*reset)(struct csiphy_device *csiphy);
-	void (*lanes_enable)(struct csiphy_device *csiphy,
-			     struct csiphy_config *cfg,
-			     s64 link_freq, u8 lane_mask);
+	int (*lanes_enable)(struct csiphy_device *csiphy,
+			    struct csiphy_config *cfg,
+			    s64 link_freq, u8 lane_mask);
 	void (*lanes_disable)(struct csiphy_device *csiphy,
 			      struct csiphy_config *cfg);
 	irqreturn_t (*isr)(int irq, void *dev);

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
  2026-03-01  0:51 ` [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration David Heidelberg via B4 Relay
  2026-03-01  0:51 ` [PATCH WIP v4 2/9] media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03  9:53   ` Bryan O'Donoghue
  2026-03-01  0:51 ` [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available David Heidelberg via B4 Relay
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: David Heidelberg <david@ixit.cz>

Inherit C-PHY information from CSIPHY, so we can configure CSID
properly.

CSI2_RX_CFG0_PHY_TYPE_SEL must be set to 1, when C-PHY mode is used.

Signed-off-by: David Heidelberg <david@ixit.cz>
---
 drivers/media/platform/qcom/camss/camss-csid-gen2.c | 1 +
 drivers/media/platform/qcom/camss/camss-csid.c      | 1 +
 drivers/media/platform/qcom/camss/camss-csid.h      | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
index 2a1746dcc1c5b..033036ae28a4f 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
@@ -183,6 +183,7 @@ static void __csid_configure_rx(struct csid_device *csid,
 	val = (lane_cnt - 1) << CSI2_RX_CFG0_NUM_ACTIVE_LANES;
 	val |= phy->lane_assign << CSI2_RX_CFG0_DL0_INPUT_SEL;
 	val |= phy->csiphy_id << CSI2_RX_CFG0_PHY_NUM_SEL;
+	val |= csid->phy.cphy << CSI2_RX_CFG0_PHY_TYPE_SEL;
 	writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG0);
 
 	val = 1 << CSI2_RX_CFG1_PACKET_ECC_CORRECTION_EN;
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index ed1820488c987..b50b0cfe280c1 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -1275,6 +1275,7 @@ static int csid_link_setup(struct media_entity *entity,
 		csid->phy.csiphy_id = csiphy->id;
 
 		lane_cfg = &csiphy->cfg.csi2->lane_cfg;
+		csid->phy.cphy = (lane_cfg->phy_cfg == V4L2_MBUS_CSI2_CPHY);
 		csid->phy.lane_cnt = lane_cfg->num_data;
 		csid->phy.lane_assign = csid_get_lane_assign(lane_cfg);
 	}
diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
index aedc96ed84b2f..a82db31bd2335 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.h
+++ b/drivers/media/platform/qcom/camss/camss-csid.h
@@ -70,6 +70,7 @@ struct csid_phy_config {
 	u32 lane_assign;
 	u32 en_vc;
 	u8 need_vc_update;
+	bool cphy;
 };
 
 struct csid_device;

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
                   ` (2 preceding siblings ...)
  2026-03-01  0:51 ` [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03  9:54   ` Bryan O'Donoghue
  2026-03-01  0:51 ` [PATCH WIP v4 5/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.1 MIPI CSI-2 CPHY init David Heidelberg via B4 Relay
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: Petr Hodina <phodina@protonmail.com>

The lanes must not be initialized before the driver has access to
the lane configuration, as it depends on whether D-PHY or C-PHY mode
is in use. Move the lane initialization to a later stage where the
configuration structures are available.

Signed-off-by: Petr Hodina <phodina@protonmail.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
---
 .../platform/qcom/camss/camss-csiphy-3ph-1-0.c     | 91 ++++++++++++++--------
 1 file changed, 57 insertions(+), 34 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
index cf83c9e062b81..9748208107222 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
@@ -1048,6 +1048,62 @@ static int csiphy_lanes_enable(struct csiphy_device *csiphy,
 	u8 val;
 	int i;
 
+	switch (csiphy->camss->res->version) {
+	case CAMSS_845:
+		{
+			regs->lane_regs = &lane_regs_sdm845[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sdm845);
+		}
+		break;
+	case CAMSS_2290:
+	case CAMSS_6150:
+		{
+			regs->lane_regs = &lane_regs_qcm2290[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_qcm2290);
+		}
+		break;
+	case CAMSS_7280:
+	case CAMSS_8250:
+		{
+			regs->lane_regs = &lane_regs_sm8250[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8250);
+		}
+		break;
+	case CAMSS_8280XP:
+		{
+			regs->lane_regs = &lane_regs_sc8280xp[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sc8280xp);
+		}
+		break;
+	case CAMSS_X1E80100:
+		{
+			regs->lane_regs = &lane_regs_x1e80100[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_x1e80100);
+		}
+		break;
+	case CAMSS_8550:
+		{
+			regs->lane_regs = &lane_regs_sm8550[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8550);
+		}
+		break;
+	case CAMSS_8650:
+		{
+			regs->lane_regs = &lane_regs_sm8650[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8650);
+		}
+		break;
+	case CAMSS_8300:
+	case CAMSS_8775P:
+		{
+			regs->lane_regs = &lane_regs_sa8775p[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sa8775p);
+		}
+		break;
+	default:
+		break;
+	}
+
 	settle_cnt = csiphy_settle_cnt_calc(link_freq, csiphy->timer_clk_rate);
 
 	val = 0;
@@ -1119,49 +1175,16 @@ static int csiphy_init(struct csiphy_device *csiphy)
 		return -ENOMEM;
 
 	csiphy->regs = regs;
-	regs->offset = 0x800;
 	regs->common_status_offset = 0xb0;
 
 	switch (csiphy->camss->res->version) {
-	case CAMSS_845:
-		regs->lane_regs = &lane_regs_sdm845[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_sdm845);
-		break;
-	case CAMSS_2290:
-	case CAMSS_6150:
-		regs->lane_regs = &lane_regs_qcm2290[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_qcm2290);
-		break;
-	case CAMSS_7280:
-	case CAMSS_8250:
-		regs->lane_regs = &lane_regs_sm8250[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8250);
-		break;
-	case CAMSS_8280XP:
-		regs->lane_regs = &lane_regs_sc8280xp[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_sc8280xp);
-		break;
 	case CAMSS_X1E80100:
-		regs->lane_regs = &lane_regs_x1e80100[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_x1e80100);
-		regs->offset = 0x1000;
-		break;
 	case CAMSS_8550:
-		regs->lane_regs = &lane_regs_sm8550[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8550);
-		regs->offset = 0x1000;
-		break;
 	case CAMSS_8650:
-		regs->lane_regs = &lane_regs_sm8650[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8650);
 		regs->offset = 0x1000;
 		break;
-	case CAMSS_8300:
-	case CAMSS_8775P:
-		regs->lane_regs = &lane_regs_sa8775p[0];
-		regs->lane_array_size = ARRAY_SIZE(lane_regs_sa8775p);
-		break;
 	default:
+		regs->offset = 0x800;
 		break;
 	}
 

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 5/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
                   ` (3 preceding siblings ...)
  2026-03-01  0:51 ` [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-01  0:51 ` [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update " David Heidelberg via B4 Relay
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: Casey Connolly <casey.connolly@linaro.org>

Add a PHY configuration sequence for the sdm845 which uses a Qualcomm
Gen 2 version 1.1 CSI-2 PHY.

The PHY can be configured as two phase or three phase in C-PHY or D-PHY
mode. This configuration supports three-phase C-PHY mode.

Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Co-developed-by: David Heidelberg <david@ixit.cz>
Signed-off-by: David Heidelberg <david@ixit.cz>
---
 .../platform/qcom/camss/camss-csiphy-3ph-1-0.c     | 72 +++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
index 9748208107222..5482fb5163e17 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
@@ -146,6 +146,7 @@ csiphy_lane_regs lane_regs_sa8775p[] = {
 };
 
 /* GEN2 1.0 2PH */
+/* 5 entries: clock + 4 lanes */
 static const struct
 csiphy_lane_regs lane_regs_sdm845[] = {
 	{0x0004, 0x0C, 0x00, CSIPHY_DEFAULT_PARAMS},
@@ -220,6 +221,71 @@ csiphy_lane_regs lane_regs_sdm845[] = {
 	{0x0664, 0x7F, 0x00, CSIPHY_DEFAULT_PARAMS},
 };
 
+/* GEN2 1.0 3PH */
+/* 3 entries: 3 lanes (C-PHY) */
+static const struct
+csiphy_lane_regs lane_regs_sdm845_3ph[] = {
+	{0x015c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x016c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
+	{0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
+	{0x0114, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0150, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0118, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x011c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0120, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0124, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0128, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x012c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0144, 0x12, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0160, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x01cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0164, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x01dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
+
+	{0x035c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x036c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
+	{0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
+	{0x0314, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0350, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0318, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x031c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0320, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0324, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0328, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x032c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0344, 0x12, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0360, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x03cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0364, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x03dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
+
+	{0x055c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x056c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
+	{0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
+	{0x0514, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0550, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0518, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x051c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0520, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0524, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0528, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x052c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0544, 0x12, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0560, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x05cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0564, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x05dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
+};
+
 /* GEN2 1.1 2PH */
 static const struct
 csiphy_lane_regs lane_regs_sc8280xp[] = {
@@ -1050,7 +1116,11 @@ static int csiphy_lanes_enable(struct csiphy_device *csiphy,
 
 	switch (csiphy->camss->res->version) {
 	case CAMSS_845:
-		{
+		if (c->phy_cfg == V4L2_MBUS_CSI2_CPHY) {
+			regs->lane_regs = &lane_regs_sdm845_3ph[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sdm845_3ph);
+
+		} else {
 			regs->lane_regs = &lane_regs_sdm845[0];
 			regs->lane_array_size = ARRAY_SIZE(lane_regs_sdm845);
 		}

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
                   ` (4 preceding siblings ...)
  2026-03-01  0:51 ` [PATCH WIP v4 5/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.1 MIPI CSI-2 CPHY init David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03  9:55   ` Bryan O'Donoghue
  2026-03-01  0:51 ` [PATCH WIP v4 7/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init David Heidelberg via B4 Relay
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: David Heidelberg <david@ixit.cz>

These values should improve C-PHY behaviour. Should match most recent
Qualcomm code.

Signed-off-by: David Heidelberg <david@ixit.cz>
---
 .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c   | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
index 5482fb5163e17..c612192ee727a 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
@@ -225,9 +225,9 @@ csiphy_lane_regs lane_regs_sdm845[] = {
 /* 3 entries: 3 lanes (C-PHY) */
 static const struct
 csiphy_lane_regs lane_regs_sdm845_3ph[] = {
-	{0x015c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
-	{0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
-	{0x016c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x015c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0168, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x016c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
 	{0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
@@ -245,9 +245,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
 	{0x0164, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x01dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
 
-	{0x035c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
-	{0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
-	{0x036c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x035c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0368, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x036c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
 	{0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
@@ -265,9 +265,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
 	{0x0364, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x03dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
 
-	{0x055c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
-	{0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
-	{0x056c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x055c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0568, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x056c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
 	{0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
 	{0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 7/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
                   ` (5 preceding siblings ...)
  2026-03-01  0:51 ` [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update " David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03  9:56   ` Bryan O'Donoghue
  2026-03-01  0:51 ` [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration David Heidelberg via B4 Relay
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: Luca Weiss <luca.weiss@fairphone.com>

Add a PHY configuration sequence for the sm8250 which uses a Qualcomm
Gen 2 version 1.2.1 CSI-2 PHY.

The PHY can be configured as two phase or three phase in C-PHY or D-PHY
mode. This configuration supports three-phase C-PHY mode.

Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
---
 .../platform/qcom/camss/camss-csiphy-3ph-1-0.c     | 112 ++++++++++++++++++++-
 1 file changed, 111 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
index c612192ee727a..e48f5c1290173 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
@@ -550,6 +550,113 @@ csiphy_lane_regs lane_regs_qcm2290[] = {
 	{0x0664, 0x3f, 0x00, CSIPHY_DEFAULT_PARAMS},
 };
 
+/* GEN2 1.2.1 3PH */
+/* 3 entries: 3 lanes (C-PHY) */
+static const struct
+csiphy_lane_regs lane_regs_sm8250_3ph[] = {
+	{0x0990, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0994, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0998, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0990, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0994, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0998, 0x1a, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x098c, 0xaf, 0x01, CSIPHY_DEFAULT_PARAMS},
+	{0x015c, 0x46, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
+	{0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
+	{0x0114, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0150, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0188, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x018c, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0190, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0118, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x011c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0120, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0124, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0128, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x012c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0160, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x01cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x01dc, 0x50, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0984, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0988, 0x05, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0980, 0x60, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x09ac, 0x35, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x09b0, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0800, 0x0e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0884, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
+
+	{0x0a90, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a94, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a98, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a90, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a94, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a98, 0x1a, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a8c, 0xaf, 0x01, CSIPHY_DEFAULT_PARAMS},
+	{0x035c, 0x46, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
+	{0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
+	{0x0314, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0350, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0388, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x038c, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0390, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0318, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x031c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0320, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0324, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0328, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x032c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0360, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x03cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x03dc, 0x50, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a84, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a88, 0x05, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0a80, 0x60, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0aac, 0x35, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0ab0, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0800, 0x0e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0884, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
+
+	{0x0b90, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b94, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b98, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b90, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b94, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b98, 0x1a, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b8c, 0xaf, 0x01, CSIPHY_DEFAULT_PARAMS},
+	{0x055c, 0x46, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
+	{0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
+	{0x0514, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0550, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0588, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x058c, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0590, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0518, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x051c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0520, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0524, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0528, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x052c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0560, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x05cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x05dc, 0x50, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b84, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b88, 0x05, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0b80, 0x60, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0bac, 0x35, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0bb0, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0800, 0x0e, 0x00, CSIPHY_DEFAULT_PARAMS},
+	{0x0884, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
+};
+
 /* GEN2 2.1.2 2PH DPHY mode */
 static const struct
 csiphy_lane_regs lane_regs_sm8550[] = {
@@ -1134,7 +1241,10 @@ static int csiphy_lanes_enable(struct csiphy_device *csiphy,
 		break;
 	case CAMSS_7280:
 	case CAMSS_8250:
-		{
+		if (c->phy_cfg == V4L2_MBUS_CSI2_CPHY) {
+			regs->lane_regs = &lane_regs_sm8250_3ph[0];
+			regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8250_3ph);
+		} else {
 			regs->lane_regs = &lane_regs_sm8250[0];
 			regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8250);
 		}

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
                   ` (6 preceding siblings ...)
  2026-03-01  0:51 ` [PATCH WIP v4 7/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03  9:59   ` Bryan O'Donoghue
  2026-03-01  0:51 ` [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency David Heidelberg via B4 Relay
  2026-03-02 18:43 ` [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms Cory Keitz
  9 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: David Heidelberg <david@ixit.cz>

Catch when C-PHY configuration gets used on SoC with CAMSS missing C-PHY
configuration lane registers.

Hopefully this check will disappear as these lane regs gets populated.

--
@bod
Proliferating special cases in switch statements on a per-SoC basis is
verboten.

Please find another way to do this, you already have a bool to indicate
cphy in struct csid_phy_config {} so at some level CAMSS already has a
bool to indicate what to do.

Please make that logic accessible to logical consumers throughout,
in this case the CPHY code.
--

Signed-off-by: David Heidelberg <david@ixit.cz>
---
 drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
index e48f5c1290173..2164647211c8d 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
@@ -1221,6 +1221,22 @@ static int csiphy_lanes_enable(struct csiphy_device *csiphy,
 	u8 val;
 	int i;
 
+	if (c->phy_cfg == V4L2_MBUS_CSI2_CPHY) {
+		switch (csiphy->camss->res->version) {
+		case CAMSS_2290:
+		case CAMSS_8280XP:
+		case CAMSS_X1E80100:
+		case CAMSS_8550:
+		case CAMSS_8650:
+		case CAMSS_8300:
+		case CAMSS_8775P:
+			dev_err(dev, "Missing lane_regs definition for C-PHY\n");
+			return -EINVAL;
+		default:
+			break;
+		}
+	}
+
 	switch (csiphy->camss->res->version) {
 	case CAMSS_845:
 		if (c->phy_cfg == V4L2_MBUS_CSI2_CPHY) {

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
                   ` (7 preceding siblings ...)
  2026-03-01  0:51 ` [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration David Heidelberg via B4 Relay
@ 2026-03-01  0:51 ` David Heidelberg via B4 Relay
  2026-03-03 10:07   ` Bryan O'Donoghue
  2026-03-20 19:48   ` Cory Keitz
  2026-03-02 18:43 ` [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms Cory Keitz
  9 siblings, 2 replies; 31+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-03-01  0:51 UTC (permalink / raw)
  To: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel,
	David Heidelberg

From: David Heidelberg <david@ixit.cz>

Ensure that the link frequency divider correctly accounts for C-PHY
operation. The divider differs between D-PHY and C-PHY, as described
in the MIPI CSI-2 specification.

For more details, see:
https://docs.kernel.org/driver-api/media/tx-rx.html#pixel-rate

Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
---
 drivers/media/platform/qcom/camss/camss-csid.c   | 11 +++++++----
 drivers/media/platform/qcom/camss/camss-csiphy.c |  6 ++----
 drivers/media/platform/qcom/camss/camss.c        | 18 +++++++++++++++---
 drivers/media/platform/qcom/camss/camss.h        |  2 +-
 4 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index b50b0cfe280c1..2fc17c6a15e2e 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -534,18 +534,21 @@ const struct csid_format_info *csid_get_fmt_entry(const struct csid_format_info
  * csid_set_clock_rates - Calculate and set clock rates on CSID module
  * @csiphy: CSID device
  */
-static int csid_set_clock_rates(struct csid_device *csid)
+static int csid_set_clock_rates(struct v4l2_subdev *sd, struct csid_device *csid)
 {
 	struct device *dev = csid->camss->dev;
+	struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
+	struct csiphy_lanes_cfg *lane_cfg = &csiphy->cfg.csi2->lane_cfg;
 	const struct csid_format_info *fmt;
+
 	s64 link_freq;
 	int i, j;
 	int ret;
 
 	fmt = csid_get_fmt_entry(csid->res->formats->formats, csid->res->formats->nformats,
 				 csid->fmt[MSM_CSIPHY_PAD_SINK].code);
-	link_freq = camss_get_link_freq(&csid->subdev.entity, fmt->bpp,
-					csid->phy.lane_cnt);
+
+	link_freq = camss_get_link_freq(&csid->subdev.entity, fmt->bpp, lane_cfg);
 	if (link_freq < 0)
 		link_freq = 0;
 
@@ -703,7 +706,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 			return ret;
 		}
 
-		ret = csid_set_clock_rates(csid);
+		ret = csid_set_clock_rates(sd, csid);
 		if (ret < 0) {
 			regulator_bulk_disable(csid->num_supplies,
 					       csid->supplies);
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index 938600f3defe1..ea9dd2cd2e740 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -143,9 +143,8 @@ static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
 
 	u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
 				csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
-	u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
 
-	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes);
+	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, &csiphy->cfg.csi2->lane_cfg);
 	if (link_freq < 0)
 		link_freq  = 0;
 
@@ -270,10 +269,9 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
 	u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg);
 	u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
 				csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
-	u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
 	u8 val;
 
-	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes);
+	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, &csiphy->cfg.csi2->lane_cfg);
 
 	if (link_freq < 0) {
 		dev_err(csiphy->camss->dev,
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index ea0c8cf3cd806..4c13bae17007e 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -32,6 +32,14 @@
 #define CAMSS_CLOCK_MARGIN_NUMERATOR 105
 #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
 
+/*
+ * C-PHY encodes data by 16/7 ~ 2.28 bits/symbol
+ * D-PHY doesn't encode data, thus 16/16 = 1 b/s
+ */
+#define CAMSS_COMMON_PHY_DIVIDENT 16
+#define CAMSS_CPHY_DIVISOR 7
+#define CAMSS_DPHY_DIVISOR 16
+
 static const struct parent_dev_ops vfe_parent_dev_ops;
 
 static const struct camss_subdev_resources csiphy_res_8x16[] = {
@@ -4280,20 +4288,24 @@ struct media_pad *camss_find_sensor_pad(struct media_entity *entity)
  * camss_get_link_freq - Get link frequency from sensor
  * @entity: Media entity in the current pipeline
  * @bpp: Number of bits per pixel for the current format
- * @lanes: Number of lanes in the link to the sensor
+ * @lane_cfg: CSI2 lane configuration
  *
  * Return link frequency on success or a negative error code otherwise
  */
 s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
-			unsigned int lanes)
+			struct csiphy_lanes_cfg *lane_cfg)
 {
 	struct media_pad *sensor_pad;
+	u8 num_lanes = lane_cfg->num_data;
+	bool cphy = lane_cfg->phy_cfg == V4L2_MBUS_CSI2_CPHY;
+	unsigned int div = num_lanes * 2 * (cphy ? CAMSS_CPHY_DIVISOR :
+						     CAMSS_DPHY_DIVISOR);
 
 	sensor_pad = camss_find_sensor_pad(entity);
 	if (!sensor_pad)
 		return -ENODEV;
 
-	return v4l2_get_link_freq(sensor_pad, bpp, 2 * lanes);
+	return v4l2_get_link_freq(sensor_pad, CAMSS_COMMON_PHY_DIVIDENT * bpp, div);
 }
 
 /*
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index 6d048414c919e..67be42b4c9174 100644
--- a/drivers/media/platform/qcom/camss/camss.h
+++ b/drivers/media/platform/qcom/camss/camss.h
@@ -163,7 +163,7 @@ int camss_enable_clocks(int nclocks, struct camss_clock *clock,
 void camss_disable_clocks(int nclocks, struct camss_clock *clock);
 struct media_pad *camss_find_sensor_pad(struct media_entity *entity);
 s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
-			unsigned int lanes);
+			struct csiphy_lanes_cfg *lane_cfg);
 int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock);
 int camss_pm_domain_on(struct camss *camss, int id);
 void camss_pm_domain_off(struct camss *camss, int id);

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms
  2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
                   ` (8 preceding siblings ...)
  2026-03-01  0:51 ` [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency David Heidelberg via B4 Relay
@ 2026-03-02 18:43 ` Cory Keitz
  2026-03-02 23:13   ` David Heidelberg
  9 siblings, 1 reply; 31+ messages in thread
From: Cory Keitz @ 2026-03-02 18:43 UTC (permalink / raw)
  To: David Heidelberg
  Cc: linux-media, linux-arm-msm, Bryan O'Donoghue, Kieran Bingham,
	Cory Keitz

Hi David,

I've been working on CPHY support for sa8775p / csid-gen3 on 6.6 and have a
similar patch set. The approach here aligns well with what I've done, good to
see this infrastructure going upstream. I've implemented the following for
SA8775P that can be added on top of your series once it lands:

- CSI2_RX_CFG0_PHY_TYPE_SEL in camss-csid-gen3.c
- CSIPHY v1.3.1 register tables for sa8775p
- Data rate-specific tuning for 5 bandwidth tiers (1.5/1.7/2.5/3.5/4.5 Gsps)

I've only tested on a 6.6 kernel so far, not on mainline, so I can't give a
Tested-by yet. I can confirm the settle count calculation and PHY selection
approach are in line with what I have tested.

Acked-by: Cory Keitz <ckeitz@amazon.com>

Thanks,
Cory

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms
  2026-03-02 18:43 ` [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms Cory Keitz
@ 2026-03-02 23:13   ` David Heidelberg
  0 siblings, 0 replies; 31+ messages in thread
From: David Heidelberg @ 2026-03-02 23:13 UTC (permalink / raw)
  To: Cory Keitz
  Cc: linux-media, linux-arm-msm, Bryan O'Donoghue, Kieran Bingham

On 02/03/2026 19:43, Cory Keitz wrote:
> Hi David,
> 
> I've been working on CPHY support for sa8775p / csid-gen3 on 6.6 and have a
> similar patch set. The approach here aligns well with what I've done, good to
> see this infrastructure going upstream. I've implemented the following for
> SA8775P that can be added on top of your series once it lands:
> 
> - CSI2_RX_CFG0_PHY_TYPE_SEL in camss-csid-gen3.c
> - CSIPHY v1.3.1 register tables for sa8775p
> - Data rate-specific tuning for 5 bandwidth tiers (1.5/1.7/2.5/3.5/4.5 Gsps)
> 
> I've only tested on a 6.6 kernel so far, not on mainline, so I can't give a
> Tested-by yet. I can confirm the settle count calculation and PHY selection
> approach are in line with what I have tested.
> 
> Acked-by: Cory Keitz <ckeitz@amazon.com>
> 
> Thanks,
> Cory

Hello Cory,

happy to hear we're not only one potential users of C-PHY in mainline.

Thank you for the validation.

I added you into the Cc for followup patchset versions!

David

-- 
David Heidelberg


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration
  2026-03-01  0:51 ` [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration David Heidelberg via B4 Relay
@ 2026-03-03  9:48   ` Bryan O'Donoghue
  0 siblings, 0 replies; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03  9:48 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
> 
> Read PHY configuration from the device-tree bus-type and save it into
> the csiphy structure for later use.
> 
> For C-PHY, skip clock line configuration, as there is none.
> 
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>   drivers/media/platform/qcom/camss/camss-csiphy.h |  2 ++
>   drivers/media/platform/qcom/camss/camss.c        | 18 +++++++++++-------
>   2 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
> index 2d5054819df7f..d198171700e73 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.h
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
> @@ -28,11 +28,13 @@ struct csiphy_lane {
>   
>   /**
>    * struct csiphy_lanes_cfg - CSIPHY lanes configuration
> + * @phy_cfg:  interface selection (C-PHY or D-PHY)
>    * @num_data: number of data lanes
>    * @data:     data lanes configuration
>    * @clk:      clock lane configuration (only for D-PHY)
>    */
>   struct csiphy_lanes_cfg {
> +	enum v4l2_mbus_type phy_cfg;
>   	int num_data;
>   	struct csiphy_lane *data;
>   	struct csiphy_lane clk;
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 00b87fd9afbd8..ea0c8cf3cd806 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -4411,11 +4411,11 @@ static int camss_parse_endpoint_node(struct device *dev,
>   	if (ret)
>   		return ret;
>   
> -	/*
> -	 * Most SoCs support both D-PHY and C-PHY standards, but currently only
> -	 * D-PHY is supported in the driver.
> -	 */
> -	if (vep.bus_type != V4L2_MBUS_CSI2_DPHY) {
> +	switch (vep.bus_type) {
> +	case V4L2_MBUS_CSI2_CPHY:
> +	case V4L2_MBUS_CSI2_DPHY:
> +		break;
> +	default:
>   		dev_err(dev, "Unsupported bus type %d\n", vep.bus_type);
>   		return -EINVAL;
>   	}
> @@ -4423,9 +4423,13 @@ static int camss_parse_endpoint_node(struct device *dev,
>   	csd->interface.csiphy_id = vep.base.port;
>   
>   	mipi_csi2 = &vep.bus.mipi_csi2;
> -	lncfg->clk.pos = mipi_csi2->clock_lane;
> -	lncfg->clk.pol = mipi_csi2->lane_polarities[0];
>   	lncfg->num_data = mipi_csi2->num_data_lanes;
> +	lncfg->phy_cfg = vep.bus_type;
> +
> +	if (lncfg->phy_cfg != V4L2_MBUS_CSI2_CPHY) {
> +		lncfg->clk.pos = mipi_csi2->clock_lane;
> +		lncfg->clk.pol = mipi_csi2->lane_polarities[0];
> +	}
>   
>   	lncfg->data = devm_kcalloc(dev,
>   				   lncfg->num_data, sizeof(*lncfg->data),
> 

This patch should come last in the series - i.e. it should be invalid to 
select CPHY mode until all of the other code has advanced to accommodate.

I guess you end up depending on this variable a little later on.

I think this patch looks good with the one caveat that I'd like 
bisectability here.

So perhaps take the switch statement and have that part be a last patch 
at the end formally enabling CPHY mode.

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 2/9] media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes
  2026-03-01  0:51 ` [PATCH WIP v4 2/9] media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes David Heidelberg via B4 Relay
@ 2026-03-03  9:52   ` Bryan O'Donoghue
  0 siblings, 0 replies; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03  9:52 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
> 
> So far, only D-PHY mode was supported, which uses even bits when enabling
> or masking lanes. For C-PHY configuration, the hardware instead requires
> using the odd bits.
> 
> Since there can be unrecognized configuration allow returning failure.
> 
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>   .../platform/qcom/camss/camss-csiphy-2ph-1-0.c     |  8 ++--
>   .../platform/qcom/camss/camss-csiphy-3ph-1-0.c     | 49 +++++++++++++++++-----
>   drivers/media/platform/qcom/camss/camss-csiphy.c   |  5 +--
>   drivers/media/platform/qcom/camss/camss-csiphy.h   |  6 +--
>   4 files changed, 48 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c
> index 9d67e7fa6366a..bb4b91f69616b 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c
> @@ -94,9 +94,9 @@ static u8 csiphy_settle_cnt_calc(s64 link_freq, u32 timer_clk_rate)
>   	return settle_cnt;
>   }
>   
> -static void csiphy_lanes_enable(struct csiphy_device *csiphy,
> -				struct csiphy_config *cfg,
> -				s64 link_freq, u8 lane_mask)
> +static int csiphy_lanes_enable(struct csiphy_device *csiphy,
> +			       struct csiphy_config *cfg,
> +			       s64 link_freq, u8 lane_mask)
>   {
>   	struct csiphy_lanes_cfg *c = &cfg->csi2->lane_cfg;
>   	u8 settle_cnt;
> @@ -132,6 +132,8 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy,
>   		writel_relaxed(0x3f, csiphy->base +
>   			       CAMSS_CSI_PHY_INTERRUPT_CLEARn(l));
>   	}
> +
> +	return 0;
>   }
>   
>   static void csiphy_lanes_disable(struct csiphy_device *csiphy,
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> index 4154832745525..cf83c9e062b81 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> @@ -14,6 +14,7 @@
>   #include <linux/delay.h>
>   #include <linux/interrupt.h>
>   #include <linux/io.h>
> +#include <linux/media-bus-format.h>
>   
>   #define CSIPHY_3PH_LNn_CFG1(n)			(0x000 + 0x100 * (n))
>   #define CSIPHY_3PH_LNn_CFG1_SWI_REC_DLY_PRG	(BIT(7) | BIT(6))
> @@ -993,13 +994,22 @@ static void csiphy_gen2_config_lanes(struct csiphy_device *csiphy,
>   
>   static u8 csiphy_get_lane_mask(struct csiphy_lanes_cfg *lane_cfg)
>   {
> -	u8 lane_mask;
> -	int i;
> +	u8 lane_mask = 0;
>   
> -	lane_mask = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
> +	switch (lane_cfg->phy_cfg) {
> +	case V4L2_MBUS_CSI2_CPHY:
> +		for (int i = 0; i < lane_cfg->num_data; i++)
> +			lane_mask |= BIT(lane_cfg->data[i].pos + 1);
> +		break;
> +	case V4L2_MBUS_CSI2_DPHY:
> +		lane_mask = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
>   
> -	for (i = 0; i < lane_cfg->num_data; i++)
> -		lane_mask |= 1 << lane_cfg->data[i].pos;
> +		for (int i = 0; i < lane_cfg->num_data; i++)
> +			lane_mask |= BIT(lane_cfg->data[i].pos);
> +		break;
> +	default:
> +		break;
> +	}
>   
>   	return lane_mask;
>   }
> @@ -1027,10 +1037,11 @@ static bool csiphy_is_gen2(u32 version)
>   	return ret;
>   }
>   
> -static void csiphy_lanes_enable(struct csiphy_device *csiphy,
> -				struct csiphy_config *cfg,
> -				s64 link_freq, u8 lane_mask)
> +static int csiphy_lanes_enable(struct csiphy_device *csiphy,
> +			       struct csiphy_config *cfg,
> +			       s64 link_freq, u8 lane_mask)
>   {
> +	struct device *dev = csiphy->camss->dev;
>   	struct csiphy_lanes_cfg *c = &cfg->csi2->lane_cfg;
>   	struct csiphy_device_regs *regs = csiphy->regs;
>   	u8 settle_cnt;
> @@ -1039,9 +1050,23 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy,
>   
>   	settle_cnt = csiphy_settle_cnt_calc(link_freq, csiphy->timer_clk_rate);
>   
> -	val = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
> -	for (i = 0; i < c->num_data; i++)
> -		val |= BIT(c->data[i].pos * 2);
> +	val = 0;
> +
> +	switch (c->phy_cfg) {
> +	case V4L2_MBUS_CSI2_CPHY:
> +		for (i = 0; i < c->num_data; i++)
> +			val |= BIT((c->data[i].pos * 2) + 1);
> +		break;
> +	case V4L2_MBUS_CSI2_DPHY:
> +		val = CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE;
> +
> +		for (i = 0; i < c->num_data; i++)
> +			val |= BIT(c->data[i].pos * 2);
> +		break;
> +	default:
> +		dev_err(dev, "Unsupported bus type %d\n", c->phy_cfg);
> +		return -EINVAL;
> +	}
>   
>   	writel_relaxed(val, csiphy->base +
>   		       CSIPHY_3PH_CMN_CSI_COMMON_CTRLn(regs->offset, 5));
> @@ -1068,6 +1093,8 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy,
>   		writel_relaxed(0, csiphy->base +
>   			       CSIPHY_3PH_CMN_CSI_COMMON_CTRLn(regs->offset, i));
>   	}
> +
> +	return 0;
>   }
>   
>   static void csiphy_lanes_disable(struct csiphy_device *csiphy,
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index 62623393f4144..938600f3defe1 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> @@ -265,6 +265,7 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
>   static int csiphy_stream_on(struct csiphy_device *csiphy)
>   {
>   	struct csiphy_config *cfg = &csiphy->cfg;
> +	const struct csiphy_hw_ops *ops = csiphy->res->hw_ops;
>   	s64 link_freq;
>   	u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg);
>   	u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
> @@ -295,9 +296,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
>   		wmb();
>   	}
>   
> -	csiphy->res->hw_ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
> -
> -	return 0;
> +	return ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
>   }
>   
>   /*
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
> index d198171700e73..21cf2ce931c1d 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.h
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
> @@ -73,9 +73,9 @@ struct csiphy_hw_ops {
>   	void (*hw_version_read)(struct csiphy_device *csiphy,
>   				struct device *dev);
>   	void (*reset)(struct csiphy_device *csiphy);
> -	void (*lanes_enable)(struct csiphy_device *csiphy,
> -			     struct csiphy_config *cfg,
> -			     s64 link_freq, u8 lane_mask);
> +	int (*lanes_enable)(struct csiphy_device *csiphy,
> +			    struct csiphy_config *cfg,
> +			    s64 link_freq, u8 lane_mask);
>   	void (*lanes_disable)(struct csiphy_device *csiphy,
>   			      struct csiphy_config *cfg);
>   	irqreturn_t (*isr)(int irq, void *dev);
> 
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support
  2026-03-01  0:51 ` [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support David Heidelberg via B4 Relay
@ 2026-03-03  9:53   ` Bryan O'Donoghue
  2026-03-03 20:31     ` David Heidelberg
  0 siblings, 1 reply; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03  9:53 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
> +	bool cphy;

Same comment as before, you should have an enum not a bool.

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
  2026-03-01  0:51 ` [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available David Heidelberg via B4 Relay
@ 2026-03-03  9:54   ` Bryan O'Donoghue
  2026-03-03 10:06     ` David Heidelberg
  0 siblings, 1 reply; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03  9:54 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
>   Move the lane initialization to a later stage where the
> configuration structures are available.

You should specify which later phase in the commit log @ next rev.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-01  0:51 ` [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update " David Heidelberg via B4 Relay
@ 2026-03-03  9:55   ` Bryan O'Donoghue
  2026-03-03 10:00     ` David Heidelberg
  0 siblings, 1 reply; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03  9:55 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
> 
> These values should improve C-PHY behaviour. Should match most recent
> Qualcomm code.
> 
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>   .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c   | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> index 5482fb5163e17..c612192ee727a 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> @@ -225,9 +225,9 @@ csiphy_lane_regs lane_regs_sdm845[] = {
>   /* 3 entries: 3 lanes (C-PHY) */
>   static const struct
>   csiphy_lane_regs lane_regs_sdm845_3ph[] = {
> -	{0x015c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
> -	{0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
> -	{0x016c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x015c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0168, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x016c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>   	{0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
> @@ -245,9 +245,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>   	{0x0164, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x01dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>   
> -	{0x035c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
> -	{0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
> -	{0x036c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x035c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0368, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x036c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>   	{0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
> @@ -265,9 +265,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>   	{0x0364, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x03dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>   
> -	{0x055c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
> -	{0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
> -	{0x056c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x055c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0568, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x056c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>   	{0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>   	{0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
> 

Squash down and Co-developed-by

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 7/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init
  2026-03-01  0:51 ` [PATCH WIP v4 7/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init David Heidelberg via B4 Relay
@ 2026-03-03  9:56   ` Bryan O'Donoghue
  0 siblings, 0 replies; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03  9:56 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
> From: Luca Weiss <luca.weiss@fairphone.com>
> 
> Add a PHY configuration sequence for the sm8250 which uses a Qualcomm
> Gen 2 version 1.2.1 CSI-2 PHY.
> 
> The PHY can be configured as two phase or three phase in C-PHY or D-PHY
> mode. This configuration supports three-phase C-PHY mode.
> 
> Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>   .../platform/qcom/camss/camss-csiphy-3ph-1-0.c     | 112 ++++++++++++++++++++-
>   1 file changed, 111 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> index c612192ee727a..e48f5c1290173 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
> @@ -550,6 +550,113 @@ csiphy_lane_regs lane_regs_qcm2290[] = {
>   	{0x0664, 0x3f, 0x00, CSIPHY_DEFAULT_PARAMS},
>   };
>   
> +/* GEN2 1.2.1 3PH */
> +/* 3 entries: 3 lanes (C-PHY) */
> +static const struct
> +csiphy_lane_regs lane_regs_sm8250_3ph[] = {
> +	{0x0990, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0994, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0998, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0990, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0994, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0998, 0x1a, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x098c, 0xaf, 0x01, CSIPHY_DEFAULT_PARAMS},
> +	{0x015c, 0x46, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
> +	{0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
> +	{0x0114, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0150, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0188, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x018c, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0190, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0118, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x011c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0120, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0124, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0128, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x012c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0160, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x01cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x01dc, 0x50, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0984, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0988, 0x05, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0980, 0x60, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x09ac, 0x35, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x09b0, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0800, 0x0e, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0884, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
> +
> +	{0x0a90, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a94, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a98, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a90, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a94, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a98, 0x1a, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a8c, 0xaf, 0x01, CSIPHY_DEFAULT_PARAMS},
> +	{0x035c, 0x46, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
> +	{0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
> +	{0x0314, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0350, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0388, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x038c, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0390, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0318, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x031c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0320, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0324, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0328, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x032c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0360, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x03cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x03dc, 0x50, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a84, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a88, 0x05, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0a80, 0x60, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0aac, 0x35, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0ab0, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0800, 0x0e, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0884, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
> +
> +	{0x0b90, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b94, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b98, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b90, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b94, 0x08, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b98, 0x1a, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b8c, 0xaf, 0x01, CSIPHY_DEFAULT_PARAMS},
> +	{0x055c, 0x46, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
> +	{0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
> +	{0x0514, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0550, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0588, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x058c, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0590, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0518, 0x3e, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x051c, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0520, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0524, 0x7f, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0528, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x052c, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0560, 0x02, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x05cc, 0x41, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x05dc, 0x50, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b84, 0x20, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b88, 0x05, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0b80, 0x60, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0bac, 0x35, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0bb0, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0800, 0x0e, 0x00, CSIPHY_DEFAULT_PARAMS},
> +	{0x0884, 0x01, 0x00, CSIPHY_DEFAULT_PARAMS},
> +};
> +
>   /* GEN2 2.1.2 2PH DPHY mode */
>   static const struct
>   csiphy_lane_regs lane_regs_sm8550[] = {
> @@ -1134,7 +1241,10 @@ static int csiphy_lanes_enable(struct csiphy_device *csiphy,
>   		break;
>   	case CAMSS_7280:
>   	case CAMSS_8250:
> -		{
> +		if (c->phy_cfg == V4L2_MBUS_CSI2_CPHY) {
> +			regs->lane_regs = &lane_regs_sm8250_3ph[0];
> +			regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8250_3ph);
> +		} else {
>   			regs->lane_regs = &lane_regs_sm8250[0];
>   			regs->lane_array_size = ARRAY_SIZE(lane_regs_sm8250);
>   		}
> 
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration
  2026-03-01  0:51 ` [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration David Heidelberg via B4 Relay
@ 2026-03-03  9:59   ` Bryan O'Donoghue
  0 siblings, 0 replies; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03  9:59 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
> @bod
> Proliferating special cases in switch statements on a per-SoC basis is
> verboten.

Hmm, your ideas are intriguing to me, and I wish to subscribe to your 
newsletter.

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-03  9:55   ` Bryan O'Donoghue
@ 2026-03-03 10:00     ` David Heidelberg
  2026-03-03 10:08       ` Bryan O'Donoghue
  2026-03-03 10:22       ` Konrad Dybcio
  0 siblings, 2 replies; 31+ messages in thread
From: David Heidelberg @ 2026-03-03 10:00 UTC (permalink / raw)
  To: Bryan O'Donoghue, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 03/03/2026 10:55, Bryan O'Donoghue wrote:
> On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
>> From: David Heidelberg <david@ixit.cz>
>>
>> These values should improve C-PHY behaviour. Should match most recent
>> Qualcomm code.
>>
>> Signed-off-by: David Heidelberg <david@ixit.cz>
>> ---
>>   .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c   | 18 +++++++++---------
>>   1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/ 
>> drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>> index 5482fb5163e17..c612192ee727a 100644
>> --- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>> +++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>> @@ -225,9 +225,9 @@ csiphy_lane_regs lane_regs_sdm845[] = {
>>   /* 3 entries: 3 lanes (C-PHY) */
>>   static const struct
>>   csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>> -    {0x015c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x016c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x015c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x0168, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x016c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>       {0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>> @@ -245,9 +245,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>       {0x0164, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x01dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x035c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x036c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x035c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x0368, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x036c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>       {0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>> @@ -265,9 +265,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>       {0x0364, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x03dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x055c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>> -    {0x056c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x055c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x0568, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>> +    {0x056c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>       {0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>       {0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>>
> 
> Squash down and Co-developed-by
> 

We don't have any documentation how these lanes are set. I think it's good to 
see two working variants, someone may need it to demystify it one day and the 
history may comes handy. Also both variants works for us.

I think it would make sense to squash it, when the magic hex gets documented, 
but even with description it may be useful to see what's being tuned to get 
better working C-PHY.

So I would propose intentionally keep here the "history" so someone in the 
future may use it to describe these registers.

David

> ---
> bod

-- 
David Heidelberg


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
  2026-03-03  9:54   ` Bryan O'Donoghue
@ 2026-03-03 10:06     ` David Heidelberg
  2026-03-03 10:10       ` Bryan O'Donoghue
  0 siblings, 1 reply; 31+ messages in thread
From: David Heidelberg @ 2026-03-03 10:06 UTC (permalink / raw)
  To: Bryan O'Donoghue, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 03/03/2026 10:54, Bryan O'Donoghue wrote:
> On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
>>   Move the lane initialization to a later stage where the
>> configuration structures are available.
> 
> You should specify which later phase in the commit log @ next rev.

"Move the lane initialization to csiphy_lanes_enable which is
entered at later stage where the configuration structures are available."

sounds good?

[...]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency
  2026-03-01  0:51 ` [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency David Heidelberg via B4 Relay
@ 2026-03-03 10:07   ` Bryan O'Donoghue
  2026-03-20 19:48   ` Cory Keitz
  1 sibling, 0 replies; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03 10:07 UTC (permalink / raw)
  To: david, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
> 
> Ensure that the link frequency divider correctly accounts for C-PHY
> operation. The divider differs between D-PHY and C-PHY, as described
> in the MIPI CSI-2 specification.
> 
> For more details, see:
> https://docs.kernel.org/driver-api/media/tx-rx.html#pixel-rate
> 
> Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>   drivers/media/platform/qcom/camss/camss-csid.c   | 11 +++++++----
>   drivers/media/platform/qcom/camss/camss-csiphy.c |  6 ++----
>   drivers/media/platform/qcom/camss/camss.c        | 18 +++++++++++++++---
>   drivers/media/platform/qcom/camss/camss.h        |  2 +-
>   4 files changed, 25 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
> index b50b0cfe280c1..2fc17c6a15e2e 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid.c
> @@ -534,18 +534,21 @@ const struct csid_format_info *csid_get_fmt_entry(const struct csid_format_info
>    * csid_set_clock_rates - Calculate and set clock rates on CSID module
>    * @csiphy: CSID device
>    */
> -static int csid_set_clock_rates(struct csid_device *csid)
> +static int csid_set_clock_rates(struct v4l2_subdev *sd, struct csid_device *csid)
>   {
>   	struct device *dev = csid->camss->dev;
> +	struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
> +	struct csiphy_lanes_cfg *lane_cfg = &csiphy->cfg.csi2->lane_cfg;
>   	const struct csid_format_info *fmt;
> +
>   	s64 link_freq;
>   	int i, j;
>   	int ret;
>   
>   	fmt = csid_get_fmt_entry(csid->res->formats->formats, csid->res->formats->nformats,
>   				 csid->fmt[MSM_CSIPHY_PAD_SINK].code);
> -	link_freq = camss_get_link_freq(&csid->subdev.entity, fmt->bpp,
> -					csid->phy.lane_cnt);
> +
> +	link_freq = camss_get_link_freq(&csid->subdev.entity, fmt->bpp, lane_cfg);
>   	if (link_freq < 0)
>   		link_freq = 0;
>   
> @@ -703,7 +706,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
>   			return ret;
>   		}
>   
> -		ret = csid_set_clock_rates(csid);
> +		ret = csid_set_clock_rates(sd, csid);
>   		if (ret < 0) {
>   			regulator_bulk_disable(csid->num_supplies,
>   					       csid->supplies);
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index 938600f3defe1..ea9dd2cd2e740 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> @@ -143,9 +143,8 @@ static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
>   
>   	u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
>   				csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
> -	u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
>   
> -	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes);
> +	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, &csiphy->cfg.csi2->lane_cfg);
>   	if (link_freq < 0)
>   		link_freq  = 0;
>   
> @@ -270,10 +269,9 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
>   	u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg);
>   	u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
>   				csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
> -	u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
>   	u8 val;
>   
> -	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes);
> +	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, &csiphy->cfg.csi2->lane_cfg);
>   
>   	if (link_freq < 0) {
>   		dev_err(csiphy->camss->dev,
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index ea0c8cf3cd806..4c13bae17007e 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -32,6 +32,14 @@
>   #define CAMSS_CLOCK_MARGIN_NUMERATOR 105
>   #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
>   
> +/*
> + * C-PHY encodes data by 16/7 ~ 2.28 bits/symbol
> + * D-PHY doesn't encode data, thus 16/16 = 1 b/s
> + */
> +#define CAMSS_COMMON_PHY_DIVIDENT 16
> +#define CAMSS_CPHY_DIVISOR 7
> +#define CAMSS_DPHY_DIVISOR 16
> +
>   static const struct parent_dev_ops vfe_parent_dev_ops;
>   
>   static const struct camss_subdev_resources csiphy_res_8x16[] = {
> @@ -4280,20 +4288,24 @@ struct media_pad *camss_find_sensor_pad(struct media_entity *entity)
>    * camss_get_link_freq - Get link frequency from sensor
>    * @entity: Media entity in the current pipeline
>    * @bpp: Number of bits per pixel for the current format
> - * @lanes: Number of lanes in the link to the sensor
> + * @lane_cfg: CSI2 lane configuration
>    *
>    * Return link frequency on success or a negative error code otherwise
>    */
>   s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
> -			unsigned int lanes)
> +			struct csiphy_lanes_cfg *lane_cfg)
>   {
>   	struct media_pad *sensor_pad;
> +	u8 num_lanes = lane_cfg->num_data;
> +	bool cphy = lane_cfg->phy_cfg == V4L2_MBUS_CSI2_CPHY;
> +	unsigned int div = num_lanes * 2 * (cphy ? CAMSS_CPHY_DIVISOR :
> +						     CAMSS_DPHY_DIVISOR);
>   
>   	sensor_pad = camss_find_sensor_pad(entity);
>   	if (!sensor_pad)
>   		return -ENODEV;
>   
> -	return v4l2_get_link_freq(sensor_pad, bpp, 2 * lanes);
> +	return v4l2_get_link_freq(sensor_pad, CAMSS_COMMON_PHY_DIVIDENT * bpp, div);
>   }
>   
>   /*
> diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
> index 6d048414c919e..67be42b4c9174 100644
> --- a/drivers/media/platform/qcom/camss/camss.h
> +++ b/drivers/media/platform/qcom/camss/camss.h
> @@ -163,7 +163,7 @@ int camss_enable_clocks(int nclocks, struct camss_clock *clock,
>   void camss_disable_clocks(int nclocks, struct camss_clock *clock);
>   struct media_pad *camss_find_sensor_pad(struct media_entity *entity);
>   s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
> -			unsigned int lanes);
> +			struct csiphy_lanes_cfg *lane_cfg);
>   int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock);
>   int camss_pm_domain_on(struct camss *camss, int id);
>   void camss_pm_domain_off(struct camss *camss, int id);
> 
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-03 10:00     ` David Heidelberg
@ 2026-03-03 10:08       ` Bryan O'Donoghue
  2026-03-03 10:22       ` Konrad Dybcio
  1 sibling, 0 replies; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03 10:08 UTC (permalink / raw)
  To: David Heidelberg, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 03/03/2026 10:00, David Heidelberg wrote:
> We don't have any documentation how these lanes are set. I think it's 
> good to see two working variants, someone may need it to demystify it 
> one day and the history may comes handy. Also both variants works for us.

OK sure that adds up keep it progressive so.

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
  2026-03-03 10:06     ` David Heidelberg
@ 2026-03-03 10:10       ` Bryan O'Donoghue
  2026-03-03 10:12         ` David Heidelberg
  0 siblings, 1 reply; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03 10:10 UTC (permalink / raw)
  To: David Heidelberg, Robert Foss, Todor Tomov, Vladimir Zapolskiy,
	Mauro Carvalho Chehab, Luca Weiss, Petr Hodina, Casey Connolly,
	Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 03/03/2026 10:06, David Heidelberg wrote:
> "Move the lane initialization to csiphy_lanes_enable which is
> entered at later stage where the configuration structures are available."

I'm being pedantic sorry.

"Move the lane initialization to csiphy_lanes_enable which is
called when the configuration structures are available."

Actually I think config is called when/if the sensor gets probed.

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
  2026-03-03 10:10       ` Bryan O'Donoghue
@ 2026-03-03 10:12         ` David Heidelberg
  0 siblings, 0 replies; 31+ messages in thread
From: David Heidelberg @ 2026-03-03 10:12 UTC (permalink / raw)
  To: Bryan O'Donoghue, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

I meant, commits are docs (and I'm reading them often myself), whatever makes 
best outcome for someone trying to understand the code :)

Thanks
David

On 03/03/2026 11:10, Bryan O'Donoghue wrote:
> On 03/03/2026 10:06, David Heidelberg wrote:
>> "Move the lane initialization to csiphy_lanes_enable which is
>> entered at later stage where the configuration structures are available."
> 
> I'm being pedantic sorry.
> 
> "Move the lane initialization to csiphy_lanes_enable which is
> called when the configuration structures are available."
> 
> Actually I think config is called when/if the sensor gets probed.
> 
> ---
> bod

-- 
David Heidelberg


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-03 10:00     ` David Heidelberg
  2026-03-03 10:08       ` Bryan O'Donoghue
@ 2026-03-03 10:22       ` Konrad Dybcio
  2026-03-03 10:27         ` David Heidelberg
  2026-03-03 10:39         ` Bryan O'Donoghue
  1 sibling, 2 replies; 31+ messages in thread
From: Konrad Dybcio @ 2026-03-03 10:22 UTC (permalink / raw)
  To: David Heidelberg, Bryan O'Donoghue, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Joel Selvaraj, Kieran Bingham, Sakari Ailus, linux-media,
	linux-arm-msm, linux-kernel, phone-devel

On 3/3/26 11:00 AM, David Heidelberg wrote:
> On 03/03/2026 10:55, Bryan O'Donoghue wrote:
>> On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
>>> From: David Heidelberg <david@ixit.cz>
>>>
>>> These values should improve C-PHY behaviour. Should match most recent
>>> Qualcomm code.
>>>
>>> Signed-off-by: David Heidelberg <david@ixit.cz>
>>> ---
>>>   .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c   | 18 +++++++++---------
>>>   1 file changed, 9 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/ drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>>> index 5482fb5163e17..c612192ee727a 100644
>>> --- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>>> +++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>>> @@ -225,9 +225,9 @@ csiphy_lane_regs lane_regs_sdm845[] = {
>>>   /* 3 entries: 3 lanes (C-PHY) */
>>>   static const struct
>>>   csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>> -    {0x015c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x016c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x015c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x0168, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x016c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>>       {0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>>> @@ -245,9 +245,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>>       {0x0164, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x01dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x035c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x036c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x035c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x0368, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x036c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>>       {0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>>> @@ -265,9 +265,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>>       {0x0364, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x03dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x055c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> -    {0x056c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x055c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x0568, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>>> +    {0x056c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>       {0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>>       {0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>>>
>>
>> Squash down and Co-developed-by

Suggested-by, perhaps

Co-developed-by usually reflects pair programming and requires a s-o-b,
and that carries legal meaning.

Konrad

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-03 10:22       ` Konrad Dybcio
@ 2026-03-03 10:27         ` David Heidelberg
  2026-03-03 10:39         ` Bryan O'Donoghue
  1 sibling, 0 replies; 31+ messages in thread
From: David Heidelberg @ 2026-03-03 10:27 UTC (permalink / raw)
  To: Konrad Dybcio, Bryan O'Donoghue, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Joel Selvaraj, Kieran Bingham, Sakari Ailus, linux-media,
	linux-arm-msm, linux-kernel, phone-devel



On 03/03/2026 11:22, Konrad Dybcio wrote:
> On 3/3/26 11:00 AM, David Heidelberg wrote:
>> On 03/03/2026 10:55, Bryan O'Donoghue wrote:
>>> On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
>>>> From: David Heidelberg <david@ixit.cz>
>>>>
>>>> These values should improve C-PHY behaviour. Should match most recent
>>>> Qualcomm code.
>>>>
>>>> Signed-off-by: David Heidelberg <david@ixit.cz>
>>>> ---
>>>>    .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c   | 18 +++++++++---------
>>>>    1 file changed, 9 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/ drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>>>> index 5482fb5163e17..c612192ee727a 100644
>>>> --- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>>>> +++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
>>>> @@ -225,9 +225,9 @@ csiphy_lane_regs lane_regs_sdm845[] = {
>>>>    /* 3 entries: 3 lanes (C-PHY) */
>>>>    static const struct
>>>>    csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>>> -    {0x015c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x0168, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x016c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x015c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x0168, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x016c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x0104, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x010c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>>>        {0x0108, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>>>> @@ -245,9 +245,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>>>        {0x0164, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x01dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x035c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x0368, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x036c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x035c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x0368, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x036c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x0304, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x030c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>>>        {0x0308, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>>>> @@ -265,9 +265,9 @@ csiphy_lane_regs lane_regs_sdm845_3ph[] = {
>>>>        {0x0364, 0x00, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x03dc, 0x51, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x055c, 0x43, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x0568, 0xa0, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> -    {0x056c, 0x25, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x055c, 0x63, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x0568, 0xac, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>> +    {0x056c, 0xa5, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x0504, 0x06, 0x00, CSIPHY_DEFAULT_PARAMS},
>>>>        {0x050c, 0x12, 0x00, CSIPHY_SETTLE_CNT_LOWER_BYTE},
>>>>        {0x0508, 0x00, 0x00, CSIPHY_SETTLE_CNT_HIGHER_BYTE},
>>>>
>>>
>>> Squash down and Co-developed-by
> 
> Suggested-by, perhaps

I had that in originally, but I have feeling between rebasing I lost the commit 
somehow and had to write it again before v4 because I remember our discussion...

Restored, Suggested-by is back! :)

> 
> Co-developed-by usually reflects pair programming and requires a s-o-b,
> and that carries legal meaning.
> 
> Konrad

-- 
David Heidelberg


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-03 10:22       ` Konrad Dybcio
  2026-03-03 10:27         ` David Heidelberg
@ 2026-03-03 10:39         ` Bryan O'Donoghue
  2026-03-03 10:46           ` Konrad Dybcio
  1 sibling, 1 reply; 31+ messages in thread
From: Bryan O'Donoghue @ 2026-03-03 10:39 UTC (permalink / raw)
  To: Konrad Dybcio, David Heidelberg, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Joel Selvaraj, Kieran Bingham, Sakari Ailus, linux-media,
	linux-arm-msm, linux-kernel, phone-devel

On 03/03/2026 10:22, Konrad Dybcio wrote:
>>> Squash down and Co-developed-by
> Suggested-by, perhaps
> 
> Co-developed-by usually reflects pair programming and requires a s-o-b,
> and that carries legal meaning.

Hmm yes but this is his change so he owns his own Co-developed-by and 
his on S-o-b ;)

---
bod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
  2026-03-03 10:39         ` Bryan O'Donoghue
@ 2026-03-03 10:46           ` Konrad Dybcio
  0 siblings, 0 replies; 31+ messages in thread
From: Konrad Dybcio @ 2026-03-03 10:46 UTC (permalink / raw)
  To: Bryan O'Donoghue, David Heidelberg, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Joel Selvaraj, Kieran Bingham, Sakari Ailus, linux-media,
	linux-arm-msm, linux-kernel, phone-devel

On 3/3/26 11:39 AM, Bryan O'Donoghue wrote:
> On 03/03/2026 10:22, Konrad Dybcio wrote:
>>>> Squash down and Co-developed-by
>> Suggested-by, perhaps
>>
>> Co-developed-by usually reflects pair programming and requires a s-o-b,
>> and that carries legal meaning.
> 
> Hmm yes but this is his change so he owns his own Co-developed-by and his on S-o-b ;)

Oh I see, I was under the impression that the original commit was authored
by him and that you're referencing my request to submit this update from
some older revision

Konrad

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support
  2026-03-03  9:53   ` Bryan O'Donoghue
@ 2026-03-03 20:31     ` David Heidelberg
  0 siblings, 0 replies; 31+ messages in thread
From: David Heidelberg @ 2026-03-03 20:31 UTC (permalink / raw)
  To: Bryan O'Donoghue, Robert Foss, Todor Tomov,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git
  Cc: Konrad Dybcio, Joel Selvaraj, Kieran Bingham, Sakari Ailus,
	linux-media, linux-arm-msm, linux-kernel, phone-devel

On 03/03/2026 10:53, Bryan O'Donoghue wrote:
> On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
>> +    bool cphy;
> 
> Same comment as before, you should have an enum not a bool.


While for general camss it makes sense to me, here it seems to be very simple 
switch with no other extra usefulness.

If u insist, I'll change it, but LGTM with cphy here.

David

> 
> ---
> bod

-- 
David Heidelberg


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency
  2026-03-01  0:51 ` [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency David Heidelberg via B4 Relay
  2026-03-03 10:07   ` Bryan O'Donoghue
@ 2026-03-20 19:48   ` Cory Keitz
  1 sibling, 0 replies; 31+ messages in thread
From: Cory Keitz @ 2026-03-20 19:48 UTC (permalink / raw)
  To: david
  Cc: Robert Foss, Todor Tomov, Bryan O'Donoghue,
	Vladimir Zapolskiy, Mauro Carvalho Chehab, Luca Weiss,
	Petr Hodina, Casey Connolly, Dr. Git, Konrad Dybcio,
	Joel Selvaraj, Kieran Bingham, Sakari Ailus, linux-media,
	linux-arm-msm, linux-kernel, phone-devel

On Sun, Mar 01, 2026 at 01:51:28AM +0100, David Heidelberg via B4 Relay wrote:
> -static int csid_set_clock_rates(struct csid_device *csid)
> +static int csid_set_clock_rates(struct v4l2_subdev *sd, struct csid_device *csid)
>  {
>  	struct device *dev = csid->camss->dev;
> +	struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
> +	struct csiphy_lanes_cfg *lane_cfg = &csiphy->cfg.csi2->lane_cfg;

I believe there's a regression here from v3. I've been testing v4 of
this series on SA8775P (kernel 6.18) with a GMSL2 camera pipeline and
hit an invalid pointer dereference in csid_set_clock_rates() during
pipeline power-up:

  pc : camss_get_link_freq+0x1c/0xc4 [qcom_camss]
  lr : csid_set_power+0xc8/0x404 [qcom_camss]
  Code: 910003fd a90153f3 aa0003f4 a9025bf5 (b9400040)

The sd passed here from csid_set_power() is the csid subdev, so the
subdevdata is a csid_device rather than a csiphy_device. The csid_device
stores its linked csiphy_id during csid_link_setup(), so the fix is to
look it up through the camss device array:

    static int csid_set_clock_rates(struct csid_device *csid)
    {
        struct csiphy_device *csiphy = &csid->camss->csiphy[csid->phy.csiphy_id];
        struct csiphy_lanes_cfg *lane_cfg = &csiphy->cfg.csi2->lane_cfg;

This also lets us drop the v4l2_subdev parameter entirely since it's
no longer needed. With the above change my pipeline powers on and
streams correctly.

Tested-by: Cory Keitz <ckeitz@amazon.com>

---

Regards,
Cory

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2026-03-20 19:48 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01  0:51 [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms David Heidelberg via B4 Relay
2026-03-01  0:51 ` [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration David Heidelberg via B4 Relay
2026-03-03  9:48   ` Bryan O'Donoghue
2026-03-01  0:51 ` [PATCH WIP v4 2/9] media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes David Heidelberg via B4 Relay
2026-03-03  9:52   ` Bryan O'Donoghue
2026-03-01  0:51 ` [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support David Heidelberg via B4 Relay
2026-03-03  9:53   ` Bryan O'Donoghue
2026-03-03 20:31     ` David Heidelberg
2026-03-01  0:51 ` [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available David Heidelberg via B4 Relay
2026-03-03  9:54   ` Bryan O'Donoghue
2026-03-03 10:06     ` David Heidelberg
2026-03-03 10:10       ` Bryan O'Donoghue
2026-03-03 10:12         ` David Heidelberg
2026-03-01  0:51 ` [PATCH WIP v4 5/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.1 MIPI CSI-2 CPHY init David Heidelberg via B4 Relay
2026-03-01  0:51 ` [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update " David Heidelberg via B4 Relay
2026-03-03  9:55   ` Bryan O'Donoghue
2026-03-03 10:00     ` David Heidelberg
2026-03-03 10:08       ` Bryan O'Donoghue
2026-03-03 10:22       ` Konrad Dybcio
2026-03-03 10:27         ` David Heidelberg
2026-03-03 10:39         ` Bryan O'Donoghue
2026-03-03 10:46           ` Konrad Dybcio
2026-03-01  0:51 ` [PATCH WIP v4 7/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init David Heidelberg via B4 Relay
2026-03-03  9:56   ` Bryan O'Donoghue
2026-03-01  0:51 ` [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration David Heidelberg via B4 Relay
2026-03-03  9:59   ` Bryan O'Donoghue
2026-03-01  0:51 ` [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency David Heidelberg via B4 Relay
2026-03-03 10:07   ` Bryan O'Donoghue
2026-03-20 19:48   ` Cory Keitz
2026-03-02 18:43 ` [PATCH WIP v4 0/9] media: camss: Add support for C-PHY configuration on Qualcomm platforms Cory Keitz
2026-03-02 23:13   ` David Heidelberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox