Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp715702ybg; Mon, 1 Jun 2020 12:26:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz/l0689fl7zz6e/T0Dp5gdt60Fuq6iWsO407SFsM//UA+Pw0KGhTAjZaLRPiXVZu0ICdT X-Received: by 2002:a17:906:e2d5:: with SMTP id gr21mr10273930ejb.219.1591039601786; Mon, 01 Jun 2020 12:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591039601; cv=none; d=google.com; s=arc-20160816; b=JLk8YBNw0ZonrzY7MdyDr7Gb/hn7g/1ND/DE9YbSY4i+YTFGe1GXnd8zm5c3AtNkLc jwpF280BTN8PNHIPbYlctbUh3+xZZvRQzzLYkpj5ig5+RV4rgSIk5zquYMf85P+isfLg P5EA3Yx4fxLtfdyxVmshvO+jW4MVXiLzki3y9/9cjSIKPrClkslx9MLv0G2ovIUYMMQK 27Db0Rgj224eMpQhQzjPrLQQ+IGY/zZfq4iccBOlv2iN2PtezW+/UNKE8kKYuntKhPWa jlAoZ5KpUxI9otzMAmjMmgZD2R/OfFgcLWiSEgS7tGKrcJlhpa0ErlWipzMC/KtEh0IU Jdeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jbUbBlIFxp1nNgt5RcQAnKU6jD4YXB9zJ2RURNcHO0g=; b=xYzxTbXtI00q6AFd6G0rF//HQTsmoQxLMPzewCzXRR0A6t+GqKKRVe4/XQR64YQjxM 1PwRRSkz2Xx8Uwt/bzN+mnQDAI2KSPYTWMrQNtMHEISJPKmXKu/ZWqizpaBlnoNR4xLt kO5ldkjSd2JFSOL1zmksjZYTaJ/rQ/Knj6VjMV8SzVMBL4S7+kdMxUrzDmJEARThNIHv hHB7szqCkipt6LRRZam0LPyX9NGQbt1iu/WaNCf+UaFm+zE2QMcPthI78KFYsa/Wtay9 2WNcaLZqbtM3KBrvDSyZa9P5lJur/76nFR4UxlCT9CfQhJoan13A6Mkn9cl+Gs+7REP+ 40NQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si256194ejr.737.2020.06.01.12.26.17; Mon, 01 Jun 2020 12:26:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728325AbgFATWC (ORCPT + 99 others); Mon, 1 Jun 2020 15:22:02 -0400 Received: from v6.sk ([167.172.42.174]:45480 "EHLO v6.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbgFATWB (ORCPT ); Mon, 1 Jun 2020 15:22:01 -0400 Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id D5A2761306; Mon, 1 Jun 2020 19:21:29 +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: [RESEND 2 PATCH] media: marvell-ccic: Add support for runtime PM Date: Mon, 1 Jun 2020 21:21:24 +0200 Message-Id: <20200601192124.172650-1-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; } -- 2.26.2