All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Add high resolution generic time support for S3C64xx
@ 2011-08-31 12:33 Tomasz Figa
  2011-08-31 12:34 ` [PATCH 1/5] ARM: Samsung: PWM: Allow to differentiate SoCs based on platform device name Tomasz Figa
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Tomasz Figa @ 2011-08-31 12:33 UTC (permalink / raw)
  To: linux-arm-kernel



^ permalink raw reply	[flat|nested] 22+ messages in thread
* [PATCH 5/5] ARM: s3c64xx: Add optional local sched_clock implementation.
@ 2011-08-28  0:49 Tomasz Figa
  0 siblings, 0 replies; 22+ messages in thread
From: Tomasz Figa @ 2011-08-28  0:49 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds local sched_clock implementation using the PWM timer used
for generic clock source and a Kconfig option to enable/disable it.

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
---
 arch/arm/mach-s3c64xx/Kconfig |    8 ++++++++
 arch/arm/mach-s3c64xx/time.c  |   28 +++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig
index 2db76fd..e11dd9b 100644
--- a/arch/arm/mach-s3c64xx/Kconfig
+++ b/arch/arm/mach-s3c64xx/Kconfig
@@ -33,6 +33,14 @@ config S3C64XX_GENERIC_CLOCKEVENTS
 	  on S3C6400/S3C6410 SoCs using PWM timers 3 and 4 instead
 	  of standard periodic tick using PWM timer 4.
 
+config S3C64XX_SCHED_CLOCK
+	bool "Use PWM clock source for scheduler clock"
+	depends on S3C64XX_GENERIC_CLOCKEVENTS
+	select HAVE_SCHED_CLOCK
+	help
+	  This option enables local scheduler clock implementation
+	  using PWM clock source.
+
 config S3C64XX_ARCH_USES_GETTIMEOFFSET
 	def_bool y if !S3C64XX_GENERIC_CLOCKEVENTS
 	select ARCH_USES_GETTIMEOFFSET
diff --git a/arch/arm/mach-s3c64xx/time.c b/arch/arm/mach-s3c64xx/time.c
index 4fa57f0..4a78844 100644
--- a/arch/arm/mach-s3c64xx/time.c
+++ b/arch/arm/mach-s3c64xx/time.c
@@ -28,6 +28,7 @@
 #include <linux/clockchips.h>
 #include <linux/platform_device.h>
 
+#include <asm/sched_clock.h>
 #include <mach/map.h>
 #include <plat/regs-timer.h>
 #include <asm/mach/time.h>
@@ -241,6 +242,29 @@ static void s3c64xx_clocksource_resume(struct clocksource *cs)
 	s3c64xx_pwm_start(PWM_SOURCE, PERIODIC);
 }
 
+#ifdef CONFIG_S3C64XX_SCHED_CLOCK
+/*
+ * Override the global weak sched_clock symbol with this
+ * local implementation which uses the clocksource to get some
+ * better resolution when scheduling the kernel. We accept that
+ * this wraps around for now, since it is just a relative time
+ * stamp. (Inspired by U300 implementation.)
+ */
+static DEFINE_CLOCK_DATA(cd);
+
+unsigned long long notrace sched_clock(void)
+{
+	return cyc_to_sched_clock(&cd,
+			~__raw_readl(S3C2410_TCNTO(PWM_SOURCE)), TCNT_MAX);
+}
+
+static void notrace s3c64xx_update_sched_clock(void)
+{
+	update_sched_clock(&cd,
+			~__raw_readl(S3C2410_TCNTO(PWM_SOURCE)), (u32)~0);
+}
+#endif /* CONFIG_S3C64XX_SCHED_CLOCK */
+
 static struct clocksource pwm_clocksource = {
 	.name		= "s3c64xx_clksrc",
 	.rating		= 250,
@@ -258,7 +282,9 @@ static void __init s3c64xx_clocksource_init(void)
 
 	s3c64xx_pwm_init(PWM_SOURCE, TCNT_MAX);
 	s3c64xx_pwm_start(PWM_SOURCE, PERIODIC);
-
+#ifdef CONFIG_S3C64XX_SCHED_CLOCK
+	init_sched_clock(&cd, s3c64xx_update_sched_clock, 32, clock_rate);
+#endif /* CONFIG_S3C64XX_SCHED_CLOCK */
 	if (clocksource_register_hz(&pwm_clocksource, clock_rate))
 		panic("%s: can't register clocksource\n", pwm_clocksource.name);
 }
-- 
1.7.6.1

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

end of thread, other threads:[~2011-10-13 14:22 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-31 12:33 [PATCH 0/5] Add high resolution generic time support for S3C64xx Tomasz Figa
2011-08-31 12:34 ` [PATCH 1/5] ARM: Samsung: PWM: Allow to differentiate SoCs based on platform device name Tomasz Figa
2011-08-31 12:44   ` Mark Brown
2011-08-31 13:30     ` Tomasz Figa
2011-09-01  2:26       ` Kukjin Kim
2011-09-01  3:33         ` Kyungmin Park
2011-09-01 11:18           ` Tomasz Figa
2011-09-01 12:32             ` Mark Brown
2011-09-06 10:41             ` Tomasz Figa
2011-09-06 11:03               ` Russell King - ARM Linux
2011-09-06 11:35                 ` Tomasz Figa
2011-09-06 12:04                   ` Russell King - ARM Linux
2011-09-07 19:01                     ` Mark Brown
2011-10-10  9:58                       ` Kukjin Kim
2011-08-31 12:34 ` [PATCH 2/5] ARM: s3c64xx: Add generic high resolution time support using PWM timers Tomasz Figa
2011-10-10  9:57   ` Kukjin Kim
2011-10-11 13:32     ` Tomasz Figa
2011-10-13 14:22   ` Russell King - ARM Linux
2011-08-31 12:35 ` [PATCH 3/5] ARM: Samsung: pwm: Exclude timer 3 on S3C64xx if generic time is enabled Tomasz Figa
2011-08-31 12:35 ` [PATCH 4/5] ARM: s3c64xx: Move all machines to s3c64xx_timer Tomasz Figa
2011-08-31 12:36 ` [PATCH 5/5] ARM: s3c64xx: Add optional local sched_clock implementation Tomasz Figa
  -- strict thread matches above, loose matches on Subject: below --
2011-08-28  0:49 Tomasz Figa

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.