From patchwork Fri Aug 11 10:47:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 13350575 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95FC9C04A6A for ; Fri, 11 Aug 2023 10:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jecVigTdBCX+Mzu2plL1TfNXqz23uQyo3q95tyV5jCk=; b=gvokCm0t7FpQ1+ heYLWqQKZMkXZDQPpjqNbCm/N4lUCBK9vg/2Q8f8V+4sxLpvogbbx2AXmy4qStixQSeATcgMYxlGU tGLupuctF8TBVxP+l5xCV+lRKxA4jiclMyzcHeTZmgudMUEFA+GQZVL5cOEpIngBolBiViNKAts3q QU3vHMz1eHgjzpS+RMRRk7dWnWb0P8MOLNHCAhqG3+ZL1LPDYKptBTXWV6mGQcolEm4eHPKLB8+P0 PvmuWGC6yAfIrXu+JXcd0+wv6x2q1UgHxsikjzQw/xA+br95pmJUkpTLKZwPaU29hiPgSQXNf2H+y oiE0NmrMYor+aLkh/RXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qUPgx-00AKGI-0d; Fri, 11 Aug 2023 10:48:27 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qUPgh-00AK73-1s for linux-arm-kernel@lists.infradead.org; Fri, 11 Aug 2023 10:48:14 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 37BAlpxn092957; Fri, 11 Aug 2023 05:47:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1691750871; bh=pfeJn5pyuS1Kn375QoTKmqM/B3qqrMhFRPx327xhsos=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gIbjb+UwYG9ssgfLaDISc9GrdglAG+3A3uGe8GTcMeWr9YOj0g9stuL5NzU6YjRfy o2kOgftOWEWrdSRAZmSfq6OAf5YtVb1dEmJUZR08IpBojFrngPWoSCNkZNnGQzADi9 p59zffgdTEIyIXe+HaZ2pV1+TpSjlSA0wN2am5kk= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 37BAlpGg110742 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Aug 2023 05:47:51 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 11 Aug 2023 05:47:51 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE104.ent.ti.com (10.64.6.25) 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; Fri, 11 Aug 2023 05:47:51 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 37BAlo43060405; Fri, 11 Aug 2023 05:47:51 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v9 08/13] media: cadence: csi2rx: Set the STOP bit when stopping a stream Date: Fri, 11 Aug 2023 16:17:30 +0530 Message-ID: <20230811-upstream_csi-v9-8-8943f7a68a81@ti.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230811-upstream_csi-v9-0-8943f7a68a81@ti.com> References: <20230811-upstream_csi-v9-0-8943f7a68a81@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2584; i=j-luthra@ti.com; h=from:subject:message-id; bh=B9IsBzzslnxknnw5dp9TzgoPZyb3XNoa/gIIm3UOPT4=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBk1g8DZlrpcKDW2I0NMphSc/hdLQPuTsHKoXapk rWT7sAXJXmJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZNYPAwAKCRBD3pH5JJpx RXumEAC4O92x8fA2Qul+1He0FNQKRLbq358F7DtBxFxn1dwqq/nsAU97WYEobNA9dTR/rdfE6o3 YHHZyGzBw0fS9e4mXT0C+twhKLpdYbrC5X9r4LBx0GMH7Ggw4z2W+K+FjFTM19jC3uKmPs0hNlK I/C2OIF+mMtM9M2M/zNlSCU1wAKotUXN8dudq52DTme8SuBQJGdIra/IyKgcZIf67dxCCJqV3+Y mMdVyyMeeAwVPBg5tEitFRWS1RB3oq63v0HGtF10kHKyt6OEYSsnccHQaKJPd55fOixVE5DIkWV Jxsj1Qq9kHoSob2QnaRd2+MaLaUIZ6bX5m5bRFPbhMQmsVOEGTZhMSq97u7Q4i7QvUyHv4JQvv3 nMsS+27QFxJVbhmuAUociaKofSkqKtwsjaDrrIJBKZ2JmJLbmO6KZaqBIV0+0wx5TblCbQFGoOl mq20EMLs1jnkHgv88W03DAl174SWTehzl50Ltdmi0bWVyd3svGYbMs98w1V6cr+BegklQ9E/i4u qHj+6BM39svgFBBqMn23OsS05HGZcHLdqRjAEp0ru2crtrQoRkSdgkmEi0UrMw5tz1PnKdOdYGG jHwQhubJGu6ZEzic9kenTK3Bep6MddIXi00/Es/RQ/CzOCahx82rKMWeFxvktAI7WtWMPXEcFcG QP+cZbYempGBJwg== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230811_034811_712521_81A2CB7F X-CRM114-Status: GOOD ( 15.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- Changes from v8: - Better log message to avoid confusion between cadence streams and v4l2 streams drivers/media/platform/cadence/cdns-csi2rx.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index b57e0c3b1944..f8205c3a28c0 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) @@ -310,13 +315,25 @@ 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 streaming on pad%u\n", i); reset_control_assert(csi2rx->pixel_rst[i]); clk_disable_unprepare(csi2rx->pixel_clk[i]);