From patchwork Mon Oct 9 13:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 13413790 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 D0E3CE95A9A for ; Mon, 9 Oct 2023 14:15:26 +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=RYxuEYwFgWFC+M7fFUX1X/ew8nyuIevHZL0gPXY5qLg=; b=Tzei6ELykGKmAb t7cZrOFk4UgQ0Z9kr94dQ9asHljt84lX4CCyncnnhfys8Uv/NqJ2ndZ+xIDsoP2gT5c3N2BTrkHgK NMe716z0NXGFCfSeXkLkU8S1QMEQLvLeM4tgAbBo4Q1ehYoJqaINTgA+Ceyrp79TXvOF7g3YxpQBM pbIjvkKTL1IAhIZ9z0vDFT82cWfCpmDDm4HBueargTdosMQHMuyRzqAqUR69WlhSGG/6+QEy0IlMQ zy7r23AHvVn7YlhH6nLAurznSaUhcy9QtwNH7ERmB7Il8HTJKFW+q+2IXYFivEqX3P0chmaEvxKOi S79NS8Go48Y2k080BN8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpr2X-00AtuM-1v; Mon, 09 Oct 2023 14:15:21 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpq1L-00Aliq-2L for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 13:10:05 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9qX3067951; Mon, 9 Oct 2023 08:09:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856992; bh=s/9/WCV+Z+pRzQZL2aiY/uIoSmDyX8F6tP63wjbi9vE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=scGwhFKwA5pRAGoHG0YS/WQI2YiJzxEzzS8I1uiRTi+nk3z6AqGnz5kxIWcQ3GiT5 K3v5Iw7x7zvwgkqopdysJFBqpBk/5QOJXQ9hkF9a5+00/aIE8jRV+8O48E7AK80X8e 6ffWv408jey835cSZcI0UNf7cE2wyJ0LuEiF1Nk8= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9qDX021644 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:52 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:52 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE106.ent.ti.com (10.64.6.27) 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, 9 Oct 2023 08:09:52 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9pe6118001; Mon, 9 Oct 2023 08:09:52 -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 v10 07/13] media: cadence: csi2rx: Soft reset the streams before starting capture Date: Mon, 9 Oct 2023 18:39:33 +0530 Message-ID: <20231009-upstream_csi-v10-7-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2047; i=j-luthra@ti.com; h=from:subject:message-id; bh=zwQO/Y0U7j6zw1eN4GZhJJir4qCqq/uRF3NrJzvTBjY=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/srZujrV2s5oLEjLN6orJklsHOAgav/7loNc tE/7oCCHfyJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7KwAKCRBD3pH5JJpx Rf2UD/9bxjA5/hCvux1X58DeE8Cjm+ol7yNkLScPpPXlouX36Ilq1806L6u4BJOnftH7aZkk109 luUFhs69wvW6doNpfpIjQ4U/2OgaJsqbF2R3vH0Q4wIUo8kwq/AhYQsANiLwM34X4czTIahidtb QlWYSBh1C97JXJSYfCLi9xhtNRZPGzfnMvuEYd6duj7N2ntnx7sOTjYOrm8N/kZGa2GQ2PFUZBj WkmYEPry3p9jQpw7IIC8Ys6BOpsUmrjw7wP8xclGE9sbE6gOscYS4hmugbBOidIUOViBLAJiM4r yEk7soEiFt9LTg/SNmgoW+PetF6vplyFr5bC5qxTZKljQCmVOumVyvaly0MLk3rMfoE2Q/jgoH3 oWTGYZx4b+OnYnz1R9HvbPD9hO59nlGIEkR77ZoZMHDv048jJ60apfKU8cmupLxP8o9E2hLrela 03Jlax2vwgtEdcBdXAEAtIcznwyT7TEOiPp9zZmsLePBf8uBBokH10i1W3HVCl/yIhFueGcXmWR oXzZV7YcNFbcg/VqQ5SF3eqfDaXNbDW0sRsqiRXuwFJiG3XjsengYrPHiHhpUnMnvyN1yyKocFw YjCiNc4O5T+V1RQas7jJYAA/TSSZ3PVCWZAHVFiHQFQFy+Kbp4uHnBBQTGbPqnRJ8/6IrowoX8E sNL9O4Hw4ctG5SA== 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-20231009_061003_898834_347E78E5 X-CRM114-Status: GOOD ( 14.61 ) 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 This resets the stream state machines and FIFOs, giving them a clean slate. On J721E if the streams are not reset before starting the capture, the captured frame gets wrapped around vertically on every run after the first. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Maxime Ripard Reviewed-by: Tomi Valkeinen Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 77e2413c345a..913f84c341f4 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -40,6 +40,7 @@ #define CSI2RX_STREAM_BASE(n) (((n) + 1) * 0x100) #define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000) +#define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4) #define CSI2RX_STREAM_CTRL_START BIT(0) #define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008) @@ -134,12 +135,23 @@ struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev) static void csi2rx_reset(struct csi2rx_priv *csi2rx) { + unsigned int i; + + /* Reset module */ writel(CSI2RX_SOFT_RESET_PROTOCOL | CSI2RX_SOFT_RESET_FRONT, csi2rx->base + CSI2RX_SOFT_RESET_REG); + /* Reset individual streams. */ + for (i = 0; i < csi2rx->max_streams; i++) { + writel(CSI2RX_STREAM_CTRL_SOFT_RST, + csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + } - udelay(10); + usleep_range(10, 20); + /* Clear resets */ writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG); + for (i = 0; i < csi2rx->max_streams; i++) + writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); } static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)