From patchwork Fri Jan 23 12:14:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 5693481 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7559D9F357 for ; Fri, 23 Jan 2015 12:14:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1EC4202E5 for ; Fri, 23 Jan 2015 12:14:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE6B3202C8 for ; Fri, 23 Jan 2015 12:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754288AbbAWMOe (ORCPT ); Fri, 23 Jan 2015 07:14:34 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:37416 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754207AbbAWMOe (ORCPT ); Fri, 23 Jan 2015 07:14:34 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NIM00CODQ080V80@mailout4.samsung.com>; Fri, 23 Jan 2015 21:14:32 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-92-54c23b288ffa Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id EE.68.09430.82B32C45; Fri, 23 Jan 2015 21:14:32 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NIM00LY7PZY0990@mmp1.samsung.com>; Fri, 23 Jan 2015 21:14:32 +0900 (KST) From: Lukasz Majewski To: Viresh Kumar Cc: Eduardo Valentin , Zhang Rui , Linux PM list , "linux-samsung-soc@vger.kernel.org" , Bartlomiej Zolnierkiewicz , Lukasz Majewski , Kukjin Kim , Amit Daniel Kachhap , Abhilash Kesavan , Abhilash Kesavan , Kukjin Kim , Chanwoo Choi , Lukasz Majewski Subject: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered Date: Fri, 23 Jan 2015 13:14:20 +0100 Message-id: <1422015260-14225-1-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1421666462-7606-1-git-send-email-l.majewski@samsung.com> References: <1421666462-7606-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNLMWRmVeSWpSXmKPExsVy+t9jAV0N60MhBmuuqVg8XrOYyaLhaojF xhnrWS2uf3nOajH/yjVWizV/lSx6F1xls+h//JrZ4s0jbos3DzczWnzuPcJoMeP8PiaLJw/7 2Cw2fvVw4PPYOesuu8fiPS+ZPDat6mTzuHNtD5vHumlvmT36tqxi9Pi8SS6APYrLJiU1J7Ms tUjfLoErY+sco4LJwhUnrn1hamB8xt/FyMkhIWAicerJBXYIW0ziwr31bF2MXBxCAosYJZo3 NrKCJIQEupgk1q82BrHZBPQkPt99ytTFyMEhIqAl8fJmKkg9s8BxFolte86CDRIWKJToXXKB BcRmEVCVePb1F5jNK+Am0d7+jw1imaJE97MJYDYnUPxNRzMjxC5Xibt/TjNPYORdwMiwilE0 tSC5oDgpPddIrzgxt7g0L10vOT93EyM4SJ9J72Bc1WBxiFGAg1GJh7dhy8EQIdbEsuLK3EOM EhzMSiK81pqHQoR4UxIrq1KL8uOLSnNSiw8xSnOwKInzKtm3hQgJpCeWpGanphakFsFkmTg4 pRoY5QpO+k51Smj6qtfVyG/Ju6Jib0Zv49E09f4kv93CO5ewzv7R9PuM0I/jOecUVWJELbXr +y2U280/iSl6FDOKMTHxSbecmMi3+fZe7q4bRr/ub5i3Yf0l3lWqPLNqr9TXH1+/bfvtXd9a PrM6TXTYqMwh1b6Ab626+jFf9wPJawxW6NRPOvlEiaU4I9FQi7moOBEAeDZ+ik4CAAA= Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 With thermal subsystem rework it is necessary to tune current cpufreq code to use cpu frequency change as a potential cooling device. Now the cpu cooling device is registered only when proper nodes and properties are available in device tree. Lack of them, however, will not prevent cpufreq for normal operation. Signed-off-by: Lukasz Majewski --- Changes for v6: - New patch --- drivers/cpufreq/exynos-cpufreq.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index f99a0b0..5e98c6b 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c @@ -18,10 +18,13 @@ #include #include #include +#include +#include #include "exynos-cpufreq.h" static struct exynos_dvfs_info *exynos_info; +static struct thermal_cooling_device *cdev; static struct regulator *arm_regulator; static unsigned int locking_frequency; @@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = { static int exynos_cpufreq_probe(struct platform_device *pdev) { + struct device_node *cpus, *np; int ret = -EINVAL; exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL); @@ -198,9 +202,36 @@ static int exynos_cpufreq_probe(struct platform_device *pdev) /* Done here as we want to capture boot frequency */ locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000; - if (!cpufreq_register_driver(&exynos_driver)) + ret = cpufreq_register_driver(&exynos_driver); + if (ret) + goto err_cpufreq_reg; + + cpus = of_find_node_by_path("/cpus"); + if (!cpus) { + pr_err("failed to find cpus node\n"); + return 0; + } + + np = of_get_next_child(cpus, NULL); + if (!np) { + pr_err("failed to find cpus child node\n"); + of_node_put(cpus); return 0; + } + + if (of_find_property(np, "#cooling-cells", NULL)) { + cdev = of_cpufreq_cooling_register(np, + cpu_present_mask); + if (IS_ERR(cdev)) + pr_err("running cpufreq without cooling device: %ld\n", + PTR_ERR(cdev)); + } + of_node_put(np); + of_node_put(cpus); + + return 0; +err_cpufreq_reg: dev_err(&pdev->dev, "failed to register cpufreq driver\n"); regulator_put(arm_regulator); err_vdd_arm: