Re: [PATCH v2] media: synopsys: dw-mipi-csi2rx: Fix DPHY testclr reset sequence

From: Frank Li

Date: Thu Nov 05 2026 - 15:01:40 EST


On Fri, Oct 23, 2026 at 02:49:41PM +0800, Guoniu Zhou wrote:
> The Synopsys DPHY datasheet recommends applying a testclr pulse at
> first power-up to reset the PHY configuration to its default values
> before any test control register is programmed.
>
> The existing code deasserts testclr first and then asserts it, which
> is the reverse of the sequence recommended by the DPHY documentation.
>
> Generate the required TESTCLR pulse by asserting TESTCLR, waiting
> for the required pulse width, and then deasserting it.
>
> Fixes: ec40b431f0ab ("media: synopsys: csi2rx: add i.MX93 support")
> Acked-by: Michael Riesch <michael.riesch@xxxxxxxxxxxxx>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@xxxxxxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> Changes in v2:
> - Keep the readback before ndelay(15) to flush the posted write.
> - Collect Acked-by tag.
> - Link to v1: https://lore.kernel.org/r/20261020-dw-csi2rx-v1-1-c58a2e5cd43d@xxxxxxxxxxx
> ---
> drivers/media/platform/synopsys/dw-mipi-csi2rx.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/synopsys/dw-mipi-csi2rx.c b/drivers/media/platform/synopsys/dw-mipi-csi2rx.c
> index b7247d597c9c..23fb4188e755 100644
> --- a/drivers/media/platform/synopsys/dw-mipi-csi2rx.c
> +++ b/drivers/media/platform/synopsys/dw-mipi-csi2rx.c
> @@ -830,18 +830,22 @@ static void imx93_csi2rx_dphy_assert_reset(struct dw_mipi_csi2rx_device *csi2)
> {
> u32 val;
>
> - /* Release Synopsys DPHY test codes from reset */
> + /* Put PHY in shutdown mode for configuration */
> dw_mipi_csi2rx_write(csi2, DW_MIPI_CSI2RX_DPHY_RSTZ, 0);
> dw_mipi_csi2rx_write(csi2, DW_MIPI_CSI2RX_PHY_SHUTDOWNZ, 0);
>
> + /*
> + * Apply testclr pulse to load analog programmability defaults
> + * and release the test interface for configuration.
> + */
> val = dw_mipi_csi2rx_read(csi2, DW_MIPI_CSI2RX_PHY_TST_CTRL0);
> - val &= ~DPHY_TEST_CTRL0_TEST_CLR;
> + val |= DPHY_TEST_CTRL0_TEST_CLR;
> dw_mipi_csi2rx_write(csi2, DW_MIPI_CSI2RX_PHY_TST_CTRL0, val);
>
> val = dw_mipi_csi2rx_read(csi2, DW_MIPI_CSI2RX_PHY_TST_CTRL0);
> /* Wait for at least 15ns */
> ndelay(15);
> - val |= DPHY_TEST_CTRL0_TEST_CLR;
> + val &= ~DPHY_TEST_CTRL0_TEST_CLR;
> dw_mipi_csi2rx_write(csi2, DW_MIPI_CSI2RX_PHY_TST_CTRL0, val);
> }
>
>
> ---
> base-commit: d7e7bca7169873b46e857c025c10f3336c1258d8
> change-id: 20261020-dw-csi2rx-6225697f45bb
>
> Best regards,
> --
> Guoniu Zhou <guoniu.zhou@xxxxxxxxxxx>
>