Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: cadence: csi2rx: configure DPHY before starting source stream

When the source device is operating above 1.5 Gbps per lane, it needs to
send the Skew Calibration Sequence before sending any HS data. If the
DPHY is initialized after the source stream is started, then it might
miss the sequence and not be able to receive data properly. Move the
start of source subdev to the end of the sequence to make sure
everything is ready to receive data before the source starts streaming.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Fixes: 3295cf1241d3 ("media: cadence: Add support for external dphy")
Tested-by: Julien Massot <julien.massot@collabora.com>
Tested-by: Changhuang Liang <Changhuang.liang@starfivetech.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Changhuang Liang <Changhuang.liang@starfivetech.com>
Signed-off-by: Jai Luthra <j-luthra@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Pratyush Yadav and committed by
Hans Verkuil
fd64dda4 4bc60736

+14 -12
+14 -12
drivers/media/platform/cadence/cdns-csi2rx.c
··· 239 239 240 240 writel(reg, csi2rx->base + CSI2RX_STATIC_CFG_REG); 241 241 242 - ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); 243 - if (ret) 244 - goto err_disable_pclk; 245 - 246 242 /* Enable DPHY clk and data lanes. */ 247 243 if (csi2rx->dphy) { 248 244 reg = CSI2RX_DPHY_CL_EN | CSI2RX_DPHY_CL_RST; ··· 248 252 } 249 253 250 254 writel(reg, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); 255 + 256 + ret = csi2rx_configure_ext_dphy(csi2rx); 257 + if (ret) { 258 + dev_err(csi2rx->dev, 259 + "Failed to configure external DPHY: %d\n", ret); 260 + goto err_disable_pclk; 261 + } 251 262 } 252 263 253 264 /* ··· 294 291 295 292 reset_control_deassert(csi2rx->sys_rst); 296 293 297 - if (csi2rx->dphy) { 298 - ret = csi2rx_configure_ext_dphy(csi2rx); 299 - if (ret) { 300 - dev_err(csi2rx->dev, 301 - "Failed to configure external DPHY: %d\n", ret); 302 - goto err_disable_sysclk; 303 - } 304 - } 294 + ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); 295 + if (ret) 296 + goto err_disable_sysclk; 305 297 306 298 clk_disable_unprepare(csi2rx->p_clk); 307 299 ··· 310 312 clk_disable_unprepare(csi2rx->pixel_clk[i - 1]); 311 313 } 312 314 315 + if (csi2rx->dphy) { 316 + writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); 317 + phy_power_off(csi2rx->dphy); 318 + } 313 319 err_disable_pclk: 314 320 clk_disable_unprepare(csi2rx->p_clk); 315 321