From patchwork Thu Dec 19 18:38:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13915522 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 434C619CD19; Thu, 19 Dec 2024 18:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734633544; cv=none; b=Mv/SROAuABfV9M+7wQ/hCeXWy5/MW8lndV/aqHGLXnyGqCruWbJG2y2ByvTA4LiCz7zNo9nfeceEbJAAUjKu7OvJFSsKdlOXQYc6CCnx9fZgxoPzPIwXoZxwhl7HG9Pmg2Xe0z7w7lDr4G4nCG/StE1rxF2BfVLVBuybHJ3nTQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734633544; c=relaxed/simple; bh=0eOJ9xP+vWFagtAHpZNh3Z76ejtLjXXDPg0SxHQq6Xw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IgvhYYToGSMCM1BEUj6zjSDmxAVcVkaJb3BD0X5BhJ93fTgRfCfHrcu0rogrlQx7VhV70fOXT1h69ecZaNeBLxn8I+Q3eZyq4esgl8E8zMaxdj8e/uN83VCgqKXUL53N9IbYlPjuWhY0my09U4jMPThqFVkQSEw/orw1rn2YGEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=Yj1rVWTE; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Yj1rVWTE" Received: from [192.168.1.104] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 554A16D6; Thu, 19 Dec 2024 19:38:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734633501; bh=0eOJ9xP+vWFagtAHpZNh3Z76ejtLjXXDPg0SxHQq6Xw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Yj1rVWTEYPLaULBwwkTi2z+qdONBUL2neI9O93QrjrriYN/GGbVW7Cqks4Ul3xfBy woxlY5IoTri73kX2NdxGPZvlfyzvEVRhb0sH+CYUV+IAqWyExa2wPKSd8rI+drisv0 qdREtnQjWoBmHgk1d8rZrcnG4R7nn3+3XgE4dqrw= From: Jacopo Mondi Date: Thu, 19 Dec 2024 19:38:29 +0100 Subject: [PATCH 1/2] media: rcar-fcp: Add rcar_fcp_soft_reset() Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241219-v4h-fcp-soft-reset-v1-1-026e72dca514@ideasonboard.com> References: <20241219-v4h-fcp-soft-reset-v1-0-026e72dca514@ideasonboard.com> In-Reply-To: <20241219-v4h-fcp-soft-reset-v1-0-026e72dca514@ideasonboard.com> To: Laurent Pinchart , Mauro Carvalho Chehab , Kieran Bingham Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.15-dev-1b0d6 X-Developer-Signature: v=1; a=openpgp-sha256; l=3800; i=jacopo.mondi+renesas@ideasonboard.com; h=from:subject:message-id; bh=0eOJ9xP+vWFagtAHpZNh3Z76ejtLjXXDPg0SxHQq6Xw=; b=owEBbQKS/ZANAwAIAXI0Bo8WoVY8AcsmYgBnZGhCNHS1omsVUY+ftcvDcyCT8qwnfpw/3Nbmu K/GoQUSCSuJAjMEAAEIAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCZ2RoQgAKCRByNAaPFqFW PPy/D/9bYOR3Ar6yH2oWps0irD8wQCuP3WlmwdNGAG5QOGrPCBl1DoNsZ3J2lQ93lyW8WOMqgle eUGo580F57HCeX2rwASBzrULBb6NZxwgJrf3qURPn2bqh1+pqsZvkWFAkWyNWb/mbYOt1Jr4zx/ z42fG0igqlmazGc3iYANjDo1rI8MKSIkYNe57AoAlGvqq0U9jrf6ZGX3URx5g634ChBjqwrZVUC qdvEqtKA7mFLWmgRf3hu7whHALeIzp95nEZvazxmj6BTegytFNFrdvxOzEIRejak7cvyBnqoGNq Wk28mnzM+25mx/wDLqK0f4TIsw0tG6vfJyRsIFopdLmrIOcgl8cvrRBPfW1cN7D2KewyWESbzLx fONRzSLK4ytDbEaDVWaerrWcSXj9cxKt4ROhM0FpeAQDbega4kZqxCbQLchZKOnNNujHZxJi/5s qeGy0qpyVHokNR5jsv96AqiFsG153ufnORr7FTGW3pw3ZeBfQy/mDvXwcR22bZ+/Nn57kbrVrFv tEHHIxB7ybo57JkBtthKUwovaIBAGL+OwSXxwbg7L+ZSpvHndsnH2Qbol21wWQfAp8VyjS/f1w/ nw1CHtu3LrPEzCXASdTixzlSbMKogl7ZHFPwD+jDA30fjEB4SdulakOTmZRyTBxl/2wzZbsNePL cyWi3jnImM6B8ww== X-Developer-Key: i=jacopo.mondi+renesas@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Add a function to perform soft reset of the FCP. The function needs to be called to correctly turn off the FCP operations before disabling the module. This function is intended to support the correct stop procedure of the VSPX-FCPVX pair according to section "62.3.7.3 Reset Operation" of the R-Car V4H User Manual at revision r120. Signed-off-by: Jacopo Mondi --- drivers/media/platform/renesas/rcar-fcp.c | 41 +++++++++++++++++++++++++++++++ include/media/rcar-fcp.h | 5 ++++ 2 files changed, 46 insertions(+) diff --git a/drivers/media/platform/renesas/rcar-fcp.c b/drivers/media/platform/renesas/rcar-fcp.c index cee9bbce4e3affb2467dbc28142e1ab2304bf5b0..fefeaf77f0122a2d88ac03a5c42a892dc284a163 100644 --- a/drivers/media/platform/renesas/rcar-fcp.c +++ b/drivers/media/platform/renesas/rcar-fcp.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -19,14 +21,30 @@ #include +#define RCAR_FCP_REG_RST 0x0010 +#define RCAR_FCP_REG_RST_SOFTRST BIT(0) +#define RCAR_FCP_REG_STA 0x0018 +#define RCAR_FCP_REG_STA_ACT BIT(0) + struct rcar_fcp_device { struct list_head list; struct device *dev; + void __iomem *base; }; static LIST_HEAD(fcp_devices); static DEFINE_MUTEX(fcp_lock); +static inline u32 rcar_fcp_read(struct rcar_fcp_device *fcp, u32 reg) +{ + return ioread32(fcp->base + reg); +} + +static inline void rcar_fcp_write(struct rcar_fcp_device *fcp, u32 reg, u32 val) +{ + iowrite32(val, fcp->base + reg); +} + /* ----------------------------------------------------------------------------- * Public API */ @@ -117,6 +135,25 @@ void rcar_fcp_disable(struct rcar_fcp_device *fcp) } EXPORT_SYMBOL_GPL(rcar_fcp_disable); +int rcar_fcp_soft_reset(struct rcar_fcp_device *fcp) +{ + u32 value; + int ret; + + if (!fcp) + return 0; + + rcar_fcp_write(fcp, RCAR_FCP_REG_RST, RCAR_FCP_REG_RST_SOFTRST); + ret = readl_poll_timeout(fcp->base + RCAR_FCP_REG_STA, + value, !(value & RCAR_FCP_REG_STA_ACT), + 0, 100); + if (ret) + dev_err(fcp->dev, "Failed to soft-reset: %d\n", ret); + + return ret; +} +EXPORT_SYMBOL_GPL(rcar_fcp_soft_reset); + /* ----------------------------------------------------------------------------- * Platform Driver */ @@ -131,6 +168,10 @@ static int rcar_fcp_probe(struct platform_device *pdev) fcp->dev = &pdev->dev; + fcp->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(fcp->base)) + return PTR_ERR(fcp->base); + dma_set_max_seg_size(fcp->dev, UINT_MAX); pm_runtime_enable(&pdev->dev); diff --git a/include/media/rcar-fcp.h b/include/media/rcar-fcp.h index 179240fb163bd2e7cc347e559f99bae943bf0e34..6ac9be9f675e667d6482a5a2483963fa52a0c622 100644 --- a/include/media/rcar-fcp.h +++ b/include/media/rcar-fcp.h @@ -18,6 +18,7 @@ void rcar_fcp_put(struct rcar_fcp_device *fcp); struct device *rcar_fcp_get_device(struct rcar_fcp_device *fcp); int rcar_fcp_enable(struct rcar_fcp_device *fcp); void rcar_fcp_disable(struct rcar_fcp_device *fcp); +int rcar_fcp_soft_reset(struct rcar_fcp_device *fcp); #else static inline struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np) { @@ -33,6 +34,10 @@ static inline int rcar_fcp_enable(struct rcar_fcp_device *fcp) return 0; } static inline void rcar_fcp_disable(struct rcar_fcp_device *fcp) { } +static inline int rcar_fcp_soft_reset(struct rcar_fcp_device *fcp) +{ + return 0; +} #endif #endif /* __MEDIA_RCAR_FCP_H__ */ From patchwork Thu Dec 19 18:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13915523 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC7AE1A9B25; Thu, 19 Dec 2024 18:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734633547; cv=none; b=Aw78VzBMa0kQ1pXfEXb5wESxHGW4iCQ8gaHfsdRsFrmoQhgsGiwrJI/vSyCjw/I1iKfkzAR8QvQSLpCgosLxRvH6cLsFuRi1dKgEK1JUw4sgfhRL1LBgkAac0ZDxYqay9FCjXbD9KXkAtLUfZSg3NlWDReu6EMSZiEtpUZVghdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734633547; c=relaxed/simple; bh=XaMs+Sf/J7HD4Gd5ISeUr575e/VWcvG3V82ckX1id6Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CT1saByssWbu0DPYjjW0O1EwNgcQtyoNf17LwRrbR2+OmxRR5tJFT9FsEUR4tCt/2wobSf9q2AZ7Zud9AvaFb06H4d+Srx8DXfu2S32JSDi2d2kZJLKnBhQLpPF70kEoXuH9ugr7ggiUYZgmNudOHCsRj2A2ChjWylQQxB1H3tM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=q8EepwIH; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="q8EepwIH" Received: from [192.168.1.104] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D5A406DE; Thu, 19 Dec 2024 19:38:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734633502; bh=XaMs+Sf/J7HD4Gd5ISeUr575e/VWcvG3V82ckX1id6Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=q8EepwIHbtvXyZvGYr4a9usrRfkonAaNCoGWRsxGjdegf21uA9sXbz6g0ZnBz9Jku B3NjRemFgbT7AKF7qrn8U2Os2gftIOA6GPAPS3Ix+jcHHmMJTb8zWgvmcur3v06+tW cUs+1reJ5+mijLFLu2f8/FIJ5QaSHVnj37ljp2Ts= From: Jacopo Mondi Date: Thu, 19 Dec 2024 19:38:30 +0100 Subject: [PATCH 2/2] rcar-fcp: Add FCPVD reset sequence for VSPD Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241219-v4h-fcp-soft-reset-v1-2-026e72dca514@ideasonboard.com> References: <20241219-v4h-fcp-soft-reset-v1-0-026e72dca514@ideasonboard.com> In-Reply-To: <20241219-v4h-fcp-soft-reset-v1-0-026e72dca514@ideasonboard.com> To: Laurent Pinchart , Mauro Carvalho Chehab , Kieran Bingham Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi , Koji Matsuoka , LUU HOAI X-Mailer: b4 0.15-dev-1b0d6 X-Developer-Signature: v=1; a=openpgp-sha256; l=1356; i=jacopo.mondi+renesas@ideasonboard.com; h=from:subject:message-id; bh=mCe4Clc7f1askjHQ1h/OR8O8gRY38N2DK5C1REzwG/4=; b=owEBbQKS/ZANAwAIAXI0Bo8WoVY8AcsmYgBnZGhD6QdtxR1QxGHq4zTQgNrhL+6v84tR/vd+Q LQX6jhDFaeJAjMEAAEIAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCZ2RoQwAKCRByNAaPFqFW PNj5D/47TECxTvLmdmmncW6UihY0v0xO6Wr7Ng0Vz8+weGtyZVp5nrdcHPWbQqQOfCk2keQCXvS wqEYarcJnUn5WsJj2xU7RpbkleoeoGqI3JEqXTD6WjilYH64s+hcdNg+u0XJf+KsZokZb7uzWbg YlL+mowM7gkwGZJdtU63lz2zHmhudGuYKIX48M3bGQrxrqpSY4XYRnr+E3MSlEYdQouqW9JOW2t knXxpr4ooLfqe5J2pnh4p+b5jjaYvrskq4e5+b4x3KbdDHCPq75jDQ6jTu/+VExQNwuiPOJ58J1 nSdp3lg/B6Lkh2CUszfq3tMgqPEUW7wewg9bYuZB/3RufIYY8YIXxRDUVmrn9TP4gw5dwKqx7dB WGTGgtVmexFe1pJoST6HgD8T8+qGMD36d8AsWeYismu5D0bSgwYJHX2A1wd/Un5ZgmONWaJmRA8 aJMwShNswrvQBo2A4VBTJPs3Y2W0iC5jh0tUK6TUFUEHSB9WkTSAJFbml8AKZwNduFbTju1ZQx7 wCdHEF22uwWV+c+xIMSINub5fwH8RHrVbaz2vPwyqYlt7hDm0kMS3ofK7Tyo6VvyweDAnkPHD1C MOhoTl5iBbXGRcgvpQrFqp1f95b0JLv/L/KbcJMEbj9IsrnRSKxr7LykL9zxLbcOJ250KmsRjGv /3EJIoS6DScuANg== X-Developer-Key: i=jacopo.mondi+renesas@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B From: Koji Matsuoka According to H/W manual v1.00, VSPD must be excecuted FCP_RST.SOFTRST after VI6_SRESET.SRST. So this patch adds it. VSPDL is not applicable. Signed-off-by: Koji Matsuoka Signed-off-by: LUU HOAI Signed-off-by: Jacopo Mondi --- drivers/media/platform/renesas/vsp1/vsp1_pipe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_pipe.c b/drivers/media/platform/renesas/vsp1/vsp1_pipe.c index bb0739f684f39e23326a4d8fdb9f43e020bc23c8..8dbbe92b522e49c795cf0b2bbe507871899ee15e 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_pipe.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_pipe.c @@ -13,6 +13,7 @@ #include #include +#include #include #include "vsp1.h" @@ -367,6 +368,11 @@ int vsp1_pipeline_stop(struct vsp1_pipeline *pipe) pipe->state = VSP1_PIPELINE_STOPPED; spin_unlock_irqrestore(&pipe->irqlock, flags); } + + if ((vsp1->version & VI6_IP_VERSION_MODEL_MASK) == + VI6_IP_VERSION_MODEL_VSPD_GEN3) + ret = rcar_fcp_soft_reset(vsp1->fcp); + } else { /* Otherwise just request a stop and wait. */ spin_lock_irqsave(&pipe->irqlock, flags);