From patchwork Tue Mar 14 11:55:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishnav Achath X-Patchwork-Id: 69525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1715001wrd; Tue, 14 Mar 2023 05:05:29 -0700 (PDT) X-Google-Smtp-Source: AK7set/HqB4PusiBfL2mzqGK+hjHQlDMGZLVuc2GH1H3o+SIBXslnN+AkAf0lBe1oIKfD10LYJGN X-Received: by 2002:a05:6a20:918c:b0:d3:3e9b:4907 with SMTP id v12-20020a056a20918c00b000d33e9b4907mr13268870pzd.39.1678795529125; Tue, 14 Mar 2023 05:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678795529; cv=none; d=google.com; s=arc-20160816; b=AxN/yJlV+K3Pe0Nta0kBeXkEyvMFjoMM1T6ZkwnzcsoWUHUZEJYy2d0RqvhBuMNoeA 6BvbE8ld1rzEQUSg5zdAUSIeTnO6JuSSg/4uMUIFOfbneIe496lXqZIyzrHKkBhUIG7e R0fFTgag5jHkow2Ps3nO50aKwTD0RJ3ybxM1QTU1mCQKxrxFyFqt/NO3+FmxWTrdtaMe SIMew/vKhHUk+HPlbHEY916rT+w3jBwi2lm6PvycPJ9UtdRnhZ+8AB6j2kng0ATHov55 7if5QpgDMjh6BsPcgnBUeOC1AYbQ1yAJ7/T3qKGosIPJuY/m6Rn+2+EeEjZRO/LyTNFS lgOQ== 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=JGSN//92xgAzRXhFvRWWriqMgsTJzBHHxKA2Y6028FI=; b=RibfM/40qP0dOyq7KOPxJs8KokfwynMP2hzZcDX4AsFsggJgzVPO3fZpWaeWtn97pW CVqAr4zB5AmJ9UetlhqPyg9UeY4XeU8N0ctP/i//olnkO2Is9uZRY5S/m4R6YWIiBg0F KI+Yo9RjgfcJ4eTaMDhwGl2ramgIYb+67lJJDKEDiYz5eJIhEuhK/k7vdp+Z2SbtRHFt 4LJjptbCzPyfi8udyDYCeMaFu8VSioVZBMLQGhPF3T4XiLpV7UcanmrljH9PZUnn0VwA drytYTU5Y2YfVvH7AkJUpTOd8+xqBvUKZlNHLf0xO6CUhdTa3pLHSA7OE2IWnb9A5aC/ npNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="XNi/HoXE"; 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 t6-20020aa79466000000b005a8b3c6b5c1si1994375pfq.245.2023.03.14.05.05.14; Tue, 14 Mar 2023 05:05:29 -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="XNi/HoXE"; 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 S231550AbjCNLzt (ORCPT + 99 others); Tue, 14 Mar 2023 07:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbjCNLzr (ORCPT ); Tue, 14 Mar 2023 07:55:47 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048CF86DF3; Tue, 14 Mar 2023 04:55:45 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 32EBtULE105814; Tue, 14 Mar 2023 06:55:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1678794930; bh=JGSN//92xgAzRXhFvRWWriqMgsTJzBHHxKA2Y6028FI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=XNi/HoXEnzqQaQ77lAH5e76/8fMAZvFDq+/0IGnWvj7q6YXHToRfzmcCrkvJnqlhB 3fMfM6tMNDao4N5XLEjKPaoIcNTY1P/LSsuJnYXeO1xHhJQldkLL4tD6/MrC+NKrBe ox9/jcf/ArwkZpNl/4vv2+P/J331OQNa0tU13Gf4= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 32EBtUT3003074 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 14 Mar 2023 06:55:30 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE109.ent.ti.com (10.64.6.30) 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:30 -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.16 via Frontend Transport; Tue, 14 Mar 2023 06:55:30 -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 32EBtTgY111843; Tue, 14 Mar 2023 06:55:29 -0500 From: Vaishnav Achath To: , , , , , , , , CC: , , , , , , , , , , Subject: [PATCH v7 06/13] media: cadence: csi2rx: Set the STOP bit when stopping a stream Date: Tue, 14 Mar 2023 17:25:09 +0530 Message-ID: <20230314115516.667-7-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?1760344700565746652?= X-GMAIL-MSGID: =?utf-8?q?1760344700565746652?= 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: Vaishnav Achath Reviewed-by: Laurent Pinchart --- (no changes since v5) Changes in v5: - Change %d to %u - Add Laurent's R-by. 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 8ecd889690b7..e80220840e93 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 @@ -40,8 +41,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) @@ -304,12 +309,23 @@ 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); 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); clk_disable_unprepare(csi2rx->pixel_clk[i]); }