From patchwork Fri Apr 17 09:37:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11494597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2025981 for ; Fri, 17 Apr 2020 09:37:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12E6A21D94 for ; Fri, 17 Apr 2020 09:37:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730372AbgDQJhb (ORCPT ); Fri, 17 Apr 2020 05:37:31 -0400 Received: from v6.sk ([167.172.42.174]:43458 "EHLO v6.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730131AbgDQJha (ORCPT ); Fri, 17 Apr 2020 05:37:30 -0400 Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 9D3CC610A6; Fri, 17 Apr 2020 09:37:28 +0000 (UTC) From: Lubomir Rintel To: Mauro Carvalho Chehab Cc: Jonathan Corbet , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Lubomir Rintel Subject: [PATCH] media: marvell-ccic: Add support for runtime PM Date: Fri, 17 Apr 2020 11:37:13 +0200 Message-Id: <20200417093713.447777-1-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On MMP3, the camera block lives on na separate power island. We want to turn it off if the CCIC is not in use to conserve power. Signed-off-by: Lubomir Rintel --- drivers/media/platform/marvell-ccic/mcam-core.c | 3 +++ drivers/media/platform/marvell-ccic/mmp-driver.c | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index 09775b6624c6b..c2cd1d461bd06 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -901,6 +902,7 @@ static void mcam_clk_enable(struct mcam_camera *mcam) { unsigned int i; + pm_runtime_get_sync(mcam->dev); for (i = 0; i < NR_MCAM_CLK; i++) { if (!IS_ERR(mcam->clk[i])) clk_prepare_enable(mcam->clk[i]); @@ -915,6 +917,7 @@ static void mcam_clk_disable(struct mcam_camera *mcam) if (!IS_ERR(mcam->clk[i])) clk_disable_unprepare(mcam->clk[i]); } + pm_runtime_put(mcam->dev); } /* ---------------------------------------------------------------------- */ diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c index 92b92255dac66..eec482d16805b 100644 --- a/drivers/media/platform/marvell-ccic/mmp-driver.c +++ b/drivers/media/platform/marvell-ccic/mmp-driver.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "mcam-core.h" @@ -313,10 +314,12 @@ static int mmpcam_probe(struct platform_device *pdev) cam->irq = res->start; ret = devm_request_irq(&pdev->dev, cam->irq, mmpcam_irq, IRQF_SHARED, "mmp-camera", mcam); - if (ret == 0) { - mmpcam_add_device(cam); - return 0; - } + if (ret) + goto out; + + mmpcam_add_device(cam); + pm_runtime_enable(&pdev->dev); + return 0; out: fwnode_handle_put(mcam->asd.match.fwnode); @@ -332,6 +335,7 @@ static int mmpcam_remove(struct mmp_camera *cam) mmpcam_remove_device(cam); mccic_shutdown(mcam); + pm_runtime_force_suspend(mcam->dev); return 0; }