From patchwork Wed Nov 16 09:04:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 82458 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp56584obn; Wed, 16 Nov 2016 01:05:51 -0800 (PST) X-Received: by 10.99.133.200 with SMTP id u191mr6026338pgd.28.1479287151127; Wed, 16 Nov 2016 01:05:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c17si30907176pgj.137.2016.11.16.01.05.50; Wed, 16 Nov 2016 01:05:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935318AbcKPJFr (ORCPT + 4 others); Wed, 16 Nov 2016 04:05:47 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:57066 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934857AbcKPJFc (ORCPT ); Wed, 16 Nov 2016 04:05:32 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGQ00DM398YZH80@mailout1.w1.samsung.com>; Wed, 16 Nov 2016 09:05:23 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161116090522eucas1p28dd6b4729f3e8a6c64a707f892e34c7c~He8zk6DSa0951009510eucas1p2x; Wed, 16 Nov 2016 09:05:22 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id A3.60.11330.2512C285; Wed, 16 Nov 2016 09:05:22 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20161116090521eucas1p105428e9cd3affab0260a574e21a749f0~He8y_Misq3110231102eucas1p1w; Wed, 16 Nov 2016 09:05:21 +0000 (GMT) X-AuditID: cbfec7f2-f79556d000002c42-27-582c21528453 Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 6F.4A.07726.7512C285; Wed, 16 Nov 2016 09:05:27 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGQ00GDL98JU960@eusync2.samsung.com>; Wed, 16 Nov 2016 09:05:21 +0000 (GMT) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Krzysztof Kozlowski , Seung-Woo Kim , Bartlomiej Zolnierkiewicz , Javier Martinez Canillas , Andrzej Hajda , Inki Dae Subject: [PATCH 7/9] s5p-mfc: Don't keep clock prepared all the time Date: Wed, 16 Nov 2016 10:04:56 +0100 Message-id: <1479287098-30493-8-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1479287098-30493-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMIsWRmVeSWpSXmKPExsWy7djP87pBijoRBg8vCVncWneO1WLjjPWs FpPuT2CxePN2DZPF+fMb2C16NmxltZhxfh+Txdojd9ktDr9pB3Inv2Rz4PLYtKqTzWNL/112 j74tqxg9Pm+SC2CJ4rJJSc3JLEst0rdL4Mq4vvEPS8EFsYrzL+ezNDBuFupi5OSQEDCRWLlg LyuELSZx4d56ti5GLg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eLt+19gNq+Ah8S5pVPZINbJSZw8NhkszingKfFk5iugBRxA2zwk lh81ncDIu4CRYRWjSGppcW56brGhXnFibnFpXrpecn7uJkZggG879nPzDsZLG4MPMQpwMCrx 8C5Q144QYk0sK67MPcQowcGsJMJ7XVAnQog3JbGyKrUoP76oNCe1+BCjKdBNE5mlRJPzgdGX VxJvaGJobmloZGxhYW5kpCTOW/LhSriQQHpiSWp2ampBahFMHxMHp1QDY8CBfYfOH8w0eC3C sejOk1UGqbYb2t4t4IrLrmG/3VvD1qBVz3rhjt2ElXvOtIU87bL9cktwl1TcpVlc9Q2KLW8u bsi/ymWiZ9R8pEzNP/xEQJb7qy8z1nBVfdPMm1o/8VL7halcH2XnLdpz9r15tnvr7HeMp2zq zjLbV4aWvzp2nynr4PKfi5VYijMSDbWYi4oTAUzR91CGAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161116090521eucas1p105428e9cd3affab0260a574e21a749f0 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161116090521eucas1p105428e9cd3affab0260a574e21a749f0 X-RootMTR: 20161116090521eucas1p105428e9cd3affab0260a574e21a749f0 References: <1479287098-30493-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch moves preparation of clocks from s5p_mfc_init_pm() (driver probe) to s5p_mfc_power_on() (start of device operation). This change will allow to use runtime power usage optimization on newer Samsung Exynos platforms (for example Exynos 5433). Signed-off-by: Marek Szyprowski --- drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 52 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c index b514584cf00d..796dac85746a 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c @@ -39,23 +39,11 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) goto err_g_ip_clk; } - ret = clk_prepare(pm->clock_gate); - if (ret) { - mfc_err("Failed to prepare clock-gating control\n"); - goto err_p_ip_clk; - } - if (dev->variant->version != MFC_VERSION_V6) { pm->clock = clk_get(&dev->plat_dev->dev, MFC_SCLK_NAME); if (IS_ERR(pm->clock)) { mfc_info("Failed to get MFC special clock control\n"); pm->clock = NULL; - } else { - ret = clk_prepare_enable(pm->clock); - if (ret) { - mfc_err("Failed to enable MFC special clock\n"); - goto err_s_clk; - } } } @@ -65,10 +53,6 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) return 0; -err_s_clk: - clk_put(pm->clock); - pm->clock = NULL; -err_p_ip_clk: clk_put(pm->clock_gate); pm->clock_gate = NULL; err_g_ip_clk: @@ -79,11 +63,9 @@ void s5p_mfc_final_pm(struct s5p_mfc_dev *dev) { if (dev->variant->version != MFC_VERSION_V6 && pm->clock) { - clk_disable_unprepare(pm->clock); clk_put(pm->clock); pm->clock = NULL; } - clk_unprepare(pm->clock_gate); clk_put(pm->clock_gate); pm->clock_gate = NULL; pm_runtime_disable(pm->device); @@ -111,22 +93,44 @@ void s5p_mfc_clock_off(void) int s5p_mfc_power_on(void) { - int ret = 0; + int ret; ret = pm_runtime_get_sync(pm->device); if (ret) return ret; - if (!pm->use_clock_gating) - ret = clk_enable(pm->clock_gate); + ret = clk_prepare_enable(pm->clock_gate); + if (ret) + goto err_pm; + + if (pm->clock) { + ret = clk_prepare_enable(pm->clock); + if (ret) + goto err_gate; + } + + if (pm->use_clock_gating) + clk_disable(pm->clock_gate); + return 0; + +err_gate: + clk_disable_unprepare(pm->clock_gate); +err_pm: + pm_runtime_put_sync(pm->device); return ret; + } int s5p_mfc_power_off(void) { - if (!pm->use_clock_gating) - clk_disable(pm->clock_gate); + if (pm->clock) + clk_disable_unprepare(pm->clock); + + if (pm->use_clock_gating) + clk_unprepare(pm->clock_gate); + else + clk_disable_unprepare(pm->clock_gate); + return pm_runtime_put_sync(pm->device); } -