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: 7118331 Return-Path: X-Original-To: patchwork-linux-arm@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 6077EBF036 for ; Thu, 3 Sep 2015 18:14:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77E562083F for ; Thu, 3 Sep 2015 18:14:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61E7320830 for ; Thu, 3 Sep 2015 18:14:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXZ0L-0006Yx-VD; Thu, 03 Sep 2015 18:12:57 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXZ0A-0005n0-OX for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2015 18:12:47 +0000 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> for linux-arm-kernel@lists.infradead.org; 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" 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= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150903_111246_972807_6BD1C495 X-CRM114-Status: GOOD ( 16.94 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lukasz Majewski , Kevin Hilman , Heiko Stuebner , Javier Martinez Canillas , Anand Moon , Michael Turquette , linux-pm@vger.kernel.org, Tomasz Figa , linux-kernel@vger.kernel.org, Chanwoo Choi , b.zolnierkie@samsung.com, Tobias Jakobi , linux-arm-kernel@lists.infradead.org, Sylwester Nawrocki , linux-clk@vger.kernel.org, linux-samsung-soc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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)