Skip to content

Commit a64175f

Browse files
Pratyush YadavHans Verkuil
authored andcommitted
media: cadence: csi2rx: Set the STOP bit when stopping a stream
The stream stop procedure says that the STOP bit should be set when the stream is to be stopped, and then the ready bit in stream status register polled to make sure the STOP operation is finished. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Tested-by: Julien Massot <julien.massot@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> 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>
1 parent 6f28a42 commit a64175f

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

drivers/media/platform/cadence/cdns-csi2rx.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/clk.h>
99
#include <linux/delay.h>
1010
#include <linux/io.h>
11+
#include <linux/iopoll.h>
1112
#include <linux/module.h>
1213
#include <linux/of.h>
1314
#include <linux/of_graph.h>
@@ -41,8 +42,12 @@
4142

4243
#define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000)
4344
#define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4)
45+
#define CSI2RX_STREAM_CTRL_STOP BIT(1)
4446
#define CSI2RX_STREAM_CTRL_START BIT(0)
4547

48+
#define CSI2RX_STREAM_STATUS_REG(n) (CSI2RX_STREAM_BASE(n) + 0x004)
49+
#define CSI2RX_STREAM_STATUS_RDY BIT(31)
50+
4651
#define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008)
4752
#define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31)
4853
#define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16)
@@ -310,13 +315,25 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
310315
static void csi2rx_stop(struct csi2rx_priv *csi2rx)
311316
{
312317
unsigned int i;
318+
u32 val;
319+
int ret;
313320

314321
clk_prepare_enable(csi2rx->p_clk);
315322
reset_control_assert(csi2rx->sys_rst);
316323
clk_disable_unprepare(csi2rx->sys_clk);
317324

318325
for (i = 0; i < csi2rx->max_streams; i++) {
319-
writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
326+
writel(CSI2RX_STREAM_CTRL_STOP,
327+
csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
328+
329+
ret = readl_relaxed_poll_timeout(csi2rx->base +
330+
CSI2RX_STREAM_STATUS_REG(i),
331+
val,
332+
!(val & CSI2RX_STREAM_STATUS_RDY),
333+
10, 10000);
334+
if (ret)
335+
dev_warn(csi2rx->dev,
336+
"Failed to stop streaming on pad%u\n", i);
320337

321338
reset_control_assert(csi2rx->pixel_rst[i]);
322339
clk_disable_unprepare(csi2rx->pixel_clk[i]);

0 commit comments

Comments
 (0)