All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Walmsley <paul@pwsan.com>
To: nm@ti.com
Cc: linux-omap@vger.kernel.org
Subject: [PATCH 12/12] OMAP3 OPP: move CPUFreq table init code to OPP layer
Date: Thu, 17 Dec 2009 17:47:42 -0700	[thread overview]
Message-ID: <20091218004741.7694.33747.stgit@localhost.localdomain> (raw)
In-Reply-To: <20091218004617.7694.84525.stgit@localhost.localdomain>

Move omap2_clk_init_cpufreq_table() to opp_init_cpufreq_table() in opp.c
where it now belongs.  OMAP2 still needs to be converted to use the OPP layer,
so it is using the old code.
---
 arch/arm/mach-omap2/clock34xx.c       |   55 +--------------------------------
 arch/arm/plat-omap/cpu-omap.c         |    6 +++-
 arch/arm/plat-omap/include/plat/opp.h |    4 ++
 arch/arm/plat-omap/opp.c              |   46 ++++++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 55 deletions(-)

diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index ba3dd70..6a40fb1 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -27,7 +27,6 @@
 #include <linux/limits.h>
 #include <linux/bitops.h>
 #include <linux/err.h>
-#include <linux/cpufreq.h>
 
 #include <plat/cpu.h>
 #include <plat/clock.h>
@@ -257,56 +256,7 @@ int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate)
 
 /* Common clock code */
 
-/*
- * As it is structured now, this will prevent an OMAP2/3 multiboot
- * kernel from compiling.  This will need further attention.
- */
-#if defined(CONFIG_ARCH_OMAP3)
-
-#ifdef CONFIG_CPU_FREQ
-
-static struct cpufreq_frequency_table *freq_table;
-
-void omap2_clk_init_cpufreq_table(struct cpufreq_frequency_table **table)
-{
-	int i = 0;
-	int opp_num;
-	struct omap_opp *opp = mpu_opps;
-	unsigned long freq = ULONG_MAX;
-
-	if (!mpu_opps) {
-		pr_warning("%s: failed to initialize frequency"
-				"table\n", __func__);
-		return;
-	}
-	opp_num = opp_get_opp_count(mpu_opps);
-	if (opp_num < 0) {
-		pr_err("%s: no opp table?\n", __func__);
-		return;
-	}
-
-	freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) *
-			(opp_num + 1), GFP_ATOMIC);
-	if (!freq_table) {
-		pr_warning("%s: failed to allocate frequency"
-				"table\n", __func__);
-		return;
-	}
-
-	while (!IS_ERR(opp = opp_find_freq_floor(opp, &freq))) {
-		freq_table[i].index = i;
-		freq_table[i].frequency = freq / 1000;
-		i++;
-		/* set the next benchmark to search */
-		freq--;
-	}
-
-	freq_table[i].index = i;
-	freq_table[i].frequency = CPUFREQ_TABLE_END;
-
-	*table = &freq_table[0];
-}
-#endif
+#ifdef CONFIG_ARCH_OMAP3
 
 struct clk_functions omap2_clk_functions = {
 	.clk_enable		= omap2_clk_enable,
@@ -315,9 +265,6 @@ 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
 };
 
 /*
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index a2b5ee4..723834e 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -132,7 +132,11 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
 
 	policy->cur = policy->min = policy->max = omap_getspeed(0);
 
-	clk_init_cpufreq_table(&freq_table);
+	if (!cpu_is_omap34xx())
+		clk_init_cpufreq_table(&freq_table);
+	else
+		opp_init_cpufreq_table(mpu_opps, &freq_table);
+
 	if (freq_table) {
 		result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
 		if (!result)
diff --git a/arch/arm/plat-omap/include/plat/opp.h b/arch/arm/plat-omap/include/plat/opp.h
index b00f7f9..91b0aa6 100644
--- a/arch/arm/plat-omap/include/plat/opp.h
+++ b/arch/arm/plat-omap/include/plat/opp.h
@@ -240,4 +240,8 @@ int opp_disable(struct omap_opp *opp);
 struct omap_opp * __deprecated opp_find_by_opp_id(struct omap_opp *opps,
 						  u8 opp_id);
 
+void opp_init_cpufreq_table(struct omap_opp *opps,
+			    struct cpufreq_frequency_table **table);
+
+
 #endif		/* __ASM_ARM_OMAP_OPP_H */
diff --git a/arch/arm/plat-omap/opp.c b/arch/arm/plat-omap/opp.c
index 8bdad43..aaafc10 100644
--- a/arch/arm/plat-omap/opp.c
+++ b/arch/arm/plat-omap/opp.c
@@ -14,6 +14,7 @@
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/cpufreq.h>
 
 #include <plat/opp_twl_tps.h>
 #include <plat/opp.h>
@@ -281,3 +282,48 @@ int opp_disable(struct omap_opp *opp)
 	opp->enabled = false;
 	return 0;
 }
+
+/* XXX document */
+void opp_init_cpufreq_table(struct omap_opp *opps,
+			    struct cpufreq_frequency_table **table)
+{
+	int i = 0;
+	int opp_num;
+	unsigned long freq = ULONG_MAX;
+	struct cpufreq_frequency_table *freq_table;
+
+	if (!opps) {
+		pr_warning("%s: failed to initialize frequency"
+				"table\n", __func__);
+		return;
+	}
+
+	opp_num = opp_get_opp_count(opps);
+	if (opp_num < 0) {
+		pr_err("%s: no opp table?\n", __func__);
+		return;
+	}
+
+	freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) *
+			     (opp_num + 1), GFP_ATOMIC);
+	if (!freq_table) {
+		pr_warning("%s: failed to allocate frequency"
+				"table\n", __func__);
+		return;
+	}
+
+	while (!OPP_TERM(opps)) {
+		if (opps->enabled) {
+			freq_table[i].index = i;
+			freq_table[i].frequency = freq / 1000;
+			i++;
+		}
+
+		opps++;
+	}
+
+	freq_table[i].index = i;
+	freq_table[i].frequency = CPUFREQ_TABLE_END;
+
+	*table = &freq_table[0];
+}



  parent reply	other threads:[~2009-12-18  0:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20091218004617.7694.84525.stgit@localhost.localdomain>
2009-12-18  0:47 ` [PATCH 01/12] OMAP OPP: remove some unnecessary variables Paul Walmsley
2009-12-18 17:28   ` Kevin Hilman
2009-12-18  0:47 ` [PATCH 02/12] OMAP OPP: split opp_find_freq_approx() into opp_find_freq_{floor, ceil}() Paul Walmsley
2009-12-18  0:47 ` [PATCH 03/12] OMAP OPP: only traverse opp_find_freq_floor() once Paul Walmsley
2009-12-19 12:10   ` Menon, Nishanth
2009-12-18  0:47 ` [PATCH 04/12] OMAP TWL/TPS OPP: move TWL/TPS-specific code to its own file Paul Walmsley
2009-12-19 12:14   ` Menon, Nishanth
2009-12-18  0:47 ` [PATCH 05/12] OMAP TWL/TPS OPP: vsel rounding belongs in opp_twl_tps.c Paul Walmsley
2009-12-19 12:16   ` Menon, Nishanth
2009-12-18  0:47 ` [PATCH 07/12] OMAP OPP: add opp_find_opp_by_opp_id() Paul Walmsley
2009-12-18  0:47 ` [PATCH 06/12] OMAP OPP: add microvolts DC ("u_volt") field into struct omap_opp Paul Walmsley
2009-12-18  0:47 ` [PATCH 08/12] OMAP SR/SRF: use opp_find_opp_by_opp_id() Paul Walmsley
2009-12-18  0:47 ` [PATCH 09/12] OMAP OPP: remove vsel Paul Walmsley
2009-12-18  0:47 ` [PATCH 10/12] OMAP OPP: remove "initial terminators" from OPP lists Paul Walmsley
2009-12-18 19:08   ` Kevin Hilman
2009-12-18  0:47 ` [PATCH 11/12] OMAP OPP: use kzalloc() rather than kmalloc() Paul Walmsley
2009-12-18  0:47 ` Paul Walmsley [this message]
2009-12-19 12:22   ` [PATCH 12/12] OMAP3 OPP: move CPUFreq table init code to OPP layer Menon, Nishanth

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=20091218004741.7694.33747.stgit@localhost.localdomain \
    --to=paul@pwsan.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=nm@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.