From patchwork Mon Jul 31 08:29:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 128542 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1908538vqg; Mon, 31 Jul 2023 03:03:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlGfcrlIRxZTSqGokQuYO8QBC45QV/4JSctEv5ATrewWqfUTZIhzMeTXt5LlLPAvzHO5YqpL X-Received: by 2002:a17:902:ef8e:b0:1bb:2d0b:1a18 with SMTP id iz14-20020a170902ef8e00b001bb2d0b1a18mr8040205plb.50.1690797824719; Mon, 31 Jul 2023 03:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690797824; cv=none; d=google.com; s=arc-20160816; b=wdeiZYeZTA7PRdG1i1V/1U115oCTHU1nZpLal7it4HLvpLOYEpHf8d7etnvkqNuxgt 74SdfYxFvuOfZNSRDusBx15ieRKR0d7FeWLs8t0LFI42CetM/WWINRKiGdIu8Xduh2sB 187Q22wd91KXmoPItE0HnD2ApvIh/rzkgCJ2laEljKw3YheU/aS43lfdZcD+LM+nqLtL boRwr8QYVXsy5JortdUF6pyhPOZTJhxYKHLDoZn7RPKS8fS8a545ylFbNkcSNnnkvbby 0si1yzJxmPVgHZjSM6Q2cLzjv+BLBISXi0YTeVGuNmxZfkdKfLDuFofTDc47cSW+76gW ln5A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a170902f31400b001b8a8f7af21si4101120ple.557.2023.07.31.03.03.31; Mon, 31 Jul 2023 03:03:44 -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 S231977AbjGaIad (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 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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772930019716679821 X-GMAIL-MSGID: 1772930019716679821 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 Reviewed-by: Tomi Valkeinen --- 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]);