From patchwork Fri Jan 21 14:28:55 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12719803
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 918B8C4332F
for ; Fri, 21 Jan 2022 14:29:54 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1381172AbiAUO3w (ORCPT );
Fri, 21 Jan 2022 09:29:52 -0500
Received: from lelv0142.ext.ti.com ([198.47.23.249]:51346 "EHLO
lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1381138AbiAUO3s (ORCPT
);
Fri, 21 Jan 2022 09:29:48 -0500
Received: from fllv0034.itg.ti.com ([10.64.40.246])
by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 20LETSME090812;
Fri, 21 Jan 2022 08:29:28 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1642775368;
bh=XbYAeanA3zKrezc/md6jUMSkGDae0yHwzSpQ9d0l7Lc=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=bCHOuXIPRW/Zl9T5fki8kiZbi1hz4fjcyhDNQFMSo59ZXPHhdsYq3VGHMwNNOdXMp
AtRY7jhT3XKnCnSOpLH/Nq3mq8C1xcxXouP28PTrirGXzvgeSssEes2XAGaXBE5u6y
spZwvpklfpTlkJD9AphyJNKwkYliB8MgRI1upLFU=
Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41])
by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 20LETSgL018820
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Fri, 21 Jan 2022 08:29:28 -0600
Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE109.ent.ti.com
(157.170.170.41) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Fri, 21
Jan 2022 08:29:28 -0600
Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE112.ent.ti.com
(157.170.170.23) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Fri, 21 Jan 2022 08:29:28 -0600
Received: from pratyush-4F-325.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 20LET4Hq072129;
Fri, 21 Jan 2022 08:29:24 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Benoit Parrot , Maxime Ripard ,
Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v6 05/14] media: cadence: csi2rx: Soft reset the streams
before starting capture
Date: Fri, 21 Jan 2022 19:58:55 +0530
Message-ID: <20220121142904.4091481-6-p.yadav@ti.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20220121142904.4091481-1-p.yadav@ti.com>
References: <20220121142904.4091481-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
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
Reviewed-by: Laurent Pinchart
---
(no changes since v5)
Changes in v5:
- Make i unsigned.
- Add Laurent's R-by.
drivers/media/platform/cadence/cdns-csi2rx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 489f0d6e80d5..346afb3578ac 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -39,6 +39,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)
@@ -135,12 +136,22 @@ struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
static void csi2rx_reset(struct csi2rx_priv *csi2rx)
{
+ unsigned int i;
+
writel(CSI2RX_SOFT_RESET_PROTOCOL | CSI2RX_SOFT_RESET_FRONT,
csi2rx->base + CSI2RX_SOFT_RESET_REG);
udelay(10);
writel(0, 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));
+ usleep_range(10, 20);
+ writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
+ }
}
static int csi2rx_configure_external_dphy(struct csi2rx_priv *csi2rx)