From patchwork Mon Nov 16 19:30:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 56685 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1509583lbb; Mon, 16 Nov 2015 11:31:29 -0800 (PST) X-Received: by 10.68.237.41 with SMTP id uz9mr17436115pbc.165.1447702289347; Mon, 16 Nov 2015 11:31:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ro10si52393885pbc.78.2015.11.16.11.31.29; Mon, 16 Nov 2015 11:31:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150AbbKPTbU (ORCPT + 28 others); Mon, 16 Nov 2015 14:31:20 -0500 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140]:34889 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750982AbbKPTbN (ORCPT ); Mon, 16 Nov 2015 14:31:13 -0500 Received: from e105922-lin.cambridge.arm.com (e105922-lin.cambridge.arm.com [10.1.207.164]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with SMTP id tAGJV3nK020614; Mon, 16 Nov 2015 19:31:03 GMT Received: by e105922-lin.cambridge.arm.com (sSMTP sendmail emulation); Mon, 16 Nov 2015 19:31:03 +0000 From: Punit Agrawal To: devicetree@vger.kernel.org Cc: Punit Agrawal , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, edubezval@gmail.com, dawei.chien@mediatek.com, javi.merino@arm.com, Sudeep Holla Subject: [PATCH v4 3/3] cpufreq: arm_big_little: Add support to register a cpufreq cooling device Date: Mon, 16 Nov 2015 19:30:25 +0000 Message-Id: <1447702225-13323-4-git-send-email-punit.agrawal@arm.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1447702225-13323-1-git-send-email-punit.agrawal@arm.com> References: <1447702225-13323-1-git-send-email-punit.agrawal@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Register passive cooling devices when initialising cpufreq on big.LITTLE systems. If the device tree provides a dynamic power coefficient for the CPUs then the bound cooling device will support the extensions that allow it to be used with all the existing thermal governors including the power allocator governor. A cooling device will be created per individual frequency domain and can be bound to thermal zones via the thermal DT bindings. Signed-off-by: Punit Agrawal Acked-by: Viresh Kumar Cc: Sudeep Holla Cc: Eduardo Valentin --- drivers/cpufreq/Kconfig.arm | 2 ++ drivers/cpufreq/arm_big_little.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 1582c1c..0e0052e 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm @@ -6,6 +6,8 @@ config ARM_BIG_LITTLE_CPUFREQ tristate "Generic ARM big LITTLE CPUfreq driver" depends on (ARM_CPU_TOPOLOGY || ARM64) && HAVE_CLK + # if CPU_THERMAL is on and THERMAL=m, ARM_BIT_LITTLE_CPUFREQ cannot be =y + depends on !CPU_THERMAL || THERMAL select PM_OPP help This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index c5d256c..60d09c0 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,7 @@ static bool bL_switching_enabled; #define ACTUAL_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq << 1 : freq) #define VIRT_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq >> 1 : freq) +static struct thermal_cooling_device *cdev[MAX_CLUSTERS]; static struct cpufreq_arm_bL_ops *arm_bL_ops; static struct clk *clk[MAX_CLUSTERS]; static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS + 1]; @@ -493,6 +495,7 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy) static int bL_cpufreq_exit(struct cpufreq_policy *policy) { struct device *cpu_dev; + int domain; cpu_dev = get_cpu_device(policy->cpu); if (!cpu_dev) { @@ -501,12 +504,43 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy) return -ENODEV; } + domain = topology_physical_package_id(cpu_dev->id); + cpufreq_cooling_unregister(cdev[domain]); + cdev[domain] = NULL; + put_cluster_clk_and_freq_table(cpu_dev); dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); return 0; } +static void bL_cpufreq_ready(struct cpufreq_policy *policy) +{ + struct device *cpu_dev = get_cpu_device(policy->cpu); + struct device_node *np = of_node_get(cpu_dev->of_node); + int domain = topology_physical_package_id(cpu_dev->id); + + if (WARN_ON(!np)) + return; + + if (of_find_property(np, "#cooling-cells", NULL)) { + u32 power_coefficient = 0; + + of_property_read_u32(np, "dynamic-power-coefficient", + &power_coefficient); + + cdev[domain] = of_cpufreq_power_cooling_register(np, + policy->related_cpus, power_coefficient, NULL); + if (IS_ERR(cdev[domain])) { + dev_err(cpu_dev, + "running cpufreq without cooling device: %ld\n", + PTR_ERR(cdev[domain])); + cdev[domain] = NULL; + } + } + of_node_put(np); +} + static struct cpufreq_driver bL_cpufreq_driver = { .name = "arm-big-little", .flags = CPUFREQ_STICKY | @@ -517,6 +551,7 @@ static struct cpufreq_driver bL_cpufreq_driver = { .get = bL_cpufreq_get_rate, .init = bL_cpufreq_init, .exit = bL_cpufreq_exit, + .ready = bL_cpufreq_ready, .attr = cpufreq_generic_attr, };