Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1400639pxb; Fri, 21 Jan 2022 17:43:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxapFgtenddYIosxPugSl6VuluCDAwCLQUdSvG7fduG0oh0Ws3dBfpbTaaxv2VwPRHxqdTH X-Received: by 2002:a05:6a00:181f:b0:4bf:9100:c2fb with SMTP id y31-20020a056a00181f00b004bf9100c2fbmr6018677pfa.13.1642815827919; Fri, 21 Jan 2022 17:43:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642815827; cv=none; d=google.com; s=arc-20160816; b=RfyjCcU7LjiGElRrtg+yer6w/ENOE3XKjraafxZNAYrKjsPRJ5bCBnY5fwAYq2aHUv 4SrB856Hi6FFx1CPFmn1i5DklqA3xRbnq3XnVzbAnyll4yls2772m5QFVH5VH2KURAs9 VW1SBT7vJGKJq2a9N5zzeLS53Ja0dI9jUFAjmF3cyN/V2eGnUKp4G14HB9klHFrmhe4D fZbislE6cPV43Dqwg7PnsY8oYMTRS8aRQ+2L6fiIPHZps1VddLKROe3ICdo/7gqcSMfh DHmi7updyrEJq68w50fBa0qX4Wc0lavk2wRgFVh2IrWbDhpffx2LMU/H+PMsq1x14K7u xSgQ== 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=XbYAeanA3zKrezc/md6jUMSkGDae0yHwzSpQ9d0l7Lc=; b=lTeyW6pWq0FUEUiDR8GCQmOMGqFJOE6MhJph4lAVKV74GrWdNeNidt925/2WJPKczR 98eSvf4nyKmgLJLG2HgwTrt3jBS96hHg9tmzPGIVgBylmwzF07D44W0SBf/9lcXRttrR k6kHsqY6qKyg79I0GjrztVR9X6xRtKykAu2FgqeUOuKbStBsGSCgHlhhofqyyhz/9AET B3g/mEcw/6KGFIL2gyB3fjkZWxBoFSPY/pFTPZbW9Pqf4wd5Q3+mzzZwhQmph9ZLSl+1 FvGpyO4ek3uBgMkhhN6KzJN0c11FreJ6+9Svu6SKPScximayHMFzrtGwApG/tkWwIzPE yGRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bCHOuXIP; 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 32si4748079pjz.151.2022.01.21.17.43.36; Fri, 21 Jan 2022 17:43:47 -0800 (PST) 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=bCHOuXIP; 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 S1381197AbiAUOaD (ORCPT + 99 others); Fri, 21 Jan 2022 09:30:03 -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=20S=C3=B6derlund?= , , , 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 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 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) -- 2.34.1