From patchwork Thu Sep 3 18:11:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 7118191 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 55774BEEC1 for ; Thu, 3 Sep 2015 18:13:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B86120688 for ; Thu, 3 Sep 2015 18:13:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D0102068E for ; Thu, 3 Sep 2015 18:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758237AbbICSMa (ORCPT ); Thu, 3 Sep 2015 14:12:30 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:58562 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758213AbbICSM0 (ORCPT ); Thu, 3 Sep 2015 14:12:26 -0400 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NU402OZS58N1110@mailout4.samsung.com>; Fri, 04 Sep 2015 03:12:24 +0900 (KST) X-AuditID: cbfee61a-f79a06d000005c6f-d7-55e88d886afb Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 91.C1.23663.88D88E55; Fri, 4 Sep 2015 03:12:24 +0900 (KST) Received: from AMDC1976.DIGITAL.local ([106.120.53.102]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NU40099I57Y1C20@mmp2.samsung.com>; Fri, 04 Sep 2015 03:12:24 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Thomas Abraham , Kukjin Kim , Kukjin Kim , Viresh Kumar , Krzysztof Kozlowski , Marek Szyprowski , "Rafael J. Wysocki" Cc: Sylwester Nawrocki , Michael Turquette , Tomasz Figa , Lukasz Majewski , Heiko Stuebner , Chanwoo Choi , Kevin Hilman , Javier Martinez Canillas , Tobias Jakobi , Anand Moon , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH v3 2/3] cpufreq-dt: add suspend frequency support Date: Thu, 03 Sep 2015 20:11:31 +0200 Message-id: <1441303892-32004-3-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1441303892-32004-1-git-send-email-b.zolnierkie@samsung.com> References: <1441303892-32004-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeLIzCtJLcpLzFFi42I5/e+xoG5H74tQgy03FC02zljPanH9y3NW i/+PXrNavHm7hsni9QtDi94FV9ks+h+/Zrb4engFo8Wbh5sZLTY9vsZq8bHnHqvF5V1z2Cw+ 9x5htJhxfh+TxbqNt9gt1h65y25x8ZSrxZnTl1gtDr9pZ7XoWMZo0bb6A6vFql1/GC02fvVw EPd4f6OV3WPnrLvsHptWdbJ53Lm2h81j85J6j3/H2D229AOFt1xtZ/Ho27KK0WP7tXnMHp83 yQVwR3HZpKTmZJalFunbJXBlfGj5ylxwW7Ri4+vfTA2Ms4W6GDk5JARMJH4+a2aCsMUkLtxb z9bFyMUhJDCLUeLY1mWsEM4vRonVT2+xg1SxCVhJTGxfxQiSEBFYxCSxcP9WsCpmgWcsEq3v ullBqoQFHCUmvpsK1sEioCqxZs1bNhCbV8BD4vfkW4wQ++QkTh6bDFTPwcEp4Clx8KkESFgI qGThhfeMExh5FzAyrGKUSC1ILihOSs81zEst1ytOzC0uzUvXS87P3cQIjpdnUjsYD+5yP8Qo wMGoxMPL6PkiVIg1say4MvcQowQHs5II7552oBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe2ZXP QoUE0hNLUrNTUwtSi2CyTBycUg2Mntk/Xm51cljuz7ovtP6og9deN+Vn1UHrvjRevr/V8+Sp wNeCtQJn25/pPfi9ZCabak2Kt4Gg5FWNxAf2ffGvVYNC7ZglbxwSeXSpV2iTvk+T6LqWvJmW /k7FE7sKr9QKL/zo8FJxr79Y+SWPaImf3vPnTDlXL+PBsXjTm1N70589to+VDVRRYinOSDTU Yi4qTgQA7z+uKpMCAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add suspend frequency support and if needed set it to the frequency obtained from the suspend opp (can be defined using opp-v2 bindings and is optional). Also implement custom suspend method (needed to not error out on platforms which don't require suspend frequency). Cc: Viresh Kumar Cc: Thomas Abraham Cc: Javier Martinez Canillas Cc: Krzysztof Kozlowski Cc: Marek Szyprowski Cc: Tobias Jakobi Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/cpufreq/cpufreq-dt.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index c3583cd..ba4ca85 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -196,6 +196,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) struct device *cpu_dev; struct regulator *cpu_reg; struct clk *cpu_clk; + struct dev_pm_opp *suspend_opp; unsigned long min_uV = ~0, max_uV = 0; unsigned int transition_latency; bool need_update = false; @@ -329,6 +330,11 @@ static int cpufreq_init(struct cpufreq_policy *policy) policy->driver_data = priv; policy->clk = cpu_clk; + + suspend_opp = dev_pm_opp_get_suspend_opp(cpu_dev); + if (suspend_opp) + policy->suspend_freq = dev_pm_opp_get_freq(suspend_opp) / 1000; + ret = cpufreq_table_validate_and_show(policy, freq_table); if (ret) { dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__, @@ -409,6 +415,31 @@ static void cpufreq_ready(struct cpufreq_policy *policy) of_node_put(np); } +#ifdef CONFIG_PM +static int cpufreq_dt_suspend(struct cpufreq_policy *policy) +{ + int ret; + + if (!policy->suspend_freq) { + pr_debug("%s: suspend_freq not defined\n", __func__); + return 0; + } + + pr_debug("%s: Setting suspend-freq: %u\n", __func__, + policy->suspend_freq); + + ret = __cpufreq_driver_target(policy, policy->suspend_freq, + CPUFREQ_RELATION_H); + if (ret) + pr_err("%s: unable to set suspend-freq: %u. err: %d\n", + __func__, policy->suspend_freq, ret); + + return ret; +} +#else +#define cpufreq_dt_suspend NULL +#endif + static struct cpufreq_driver dt_cpufreq_driver = { .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .verify = cpufreq_generic_frequency_table_verify, @@ -419,6 +450,7 @@ static struct cpufreq_driver dt_cpufreq_driver = { .ready = cpufreq_ready, .name = "cpufreq-dt", .attr = cpufreq_dt_attr, + .suspend = cpufreq_dt_suspend, }; static int dt_cpufreq_probe(struct platform_device *pdev)