Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp486133pxv; Thu, 24 Jun 2021 12:24:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmkKzHJewdObpV2Vu2H0nII2LHuRGfSsq0THbZR1WqWx1GSl5pMrz2bYK4XoCU4Wi3lVhl X-Received: by 2002:a17:906:f285:: with SMTP id gu5mr6855654ejb.226.1624562654436; Thu, 24 Jun 2021 12:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624562654; cv=none; d=google.com; s=arc-20160816; b=yVg41OkbwnWNBcwi5OZM+9UX/vAJs9DbhjzFdwFAMxE4SUfVSpioy1oH9wQQzZgUUO Iv4Ut91fctukg+aiHy+ErlN1MAopXBME+OkqHDnwwylQ44KyYvqZbLDnGrLPLpsvhDiT zzvFEbPG4KLKI/WI+oSikAfI/tnHtWLGXBLUZhRs2Y8AszsLWnfAzrxWiUkQdxpGK4X6 Hwu7bL7RliMvbGhjZ3Xtj4trnBjbbdMusHZMxziYx3vIjmBsIPbkB60gvTL3NeQ4aoSB rdL0Cv4o03AYpYxJt1inIgg4W+8iVivj82xBGoi0XzeGeN9rqu7yUDki3To75u/zibfM PaEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J0vYLX1VEIIhvtOEuWuQOTgbjYsk/PtZul3G3ueX2KQ=; b=S5lL+kV4hdJ6ds2YJPnIW6/psnpqjyo+ZkEHw0zXCgLkef9ebNrmYFJSOTz8M/ngpL bXXQUc/8l3dgcTwIQ0ia9v3GmFnaraEnWHw64b1I/KJapv6WNdaR4vqpTPJXBtTxKLwr UvbxWTHqdupHxkv4b5l9hRnE91a74cwoQ6GAwG5ce8wpernbTYZDkZWQZA5gD4JxsdFI HLq65/OZ4MhulVF5IgKUAbLkmb8up8m5DB0Tggzx8yRYdToD7Qf4uT8JU43IkRn0Lh/+ s/VLZ68mIAOFVUf8K1mquvlrqea3QV4BXzvs8H1V7EJkz4eF9pNO7rlVtOOX3LydNPDE nYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wkkFKo52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l25si3696640edq.261.2021.06.24.12.23.50; Thu, 24 Jun 2021 12:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wkkFKo52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232833AbhFXTY7 (ORCPT + 99 others); Thu, 24 Jun 2021 15:24:59 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:51304 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbhFXTYu (ORCPT ); Thu, 24 Jun 2021 15:24:50 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 15OJMR8t043449; Thu, 24 Jun 2021 14:22:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1624562547; bh=J0vYLX1VEIIhvtOEuWuQOTgbjYsk/PtZul3G3ueX2KQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wkkFKo52DNTrCKW/IDAeABhotHxkvHk+j3dDaZvk3QA2KBzBeOxlBzU61J5aSD9Hd I2tr3xTwOU2z/pveA5AOZ4UlMOQDmAYY6+ckrrtzSrXzCZJ6D+mSV4PD2VhFmBoss+ edXxDDUsnPtExRIMqdlQfWdClJtH44FzkumRW3NM= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 15OJMRYm057861 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 Jun 2021 14:22:27 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) 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.2176.2; Thu, 24 Jun 2021 14:22:27 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Thu, 24 Jun 2021 14:22:27 -0500 Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 15OJM14K120548; Thu, 24 Jun 2021 14:22:25 -0500 From: Pratyush Yadav To: Mauro Carvalho Chehab CC: Laurent Pinchart , Vignesh Raghavendra , Tomi Valkeinen , Nikhil Devshatwar , Pratyush Yadav , Maxime Ripard , , Subject: [PATCH v3 04/11] media: cadence: csi2rx: Soft reset the streams before starting capture Date: Fri, 25 Jun 2021 00:51:53 +0530 Message-ID: <20210624192200.22559-5-p.yadav@ti.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210624192200.22559-1-p.yadav@ti.com> References: <20210624192200.22559-1-p.yadav@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- (no changes since v1) 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 d86be917135b..379bc163d4c1 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) { + 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) -- 2.30.0