All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
@ 2012-05-02 13:56 ` Vaibhav Hiremath
  0 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, paul, santosh.shilimkar, b-cousson,
	linux-arm-kernel, Vaibhav Hiremath

Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)

This patch series cleans up the existing 32k-sync timer implementation,
movind SoC init code to respective files (mach-omap1/timer32k.c and
mach-omap2/timer.c) and uses kernel parameter to override the default
clocksource of "counter_32k", also in order to support some OMAP based
derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
adds hwmod lookup for omap2+ devices, and if lookup fails then
fall back to gp-timer.

if(use_gptimer_clksrc == true)
	gptimer clocksource init;
else if (counter_32 init == false)
	/* Fallback to gptimer */
	gptimer clocksource init(;

With this, we should be able to support multi-omap boot
including devices with/without 32k-sync timer.

This patch-series has been boot tested on AM37xEVM platform, it
would be helpful if somebody help me to validate it on OMAP1/2
platforms.

The patches are also available at (based on linux-omap/master) -
https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup

History:
========
Changes from V5:
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg67163.html
	- 2 of the original patch-series (1/3 and 2/3) has already been
	  accepted and queued by Paul, so removing them.
	  Also, add 2 new patches,
		- OMAP2 timer32k cleanup, check for return values.
		- Changed name of system timers, "gp timer" => "gp_timer".
	- Moved SoC specific init code to respective files
	  (mach-omap1/timer32k.c and mach-omap2/timer.c)

Changes from V4:
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg67019.html
	- Fix the possible bug, leftover the cnt addr argument to
	  clocksource_mmio_init().

Changes from V3:
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg66462.html
	- Fixed all review comments from Kevin H
		* Moved counter_32k CR register offset handling to
		  counter_32k.c file, so now, calling funtion don't have
		  to maintain or add offset to base addr.
		* Added comment for function omap_init_clocksource_32k()
		* Used resource_size() for calculate size
		* Convert WARN_ON to pr_warn

Changes from V2:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/092037.html
	- Added early_param support to read clocksource selection
	  from user through kernel parameter ("clocksource=")
	- Converted to ocp_if changes from Paul

Changes from V1:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-January/081037.html
	- Based on Tony's comment, added pbase & size argument to
	  omap_init_clocksource_32k(), to avoid cpu_is_xxx() check.
	- Added commit description based on discussion on list
	  (Thanks to Santosh here)
	- Reorder patch sequence




Vaibhav Hiremath (3):
  ARM: OMAP1: FIX: check possible error condition in timer_init
  ARM: OMAP2+: Replace space=>underscore in the name field of system
    timers
  ARM: OMAP: Make OMAP clocksource source selection using kernel param

 arch/arm/mach-omap1/common.h             |   10 ++-
 arch/arm/mach-omap1/time.c               |   16 +----
 arch/arm/mach-omap1/timer32k.c           |   28 ++++++-
 arch/arm/mach-omap2/timer.c              |  118 +++++++++++++++++++++++------
 arch/arm/plat-omap/counter_32k.c         |   91 ++++++++++-------------
 arch/arm/plat-omap/include/plat/common.h |    2 +-
 6 files changed, 167 insertions(+), 98 deletions(-)


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

* [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
@ 2012-05-02 13:56 ` Vaibhav Hiremath
  0 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-arm-kernel

Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)

This patch series cleans up the existing 32k-sync timer implementation,
movind SoC init code to respective files (mach-omap1/timer32k.c and
mach-omap2/timer.c) and uses kernel parameter to override the default
clocksource of "counter_32k", also in order to support some OMAP based
derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
adds hwmod lookup for omap2+ devices, and if lookup fails then
fall back to gp-timer.

if(use_gptimer_clksrc == true)
	gptimer clocksource init;
else if (counter_32 init == false)
	/* Fallback to gptimer */
	gptimer clocksource init(;

With this, we should be able to support multi-omap boot
including devices with/without 32k-sync timer.

This patch-series has been boot tested on AM37xEVM platform, it
would be helpful if somebody help me to validate it on OMAP1/2
platforms.

The patches are also available at (based on linux-omap/master) -
https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup

History:
========
Changes from V5:
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg67163.html
	- 2 of the original patch-series (1/3 and 2/3) has already been
	  accepted and queued by Paul, so removing them.
	  Also, add 2 new patches,
		- OMAP2 timer32k cleanup, check for return values.
		- Changed name of system timers, "gp timer" => "gp_timer".
	- Moved SoC specific init code to respective files
	  (mach-omap1/timer32k.c and mach-omap2/timer.c)

Changes from V4:
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg67019.html
	- Fix the possible bug, leftover the cnt addr argument to
	  clocksource_mmio_init().

Changes from V3:
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg66462.html
	- Fixed all review comments from Kevin H
		* Moved counter_32k CR register offset handling to
		  counter_32k.c file, so now, calling funtion don't have
		  to maintain or add offset to base addr.
		* Added comment for function omap_init_clocksource_32k()
		* Used resource_size() for calculate size
		* Convert WARN_ON to pr_warn

Changes from V2:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/092037.html
	- Added early_param support to read clocksource selection
	  from user through kernel parameter ("clocksource=")
	- Converted to ocp_if changes from Paul

Changes from V1:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-January/081037.html
	- Based on Tony's comment, added pbase & size argument to
	  omap_init_clocksource_32k(), to avoid cpu_is_xxx() check.
	- Added commit description based on discussion on list
	  (Thanks to Santosh here)
	- Reorder patch sequence




Vaibhav Hiremath (3):
  ARM: OMAP1: FIX: check possible error condition in timer_init
  ARM: OMAP2+: Replace space=>underscore in the name field of system
    timers
  ARM: OMAP: Make OMAP clocksource source selection using kernel param

 arch/arm/mach-omap1/common.h             |   10 ++-
 arch/arm/mach-omap1/time.c               |   16 +----
 arch/arm/mach-omap1/timer32k.c           |   28 ++++++-
 arch/arm/mach-omap2/timer.c              |  118 +++++++++++++++++++++++------
 arch/arm/plat-omap/counter_32k.c         |   91 ++++++++++-------------
 arch/arm/plat-omap/include/plat/common.h |    2 +-
 6 files changed, 167 insertions(+), 98 deletions(-)

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

* [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
  2012-05-02 13:56 ` Vaibhav Hiremath
@ 2012-05-02 13:56   ` Vaibhav Hiremath
  -1 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, paul, santosh.shilimkar, b-cousson,
	linux-arm-kernel, Vaibhav Hiremath

OMAP1, omap_32k_timer_init() function always returns "true",
irrespective of whether error occurred while initializing 32k sync
counter as a kernel clocksource or not and execution will never
fallback to mpu_timer clocksource init code.

This patch adds check for return value from function
omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
in case of failure/error from omap_init_clocksource_32k().

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Benoit Cousson <b-cousson@ti.com>
---
This is new patch addition compared to original series (<=V5).

Also, note that, this patch is only compile tested, since
I do not have omap1 board with me to validate it.
Kevin, can you help me to validate it.

 arch/arm/mach-omap1/common.h   |   10 +++++++++-
 arch/arm/mach-omap1/time.c     |   16 +---------------
 arch/arm/mach-omap1/timer32k.c |   13 +++++++++----
 3 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index 8cc616e..e8c9ad3 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -63,7 +63,15 @@ extern void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
 			       unsigned int ctrl);

 extern struct sys_timer omap1_timer;
-extern bool omap_32k_timer_init(void);
+
+#ifdef CONFIG_OMAP_32K_TIMER
+extern int omap_32k_timer_init(void);
+#else
+static int __init omap_32k_timer_init(void)
+{
+	return -ENODEV;
+}
+#endif

 extern u32 omap_irq_flags;

diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 4d8dd9a..4062480 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -232,20 +232,6 @@ static inline void omap_mpu_timer_init(void)
 }
 #endif	/* CONFIG_OMAP_MPU_TIMER */

-static inline int omap_32k_timer_usable(void)
-{
-	int res = false;
-
-	if (cpu_is_omap730() || cpu_is_omap15xx())
-		return res;
-
-#ifdef CONFIG_OMAP_32K_TIMER
-	res = omap_32k_timer_init();
-#endif
-
-	return res;
-}
-
 /*
  * ---------------------------------------------------------------------------
  * Timer initialization
@@ -253,7 +239,7 @@ static inline int omap_32k_timer_usable(void)
  */
 static void __init omap1_timer_init(void)
 {
-	if (!omap_32k_timer_usable())
+	if (omap_32k_timer_init() != 0)
 		omap_mpu_timer_init();
 }

diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index 325b9a0..e3613a8 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -182,10 +182,15 @@ static __init void omap_init_32k_timer(void)
  * Timer initialization
  * ---------------------------------------------------------------------------
  */
-bool __init omap_32k_timer_init(void)
+int __init omap_32k_timer_init(void)
 {
-	omap_init_clocksource_32k();
-	omap_init_32k_timer();
+	int ret = -ENODEV;

-	return true;
+	if (cpu_is_omap16xx())
+		ret = omap_init_clocksource_32k();
+
+	if (!ret)
+		omap_init_32k_timer();
+
+	return ret;
 }
--
1.7.0.4


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

* [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
@ 2012-05-02 13:56   ` Vaibhav Hiremath
  0 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-arm-kernel

OMAP1, omap_32k_timer_init() function always returns "true",
irrespective of whether error occurred while initializing 32k sync
counter as a kernel clocksource or not and execution will never
fallback to mpu_timer clocksource init code.

This patch adds check for return value from function
omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
in case of failure/error from omap_init_clocksource_32k().

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Benoit Cousson <b-cousson@ti.com>
---
This is new patch addition compared to original series (<=V5).

Also, note that, this patch is only compile tested, since
I do not have omap1 board with me to validate it.
Kevin, can you help me to validate it.

 arch/arm/mach-omap1/common.h   |   10 +++++++++-
 arch/arm/mach-omap1/time.c     |   16 +---------------
 arch/arm/mach-omap1/timer32k.c |   13 +++++++++----
 3 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index 8cc616e..e8c9ad3 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -63,7 +63,15 @@ extern void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
 			       unsigned int ctrl);

 extern struct sys_timer omap1_timer;
-extern bool omap_32k_timer_init(void);
+
+#ifdef CONFIG_OMAP_32K_TIMER
+extern int omap_32k_timer_init(void);
+#else
+static int __init omap_32k_timer_init(void)
+{
+	return -ENODEV;
+}
+#endif

 extern u32 omap_irq_flags;

diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 4d8dd9a..4062480 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -232,20 +232,6 @@ static inline void omap_mpu_timer_init(void)
 }
 #endif	/* CONFIG_OMAP_MPU_TIMER */

-static inline int omap_32k_timer_usable(void)
-{
-	int res = false;
-
-	if (cpu_is_omap730() || cpu_is_omap15xx())
-		return res;
-
-#ifdef CONFIG_OMAP_32K_TIMER
-	res = omap_32k_timer_init();
-#endif
-
-	return res;
-}
-
 /*
  * ---------------------------------------------------------------------------
  * Timer initialization
@@ -253,7 +239,7 @@ static inline int omap_32k_timer_usable(void)
  */
 static void __init omap1_timer_init(void)
 {
-	if (!omap_32k_timer_usable())
+	if (omap_32k_timer_init() != 0)
 		omap_mpu_timer_init();
 }

diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index 325b9a0..e3613a8 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -182,10 +182,15 @@ static __init void omap_init_32k_timer(void)
  * Timer initialization
  * ---------------------------------------------------------------------------
  */
-bool __init omap_32k_timer_init(void)
+int __init omap_32k_timer_init(void)
 {
-	omap_init_clocksource_32k();
-	omap_init_32k_timer();
+	int ret = -ENODEV;

-	return true;
+	if (cpu_is_omap16xx())
+		ret = omap_init_clocksource_32k();
+
+	if (!ret)
+		omap_init_32k_timer();
+
+	return ret;
 }
--
1.7.0.4

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

* [PATCH-V6 2/3] ARM: OMAP2+: Replace space=>underscore in the name field of system timers
  2012-05-02 13:56 ` Vaibhav Hiremath
@ 2012-05-02 13:56   ` Vaibhav Hiremath
  -1 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, paul, santosh.shilimkar, b-cousson,
	linux-arm-kernel, Vaibhav Hiremath

Depending on the bootloader, passing command-line arguments
with spaces may have issues. Some bootloaders doesn't seem
to pass along the quotes, passing only 'gp' part of the string,
which leads to wrong clocksource override configuration.

So this patch changes "gp timer" => "gp_timer", for clockevent,
clocksource and timer irq_handler.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
---
This is new patch addition compared to original series (<=V5).

 arch/arm/mach-omap2/timer.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index ecec873..777f84b 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -90,7 +90,7 @@ static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id)
 }

 static struct irqaction omap2_gp_timer_irq = {
-	.name		= "gp timer",
+	.name		= "gp_timer",
 	.flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
 	.handler	= omap2_gp_timer_interrupt,
 };
@@ -132,7 +132,7 @@ static void omap2_gp_timer_set_mode(enum clock_event_mode mode,
 }

 static struct clock_event_device clockevent_gpt = {
-	.name		= "gp timer",
+	.name		= "gp_timer",
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 	.shift		= 32,
 	.set_next_event	= omap2_gp_timer_set_next_event,
@@ -269,7 +269,7 @@ static cycle_t clocksource_read_cycles(struct clocksource *cs)
 }

 static struct clocksource clocksource_gpt = {
-	.name		= "gp timer",
+	.name		= "gp_timer",
 	.rating		= 300,
 	.read		= clocksource_read_cycles,
 	.mask		= CLOCKSOURCE_MASK(32),
--
1.7.0.4


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

* [PATCH-V6 2/3] ARM: OMAP2+: Replace space=>underscore in the name field of system timers
@ 2012-05-02 13:56   ` Vaibhav Hiremath
  0 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-arm-kernel

Depending on the bootloader, passing command-line arguments
with spaces may have issues. Some bootloaders doesn't seem
to pass along the quotes, passing only 'gp' part of the string,
which leads to wrong clocksource override configuration.

So this patch changes "gp timer" => "gp_timer", for clockevent,
clocksource and timer irq_handler.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
---
This is new patch addition compared to original series (<=V5).

 arch/arm/mach-omap2/timer.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index ecec873..777f84b 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -90,7 +90,7 @@ static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id)
 }

 static struct irqaction omap2_gp_timer_irq = {
-	.name		= "gp timer",
+	.name		= "gp_timer",
 	.flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
 	.handler	= omap2_gp_timer_interrupt,
 };
@@ -132,7 +132,7 @@ static void omap2_gp_timer_set_mode(enum clock_event_mode mode,
 }

 static struct clock_event_device clockevent_gpt = {
-	.name		= "gp timer",
+	.name		= "gp_timer",
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 	.shift		= 32,
 	.set_next_event	= omap2_gp_timer_set_next_event,
@@ -269,7 +269,7 @@ static cycle_t clocksource_read_cycles(struct clocksource *cs)
 }

 static struct clocksource clocksource_gpt = {
-	.name		= "gp timer",
+	.name		= "gp_timer",
 	.rating		= 300,
 	.read		= clocksource_read_cycles,
 	.mask		= CLOCKSOURCE_MASK(32),
--
1.7.0.4

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

* [PATCH-V6 3/3] ARM: OMAP: Make OMAP clocksource source selection using kernel param
  2012-05-02 13:56 ` Vaibhav Hiremath
@ 2012-05-02 13:56   ` Vaibhav Hiremath
  -1 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-omap
  Cc: tony, khilman, paul, santosh.shilimkar, b-cousson,
	linux-arm-kernel, Vaibhav Hiremath, Felipe Balbi,
	Tarun Kanti DebBarma, Ming Lei

Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -

1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.

The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.

Option 3 will still work but it is no better than 32K sync-timer
based clocksource.

We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.

Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.

And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.

So, the solution is,

Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.

Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
---
Two of the original patch-series (1/3 and 2/3) has already been
accepted and queued by Paul, so removing them.
New 2 patches have been added to the series,
	- OMAP2 timer32k cleanup, check for return values.
	- Changed name of system timers, "gp timer" => "gp_timer".

 arch/arm/mach-omap1/timer32k.c           |   19 +++++-
 arch/arm/mach-omap2/timer.c              |  112 ++++++++++++++++++++++++------
 arch/arm/plat-omap/counter_32k.c         |   91 ++++++++++--------------
 arch/arm/plat-omap/include/plat/common.h |    2 +-
 4 files changed, 147 insertions(+), 77 deletions(-)

diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index e3613a8..eae49c3 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -71,6 +71,7 @@

 /* 16xx specific defines */
 #define OMAP1_32K_TIMER_BASE		0xfffb9000
+#define OMAP1_32KSYNC_TIMER_BASE	0xfffbc400
 #define OMAP1_32K_TIMER_CR		0x08
 #define OMAP1_32K_TIMER_TVR		0x00
 #define OMAP1_32K_TIMER_TCR		0x04
@@ -186,8 +187,22 @@ int __init omap_32k_timer_init(void)
 {
 	int ret = -ENODEV;

-	if (cpu_is_omap16xx())
-		ret = omap_init_clocksource_32k();
+	if (cpu_is_omap16xx()) {
+		void __iomem *base;
+		struct clk *sync32k_ick;
+
+		base = ioremap(OMAP1_32KSYNC_TIMER_BASE, SZ_1K);
+		if (!base) {
+			pr_err("32k_counter: failed to map base addr\n");
+			return -ENODEV;
+		}
+
+		sync32k_ick = clk_get(NULL, "omap_32ksync_ick");
+		if (!IS_ERR(sync32k_ick))
+			clk_enable(sync32k_ick);
+
+		ret = omap_init_clocksource_32k(base);
+	}

 	if (!ret)
 		omap_init_32k_timer();
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 777f84b..30824b5 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -243,22 +243,8 @@ static void __init omap2_gp_clockevent_init(int gptimer_id,
 }

 /* Clocksource code */
-
-#ifdef CONFIG_OMAP_32K_TIMER
-/*
- * When 32k-timer is enabled, don't use GPTimer for clocksource
- * instead, just leave default clocksource which uses the 32k
- * sync counter.  See clocksource setup in plat-omap/counter_32k.c
- */
-
-static void __init omap2_gp_clocksource_init(int unused, const char *dummy)
-{
-	omap_init_clocksource_32k();
-}
-
-#else
-
 static struct omap_dm_timer clksrc;
+static bool use_gptimer_clksrc;

 /*
  * clocksource
@@ -285,7 +271,46 @@ static u32 notrace dmtimer_read_sched_clock(void)
 }

 /* Setup free-running counter for clocksource */
-static void __init omap2_gp_clocksource_init(int gptimer_id,
+static int __init omap2_sync32k_clocksource_init(void)
+{
+	int ret;
+	struct omap_hwmod *oh;
+	void __iomem *vbase;
+	const char *oh_name = "counter_32k";
+
+	/*
+	 * First check hwmod data is available for sync32k counter
+	 */
+	oh = omap_hwmod_lookup(oh_name);
+	if (!oh || oh->slaves_cnt == 0)
+		return -ENODEV;
+
+	omap_hwmod_setup_one(oh_name);
+
+	vbase = omap_hwmod_get_mpu_rt_va(oh);
+	if (!vbase) {
+		pr_warn("%s: failed to get counter_32k resource\n", __func__);
+		return -ENXIO;
+	}
+
+	ret = omap_hwmod_enable(oh);
+	if (ret) {
+		pr_warn("%s: failed to enable counter_32k module (%d)\n",
+							__func__, ret);
+		return ret;
+	}
+
+	ret = omap_init_clocksource_32k(vbase);
+	if (ret) {
+		pr_warn("%s: failed to initialize counter_32k as a clocksource (%d)\n",
+							__func__, ret);
+		omap_hwmod_idle(oh);
+	}
+
+	return ret;
+}
+
+static void __init omap2_gptimer_clocksource_init(int gptimer_id,
 						const char *fck_source)
 {
 	int res;
@@ -293,9 +318,6 @@ static void __init omap2_gp_clocksource_init(int gptimer_id,
 	res = omap_dm_timer_init_one(&clksrc, gptimer_id, fck_source);
 	BUG_ON(res);

-	pr_info("OMAP clocksource: GPTIMER%d at %lu Hz\n",
-		gptimer_id, clksrc.rate);
-
 	__omap_dm_timer_load_start(&clksrc,
 			OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0, 1);
 	setup_sched_clock(dmtimer_read_sched_clock, 32, clksrc.rate);
@@ -303,15 +325,36 @@ static void __init omap2_gp_clocksource_init(int gptimer_id,
 	if (clocksource_register_hz(&clocksource_gpt, clksrc.rate))
 		pr_err("Could not register clocksource %s\n",
 			clocksource_gpt.name);
+	else
+		pr_info("OMAP clocksource: GPTIMER%d at %lu Hz\n",
+			gptimer_id, clksrc.rate);
+}
+
+static void __init omap2_clocksource_init(int gptimer_id,
+						const char *fck_source)
+{
+	/*
+	 * First give preference to kernel parameter configuration
+	 * by user (clocksource="gp_timer").
+	 *
+	 * In case of missing kernel parameter for clocksource,
+	 * first check for availability for 32k-sync timer, in case
+	 * of failure in finding 32k_counter module or registering
+	 * it as clocksource, execution will fallback to gp-timer.
+	 */
+	if (use_gptimer_clksrc == true)
+		omap2_gptimer_clocksource_init(gptimer_id, fck_source);
+	else if (omap2_sync32k_clocksource_init())
+		/* Fall back to gp-timer code */
+		omap2_gptimer_clocksource_init(gptimer_id, fck_source);
 }
-#endif

 #define OMAP_SYS_TIMER_INIT(name, clkev_nr, clkev_src,			\
 				clksrc_nr, clksrc_src)			\
 static void __init omap##name##_timer_init(void)			\
 {									\
 	omap2_gp_clockevent_init((clkev_nr), clkev_src);		\
-	omap2_gp_clocksource_init((clksrc_nr), clksrc_src);		\
+	omap2_clocksource_init((clksrc_nr), clksrc_src);		\
 }

 #define OMAP_SYS_TIMER(name)						\
@@ -342,7 +385,7 @@ static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
 static void __init omap4_timer_init(void)
 {
 	omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE);
-	omap2_gp_clocksource_init(2, OMAP4_MPU_SOURCE);
+	omap2_clocksource_init(2, OMAP4_MPU_SOURCE);
 #ifdef CONFIG_LOCAL_TIMERS
 	/* Local timers are not supprted on OMAP4430 ES1.0 */
 	if (omap_rev() != OMAP4430_REV_ES1_0) {
@@ -510,3 +553,28 @@ static int __init omap2_dm_timer_init(void)
 	return 0;
 }
 arch_initcall(omap2_dm_timer_init);
+
+/**
+ * omap2_override_clocksource - clocksource override with user configuration
+ *
+ * Allows user to override default clocksource, using kernel parameter
+ *   clocksource="gp_timer"	(For all OMAP2PLUS architectures)
+ *
+ * Note that, here we are using same standard kernel parameter "clocksource=",
+ * and not introducing any OMAP specific interface.
+ */
+static int __init omap2_override_clocksource(char *str)
+{
+	if (!str)
+		return 0;
+	/*
+	 * For OMAP architecture, we only have two options
+	 *    - sync_32k (default)
+	 *    - gp_timer (sys_clk based)
+	 */
+	if (!strcmp(str, "gp_timer"))
+		use_gptimer_clksrc = true;
+
+	return 0;
+}
+early_param("clocksource", omap2_override_clocksource);
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index 5068fe5..b2f634b 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -27,19 +27,20 @@

 #include <plat/clock.h>

+/* OMAP2_32KSYNCNT_CR_OFF: offset of 32ksync counter register */
+#define OMAP2_32KSYNCNT_CR_OFF		0x10
+
 /*
  * 32KHz clocksource ... always available, on pretty most chips except
  * OMAP 730 and 1510.  Other timers could be used as clocksources, with
  * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
  * but systems won't necessarily want to spend resources that way.
  */
-static void __iomem *timer_32k_base;
-
-#define OMAP16XX_TIMER_32K_SYNCHRONIZED		0xfffbc410
+static void __iomem *sync32k_cnt_reg;

 static u32 notrace omap_32k_read_sched_clock(void)
 {
-	return timer_32k_base ? __raw_readl(timer_32k_base) : 0;
+	return sync32k_cnt_reg ? __raw_readl(sync32k_cnt_reg) : 0;
 }

 /**
@@ -59,7 +60,7 @@ void read_persistent_clock(struct timespec *ts)
 	struct timespec *tsp = &persistent_ts;

 	last_cycles = cycles;
-	cycles = timer_32k_base ? __raw_readl(timer_32k_base) : 0;
+	cycles = sync32k_cnt_reg ? __raw_readl(sync32k_cnt_reg) : 0;
 	delta = cycles - last_cycles;

 	nsecs = clocksource_cyc2ns(delta, persistent_mult, persistent_shift);
@@ -68,54 +69,40 @@ void read_persistent_clock(struct timespec *ts)
 	*ts = *tsp;
 }

-int __init omap_init_clocksource_32k(void)
+/**
+ * omap_init_clocksource_32k - setup and register counter 32k as a
+ * kernel clocksource
+ * @pbase: base addr of counter_32k module
+ * @size: size of counter_32k to map
+ *
+ * Returns 0 upon success or negative error code upon failure.
+ *
+ */
+int __init omap_init_clocksource_32k(void __iomem *vbase)
 {
-	static char err[] __initdata = KERN_ERR
-			"%s: can't register clocksource!\n";
-
-	if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
-		u32 pbase;
-		unsigned long size = SZ_4K;
-		void __iomem *base;
-		struct clk *sync_32k_ick;
-
-		if (cpu_is_omap16xx()) {
-			pbase = OMAP16XX_TIMER_32K_SYNCHRONIZED;
-			size = SZ_1K;
-		} else if (cpu_is_omap2420())
-			pbase = OMAP2420_32KSYNCT_BASE + 0x10;
-		else if (cpu_is_omap2430())
-			pbase = OMAP2430_32KSYNCT_BASE + 0x10;
-		else if (cpu_is_omap34xx())
-			pbase = OMAP3430_32KSYNCT_BASE + 0x10;
-		else if (cpu_is_omap44xx())
-			pbase = OMAP4430_32KSYNCT_BASE + 0x10;
-		else
-			return -ENODEV;
-
-		/* For this to work we must have a static mapping in io.c for this area */
-		base = ioremap(pbase, size);
-		if (!base)
-			return -ENODEV;
-
-		sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
-		if (!IS_ERR(sync_32k_ick))
-			clk_enable(sync_32k_ick);
-
-		timer_32k_base = base;
-
-		/*
-		 * 120000 rough estimate from the calculations in
-		 * __clocksource_updatefreq_scale.
-		 */
-		clocks_calc_mult_shift(&persistent_mult, &persistent_shift,
-				32768, NSEC_PER_SEC, 120000);
-
-		if (clocksource_mmio_init(base, "32k_counter", 32768, 250, 32,
-					  clocksource_mmio_readl_up))
-			printk(err, "32k_counter");
-
-		setup_sched_clock(omap_32k_read_sched_clock, 32, 32768);
+	int ret;
+
+	/*
+	 * 32k sync Counter register offset is at 0x10
+	 */
+	sync32k_cnt_reg = vbase + OMAP2_32KSYNCNT_CR_OFF;
+
+	/*
+	 * 120000 rough estimate from the calculations in
+	 * __clocksource_updatefreq_scale.
+	 */
+	clocks_calc_mult_shift(&persistent_mult, &persistent_shift,
+			32768, NSEC_PER_SEC, 120000);
+
+	ret = clocksource_mmio_init(sync32k_cnt_reg, "32k_counter", 32768,
+				250, 32, clocksource_mmio_readl_up);
+	if (ret) {
+		pr_err("32k_counter: can't register clocksource\n");
+		return ret;
 	}
+
+	setup_sched_clock(omap_32k_read_sched_clock, 32, 32768);
+	pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n");
+
 	return 0;
 }
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index a557b84..d1cb6f5 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -30,7 +30,7 @@
 #include <plat/i2c.h>
 #include <plat/omap_hwmod.h>

-extern int __init omap_init_clocksource_32k(void);
+extern int __init omap_init_clocksource_32k(void __iomem *vbase);

 extern void __init omap_check_revision(void);

--
1.7.0.4


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

* [PATCH-V6 3/3] ARM: OMAP: Make OMAP clocksource source selection using kernel param
@ 2012-05-02 13:56   ` Vaibhav Hiremath
  0 siblings, 0 replies; 28+ messages in thread
From: Vaibhav Hiremath @ 2012-05-02 13:56 UTC (permalink / raw)
  To: linux-arm-kernel

Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -

1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.

The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.

Option 3 will still work but it is no better than 32K sync-timer
based clocksource.

We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.

Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.

And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.

So, the solution is,

Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.

Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
---
Two of the original patch-series (1/3 and 2/3) has already been
accepted and queued by Paul, so removing them.
New 2 patches have been added to the series,
	- OMAP2 timer32k cleanup, check for return values.
	- Changed name of system timers, "gp timer" => "gp_timer".

 arch/arm/mach-omap1/timer32k.c           |   19 +++++-
 arch/arm/mach-omap2/timer.c              |  112 ++++++++++++++++++++++++------
 arch/arm/plat-omap/counter_32k.c         |   91 ++++++++++--------------
 arch/arm/plat-omap/include/plat/common.h |    2 +-
 4 files changed, 147 insertions(+), 77 deletions(-)

diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index e3613a8..eae49c3 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -71,6 +71,7 @@

 /* 16xx specific defines */
 #define OMAP1_32K_TIMER_BASE		0xfffb9000
+#define OMAP1_32KSYNC_TIMER_BASE	0xfffbc400
 #define OMAP1_32K_TIMER_CR		0x08
 #define OMAP1_32K_TIMER_TVR		0x00
 #define OMAP1_32K_TIMER_TCR		0x04
@@ -186,8 +187,22 @@ int __init omap_32k_timer_init(void)
 {
 	int ret = -ENODEV;

-	if (cpu_is_omap16xx())
-		ret = omap_init_clocksource_32k();
+	if (cpu_is_omap16xx()) {
+		void __iomem *base;
+		struct clk *sync32k_ick;
+
+		base = ioremap(OMAP1_32KSYNC_TIMER_BASE, SZ_1K);
+		if (!base) {
+			pr_err("32k_counter: failed to map base addr\n");
+			return -ENODEV;
+		}
+
+		sync32k_ick = clk_get(NULL, "omap_32ksync_ick");
+		if (!IS_ERR(sync32k_ick))
+			clk_enable(sync32k_ick);
+
+		ret = omap_init_clocksource_32k(base);
+	}

 	if (!ret)
 		omap_init_32k_timer();
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 777f84b..30824b5 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -243,22 +243,8 @@ static void __init omap2_gp_clockevent_init(int gptimer_id,
 }

 /* Clocksource code */
-
-#ifdef CONFIG_OMAP_32K_TIMER
-/*
- * When 32k-timer is enabled, don't use GPTimer for clocksource
- * instead, just leave default clocksource which uses the 32k
- * sync counter.  See clocksource setup in plat-omap/counter_32k.c
- */
-
-static void __init omap2_gp_clocksource_init(int unused, const char *dummy)
-{
-	omap_init_clocksource_32k();
-}
-
-#else
-
 static struct omap_dm_timer clksrc;
+static bool use_gptimer_clksrc;

 /*
  * clocksource
@@ -285,7 +271,46 @@ static u32 notrace dmtimer_read_sched_clock(void)
 }

 /* Setup free-running counter for clocksource */
-static void __init omap2_gp_clocksource_init(int gptimer_id,
+static int __init omap2_sync32k_clocksource_init(void)
+{
+	int ret;
+	struct omap_hwmod *oh;
+	void __iomem *vbase;
+	const char *oh_name = "counter_32k";
+
+	/*
+	 * First check hwmod data is available for sync32k counter
+	 */
+	oh = omap_hwmod_lookup(oh_name);
+	if (!oh || oh->slaves_cnt == 0)
+		return -ENODEV;
+
+	omap_hwmod_setup_one(oh_name);
+
+	vbase = omap_hwmod_get_mpu_rt_va(oh);
+	if (!vbase) {
+		pr_warn("%s: failed to get counter_32k resource\n", __func__);
+		return -ENXIO;
+	}
+
+	ret = omap_hwmod_enable(oh);
+	if (ret) {
+		pr_warn("%s: failed to enable counter_32k module (%d)\n",
+							__func__, ret);
+		return ret;
+	}
+
+	ret = omap_init_clocksource_32k(vbase);
+	if (ret) {
+		pr_warn("%s: failed to initialize counter_32k as a clocksource (%d)\n",
+							__func__, ret);
+		omap_hwmod_idle(oh);
+	}
+
+	return ret;
+}
+
+static void __init omap2_gptimer_clocksource_init(int gptimer_id,
 						const char *fck_source)
 {
 	int res;
@@ -293,9 +318,6 @@ static void __init omap2_gp_clocksource_init(int gptimer_id,
 	res = omap_dm_timer_init_one(&clksrc, gptimer_id, fck_source);
 	BUG_ON(res);

-	pr_info("OMAP clocksource: GPTIMER%d at %lu Hz\n",
-		gptimer_id, clksrc.rate);
-
 	__omap_dm_timer_load_start(&clksrc,
 			OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0, 1);
 	setup_sched_clock(dmtimer_read_sched_clock, 32, clksrc.rate);
@@ -303,15 +325,36 @@ static void __init omap2_gp_clocksource_init(int gptimer_id,
 	if (clocksource_register_hz(&clocksource_gpt, clksrc.rate))
 		pr_err("Could not register clocksource %s\n",
 			clocksource_gpt.name);
+	else
+		pr_info("OMAP clocksource: GPTIMER%d at %lu Hz\n",
+			gptimer_id, clksrc.rate);
+}
+
+static void __init omap2_clocksource_init(int gptimer_id,
+						const char *fck_source)
+{
+	/*
+	 * First give preference to kernel parameter configuration
+	 * by user (clocksource="gp_timer").
+	 *
+	 * In case of missing kernel parameter for clocksource,
+	 * first check for availability for 32k-sync timer, in case
+	 * of failure in finding 32k_counter module or registering
+	 * it as clocksource, execution will fallback to gp-timer.
+	 */
+	if (use_gptimer_clksrc == true)
+		omap2_gptimer_clocksource_init(gptimer_id, fck_source);
+	else if (omap2_sync32k_clocksource_init())
+		/* Fall back to gp-timer code */
+		omap2_gptimer_clocksource_init(gptimer_id, fck_source);
 }
-#endif

 #define OMAP_SYS_TIMER_INIT(name, clkev_nr, clkev_src,			\
 				clksrc_nr, clksrc_src)			\
 static void __init omap##name##_timer_init(void)			\
 {									\
 	omap2_gp_clockevent_init((clkev_nr), clkev_src);		\
-	omap2_gp_clocksource_init((clksrc_nr), clksrc_src);		\
+	omap2_clocksource_init((clksrc_nr), clksrc_src);		\
 }

 #define OMAP_SYS_TIMER(name)						\
@@ -342,7 +385,7 @@ static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
 static void __init omap4_timer_init(void)
 {
 	omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE);
-	omap2_gp_clocksource_init(2, OMAP4_MPU_SOURCE);
+	omap2_clocksource_init(2, OMAP4_MPU_SOURCE);
 #ifdef CONFIG_LOCAL_TIMERS
 	/* Local timers are not supprted on OMAP4430 ES1.0 */
 	if (omap_rev() != OMAP4430_REV_ES1_0) {
@@ -510,3 +553,28 @@ static int __init omap2_dm_timer_init(void)
 	return 0;
 }
 arch_initcall(omap2_dm_timer_init);
+
+/**
+ * omap2_override_clocksource - clocksource override with user configuration
+ *
+ * Allows user to override default clocksource, using kernel parameter
+ *   clocksource="gp_timer"	(For all OMAP2PLUS architectures)
+ *
+ * Note that, here we are using same standard kernel parameter "clocksource=",
+ * and not introducing any OMAP specific interface.
+ */
+static int __init omap2_override_clocksource(char *str)
+{
+	if (!str)
+		return 0;
+	/*
+	 * For OMAP architecture, we only have two options
+	 *    - sync_32k (default)
+	 *    - gp_timer (sys_clk based)
+	 */
+	if (!strcmp(str, "gp_timer"))
+		use_gptimer_clksrc = true;
+
+	return 0;
+}
+early_param("clocksource", omap2_override_clocksource);
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index 5068fe5..b2f634b 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -27,19 +27,20 @@

 #include <plat/clock.h>

+/* OMAP2_32KSYNCNT_CR_OFF: offset of 32ksync counter register */
+#define OMAP2_32KSYNCNT_CR_OFF		0x10
+
 /*
  * 32KHz clocksource ... always available, on pretty most chips except
  * OMAP 730 and 1510.  Other timers could be used as clocksources, with
  * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
  * but systems won't necessarily want to spend resources that way.
  */
-static void __iomem *timer_32k_base;
-
-#define OMAP16XX_TIMER_32K_SYNCHRONIZED		0xfffbc410
+static void __iomem *sync32k_cnt_reg;

 static u32 notrace omap_32k_read_sched_clock(void)
 {
-	return timer_32k_base ? __raw_readl(timer_32k_base) : 0;
+	return sync32k_cnt_reg ? __raw_readl(sync32k_cnt_reg) : 0;
 }

 /**
@@ -59,7 +60,7 @@ void read_persistent_clock(struct timespec *ts)
 	struct timespec *tsp = &persistent_ts;

 	last_cycles = cycles;
-	cycles = timer_32k_base ? __raw_readl(timer_32k_base) : 0;
+	cycles = sync32k_cnt_reg ? __raw_readl(sync32k_cnt_reg) : 0;
 	delta = cycles - last_cycles;

 	nsecs = clocksource_cyc2ns(delta, persistent_mult, persistent_shift);
@@ -68,54 +69,40 @@ void read_persistent_clock(struct timespec *ts)
 	*ts = *tsp;
 }

-int __init omap_init_clocksource_32k(void)
+/**
+ * omap_init_clocksource_32k - setup and register counter 32k as a
+ * kernel clocksource
+ * @pbase: base addr of counter_32k module
+ * @size: size of counter_32k to map
+ *
+ * Returns 0 upon success or negative error code upon failure.
+ *
+ */
+int __init omap_init_clocksource_32k(void __iomem *vbase)
 {
-	static char err[] __initdata = KERN_ERR
-			"%s: can't register clocksource!\n";
-
-	if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
-		u32 pbase;
-		unsigned long size = SZ_4K;
-		void __iomem *base;
-		struct clk *sync_32k_ick;
-
-		if (cpu_is_omap16xx()) {
-			pbase = OMAP16XX_TIMER_32K_SYNCHRONIZED;
-			size = SZ_1K;
-		} else if (cpu_is_omap2420())
-			pbase = OMAP2420_32KSYNCT_BASE + 0x10;
-		else if (cpu_is_omap2430())
-			pbase = OMAP2430_32KSYNCT_BASE + 0x10;
-		else if (cpu_is_omap34xx())
-			pbase = OMAP3430_32KSYNCT_BASE + 0x10;
-		else if (cpu_is_omap44xx())
-			pbase = OMAP4430_32KSYNCT_BASE + 0x10;
-		else
-			return -ENODEV;
-
-		/* For this to work we must have a static mapping in io.c for this area */
-		base = ioremap(pbase, size);
-		if (!base)
-			return -ENODEV;
-
-		sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
-		if (!IS_ERR(sync_32k_ick))
-			clk_enable(sync_32k_ick);
-
-		timer_32k_base = base;
-
-		/*
-		 * 120000 rough estimate from the calculations in
-		 * __clocksource_updatefreq_scale.
-		 */
-		clocks_calc_mult_shift(&persistent_mult, &persistent_shift,
-				32768, NSEC_PER_SEC, 120000);
-
-		if (clocksource_mmio_init(base, "32k_counter", 32768, 250, 32,
-					  clocksource_mmio_readl_up))
-			printk(err, "32k_counter");
-
-		setup_sched_clock(omap_32k_read_sched_clock, 32, 32768);
+	int ret;
+
+	/*
+	 * 32k sync Counter register offset is at 0x10
+	 */
+	sync32k_cnt_reg = vbase + OMAP2_32KSYNCNT_CR_OFF;
+
+	/*
+	 * 120000 rough estimate from the calculations in
+	 * __clocksource_updatefreq_scale.
+	 */
+	clocks_calc_mult_shift(&persistent_mult, &persistent_shift,
+			32768, NSEC_PER_SEC, 120000);
+
+	ret = clocksource_mmio_init(sync32k_cnt_reg, "32k_counter", 32768,
+				250, 32, clocksource_mmio_readl_up);
+	if (ret) {
+		pr_err("32k_counter: can't register clocksource\n");
+		return ret;
 	}
+
+	setup_sched_clock(omap_32k_read_sched_clock, 32, 32768);
+	pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n");
+
 	return 0;
 }
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index a557b84..d1cb6f5 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -30,7 +30,7 @@
 #include <plat/i2c.h>
 #include <plat/omap_hwmod.h>

-extern int __init omap_init_clocksource_32k(void);
+extern int __init omap_init_clocksource_32k(void __iomem *vbase);

 extern void __init omap_check_revision(void);

--
1.7.0.4

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

* Re: [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
  2012-05-02 13:56 ` Vaibhav Hiremath
@ 2012-05-02 19:56   ` Jon Hunter
  -1 siblings, 0 replies; 28+ messages in thread
From: Jon Hunter @ 2012-05-02 19:56 UTC (permalink / raw)
  To: Vaibhav Hiremath
  Cc: linux-omap, khilman, paul, b-cousson, tony, santosh.shilimkar,
	linux-arm-kernel

Hi Vaibhav,

On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
> Current OMAP code supports couple of clocksource options based
> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
> 
> This patch series cleans up the existing 32k-sync timer implementation,
> movind SoC init code to respective files (mach-omap1/timer32k.c and
> mach-omap2/timer.c) and uses kernel parameter to override the default
> clocksource of "counter_32k", also in order to support some OMAP based
> derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
> adds hwmod lookup for omap2+ devices, and if lookup fails then
> fall back to gp-timer.
> 
> if(use_gptimer_clksrc == true)
> 	gptimer clocksource init;
> else if (counter_32 init == false)
> 	/* Fallback to gptimer */
> 	gptimer clocksource init(;
> 
> With this, we should be able to support multi-omap boot
> including devices with/without 32k-sync timer.
> 
> This patch-series has been boot tested on AM37xEVM platform, it
> would be helpful if somebody help me to validate it on OMAP1/2
> platforms.
> 
> The patches are also available at (based on linux-omap/master) -
> https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup

I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?

Cheers
Jon

>From 2a213a6d5f5894bc1c5262f2724508eaef21c7a5 Mon Sep 17 00:00:00 2001
From: Jon Hunter <jon-hunter@ti.com>
Date: Wed, 2 May 2012 14:45:03 -0500
Subject: [PATCH] ARM: OMAP4: Enable counter_32k HWMOD for OMAP4 devices

HWMOD is being used to determine if the 32k sync timer is present in order
to use the timer as the clocksource for the kernel. Enable the counter_32k
HWMOD for OMAP4 devices so that the 32k sync timer will be used by default.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 6abc757..f0455d0 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -5561,7 +5561,7 @@ static __initdata struct omap_hwmod *omap44xx_hwmods[] = {
 	&omap44xx_bandgap_hwmod,
 
 	/* counter class */
-/*	&omap44xx_counter_32k_hwmod, */
+	&omap44xx_counter_32k_hwmod,
 
 	/* dma class */
 	&omap44xx_dma_system_hwmod,
-- 
1.7.5.4

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

* [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
@ 2012-05-02 19:56   ` Jon Hunter
  0 siblings, 0 replies; 28+ messages in thread
From: Jon Hunter @ 2012-05-02 19:56 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Vaibhav,

On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
> Current OMAP code supports couple of clocksource options based
> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
> 
> This patch series cleans up the existing 32k-sync timer implementation,
> movind SoC init code to respective files (mach-omap1/timer32k.c and
> mach-omap2/timer.c) and uses kernel parameter to override the default
> clocksource of "counter_32k", also in order to support some OMAP based
> derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
> adds hwmod lookup for omap2+ devices, and if lookup fails then
> fall back to gp-timer.
> 
> if(use_gptimer_clksrc == true)
> 	gptimer clocksource init;
> else if (counter_32 init == false)
> 	/* Fallback to gptimer */
> 	gptimer clocksource init(;
> 
> With this, we should be able to support multi-omap boot
> including devices with/without 32k-sync timer.
> 
> This patch-series has been boot tested on AM37xEVM platform, it
> would be helpful if somebody help me to validate it on OMAP1/2
> platforms.
> 
> The patches are also available at (based on linux-omap/master) -
> https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup

I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?

Cheers
Jon

>From 2a213a6d5f5894bc1c5262f2724508eaef21c7a5 Mon Sep 17 00:00:00 2001
From: Jon Hunter <jon-hunter@ti.com>
Date: Wed, 2 May 2012 14:45:03 -0500
Subject: [PATCH] ARM: OMAP4: Enable counter_32k HWMOD for OMAP4 devices

HWMOD is being used to determine if the 32k sync timer is present in order
to use the timer as the clocksource for the kernel. Enable the counter_32k
HWMOD for OMAP4 devices so that the 32k sync timer will be used by default.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 6abc757..f0455d0 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -5561,7 +5561,7 @@ static __initdata struct omap_hwmod *omap44xx_hwmods[] = {
 	&omap44xx_bandgap_hwmod,
 
 	/* counter class */
-/*	&omap44xx_counter_32k_hwmod, */
+	&omap44xx_counter_32k_hwmod,
 
 	/* dma class */
 	&omap44xx_dma_system_hwmod,
-- 
1.7.5.4

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

* Re: [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
  2012-05-02 13:56   ` Vaibhav Hiremath
@ 2012-05-02 20:08     ` Kevin Hilman
  -1 siblings, 0 replies; 28+ messages in thread
From: Kevin Hilman @ 2012-05-02 20:08 UTC (permalink / raw)
  To: Vaibhav Hiremath
  Cc: linux-omap, tony, paul, santosh.shilimkar, b-cousson, linux-arm-kernel

Vaibhav Hiremath <hvaibhav@ti.com> writes:

> OMAP1, omap_32k_timer_init() function always returns "true",
> irrespective of whether error occurred while initializing 32k sync
> counter as a kernel clocksource or not and execution will never
> fallback to mpu_timer clocksource init code.
>
> This patch adds check for return value from function
> omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
> in case of failure/error from omap_init_clocksource_32k().
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Benoit Cousson <b-cousson@ti.com>
> ---
> This is new patch addition compared to original series (<=V5).
>
> Also, note that, this patch is only compile tested, since
> I do not have omap1 board with me to validate it.
> Kevin, can you help me to validate it.

I boot tested on OMAP1 (5912/OSK) with 32k timer and MPU timer
Kconfigs.  Works fine, but needs small change below for compile warnings.

Otherwise, looks good.

Acked-by: Kevin Hilman <khilman@ti.com>

>  arch/arm/mach-omap1/common.h   |   10 +++++++++-
>  arch/arm/mach-omap1/time.c     |   16 +---------------
>  arch/arm/mach-omap1/timer32k.c |   13 +++++++++----
>  3 files changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
> index 8cc616e..e8c9ad3 100644
> --- a/arch/arm/mach-omap1/common.h
> +++ b/arch/arm/mach-omap1/common.h
> @@ -63,7 +63,15 @@ extern void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
>  			       unsigned int ctrl);
>
>  extern struct sys_timer omap1_timer;
> -extern bool omap_32k_timer_init(void);
> +
> +#ifdef CONFIG_OMAP_32K_TIMER
> +extern int omap_32k_timer_init(void);
> +#else
> +static int __init omap_32k_timer_init(void)

This needs to be inline.   Compile test on OMAP1 with
CONFIG_OMAP_32K_TIMER=n to see why.

> +{
> +	return -ENODEV;
> +}
> +#endif
>
>  extern u32 omap_irq_flags;
>
> diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
> index 4d8dd9a..4062480 100644
> --- a/arch/arm/mach-omap1/time.c
> +++ b/arch/arm/mach-omap1/time.c
> @@ -232,20 +232,6 @@ static inline void omap_mpu_timer_init(void)
>  }
>  #endif	/* CONFIG_OMAP_MPU_TIMER */
>
> -static inline int omap_32k_timer_usable(void)
> -{
> -	int res = false;
> -
> -	if (cpu_is_omap730() || cpu_is_omap15xx())
> -		return res;
> -
> -#ifdef CONFIG_OMAP_32K_TIMER
> -	res = omap_32k_timer_init();
> -#endif
> -
> -	return res;
> -}
> -
>  /*
>   * ---------------------------------------------------------------------------
>   * Timer initialization
> @@ -253,7 +239,7 @@ static inline int omap_32k_timer_usable(void)
>   */
>  static void __init omap1_timer_init(void)
>  {
> -	if (!omap_32k_timer_usable())
> +	if (omap_32k_timer_init() != 0)
>  		omap_mpu_timer_init();
>  }
>
> diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
> index 325b9a0..e3613a8 100644
> --- a/arch/arm/mach-omap1/timer32k.c
> +++ b/arch/arm/mach-omap1/timer32k.c
> @@ -182,10 +182,15 @@ static __init void omap_init_32k_timer(void)
>   * Timer initialization
>   * ---------------------------------------------------------------------------
>   */
> -bool __init omap_32k_timer_init(void)
> +int __init omap_32k_timer_init(void)
>  {
> -	omap_init_clocksource_32k();
> -	omap_init_32k_timer();
> +	int ret = -ENODEV;
>
> -	return true;
> +	if (cpu_is_omap16xx())
> +		ret = omap_init_clocksource_32k();
> +
> +	if (!ret)
> +		omap_init_32k_timer();
> +
> +	return ret;
>  }
> --
> 1.7.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] 28+ messages in thread

* [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
@ 2012-05-02 20:08     ` Kevin Hilman
  0 siblings, 0 replies; 28+ messages in thread
From: Kevin Hilman @ 2012-05-02 20:08 UTC (permalink / raw)
  To: linux-arm-kernel

Vaibhav Hiremath <hvaibhav@ti.com> writes:

> OMAP1, omap_32k_timer_init() function always returns "true",
> irrespective of whether error occurred while initializing 32k sync
> counter as a kernel clocksource or not and execution will never
> fallback to mpu_timer clocksource init code.
>
> This patch adds check for return value from function
> omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
> in case of failure/error from omap_init_clocksource_32k().
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Benoit Cousson <b-cousson@ti.com>
> ---
> This is new patch addition compared to original series (<=V5).
>
> Also, note that, this patch is only compile tested, since
> I do not have omap1 board with me to validate it.
> Kevin, can you help me to validate it.

I boot tested on OMAP1 (5912/OSK) with 32k timer and MPU timer
Kconfigs.  Works fine, but needs small change below for compile warnings.

Otherwise, looks good.

Acked-by: Kevin Hilman <khilman@ti.com>

>  arch/arm/mach-omap1/common.h   |   10 +++++++++-
>  arch/arm/mach-omap1/time.c     |   16 +---------------
>  arch/arm/mach-omap1/timer32k.c |   13 +++++++++----
>  3 files changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
> index 8cc616e..e8c9ad3 100644
> --- a/arch/arm/mach-omap1/common.h
> +++ b/arch/arm/mach-omap1/common.h
> @@ -63,7 +63,15 @@ extern void omap1_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
>  			       unsigned int ctrl);
>
>  extern struct sys_timer omap1_timer;
> -extern bool omap_32k_timer_init(void);
> +
> +#ifdef CONFIG_OMAP_32K_TIMER
> +extern int omap_32k_timer_init(void);
> +#else
> +static int __init omap_32k_timer_init(void)

This needs to be inline.   Compile test on OMAP1 with
CONFIG_OMAP_32K_TIMER=n to see why.

> +{
> +	return -ENODEV;
> +}
> +#endif
>
>  extern u32 omap_irq_flags;
>
> diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
> index 4d8dd9a..4062480 100644
> --- a/arch/arm/mach-omap1/time.c
> +++ b/arch/arm/mach-omap1/time.c
> @@ -232,20 +232,6 @@ static inline void omap_mpu_timer_init(void)
>  }
>  #endif	/* CONFIG_OMAP_MPU_TIMER */
>
> -static inline int omap_32k_timer_usable(void)
> -{
> -	int res = false;
> -
> -	if (cpu_is_omap730() || cpu_is_omap15xx())
> -		return res;
> -
> -#ifdef CONFIG_OMAP_32K_TIMER
> -	res = omap_32k_timer_init();
> -#endif
> -
> -	return res;
> -}
> -
>  /*
>   * ---------------------------------------------------------------------------
>   * Timer initialization
> @@ -253,7 +239,7 @@ static inline int omap_32k_timer_usable(void)
>   */
>  static void __init omap1_timer_init(void)
>  {
> -	if (!omap_32k_timer_usable())
> +	if (omap_32k_timer_init() != 0)
>  		omap_mpu_timer_init();
>  }
>
> diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
> index 325b9a0..e3613a8 100644
> --- a/arch/arm/mach-omap1/timer32k.c
> +++ b/arch/arm/mach-omap1/timer32k.c
> @@ -182,10 +182,15 @@ static __init void omap_init_32k_timer(void)
>   * Timer initialization
>   * ---------------------------------------------------------------------------
>   */
> -bool __init omap_32k_timer_init(void)
> +int __init omap_32k_timer_init(void)
>  {
> -	omap_init_clocksource_32k();
> -	omap_init_32k_timer();
> +	int ret = -ENODEV;
>
> -	return true;
> +	if (cpu_is_omap16xx())
> +		ret = omap_init_clocksource_32k();
> +
> +	if (!ret)
> +		omap_init_32k_timer();
> +
> +	return ret;
>  }
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH-V6 2/3] ARM: OMAP2+: Replace space=>underscore in the name field of system timers
  2012-05-02 13:56   ` Vaibhav Hiremath
@ 2012-05-02 20:09     ` Kevin Hilman
  -1 siblings, 0 replies; 28+ messages in thread
From: Kevin Hilman @ 2012-05-02 20:09 UTC (permalink / raw)
  To: Vaibhav Hiremath
  Cc: linux-omap, tony, paul, santosh.shilimkar, b-cousson, linux-arm-kernel

Vaibhav Hiremath <hvaibhav@ti.com> writes:

> Depending on the bootloader, passing command-line arguments
> with spaces may have issues. Some bootloaders doesn't seem
> to pass along the quotes, passing only 'gp' part of the string,
> which leads to wrong clocksource override configuration.

For clarity, it would help to specify which command-line options this
affects

> So this patch changes "gp timer" => "gp_timer", for clockevent,
> clocksource and timer irq_handler.
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Benoit Cousson <b-cousson@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Kevin Hilman <khilman@ti.com>

With the change above,

Acked-by: Kevin Hilman <khilman@ti.com>


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

* [PATCH-V6 2/3] ARM: OMAP2+: Replace space=>underscore in the name field of system timers
@ 2012-05-02 20:09     ` Kevin Hilman
  0 siblings, 0 replies; 28+ messages in thread
From: Kevin Hilman @ 2012-05-02 20:09 UTC (permalink / raw)
  To: linux-arm-kernel

Vaibhav Hiremath <hvaibhav@ti.com> writes:

> Depending on the bootloader, passing command-line arguments
> with spaces may have issues. Some bootloaders doesn't seem
> to pass along the quotes, passing only 'gp' part of the string,
> which leads to wrong clocksource override configuration.

For clarity, it would help to specify which command-line options this
affects

> So this patch changes "gp timer" => "gp_timer", for clockevent,
> clocksource and timer irq_handler.
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Benoit Cousson <b-cousson@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Kevin Hilman <khilman@ti.com>

With the change above,

Acked-by: Kevin Hilman <khilman@ti.com>

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

* Re: [PATCH-V6 3/3] ARM: OMAP: Make OMAP clocksource source selection using kernel param
  2012-05-02 13:56   ` Vaibhav Hiremath
@ 2012-05-02 20:39     ` Kevin Hilman
  -1 siblings, 0 replies; 28+ messages in thread
From: Kevin Hilman @ 2012-05-02 20:39 UTC (permalink / raw)
  To: Vaibhav Hiremath
  Cc: linux-omap, tony, paul, santosh.shilimkar, b-cousson,
	linux-arm-kernel, Felipe Balbi, Tarun Kanti DebBarma, Ming Lei

Vaibhav Hiremath <hvaibhav@ti.com> writes:

> Current OMAP code supports couple of clocksource options based
> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
> So there can be 3 options -
>
> 1. 32KHz sync-timer
> 2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
> 3. 32KHz based gptimer.
>
> The optional gptimer based clocksource was added so that it can
> give the high precision than sync-timer, so expected usage was 2
> and not 3.
> Unfortunately option 2, clocksource doesn't meet the requirement of
> free-running clock as per clocksource need. It stops in low power states
> when sys_clock is cut. That makes gptimer based clocksource option
> useless for OMAP2/3/4 devices with sys_clock as a clock input.
> So, in order to use option 2, deeper idle state MUST be disabled.
>
> Option 3 will still work but it is no better than 32K sync-timer
> based clocksource.
>
> We must support both sync timer and gptimer based clocksource as
> some OMAP based derivative SoCs like AM33XX does not have the
> sync timer.
>
> Considering above, make sync-timer and gptimer clocksource runtime
> selectable so that both OMAP and AMXXXX continue to use the same code.
>
> And, in order to precisely configure/setup sched_clock for given
> clocksource, decision has to be made early enough in boot sequence.
>
> So, the solution is,
>
> Use standard kernel parameter ("clocksource=") to override
> default 32k_sync-timer, in addition to this, we also use hwmod database
> lookup mechanism, through which at run-time we can identify availability
> of 32k-sync timer on the device, else fall back to gptimer.
>
> Also, moved low-level SoC specific init code to respective files,
> (mach-omap1/timer32k.c and mach-omap2/timer.c)
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Benoit Cousson <b-cousson@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> Cc: Ming Lei <tom.leiming@gmail.com>

Reviewed-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>

tested on OMAP3530/Overo with default 32k timer and cmdline override for
GPtimer.

Kevin

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

* [PATCH-V6 3/3] ARM: OMAP: Make OMAP clocksource source selection using kernel param
@ 2012-05-02 20:39     ` Kevin Hilman
  0 siblings, 0 replies; 28+ messages in thread
From: Kevin Hilman @ 2012-05-02 20:39 UTC (permalink / raw)
  To: linux-arm-kernel

Vaibhav Hiremath <hvaibhav@ti.com> writes:

> Current OMAP code supports couple of clocksource options based
> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
> So there can be 3 options -
>
> 1. 32KHz sync-timer
> 2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
> 3. 32KHz based gptimer.
>
> The optional gptimer based clocksource was added so that it can
> give the high precision than sync-timer, so expected usage was 2
> and not 3.
> Unfortunately option 2, clocksource doesn't meet the requirement of
> free-running clock as per clocksource need. It stops in low power states
> when sys_clock is cut. That makes gptimer based clocksource option
> useless for OMAP2/3/4 devices with sys_clock as a clock input.
> So, in order to use option 2, deeper idle state MUST be disabled.
>
> Option 3 will still work but it is no better than 32K sync-timer
> based clocksource.
>
> We must support both sync timer and gptimer based clocksource as
> some OMAP based derivative SoCs like AM33XX does not have the
> sync timer.
>
> Considering above, make sync-timer and gptimer clocksource runtime
> selectable so that both OMAP and AMXXXX continue to use the same code.
>
> And, in order to precisely configure/setup sched_clock for given
> clocksource, decision has to be made early enough in boot sequence.
>
> So, the solution is,
>
> Use standard kernel parameter ("clocksource=") to override
> default 32k_sync-timer, in addition to this, we also use hwmod database
> lookup mechanism, through which at run-time we can identify availability
> of 32k-sync timer on the device, else fall back to gptimer.
>
> Also, moved low-level SoC specific init code to respective files,
> (mach-omap1/timer32k.c and mach-omap2/timer.c)
>
> Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Benoit Cousson <b-cousson@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> Cc: Ming Lei <tom.leiming@gmail.com>

Reviewed-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>

tested on OMAP3530/Overo with default 32k timer and cmdline override for
GPtimer.

Kevin

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

* RE: [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
  2012-05-02 19:56   ` Jon Hunter
@ 2012-05-03  5:07     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 28+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-03  5:07 UTC (permalink / raw)
  To: Hunter, Jon
  Cc: linux-omap, Hilman, Kevin, paul, Cousson, Benoit, tony,
	Shilimkar, Santosh, linux-arm-kernel

On Thu, May 03, 2012 at 01:26:18, Hunter, Jon wrote:
> Hi Vaibhav,
> 
> On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
> > Current OMAP code supports couple of clocksource options based
> > on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
> > and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
> > 
> > This patch series cleans up the existing 32k-sync timer implementation,
> > movind SoC init code to respective files (mach-omap1/timer32k.c and
> > mach-omap2/timer.c) and uses kernel parameter to override the default
> > clocksource of "counter_32k", also in order to support some OMAP based
> > derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
> > adds hwmod lookup for omap2+ devices, and if lookup fails then
> > fall back to gp-timer.
> > 
> > if(use_gptimer_clksrc == true)
> > 	gptimer clocksource init;
> > else if (counter_32 init == false)
> > 	/* Fallback to gptimer */
> > 	gptimer clocksource init(;
> > 
> > With this, we should be able to support multi-omap boot
> > including devices with/without 32k-sync timer.
> > 
> > This patch-series has been boot tested on AM37xEVM platform, it
> > would be helpful if somebody help me to validate it on OMAP1/2
> > platforms.
> > 
> > The patches are also available at (based on linux-omap/master) -
> > https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup
> 
> I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?
> 

The 32kcounter hwmod entry is already enabled in linux-omap/master branch.

Your baseline looks pretty old to me, are you not using linux-omap/master?
The hwmod data registration has now changed to ocp_if, and your patch still 
use hwmod data entry.

Can you please use linux-omap/master and test it?

Thanks,
Vaibhav

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

* [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
@ 2012-05-03  5:07     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 28+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-03  5:07 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, May 03, 2012 at 01:26:18, Hunter, Jon wrote:
> Hi Vaibhav,
> 
> On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
> > Current OMAP code supports couple of clocksource options based
> > on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
> > and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
> > 
> > This patch series cleans up the existing 32k-sync timer implementation,
> > movind SoC init code to respective files (mach-omap1/timer32k.c and
> > mach-omap2/timer.c) and uses kernel parameter to override the default
> > clocksource of "counter_32k", also in order to support some OMAP based
> > derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
> > adds hwmod lookup for omap2+ devices, and if lookup fails then
> > fall back to gp-timer.
> > 
> > if(use_gptimer_clksrc == true)
> > 	gptimer clocksource init;
> > else if (counter_32 init == false)
> > 	/* Fallback to gptimer */
> > 	gptimer clocksource init(;
> > 
> > With this, we should be able to support multi-omap boot
> > including devices with/without 32k-sync timer.
> > 
> > This patch-series has been boot tested on AM37xEVM platform, it
> > would be helpful if somebody help me to validate it on OMAP1/2
> > platforms.
> > 
> > The patches are also available at (based on linux-omap/master) -
> > https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup
> 
> I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?
> 

The 32kcounter hwmod entry is already enabled in linux-omap/master branch.

Your baseline looks pretty old to me, are you not using linux-omap/master?
The hwmod data registration has now changed to ocp_if, and your patch still 
use hwmod data entry.

Can you please use linux-omap/master and test it?

Thanks,
Vaibhav

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

* RE: [PATCH-V6 3/3] ARM: OMAP: Make OMAP clocksource source selection using kernel param
  2012-05-02 20:39     ` Kevin Hilman
@ 2012-05-03  8:06       ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 28+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-03  8:06 UTC (permalink / raw)
  To: Hilman, Kevin
  Cc: linux-omap, tony, paul, Shilimkar, Santosh, Cousson, Benoit,
	linux-arm-kernel, Balbi, Felipe, DebBarma, Tarun Kanti, Ming Lei

On Thu, May 03, 2012 at 02:09:59, Hilman, Kevin wrote:
> Vaibhav Hiremath <hvaibhav@ti.com> writes:
> 
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Felipe Balbi <balbi@ti.com>
> > Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> > Cc: Benoit Cousson <b-cousson@ti.com>
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Paul Walmsley <paul@pwsan.com>
> > Cc: Kevin Hilman <khilman@ti.com>
> > Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> > Cc: Ming Lei <tom.leiming@gmail.com>
> 
> Reviewed-by: Kevin Hilman <khilman@ti.com>
> Tested-by: Kevin Hilman <khilman@ti.com>
> 
> tested on OMAP3530/Overo with default 32k timer and cmdline override for
> GPtimer.
> 

Thanks Kevin, I have submitted V7 version of this series with your ack and 
tested-by.

Tony,
Can you queue it for v3.5?

Thanks,
Vaibhav


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

* [PATCH-V6 3/3] ARM: OMAP: Make OMAP clocksource source selection using kernel param
@ 2012-05-03  8:06       ` Hiremath, Vaibhav
  0 siblings, 0 replies; 28+ messages in thread
From: Hiremath, Vaibhav @ 2012-05-03  8:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, May 03, 2012 at 02:09:59, Hilman, Kevin wrote:
> Vaibhav Hiremath <hvaibhav@ti.com> writes:
> 
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Felipe Balbi <balbi@ti.com>
> > Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> > Cc: Benoit Cousson <b-cousson@ti.com>
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Paul Walmsley <paul@pwsan.com>
> > Cc: Kevin Hilman <khilman@ti.com>
> > Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> > Cc: Ming Lei <tom.leiming@gmail.com>
> 
> Reviewed-by: Kevin Hilman <khilman@ti.com>
> Tested-by: Kevin Hilman <khilman@ti.com>
> 
> tested on OMAP3530/Overo with default 32k timer and cmdline override for
> GPtimer.
> 

Thanks Kevin, I have submitted V7 version of this series with your ack and 
tested-by.

Tony,
Can you queue it for v3.5?

Thanks,
Vaibhav

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

* Re: [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
  2012-05-03  5:07     ` Hiremath, Vaibhav
@ 2012-05-03 18:19       ` Jon Hunter
  -1 siblings, 0 replies; 28+ messages in thread
From: Jon Hunter @ 2012-05-03 18:19 UTC (permalink / raw)
  To: Hiremath, Vaibhav
  Cc: linux-omap, Hilman, Kevin, paul, Cousson, Benoit, tony,
	Shilimkar, Santosh, linux-arm-kernel

Hi Vaibhav,

On 05/03/2012 12:07 AM, Hiremath, Vaibhav wrote:
> On Thu, May 03, 2012 at 01:26:18, Hunter, Jon wrote:
>> Hi Vaibhav,
>>
>> On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
>>> Current OMAP code supports couple of clocksource options based
>>> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
>>> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
>>>
>>> This patch series cleans up the existing 32k-sync timer implementation,
>>> movind SoC init code to respective files (mach-omap1/timer32k.c and
>>> mach-omap2/timer.c) and uses kernel parameter to override the default
>>> clocksource of "counter_32k", also in order to support some OMAP based
>>> derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
>>> adds hwmod lookup for omap2+ devices, and if lookup fails then
>>> fall back to gp-timer.
>>>
>>> if(use_gptimer_clksrc == true)
>>> 	gptimer clocksource init;
>>> else if (counter_32 init == false)
>>> 	/* Fallback to gptimer */
>>> 	gptimer clocksource init(;
>>>
>>> With this, we should be able to support multi-omap boot
>>> including devices with/without 32k-sync timer.
>>>
>>> This patch-series has been boot tested on AM37xEVM platform, it
>>> would be helpful if somebody help me to validate it on OMAP1/2
>>> platforms.
>>>
>>> The patches are also available at (based on linux-omap/master) -
>>> https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup
>>
>> I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?
>>
> 
> The 32kcounter hwmod entry is already enabled in linux-omap/master branch.
> 
> Your baseline looks pretty old to me, are you not using linux-omap/master?

Ha! My "old" baseline is the latest mainline kernel ;-)

I guess this is a bit out-dated in terms of omap now. Sorry I missed
that fact your patches were on top of the omap kernel in the changelog.

Cheers
Jon

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

* [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
@ 2012-05-03 18:19       ` Jon Hunter
  0 siblings, 0 replies; 28+ messages in thread
From: Jon Hunter @ 2012-05-03 18:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Vaibhav,

On 05/03/2012 12:07 AM, Hiremath, Vaibhav wrote:
> On Thu, May 03, 2012 at 01:26:18, Hunter, Jon wrote:
>> Hi Vaibhav,
>>
>> On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
>>> Current OMAP code supports couple of clocksource options based
>>> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
>>> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
>>>
>>> This patch series cleans up the existing 32k-sync timer implementation,
>>> movind SoC init code to respective files (mach-omap1/timer32k.c and
>>> mach-omap2/timer.c) and uses kernel parameter to override the default
>>> clocksource of "counter_32k", also in order to support some OMAP based
>>> derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
>>> adds hwmod lookup for omap2+ devices, and if lookup fails then
>>> fall back to gp-timer.
>>>
>>> if(use_gptimer_clksrc == true)
>>> 	gptimer clocksource init;
>>> else if (counter_32 init == false)
>>> 	/* Fallback to gptimer */
>>> 	gptimer clocksource init(;
>>>
>>> With this, we should be able to support multi-omap boot
>>> including devices with/without 32k-sync timer.
>>>
>>> This patch-series has been boot tested on AM37xEVM platform, it
>>> would be helpful if somebody help me to validate it on OMAP1/2
>>> platforms.
>>>
>>> The patches are also available at (based on linux-omap/master) -
>>> https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup
>>
>> I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?
>>
> 
> The 32kcounter hwmod entry is already enabled in linux-omap/master branch.
> 
> Your baseline looks pretty old to me, are you not using linux-omap/master?

Ha! My "old" baseline is the latest mainline kernel ;-)

I guess this is a bit out-dated in terms of omap now. Sorry I missed
that fact your patches were on top of the omap kernel in the changelog.

Cheers
Jon

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

* Re: [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
  2012-05-02 20:08     ` Kevin Hilman
@ 2012-05-04 17:43       ` Tony Lindgren
  -1 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2012-05-04 17:43 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Vaibhav Hiremath, linux-omap, paul, santosh.shilimkar, b-cousson,
	linux-arm-kernel, Kevin Hilman

Hi,

* Kevin Hilman <khilman@ti.com> [120502 13:11]:
> Vaibhav Hiremath <hvaibhav@ti.com> writes:
> 
> > OMAP1, omap_32k_timer_init() function always returns "true",
> > irrespective of whether error occurred while initializing 32k sync
> > counter as a kernel clocksource or not and execution will never
> > fallback to mpu_timer clocksource init code.
> >
> > This patch adds check for return value from function
> > omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
> > in case of failure/error from omap_init_clocksource_32k().
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Kevin Hilman <khilman@ti.com>
> > Cc: Paul Walmsley <paul@pwsan.com>
> > Cc: Benoit Cousson <b-cousson@ti.com>
> > ---
> > This is new patch addition compared to original series (<=V5).
> >
> > Also, note that, this patch is only compile tested, since
> > I do not have omap1 board with me to validate it.
> > Kevin, can you help me to validate it.
> 
> I boot tested on OMAP1 (5912/OSK) with 32k timer and MPU timer
> Kconfigs.  Works fine, but needs small change below for compile warnings.
> 
> Otherwise, looks good.

We need at least one tested-by on some 15xx platform for these changes.
Janusz, can you please give this series a try on your board too?

Regards,

Tony

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

* [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
@ 2012-05-04 17:43       ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2012-05-04 17:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

* Kevin Hilman <khilman@ti.com> [120502 13:11]:
> Vaibhav Hiremath <hvaibhav@ti.com> writes:
> 
> > OMAP1, omap_32k_timer_init() function always returns "true",
> > irrespective of whether error occurred while initializing 32k sync
> > counter as a kernel clocksource or not and execution will never
> > fallback to mpu_timer clocksource init code.
> >
> > This patch adds check for return value from function
> > omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
> > in case of failure/error from omap_init_clocksource_32k().
> >
> > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Kevin Hilman <khilman@ti.com>
> > Cc: Paul Walmsley <paul@pwsan.com>
> > Cc: Benoit Cousson <b-cousson@ti.com>
> > ---
> > This is new patch addition compared to original series (<=V5).
> >
> > Also, note that, this patch is only compile tested, since
> > I do not have omap1 board with me to validate it.
> > Kevin, can you help me to validate it.
> 
> I boot tested on OMAP1 (5912/OSK) with 32k timer and MPU timer
> Kconfigs.  Works fine, but needs small change below for compile warnings.
> 
> Otherwise, looks good.

We need at least one tested-by on some 15xx platform for these changes.
Janusz, can you please give this series a try on your board too?

Regards,

Tony

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

* Re: [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
  2012-05-04 17:43       ` Tony Lindgren
@ 2012-05-04 19:45         ` Janusz Krzysztofik
  -1 siblings, 0 replies; 28+ messages in thread
From: Janusz Krzysztofik @ 2012-05-04 19:45 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Vaibhav Hiremath, linux-omap, paul, santosh.shilimkar, b-cousson,
	linux-arm-kernel, Kevin Hilman

Dnia piątek, 4 maja 2012 10:43:02 Tony Lindgren pisze:
> Hi,
> 
> * Kevin Hilman <khilman@ti.com> [120502 13:11]:
> > Vaibhav Hiremath <hvaibhav@ti.com> writes:
> > 
> > > OMAP1, omap_32k_timer_init() function always returns "true",
> > > irrespective of whether error occurred while initializing 32k sync
> > > counter as a kernel clocksource or not and execution will never
> > > fallback to mpu_timer clocksource init code.
> > >
> > > This patch adds check for return value from function
> > > omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
> > > in case of failure/error from omap_init_clocksource_32k().
> > >
> > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > Cc: Tony Lindgren <tony@atomide.com>
> > > Cc: Kevin Hilman <khilman@ti.com>
> > > Cc: Paul Walmsley <paul@pwsan.com>
> > > Cc: Benoit Cousson <b-cousson@ti.com>
> > > ---
> > > This is new patch addition compared to original series (<=V5).
> > >
> > > Also, note that, this patch is only compile tested, since
> > > I do not have omap1 board with me to validate it.
> > > Kevin, can you help me to validate it.
> > 
> > I boot tested on OMAP1 (5912/OSK) with 32k timer and MPU timer
> > Kconfigs.  Works fine, but needs small change below for compile 
warnings.
> > 
> > Otherwise, looks good.
> 
> We need at least one tested-by on some 15xx platform for these 
changes.
> Janusz, can you please give this series a try on your board too?

Sure, but in a week or so.

I'm still trying to follow the l-o list, but please always Cc: me for 
testing any changes on Amstrad Delta whenever you see fit.

Regards,
Janusz
--
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] 28+ messages in thread

* [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init
@ 2012-05-04 19:45         ` Janusz Krzysztofik
  0 siblings, 0 replies; 28+ messages in thread
From: Janusz Krzysztofik @ 2012-05-04 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

Dnia pi?tek, 4 maja 2012 10:43:02 Tony Lindgren pisze:
> Hi,
> 
> * Kevin Hilman <khilman@ti.com> [120502 13:11]:
> > Vaibhav Hiremath <hvaibhav@ti.com> writes:
> > 
> > > OMAP1, omap_32k_timer_init() function always returns "true",
> > > irrespective of whether error occurred while initializing 32k sync
> > > counter as a kernel clocksource or not and execution will never
> > > fallback to mpu_timer clocksource init code.
> > >
> > > This patch adds check for return value from function
> > > omap_init_clocksource_32k(), and fallback to omap_mpu_timer_init()
> > > in case of failure/error from omap_init_clocksource_32k().
> > >
> > > Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > > Cc: Tony Lindgren <tony@atomide.com>
> > > Cc: Kevin Hilman <khilman@ti.com>
> > > Cc: Paul Walmsley <paul@pwsan.com>
> > > Cc: Benoit Cousson <b-cousson@ti.com>
> > > ---
> > > This is new patch addition compared to original series (<=V5).
> > >
> > > Also, note that, this patch is only compile tested, since
> > > I do not have omap1 board with me to validate it.
> > > Kevin, can you help me to validate it.
> > 
> > I boot tested on OMAP1 (5912/OSK) with 32k timer and MPU timer
> > Kconfigs.  Works fine, but needs small change below for compile 
warnings.
> > 
> > Otherwise, looks good.
> 
> We need at least one tested-by on some 15xx platform for these 
changes.
> Janusz, can you please give this series a try on your board too?

Sure, but in a week or so.

I'm still trying to follow the l-o list, but please always Cc: me for 
testing any changes on Amstrad Delta whenever you see fit.

Regards,
Janusz

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

* Re: [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
  2012-05-03 18:19       ` Jon Hunter
@ 2012-05-07 12:39         ` Cousson, Benoit
  -1 siblings, 0 replies; 28+ messages in thread
From: Cousson, Benoit @ 2012-05-07 12:39 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Hiremath, Vaibhav, linux-omap, Hilman, Kevin, paul, tony,
	Shilimkar, Santosh, linux-arm-kernel

On 5/3/2012 8:19 PM, Jon Hunter wrote:
> Hi Vaibhav,
>
> On 05/03/2012 12:07 AM, Hiremath, Vaibhav wrote:
>> On Thu, May 03, 2012 at 01:26:18, Hunter, Jon wrote:
>>> Hi Vaibhav,
>>>
>>> On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
>>>> Current OMAP code supports couple of clocksource options based
>>>> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
>>>> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
>>>>
>>>> This patch series cleans up the existing 32k-sync timer implementation,
>>>> movind SoC init code to respective files (mach-omap1/timer32k.c and
>>>> mach-omap2/timer.c) and uses kernel parameter to override the default
>>>> clocksource of "counter_32k", also in order to support some OMAP based
>>>> derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
>>>> adds hwmod lookup for omap2+ devices, and if lookup fails then
>>>> fall back to gp-timer.
>>>>
>>>> if(use_gptimer_clksrc == true)
>>>> 	gptimer clocksource init;
>>>> else if (counter_32 init == false)
>>>> 	/* Fallback to gptimer */
>>>> 	gptimer clocksource init(;
>>>>
>>>> With this, we should be able to support multi-omap boot
>>>> including devices with/without 32k-sync timer.
>>>>
>>>> This patch-series has been boot tested on AM37xEVM platform, it
>>>> would be helpful if somebody help me to validate it on OMAP1/2
>>>> platforms.
>>>>
>>>> The patches are also available at (based on linux-omap/master) -
>>>> https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup
>>>
>>> I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?
>>>
>>
>> The 32kcounter hwmod entry is already enabled in linux-omap/master branch.
>>
>> Your baseline looks pretty old to me, are you not using linux-omap/master?
>
> Ha! My "old" baseline is the latest mainline kernel ;-)
>
> I guess this is a bit out-dated in terms of omap now. Sorry I missed
> that fact your patches were on top of the omap kernel in the changelog.

Yeah, in fact Paul submitted a big series to clean / re-organize and add 
missing hwmod for 3.5. So any change on hwmod should be done on top of 
Paul's branch.

Regards,
Benoit

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

* [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime
@ 2012-05-07 12:39         ` Cousson, Benoit
  0 siblings, 0 replies; 28+ messages in thread
From: Cousson, Benoit @ 2012-05-07 12:39 UTC (permalink / raw)
  To: linux-arm-kernel

On 5/3/2012 8:19 PM, Jon Hunter wrote:
> Hi Vaibhav,
>
> On 05/03/2012 12:07 AM, Hiremath, Vaibhav wrote:
>> On Thu, May 03, 2012 at 01:26:18, Hunter, Jon wrote:
>>> Hi Vaibhav,
>>>
>>> On 05/02/2012 08:56 AM, Vaibhav Hiremath wrote:
>>>> Current OMAP code supports couple of clocksource options based
>>>> on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
>>>> and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz)
>>>>
>>>> This patch series cleans up the existing 32k-sync timer implementation,
>>>> movind SoC init code to respective files (mach-omap1/timer32k.c and
>>>> mach-omap2/timer.c) and uses kernel parameter to override the default
>>>> clocksource of "counter_32k", also in order to support some OMAP based
>>>> derivative SoCs like AM33XX which doesn't have 32K sync-timer hardware IP,
>>>> adds hwmod lookup for omap2+ devices, and if lookup fails then
>>>> fall back to gp-timer.
>>>>
>>>> if(use_gptimer_clksrc == true)
>>>> 	gptimer clocksource init;
>>>> else if (counter_32 init == false)
>>>> 	/* Fallback to gptimer */
>>>> 	gptimer clocksource init(;
>>>>
>>>> With this, we should be able to support multi-omap boot
>>>> including devices with/without 32k-sync timer.
>>>>
>>>> This patch-series has been boot tested on AM37xEVM platform, it
>>>> would be helpful if somebody help me to validate it on OMAP1/2
>>>> platforms.
>>>>
>>>> The patches are also available at (based on linux-omap/master) -
>>>> https://github.com/hvaibhav/am335x-linux   32ksync-timer-cleanup
>>>
>>> I was testing on OMAP4 and I found that the gptimer was always being set by default. I noticed that currently the HWMOD for counter_32k on OMAP4 is commented and hence was not being found. Please can you include the following with your series?
>>>
>>
>> The 32kcounter hwmod entry is already enabled in linux-omap/master branch.
>>
>> Your baseline looks pretty old to me, are you not using linux-omap/master?
>
> Ha! My "old" baseline is the latest mainline kernel ;-)
>
> I guess this is a bit out-dated in terms of omap now. Sorry I missed
> that fact your patches were on top of the omap kernel in the changelog.

Yeah, in fact Paul submitted a big series to clean / re-organize and add 
missing hwmod for 3.5. So any change on hwmod should be done on top of 
Paul's branch.

Regards,
Benoit

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

end of thread, other threads:[~2012-05-07 12:40 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-02 13:56 [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime Vaibhav Hiremath
2012-05-02 13:56 ` Vaibhav Hiremath
2012-05-02 13:56 ` [PATCH-V6 1/3] ARM: OMAP1: FIX: check possible error condition in timer_init Vaibhav Hiremath
2012-05-02 13:56   ` Vaibhav Hiremath
2012-05-02 20:08   ` Kevin Hilman
2012-05-02 20:08     ` Kevin Hilman
2012-05-04 17:43     ` Tony Lindgren
2012-05-04 17:43       ` Tony Lindgren
2012-05-04 19:45       ` Janusz Krzysztofik
2012-05-04 19:45         ` Janusz Krzysztofik
2012-05-02 13:56 ` [PATCH-V6 2/3] ARM: OMAP2+: Replace space=>underscore in the name field of system timers Vaibhav Hiremath
2012-05-02 13:56   ` Vaibhav Hiremath
2012-05-02 20:09   ` Kevin Hilman
2012-05-02 20:09     ` Kevin Hilman
2012-05-02 13:56 ` [PATCH-V6 3/3] ARM: OMAP: Make OMAP clocksource source selection using kernel param Vaibhav Hiremath
2012-05-02 13:56   ` Vaibhav Hiremath
2012-05-02 20:39   ` Kevin Hilman
2012-05-02 20:39     ` Kevin Hilman
2012-05-03  8:06     ` Hiremath, Vaibhav
2012-05-03  8:06       ` Hiremath, Vaibhav
2012-05-02 19:56 ` [PATCH-V6 0/3] ARM: OMAP: Make OMAP clocksource source selection runtime Jon Hunter
2012-05-02 19:56   ` Jon Hunter
2012-05-03  5:07   ` Hiremath, Vaibhav
2012-05-03  5:07     ` Hiremath, Vaibhav
2012-05-03 18:19     ` Jon Hunter
2012-05-03 18:19       ` Jon Hunter
2012-05-07 12:39       ` Cousson, Benoit
2012-05-07 12:39         ` Cousson, Benoit

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.