Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp487546pxv; Thu, 24 Jun 2021 12:26:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLA7fQeoVlckR8EjuRsLJs6Qy5SpprOweo6RgzwqsgNPDLiV0UwovEr58JJhp8mVH94RsZ X-Received: by 2002:a05:6402:40c3:: with SMTP id z3mr9084464edb.375.1624562791531; Thu, 24 Jun 2021 12:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624562791; cv=none; d=google.com; s=arc-20160816; b=asm6TjsJsDNGHOZU2LYo+jrwncqAJICUrQS4AfjujYhS4kqyIyqTiFJUFgsOJaCaK0 CTJlbOuojY+9ab+1TZNq8yePMVYKe7svHY32vq9pZsVH3JAbEI0XXWle3a8K3QCIYI2t HZ0uI5JqMjdiGH5MGnmc8KHUqNqqx1YLY3jn7gGJAEeFiP2ngrC4/GOLg6UleI1onjng gsUyW5+05jGe8s/SwqBvTzCerTlIio9+sET0DYTfch8Iv1dJ/yTRTWAfwzmc2ug4Njah 7EvRihS1Zv30X7WtwxT63jy3zFrTZqRhPOAl5gU9AXN4hbISgxZ7/0L9ndpwYW8WxZO2 0XNA== 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=5vgH9+Q5dkeV+iA2ccYP34gskHwhoifbJxU7sUk2f+I=; b=S6lkBgKFb3wQabLuehCVaOc4M/wKcYsV4+f5t1EbHi0ganVXBALrcfOv0J/cjopLxI F0wQe65xd7y/YJggbJk5bq0zc7bfDQ0Zbr4W2fS07RVg3lyb8yA2nbCu0dRYpqLo2kPq smHElEsvrlVfYMahgQOti0te0+nk7C4VTB92F1Mw5gqc9oBCPfPiYVsr3bydvMur9IUO oR6DiwWbp0Vn5SyRtabyYx819r2yDr90nagL1qDfWzoKpWGWuDOGDUkJ5ugti7qNq6kJ b77rCXBLn95lFfrO9XHlthzv9KebcWulkAlURsBj6mkutqqrSYLHMKbOj10akYOkvrgX uXBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eAKhVrp1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si3963043edr.513.2021.06.24.12.26.08; Thu, 24 Jun 2021 12:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eAKhVrp1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232856AbhFXTZE (ORCPT + 99 others); Thu, 24 Jun 2021 15:25:04 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:51336 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232818AbhFXTYw (ORCPT ); Thu, 24 Jun 2021 15:24:52 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 15OJMUWZ043461; Thu, 24 Jun 2021 14:22:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1624562550; bh=5vgH9+Q5dkeV+iA2ccYP34gskHwhoifbJxU7sUk2f+I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eAKhVrp1sNgUpVsoPqIJ6usQ5qW1mTl8V2msNG9DKhm1vQaj8ryX4woIxZCoRODFD loNNfsc/DZ2jvAFnf2vgS3iITtumNTcH8Gnby4D1WANZ397buMhJ0j7mvhBTWoW4tN YhnmwSb+U+ZgsK8o1OvQ66H9PMydwIrAz6zvhEZU= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 15OJMUBp086126 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 Jun 2021 14:22:30 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 24 Jun 2021 14:22:30 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) 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.2176.2 via Frontend Transport; Thu, 24 Jun 2021 14:22:30 -0500 Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 15OJM14L120548; Thu, 24 Jun 2021 14:22:28 -0500 From: Pratyush Yadav To: Mauro Carvalho Chehab CC: Laurent Pinchart , Vignesh Raghavendra , Tomi Valkeinen , Nikhil Devshatwar , Pratyush Yadav , Maxime Ripard , , Subject: [PATCH v3 05/11] media: cadence: csi2rx: Set the STOP bit when stopping a stream Date: Fri, 25 Jun 2021 00:51:54 +0530 Message-ID: <20210624192200.22559-6-p.yadav@ti.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210624192200.22559-1-p.yadav@ti.com> References: <20210624192200.22559-1-p.yadav@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- (no changes since v1) 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 379bc163d4c1..34d4829a0d87 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) @@ -326,12 +331,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%d\n", i); clk_disable_unprepare(csi2rx->pixel_clk[i]); } -- 2.30.0