media: camss: Add support for C-PHY configuration on Qualcomm platforms
Subsystems (4)
v4 cover media: camss: Add support for C-PHY configuration on Qualcomm platforms
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
---
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/[email protected]
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/[email protected]
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/[email protected]
---
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,
Signature · 1 line
David Heidelberg <[email protected]>
PATCH v4 1/9 media: qcom: camss: csiphy: Introduce PHY configuration
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.
--- drivers/media/platform/qcom/camss/camss-csiphy.h | 2 ++ drivers/media/platform/qcom/camss/camss.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/media/platform/qcom/camss/camss-csiphy.h +2 -0
@@ -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;
drivers/media/platform/qcom/camss/camss.c +11 -7
@@ -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),
Signature · 1 line
2.51.0
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 1/9] media: qcom: camss: csiphy: Introduce PHY configuration
Quoted 59 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
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 <[email protected]>--- drivers/media/platform/qcom/camss/camss-csiphy.h | 2 ++ drivers/media/platform/qcom/camss/camss.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-)drivers/media/platform/qcom/camss/camss-csiphy.h +2
-0@@ -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;drivers/media/platform/qcom/camss/camss.c +5
-7@@ -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 ];
drivers/media/platform/qcom/camss/camss.c static int camss_parse_endpoint_node(struct device *dev, · line 4435
Quoted 10 lines
drivers/media/platform/qcom/camss/camss.c +6
-0lncfg->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
PATCH v4 2/9 media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes
In reply to David HeidelbergSo 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.
--- .../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(-)
drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c +5 -3
@@ -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,
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +38 -11
82 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-csiphy.c +2 -3
@@ -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); }/*
drivers/media/platform/qcom/camss/camss-csiphy.h +3 -3
@@ -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);
Signature · 1 line
2.51.0
Re: [PATCH WIP v4 2/9] media: qcom: camss: csiphy-3ph: Use odd bits for configuring C-PHY lanes
Quoted 164 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
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 <[email protected]>--- .../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(-)drivers/media/platform/qcom/camss/camss-csiphy-2ph-1-0.c +5
-3@@ -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,drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +38
-11@@ -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,drivers/media/platform/qcom/camss/camss-csiphy.c +2
-3@@ -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); }/* drivers/media/platform/qcom/camss/camss-csiphy.h +0
-0@@ -73,9 +73,9 @@ struct csiphy_hw_ops {void (*hw_version_read)(struct csiphy_device *csiphy,struct device *dev);
drivers/media/platform/qcom/camss/camss-csiphy.h struct csiphy_hw_ops { · line 81
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-csiphy.h +3
-3void (*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);
PATCH v4 3/9 media: qcom: camss: Prepare CSID for C-PHY support
In reply to David HeidelbergInherit 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.
--- 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(+)
drivers/media/platform/qcom/camss/camss-csid-gen2.c +1 -0
@@ -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 ;
drivers/media/platform/qcom/camss/camss-csid.c +1 -0
@@ -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); }
drivers/media/platform/qcom/camss/camss-csid.h +1 -0
@@ -70,6 +70,7 @@ struct csid_phy_config {u32 lane_assign;u32 en_vc;u8 need_vc_update; +bool cphy; };struct csid_device ;
Signature · 1 line
2.51.0
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support
drivers/media/platform/qcom/camss/camss-csid.h struct csid_phy_config { · line 73
Quoted 1 line · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
drivers/media/platform/qcom/camss/camss-csid.h +1
-0+bool cphy;
Same comment as before, you should have an enum not a bool.
---
bod
Re: [PATCH WIP v4 3/9] media: qcom: camss: Prepare CSID for C-PHY support
Quoted 4 lines · Bryan O'Donoghue
Quoted 1 line · 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
Quoted 3 lines
---
bod
Signature · 1 line
David Heidelberg
PATCH v4 4/9 media: qcom: camss: Initialize lanes after lane configuration is available
In reply to David HeidelbergFrom: Petr Hodina <[email protected]>
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.
--- .../platform/qcom/camss/camss-csiphy-3ph-1-0.c | 91 ++++++++++++++-------- 1 file changed, 57 insertions(+), 34 deletions(-)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +57 -34
@@ -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 ; }
Signature · 1 line
2.51.0
Re: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
Quoted 2 lines · 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.
---
bod
Re: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
Quoted 5 lines · Bryan O'Donoghue
Quoted 2 lines · 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?
[...]
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
Quoted 2 lines · David Heidelberg
"Move the lane initialization to
csiphy_lanes_enablewhich 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
Re: [PATCH WIP v4 4/9] media: qcom: camss: Initialize lanes after lane configuration is available
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
Quoted 13 lines · Bryan O'Donoghue
Quoted 2 lines · David Heidelberg
"Move the lane initialization to
csiphy_lanes_enablewhich is entered at later stage where the configuration structures are available."I'm being pedantic sorry.
"Move the lane initialization to
csiphy_lanes_enablewhich is called when the configuration structures are available."Actually I think config is called when/if the sensor gets probed.
---
bod
Signature · 1 line
David Heidelberg
PATCH v4 5/9 media: qcom: camss: csiphy-3ph: Add Gen2 v1.1 MIPI CSI-2 CPHY init
In reply to David HeidelbergFrom: Casey Connolly <[email protected]>
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.
--- .../platform/qcom/camss/camss-csiphy-3ph-1-0.c | 72 +++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +71 -1
@@ -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); }
Signature · 1 line
2.51.0
PATCH v4 6/9 media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
In reply to David HeidelbergThese values should improve C-PHY behaviour. Should match most recent Qualcomm code.
--- .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +9 -9
@@ -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},
Signature · 1 line
2.51.0
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
Quoted 44 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
These values should improve C-PHY behaviour. Should match most recent Qualcomm code.
Signed-off-by David Heidelberg <[email protected]>--- .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +6
-6@@ -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},
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c csiphy_lane_regs lane_regs_sdm845_3ph[] = { · line 273
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +3
-3- {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
Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
Quoted 47 lines · Bryan O'Donoghue
Quoted 46 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
These values should improve C-PHY behaviour. Should match most recent Qualcomm code.
Signed-off-by David Heidelberg <[email protected]>---
.../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 18 +++++++++---------1 file changed, 9 insertions(+), 9 deletions(-)drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +0
-0@@ -225,9 +225,9 @@ csiphy_lane_regs lane_regs_sdm845[] = { /* 3 entries: 3 lanes (C-PHY) */static const struct
csiphy_lane_regslane_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},drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +4
-6@@ -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},
Quoted 9 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c csiphy_lane_regs lane_regs_sdm845_3ph[] = {
Quoted 6 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +2
-0+ {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
Quoted 2 lines
---
bod
Signature · 1 line
David Heidelberg
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
Quoted 1 line · David Heidelberg
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
Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
In reply to David HeidelbergQuoted 48 lines · David Heidelberg
Quoted 47 lines · Bryan O'Donoghue
Quoted 46 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
These values should improve C-PHY behaviour. Should match most recent Qualcomm code.
Signed-off-by David Heidelberg <[email protected]>---
.../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 18 +++++++++---------1 file changed, 9 insertions(+), 9 deletions(-)drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +0
-0@@ -225,9 +225,9 @@ csiphy_lane_regs lane_regs_sdm845[] = { /* 3 entries: 3 lanes (C-PHY) */static const struct
csiphy_lane_regslane_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},drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +4
-6@@ -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},
Quoted 8 lines
Quoted 8 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c csiphy_lane_regs lane_regs_sdm845_3ph[] = {
Quoted 6 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +2
-0+ {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
Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
Quoted 58 lines · Konrad Dybcio
Quoted 48 lines · David Heidelberg
Quoted 47 lines · Bryan O'Donoghue
Quoted 46 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
These values should improve C-PHY behaviour. Should match most recent Qualcomm code.
Signed-off-by David Heidelberg <[email protected]>--- .../media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +7
-9@@ -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},Quoted 8 lines
Quoted 8 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c csiphy_lane_regs lane_regs_sdm845_3ph[] = {
Quoted 6 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +2
-0+ {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
Quoted 1 line
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! :)
Quoted 5 lines
Co-developed-by usually reflects pair programming and requires a s-o-b, and that carries legal meaning.
Konrad
Signature · 1 line
David Heidelberg
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
In reply to Konrad DybcioQuoted 5 lines · Konrad Dybcio
Quoted 1 line
Quoted 1 line
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
Re: [PATCH WIP v4 6/9] media: qcom: camss: csiphy-3ph: Update Gen2 v1.1 MIPI CSI-2 CPHY init
Quoted 8 lines · Bryan O'Donoghue
Quoted 5 lines · Konrad Dybcio
Quoted 1 line
Quoted 1 line
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
PATCH v4 7/9 media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init
In reply to David HeidelbergFrom: Luca Weiss <[email protected]>
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.
--- .../platform/qcom/camss/camss-csiphy-3ph-1-0.c | 112 ++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +111 -1
@@ -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); }
Signature · 1 line
2.51.0
Re: [PATCH WIP v4 7/9] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2.1 MIPI CSI-2 C-PHY init
Quoted 136 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: Luca Weiss <[email protected]>
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 <[email protected]>Reviewed-by Konrad Dybcio <[email protected]>Signed-off-by David Heidelberg <[email protected]>--- .../platform/qcom/camss/camss-csiphy-3ph-1-0.c | 112 ++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-)drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +107
-0@@ -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 ;
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c static int csiphy_lanes_enable(struct csiphy_device *csiphy, · line 1250
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +4
-1case 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); }
PATCH v4 8/9 media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration
In reply to David HeidelbergCatch 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.
--
--- drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +16 -0
@@ -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 ) {
Signature · 1 line
2.51.0
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration
Quoted 3 lines · 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
Bryan O'Donoghue
maintainerRe: [PATCH WIP v4 8/9] media: qcom: camss: csiphy-3ph: C-PHY needs own lane configuration
Quoted 11 lines · Bryan O'Donoghue
Quoted 3 lines · 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
@David.
I'm realising my Simpson's reference probably isn't actionable development feedback ;)
How about embeddding a pointer to either a DPHY or CPHY init sequence somewhere and checking that pointer ?
If it the CPHY init sequence/table in this case, is NULL return -EOPTNOTSUPP.
That way instead of constantly extending a switch for each new SoC we enumerate a pointer and check that pointer's validity.
Then we have nice clean code which just checks the value of a pointer, instead of an ever-growing list of SoCs in a switch.
---
bod
PATCH v4 9/9 media: qcom: camss: Account for C-PHY when calculating link frequency
In reply to David HeidelbergEnsure 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
--- 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(-)
drivers/media/platform/qcom/camss/camss-csid.c +7 -4
@@ -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);
drivers/media/platform/qcom/camss/camss-csiphy.c +2 -4
@@ -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,
drivers/media/platform/qcom/camss/camss.c +15 -3
@@ -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); }/*
drivers/media/platform/qcom/camss/camss.h +1 -1
@@ -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);
Signature · 1 line
2.51.0
Re: [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency
Quoted 136 lines · On 01/03/2026 00:51, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
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-rateSuggested-by Sakari Ailus <[email protected]>Signed-off-by David Heidelberg <[email protected]>--- 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(-)drivers/media/platform/qcom/camss/camss-csid.c +7
-4@@ -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);drivers/media/platform/qcom/camss/camss-csiphy.c +2
-4@@ -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,drivers/media/platform/qcom/camss/camss.c +15
-3@@ -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); }/* drivers/media/platform/qcom/camss/camss.h +0
-0
drivers/media/platform/qcom/camss/camss.h int camss_enable_clocks(int nclocks, struct camss_clock *clock, · line 169
Quoted 8 lines
drivers/media/platform/qcom/camss/camss.h +1
-1@@ -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);
Re: [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency
In reply to David Heidelbergdrivers/media/platform/qcom/camss/camss-csid.c const struct csid_format_info *csid_get_fmt_entry(const struct csid_format_info · line 541
Quoted 6 lines · On Sun, Mar 01, 2026 at 01:51:28AM +0100, David Heidelberg via B4 Relay wrote:
drivers/media/platform/qcom/camss/camss-csid.c +3
-1-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.
---
Regards,
Cory
Re: [PATCH WIP v4 9/9] media: qcom: camss: Account for C-PHY when calculating link frequency
Quoted 22 lines · Cory Keitz
drivers/media/platform/qcom/camss/camss-csid.c const struct csid_format_info *csid_get_fmt_entry(const struct csid_format_info · line 541
Quoted 6 lines · On Sun, Mar 01, 2026 at 01:51:28AM +0100, David Heidelberg via B4 Relay wrote:
drivers/media/platform/qcom/camss/camss-csid.c +3
-1-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 acsid_devicerather than acsiphy_device. Thecsid_devicestores its linkedcsiphy_idduringcsid_link_setup(), so the fix is to look it up through the camss device array:
Quoted 8 lines
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_subdevparameter entirely since it's no longer needed. With the above change my pipeline powers on and streams correctly.
Thank you for catching this, until I'll sent next revision, it's fixed in the git branch [1].
David
[1] https://codeberg.org/sdm845/linux/commits/branch/b4/qcom-cphy
Quoted 7 lines
Tested-by Cory Keitz <[email protected]>---
Regards,
Cory
Signature · 1 line
David Heidelberg
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.
Thanks,
Cory
Quoted 11 lines · 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_SELincamss-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)
Quoted 8 lines
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 <[email protected]>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
Signature · 1 line
David Heidelberg