Skip to contentSkip to conversation

Remodel Tegra cpufreq driver to support Tegra series SoCs

PATCH Superseded Bill Huang 3 participants 8 messages Sep 12, 2013 – Sep 14, 2013

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Bill Huang

author
#0 lore raw

v2 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.

Changes since v1:

- Split up patches.
- Split configuration-time data out of structure "tegra_cpufreq_data".
- Bug fixes.

Bill Huang (4):
cpufreq: tegra: Call tegra_cpufreq_init() specifically in machine
code
cpufreq: tegra: Remove not used header files and clean up codes
cpufreq: tegra: Re-model Tegra cpufreq driver
ARM: tegra: defconfig updates

 arch/arm/configs/tegra_defconfig  |    1 +
 arch/arm/mach-tegra/common.c      |    2 +
 drivers/cpufreq/Kconfig.arm       |    8 +-
 drivers/cpufreq/Makefile          |    1 +
 drivers/cpufreq/tegra-cpufreq.c   |  194 +++++++++++++++++--------------------
 drivers/cpufreq/tegra-cpufreq.h   |   42 ++++++++
 drivers/cpufreq/tegra20-cpufreq.c |  138 ++++++++++++++++++++++++++
 include/linux/tegra-soc.h         |   11 ++-
 8 files changed, 290 insertions(+), 107 deletions(-)
 create mode 100644 drivers/cpufreq/tegra-cpufreq.h
 create mode 100644 drivers/cpufreq/tegra20-cpufreq.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v2 1/4 cpufreq: tegra: Call tegra_cpufreq_init() specifically in machine code

Move the call from module_init to Tegra machine codes so it won't be called in a multi-platform kernel running on non-Tegra SoCs.

---
 arch/arm/mach-tegra/common.c    |    2 ++
 drivers/cpufreq/tegra-cpufreq.c |   13 ++-----------
 include/linux/tegra-soc.h       |   11 ++++++++++-
 3 files changed, 14 insertions(+), 12 deletions(-)
arch/arm/mach-tegra/common.c +2 -0
index 94a119a..db4414e 100644
@@ -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/tegra-cpufreq.c +2 -11
index a7b876f..09c5af0 100644
@@ -253,7 +253,7 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
 	.attr		= tegra_cpufreq_attr,
 };
 
-static int __init tegra_cpufreq_init(void)
+int __init tegra_cpufreq_init(void)
 {
 	cpu_clk = clk_get_sys(NULL, "cclk");
 	if (IS_ERR(cpu_clk))
@@ -275,17 +275,8 @@ static int __init tegra_cpufreq_init(void)
 
 	return cpufreq_register_driver(&tegra_cpufreq_driver);
 }
-
-static void __exit tegra_cpufreq_exit(void)
-{
-        cpufreq_unregister_driver(&tegra_cpufreq_driver);
-	clk_put(emc_clk);
-	clk_put(cpu_clk);
-}
-
+EXPORT_SYMBOL(tegra_cpufreq_init);
 
 MODULE_AUTHOR("Colin Cross <[email protected]>");
 MODULE_DESCRIPTION("cpufreq driver for Nvidia Tegra2");
 MODULE_LICENSE("GPL");
-module_init(tegra_cpufreq_init);
-module_exit(tegra_cpufreq_exit);
include/linux/tegra-soc.h +10 -1
index 95f611d..d86d081 100644
@@ -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)
+{
+	return -EINVAL;
+}
+#endif
+
 #endif /* __LINUX_TEGRA_SOC_H_ */
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v2 2/4 cpufreq: tegra: Remove not used header files and clean up codes

In reply to Bill Huang

Remove the 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 |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/cpufreq/tegra-cpufreq.c +2 -13
index 09c5af0..c2d2910 100644
@@ -18,14 +18,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[] = {
@@ -40,14 +35,14 @@ static struct cpufreq_frequency_table freq_table[] = {
 	{ .frequency = CPUFREQ_TABLE_END },
 };
 
-#define NUM_CPUS	2
+#define MAX_CPUS	4
 
 static struct clk *cpu_clk;
 static struct clk *pll_x_clk;
 static struct clk *pll_p_clk;
 static struct clk *emc_clk;
 
-static unsigned long target_cpu_speed[NUM_CPUS];
+static unsigned long target_cpu_speed[MAX_CPUS];
 static DEFINE_MUTEX(tegra_cpu_lock);
 static bool is_suspended;
 
@@ -60,9 +55,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 +201,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
author
#3 lore raw

PATCH v2 3/4 cpufreq: tegra: Re-model Tegra cpufreq driver

In reply to Bill Huang

Re-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).

---
 drivers/cpufreq/Kconfig.arm       |    8 +-
 drivers/cpufreq/Makefile          |    1 +
 drivers/cpufreq/tegra-cpufreq.c   |  176 +++++++++++++++++++------------------
 drivers/cpufreq/tegra-cpufreq.h   |   42 +++++++++
 drivers/cpufreq/tegra20-cpufreq.c |  138 +++++++++++++++++++++++++++++
 5 files changed, 278 insertions(+), 87 deletions(-)
 create mode 100644 drivers/cpufreq/tegra-cpufreq.h
 create mode 100644 drivers/cpufreq/tegra20-cpufreq.c
drivers/cpufreq/Kconfig.arm +7 -1
index 0fa204b..09a80a4 100644
@@ -232,6 +232,12 @@ 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 support for TEGRA SOCs.
+	  This adds the CPUFreq driver for NVIDIA TEGRA20 SoC.
+
+	  If in doubt, say N.
drivers/cpufreq/Makefile +1 -0
index ad5866c..22a85f0 100644
@@ -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 +90 -86

257 lines not on this page · raw message

drivers/cpufreq/tegra-cpufreq.h new file +42 -0

42 lines not on this page · raw message

drivers/cpufreq/tegra20-cpufreq.c new file +138 -0

138 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH v2 3/4] cpufreq: tegra: Re-model Tegra cpufreq driver

Quoted 14 lines · Bill Huang

Re-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).

drivers/cpufreq/Kconfig.arm +0 -0
@@ -232,6 +232,12 @@ config ARM_TEGRA_CPUFREQ
 	bool "TEGRA CPUFreq support"
 	depends on ARCH_TEGRA
 	select CPU_FREQ_TABLE

drivers/cpufreq/Kconfig.arm config ARM_TEGRA_CPUFREQ · line 243

Quoted 10 lines
drivers/cpufreq/Kconfig.arm +7 -1
+
+config ARM_TEGRA20_CPUFREQ
+	bool "NVIDIA TEGRA20"
+	depends on ARM_TEGRA_CPUFREQ && ARCH_TEGRA_2x_SOC
 	default y
 	help
-	  This adds the CPUFreq driver support for TEGRA SOCs.
+	  This adds the CPUFreq driver for NVIDIA TEGRA20 SoC.
+
+	  If in doubt, say N.

This patch removes the following from "config ARM_TEGRA_CPUFREQ":

default y
help
This adds the CPUFreq driver support for TEGRA SOCs.

I think that option should be left unchanged, such that this patch *just* adds the new option without changing the existing one. If you do that, then you can completely drop patch 4/4.

Other than that, this series looks fine.

author
#5 lore raw

Re: [PATCH v2 3/4] cpufreq: tegra: Re-model Tegra cpufreq driver

Quoted 28 lines · Stephen Warren
Quoted 14 lines · Bill Huang

Re-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).

drivers/cpufreq/Kconfig.arm +0 -0
@@ -232,6 +232,12 @@ config ARM_TEGRA_CPUFREQ
 	bool "TEGRA CPUFreq support"
 	depends on ARCH_TEGRA
 	select CPU_FREQ_TABLE

drivers/cpufreq/Kconfig.arm config ARM_TEGRA_CPUFREQ · line 243

Quoted 10 lines
drivers/cpufreq/Kconfig.arm +7 -1
+
+config ARM_TEGRA20_CPUFREQ
+	bool "NVIDIA TEGRA20"
+	depends on ARM_TEGRA_CPUFREQ && ARCH_TEGRA_2x_SOC
 	default y
 	help
-	  This adds the CPUFreq driver support for TEGRA SOCs.
+	  This adds the CPUFreq driver for NVIDIA TEGRA20 SoC.
+
+	  If in doubt, say N.

This patch removes the following from "config ARM_TEGRA_CPUFREQ":

Quoted 7 lines

default y
help
This adds the CPUFreq driver support for TEGRA SOCs.

I think that option should be left unchanged, such that this patch *just* adds the new option without changing the existing one. If you do that, then you can completely drop patch 4/4.

Thanks, I'll change and rebase in next version after Viresh's cleanup patch series is merged.

Quoted 2 lines

Other than that, this series looks fine.

author
#6 lore raw

PATCH v2 4/4 ARM: tegra: defconfig updates

In reply to Bill Huang

Enable:
* Tegra CPUFreq driver.

---
 arch/arm/configs/tegra_defconfig |    1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/tegra_defconfig +1 -0
index ea042e8..64bc8bd 100644
@@ -42,6 +42,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0
 CONFIG_KEXEC=y
 CONFIG_CPU_FREQ=y
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+CONFIG_ARM_TEGRA_CPUFREQ=y
 CONFIG_CPU_IDLE=y
 CONFIG_VFP=y
 CONFIG_PM_RUNTIME=y
Signature · 1 line
1.7.9.5
maintainer
#7 lore raw
In reply to Bill Huang
Quoted 18 lines · Bill Huang

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.

Changes since v1:

- Split up patches.
- Split configuration-time data out of structure "tegra_cpufreq_data".
- Bug fixes.

Bill Huang (4):
cpufreq: tegra: Call tegra_cpufreq_init() specifically in machine
code
cpufreq: tegra: Remove not used header files and clean up codes
cpufreq: tegra: Re-model Tegra cpufreq driver
ARM: tegra: defconfig updates

Quoted 11 lines
 arch/arm/configs/tegra_defconfig  |    1 +
 arch/arm/mach-tegra/common.c      |    2 +
 drivers/cpufreq/Kconfig.arm       |    8 +-
 drivers/cpufreq/Makefile          |    1 +
 drivers/cpufreq/tegra-cpufreq.c   |  194 +++++++++++++++++--------------------
 drivers/cpufreq/tegra-cpufreq.h   |   42 ++++++++
 drivers/cpufreq/tegra20-cpufreq.c |  138 ++++++++++++++++++++++++++
 include/linux/tegra-soc.h         |   11 ++-
 8 files changed, 290 insertions(+), 107 deletions(-)
 create mode 100644 drivers/cpufreq/tegra-cpufreq.h
 create mode 100644 drivers/cpufreq/tegra20-cpufreq.c

I haven't gone deeper into these yet, but there are some cleaup patches that I have prepared/posted earlier, which will be queued by Rafael soon.. And after that you would be required to rebase your stuff on top of it.. As there would be many conflicts..

--
viresh