Skip to contentSkip to conversation

ARM: OMAP: implement CPUfreq frequency table based on PRCM table

PATCH/RFC Kevin Hilman 2 participants 2 messages Oct 19, 2007 – Nov 1, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

This patch adds a CPUfreq frequency-table implementation for OMAP2 by walking the PRCM rate-table for available entries and adding them to a CPUfreq table.

CPUfreq can then be used to manage switching between all the available entries in the PRCM rate table. Either use the CPUfreq sysfs interface directly, (see Section 3 of Documentation/cpu-freq/user-guide.txt) or use the cpufrequtils package:
http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html

---
 arch/arm/mach-omap2/clock24xx.c |   39 ++++++++++++++++++++++++++++++
 arch/arm/plat-omap/cpu-omap.c   |   52 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 89 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/clock24xx.c +39 -0
Index: dev/arch/arm/mach-omap2/clock24xx.c
===================================================================
@@ -26,6 +26,7 @@
 #include <linux/clk.h>
 
 #include <linux/io.h>
+#include <linux/cpufreq.h>
 
 #include <asm/arch/clock.h>
 #include <asm/arch/sram.h>
@@ -461,6 +462,42 @@ static int __init omap2_clk_arch_init(vo
 }
 arch_initcall(omap2_clk_arch_init);
 
+#ifdef CONFIG_CPU_FREQ
+/*
+ * Walk PRCM rate table and fillout cpufreq freq_table
+ */
+static struct cpufreq_frequency_table freq_table[16];
+struct cpufreq_frequency_table *omap2_cpufreq_table;
+
+static void omap2_cpufreq_init_table(void)
+{
+	struct prcm_config *prcm;
+	int i = 0;
+
+	for (prcm = rate_table; prcm->mpu_speed; prcm++) {
+		if (!(prcm->flags & cpu_mask))
+			continue;
+		if (prcm->xtal_speed != sys_ck.rate)
+			continue;
+
+		/* don't put bypass rates in table */
+		if (prcm->dpll_speed == prcm->xtal_speed)
+			continue;
+
+		freq_table[i].index = i;
+		freq_table[i].frequency = prcm->mpu_speed / 1000;
+		i++;
+	}
+
+	freq_table[i].index = i;
+	freq_table[i].frequency = CPUFREQ_TABLE_END;
+
+	omap2_cpufreq_table = &freq_table[0];
+}
+#else
+static void omap2_cpufreq_init_table(void) {}
+#endif
+
 int __init omap2_clk_init(void)
 {
 	struct prcm_config *prcm;
@@ -520,5 +557,7 @@ int __init omap2_clk_init(void)
 	vclk = clk_get(NULL, "virt_prcm_set");
 	sclk = clk_get(NULL, "sys_ck");
 
+	omap2_cpufreq_init_table();
+
 	return 0;
 }
arch/arm/plat-omap/cpu-omap.c +50 -2

111 lines not on this page · raw message

--

maintainer
#1 lore raw

Hi,

Quoted 62 lines · Kevin Hilman

This patch adds a CPUfreq frequency-table implementation for OMAP2 by walking the PRCM rate-table for available entries and adding them to a CPUfreq table.

CPUfreq can then be used to manage switching between all the available entries in the PRCM rate table. Either use the CPUfreq sysfs interface directly, (see Section 3 of Documentation/cpu-freq/user-guide.txt) or use the cpufrequtils package:
http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html

---
 arch/arm/mach-omap2/clock24xx.c |   39 ++++++++++++++++++++++++++++++
 arch/arm/plat-omap/cpu-omap.c   |   52 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 89 insertions(+), 2 deletions(-)

Index: dev/arch/arm/mach-omap2/clock24xx.c
===================================================================

arch/arm/mach-omap2/clock24xx.c +30 -0
@@ -26,6 +26,7 @@
 #include <linux/clk.h>
 
 #include <linux/io.h>
+#include <linux/cpufreq.h>
 
 #include <asm/arch/clock.h>
 #include <asm/arch/sram.h>
@@ -461,6 +462,42 @@ static int __init omap2_clk_arch_init(vo
 }
 arch_initcall(omap2_clk_arch_init);
 
+#ifdef CONFIG_CPU_FREQ
+/*
+ * Walk PRCM rate table and fillout cpufreq freq_table
+ */
+static struct cpufreq_frequency_table freq_table[16];
+struct cpufreq_frequency_table *omap2_cpufreq_table;
+
+static void omap2_cpufreq_init_table(void)
+{
+	struct prcm_config *prcm;
+	int i = 0;
+
+	for (prcm = rate_table; prcm->mpu_speed; prcm++) {
+		if (!(prcm->flags & cpu_mask))
+			continue;
+		if (prcm->xtal_speed != sys_ck.rate)
+			continue;
+
+		/* don't put bypass rates in table */
+		if (prcm->dpll_speed == prcm->xtal_speed)
+			continue;
+
+		freq_table[i].index = i;
+		freq_table[i].frequency = prcm->mpu_speed / 1000;
+		i++;
+	}
+
+	freq_table[i].index = i;
+	freq_table[i].frequency = CPUFREQ_TABLE_END;

arch/arm/mach-omap2/clock24xx.c static int __init omap2_clk_arch_init(vo · line 503

Quoted 10 lines
arch/arm/mach-omap2/clock24xx.c +7 -0
+
+	omap2_cpufreq_table = &freq_table[0];
+}
+#else
+static void omap2_cpufreq_init_table(void) {}
+#endif
+
 int __init omap2_clk_init(void)
 {
 	struct prcm_config *prcm;

How about rather call omap2_cpufreq_init_table(freq_table) from cpu-omap.c init and pass it the freq table from cpu-omap.c?

Also, eventually we should allow board-*.c files specify the rate table too.

Regards,

Tony