From: soren.brinkmann@xilinx.com (Soren Brinkmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clocksource/cadence_ttc: Reuse clocksource as sched_clock
Date: Wed, 3 Jul 2013 14:50:16 -0700 [thread overview]
Message-ID: <1372888216-10726-1-git-send-email-soren.brinkmann@xilinx.com> (raw)
Reuse the TTC clocksource timer as sched clock, too. Since only a single
sched clock is supported in Linux, this feature optional and can be
selected through Kconfig.
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
drivers/clocksource/Kconfig | 7 +++++++
drivers/clocksource/cadence_ttc_timer.c | 18 ++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 5871933..8dda767 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -36,6 +36,13 @@ config VT8500_TIMER
config CADENCE_TTC_TIMER
bool
+config CADENCE_TTC_TIMER_SCHED_CLOCK
+ bool "Cadence TTC Sched Clock"
+ depends on CADENCE_TTC_TIMER
+ help
+ Use the clocksource timer provided by the TTC as
+ sched clock, also.
+
config CLKSRC_NOMADIK_MTU
bool
depends on (ARCH_NOMADIK || ARCH_U8500)
diff --git a/drivers/clocksource/cadence_ttc_timer.c b/drivers/clocksource/cadence_ttc_timer.c
index 4cbe28c..ef0f52b 100644
--- a/drivers/clocksource/cadence_ttc_timer.c
+++ b/drivers/clocksource/cadence_ttc_timer.c
@@ -22,6 +22,7 @@
#include <linux/of_irq.h>
#include <linux/slab.h>
#include <linux/clk-provider.h>
+#include <asm/sched_clock.h>
/*
* This driver configures the 2 16-bit count-up timers as follows:
@@ -95,6 +96,10 @@ struct ttc_timer_clockevent {
#define to_ttc_timer_clkevent(x) \
container_of(x, struct ttc_timer_clockevent, ce)
+#ifdef CONFIG_CADENCE_TTC_TIMER_SCHED_CLOCK
+static void __iomem *ttc_sched_clock_val_reg;
+#endif
+
/**
* ttc_set_interval - Set the timer interval value
*
@@ -156,6 +161,13 @@ static cycle_t __ttc_clocksource_read(struct clocksource *cs)
TTC_COUNT_VAL_OFFSET);
}
+#ifdef CONFIG_CADENCE_TTC_TIMER_SCHED_CLOCK
+static u32 notrace ttc_sched_clock_read(void)
+{
+ return __raw_readl(ttc_sched_clock_val_reg);
+}
+#endif
+
/**
* ttc_set_next_event - Sets the time interval for next event
*
@@ -297,6 +309,12 @@ static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base)
kfree(ttccs);
return;
}
+
+#ifdef CONFIG_CADENCE_TTC_TIMER_SCHED_CLOCK
+ ttc_sched_clock_val_reg = base + TTC_COUNT_VAL_OFFSET;
+ setup_sched_clock(ttc_sched_clock_read, 16,
+ clk_get_rate(ttccs->ttc.clk) / PRESCALE);
+#endif
}
static int ttc_rate_change_clockevent_cb(struct notifier_block *nb,
--
1.8.3.2
next reply other threads:[~2013-07-03 21:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 21:50 Soren Brinkmann [this message]
2013-07-04 3:30 ` [PATCH] clocksource/cadence_ttc: Reuse clocksource as sched_clock Baruch Siach
2013-07-05 20:12 ` Sören Brinkmann
2013-07-05 20:42 ` Thomas Gleixner
2013-07-05 20:56 ` Sören Brinkmann
2013-07-05 20:59 ` Thomas Gleixner
2013-07-05 21:10 ` Sören Brinkmann
2013-07-05 6:30 ` Thomas Gleixner
2013-07-05 15:43 ` Sören Brinkmann
2013-07-05 16:05 ` Thomas Gleixner
2013-07-05 16:12 ` Sören Brinkmann
2013-07-05 16:23 ` Thomas Gleixner
2013-07-08 16:27 ` Sören Brinkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372888216-10726-1-git-send-email-soren.brinkmann@xilinx.com \
--to=soren.brinkmann@xilinx.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox