From patchwork Fri Aug 11 10:47:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 134423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1016761vqi; Fri, 11 Aug 2023 04:29:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFH+iScx/NcZUcWWrpZ82PKzydHSVuBuPAotzglfYx4F4QZRXmNkYeXGEtQdW5y2Ezggker X-Received: by 2002:aa7:d40f:0:b0:523:a1f:1b50 with SMTP id z15-20020aa7d40f000000b005230a1f1b50mr1533222edq.28.1691753376342; Fri, 11 Aug 2023 04:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691753376; cv=none; d=google.com; s=arc-20160816; b=h0r32FHzGkBLA1dPHkSM7Vrzk1+hq5OzRnbmTwE66H8tscSrSxubizb7Rp5WRd2meH k3jrPl3qPOD0g7j/bmYJuFmCa/Hdl/UaeQITlQjNb/k1vT5WMT6GtdjOEDXl8807uxbo ZPoMBVZxzbEO9GWCHTSxuwjyDq6eQ+59y82TT06Xeugv/BuA3UCjBh7c2T8d4sDFYiXl sPPwIcO8O3FuSZ7+iXoOqUJivKRvdwrgRjlULI8dCgymx9pV4BObYu8yDCeay6EISeLf FT4pS9EppUOafazWRpLWlTXg7xvt16yj2tfrXguHG8qv+5wsFJew0r4rFepF0zpizYXp Q8wA== 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=pfeJn5pyuS1Kn375QoTKmqM/B3qqrMhFRPx327xhsos=; fh=k9bcrvr0E/Y9x8inCQPBEuuvszlC0pPMsAktFCa61vM=; b=BCXJsMdEmAdQYLhbxh1y0fTYMxONXjEhrd84qwp6t3bV+jaa21GORiFfduUi3v6XKJ TA7LycRBMUrd3IqTOwL6uVmuu8dPG6XTJD38dmTF5HguacaPz2quSiYbjM4qFYOxVQaP 7TChnr5aLYgv1vOwIjLB1JJ3VZbsuUQwxH1mODKvy5JX2BkeXdejZk7XSVI2PZaKm6gC Qd9zcR05Ou0rt7tsXxTGicLmgCf5Xua5jU06YTAs0dtJ9g2OM3NHrw8eZ5XBybvdVwfk XRChpfYaNbKDCYbGzxXzZQ0T2CCocGrmIRqx4YHljiX0O+t+hI8AYOCg3QavKml623Cs Gm1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=gIbjb+Uw; 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 n4-20020aa7db44000000b00523384d6840si3099396edt.453.2023.08.11.04.29.12; Fri, 11 Aug 2023 04:29:36 -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=gIbjb+Uw; 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 S235907AbjHKKsc (ORCPT + 99 others); Fri, 11 Aug 2023 06:48:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235538AbjHKKsQ (ORCPT ); Fri, 11 Aug 2023 06:48:16 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA9BE52; Fri, 11 Aug 2023 03:48:15 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 37BAlpxn092957; Fri, 11 Aug 2023 05:47:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1691750871; bh=pfeJn5pyuS1Kn375QoTKmqM/B3qqrMhFRPx327xhsos=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gIbjb+UwYG9ssgfLaDISc9GrdglAG+3A3uGe8GTcMeWr9YOj0g9stuL5NzU6YjRfy o2kOgftOWEWrdSRAZmSfq6OAf5YtVb1dEmJUZR08IpBojFrngPWoSCNkZNnGQzADi9 p59zffgdTEIyIXe+HaZ2pV1+TpSjlSA0wN2am5kk= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 37BAlpGg110742 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Aug 2023 05:47:51 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE108.ent.ti.com (10.64.6.29) 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:51 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE104.ent.ti.com (10.64.6.25) 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:51 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 37BAlo43060405; Fri, 11 Aug 2023 05:47:51 -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 08/13] media: cadence: csi2rx: Set the STOP bit when stopping a stream Date: Fri, 11 Aug 2023 16:17:30 +0530 Message-ID: <20230811-upstream_csi-v9-8-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=2584; i=j-luthra@ti.com; h=from:subject:message-id; bh=B9IsBzzslnxknnw5dp9TzgoPZyb3XNoa/gIIm3UOPT4=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBk1g8DZlrpcKDW2I0NMphSc/hdLQPuTsHKoXapk rWT7sAXJXmJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZNYPAwAKCRBD3pH5JJpx RXumEAC4O92x8fA2Qul+1He0FNQKRLbq358F7DtBxFxn1dwqq/nsAU97WYEobNA9dTR/rdfE6o3 YHHZyGzBw0fS9e4mXT0C+twhKLpdYbrC5X9r4LBx0GMH7Ggw4z2W+K+FjFTM19jC3uKmPs0hNlK I/C2OIF+mMtM9M2M/zNlSCU1wAKotUXN8dudq52DTme8SuBQJGdIra/IyKgcZIf67dxCCJqV3+Y mMdVyyMeeAwVPBg5tEitFRWS1RB3oq63v0HGtF10kHKyt6OEYSsnccHQaKJPd55fOixVE5DIkWV Jxsj1Qq9kHoSob2QnaRd2+MaLaUIZ6bX5m5bRFPbhMQmsVOEGTZhMSq97u7Q4i7QvUyHv4JQvv3 nMsS+27QFxJVbhmuAUociaKofSkqKtwsjaDrrIJBKZ2JmJLbmO6KZaqBIV0+0wx5TblCbQFGoOl mq20EMLs1jnkHgv88W03DAl174SWTehzl50Ltdmi0bWVyd3svGYbMs98w1V6cr+BegklQ9E/i4u qHj+6BM39svgFBBqMn23OsS05HGZcHLdqRjAEp0ru2crtrQoRkSdgkmEi0UrMw5tz1PnKdOdYGG jHwQhubJGu6ZEzic9kenTK3Bep6MddIXi00/Es/RQ/CzOCahx82rKMWeFxvktAI7WtWMPXEcFcG QP+cZbYempGBJwg== 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: 1773931988712060906 X-GMAIL-MSGID: 1773931988712060906 From: Pratyush Yadav The stream stop procedure says that the STOP bit should be set when the stream is to be stopped, and then the ready bit in stream status register polled to make sure the STOP operation is finished. Signed-off-by: Pratyush Yadav Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- Changes from v8: - Better log message to avoid confusion between cadence streams and v4l2 streams drivers/media/platform/cadence/cdns-csi2rx.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index b57e0c3b1944..f8205c3a28c0 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -41,8 +42,12 @@ #define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000) #define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4) +#define CSI2RX_STREAM_CTRL_STOP BIT(1) #define CSI2RX_STREAM_CTRL_START BIT(0) +#define CSI2RX_STREAM_STATUS_REG(n) (CSI2RX_STREAM_BASE(n) + 0x004) +#define CSI2RX_STREAM_STATUS_RDY BIT(31) + #define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008) #define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31) #define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16) @@ -310,13 +315,25 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) static void csi2rx_stop(struct csi2rx_priv *csi2rx) { unsigned int i; + u32 val; + int ret; clk_prepare_enable(csi2rx->p_clk); reset_control_assert(csi2rx->sys_rst); clk_disable_unprepare(csi2rx->sys_clk); for (i = 0; i < csi2rx->max_streams; i++) { - writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + writel(CSI2RX_STREAM_CTRL_STOP, + csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + + ret = readl_relaxed_poll_timeout(csi2rx->base + + CSI2RX_STREAM_STATUS_REG(i), + val, + !(val & CSI2RX_STREAM_STATUS_RDY), + 10, 10000); + if (ret) + dev_warn(csi2rx->dev, + "Failed to stop streaming on pad%u\n", i); reset_control_assert(csi2rx->pixel_rst[i]); clk_disable_unprepare(csi2rx->pixel_clk[i]);