diff options
author | Jon Medhurst <tixy@linaro.org> | 2015-04-22 18:17:36 +0100 |
---|---|---|
committer | Jon Medhurst <tixy@linaro.org> | 2015-04-22 18:17:36 +0100 |
commit | 58cd60ea3cc23c74a5769641f9013cd91a1081d6 (patch) | |
tree | 1a3099524adfb63d6eb884dcbf9905bc5df439da /drivers | |
parent | e8f4fb1663b879c68cef5e961cddf057bcd79410 (diff) | |
parent | e54a43637ecf77db291efe521b928326da67f01f (diff) |
Merge branch 'lsk-3.10-armlt-scpi-cpufreq-new' into integration-lsk-3.10-juno-android-new
Conflicts:
linaro/configs/vexpress64.conf
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/cpu.c | 1 | ||||
-rw-r--r-- | drivers/cpufreq/Kconfig.arm | 10 | ||||
-rw-r--r-- | drivers/cpufreq/Makefile | 1 | ||||
-rw-r--r-- | drivers/cpufreq/arm_big_little.c | 6 | ||||
-rw-r--r-- | drivers/cpufreq/scpi-cpufreq.c | 103 |
5 files changed, 118 insertions, 3 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 607efe6b7dc8..7acaf9a57a4f 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -319,6 +319,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) cpu->dev.id = num; cpu->dev.bus = &cpu_subsys; cpu->dev.release = cpu_device_release; + cpu->dev.of_node = of_get_cpu_node(num, NULL); #ifdef CONFIG_HAVE_CPU_AUTOPROBE cpu->dev.bus->uevent = cpu_uevent; #endif diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 22727792350b..06c82cf6edab 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm @@ -24,6 +24,16 @@ config ARM_VEXPRESS_BL_CPUFREQ This enables the CPUfreq driver for ARM Vexpress big.LITTLE platform. If in doubt, say N. +config ARM_SCPI_CPUFREQ + tristate "SCPI based CPUfreq driver" + depends on ARM_BIG_LITTLE_CPUFREQ && ARM_SCPI_PROTOCOL + help + This add the CPUfreq driver support for ARM big.LITTLE platforms + using SCPI interface for CPU power management. + + This driver works only if firmware the supporting CPU DVFS adhere + to SCPI protocol. + config ARM_EXYNOS_CPUFREQ bool "SAMSUNG EXYNOS SoCs" depends on ARCH_EXYNOS diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index a8f252b32b8c..517fe85726c9 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile @@ -74,6 +74,7 @@ obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o obj-$(CONFIG_ARCH_TEGRA) += tegra-cpufreq.o +obj-$(CONFIG_ARM_SCPI_CPUFREQ) += scpi-cpufreq.o ################################################################################## # PowerPC platform drivers diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index eaee6e222207..99a12ac4d3fb 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c @@ -165,6 +165,8 @@ bL_cpufreq_set_rate(u32 cpu, u32 old_cluster, u32 new_cluster, u32 rate) mutex_unlock(&cluster_lock[old_cluster]); } + if (bL_cpufreq_get_rate(cpu) != new_rate) + return -EIO; return 0; } @@ -330,7 +332,6 @@ static void put_cluster_clk_and_freq_table(struct device *cpu_dev) static int _get_cluster_clk_and_freq_table(struct device *cpu_dev) { u32 cluster = cpu_to_cluster(cpu_dev->id); - char name[14] = "cpu-cluster.X"; int ret; if (atomic_inc_return(&cluster_usage[cluster]) != 1) @@ -350,8 +351,7 @@ static int _get_cluster_clk_and_freq_table(struct device *cpu_dev) goto atomic_dec; } - name[12] = cluster + '0'; - clk[cluster] = clk_get_sys(name, NULL); + clk[cluster] = clk_get(cpu_dev, NULL); if (!IS_ERR(clk[cluster])) { dev_dbg(cpu_dev, "%s: clk: %p & freq table: %p, cluster: %d\n", __func__, clk[cluster], freq_table[cluster], diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c new file mode 100644 index 000000000000..6311feb52a07 --- /dev/null +++ b/drivers/cpufreq/scpi-cpufreq.c @@ -0,0 +1,103 @@ +/* + * SCPI CPUFreq Interface driver + * + * It provides necessary ops to arm_big_little cpufreq driver. + * + * Copyright (C) 2015 ARM Ltd. + * Sudeep Holla <sudeep.holla@arm.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include <linux/cpufreq.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/opp.h> +#include <linux/scpi_protocol.h> +#include <linux/types.h> + +#include "arm_big_little.h" + +static struct scpi_ops *scpi_ops; + +static int scpi_init_opp_table(struct device *cpu_dev) +{ + u8 domain = topology_physical_package_id(cpu_dev->id); + struct scpi_dvfs_info *info; + struct scpi_opp *opp; + int idx, ret = 0; + + if ((opp_get_opp_count(cpu_dev)) > 0) + return 0; + info = scpi_ops->dvfs_get_info(domain); + if (IS_ERR(info)) + return PTR_ERR(info); + + opp = info->opps; + if (!opp) + return -EIO; + + for (idx = 0; idx < info->count; idx++, opp++) { + ret = opp_add(cpu_dev, opp->freq, opp->m_volt * 1000); + if (ret) { + dev_warn(cpu_dev, "failed to add opp %uHz %umV\n", + opp->freq, opp->m_volt); + return ret; + } + } + return ret; +} + +static int scpi_get_transition_latency(struct device *cpu_dev) +{ + u8 domain = topology_physical_package_id(cpu_dev->id); + struct scpi_dvfs_info *info; + + info = scpi_ops->dvfs_get_info(domain); + if (IS_ERR(info)) + return PTR_ERR(info); + + return info->latency; +} + +static struct cpufreq_arm_bL_ops scpi_cpufreq_ops = { + .name = "scpi", + .get_transition_latency = scpi_get_transition_latency, + .init_opp_table = scpi_init_opp_table, +}; + +static int scpi_cpufreq_probe(struct platform_device *pdev) +{ + scpi_ops = get_scpi_ops(); + if (!scpi_ops) + return -EIO; + + return bL_cpufreq_register(&scpi_cpufreq_ops); +} + +static int scpi_cpufreq_remove(struct platform_device *pdev) +{ + bL_cpufreq_unregister(&scpi_cpufreq_ops); + return 0; +} + +static struct platform_driver scpi_cpufreq_platdrv = { + .driver = { + .name = "scpi-cpufreq", + .owner = THIS_MODULE, + }, + .probe = scpi_cpufreq_probe, + .remove = scpi_cpufreq_remove, +}; +module_platform_driver(scpi_cpufreq_platdrv); + +MODULE_LICENSE("GPL"); |