Remodel Tegra cpufreq driver to support Tegra series SoCs
Subsystems (4)
cover Remodel Tegra cpufreq driver to support Tegra series SoCs
This patch series remodel Tegra cpufreq driver to make it more easy to add new SoC support, in addition to that, adding probe function in the driver to let probe defer can be used to control init sequence when we going to support DVFS.
Bill Huang (2):
cpufreq: tegra: Remove not used header and clean up codes
cpufreq: tegra: Re-model Tegra cpufreq driver
arch/arm/mach-tegra/common.c | 2 + drivers/cpufreq/Kconfig.arm | 16 +++- drivers/cpufreq/Makefile | 1 + drivers/cpufreq/tegra-cpufreq.c | 192 +++++++++++++++++-------------------- drivers/cpufreq/tegra-cpufreq.h | 37 +++++++ drivers/cpufreq/tegra20-cpufreq.c | 133 +++++++++++++++++++++++++ include/linux/tegra-soc.h | 11 ++- 7 files changed, 283 insertions(+), 109 deletions(-) create mode 100644 drivers/cpufreq/tegra-cpufreq.h create mode 100644 drivers/cpufreq/tegra20-cpufreq.c
Signature · 1 line
1.7.9.5
PATCH 1/2 cpufreq: tegra: Remove not used header and clean up codes
Remove inclustion of the not needed header files and remove the logic to check the CPU ID to not exceeding the maximum supported CPUs.
--- drivers/cpufreq/tegra-cpufreq.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/cpufreq/tegra-cpufreq.c +2 -12
@@ -1,5 +1,6 @@/* -* Copyright (C) 2010 Google, Inc. +* Copyright (c) 2013, NVIDIA Corporation. +* Copyright (C) 2010-2013 Google, Inc. * * Author: * Colin Cross <[email protected]>
@@ -18,14 +19,9 @@#include <linux/kernel.h> #include <linux/module.h> -#include <linux/types.h> -#include <linux/sched.h> #include <linux/cpufreq.h> -#include <linux/delay.h> -#include <linux/init.h> #include <linux/err.h> #include <linux/clk.h> -#include <linux/io.h> #include <linux/suspend.h> static struct cpufreq_frequency_table freq_table[] = {
@@ -60,9 +56,6 @@ static unsigned int tegra_getspeed(unsigned int cpu) {unsigned long rate; -if (cpu >=NUM_CPUS ) -return 0 ; - rate =clk_get_rate (cpu_clk) /1000 ;return rate; }
@@ -209,9 +202,6 @@ static struct notifier_block tegra_cpu_pm_notifier = {static int tegra_cpu_init (struct cpufreq_policy *policy) { -if (policy->cpu >=NUM_CPUS ) -return -EINVAL ; -clk_prepare_enable (emc_clk);clk_prepare_enable (cpu_clk);
Signature · 1 line
1.7.9.5
Re: [PATCH 1/2] cpufreq: tegra: Remove not used header and clean up codes
drivers/cpufreq/tegra-cpufreq.c line 3
Quoted 8 lines · Bill Huang
Remove inclustion of the not needed header files and remove the logic to check the CPU ID to not exceeding the maximum supported CPUs.
drivers/cpufreq/tegra-cpufreq.c +2
-1-* Copyright (C) 2010 Google, Inc. +* Copyright (c) 2013, NVIDIA Corporation. +* Copyright (C) 2010-2013 Google, Inc.
This is such a trivial patch, I don't think it's appropriate to add an NVIDIA (c) notice. It may well be appropriate in patch 2/2.
I assume that Google didn't write this patch, so why adjust that (c) notice?
PATCH 2/2 cpufreq: tegra: Re-model Tegra cpufreq driver
In reply to Bill HuangRe-model Tegra cpufreq driver to support all Tegra series of SoCs.
* Make tegra-cpufreq.c a generic Tegra cpufreq driver.
* Move Tegra20 specific codes into tegra20-cpufreq.c.
* Bind Tegra cpufreq dirver with a fake device so defer probe would work when we're going to get regulator in the driver to support voltage scaling (DVFS).
* Call tegra_cpufreq_init() in Tegra machine code specifically so it won't be called in multi-platform kernel which is not running on Tegra SoCs.
--- arch/arm/mach-tegra/common.c | 2 + drivers/cpufreq/Kconfig.arm | 16 +++- drivers/cpufreq/Makefile | 1 + drivers/cpufreq/tegra-cpufreq.c | 178 ++++++++++++++++++------------------- drivers/cpufreq/tegra-cpufreq.h | 37 ++++++++ drivers/cpufreq/tegra20-cpufreq.c | 133 +++++++++++++++++++++++++++ include/linux/tegra-soc.h | 11 ++- 7 files changed, 281 insertions(+), 97 deletions(-) create mode 100644 drivers/cpufreq/tegra-cpufreq.h create mode 100644 drivers/cpufreq/tegra20-cpufreq.c
arch/arm/mach-tegra/common.c +2 -0
@@ -25,6 +25,7 @@#include <linux/reboot.h> #include <linux/irqchip.h> #include <linux/clk-provider.h> +#include <linux/tegra-soc.h> #include <asm/hardware/cache-l2x0.h>
@@ -109,6 +110,7 @@ void __init tegra_init_early(void)void __init tegra_init_late (void ) { +tegra_cpufreq_init ();tegra_init_suspend ();tegra_cpuidle_init ();tegra_powergate_debugfs_init ();
drivers/cpufreq/Kconfig.arm +13 -3
@@ -229,9 +229,19 @@ config ARM_SPEAR_CPUFREQ This adds the CPUFreq driver support for SPEAr SOCs. config ARM_TEGRA_CPUFREQ - bool "TEGRA CPUFreq support" - depends on ARCH_TEGRA + bool + select CPU_FREQ_TABLE + +config ARM_EXYNOS_CPUFREQ + bool select CPU_FREQ_TABLE + +config ARM_TEGRA20_CPUFREQ + bool "NVIDIA TEGRA20" + depends on ARCH_TEGRA default y + select ARM_TEGRA_CPUFREQ help - This adds the CPUFreq driver support for TEGRA SOCs. + This adds the CPUFreq driver for NVIDIA TEGRA20 SoC. + + If in doubt, say N.
drivers/cpufreq/Makefile +1 -0
@@ -77,6 +77,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_ARM_TEGRA_CPUFREQ) += tegra-cpufreq.o +obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o ################################################################################## # PowerPC platform drivers
drivers/cpufreq/tegra-cpufreq.c +85 -93
260 lines not on this page · raw message
drivers/cpufreq/tegra-cpufreq.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (c) 2013, NVIDIA Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __LINUX_TEGRA_CPUFREQ_H +#define __LINUX_TEGRA_CPUFREQ_H + +struct tegra_cpufreq_data { +struct device *dev; +struct clk *cpu_clk; +struct cpufreq_frequency_table *freq_table; +void (*vote_emc_on_cpu_rate)(unsigned long ); +int (*cpu_clk_set_rate)(unsigned long ); +void (*cpufreq_clk_init)(void ); +void (*cpufreq_clk_exit)(void ); +}; + +#ifdef CONFIG_ARM_TEGRA20_CPUFREQ +int tegra20_cpufreq_init (struct tegra_cpufreq_data *data); +#else +static inline int tegra20_cpufreq_init (struct tegra_cpufreq_data *data) +{return -EOPNOTSUPP ; } +#endif + +#endif /* __LINUX_TEGRA_CPUFREQ_H_ */
drivers/cpufreq/tegra20-cpufreq.c new file +133 -0
133 lines not on this page · raw message
include/linux/tegra-soc.h +10 -1
@@ -1,5 +1,5 @@/* -* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2012,2013, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License,
@@ -19,4 +19,13 @@u32 tegra_read_chipid (void ); +#ifdef CONFIG_ARM_TEGRA_CPUFREQ +int tegra_cpufreq_init (void ); +#else +static inline int tegra_cpufreq_init (void ) +{ +retrun EOPNOTSUPP ; +} +#endif +#endif /* __LINUX_TEGRA_SOC_H_ */
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2] cpufreq: tegra: Re-model Tegra cpufreq driver
Quoted 10 lines · Bill Huang
Re-model Tegra cpufreq driver to support all Tegra series of SoCs.
* Make
tegra-cpufreq.ca generic Tegra cpufreq driver.
* Move Tegra20 specific codes intotegra20-cpufreq.c.
* Bind Tegra cpufreq dirver with a fake device so defer probe would work when we're going to get regulator in the driver to support voltage scaling (DVFS).
* Calltegra_cpufreq_init()in Tegra machine code specifically so it won't be called in multi-platform kernel which is not running on Tegra SoCs.
That's a lot of things for one patch. Can this please be split up?
In particular, I would like a separate patch for the final bullet point, and for that patch to be the first in the series, so that we can merge it into both the Tegra and cpufreq trees if needed to resolve any conflicts.
drivers/cpufreq/Kconfig.arm config ARM_SPEAR_CPUFREQ · line 233
Quoted 7 lines
drivers/cpufreq/Kconfig.arm +2
-2config ARM_TEGRA_CPUFREQ - bool "TEGRA CPUFreq support" - depends on ARCH_TEGRA + bool + select CPU_FREQ_TABLE
Why make this a hidden option? It'd be best to leave it user-visible, so that existing defconfigs aren't broken by this change.
drivers/cpufreq/Kconfig.arm config ARM_SPEAR_CPUFREQ · line 237
Quoted 3 lines
drivers/cpufreq/Kconfig.arm +2
-0+config ARM_EXYNOS_CPUFREQ + bool select CPU_FREQ_TABLE
I think that Exynos change is a mistake?
drivers/cpufreq/Kconfig.arm config ARM_SPEAR_CPUFREQ · line 241
Quoted 4 lines
drivers/cpufreq/Kconfig.arm +4
-0+ +config ARM_TEGRA20_CPUFREQ + bool "NVIDIA TEGRA20" + depends on ARCH_TEGRA
Shouldn't that be ARCH_TEGRA_2x_SOC specifically?
Quoted 1 line
default y
Does the syntax "default ARM_TEGRA_CPUFREQ" work? Actually, this should depend on ARM_TEGRA_CPUFREQ rather than select it, and that way you can keep this "default y" and it'll only be enabled if Tegra cpufreq is enabled.
In summary, I think the following should work well:
config ARM_TEGRA_CPUFREQ
bool "TEGRA CPUFreq support"
depends on ARCH_TEGRA
select CPU_FREQ_TABLE
config ARM_TEGRA20_CPUFREQ
bool "NVIDIA TEGRA20"
depends on ARM_TEGRA_CPUFREQ && ARCH_TEGRA_2x_SOC default y
help
This adds the CPUFreq driver for NVIDIA TEGRA20 SoC.
If in doubt, say N.
drivers/cpufreq/tegra-cpufreq.c line 32
Quoted 4 lines
drivers/cpufreq/tegra-cpufreq.c +1
-1-#define NUM_CPUS 2 +#define NUM_CPUS 4
NUM_ or MAX_?
drivers/cpufreq/tegra-cpufreq.h line 28
Quoted 11 lines
drivers/cpufreq/tegra-cpufreq.h +9
-0+struct tegra_cpufreq_data { +struct device *dev; +struct clk *cpu_clk; +struct cpufreq_frequency_table *freq_table; +void (*vote_emc_on_cpu_rate)(unsigned long ); +int (*cpu_clk_set_rate)(unsigned long ); +void (*cpufreq_clk_init)(void ); +void (*cpufreq_clk_exit)(void ); +};
There's a mix of runtime and configuration-time data there. It'd be nicer to split the two out, so that all the configuration data could be in a const struct that's pointed to by a field in the runtime data struct, or passed back out of tegra20_cpufreq_init() as a separate pointer variable and assigned to a separate global in tegra-cpufreq.c, to avoid double-indirections everywhere at runtime.
drivers/cpufreq/tegra20-cpufreq.c line 39
Quoted 13 lines
drivers/cpufreq/tegra20-cpufreq.c +11
-0+static struct cpufreq_frequency_table freq_table[] = { + { .frequency =216000 }, + { .frequency =312000 }, + { .frequency =456000 }, + { .frequency =608000 }, + { .frequency =760000 }, + { .frequency =816000 }, + { .frequency =912000 }, + { .frequency =1000000 }, + { .frequency =CPUFREQ_TABLE_END }, +};
Should/can we query that list from the clock driver?
Quoted 1 line
+int
tegra20_cpufreq_init(struct tegra_cpufreq_data *data)
...
drivers/cpufreq/tegra20-cpufreq.c line 129
Quoted 6 lines
drivers/cpufreq/tegra20-cpufreq.c +6
-0+ data->cpu_clk = cpu_clk; + data->freq_table = freq_table; + data->vote_emc_on_cpu_rate = tegra20_vote_emc_on_cpu_rate; + data->cpu_clk_set_rate = tegra20_cpu_clk_set_rate; + data->cpufreq_clk_init = tegra20_cpufreq_clk_init; + data->cpufreq_clk_exit = tegra20_cpufreq_clk_exit;
With the struct split I proposed above, most of that could just be:
*soc_config = &tegra20_cpufreq_config;
where there's an extra function parameter "struct tegra_cpufreq_config **soc_config", and most of those values are in a static const tegra_cpufreq_config tegra20_cpufreq_config = { ... }.
Re: [PATCH 2/2] cpufreq: tegra: Re-model Tegra cpufreq driver
Quoted 17 lines · Stephen Warren
drivers/cpufreq/tegra20-cpufreq.c line 39
Quoted 13 lines · Bill Huang
drivers/cpufreq/tegra20-cpufreq.c +11
-0+static struct cpufreq_frequency_table freq_table[] = { + { .frequency =216000 }, + { .frequency =312000 }, + { .frequency =456000 }, + { .frequency =608000 }, + { .frequency =760000 }, + { .frequency =816000 }, + { .frequency =912000 }, + { .frequency =1000000 }, + { .frequency =CPUFREQ_TABLE_END }, +};Should/can we query that list from the clock driver?
It's not easy to query that list from clock driver so I'll leave it as it was. I'll take all the other comments, thanks.
Re: [PATCH 2/2] cpufreq: tegra: Re-model Tegra cpufreq driver
In reply to Bill Huanginclude/linux/tegra-soc.h line 27
Quoted 3 lines · Bill Huang
include/linux/tegra-soc.h +3
-0+static inline int tegra_cpufreq_init (void ) +{ +retrun EOPNOTSUPP ;
This should be -EOPNOTSUPP at least. I think -EINVAL might be better.
Cheers,
Peter.
Re: [PATCH 2/2] cpufreq: tegra: Re-model Tegra cpufreq driver
Quoted 7 lines · Peter De Schrijver
include/linux/tegra-soc.h line 27
Quoted 3 lines · Bill Huang
include/linux/tegra-soc.h +3
-0+static inline int tegra_cpufreq_init (void ) +{ +retrun EOPNOTSUPP ;This should be
-EOPNOTSUPPat least. I think-EINVALmight be better.
Yeah thanks, I'll also fix the TYPO of return.
Quoted 4 lines
Cheers,
Peter.