Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4177745rwb; Mon, 31 Jul 2023 02:47:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+PzOKb2Ot90iOpTXAMmcs7hctzcFrk5dmWQ28FXYV0+Y5/pGpridhS/SyWbZ8ycovp8df X-Received: by 2002:a05:6808:98c:b0:3a7:215c:e34 with SMTP id a12-20020a056808098c00b003a7215c0e34mr4054600oic.15.1690796856732; Mon, 31 Jul 2023 02:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690796856; cv=none; d=google.com; s=arc-20160816; b=lk9TnhkYbKaOZe0Ym6HqinNFlbJs9hcl5JmHc9NUSiLZT3m23XTmhZCM3/HeflbUAd CnxHmr7VjBLp29JeuSHPs0SdSvSU9Ci4OF3d3hXj7CR4826YBpLKwsq33P6Yb8qMm9EZ mq9UYBEGtnPxGj2QC2MvjVK3jotHHy9R/Jz0lKoDf22p9xrorGGlecDz5eU8J/4mOkL3 dcVJqZapx7L/UFSxogPPE4bKZB3a+N1cm/nRM7om2/Waxyu8cQvNe3oOfN41GQIPoRRe gwTRGPK63+6rU/fImH4GzgMf8sQn+dgRDlPx5//lZne9YTJXrNUBNfUVGdIem+uT1yg9 1U/w== 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=tQ6ZBBMuZh67BF7DUCMEDQQSmQ2RVx3GcJBLcvVDOSI=; fh=V3yzwYxt4PgbnoX3kc2m6CeiASFvGUTpa1ANjIQvoCg=; b=IcA6SlCKzVd3vkggDwmWrUMiPD45K6TXIyMayLdb7n41+nUNqhcbIhxdtVZ0iPJOpv NsWsKWhqP/Jm1eTySXhfoAQMMQzTnMnck9QRJGVKCzmZZvXKdqy2corebNHpULPUhdu/ KjSZVMVCz+v/PpL9LqT6u3d6Kiwa2GHrPKhW7pM5vlndqmRt/LjnbXrEf0DAZB0YmOMR 7NYD95/lVI2xNeFhH8YRufO/b1Wc/LszoRODY5rsDeckm1m4MNGrPtYDwbHpkE1Ykw1U +oYf/kW3ExLs4WGhBT7/fyP74zC0SsXL3mTusSoLhrs/bJuhOtfxoxSyUJOCi/lyB7Jp x52g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mbUZcOCW; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg14-20020a170903060e00b001bbfbe6bf3esi3377361plb.504.2023.07.31.02.47.24; Mon, 31 Jul 2023 02:47: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=mbUZcOCW; 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 S231565AbjGaIad (ORCPT + 99 others); Mon, 31 Jul 2023 04:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231183AbjGaI36 (ORCPT ); Mon, 31 Jul 2023 04:29:58 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085AA1A7; Mon, 31 Jul 2023 01:29:55 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 36V8TlSY128730; Mon, 31 Jul 2023 03:29:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1690792187; bh=tQ6ZBBMuZh67BF7DUCMEDQQSmQ2RVx3GcJBLcvVDOSI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=mbUZcOCWDB0P7t7fFV6doayIlQBWP7++dzWwm2yhAA/0Q3hzIcqLaQIFtWGfucX9X vTRJg99MTbk1E+eEozx66XX4Ig6U/9agyco6KZtiR9apPfxGeLFDgzS6eupM8kUVDp giMMlzIYcveOPQVzc5BMcbX6aUYsNCgZp53rvhYQ= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 36V8TlI4087159 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 31 Jul 2023 03:29:47 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 31 Jul 2023 03:29:47 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) 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; Mon, 31 Jul 2023 03:29:47 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 36V8TkGu041962; Mon, 31 Jul 2023 03:29:47 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Laurent Pinchart , Tomi Valkeinen CC: , , , , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , Subject: [PATCH v8 10/16] media: cadence: csi2rx: Set the STOP bit when stopping a stream Date: Mon, 31 Jul 2023 13:59:28 +0530 Message-ID: <20230731-upstream_csi-v8-10-fb7d3661c2c9@ti.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731-upstream_csi-v8-0-fb7d3661c2c9@ti.com> References: <20230731-upstream_csi-v8-0-fb7d3661c2c9@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=openpgp-sha256; l=2495; i=j-luthra@ti.com; h=from:subject:message-id; bh=/nT3CbZiw2p97e7tgRwHLuHzcybKAmyi7/0N9VjkH/A=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBkx2xrVs66TvdMqigX3AtSIeJipg4DpYUHL+ARM MhT1XT/bBaJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZMdsawAKCRBD3pH5JJpx RVN+D/0fAI31Zonm3IDXv8qu8vnYZ5wDJMhz/QOGLuBz+Ge0S3Vj539/uDLcs/2IZkV0tO6eOEQ TIQQjAoSbiF22ZXUl2GNzU+EaHdzdjezuGRkrzyz2vTzXz7B56qo3oB66gEihGvojfjXUDtVfj2 NNOw+frrPu7WYILUC9BCQ5PtMGCHT2qZ4PF9wLUvKMSUBxeLXYMOleNhQCsX0CRm5BXC3S2DUJX eTcKyqbo5lWumpOQ+o1LaUoWC7148KyWYHR0fEJWSv25E8azBZbgGHQkY4KCoStpH4dqf//LYXf 5PZSf6cxNKl8wqCF9KdeBYDVhK86GVFEuKYkvfnIohJ6Gv2BOv8Nilj9JqM5omz34Xf9PXhLlIl jZJ1gOglvqEHuHuE7rgWmcods3j6xCCqj69kJo4i6M7P7MHrE/g9iYExLpUbvCeFN3bIjyFzenD 2m5Y1L4csjmWQkC62QtK23S6PRM7y+Hjj/vaikXIMAGsjymAD7Ygsn7+Cu9FDjh3f9/J7gorjKh 8BgrKXVpTAJEcpAQQa/z3XCGtbNJBsHzld+dn9U6a2hV7ALtI2lFpxXksKQ2ThqmZn5Kug8F4LR fIZpI+hi0vZZYIoqdF5N4FXO+AFNfctzWq++1yIBYPvtRRdVdlATaCPE1uDjkkmAlwdVWUS9xei aAJYzRfvxEIibIw== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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 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 Signed-off-by: Jai Luthra Reviewed-by: Laurent Pinchart --- v7->v8: - Fix bug where intention was to wait till stream status is idle, i.e. STREAM_STATUS[31] -> 0 - but we were instead checking the opposite drivers/media/platform/cadence/cdns-csi2rx.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 30cdc260b46a..a17ef88dff82 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) @@ -314,13 +319,24 @@ 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 stream%u\n", i); reset_control_assert(csi2rx->pixel_rst[i]); clk_disable_unprepare(csi2rx->pixel_clk[i]); -- 2.41.0