From patchwork Fri Aug 11 10:47:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 134431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1027195vqi; Fri, 11 Aug 2023 04:47:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVcGqPpB3X1ms9BWJhUHayAXO68TcKbcFNekqMXpwYTZtf6ZtCWErLemt6eOLqTRZlqvOg X-Received: by 2002:a05:6a00:2d86:b0:67e:e019:3a28 with SMTP id fb6-20020a056a002d8600b0067ee0193a28mr1385616pfb.16.1691754473381; Fri, 11 Aug 2023 04:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691754473; cv=none; d=google.com; s=arc-20160816; b=RqNeCMofOObfFfBW8Q49tsrllD4qfn8UldgZV1q91dojFYrwrLlTZua2Jce3FCp0pB flqKLK8NBPMPLilfH9cW43lNGmOKdl7plj9ik+hHOROHYDpeoe7K95QlGAB4Sta6EfkN K/vCwPRcwiEokWr+0T0oJpFheGqaVEhni/u+bZI59NSNCCH1V/nzajF0RKe+hmK4g9/h 5aS65m/5RgOspT+Zo6R5DYJ7qVDU53DM0183Qi6AP73hNSBg7vkugd/fkmgZhxcA98gq 42Ov79Sm6Yt+GUSA3k+2033jcQ759U7/WTVikL9LEZDGzEhTrhO5GB9Ot7jwLPSdfQt7 J4oQ== 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=Jt/CtUJuvXw143SkqQX5c8m1ZObK6v0lOQaL9M+GqKw=; fh=k9bcrvr0E/Y9x8inCQPBEuuvszlC0pPMsAktFCa61vM=; b=KqF1LJ8w/kqotKH/qz57ovVceJCoYiTxLD9FSBUi0GkdR7YmbI1uBcfPKPth1P1HB6 E0eLbBPzTvNVV7RMfkgTWtOkpu3msxOKdZsQQohfDjbbRyB6jz55l+c4nR0Ofe4shpxl NF0DYAtJsliOKYpGPKt5QvFDwXf+ZiX5thzaxGIpZXMqmpxwKyLFGDq4taG2kquSFM6n rYzWS7EXPhYrYD0Fxjzf6lVi/R1QWZqAvAr+aQIWIZuHDSPVufMHWnKpLA76wIHTbcz/ uPe4OEiD5Ckg+06fmF2CIxUfVE+VPZ9q2KMy0Zt/xoAiWOt97D4Wqmjqca+lVb2nZN6a gARw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=p4wfv6oj; 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 y42-20020a056a00182a00b0068756b49d3dsi3437034pfa.69.2023.08.11.04.47.39; Fri, 11 Aug 2023 04:47:53 -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=p4wfv6oj; 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 S235738AbjHKKsT (ORCPT + 99 others); Fri, 11 Aug 2023 06:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbjHKKsP (ORCPT ); Fri, 11 Aug 2023 06:48:15 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3A6BE52; Fri, 11 Aug 2023 03:48:13 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 37BAloMi088936; Fri, 11 Aug 2023 05:47:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1691750870; bh=Jt/CtUJuvXw143SkqQX5c8m1ZObK6v0lOQaL9M+GqKw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=p4wfv6ojuUec7N/hdWdI3pYKP0uTZmj/QRklyuANk5+KwNBRoznYTW2LQyUWrYX31 ExcJdQQ8+ndaOkgBEl5czBlZaHqNijkgxSyBtqqbe+1xHC1OJJqxovfX52574bTfv7 ms7gdWmYrM8TKRjNtl5CXO1LZcxeFK6uOBDOkSaY= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 37BAlocc041945 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Aug 2023 05:47:50 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 11 Aug 2023 05:47:50 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE104.ent.ti.com (157.170.170.34) 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; Fri, 11 Aug 2023 05:47:50 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 37BAln0w008272; Fri, 11 Aug 2023 05:47:49 -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 v9 07/13] media: cadence: csi2rx: Soft reset the streams before starting capture Date: Fri, 11 Aug 2023 16:17:29 +0530 Message-ID: <20230811-upstream_csi-v9-7-8943f7a68a81@ti.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230811-upstream_csi-v9-0-8943f7a68a81@ti.com> References: <20230811-upstream_csi-v9-0-8943f7a68a81@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1998; i=j-luthra@ti.com; h=from:subject:message-id; bh=ND2+AeL/8naVEz1dLhGdl9YP2oZXLbJkqWDu7tykgBY=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBk1g8BdvyE3kkHeBUT1BHxluyU5iP4UDye9dIGD PHmzrG9lVKJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZNYPAQAKCRBD3pH5JJpx RdFRD/4xFvP4EG7d7m365bT1NpU3doOJKtBE57fyECqryuflTFrskWMNJzvdsFjxXt/i5j1oF// pGYQGTlk3jxI5HR8Lo477dkD0cKsDk7yWzfqZd06uH3Cjs6Qan/nfyaXQYFVQDQZBnOq56TPbMm AUCfg0ubTuJAXEov7N03WtpPDLVyEt81iRpkmrCz1XAFi5SaWJOcsoORzDQxNE1QQ4+XFxfq+n0 hYcuX3JjFStbI1fsb0ARhPLxibhqjkGcOEIC9u36en9sg1K+WLDOkS6VhQV3JkmR1w5+Y0I/7eg k9LIMaik4VEqZXv0UfF5GIIZw1mWGB2m8Gn7BUZ560+oFcY6emjjtpm5YiIA4SbXebZYx+UP+lO y9JH9ipz/6s2Ec1yM7xH4lG7Jc2b96DyosqEmtXNiS3ZFXIFP1nbGr7XTqTnz5mRQ9hB2WArrTT YB0WmXuKnUIYJskBXolm6HYSApkQUUunTlVfPpUViBgYy+sC63v8crXWmvqJqRY7MGG3cq9JSo6 Q1VEN6WCJu8AjOOluYDC4oMwRSKkeOHzXt63qX0fAgkTr7eyVUP4xy1k1Yi2tJcnM4w2a+I2/tm 2abHZMAS8MWLh9vZQ6Wvq7Trpa52Y4Lj69/UbwQiIhvEUC4Pa2KmOFLcz5Sktb3ap6tZ8RmC94e kgqIgDUs2OmClSQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1773933138722518281 X-GMAIL-MSGID: 1773933138722518281 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 Reviewed-by: Laurent Pinchart Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- Changes from v8: - Simplify reset sequence, minimizing delays 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 933edec89520..b57e0c3b1944 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)