From patchwork Tue Mar 14 11:55:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishnav Achath X-Patchwork-Id: 69551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1720685wrd; Tue, 14 Mar 2023 05:15:49 -0700 (PDT) X-Google-Smtp-Source: AK7set+0oRjrcoVbVIW/jtTjG65KhC6WgrXktlp/BEGCeZ9bQoLGUSlqRTPfXUCgzJ2FDyJGKQ4B X-Received: by 2002:a17:903:1251:b0:19e:d60a:e9e with SMTP id u17-20020a170903125100b0019ed60a0e9emr29349805plh.42.1678796149180; Tue, 14 Mar 2023 05:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678796149; cv=none; d=google.com; s=arc-20160816; b=yJ7ldUR1+JPuaaVgG1DttuyDnuoqm7l3YE0lgNWhJs1DLzSXWFTxR0Syvj2E7I16gF PzX9K0CoffIzA7BJFZt0ghuHdlhYYgkJOt1E/I6uda1211D+siRF9WrcpUKfjj6GyFZq AWUOSwd34gv7cTwduIyt5+S2CD4M6AidSTHYyhwki0m6tVRSlei3rbCakQy/RAgEloT8 wyacTuIMQUV0ovBkSFgdFz+OFBHU3pPt5fmVMLDi9HlAgRDcVOXeb58Iuh1bzI6QIAbr fD+r5cVVmEz39eqEf8Zab33s4DTBxyLdUQo+F/SPtyAWhTf6uyEZgurD5lpf6yHzUXKV EL4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=O4xsDatyGPKQX0onRSd0fgi9UJM7fBoDvmCijQM4SEw=; b=IqkE3+UjMZ+VZIiw1pTtZ4F6ONxdCxsDIEYZtIkNvtw2AxRGA++gTtzW2mWae4PPj3 dHjVEriBRX5mCTSaPP3Rkz7oizbwB+UXrWajAfrDGdK46ww2+Zxi9MrFeEmkKa1e4sFV OjZnxC+yjrqqMO/7OdxsygWNIGfQmlHpdwz1IdOQivKmKwH1jGRnt8QbCFNPmshLQBNm OR7l016lv0/3K/9NejEWSyhvgqRrVa/+T15CQEZ6lHD3/GkW/ed+2fNGOuWyQsVJYVUG PahfgYeq5rH+pqG+WQ9/40nrtkPDOj//XiLNCggwps45kaHnB5Q5BmRd2n6rOhEl04oT w3pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HOaKGRpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lh4-20020a170903290400b0019ea9a23140si2309463plb.309.2023.03.14.05.15.35; Tue, 14 Mar 2023 05:15:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HOaKGRpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231531AbjCNLzr (ORCPT + 99 others); Tue, 14 Mar 2023 07:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjCNLzp (ORCPT ); Tue, 14 Mar 2023 07:55:45 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9926382A99; Tue, 14 Mar 2023 04:55:44 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 32EBtT4n056385; Tue, 14 Mar 2023 06:55:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1678794929; bh=O4xsDatyGPKQX0onRSd0fgi9UJM7fBoDvmCijQM4SEw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HOaKGRprFKhOYXhPxc/z+dr3IyNBFaRLPVBKEM5MMs0flh/F2CHNz8kLPK6qYaYCF PGmcltUmucXdeCHj1pBrLJg3H2Torba/ZxxvLs4ZEvMuV38k05gcTzEBjtfJxh13sI UAuKY01eUEA7wDyZsC4AYVbXB3cLr0HmzTTM1a6U= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 32EBtSGJ003014 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 14 Mar 2023 06:55:28 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 14 Mar 2023 06:55:28 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 14 Mar 2023 06:55:28 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 32EBtRfF057265; Tue, 14 Mar 2023 06:55:27 -0500 From: Vaishnav Achath To: , , , , , , , , CC: , , , , , , , , , , Subject: [PATCH v7 05/13] media: cadence: csi2rx: Soft reset the streams before starting capture Date: Tue, 14 Mar 2023 17:25:08 +0530 Message-ID: <20230314115516.667-6-vaishnav.a@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230314115516.667-1-vaishnav.a@ti.com> References: <20230314115516.667-1-vaishnav.a@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760345350806368525?= X-GMAIL-MSGID: =?utf-8?q?1760345350806368525?= 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 Signed-off-by: Vaishnav Achath 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 6933626adfc8..8ecd889690b7 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)