ARM: OMAP: implement CPUfreq frequency table based on PRCM table
PATCH 1/1 ARM: OMAP: implement CPUfreq frequency table based on PRCM table
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 | 37 ++++++++++++++++++++++++++++ arch/arm/plat-omap/cpu-omap.c | 52 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 87 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/clock24xx.c +37 -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[ARRAY_SIZE (rate_table)]; + +void clk_init_cpufreq_table (struct cpufreq_frequency_table **table) +{ +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 ; + + *table = &freq_table[0 ]; +} +#else +void clk_init_cpufreq_table (struct cpufreq_frequency_table **table) { } +#endif +EXPORT_SYMBOL (clk_init_cpufreq_table); +int __init omap2_clk_init (void ) {struct prcm_config *prcm;
arch/arm/plat-omap/cpu-omap.c +50 -2
117 lines not on this page · raw message
--
Tony Lindgren
maintainerHi,
Quoted 3 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.
I updated the patch a bit to use the cpufreq table if initialized, and to allow omap1 and omap3 to implement it later on easily. Can you please check? I've only compile tested on osk, and on n800 noticed there are currently no frequencies for 19.2 source clock.
Regards,
Tony
From: Kevin Hilman <[email protected]>
Subject: [PATCH] ARM: OMAP: implement CPUfreq frequency table based on PRCM table
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
Updated to try to use cpufreq_table if it exists.
arch/arm/mach-omap2/clock24xx.c +43 -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>
@@ -374,6 +375,45 @@ static int omap2_select_table_rate(struct clk *clk, unsigned long rate)return 0 ; } +#ifdef CONFIG_CPU_FREQ +/* +* Walk PRCM rate table and fillout cpufreq freq_table +*/ +static struct cpufreq_frequency_table freq_table[ARRAY_SIZE (rate_table)]; + +void omap2_clk_init_cpufreq_table (struct cpufreq_frequency_table **table) +{ +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++; + } + +if (i ==0 ) { +printk (KERN_WARNING "%s: failed to initialize frequency table\n" , + __FUNCTION__); +return ; + } + + freq_table[i].index = i; + freq_table[i].frequency =CPUFREQ_TABLE_END ; + + *table = &freq_table[0 ]; +} +#endif +static struct clk_functions omap2_clk_functions = { .clk_enable = omap2_clk_enable, .clk_disable = omap2_clk_disable,
@@ -381,6 +421,9 @@ static struct clk_functions omap2_clk_functions = { .clk_set_rate = omap2_clk_set_rate, .clk_set_parent = omap2_clk_set_parent, .clk_disable_unused = omap2_clk_disable_unused, +#ifdef CONFIG_CPU_FREQ + .clk_init_cpufreq_table = omap2_clk_init_cpufreq_table, +#endif };static u32 omap2_get_apll_clkin (void )
arch/arm/plat-omap/clock.c +13 -0
@@ -394,6 +394,19 @@ void clk_enable_init_clocks(void) }EXPORT_SYMBOL (clk_enable_init_clocks); +#ifdef CONFIG_CPU_FREQ +void clk_init_cpufreq_table (struct cpufreq_frequency_table **table) +{ +unsigned long flags; + +spin_lock_irqsave (&clockfw_lock, flags); +if (arch_clock->clk_init_cpufreq_table) + arch_clock->clk_init_cpufreq_table (table); +spin_unlock_irqrestore (&clockfw_lock, flags); +} +EXPORT_SYMBOL (clk_init_cpufreq_table); +#endif +/*-------------------------------------------------------------------------*/ #ifdef CONFIG_OMAP_RESET_CLOCKS
arch/arm/plat-omap/cpu-omap.c +53 -4
111 lines not on this page · raw message
include/asm-arm/arch-omap/clock.h +8 -0
@@ -10,6 +10,8 @@* published by the Free Software Foundation. */ +#include <linux/cpufreq.h> +#ifndef __ARCH_ARM_OMAP_CLOCK_H#define __ARCH_ARM_OMAP_CLOCK_H
@@ -85,6 +87,9 @@ struct clk_functions {void (*clk_allow_idle)(struct clk *clk);void (*clk_deny_idle)(struct clk *clk);void (*clk_disable_unused)(struct clk *clk); +#ifdef CONFIG_CPU_FREQ +void (*clk_init_cpufreq_table)(struct cpufreq_frequency_table **table); +#endif };extern unsigned int mpurate;
@@ -99,6 +104,9 @@ extern void clk_allow_idle(struct clk *clk);extern void clk_deny_idle (struct clk *clk);extern int clk_get_usecount (struct clk *clk);extern void clk_enable_init_clocks (void ); +#ifdef CONFIG_CPU_FREQ +extern void clk_init_cpufreq_table (struct cpufreq_frequency_table **table); +#endif /* Clock flags */ #define RATE_CKCTL (1 << 0)/* Main fixed ratio clocks */
Quoted 8 lines · Tony Lindgren
Quoted 3 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.
I updated the patch a bit to use the cpufreq table if initialized, and to allow omap1 and omap3 to implement it later on easily. Can you please check?
I like it. Thanks.
Quoted 2 lines
I've only compile tested on osk, and on n800 noticed there are currently no frequencies for 19.2 source clock.
I tested cpufreq on 2430 and it looks good.
I'll be adding the 3430 support shortly as well, so your updates are cleaner for that.
Kevin
Tony Lindgren
maintainerQuoted 8 lines · Kevin Hilman
Quoted 5 lines · Tony Lindgren
Quoted 3 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.
Quoted 5 lines
Quoted 3 lines
I updated the patch a bit to use the cpufreq table if initialized, and to allow omap1 and omap3 to implement it later on easily. Can you please check?
I like it. Thanks.
Cool.
Quoted 4 lines
Quoted 2 lines
I've only compile tested on osk, and on n800 noticed there are currently no frequencies for 19.2 source clock.
I tested cpufreq on 2430 and it looks good.
OK, will push today then.
Quoted 2 lines
I'll be adding the 3430 support shortly as well, so your updates are cleaner for that.
OK
Tony