cpufreq: tegra: Re-model Tegra20 cpufreq driver
Subsystems (4)
PATCH v5 1/1 cpufreq: tegra: Re-model Tegra20 cpufreq driver
Re-model Tegra20 cpufreq driver as below.
* Rename tegra-cpufreq.c to tegra20-cpufreq.c since this file supports only Tegra20.
* Add probe function so defer probe can be used when we're going to support DVFS.
* Create a fake cpufreq platform device with its name being "${root_compatible}-cpufreq" so SoC cpufreq driver can bind to it accordingly.
---
This patch 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 are going to support DVFS.
Changes since v4:
- Remove module driver keyword since we'll not be built as a module driver
- Read SoC compatible Id from DT root instead of statically define it.
- Rebased on linux-next branch of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
Changes since v3:
- Create separate driver for each SoCs instead of a central driver indirect call to different SoC functions.
Changes since v2:
- Fix Kconfig.
- Rebase on top of branch 'cpufreq-next' on git://git.linaro.org/people/vireshk/linux.git.
Changes since v1:
- Split up patches.
- Split configuration-time data out of structure "tegra_cpufreq_data".
- Bug fixes.
---
arch/arm/mach-tegra/tegra.c | 2 +
drivers/cpufreq/Kconfig.arm | 12 +
drivers/cpufreq/Makefile | 1 +
drivers/cpufreq/tegra-cpufreq.c | 283 +++-----------------
.../cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} | 96 +++----
include/linux/tegra-cpufreq.h | 23 ++
6 files changed, 119 insertions(+), 298 deletions(-)
copy drivers/cpufreq/{tegra-cpufreq.c => tegra20-cpufreq.c} (66%)
create mode 100644 include/linux/tegra-cpufreq.harch/arm/mach-tegra/tegra.c +2 -0
@@ -34,6 +34,7 @@#include <linux/usb/tegra_usb_phy.h> #include <linux/clk/tegra.h> #include <linux/irqchip.h> +#include <linux/tegra-cpufreq.h> #include <asm/hardware/cache-l2x0.h> #include <asm/mach-types.h>
@@ -160,6 +161,7 @@ static void __init tegra_dt_init_late(void) {int i; +tegra_cpufreq_init ();tegra_init_suspend ();tegra_cpuidle_init ();tegra_powergate_debugfs_init ();
drivers/cpufreq/Kconfig.arm +12 -0
@@ -225,6 +225,18 @@ config ARM_TEGRA_CPUFREQ help This adds the CPUFreq driver support for TEGRA SOCs. +config ARM_TEGRA20_CPUFREQ + bool "NVIDIA TEGRA20" + depends on ARM_TEGRA_CPUFREQ && ARCH_TEGRA_2x_SOC + default y + help + This enables Tegra20 cpufreq functionality, it adds + Tegra20 CPU frequency ladder and the call back functions + to set CPU rate. All the non-SoC dependant codes are + controlled by the config ARM_TEGRA_CPUFREQ. + + If in doubt, say N. + config ARM_VEXPRESS_SPC_CPUFREQ tristate "Versatile Express SPC based CPUfreq driver" select ARM_BIG_LITTLE_CPUFREQ
drivers/cpufreq/Makefile +1 -0
@@ -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_ARM_TEGRA_CPUFREQ) += tegra-cpufreq.o +obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o ##################################################################################
drivers/cpufreq/tegra-cpufreq.c +32 -251
293 lines not on this page · raw message
drivers/cpufreq/tegra20-cpufreq.c renamed from drivers/cpufreq/tegra-cpufreq.c +49 -47
232 lines not on this page · raw message
include/linux/tegra-cpufreq.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* 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. +*/ + +#ifndef __LINUX_TEGRA_CPUFREQ_H +#define __LINUX_TEGRA_CPUFREQ_H + +#ifdef CONFIG_ARM_TEGRA_CPUFREQ +int tegra_cpufreq_init (void ); +#else +static inline int tegra_cpufreq_init (void ) {return 0 ; } +#endif + +#endif /* __LINUX_TEGRA_CPUFREQ_H_ */
Signature · 1 line
1.7.9.5
Quoted 9 lines · Bill Huang
Re-model Tegra20 cpufreq driver as below.
* Rename
tegra-cpufreq.ctotegra20-cpufreq.csince this file supports only Tegra20.
* Add probe function so defer probe can be used when we're going to support DVFS.
* Create a fake cpufreq platform device with its name being "${root_compatible}-cpufreq" so SoC cpufreq driver can bind to it accordingly.
It should be fine to merge the arch/arm/mach-tegra/ changes in this patch through the cpufreq tree, since I don't think they'll conflict at all with anything in other trees this kernel cycle.
drivers/cpufreq/tegra20-cpufreq.c static struct cpufreq_frequency_table freq_table[] = { · line 42
Quoted 4 lines
drivers/cpufreq/tegra20-cpufreq.c renamed from drivers/cpufreq/tegra-cpufreq.c +1
-1-#define NUM_CPUS 2 +#define MAX_CPUS 2
Nit: Given this driver is explicitly for a 2-CPU SoC, I don't think there's any need to s/NUM/MAX/ here. But I don't care that much.
Viresh Kumar
maintainerdrivers/cpufreq/Kconfig.arm config ARM_TEGRA_CPUFREQ · line 230
Quoted 11 lines · Bill Huang
drivers/cpufreq/Kconfig.arm +3
-0@@ -225,6 +225,18 @@ config ARM_TEGRA_CPUFREQ help This adds the CPUFreq driver support for TEGRA SOCs. +config ARM_TEGRA20_CPUFREQ + bool "NVIDIA TEGRA20" + depends on ARM_TEGRA_CPUFREQ && ARCH_TEGRA_2x_SOC
Probably just in case you agree to my next comment:
depends on ARCH_TEGRA_2x_SOC
Quoted 40 lines
drivers/cpufreq/Kconfig.arm +8
-0+ default y + help + This enables Tegra20 cpufreq functionality, it adds + Tegra20 CPU frequency ladder and the call back functions + to set CPU rate. All the non-SoC dependant codes are + controlled by the config ARM_TEGRA_CPUFREQ. + + If in doubt, say N.drivers/cpufreq/tegra-cpufreq.c +23
-0/* +* 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. */ #include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/of.h> +#include <linux/tegra-cpufreq.h> + +int __init tegra_cpufreq_init (void ) +{ +struct device_node *root; + + root =of_find_node_by_path ("/" ); +if (root) { +struct platform_device_info devinfo; +const char *compat; +int i; + +memset (&devinfo,0 ,sizeof (devinfo));
drivers/cpufreq/tegra-cpufreq.c
Quoted 10 lines
drivers/cpufreq/tegra-cpufreq.c +9
-0+ i =of_property_count_strings (root,"compatible" ); +if (i >0 ) { +of_property_read_string_index ( + root,"compatible" , i -1 , &compat); + devinfo.name =kasprintf ( +GFP_KERNEL ,"%s-cpufreq" , compat); +platform_device_register_full (&devinfo); + } } +EXPORT_SYMBOL (tegra_cpufreq_init);
Probably above is all that is present in this file. This is just about adding the right cpufreq device so that right driver can get probed.
I don't think this code is present at the right place. We don't need a file in cpufreq/ which is there just to add a device :) ..
Probably move this piece of code to arch/mach-tegra where you are calling init.
And so remove ARM_TEGRA_CPUFREQ config option completely.
Quoted 72 lines · Viresh Kumar
drivers/cpufreq/Kconfig.arm config ARM_TEGRA_CPUFREQ · line 230
Quoted 11 lines · Bill Huang
drivers/cpufreq/Kconfig.arm +3
-0@@ -225,6 +225,18 @@ config ARM_TEGRA_CPUFREQ help This adds the CPUFreq driver support for TEGRA SOCs. +config ARM_TEGRA20_CPUFREQ + bool "NVIDIA TEGRA20" + depends on ARM_TEGRA_CPUFREQ && ARCH_TEGRA_2x_SOCProbably just in case you agree to my next comment:
depends on
ARCH_TEGRA_2x_SOCQuoted 40 lines
drivers/cpufreq/Kconfig.arm +8
-0+ default y + help + This enables Tegra20 cpufreq functionality, it adds + Tegra20 CPU frequency ladder and the call back functions + to set CPU rate. All the non-SoC dependant codes are + controlled by the config ARM_TEGRA_CPUFREQ. + + If in doubt, say N.drivers/cpufreq/tegra-cpufreq.c +23
-0/* +* 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. */ #include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/of.h> +#include <linux/tegra-cpufreq.h> + +int __init tegra_cpufreq_init (void ) +{ +struct device_node *root; + + root =of_find_node_by_path ("/" ); +if (root) { +struct platform_device_info devinfo; +const char *compat; +int i; + +memset (&devinfo,0 ,sizeof (devinfo));drivers/cpufreq/tegra-cpufreq.c
Quoted 10 lines
drivers/cpufreq/tegra-cpufreq.c +9
-0+ i =of_property_count_strings (root,"compatible" ); +if (i >0 ) { +of_property_read_string_index ( + root,"compatible" , i -1 , &compat); + devinfo.name =kasprintf ( +GFP_KERNEL ,"%s-cpufreq" , compat); +platform_device_register_full (&devinfo); + } } +EXPORT_SYMBOL (tegra_cpufreq_init);Probably above is all that is present in this file. This is just about adding the right cpufreq device so that right driver can get probed.
Quoted 8 lines
I don't think this code is present at the right place. We don't need a file in cpufreq/ which is there just to add a device :) ..
Probably move this piece of code to
arch/mach-tegrawhere you are calling init.And so remove
ARM_TEGRA_CPUFREQconfig option completely.
Don't you think it worth creating a file here so this can be shared to arm64?
Viresh Kumar
maintainerQuoted 2 lines · bilhuang
Don't you think it worth creating a file here so this can be shared to arm64?
We will see how to handle virtual devices when we will start getting arm64 SoCs. Probably we might end up writing a single file in cpufreq, if required, that will create virtual devices for every arm64 platform..
So, some people might use it and others wouldn't.. But no platform specific files for such stuff. So, the best we can do for now is to move these to platform code as we are talking about arm32 SoC's for now which do have a mach-* directory..
Quoted 4 lines · Viresh Kumar
Quoted 2 lines · bilhuang
Don't you think it worth creating a file here so this can be shared to arm64?
Quoted 9 lines
We will see how to handle virtual devices when we will start getting arm64 SoCs. Probably we might end up writing a single file in cpufreq, if required, that will create virtual devices for every arm64 platform..
So, some people might use it and others wouldn't.. But no platform specific files for such stuff. So, the best we can do for now is to move these to platform code as we are talking about arm32 SoC's for now which do have a mach-* directory..
OK thanks, this is suggested by Stephen earlier, I'll let him comment in case he might think otherwise.
Quoted 9 lines · bilhuang
Quoted 8 lines · Viresh Kumar
Quoted 2 lines · bilhuang
Don't you think it worth creating a file here so this can be shared to arm64?
We will see how to handle virtual devices when we will start getting arm64 SoCs. Probably we might end up writing a single file in cpufreq, if required, that will create virtual devices for every arm64 platform..
Quoted 7 lines
Quoted 5 lines
So, some people might use it and others wouldn't.. But no platform specific files for such stuff. So, the best we can do for now is to move these to platform code as we are talking about arm32 SoC's for now which do have a mach-* directory..
OK thanks, this is suggested by Stephen earlier, I'll let him comment in case he might think otherwise.
No, I definitely don't agree here. The rules for arch/arm64 are: no platform-specific code. We should immediately start planning for that. If this means renaming the file that creates the virtual device from tegra-cpufreq.c to something else, so be it, but we shouldn't go backwards and push stuff into the arch directories.
Viresh Kumar
maintainerCcc'ing Grant and Rob as well.
Quoted 5 lines · Stephen Warren
No, I definitely don't agree here. The rules for
arch/arm64are: no platform-specific code. We should immediately start planning for that. If this means renaming the file that creates the virtual device fromtegra-cpufreq.cto something else, so be it, but we shouldn't go backwards and push stuff into the arch directories.
I don't mind doing this now as well if it is generic enough. I wasn't sure if you guys wanted to take it on now..
@Bill: So, please create a separate commit for creating such file which would create a virtual device for probing cpufreq drivers with name picked from root-node. Compilation of such a file should be configurable but if it is compiled, then it shouldn't cause any problems if that device isn't used, for multiplatform kernels specially..
Probably then you can widen the scope of your patchset by modifying some of the existing drivers which require a device to get cpufreq driver probed. Currently they are all making such a device from their arch/ stuff.
I am not sure about the location of such file. Should this be placed in DT code somewhere or kept in cpufreq? Rob/Grant ??
--
viresh
Quoted 18 lines · Viresh Kumar
Ccc'ing Grant and Rob as well.
Quoted 5 lines · Stephen Warren
No, I definitely don't agree here. The rules for
arch/arm64are: no platform-specific code. We should immediately start planning for that. If this means renaming the file that creates the virtual device fromtegra-cpufreq.cto something else, so be it, but we shouldn't go backwards and push stuff into the arch directories.I don't mind doing this now as well if it is generic enough. I wasn't sure if you guys wanted to take it on now..
@Bill: So, please create a separate commit for creating such file which would create a virtual device for probing cpufreq drivers with name picked from root-node. Compilation of such a file should be configurable but if it is compiled, then it shouldn't cause any problems if that device isn't used, for multiplatform kernels specially..
Quoted 4 lines
Probably then you can widen the scope of your patchset by modifying some of the existing drivers which require a device to get cpufreq driver probed. Currently they are all making such a device from their
arch/stuff.
Actually, I don't have plan or resource on doing this, would it be better that you help to do that instead? Thanks.
Quoted 4 lines
I am not sure about the location of such file. Should this be placed in DT code somewhere or kept in cpufreq? Rob/Grant ??
Do we have consensus on where to create such file?
Quoted 3 lines
--
viresh
Viresh Kumar
maintainerQuoted 2 lines · bilhuang
Actually, I don't have plan or resource on doing this, would it be better that you help to do that instead? Thanks.
Point taken. I am there to help if required. So, initially you can just make Tegra work according to the new file we were talking about. I will fix others later.
Quoted 4 lines
Quoted 3 lines
I am not sure about the location of such file. Should this be placed in DT code somewhere or kept in cpufreq? Rob/Grant ??
Do we have consensus on where to create such file?
Not yet, probably people were on leaves.
@Grant/Rob: Any inputs here?