From patchwork Sat Mar 12 08:42:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 12778773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E040C433F5 for ; Sat, 12 Mar 2022 08:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231449AbiCLInX (ORCPT ); Sat, 12 Mar 2022 03:43:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiCLInW (ORCPT ); Sat, 12 Mar 2022 03:43:22 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4B7492965C9; Sat, 12 Mar 2022 00:42:17 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.90,175,1643641200"; d="scan'208";a="114165833" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 12 Mar 2022 17:42:16 +0900 Received: from localhost.localdomain (unknown [10.226.93.53]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id EEBFE423991B; Sat, 12 Mar 2022 17:42:13 +0900 (JST) From: Biju Das To: Mauro Carvalho Chehab , Philipp Zabel Cc: Biju Das , Laurent Pinchart , Kieran Bingham , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Biju Das , Prabhakar Mahadev Lad Subject: [PATCH v5 2/3] media: vsp1: Add support to deassert/assert reset line Date: Sat, 12 Mar 2022 08:42:04 +0000 Message-Id: <20220312084205.31462-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220312084205.31462-1-biju.das.jz@bp.renesas.com> References: <20220312084205.31462-1-biju.das.jz@bp.renesas.com> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As the resets DT property is mandatory, and is present in all .dtsi in mainline, add support to perform deassert/assert using reference counted reset handle. Signed-off-by: Biju Das Reviewed-by: Lad Prabhakar Reviewed-by: Philipp Zabel Reviewed-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart --- v4->v5: * Added Rb tag from Geert v3->v4: * Restored error check for pm_runtime_resume_and_get and calls assert() in case of failure. v2->v3: * Added Rb tag from Philipp * If reset_control_deassert() failed, return ret directly. v1->v2: * Used reference counted reset handle to perform deassert/assert RFC->v1: * Added reset support as separate patch * Moved rstc just after the bus_master field in struct vsp1_device RFC: * https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220112174612.10773-21-biju.das.jz@bp.renesas.com/ --- drivers/media/platform/vsp1/vsp1.h | 1 + drivers/media/platform/vsp1/vsp1_drv.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/vsp1/vsp1.h b/drivers/media/platform/vsp1/vsp1.h index 37cf33c7e6ca..c5da829c79b5 100644 --- a/drivers/media/platform/vsp1/vsp1.h +++ b/drivers/media/platform/vsp1/vsp1.h @@ -79,6 +79,7 @@ struct vsp1_device { void __iomem *mmio; struct rcar_fcp_device *fcp; struct device *bus_master; + struct reset_control *rstc; struct vsp1_brx *brs; struct vsp1_brx *bru; diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 502c7d9d6890..699d7d985df4 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -569,7 +570,16 @@ static void vsp1_mask_all_interrupts(struct vsp1_device *vsp1) */ int vsp1_device_get(struct vsp1_device *vsp1) { - return pm_runtime_resume_and_get(vsp1->dev); + int ret = reset_control_deassert(vsp1->rstc); + + if (ret < 0) + return ret; + + ret = pm_runtime_resume_and_get(vsp1->dev); + if (ret < 0) + reset_control_assert(vsp1->rstc); + + return ret; } /* @@ -581,6 +591,7 @@ int vsp1_device_get(struct vsp1_device *vsp1) void vsp1_device_put(struct vsp1_device *vsp1) { pm_runtime_put_sync(vsp1->dev); + reset_control_assert(vsp1->rstc); } /* ----------------------------------------------------------------------------- @@ -827,6 +838,11 @@ static int vsp1_probe(struct platform_device *pdev) if (irq < 0) return irq; + vsp1->rstc = devm_reset_control_get_shared(&pdev->dev, NULL); + if (IS_ERR(vsp1->rstc)) + return dev_err_probe(&pdev->dev, PTR_ERR(vsp1->rstc), + "failed to get reset ctrl\n"); + /* FCP (optional). */ fcp_node = of_parse_phandle(pdev->dev.of_node, "renesas,fcp", 0); if (fcp_node) {