From: Kevin Hilman <khilman@deeprootsystems.com>
To: linux-omap@vger.kernel.org
Subject: [PATCH 45/86] [ARM] OMAP2: Implement CPUfreq frequency table based on PRCM table
Date: Thu, 12 Mar 2009 11:27:55 -0700 [thread overview]
Message-ID: <1236882516-29403-46-git-send-email-khilman@deeprootsystems.com> (raw)
In-Reply-To: <1236882516-29403-45-git-send-email-khilman@deeprootsystems.com>
From: Kevin Hilman <khilman@mvista.com>
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
Signed-off-by: Kevin Hilman <khilman@mvista.com>
Updated to try to use cpufreq_table if it exists.
linux-omap source commit is 77ce544fa48deb7a2003f454624e3ca10d37ab87.
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-omap2/clock24xx.c | 42 ++++++++++++++++++++++
arch/arm/plat-omap/cpu-omap.c | 57 ++++++++++++++++++++++++++++--
arch/arm/plat-omap/include/mach/clock.h | 3 ++
3 files changed, 98 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 421728a..b990266 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -574,6 +574,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", __func__);
+ 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,
@@ -581,6 +620,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)
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index b269024..843e8af 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -23,10 +23,13 @@
#include <linux/io.h>
#include <mach/hardware.h>
+#include <mach/clock.h>
#include <asm/system.h>
#define VERY_HI_RATE 900000000
+static struct cpufreq_frequency_table *freq_table;
+
#ifdef CONFIG_ARCH_OMAP1
#define MPU_CLK "mpu"
#else
@@ -39,6 +42,9 @@ static struct clk *mpu_clk;
int omap_verify_speed(struct cpufreq_policy *policy)
{
+ if (freq_table)
+ return cpufreq_frequency_table_verify(policy, freq_table);
+
if (policy->cpu)
return -EINVAL;
@@ -70,12 +76,26 @@ static int omap_target(struct cpufreq_policy *policy,
struct cpufreq_freqs freqs;
int ret = 0;
+ /* Ensure desired rate is within allowed range. Some govenors
+ * (ondemand) will just pass target_freq=0 to get the minimum. */
+ if (target_freq < policy->cpuinfo.min_freq)
+ target_freq = policy->cpuinfo.min_freq;
+ if (target_freq > policy->cpuinfo.max_freq)
+ target_freq = policy->cpuinfo.max_freq;
+
freqs.old = omap_getspeed(0);
freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
freqs.cpu = 0;
+ if (freqs.old == freqs.new)
+ return ret;
+
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
- ret = clk_set_rate(mpu_clk, target_freq * 1000);
+#ifdef CONFIG_CPU_FREQ_DEBUG
+ printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
+ freqs.old, freqs.new);
+#endif
+ ret = clk_set_rate(mpu_clk, freqs.new * 1000);
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
return ret;
@@ -83,16 +103,31 @@ static int omap_target(struct cpufreq_policy *policy,
static int __init omap_cpu_init(struct cpufreq_policy *policy)
{
+ int result = 0;
+
mpu_clk = clk_get(NULL, MPU_CLK);
if (IS_ERR(mpu_clk))
return PTR_ERR(mpu_clk);
if (policy->cpu != 0)
return -EINVAL;
+
policy->cur = policy->min = policy->max = omap_getspeed(0);
- policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000;
- policy->cpuinfo.max_freq = clk_round_rate(mpu_clk, VERY_HI_RATE) / 1000;
- policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
+
+ clk_init_cpufreq_table(&freq_table);
+ if (freq_table) {
+ result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
+ if (!result)
+ cpufreq_frequency_table_get_attr(freq_table,
+ policy->cpu);
+ } else {
+ policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000;
+ policy->cpuinfo.max_freq = clk_round_rate(mpu_clk,
+ VERY_HI_RATE) / 1000;
+ }
+
+ /* FIXME: what's the actual transition time? */
+ policy->cpuinfo.transition_latency = 10 * 1000 * 1000;
return 0;
}
@@ -103,6 +138,11 @@ static int omap_cpu_exit(struct cpufreq_policy *policy)
return 0;
}
+static struct freq_attr *omap_cpufreq_attr[] = {
+ &cpufreq_freq_attr_scaling_available_freqs,
+ NULL,
+};
+
static struct cpufreq_driver omap_driver = {
.flags = CPUFREQ_STICKY,
.verify = omap_verify_speed,
@@ -111,6 +151,7 @@ static struct cpufreq_driver omap_driver = {
.init = omap_cpu_init,
.exit = omap_cpu_exit,
.name = "omap",
+ .attr = omap_cpufreq_attr,
};
static int __init omap_cpufreq_init(void)
@@ -119,3 +160,11 @@ static int __init omap_cpufreq_init(void)
}
arch_initcall(omap_cpufreq_init);
+
+/*
+ * if ever we want to remove this, upon cleanup call:
+ *
+ * cpufreq_unregister_driver()
+ * cpufreq_frequency_table_put_attr()
+ */
+
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h
index 6f49a33..681c651 100644
--- a/arch/arm/plat-omap/include/mach/clock.h
+++ b/arch/arm/plat-omap/include/mach/clock.h
@@ -121,6 +121,9 @@ extern void recalculate_root_clocks(void);
extern void followparent_recalc(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
extern const struct clkops clkops_null;
--
1.6.1.2
next prev parent reply other threads:[~2009-03-12 18:32 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 18:27 [PATCH 00/86] OMAP2/3: clock sync with linux-omap Kevin Hilman
2009-03-12 18:27 ` [PATCH 01/86] [ARM] omap: remove VIRTUAL_CLOCK Kevin Hilman
2009-03-12 18:27 ` [PATCH 02/86] [ARM] omap: introduce clock operations structure Kevin Hilman
2009-03-12 18:27 ` [PATCH 03/86] [ARM] omap: provide a NULL " Kevin Hilman
2009-03-12 18:27 ` [PATCH 04/86] [ARM] omap: kill PARENT_CONTROLS_CLOCK Kevin Hilman
2009-03-12 18:27 ` [PATCH 05/86] [ARM] omap: add default .ops to all remaining OMAP2 clocks Kevin Hilman
2009-03-12 18:27 ` [PATCH 06/86] [ARM] omap: eliminate unnecessary conditionals in omap2_clk_wait_ready Kevin Hilman
2009-03-12 18:27 ` [PATCH 07/86] [ARM] omap: don't use clkops_omap2_dflt_wait for non-ICLK/FCLK clocks Kevin Hilman
2009-03-12 18:27 ` [PATCH 08/86] [ARM] omap: remove clk->owner Kevin Hilman
2009-03-12 18:27 ` [PATCH 09/86] [ARM] omap: rearrange clock.h structure order Kevin Hilman
2009-03-12 18:27 ` [PATCH 10/86] [ARM] omap: remove clk_deny_idle and clk_allow_idle Kevin Hilman
2009-03-12 18:27 ` [PATCH 11/86] [ARM] omap: provide a standard clk_get_parent() implementation Kevin Hilman
2009-03-12 18:27 ` [PATCH 12/86] [ARM] omap: move clock propagation into core omap clock code Kevin Hilman
2009-03-12 18:27 ` [PATCH 13/86] [ARM] omap: remove unnecessary calls to propagate_rate() Kevin Hilman
2009-03-12 18:27 ` [PATCH 14/86] [ARM] omap: move propagate_rate() calls into generic omap clock code Kevin Hilman
2009-03-12 18:27 ` [PATCH 15/86] [ARM] omap: handle RATE_CKCTL via .set_rate/.round_rate methods Kevin Hilman
2009-03-12 18:27 ` [PATCH 16/86] [ARM] omap: ensure devname is set for dummy devices Kevin Hilman
2009-03-12 18:27 ` [PATCH 17/86] [ARM] omap: allow double-registering of clocks Kevin Hilman
2009-03-12 18:27 ` [PATCH 18/86] [ARM] omap: convert OMAP1 to use clkdev Kevin Hilman
2009-03-12 18:27 ` [PATCH 19/86] [ARM] omap: convert OMAP2 " Kevin Hilman
2009-03-12 18:27 ` [PATCH 20/86] [ARM] omap: convert OMAP3 " Kevin Hilman
2009-03-12 18:27 ` [PATCH 21/86] [ARM] omap: remove pre-CLKDEV clk_get/clk_put Kevin Hilman
2009-03-12 18:27 ` [PATCH 22/86] [ARM] omap: provide a dummy clock node Kevin Hilman
2009-03-12 18:27 ` [PATCH 23/86] [ARM] omap: watchdog: convert clocks to match by devid and conid Kevin Hilman
2009-03-12 18:27 ` [PATCH 24/86] [ARM] omap: watchdog: provide a dummy ick for OMAP1 Kevin Hilman
2009-03-12 18:27 ` [PATCH 25/86] [ARM] omap: MMC: convert clocks to match by devid and conid Kevin Hilman
2009-03-12 18:27 ` [PATCH 26/86] [ARM] omap: MMC: provide a dummy ick for OMAP1 Kevin Hilman
2009-03-12 18:27 ` [PATCH 27/86] [ARM] omap: mcspi: new short connection id names Kevin Hilman
2009-03-12 18:27 ` [PATCH 28/86] [ARM] omap: mcbsp: convert to use fck/ick clocks directly Kevin Hilman
2009-03-12 18:27 ` [PATCH 29/86] [ARM] omap: i2c: use short connection ids Kevin Hilman
2009-03-12 18:27 ` [PATCH 30/86] [ARM] omap: i2c: remove armxor_ck Kevin Hilman
2009-03-12 18:27 ` [PATCH 31/86] [ARM] omap: i2c: remove conditional ick clocks Kevin Hilman
2009-03-12 18:27 ` [PATCH 32/86] [ARM] omap: w1: convert omap HDQ clocks to match by devid and conid Kevin Hilman
2009-03-12 18:27 ` [PATCH 33/86] [ARM] omap: spi: arrange for omap_uwire to use connection ID Kevin Hilman
2009-03-12 18:27 ` [PATCH 34/86] [ARM] omap: convert omap RNG clocks to match by devid and conid Kevin Hilman
2009-03-12 18:27 ` [PATCH 35/86] [ARM] omap: omap24xxcam: use short connection IDs for omap2 clocks Kevin Hilman
2009-03-12 18:27 ` [PATCH 36/86] [ARM] omap: hsmmc: new short connection id names Kevin Hilman
2009-03-12 18:27 ` [PATCH 37/86] [ARM] OMAP2/3: Add non-CORE DPLL rate set code and M, N programming Kevin Hilman
2009-03-12 18:27 ` [PATCH 38/86] [ARM] OMAP: Fix sparse, checkpatch warnings in OMAP2/3 PRCM/PM code Kevin Hilman
2009-03-12 18:27 ` [PATCH 39/86] [ARM] OMAP24xx clock: add missing SSI L4 interface clock Kevin Hilman
2009-03-12 18:27 ` [PATCH 40/86] [ARM] OMAP3: move USBHOST SAR handling from clock framework to powerdomain layer Kevin Hilman
2009-03-12 18:27 ` [PATCH 41/86] [ARM] OMAP3 clock: fix 96MHz clocks Kevin Hilman
2009-03-12 18:27 ` [PATCH 42/86] [ARM] OMAP2: Fix definition of SGX clock register bits Kevin Hilman
2009-03-12 18:27 ` [PATCH 43/86] [ARM] OMAP: Add CSI2 clock struct for handling it with clock API Kevin Hilman
2009-03-12 18:27 ` [PATCH 44/86] [ARM] OMAP: Make dpll4_m4_ck programmable with clk_set_rate() Kevin Hilman
2009-03-12 18:27 ` Kevin Hilman [this message]
2009-03-12 18:27 ` [PATCH 46/86] [ARM] OMAP2/3 clockdomains: combine pwrdm, pwrdm_name into union in struct clockdomain Kevin Hilman
2009-03-12 18:27 ` [PATCH 47/86] [ARM] OMAP2/3 clockdomains: add CM and PRM clkdms Kevin Hilman
2009-03-12 18:27 ` [PATCH 48/86] [ARM] OMAP3 clock: move sys_clkout2 clk to core_clkdm Kevin Hilman
2009-03-12 18:27 ` [PATCH 49/86] [ARM] OMAP3 PRCM: add DPLL1-5 powerdomains, clockdomains; mark clocks Kevin Hilman
2009-03-12 18:28 ` [PATCH 50/86] [ARM] OMAP3 powerdomains: remove RET from SGX power states list Kevin Hilman
2009-03-12 18:28 ` [PATCH 51/86] [ARM] OMAP: wait for pwrdm transition after clk_enable() Kevin Hilman
2009-03-12 18:28 ` [PATCH 52/86] [ARM] OMAP2/3 clockdomains: autodeps should respect platform flags Kevin Hilman
2009-03-12 18:28 ` [PATCH 53/86] [ARM] OMAP3: PM: Emu_pwrdm is switched off by hardware even when sdti is in use Kevin Hilman
2009-03-12 18:28 ` [PATCH 54/86] [ARM] OMAP3 clock: fix DPLL jitter correction and rate programming Kevin Hilman
2009-03-12 18:28 ` [PATCH 55/86] [ARM] OMAP3 clock: DPLL{1,2}_FCLK clksel can divide by 4 Kevin Hilman
2009-03-12 18:28 ` [PATCH 56/86] [ARM] OMAP3 clock: convert dpll_data.idlest_bit to idlest_mask Kevin Hilman
2009-03-12 18:28 ` [PATCH 57/86] [ARM] OMAP3 clock: remove unnecessary dpll_data dereferences Kevin Hilman
2009-03-12 18:28 ` [PATCH 58/86] [ARM] OMAP3 clock: optimize DPLL rate rounding algorithm Kevin Hilman
2009-03-12 18:28 ` [PATCH 59/86] [ARM] OMAP3 clock: avoid invalid FREQSEL values during DPLL rate rounding Kevin Hilman
2009-03-12 18:28 ` [PATCH 60/86] [ARM] OMAP3 clock: disable DPLL autoidle while waiting for DPLL to lock Kevin Hilman
2009-03-12 18:28 ` [PATCH 61/86] [ARM] OMAP2/3 clock: clean up mach-omap2/clock.c Kevin Hilman
2009-03-12 18:28 ` [PATCH 62/86] [ARM] OMAP34XX: Add miscellaneous definitions related to 34xx Kevin Hilman
2009-03-12 18:28 ` [PATCH 63/86] [ARM] OMAP2 PRCM: clean up CM_IDLEST bits Kevin Hilman
2009-03-12 18:28 ` [PATCH 64/86] [ARM] omap: Fix omap1 clock issues Kevin Hilman
2009-03-12 18:28 ` [PATCH 65/86] [ARM] OMAP2 SDRC: move mach-omap2/memory.h into mach/sdrc.h Kevin Hilman
2009-03-12 18:28 ` [PATCH 66/86] [ARM] OMAP2 SDRC: rename memory.c to sdrc2xxx.c Kevin Hilman
2009-03-12 18:28 ` [PATCH 67/86] [ARM] OMAP2 SDRC: separate common OMAP2/3 code from OMAP2xxx code Kevin Hilman
2009-03-12 18:28 ` [PATCH 68/86] [ARM] OMAP2 SDRC: add SDRAM timing parameter infrastructure Kevin Hilman
2009-03-12 18:28 ` [PATCH 69/86] [ARM] OMAP3 clock: add omap3_core_dpll_m2_set_rate() Kevin Hilman
2009-03-12 18:28 ` [PATCH 70/86] [ARM] OMAP3: PM: Make sure clk_disable_unused() order is correct Kevin Hilman
2009-03-12 18:28 ` [PATCH 71/86] [ARM] OMAP2/3 clock: use standard set_rate fn in omap2_clk_arch_init() Kevin Hilman
2009-03-12 18:28 ` [PATCH 72/86] [ARM] omap: clks: call recalc after any rate change Kevin Hilman
2009-03-12 18:28 ` [PATCH 73/86] [ARM] omap: create a proper tree of clocks Kevin Hilman
2009-03-12 18:28 ` [PATCH 74/86] [ARM] OMAP2/3 clock: don't use a barrier after clk_disable() Kevin Hilman
2009-03-12 18:28 ` [PATCH 75/86] [ARM] OMAP2xxx clock: consolidate DELAYED_APP clock commits; fix barrier Kevin Hilman
2009-03-12 18:28 ` [PATCH 76/86] [ARM] OMAP2/3 clock: convert remaining MPU barriers into OCP barriers Kevin Hilman
2009-03-12 18:28 ` [PATCH 77/86] [ARM] OMAP clock: drop clk_get_usecount() Kevin Hilman
2009-03-12 18:28 ` [PATCH 78/86] [ARM] omap: fix usecount decrement bug Kevin Hilman
2009-03-12 18:28 ` [PATCH 79/86] [ARM] omap: fix clockdomain enable/disable ordering Kevin Hilman
2009-03-12 18:28 ` [PATCH 80/86] [ARM] OMAP2/3 clock: don't tinker with hardirqs when they are supposed to be disabled Kevin Hilman
2009-03-12 18:28 ` [PATCH 81/86] [ARM] omap: arrange for clock recalc methods to return the rate Kevin Hilman
2009-03-12 18:28 ` [PATCH 82/86] [ARM] omap: add support for bypassing DPLLs Kevin Hilman
2009-03-12 18:28 ` [PATCH 83/86] [ARM] OMAP3: update ES level flags to discriminate between post-ES2 revisions Kevin Hilman
2009-03-12 18:28 ` [PATCH 84/86] [ARM] OMAP3 powerdomains: make USBTLL SAR only available on ES3.1 and beyond Kevin Hilman
2009-03-12 18:28 ` [PATCH 85/86] [ARM] omap: ensure that failing power domain lookups produce errors Kevin Hilman
2009-03-12 18:28 ` [PATCH 86/86] [ARM] omap: clk_set_parent: deny changing parent if clock is enabled Kevin Hilman
2009-03-12 20:39 ` [PATCH 38/86] [ARM] OMAP: Fix sparse, checkpatch warnings in OMAP2/3 PRCM/PM code Pandita, Vikram
2009-03-12 21:32 ` Kevin Hilman
2009-03-16 18:06 ` [PATCH 00/86] OMAP2/3: clock sync with linux-omap Kevin Hilman
2009-03-19 8:57 ` Paul Walmsley
2009-03-19 16:04 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1236882516-29403-46-git-send-email-khilman@deeprootsystems.com \
--to=khilman@deeprootsystems.com \
--cc=linux-omap@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).