From patchwork Mon Jul 31 08:29:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 709949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06640C04E69 for ; Mon, 31 Jul 2023 08:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231809AbjGaIaM (ORCPT ); Mon, 31 Jul 2023 04:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231183AbjGaI36 (ORCPT ); Mon, 31 Jul 2023 04:29:58 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085AA1A7; Mon, 31 Jul 2023 01:29:55 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 36V8TlSY128730; Mon, 31 Jul 2023 03:29:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1690792187; bh=tQ6ZBBMuZh67BF7DUCMEDQQSmQ2RVx3GcJBLcvVDOSI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=mbUZcOCWDB0P7t7fFV6doayIlQBWP7++dzWwm2yhAA/0Q3hzIcqLaQIFtWGfucX9X vTRJg99MTbk1E+eEozx66XX4Ig6U/9agyco6KZtiR9apPfxGeLFDgzS6eupM8kUVDp giMMlzIYcveOPQVzc5BMcbX6aUYsNCgZp53rvhYQ= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 36V8TlI4087159 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 31 Jul 2023 03:29:47 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 31 Jul 2023 03:29:47 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 31 Jul 2023 03:29:47 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 36V8TkGu041962; Mon, 31 Jul 2023 03:29:47 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Laurent Pinchart , Tomi Valkeinen CC: , , , , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , Subject: [PATCH v8 10/16] media: cadence: csi2rx: Set the STOP bit when stopping a stream Date: Mon, 31 Jul 2023 13:59:28 +0530 Message-ID: <20230731-upstream_csi-v8-10-fb7d3661c2c9@ti.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731-upstream_csi-v8-0-fb7d3661c2c9@ti.com> References: <20230731-upstream_csi-v8-0-fb7d3661c2c9@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2495; i=j-luthra@ti.com; h=from:subject:message-id; bh=/nT3CbZiw2p97e7tgRwHLuHzcybKAmyi7/0N9VjkH/A=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBkx2xrVs66TvdMqigX3AtSIeJipg4DpYUHL+ARM MhT1XT/bBaJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZMdsawAKCRBD3pH5JJpx RVN+D/0fAI31Zonm3IDXv8qu8vnYZ5wDJMhz/QOGLuBz+Ge0S3Vj539/uDLcs/2IZkV0tO6eOEQ TIQQjAoSbiF22ZXUl2GNzU+EaHdzdjezuGRkrzyz2vTzXz7B56qo3oB66gEihGvojfjXUDtVfj2 NNOw+frrPu7WYILUC9BCQ5PtMGCHT2qZ4PF9wLUvKMSUBxeLXYMOleNhQCsX0CRm5BXC3S2DUJX eTcKyqbo5lWumpOQ+o1LaUoWC7148KyWYHR0fEJWSv25E8azBZbgGHQkY4KCoStpH4dqf//LYXf 5PZSf6cxNKl8wqCF9KdeBYDVhK86GVFEuKYkvfnIohJ6Gv2BOv8Nilj9JqM5omz34Xf9PXhLlIl jZJ1gOglvqEHuHuE7rgWmcods3j6xCCqj69kJo4i6M7P7MHrE/g9iYExLpUbvCeFN3bIjyFzenD 2m5Y1L4csjmWQkC62QtK23S6PRM7y+Hjj/vaikXIMAGsjymAD7Ygsn7+Cu9FDjh3f9/J7gorjKh 8BgrKXVpTAJEcpAQQa/z3XCGtbNJBsHzld+dn9U6a2hV7ALtI2lFpxXksKQ2ThqmZn5Kug8F4LR fIZpI+hi0vZZYIoqdF5N4FXO+AFNfctzWq++1yIBYPvtRRdVdlATaCPE1uDjkkmAlwdVWUS9xei aAJYzRfvxEIibIw== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Pratyush Yadav 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 Signed-off-by: Jai Luthra Reviewed-by: Laurent Pinchart --- v7->v8: - Fix bug where intention was to wait till stream status is idle, i.e. STREAM_STATUS[31] -> 0 - but we were instead checking the opposite drivers/media/platform/cadence/cdns-csi2rx.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 30cdc260b46a..a17ef88dff82 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -41,8 +42,12 @@ #define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000) #define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4) +#define CSI2RX_STREAM_CTRL_STOP BIT(1) #define CSI2RX_STREAM_CTRL_START BIT(0) +#define CSI2RX_STREAM_STATUS_REG(n) (CSI2RX_STREAM_BASE(n) + 0x004) +#define CSI2RX_STREAM_STATUS_RDY BIT(31) + #define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008) #define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31) #define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16) @@ -314,13 +319,24 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) static void csi2rx_stop(struct csi2rx_priv *csi2rx) { unsigned int i; + u32 val; + int ret; clk_prepare_enable(csi2rx->p_clk); reset_control_assert(csi2rx->sys_rst); clk_disable_unprepare(csi2rx->sys_clk); for (i = 0; i < csi2rx->max_streams; i++) { - writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + writel(CSI2RX_STREAM_CTRL_STOP, + csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + + ret = readl_relaxed_poll_timeout(csi2rx->base + + CSI2RX_STREAM_STATUS_REG(i), + val, + !(val & CSI2RX_STREAM_STATUS_RDY), + 10, 10000); + if (ret) + dev_warn(csi2rx->dev, "Failed to stop stream%u\n", i); reset_control_assert(csi2rx->pixel_rst[i]); clk_disable_unprepare(csi2rx->pixel_clk[i]);