linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support
@ 2011-02-25  6:10 Santosh Shilimkar
  2011-02-25  6:10 ` [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver Santosh Shilimkar
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2011-02-25  6:10 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, vishwanath.bs, Santosh Shilimkar

This series is an attempt to clean-up omap cpufreq driver.
	- The OMAP1 and OMAP2PLUS cpufreq support is split to avoid
	  any #ifdefery
	- Alias clock nodes are added in all OMAP2PLUS clock-data
	  to avoid any cpu_is_xxx() checks
	- The omap2plus_cupfreq support is updated to work on
	  SMP_ON_UP builds
	- SMP support is added which can be used on OMAP4

Thanks to Vishwanath BS <vishwanath.bs@ti.com> for doing testing with
his DVFS series and review.

The series is generated against Kevin's cpufreq branch.

The following changes since commit 444a22eb04ae07aef45cd4d0154f6f2bbe76daa9:
  Kevin Hilman (1):
        cpufreq: fixup after new OPP layer merged


Santosh Shilimkar (3):
  omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq
    driver
  omap: cpufreq: Split omap1 and omap2plus cpufreq drivers.
  omap2plus: cpufreq: Add SMP support to cater OMAP4430

 arch/arm/mach-omap1/Makefile                       |    3 +
 .../cpu-omap.c => mach-omap1/omap1-cpufreq.c}      |   70 +++-------
 arch/arm/mach-omap2/Makefile                       |    3 +
 arch/arm/mach-omap2/clock2420_data.c               |    1 +
 arch/arm/mach-omap2/clock2430_data.c               |    1 +
 arch/arm/mach-omap2/clock3xxx_data.c               |    1 +
 arch/arm/mach-omap2/clock44xx_data.c               |    1 +
 .../cpu-omap.c => mach-omap2/omap2plus-cpufreq.c}  |  152 +++++++++++++-------
 arch/arm/plat-omap/Makefile                        |    1 -
 9 files changed, 129 insertions(+), 104 deletions(-)
 copy arch/arm/{plat-omap/cpu-omap.c => mach-omap1/omap1-cpufreq.c} (74%)
 rename arch/arm/{plat-omap/cpu-omap.c => mach-omap2/omap2plus-cpufreq.c} (56%)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver
  2011-02-25  6:10 [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Santosh Shilimkar
@ 2011-02-25  6:10 ` Santosh Shilimkar
  2011-03-10 22:13   ` Kevin Hilman
  2011-02-25  6:10 ` [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers Santosh Shilimkar
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Santosh Shilimkar @ 2011-02-25  6:10 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, vishwanath.bs, Santosh Shilimkar

Add an alias clock node for cpu clock control on all OMAP2PLUS devices.
The intention is avoid cpu_is_xxxx() checks in the common cpufreq driver.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 arch/arm/mach-omap2/clock2420_data.c |    1 +
 arch/arm/mach-omap2/clock2430_data.c |    1 +
 arch/arm/mach-omap2/clock3xxx_data.c |    1 +
 arch/arm/mach-omap2/clock44xx_data.c |    1 +
 4 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index 0a992bc..3efe45b 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -1799,6 +1799,7 @@ static struct omap_clk omap2420_clks[] = {
 	CLK(NULL,	"ssi_l4_ick",	&ssi_l4_ick,	CK_242X),
 	/* virtual meta-group clock */
 	CLK(NULL,	"virt_prcm_set", &virt_prcm_set, CK_242X),
+	CLK(NULL,	"cpu_ck", &virt_prcm_set, CK_242X),
 	/* general l4 interface ck, multi-parent functional clk */
 	CLK(NULL,	"gpt1_ick",	&gpt1_ick,	CK_242X),
 	CLK(NULL,	"gpt1_fck",	&gpt1_fck,	CK_242X),
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
index c047dcd..25b1c2d 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -1903,6 +1903,7 @@ static struct omap_clk omap2430_clks[] = {
 	CLK(NULL,	"ssi_l4_ick",	&ssi_l4_ick,	CK_243X),
 	/* virtual meta-group clock */
 	CLK(NULL,	"virt_prcm_set", &virt_prcm_set, CK_243X),
+	CLK(NULL,	"cpu_ck", &virt_prcm_set, CK_243X),
 	/* general l4 interface ck, multi-parent functional clk */
 	CLK(NULL,	"gpt1_ick",	&gpt1_ick,	CK_243X),
 	CLK(NULL,	"gpt1_fck",	&gpt1_fck,	CK_243X),
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 403a4a1..655d1a9 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3224,6 +3224,7 @@ static struct omap_clk omap3xxx_clks[] = {
 	CLK(NULL,	"mcbsp_clks",	&mcbsp_clks,	CK_3XXX),
 	CLK(NULL,	"sys_clkout1",	&sys_clkout1,	CK_3XXX),
 	CLK(NULL,	"dpll1_ck",	&dpll1_ck,	CK_3XXX),
+	CLK(NULL,	"cpu_ck",	&dpll1_ck,	CK_3XXX),
 	CLK(NULL,	"dpll1_x2_ck",	&dpll1_x2_ck,	CK_3XXX),
 	CLK(NULL,	"dpll1_x2m2_ck", &dpll1_x2m2_ck, CK_3XXX),
 	CLK(NULL,	"dpll2_ck",	&dpll2_ck,	CK_34XX | CK_36XX),
diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c
index e8cb32f..4d5ede3 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -3058,6 +3058,7 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"dpll_iva_m4x2_ck",		&dpll_iva_m4x2_ck,	CK_443X),
 	CLK(NULL,	"dpll_iva_m5x2_ck",		&dpll_iva_m5x2_ck,	CK_443X),
 	CLK(NULL,	"dpll_mpu_ck",			&dpll_mpu_ck,	CK_443X),
+	CLK(NULL,	"cpu_ck",			&dpll_mpu_ck,	CK_443X),
 	CLK(NULL,	"dpll_mpu_m2_ck",		&dpll_mpu_m2_ck,	CK_443X),
 	CLK(NULL,	"per_hs_clk_div_ck",		&per_hs_clk_div_ck,	CK_443X),
 	CLK(NULL,	"per_hsd_byp_clk_mux_ck",	&per_hsd_byp_clk_mux_ck,	CK_443X),
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers.
  2011-02-25  6:10 [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Santosh Shilimkar
  2011-02-25  6:10 ` [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver Santosh Shilimkar
@ 2011-02-25  6:10 ` Santosh Shilimkar
  2011-02-25  7:17   ` Vishwanath Sripathy
  2011-02-25  8:19   ` DebBarma, Tarun Kanti
  2011-02-25  6:10 ` [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430 Santosh Shilimkar
  2011-03-10 22:28 ` [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Kevin Hilman
  3 siblings, 2 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2011-02-25  6:10 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, vishwanath.bs, Santosh Shilimkar

This patch is an attempt to cleanup the #ifdeferry in the
omap cpufreq drivers.

The split betwenn omap1 and omap2plus is logical because
	- omap1 doesn't support opp layer.
	- omap1 build is seperate from omap2plus.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Vishwanath BS <vishwanath.bs@ti.com>
---
 arch/arm/mach-omap1/Makefile                       |    3 +
 .../cpu-omap.c => mach-omap1/omap1-cpufreq.c}      |   70 +++++-----------
 arch/arm/mach-omap2/Makefile                       |    3 +
 .../cpu-omap.c => mach-omap2/omap2plus-cpufreq.c}  |   87 +++++++++-----------
 arch/arm/plat-omap/Makefile                        |    1 -
 5 files changed, 67 insertions(+), 97 deletions(-)
 copy arch/arm/{plat-omap/cpu-omap.c => mach-omap1/omap1-cpufreq.c} (74%)
 rename arch/arm/{plat-omap/cpu-omap.c => mach-omap2/omap2plus-cpufreq.c} (76%)

diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index 6ee1950..02b80f5 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -11,6 +11,9 @@ obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
 obj-$(CONFIG_OMAP_MPU_TIMER)	+= time.o
 obj-$(CONFIG_OMAP_32K_TIMER)	+= timer32k.o
 
+# CPUFREQ driver
+obj-$(CONFIG_CPU_FREQ) += omap1-cpufreq.o
+
 # Power Management
 obj-$(CONFIG_PM) += pm.o sleep.o pm_bus.o
 
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/mach-omap1/omap1-cpufreq.c
similarity index 74%
copy from arch/arm/plat-omap/cpu-omap.c
copy to arch/arm/mach-omap1/omap1-cpufreq.c
index 1c1b80b..64faf3f 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/mach-omap1/omap1-cpufreq.c
@@ -1,5 +1,5 @@
 /*
- *  linux/arch/arm/plat-omap/cpu-omap.c
+ *  OMAP1 cpufreq driver
  *
  *  CPU frequency scaling for OMAP
  *
@@ -27,31 +27,18 @@
 #include <linux/io.h>
 #include <linux/opp.h>
 
-#include <mach/hardware.h>
-#include <plat/clock.h>
 #include <asm/system.h>
 
-#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
+#include <plat/clock.h>
 #include <plat/omap-pm.h>
-#include <plat/common.h>
-#endif
+
+#include <mach/hardware.h>
 
 #define VERY_HI_RATE	900000000
 
 static struct cpufreq_frequency_table *freq_table;
-
-#ifdef CONFIG_ARCH_OMAP1
-#define MPU_CLK		"mpu"
-#elif defined(CONFIG_ARCH_OMAP3)
-#define MPU_CLK		"arm_fck"
-#else
-#define MPU_CLK		"virt_prcm_set"
-#endif
-
 static struct clk *mpu_clk;
 
-/* TODO: Add support for SDRAM timing changes */
-
 static int omap_verify_speed(struct cpufreq_policy *policy)
 {
 	if (freq_table)
@@ -85,13 +72,7 @@ static int omap_target(struct cpufreq_policy *policy,
 		       unsigned int target_freq,
 		       unsigned int relation)
 {
-#ifdef CONFIG_ARCH_OMAP1
 	struct cpufreq_freqs freqs;
-#endif
-#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
-	unsigned long freq;
-	struct device *mpu_dev = omap2_get_mpuss_device();
-#endif
 	int ret = 0;
 
 	/* Ensure desired rate is within allowed range.  Some govenors
@@ -101,25 +82,22 @@ static int omap_target(struct cpufreq_policy *policy,
 	if (target_freq > policy->max)
 		target_freq = policy->max;
 
-#ifdef CONFIG_ARCH_OMAP1
 	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);
+
 #ifdef CONFIG_CPU_FREQ_DEBUG
-	printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
-	       freqs.old, freqs.new);
+	pr_info("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);
-#elif defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
-	freq = target_freq * 1000;
-	if (opp_find_freq_ceil(mpu_dev, &freq))
-		omap_pm_cpu_set_freq(freq);
-#endif
+	if (!ret)
+		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+
 	return ret;
 }
 
@@ -127,7 +105,7 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
 {
 	int result = 0;
 
-	mpu_clk = clk_get(NULL, MPU_CLK);
+	mpu_clk = clk_get(NULL, "mpu");
 	if (IS_ERR(mpu_clk))
 		return PTR_ERR(mpu_clk);
 
@@ -136,13 +114,7 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
 
 	policy->cur = policy->min = policy->max = omap_getspeed(0);
 
-	if (!cpu_is_omap34xx()) {
-		clk_init_cpufreq_table(&freq_table);
-	} else {
-		struct device *mpu_dev = omap2_get_mpuss_device();
-
-		opp_init_cpufreq_table(mpu_dev, &freq_table);
-	}
+	clk_init_cpufreq_table(&freq_table);
 
 	if (freq_table) {
 		result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
@@ -184,7 +156,7 @@ static struct cpufreq_driver omap_driver = {
 	.get		= omap_getspeed,
 	.init		= omap_cpu_init,
 	.exit		= omap_cpu_exit,
-	.name		= "omap",
+	.name		= "omap1",
 	.attr		= omap_cpufreq_attr,
 };
 
@@ -193,12 +165,12 @@ static int __init omap_cpufreq_init(void)
 	return cpufreq_register_driver(&omap_driver);
 }
 
-late_initcall(omap_cpufreq_init);
-
-/*
- * if ever we want to remove this, upon cleanup call:
- *
- * cpufreq_unregister_driver()
- * cpufreq_frequency_table_put_attr()
- */
+static void __exit omap_cpufreq_exit(void)
+{
+	cpufreq_unregister_driver(&omap_driver);
+}
 
+MODULE_DESCRIPTION("cpufreq driver for OMAP1 SOCs");
+MODULE_LICENSE("GPL");
+module_init(omap_cpufreq_init);
+module_exit(omap_cpufreq_exit);
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 1c0c2b0..b1187f9 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -56,6 +56,9 @@ obj-$(CONFIG_ARCH_OMAP3)		+= opp3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP4)		+= opp4xxx_data.o
 endif
 
+# CPUFREQ driver
+obj-$(CONFIG_CPU_FREQ)			+= omap2plus-cpufreq.o
+
 # Power Management
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c
similarity index 76%
rename from arch/arm/plat-omap/cpu-omap.c
rename to arch/arm/mach-omap2/omap2plus-cpufreq.c
index 1c1b80b..48da867 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
@@ -1,5 +1,5 @@
 /*
- *  linux/arch/arm/plat-omap/cpu-omap.c
+ *  OMAP2PLUS cpufreq driver
  *
  *  CPU frequency scaling for OMAP
  *
@@ -27,31 +27,20 @@
 #include <linux/io.h>
 #include <linux/opp.h>
 
-#include <mach/hardware.h>
-#include <plat/clock.h>
 #include <asm/system.h>
+#include <asm/smp_plat.h>
 
-#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
+#include <plat/clock.h>
 #include <plat/omap-pm.h>
 #include <plat/common.h>
-#endif
+
+#include <mach/hardware.h>
 
 #define VERY_HI_RATE	900000000
 
 static struct cpufreq_frequency_table *freq_table;
-
-#ifdef CONFIG_ARCH_OMAP1
-#define MPU_CLK		"mpu"
-#elif defined(CONFIG_ARCH_OMAP3)
-#define MPU_CLK		"arm_fck"
-#else
-#define MPU_CLK		"virt_prcm_set"
-#endif
-
 static struct clk *mpu_clk;
 
-/* TODO: Add support for SDRAM timing changes */
-
 static int omap_verify_speed(struct cpufreq_policy *policy)
 {
 	if (freq_table)
@@ -85,14 +74,8 @@ static int omap_target(struct cpufreq_policy *policy,
 		       unsigned int target_freq,
 		       unsigned int relation)
 {
-#ifdef CONFIG_ARCH_OMAP1
-	struct cpufreq_freqs freqs;
-#endif
-#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
-	unsigned long freq;
-	struct device *mpu_dev = omap2_get_mpuss_device();
-#endif
 	int ret = 0;
+	struct cpufreq_freqs freqs;
 
 	/* Ensure desired rate is within allowed range.  Some govenors
 	 * (ondemand) will just pass target_freq=0 to get the minimum. */
@@ -101,33 +84,44 @@ static int omap_target(struct cpufreq_policy *policy,
 	if (target_freq > policy->max)
 		target_freq = policy->max;
 
-#ifdef CONFIG_ARCH_OMAP1
 	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);
+
 #ifdef CONFIG_CPU_FREQ_DEBUG
-	printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
-	       freqs.old, freqs.new);
+	pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old, freqs.new);
 #endif
+
 	ret = clk_set_rate(mpu_clk, freqs.new * 1000);
+	if (ret)
+		return ret;
+
+	/*
+	 * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
+	 * won't get updated when UP machine cpufreq build with
+	 * CONFIG_SMP enabled. Below code is added only to manage that
+	 * scenario
+	 */
+	if (!is_smp())
+		loops_per_jiffy =
+			 cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new);
+
 	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
-#elif defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
-	freq = target_freq * 1000;
-	if (opp_find_freq_ceil(mpu_dev, &freq))
-		omap_pm_cpu_set_freq(freq);
-#endif
+
 	return ret;
 }
 
 static int __init omap_cpu_init(struct cpufreq_policy *policy)
 {
 	int result = 0;
+	struct device *mpu_dev;
 
-	mpu_clk = clk_get(NULL, MPU_CLK);
+	mpu_clk = clk_get(NULL, "cpu_ck");
 	if (IS_ERR(mpu_clk))
 		return PTR_ERR(mpu_clk);
 
@@ -136,13 +130,12 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
 
 	policy->cur = policy->min = policy->max = omap_getspeed(0);
 
-	if (!cpu_is_omap34xx()) {
-		clk_init_cpufreq_table(&freq_table);
-	} else {
-		struct device *mpu_dev = omap2_get_mpuss_device();
-
-		opp_init_cpufreq_table(mpu_dev, &freq_table);
+	mpu_dev = omap2_get_mpuss_device();
+	if (!mpu_dev) {
+		pr_warning("%s: unable to get the mpu device\n", __func__);
+		return -EINVAL;
 	}
+	opp_init_cpufreq_table(mpu_dev, &freq_table);
 
 	if (freq_table) {
 		result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
@@ -184,7 +177,7 @@ static struct cpufreq_driver omap_driver = {
 	.get		= omap_getspeed,
 	.init		= omap_cpu_init,
 	.exit		= omap_cpu_exit,
-	.name		= "omap",
+	.name		= "omap2plus",
 	.attr		= omap_cpufreq_attr,
 };
 
@@ -193,12 +186,12 @@ static int __init omap_cpufreq_init(void)
 	return cpufreq_register_driver(&omap_driver);
 }
 
-late_initcall(omap_cpufreq_init);
-
-/*
- * if ever we want to remove this, upon cleanup call:
- *
- * cpufreq_unregister_driver()
- * cpufreq_frequency_table_put_attr()
- */
+static void __exit omap_cpufreq_exit(void)
+{
+	cpufreq_unregister_driver(&omap_driver);
+}
 
+MODULE_DESCRIPTION("cpufreq driver for OMAP2PLUS SOCs");
+MODULE_LICENSE("GPL");
+module_init(omap_cpufreq_init);
+module_exit(omap_cpufreq_exit);
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index a4a1285..ec7862e 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
 obj-$(CONFIG_OMAP_IOMMU) += iommu.o iovmm.o
 obj-$(CONFIG_OMAP_IOMMU_DEBUG) += iommu-debug.o
 
-obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
 obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
 obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o
 obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430
  2011-02-25  6:10 [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Santosh Shilimkar
  2011-02-25  6:10 ` [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver Santosh Shilimkar
  2011-02-25  6:10 ` [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers Santosh Shilimkar
@ 2011-02-25  6:10 ` Santosh Shilimkar
  2011-02-25  8:10   ` DebBarma, Tarun Kanti
  2011-03-10 22:27   ` Kevin Hilman
  2011-03-10 22:28 ` [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Kevin Hilman
  3 siblings, 2 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2011-02-25  6:10 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, vishwanath.bs, Santosh Shilimkar

On OMAP SMP configuartion, both processors share the voltage
and clock. So both CPUs needs to be scaled together and hence
needs software co-ordination.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
cc: Vishwanath BS <vishwanath.bs@ti.com>
---
 arch/arm/mach-omap2/omap2plus-cpufreq.c |   71 ++++++++++++++++++++++++++----
 1 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c
index 48da867..8c903c1 100644
--- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
+++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
@@ -26,9 +26,11 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/opp.h>
+#include <linux/cpu.h>
 
 #include <asm/system.h>
 #include <asm/smp_plat.h>
+#include <asm/cpu.h>
 
 #include <plat/clock.h>
 #include <plat/omap-pm.h>
@@ -63,7 +65,7 @@ static unsigned int omap_getspeed(unsigned int cpu)
 {
 	unsigned long rate;
 
-	if (cpu)
+	if (cpu >= NR_CPUS)
 		return 0;
 
 	rate = clk_get_rate(mpu_clk) / 1000;
@@ -74,9 +76,13 @@ static int omap_target(struct cpufreq_policy *policy,
 		       unsigned int target_freq,
 		       unsigned int relation)
 {
-	int ret = 0;
+	int i, ret = 0;
 	struct cpufreq_freqs freqs;
 
+	/* Wait untill all CPU's are initialized */
+	if (is_smp() && (num_online_cpus() < NR_CPUS))
+		return ret;
+
 	/* Ensure desired rate is within allowed range.  Some govenors
 	 * (ondemand) will just pass target_freq=0 to get the minimum. */
 	if (target_freq < policy->min)
@@ -84,15 +90,25 @@ static int omap_target(struct cpufreq_policy *policy,
 	if (target_freq > policy->max)
 		target_freq = policy->max;
 
-	freqs.old = omap_getspeed(0);
+	freqs.old = omap_getspeed(policy->cpu);
 	freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
-	freqs.cpu = 0;
+	freqs.cpu = policy->cpu;
 
 	if (freqs.old == freqs.new)
 		return ret;
 
-	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+	if (!is_smp()) {
+		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+		goto set_freq;
+	}
+
+	/* notifiers */
+	for_each_cpu(i, policy->cpus) {
+		freqs.cpu = i;
+		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+	}
 
+set_freq:
 #ifdef CONFIG_CPU_FREQ_DEBUG
 	pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old, freqs.new);
 #endif
@@ -100,6 +116,7 @@ static int omap_target(struct cpufreq_policy *policy,
 	ret = clk_set_rate(mpu_clk, freqs.new * 1000);
 	if (ret)
 		return ret;
+	freqs.new = omap_getspeed(policy->cpu);
 
 	/*
 	 * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
@@ -107,12 +124,32 @@ static int omap_target(struct cpufreq_policy *policy,
 	 * CONFIG_SMP enabled. Below code is added only to manage that
 	 * scenario
 	 */
-	if (!is_smp())
+	if (!is_smp()) {
 		loops_per_jiffy =
 			 cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new);
+		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+		goto skip_lpj;
+	}
 
-	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+#ifdef CONFIG_SMP
+	/*
+	 * Note that loops_per_jiffy is not updated on SMP systems in
+	 * cpufreq driver. So, update the per-CPU loops_per_jiffy value
+	 * on frequency transition. We need to update all dependent cpus
+	 */
+	for_each_cpu(i, policy->cpus)
+		per_cpu(cpu_data, i).loops_per_jiffy =
+			cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
+					freqs.old, freqs.new);
+#endif
+
+	/* notifiers */
+	for_each_cpu(i, policy->cpus) {
+		freqs.cpu = i;
+		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+	}
 
+skip_lpj:
 	return ret;
 }
 
@@ -120,15 +157,16 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
 {
 	int result = 0;
 	struct device *mpu_dev;
+	static cpumask_var_t cpumask;
 
 	mpu_clk = clk_get(NULL, "cpu_ck");
 	if (IS_ERR(mpu_clk))
 		return PTR_ERR(mpu_clk);
 
-	if (policy->cpu != 0)
+	if (policy->cpu >= NR_CPUS)
 		return -EINVAL;
 
-	policy->cur = policy->min = policy->max = omap_getspeed(0);
+	policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu);
 
 	mpu_dev = omap2_get_mpuss_device();
 	if (!mpu_dev) {
@@ -150,7 +188,20 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
 
 	policy->min = policy->cpuinfo.min_freq;
 	policy->max = policy->cpuinfo.max_freq;
-	policy->cur = omap_getspeed(0);
+	policy->cur = omap_getspeed(policy->cpu);
+
+	/*
+	 * On OMAP SMP configuartion, both processors share the voltage
+	 * and clock. So both CPUs needs to be scaled together and hence
+	 * needs software co-ordination. Use cpufreq affected_cpus
+	 * interface to handle this scenario. Additional is_smp() check
+	 * is to keep SMP_ON_UP builf working.
+	 */
+	if (is_smp()) {
+		policy->shared_type = CPUFREQ_SHARED_TYPE_ANY;
+		cpumask_or(cpumask, cpumask_of(policy->cpu), cpumask);
+		cpumask_copy(policy->cpus, cpumask);
+	}
 
 	/* FIXME: what's the actual transition time? */
 	policy->cpuinfo.transition_latency = 300 * 1000;
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* RE: [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers.
  2011-02-25  6:10 ` [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers Santosh Shilimkar
@ 2011-02-25  7:17   ` Vishwanath Sripathy
  2011-02-25  7:22     ` Santosh Shilimkar
  2011-02-25  8:19   ` DebBarma, Tarun Kanti
  1 sibling, 1 reply; 13+ messages in thread
From: Vishwanath Sripathy @ 2011-02-25  7:17 UTC (permalink / raw)
  To: Santosh Shilimkar, linux-omap; +Cc: Kevin Hilman

> -----Original Message-----
> From: Santosh Shilimkar [mailto:santosh.shilimkar@ti.com]
> Sent: Friday, February 25, 2011 11:41 AM
> To: linux-omap@vger.kernel.org
> Cc: khilman@ti.com; vishwanath.bs@ti.com; Santosh Shilimkar
> Subject: [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus
> cpufreq drivers.
>
> This patch is an attempt to cleanup the #ifdeferry in the
> omap cpufreq drivers.
>
> The split betwenn omap1 and omap2plus is logical because
> 	- omap1 doesn't support opp layer.
> 	- omap1 build is seperate from omap2plus.
>
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Vishwanath BS <vishwanath.bs@ti.com>
> ---
>  arch/arm/mach-omap1/Makefile                       |    3 +
>  .../cpu-omap.c => mach-omap1/omap1-cpufreq.c}      |   70 +++++---
> --------
>  arch/arm/mach-omap2/Makefile                       |    3 +
>  .../cpu-omap.c => mach-omap2/omap2plus-cpufreq.c}  |   87
> +++++++++-----------
>  arch/arm/plat-omap/Makefile                        |    1 -
>  5 files changed, 67 insertions(+), 97 deletions(-)
>  copy arch/arm/{plat-omap/cpu-omap.c => mach-omap1/omap1-
> cpufreq.c} (74%)
>  rename arch/arm/{plat-omap/cpu-omap.c => mach-omap2/omap2plus-
> cpufreq.c} (76%)
>
> diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-
> omap1/Makefile
> index 6ee1950..02b80f5 100644
> --- a/arch/arm/mach-omap1/Makefile
> +++ b/arch/arm/mach-omap1/Makefile
> @@ -11,6 +11,9 @@ obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
>  obj-$(CONFIG_OMAP_MPU_TIMER)	+= time.o
>  obj-$(CONFIG_OMAP_32K_TIMER)	+= timer32k.o
>
> +# CPUFREQ driver
> +obj-$(CONFIG_CPU_FREQ) += omap1-cpufreq.o
> +
>  # Power Management
>  obj-$(CONFIG_PM) += pm.o sleep.o pm_bus.o
>
> diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/mach-
> omap1/omap1-cpufreq.c
> similarity index 74%
> copy from arch/arm/plat-omap/cpu-omap.c
> copy to arch/arm/mach-omap1/omap1-cpufreq.c
> index 1c1b80b..64faf3f 100644
> --- a/arch/arm/plat-omap/cpu-omap.c
> +++ b/arch/arm/mach-omap1/omap1-cpufreq.c
> @@ -1,5 +1,5 @@
>  /*
> - *  linux/arch/arm/plat-omap/cpu-omap.c
> + *  OMAP1 cpufreq driver
>   *
>   *  CPU frequency scaling for OMAP
>   *
> @@ -27,31 +27,18 @@
>  #include <linux/io.h>
>  #include <linux/opp.h>
>
> -#include <mach/hardware.h>
> -#include <plat/clock.h>
>  #include <asm/system.h>
>
> -#if defined(CONFIG_ARCH_OMAP3) &&
> !defined(CONFIG_OMAP_PM_NONE)
> +#include <plat/clock.h>
>  #include <plat/omap-pm.h>
> -#include <plat/common.h>
> -#endif
> +
> +#include <mach/hardware.h>
>
>  #define VERY_HI_RATE	900000000
>
>  static struct cpufreq_frequency_table *freq_table;
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -#define MPU_CLK		"mpu"
> -#elif defined(CONFIG_ARCH_OMAP3)
> -#define MPU_CLK		"arm_fck"
> -#else
> -#define MPU_CLK		"virt_prcm_set"
> -#endif
> -
>  static struct clk *mpu_clk;
>
> -/* TODO: Add support for SDRAM timing changes */
> -
>  static int omap_verify_speed(struct cpufreq_policy *policy)
>  {
>  	if (freq_table)
> @@ -85,13 +72,7 @@ static int omap_target(struct cpufreq_policy
> *policy,
>  		       unsigned int target_freq,
>  		       unsigned int relation)
>  {
> -#ifdef CONFIG_ARCH_OMAP1
>  	struct cpufreq_freqs freqs;
> -#endif
> -#if defined(CONFIG_ARCH_OMAP3) &&
> !defined(CONFIG_OMAP_PM_NONE)
> -	unsigned long freq;
> -	struct device *mpu_dev = omap2_get_mpuss_device();
> -#endif
>  	int ret = 0;
>
>  	/* Ensure desired rate is within allowed range.  Some govenors
> @@ -101,25 +82,22 @@ static int omap_target(struct cpufreq_policy
> *policy,
>  	if (target_freq > policy->max)
>  		target_freq = policy->max;
>
> -#ifdef CONFIG_ARCH_OMAP1
>  	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);
> +
>  #ifdef CONFIG_CPU_FREQ_DEBUG
> -	printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
> -	       freqs.old, freqs.new);
> +	pr_info("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);
> -#elif defined(CONFIG_ARCH_OMAP3) &&
> !defined(CONFIG_OMAP_PM_NONE)
> -	freq = target_freq * 1000;
> -	if (opp_find_freq_ceil(mpu_dev, &freq))
> -		omap_pm_cpu_set_freq(freq);
> -#endif
> +	if (!ret)
> +		cpufreq_notify_transition(&freqs,
> CPUFREQ_POSTCHANGE);
> +
>  	return ret;
>  }
>
> @@ -127,7 +105,7 @@ static int __init omap_cpu_init(struct
> cpufreq_policy *policy)
>  {
>  	int result = 0;
>
> -	mpu_clk = clk_get(NULL, MPU_CLK);
> +	mpu_clk = clk_get(NULL, "mpu");
>  	if (IS_ERR(mpu_clk))
>  		return PTR_ERR(mpu_clk);
>
> @@ -136,13 +114,7 @@ static int __init omap_cpu_init(struct
> cpufreq_policy *policy)
>
>  	policy->cur = policy->min = policy->max = omap_getspeed(0);
>
> -	if (!cpu_is_omap34xx()) {
> -		clk_init_cpufreq_table(&freq_table);
> -	} else {
> -		struct device *mpu_dev = omap2_get_mpuss_device();
> -
> -		opp_init_cpufreq_table(mpu_dev, &freq_table);
> -	}
> +	clk_init_cpufreq_table(&freq_table);
>
>  	if (freq_table) {
>  		result = cpufreq_frequency_table_cpuinfo(policy,
> freq_table);
> @@ -184,7 +156,7 @@ static struct cpufreq_driver omap_driver = {
>  	.get		= omap_getspeed,
>  	.init		= omap_cpu_init,
>  	.exit		= omap_cpu_exit,
> -	.name		= "omap",
> +	.name		= "omap1",
>  	.attr		= omap_cpufreq_attr,
>  };
>
> @@ -193,12 +165,12 @@ static int __init omap_cpufreq_init(void)
>  	return cpufreq_register_driver(&omap_driver);
>  }
>
> -late_initcall(omap_cpufreq_init);
> -
> -/*
> - * if ever we want to remove this, upon cleanup call:
> - *
> - * cpufreq_unregister_driver()
> - * cpufreq_frequency_table_put_attr()
> - */
> +static void __exit omap_cpufreq_exit(void)
> +{
> +	cpufreq_unregister_driver(&omap_driver);
> +}
>
> +MODULE_DESCRIPTION("cpufreq driver for OMAP1 SOCs");
> +MODULE_LICENSE("GPL");
> +module_init(omap_cpufreq_init);
> +module_exit(omap_cpufreq_exit);
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-
> omap2/Makefile
> index 1c0c2b0..b1187f9 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -56,6 +56,9 @@ obj-$(CONFIG_ARCH_OMAP3)		+=
> opp3xxx_data.o
>  obj-$(CONFIG_ARCH_OMAP4)		+= opp4xxx_data.o
>  endif
>
> +# CPUFREQ driver
> +obj-$(CONFIG_CPU_FREQ)			+= omap2plus-cpufreq.o
> +
>  # Power Management
>  ifeq ($(CONFIG_PM),y)
>  obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
> diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/mach-
> omap2/omap2plus-cpufreq.c
> similarity index 76%
> rename from arch/arm/plat-omap/cpu-omap.c
> rename to arch/arm/mach-omap2/omap2plus-cpufreq.c
> index 1c1b80b..48da867 100644
> --- a/arch/arm/plat-omap/cpu-omap.c
> +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
> @@ -1,5 +1,5 @@
>  /*
> - *  linux/arch/arm/plat-omap/cpu-omap.c
> + *  OMAP2PLUS cpufreq driver
>   *
>   *  CPU frequency scaling for OMAP
>   *
> @@ -27,31 +27,20 @@
>  #include <linux/io.h>
>  #include <linux/opp.h>
>
> -#include <mach/hardware.h>
> -#include <plat/clock.h>
>  #include <asm/system.h>
> +#include <asm/smp_plat.h>
>
> -#if defined(CONFIG_ARCH_OMAP3) &&
> !defined(CONFIG_OMAP_PM_NONE)
> +#include <plat/clock.h>
>  #include <plat/omap-pm.h>
>  #include <plat/common.h>
> -#endif
> +
> +#include <mach/hardware.h>
>
>  #define VERY_HI_RATE	900000000
>
>  static struct cpufreq_frequency_table *freq_table;
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -#define MPU_CLK		"mpu"
> -#elif defined(CONFIG_ARCH_OMAP3)
> -#define MPU_CLK		"arm_fck"
> -#else
> -#define MPU_CLK		"virt_prcm_set"
> -#endif
> -
>  static struct clk *mpu_clk;
>
> -/* TODO: Add support for SDRAM timing changes */
> -
>  static int omap_verify_speed(struct cpufreq_policy *policy)
>  {
>  	if (freq_table)
> @@ -85,14 +74,8 @@ static int omap_target(struct cpufreq_policy
> *policy,
>  		       unsigned int target_freq,
>  		       unsigned int relation)
>  {
> -#ifdef CONFIG_ARCH_OMAP1
> -	struct cpufreq_freqs freqs;
> -#endif
> -#if defined(CONFIG_ARCH_OMAP3) &&
> !defined(CONFIG_OMAP_PM_NONE)
> -	unsigned long freq;
> -	struct device *mpu_dev = omap2_get_mpuss_device();
> -#endif
>  	int ret = 0;
> +	struct cpufreq_freqs freqs;
>
>  	/* Ensure desired rate is within allowed range.  Some govenors
>  	 * (ondemand) will just pass target_freq=0 to get the minimum.
> */
> @@ -101,33 +84,44 @@ static int omap_target(struct cpufreq_policy
> *policy,
>  	if (target_freq > policy->max)
>  		target_freq = policy->max;
>
> -#ifdef CONFIG_ARCH_OMAP1
>  	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);
> +
>  #ifdef CONFIG_CPU_FREQ_DEBUG
> -	printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
> -	       freqs.old, freqs.new);
> +	pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old,
> freqs.new);
>  #endif
> +
>  	ret = clk_set_rate(mpu_clk, freqs.new * 1000);
> +	if (ret)
> +		return ret;
Do you want to return here w/o calling post notifiers and readjusting the
jiffies? Cpufreq updates lpj as part of PRECHANGE notifier when frequency
is scaled up. So in that case returning here will end of having wrong lpj
I suppose.

Vishwa
> +
> +	/*
> +	 * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
> +	 * won't get updated when UP machine cpufreq build with
> +	 * CONFIG_SMP enabled. Below code is added only to manage
> that
> +	 * scenario
> +	 */
> +	if (!is_smp())
> +		loops_per_jiffy =
> +			 cpufreq_scale(loops_per_jiffy, freqs.old,
> freqs.new);
> +
>  	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
> -#elif defined(CONFIG_ARCH_OMAP3) &&
> !defined(CONFIG_OMAP_PM_NONE)
> -	freq = target_freq * 1000;
> -	if (opp_find_freq_ceil(mpu_dev, &freq))
> -		omap_pm_cpu_set_freq(freq);
> -#endif
> +
>  	return ret;
>  }
>
>  static int __init omap_cpu_init(struct cpufreq_policy *policy)
>  {
>  	int result = 0;
> +	struct device *mpu_dev;
>
> -	mpu_clk = clk_get(NULL, MPU_CLK);
> +	mpu_clk = clk_get(NULL, "cpu_ck");
>  	if (IS_ERR(mpu_clk))
>  		return PTR_ERR(mpu_clk);
>
> @@ -136,13 +130,12 @@ static int __init omap_cpu_init(struct
> cpufreq_policy *policy)
>
>  	policy->cur = policy->min = policy->max = omap_getspeed(0);
>
> -	if (!cpu_is_omap34xx()) {
> -		clk_init_cpufreq_table(&freq_table);
> -	} else {
> -		struct device *mpu_dev = omap2_get_mpuss_device();
> -
> -		opp_init_cpufreq_table(mpu_dev, &freq_table);
> +	mpu_dev = omap2_get_mpuss_device();
> +	if (!mpu_dev) {
> +		pr_warning("%s: unable to get the mpu device\n",
> __func__);
> +		return -EINVAL;
>  	}
> +	opp_init_cpufreq_table(mpu_dev, &freq_table);
>
>  	if (freq_table) {
>  		result = cpufreq_frequency_table_cpuinfo(policy,
> freq_table);
> @@ -184,7 +177,7 @@ static struct cpufreq_driver omap_driver = {
>  	.get		= omap_getspeed,
>  	.init		= omap_cpu_init,
>  	.exit		= omap_cpu_exit,
> -	.name		= "omap",
> +	.name		= "omap2plus",
>  	.attr		= omap_cpufreq_attr,
>  };
>
> @@ -193,12 +186,12 @@ static int __init omap_cpufreq_init(void)
>  	return cpufreq_register_driver(&omap_driver);
>  }
>
> -late_initcall(omap_cpufreq_init);
> -
> -/*
> - * if ever we want to remove this, upon cleanup call:
> - *
> - * cpufreq_unregister_driver()
> - * cpufreq_frequency_table_put_attr()
> - */
> +static void __exit omap_cpufreq_exit(void)
> +{
> +	cpufreq_unregister_driver(&omap_driver);
> +}
>
> +MODULE_DESCRIPTION("cpufreq driver for OMAP2PLUS SOCs");
> +MODULE_LICENSE("GPL");
> +module_init(omap_cpufreq_init);
> +module_exit(omap_cpufreq_exit);
> diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
> index a4a1285..ec7862e 100644
> --- a/arch/arm/plat-omap/Makefile
> +++ b/arch/arm/plat-omap/Makefile
> @@ -21,7 +21,6 @@ obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
>  obj-$(CONFIG_OMAP_IOMMU) += iommu.o iovmm.o
>  obj-$(CONFIG_OMAP_IOMMU_DEBUG) += iommu-debug.o
>
> -obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
>  obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
>  obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o
>  obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o
> --
> 1.6.0.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers.
  2011-02-25  7:17   ` Vishwanath Sripathy
@ 2011-02-25  7:22     ` Santosh Shilimkar
  0 siblings, 0 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2011-02-25  7:22 UTC (permalink / raw)
  To: Vishwanath Sripathy, linux-omap; +Cc: Kevin Hilman

> -----Original Message-----
> From: Vishwanath Sripathy [mailto:vishwanath.bs@ti.com]
> Sent: Friday, February 25, 2011 12:47 PM
> To: Santosh Shilimkar; linux-omap@vger.kernel.org
> Cc: Kevin Hilman
> Subject: RE: [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus
> cpufreq drivers.
>
[....]

> > @@ -101,33 +84,44 @@ static int omap_target(struct cpufreq_policy
> > *policy,
> >  	if (target_freq > policy->max)
> >  		target_freq = policy->max;
> >
> > -#ifdef CONFIG_ARCH_OMAP1
> >  	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);
> > +
> >  #ifdef CONFIG_CPU_FREQ_DEBUG
> > -	printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
> > -	       freqs.old, freqs.new);
> > +	pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old,
> > freqs.new);
> >  #endif
> > +
> >  	ret = clk_set_rate(mpu_clk, freqs.new * 1000);
> > +	if (ret)
> > +		return ret;
> Do you want to return here w/o calling post notifiers and
> readjusting the
> jiffies? Cpufreq updates lpj as part of PRECHANGE notifier when
> frequency
> is scaled up. So in that case returning here will end of having
> wrong lpj I suppose.
You are right. A notifier with old freq is needed here.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430
  2011-02-25  6:10 ` [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430 Santosh Shilimkar
@ 2011-02-25  8:10   ` DebBarma, Tarun Kanti
  2011-03-10 22:27   ` Kevin Hilman
  1 sibling, 0 replies; 13+ messages in thread
From: DebBarma, Tarun Kanti @ 2011-02-25  8:10 UTC (permalink / raw)
  To: Shilimkar, Santosh, linux-omap@vger.kernel.org
  Cc: Hilman, Kevin, Sripathy, Vishwanath

> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> owner@vger.kernel.org] On Behalf Of Shilimkar, Santosh
> Sent: Friday, February 25, 2011 11:41 AM
> To: linux-omap@vger.kernel.org
> Cc: Hilman, Kevin; Sripathy, Vishwanath; Shilimkar, Santosh
> Subject: [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430
> 
> On OMAP SMP configuartion, both processors share the voltage
> and clock. So both CPUs needs to be scaled together and hence
> needs software co-ordination.
> 
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>
> cc: Vishwanath BS <vishwanath.bs@ti.com>
> ---
>  arch/arm/mach-omap2/omap2plus-cpufreq.c |   71
> ++++++++++++++++++++++++++----
>  1 files changed, 61 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-
> omap2/omap2plus-cpufreq.c
> index 48da867..8c903c1 100644
> --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
> +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
> @@ -26,9 +26,11 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/opp.h>
> +#include <linux/cpu.h>
> 
>  #include <asm/system.h>
>  #include <asm/smp_plat.h>
> +#include <asm/cpu.h>
> 
>  #include <plat/clock.h>
>  #include <plat/omap-pm.h>
> @@ -63,7 +65,7 @@ static unsigned int omap_getspeed(unsigned int cpu)
>  {
>  	unsigned long rate;
> 
> -	if (cpu)
> +	if (cpu >= NR_CPUS)
>  		return 0;
> 
>  	rate = clk_get_rate(mpu_clk) / 1000;
> @@ -74,9 +76,13 @@ static int omap_target(struct cpufreq_policy *policy,
>  		       unsigned int target_freq,
>  		       unsigned int relation)
>  {
> -	int ret = 0;
> +	int i, ret = 0;
>  	struct cpufreq_freqs freqs;
> 
> +	/* Wait untill all CPU's are initialized */
Typo: until

> +	if (is_smp() && (num_online_cpus() < NR_CPUS))
> +		return ret;
Does it make sense to add pr_info() or pr_warning() before returning?
> +
>  	/* Ensure desired rate is within allowed range.  Some govenors
>  	 * (ondemand) will just pass target_freq=0 to get the minimum. */
>  	if (target_freq < policy->min)
> @@ -84,15 +90,25 @@ static int omap_target(struct cpufreq_policy *policy,
>  	if (target_freq > policy->max)
>  		target_freq = policy->max;
> 
> -	freqs.old = omap_getspeed(0);
> +	freqs.old = omap_getspeed(policy->cpu);
>  	freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
> -	freqs.cpu = 0;
> +	freqs.cpu = policy->cpu;
> 
>  	if (freqs.old == freqs.new)
>  		return ret;
> 
> -	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
> +	if (!is_smp()) {
> +		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
> +		goto set_freq;
> +	}
> +
> +	/* notifiers */
> +	for_each_cpu(i, policy->cpus) {
> +		freqs.cpu = i;
> +		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
> +	}
> 
> +set_freq:
>  #ifdef CONFIG_CPU_FREQ_DEBUG
>  	pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old,
> freqs.new);
>  #endif
> @@ -100,6 +116,7 @@ static int omap_target(struct cpufreq_policy *policy,
>  	ret = clk_set_rate(mpu_clk, freqs.new * 1000);
>  	if (ret)
>  		return ret;
> +	freqs.new = omap_getspeed(policy->cpu);
> 
>  	/*
>  	 * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
> @@ -107,12 +124,32 @@ static int omap_target(struct cpufreq_policy
> *policy,
>  	 * CONFIG_SMP enabled. Below code is added only to manage that
>  	 * scenario
>  	 */
> -	if (!is_smp())
> +	if (!is_smp()) {
>  		loops_per_jiffy =
>  			 cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new);
> +		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
> +		goto skip_lpj;
> +	}
> 
> -	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
> +#ifdef CONFIG_SMP
> +	/*
> +	 * Note that loops_per_jiffy is not updated on SMP systems in
> +	 * cpufreq driver. So, update the per-CPU loops_per_jiffy value
> +	 * on frequency transition. We need to update all dependent cpus
CPUs.
> +	 */
> +	for_each_cpu(i, policy->cpus)
> +		per_cpu(cpu_data, i).loops_per_jiffy =
> +			cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
> +					freqs.old, freqs.new);
> +#endif
> +
> +	/* notifiers */
> +	for_each_cpu(i, policy->cpus) {
> +		freqs.cpu = i;
> +		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
> +	}
> 
> +skip_lpj:
>  	return ret;
>  }
> 
> @@ -120,15 +157,16 @@ static int __init omap_cpu_init(struct
> cpufreq_policy *policy)
>  {
>  	int result = 0;
>  	struct device *mpu_dev;
> +	static cpumask_var_t cpumask;
> 
>  	mpu_clk = clk_get(NULL, "cpu_ck");
>  	if (IS_ERR(mpu_clk))
>  		return PTR_ERR(mpu_clk);
> 
> -	if (policy->cpu != 0)
> +	if (policy->cpu >= NR_CPUS)
>  		return -EINVAL;
> 
> -	policy->cur = policy->min = policy->max = omap_getspeed(0);
> +	policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu);
> 
>  	mpu_dev = omap2_get_mpuss_device();
>  	if (!mpu_dev) {
> @@ -150,7 +188,20 @@ static int __init omap_cpu_init(struct cpufreq_policy
> *policy)
> 
>  	policy->min = policy->cpuinfo.min_freq;
>  	policy->max = policy->cpuinfo.max_freq;
> -	policy->cur = omap_getspeed(0);
> +	policy->cur = omap_getspeed(policy->cpu);
> +
> +	/*
> +	 * On OMAP SMP configuartion, both processors share the voltage
> +	 * and clock. So both CPUs needs to be scaled together and hence
> +	 * needs software co-ordination. Use cpufreq affected_cpus
> +	 * interface to handle this scenario. Additional is_smp() check
> +	 * is to keep SMP_ON_UP builf working.
Typo: build
> +	 */
> +	if (is_smp()) {
> +		policy->shared_type = CPUFREQ_SHARED_TYPE_ANY;
> +		cpumask_or(cpumask, cpumask_of(policy->cpu), cpumask);
> +		cpumask_copy(policy->cpus, cpumask);
> +	}
> 
>  	/* FIXME: what's the actual transition time? */
>  	policy->cpuinfo.transition_latency = 300 * 1000;
> --
> 1.6.0.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers.
  2011-02-25  6:10 ` [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers Santosh Shilimkar
  2011-02-25  7:17   ` Vishwanath Sripathy
@ 2011-02-25  8:19   ` DebBarma, Tarun Kanti
  1 sibling, 0 replies; 13+ messages in thread
From: DebBarma, Tarun Kanti @ 2011-02-25  8:19 UTC (permalink / raw)
  To: Shilimkar, Santosh, linux-omap@vger.kernel.org
  Cc: Hilman, Kevin, Sripathy, Vishwanath

> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> owner@vger.kernel.org] On Behalf Of Shilimkar, Santosh
> Sent: Friday, February 25, 2011 11:41 AM
> To: linux-omap@vger.kernel.org
> Cc: Hilman, Kevin; Sripathy, Vishwanath; Shilimkar, Santosh
> Subject: [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq
> drivers.
> 
> This patch is an attempt to cleanup the #ifdeferry in the
> omap cpufreq drivers.
> 
> The split betwenn omap1 and omap2plus is logical because
Typo: between

> 	- omap1 doesn't support opp layer.
> 	- omap1 build is seperate from omap2plus.
> 
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Vishwanath BS <vishwanath.bs@ti.com>
> ---
>  arch/arm/mach-omap1/Makefile                       |    3 +
>  .../cpu-omap.c => mach-omap1/omap1-cpufreq.c}      |   70 +++++----------
> -
>  arch/arm/mach-omap2/Makefile                       |    3 +
>  .../cpu-omap.c => mach-omap2/omap2plus-cpufreq.c}  |   87 +++++++++------
> -----
>  arch/arm/plat-omap/Makefile                        |    1 -
>  5 files changed, 67 insertions(+), 97 deletions(-)
>  copy arch/arm/{plat-omap/cpu-omap.c => mach-omap1/omap1-cpufreq.c} (74%)
>  rename arch/arm/{plat-omap/cpu-omap.c => mach-omap2/omap2plus-cpufreq.c}
> (76%)
> 
> diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
> index 6ee1950..02b80f5 100644
> --- a/arch/arm/mach-omap1/Makefile
> +++ b/arch/arm/mach-omap1/Makefile
> @@ -11,6 +11,9 @@ obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
>  obj-$(CONFIG_OMAP_MPU_TIMER)	+= time.o
>  obj-$(CONFIG_OMAP_32K_TIMER)	+= timer32k.o
> 
> +# CPUFREQ driver
> +obj-$(CONFIG_CPU_FREQ) += omap1-cpufreq.o
> +
>  # Power Management
>  obj-$(CONFIG_PM) += pm.o sleep.o pm_bus.o
> 
> diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/mach-omap1/omap1-
> cpufreq.c
> similarity index 74%
> copy from arch/arm/plat-omap/cpu-omap.c
> copy to arch/arm/mach-omap1/omap1-cpufreq.c
> index 1c1b80b..64faf3f 100644
> --- a/arch/arm/plat-omap/cpu-omap.c
> +++ b/arch/arm/mach-omap1/omap1-cpufreq.c
> @@ -1,5 +1,5 @@
>  /*
> - *  linux/arch/arm/plat-omap/cpu-omap.c
> + *  OMAP1 cpufreq driver
>   *
>   *  CPU frequency scaling for OMAP
>   *
> @@ -27,31 +27,18 @@
>  #include <linux/io.h>
>  #include <linux/opp.h>
> 
> -#include <mach/hardware.h>
> -#include <plat/clock.h>
>  #include <asm/system.h>
> 
> -#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
> +#include <plat/clock.h>
>  #include <plat/omap-pm.h>
> -#include <plat/common.h>
> -#endif
> +
> +#include <mach/hardware.h>
> 
>  #define VERY_HI_RATE	900000000
> 
>  static struct cpufreq_frequency_table *freq_table;
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -#define MPU_CLK		"mpu"
> -#elif defined(CONFIG_ARCH_OMAP3)
> -#define MPU_CLK		"arm_fck"
> -#else
> -#define MPU_CLK		"virt_prcm_set"
> -#endif
> -
>  static struct clk *mpu_clk;
> 
> -/* TODO: Add support for SDRAM timing changes */
> -
>  static int omap_verify_speed(struct cpufreq_policy *policy)
>  {
>  	if (freq_table)
> @@ -85,13 +72,7 @@ static int omap_target(struct cpufreq_policy *policy,
>  		       unsigned int target_freq,
>  		       unsigned int relation)
>  {
> -#ifdef CONFIG_ARCH_OMAP1
>  	struct cpufreq_freqs freqs;
> -#endif
> -#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
> -	unsigned long freq;
> -	struct device *mpu_dev = omap2_get_mpuss_device();
> -#endif
>  	int ret = 0;
> 
>  	/* Ensure desired rate is within allowed range.  Some govenors
> @@ -101,25 +82,22 @@ static int omap_target(struct cpufreq_policy *policy,
>  	if (target_freq > policy->max)
>  		target_freq = policy->max;
> 
> -#ifdef CONFIG_ARCH_OMAP1
>  	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);
> +
>  #ifdef CONFIG_CPU_FREQ_DEBUG
> -	printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
> -	       freqs.old, freqs.new);
> +	pr_info("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);
> -#elif defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
> -	freq = target_freq * 1000;
> -	if (opp_find_freq_ceil(mpu_dev, &freq))
> -		omap_pm_cpu_set_freq(freq);
> -#endif
> +	if (!ret)
> +		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
> +
>  	return ret;
>  }
> 
> @@ -127,7 +105,7 @@ static int __init omap_cpu_init(struct cpufreq_policy
> *policy)
>  {
>  	int result = 0;
> 
> -	mpu_clk = clk_get(NULL, MPU_CLK);
> +	mpu_clk = clk_get(NULL, "mpu");
>  	if (IS_ERR(mpu_clk))
>  		return PTR_ERR(mpu_clk);
> 
> @@ -136,13 +114,7 @@ static int __init omap_cpu_init(struct cpufreq_policy
> *policy)
> 
>  	policy->cur = policy->min = policy->max = omap_getspeed(0);
> 
> -	if (!cpu_is_omap34xx()) {
> -		clk_init_cpufreq_table(&freq_table);
> -	} else {
> -		struct device *mpu_dev = omap2_get_mpuss_device();
> -
> -		opp_init_cpufreq_table(mpu_dev, &freq_table);
> -	}
> +	clk_init_cpufreq_table(&freq_table);
> 
>  	if (freq_table) {
>  		result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
> @@ -184,7 +156,7 @@ static struct cpufreq_driver omap_driver = {
>  	.get		= omap_getspeed,
>  	.init		= omap_cpu_init,
>  	.exit		= omap_cpu_exit,
> -	.name		= "omap",
> +	.name		= "omap1",
>  	.attr		= omap_cpufreq_attr,
>  };
> 
> @@ -193,12 +165,12 @@ static int __init omap_cpufreq_init(void)
>  	return cpufreq_register_driver(&omap_driver);
>  }
> 
> -late_initcall(omap_cpufreq_init);
> -
> -/*
> - * if ever we want to remove this, upon cleanup call:
> - *
> - * cpufreq_unregister_driver()
> - * cpufreq_frequency_table_put_attr()
> - */
> +static void __exit omap_cpufreq_exit(void)
> +{
> +	cpufreq_unregister_driver(&omap_driver);
> +}
> 
> +MODULE_DESCRIPTION("cpufreq driver for OMAP1 SOCs");
> +MODULE_LICENSE("GPL");
> +module_init(omap_cpufreq_init);
> +module_exit(omap_cpufreq_exit);
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 1c0c2b0..b1187f9 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -56,6 +56,9 @@ obj-$(CONFIG_ARCH_OMAP3)		+= opp3xxx_data.o
>  obj-$(CONFIG_ARCH_OMAP4)		+= opp4xxx_data.o
>  endif
> 
> +# CPUFREQ driver
> +obj-$(CONFIG_CPU_FREQ)			+= omap2plus-cpufreq.o
> +
>  # Power Management
>  ifeq ($(CONFIG_PM),y)
>  obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
> diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/mach-
> omap2/omap2plus-cpufreq.c
> similarity index 76%
> rename from arch/arm/plat-omap/cpu-omap.c
> rename to arch/arm/mach-omap2/omap2plus-cpufreq.c
> index 1c1b80b..48da867 100644
> --- a/arch/arm/plat-omap/cpu-omap.c
> +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
> @@ -1,5 +1,5 @@
>  /*
> - *  linux/arch/arm/plat-omap/cpu-omap.c
> + *  OMAP2PLUS cpufreq driver
>   *
>   *  CPU frequency scaling for OMAP
>   *
> @@ -27,31 +27,20 @@
>  #include <linux/io.h>
>  #include <linux/opp.h>
> 
> -#include <mach/hardware.h>
> -#include <plat/clock.h>
>  #include <asm/system.h>
> +#include <asm/smp_plat.h>
> 
> -#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
> +#include <plat/clock.h>
>  #include <plat/omap-pm.h>
>  #include <plat/common.h>
> -#endif
> +
> +#include <mach/hardware.h>
> 
>  #define VERY_HI_RATE	900000000
> 
>  static struct cpufreq_frequency_table *freq_table;
> -
> -#ifdef CONFIG_ARCH_OMAP1
> -#define MPU_CLK		"mpu"
> -#elif defined(CONFIG_ARCH_OMAP3)
> -#define MPU_CLK		"arm_fck"
> -#else
> -#define MPU_CLK		"virt_prcm_set"
> -#endif
> -
>  static struct clk *mpu_clk;
> 
> -/* TODO: Add support for SDRAM timing changes */
> -
>  static int omap_verify_speed(struct cpufreq_policy *policy)
>  {
>  	if (freq_table)
> @@ -85,14 +74,8 @@ static int omap_target(struct cpufreq_policy *policy,
>  		       unsigned int target_freq,
>  		       unsigned int relation)
>  {
> -#ifdef CONFIG_ARCH_OMAP1
> -	struct cpufreq_freqs freqs;
> -#endif
> -#if defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
> -	unsigned long freq;
> -	struct device *mpu_dev = omap2_get_mpuss_device();
> -#endif
>  	int ret = 0;
> +	struct cpufreq_freqs freqs;
> 
>  	/* Ensure desired rate is within allowed range.  Some govenors
>  	 * (ondemand) will just pass target_freq=0 to get the minimum. */
> @@ -101,33 +84,44 @@ static int omap_target(struct cpufreq_policy *policy,
>  	if (target_freq > policy->max)
>  		target_freq = policy->max;
> 
> -#ifdef CONFIG_ARCH_OMAP1
>  	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);
> +
>  #ifdef CONFIG_CPU_FREQ_DEBUG
> -	printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
> -	       freqs.old, freqs.new);
> +	pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old,
> freqs.new);
>  #endif
> +
>  	ret = clk_set_rate(mpu_clk, freqs.new * 1000);
> +	if (ret)
> +		return ret;
What about pr_warning() before return?
> +
> +	/*
> +	 * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
> +	 * won't get updated when UP machine cpufreq build with
> +	 * CONFIG_SMP enabled. Below code is added only to manage that
> +	 * scenario
Typo: add '.' at the end.
--
Tarun
> +	 */
> +	if (!is_smp())
> +		loops_per_jiffy =
> +			 cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new);
> +
>  	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
> -#elif defined(CONFIG_ARCH_OMAP3) && !defined(CONFIG_OMAP_PM_NONE)
> -	freq = target_freq * 1000;
> -	if (opp_find_freq_ceil(mpu_dev, &freq))
> -		omap_pm_cpu_set_freq(freq);
> -#endif
> +
>  	return ret;
>  }
> 
>  static int __init omap_cpu_init(struct cpufreq_policy *policy)
>  {
>  	int result = 0;
> +	struct device *mpu_dev;
> 
> -	mpu_clk = clk_get(NULL, MPU_CLK);
> +	mpu_clk = clk_get(NULL, "cpu_ck");
>  	if (IS_ERR(mpu_clk))
>  		return PTR_ERR(mpu_clk);
> 
> @@ -136,13 +130,12 @@ static int __init omap_cpu_init(struct
> cpufreq_policy *policy)
> 
>  	policy->cur = policy->min = policy->max = omap_getspeed(0);
> 
> -	if (!cpu_is_omap34xx()) {
> -		clk_init_cpufreq_table(&freq_table);
> -	} else {
> -		struct device *mpu_dev = omap2_get_mpuss_device();
> -
> -		opp_init_cpufreq_table(mpu_dev, &freq_table);
> +	mpu_dev = omap2_get_mpuss_device();
> +	if (!mpu_dev) {
> +		pr_warning("%s: unable to get the mpu device\n", __func__);
> +		return -EINVAL;
>  	}
> +	opp_init_cpufreq_table(mpu_dev, &freq_table);
> 
>  	if (freq_table) {
>  		result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
> @@ -184,7 +177,7 @@ static struct cpufreq_driver omap_driver = {
>  	.get		= omap_getspeed,
>  	.init		= omap_cpu_init,
>  	.exit		= omap_cpu_exit,
> -	.name		= "omap",
> +	.name		= "omap2plus",
>  	.attr		= omap_cpufreq_attr,
>  };
> 
> @@ -193,12 +186,12 @@ static int __init omap_cpufreq_init(void)
>  	return cpufreq_register_driver(&omap_driver);
>  }
> 
> -late_initcall(omap_cpufreq_init);
> -
> -/*
> - * if ever we want to remove this, upon cleanup call:
> - *
> - * cpufreq_unregister_driver()
> - * cpufreq_frequency_table_put_attr()
> - */
> +static void __exit omap_cpufreq_exit(void)
> +{
> +	cpufreq_unregister_driver(&omap_driver);
> +}
> 
> +MODULE_DESCRIPTION("cpufreq driver for OMAP2PLUS SOCs");
> +MODULE_LICENSE("GPL");
> +module_init(omap_cpufreq_init);
> +module_exit(omap_cpufreq_exit);
> diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
> index a4a1285..ec7862e 100644
> --- a/arch/arm/plat-omap/Makefile
> +++ b/arch/arm/plat-omap/Makefile
> @@ -21,7 +21,6 @@ obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
>  obj-$(CONFIG_OMAP_IOMMU) += iommu.o iovmm.o
>  obj-$(CONFIG_OMAP_IOMMU_DEBUG) += iommu-debug.o
> 
> -obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
>  obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
>  obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o
>  obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o
> --
> 1.6.0.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver
  2011-02-25  6:10 ` [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver Santosh Shilimkar
@ 2011-03-10 22:13   ` Kevin Hilman
  2011-03-14  9:19     ` Santosh Shilimkar
  0 siblings, 1 reply; 13+ messages in thread
From: Kevin Hilman @ 2011-03-10 22:13 UTC (permalink / raw)
  To: Santosh Shilimkar; +Cc: linux-omap, vishwanath.bs

Santosh Shilimkar <santosh.shilimkar@ti.com> writes:

> Add an alias clock node for cpu clock control on all OMAP2PLUS devices.
> The intention is avoid cpu_is_xxxx() checks in the common cpufreq driver.
>
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

Rather than having hard-coded clkdev nodes, Since CPUfreq will be the
only user of these clocks, it might make sense to just use cpu_is_* in
the CPUfreq init and do clk_add_alias().

> ---
>  arch/arm/mach-omap2/clock2420_data.c |    1 +
>  arch/arm/mach-omap2/clock2430_data.c |    1 +
>  arch/arm/mach-omap2/clock3xxx_data.c |    1 +
>  arch/arm/mach-omap2/clock44xx_data.c |    1 +
>  4 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
> index 0a992bc..3efe45b 100644
> --- a/arch/arm/mach-omap2/clock2420_data.c
> +++ b/arch/arm/mach-omap2/clock2420_data.c
> @@ -1799,6 +1799,7 @@ static struct omap_clk omap2420_clks[] = {
>  	CLK(NULL,	"ssi_l4_ick",	&ssi_l4_ick,	CK_242X),
>  	/* virtual meta-group clock */
>  	CLK(NULL,	"virt_prcm_set", &virt_prcm_set, CK_242X),
> +	CLK(NULL,	"cpu_ck", &virt_prcm_set, CK_242X),

Are there any other users of virt_prcm_set?  Probably could get rid of
it now.

>  	/* general l4 interface ck, multi-parent functional clk */
>  	CLK(NULL,	"gpt1_ick",	&gpt1_ick,	CK_242X),
>  	CLK(NULL,	"gpt1_fck",	&gpt1_fck,	CK_242X),
> diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
> index c047dcd..25b1c2d 100644
> --- a/arch/arm/mach-omap2/clock2430_data.c
> +++ b/arch/arm/mach-omap2/clock2430_data.c
> @@ -1903,6 +1903,7 @@ static struct omap_clk omap2430_clks[] = {
>  	CLK(NULL,	"ssi_l4_ick",	&ssi_l4_ick,	CK_243X),
>  	/* virtual meta-group clock */
>  	CLK(NULL,	"virt_prcm_set", &virt_prcm_set, CK_243X),
> +	CLK(NULL,	"cpu_ck", &virt_prcm_set, CK_243X),

ditto

>  	/* general l4 interface ck, multi-parent functional clk */
>  	CLK(NULL,	"gpt1_ick",	&gpt1_ick,	CK_243X),
>  	CLK(NULL,	"gpt1_fck",	&gpt1_fck,	CK_243X),
> diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
> index 403a4a1..655d1a9 100644
> --- a/arch/arm/mach-omap2/clock3xxx_data.c
> +++ b/arch/arm/mach-omap2/clock3xxx_data.c
> @@ -3224,6 +3224,7 @@ static struct omap_clk omap3xxx_clks[] = {
>  	CLK(NULL,	"mcbsp_clks",	&mcbsp_clks,	CK_3XXX),
>  	CLK(NULL,	"sys_clkout1",	&sys_clkout1,	CK_3XXX),
>  	CLK(NULL,	"dpll1_ck",	&dpll1_ck,	CK_3XXX),
> +	CLK(NULL,	"cpu_ck",	&dpll1_ck,	CK_3XXX),
>  	CLK(NULL,	"dpll1_x2_ck",	&dpll1_x2_ck,	CK_3XXX),
>  	CLK(NULL,	"dpll1_x2m2_ck", &dpll1_x2m2_ck, CK_3XXX),
>  	CLK(NULL,	"dpll2_ck",	&dpll2_ck,	CK_34XX | CK_36XX),
> diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c
> index e8cb32f..4d5ede3 100644
> --- a/arch/arm/mach-omap2/clock44xx_data.c
> +++ b/arch/arm/mach-omap2/clock44xx_data.c
> @@ -3058,6 +3058,7 @@ static struct omap_clk omap44xx_clks[] = {
>  	CLK(NULL,	"dpll_iva_m4x2_ck",		&dpll_iva_m4x2_ck,	CK_443X),
>  	CLK(NULL,	"dpll_iva_m5x2_ck",		&dpll_iva_m5x2_ck,	CK_443X),
>  	CLK(NULL,	"dpll_mpu_ck",			&dpll_mpu_ck,	CK_443X),
> +	CLK(NULL,	"cpu_ck",			&dpll_mpu_ck,	CK_443X),
>  	CLK(NULL,	"dpll_mpu_m2_ck",		&dpll_mpu_m2_ck,	CK_443X),
>  	CLK(NULL,	"per_hs_clk_div_ck",		&per_hs_clk_div_ck,	CK_443X),
>  	CLK(NULL,	"per_hsd_byp_clk_mux_ck",	&per_hsd_byp_clk_mux_ck,	CK_443X),

Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430
  2011-02-25  6:10 ` [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430 Santosh Shilimkar
  2011-02-25  8:10   ` DebBarma, Tarun Kanti
@ 2011-03-10 22:27   ` Kevin Hilman
  1 sibling, 0 replies; 13+ messages in thread
From: Kevin Hilman @ 2011-03-10 22:27 UTC (permalink / raw)
  To: Santosh Shilimkar; +Cc: linux-omap, vishwanath.bs

Santosh Shilimkar <santosh.shilimkar@ti.com> writes:

> On OMAP SMP configuartion, both processors share the voltage
> and clock. So both CPUs needs to be scaled together and hence
> needs software co-ordination.
>
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>
> cc: Vishwanath BS <vishwanath.bs@ti.com>

[...]

> @@ -74,9 +76,13 @@ static int omap_target(struct cpufreq_policy *policy,
>  		       unsigned int target_freq,
>  		       unsigned int relation)
>  {
> -	int ret = 0;
> +	int i, ret = 0;
>  	struct cpufreq_freqs freqs;
>  
> +	/* Wait untill all CPU's are initialized */
> +	if (is_smp() && (num_online_cpus() < NR_CPUS))
> +		return ret;
> +

Minor: the 'Wait' in the comment is a bit misleading.  It should
rather say something like "Changes not allowed until all CPUs are online"

Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support
  2011-02-25  6:10 [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Santosh Shilimkar
                   ` (2 preceding siblings ...)
  2011-02-25  6:10 ` [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430 Santosh Shilimkar
@ 2011-03-10 22:28 ` Kevin Hilman
  2011-03-11  5:54   ` Santosh Shilimkar
  3 siblings, 1 reply; 13+ messages in thread
From: Kevin Hilman @ 2011-03-10 22:28 UTC (permalink / raw)
  To: Santosh Shilimkar; +Cc: linux-omap, vishwanath.bs

Hi Santosh,

Santosh Shilimkar <santosh.shilimkar@ti.com> writes:

> This series is an attempt to clean-up omap cpufreq driver.
> 	- The OMAP1 and OMAP2PLUS cpufreq support is split to avoid
> 	  any #ifdefery
> 	- Alias clock nodes are added in all OMAP2PLUS clock-data
> 	  to avoid any cpu_is_xxx() checks
> 	- The omap2plus_cupfreq support is updated to work on
> 	  SMP_ON_UP builds
> 	- SMP support is added which can be used on OMAP4
>
> Thanks to Vishwanath BS <vishwanath.bs@ti.com> for doing testing with
> his DVFS series and review.

Thanks for this series.  I was planning on doing this cleanup as well,
but it's been a busy development cycle for linux-omap. ;)

After fixing the minor comments, please rebase on latest pm-wip/cpufreq
and I'll add it to that branch.  This probably won't make it for 2.6.39,
but I'll aim for early in the .40 cycle.

Thanks,

Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support
  2011-03-10 22:28 ` [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Kevin Hilman
@ 2011-03-11  5:54   ` Santosh Shilimkar
  0 siblings, 0 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2011-03-11  5:54 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, Vishwanath Sripathy

> -----Original Message-----
> From: Kevin Hilman [mailto:khilman@ti.com]
> Sent: Friday, March 11, 2011 3:59 AM
> To: Santosh Shilimkar
> Cc: linux-omap@vger.kernel.org; vishwanath.bs@ti.com
> Subject: Re: [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP
> support
>
> Hi Santosh,
>
> Santosh Shilimkar <santosh.shilimkar@ti.com> writes:
>
> > This series is an attempt to clean-up omap cpufreq driver.
> > 	- The OMAP1 and OMAP2PLUS cpufreq support is split to avoid
> > 	  any #ifdefery
> > 	- Alias clock nodes are added in all OMAP2PLUS clock-data
> > 	  to avoid any cpu_is_xxx() checks
> > 	- The omap2plus_cupfreq support is updated to work on
> > 	  SMP_ON_UP builds
> > 	- SMP support is added which can be used on OMAP4
> >
> > Thanks to Vishwanath BS <vishwanath.bs@ti.com> for doing testing
> > with his DVFS series and review.
>
> Thanks for this series.  I was planning on doing this cleanup as
> well, but it's been a busy development cycle for linux-omap. ;)
>
> After fixing the minor comments, please rebase on latest pm-
> wip/cpufreq
> and I'll add it to that branch.  This probably won't make it for
> 2.6.39, but I'll aim for early in the .40 cycle.
>
Sure. Will do.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver
  2011-03-10 22:13   ` Kevin Hilman
@ 2011-03-14  9:19     ` Santosh Shilimkar
  0 siblings, 0 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2011-03-14  9:19 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, Vishwanath Sripathy

> -----Original Message-----
> From: Kevin Hilman [mailto:khilman@ti.com]
> Sent: Friday, March 11, 2011 3:43 AM
> To: Santosh Shilimkar
> Cc: linux-omap@vger.kernel.org; vishwanath.bs@ti.com
> Subject: Re: [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be
> used in common cpufreq driver
>
> Santosh Shilimkar <santosh.shilimkar@ti.com> writes:
>
> > Add an alias clock node for cpu clock control on all OMAP2PLUS
> devices.
> > The intention is avoid cpu_is_xxxx() checks in the common cpufreq
> driver.
> >
> > Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
>
> Rather than having hard-coded clkdev nodes, Since CPUfreq will be
> the
> only user of these clocks, it might make sense to just use cpu_is_*
> in the CPUfreq init and do clk_add_alias().
>

Since we are ok to have cpu_is_*() in CPUfreq init, we don't even
need to clk_add_alias().

We just the correct clock node handle based on SOC.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-03-14  9:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-25  6:10 [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Santosh Shilimkar
2011-02-25  6:10 ` [PATCH 1/3] omap2plus: clock: Add an alias cpu_ck to be used in common cpufreq driver Santosh Shilimkar
2011-03-10 22:13   ` Kevin Hilman
2011-03-14  9:19     ` Santosh Shilimkar
2011-02-25  6:10 ` [PATCH 2/3] omap: cpufreq: Split omap1 and omap2plus cpufreq drivers Santosh Shilimkar
2011-02-25  7:17   ` Vishwanath Sripathy
2011-02-25  7:22     ` Santosh Shilimkar
2011-02-25  8:19   ` DebBarma, Tarun Kanti
2011-02-25  6:10 ` [PATCH 3/3] omap2plus: cpufreq: Add SMP support to cater OMAP4430 Santosh Shilimkar
2011-02-25  8:10   ` DebBarma, Tarun Kanti
2011-03-10 22:27   ` Kevin Hilman
2011-03-10 22:28 ` [PATCH 0/3] [pm-wip/cpufreq] cpufreq cleanup and SMP support Kevin Hilman
2011-03-11  5:54   ` Santosh Shilimkar

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