From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/13 v2] clocksource: convert ARM 32-bit down counting clocksources
Date: Thu, 12 May 2011 13:47:10 +0100 [thread overview]
Message-ID: <20110512124710.GE1356@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <E1QJhPM-0000yq-ED@rmk-PC.arm.linux.org.uk>
Convert SP804, MXC, Nomadik and Orion 32-bit down-counting clocksources
to generic mmio clocksource infrastructure.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Alessandro Rubini <rubini@unipv.it>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
This is v2 of this patch, which adds Catalin to the Cc for timer-sp.c
as ARM platforms are impacted by this change, and fixes a build problem
with timer-sp.c.
arch/arm/Kconfig | 2 ++
arch/arm/common/timer-sp.c | 30 ++++++------------------------
arch/arm/plat-mxc/epit.c | 18 ++----------------
arch/arm/plat-nomadik/Kconfig | 1 +
arch/arm/plat-nomadik/timer.c | 31 +++----------------------------
arch/arm/plat-orion/time.c | 21 ++-------------------
6 files changed, 16 insertions(+), 87 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9aa5514..0a05a57 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1042,6 +1042,7 @@ config PLAT_IOP
config PLAT_ORION
bool
+ select CLKSRC_MMIO
select HAVE_SCHED_CLOCK
config PLAT_PXA
@@ -1052,6 +1053,7 @@ config PLAT_VERSATILE
config ARM_TIMER_SP804
bool
+ select CLKSRC_MMIO
source arch/arm/mm/Kconfig
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index 6ef3342..445b05e 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -32,35 +32,17 @@
#define TIMER_FREQ_KHZ (1000)
#define TIMER_RELOAD (TIMER_FREQ_KHZ * 1000 / HZ)
-static void __iomem *clksrc_base;
-
-static cycle_t sp804_read(struct clocksource *cs)
-{
- return ~readl(clksrc_base + TIMER_VALUE);
-}
-
-static struct clocksource clocksource_sp804 = {
- .name = "timer3",
- .rating = 200,
- .read = sp804_read,
- .mask = CLOCKSOURCE_MASK(32),
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
void __init sp804_clocksource_init(void __iomem *base)
{
- struct clocksource *cs = &clocksource_sp804;
-
- clksrc_base = base;
-
/* setup timer 0 as free-running clocksource */
- writel(0, clksrc_base + TIMER_CTRL);
- writel(0xffffffff, clksrc_base + TIMER_LOAD);
- writel(0xffffffff, clksrc_base + TIMER_VALUE);
+ writel(0, base + TIMER_CTRL);
+ writel(0xffffffff, base + TIMER_LOAD);
+ writel(0xffffffff, base + TIMER_VALUE);
writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC,
- clksrc_base + TIMER_CTRL);
+ base + TIMER_CTRL);
- clocksource_register_khz(cs, TIMER_FREQ_KHZ);
+ clocksource_mmio_init(base + TIMER_VALUE, "timer3",
+ TIMER_FREQ_KHZ * 1000, 200, 32, clocksource_mmio_readl_down);
}
diff --git a/arch/arm/plat-mxc/epit.c b/arch/arm/plat-mxc/epit.c
index d69d343..d3467f8 100644
--- a/arch/arm/plat-mxc/epit.c
+++ b/arch/arm/plat-mxc/epit.c
@@ -83,26 +83,12 @@ static void epit_irq_acknowledge(void)
__raw_writel(EPITSR_OCIF, timer_base + EPITSR);
}
-static cycle_t epit_read(struct clocksource *cs)
-{
- return 0 - __raw_readl(timer_base + EPITCNR);
-}
-
-static struct clocksource clocksource_epit = {
- .name = "epit",
- .rating = 200,
- .read = epit_read,
- .mask = CLOCKSOURCE_MASK(32),
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
static int __init epit_clocksource_init(struct clk *timer_clk)
{
unsigned int c = clk_get_rate(timer_clk);
- clocksource_register_hz(&clocksource_epit, c);
-
- return 0;
+ return clocksource_mmio_init(timer_base + EPITCNR, "epit", c, 200, 32,
+ clocksource_mmio_readl_down);
}
/* clock event */
diff --git a/arch/arm/plat-nomadik/Kconfig b/arch/arm/plat-nomadik/Kconfig
index 187f4e8..18296ee 100644
--- a/arch/arm/plat-nomadik/Kconfig
+++ b/arch/arm/plat-nomadik/Kconfig
@@ -5,6 +5,7 @@
config PLAT_NOMADIK
bool
depends on ARCH_NOMADIK || ARCH_U8500
+ select CLKSRC_MMIO
default y
help
Common platform code for Nomadik and other ST-Ericsson
diff --git a/arch/arm/plat-nomadik/timer.c b/arch/arm/plat-nomadik/timer.c
index 4172340..ef74e15 100644
--- a/arch/arm/plat-nomadik/timer.c
+++ b/arch/arm/plat-nomadik/timer.c
@@ -26,29 +26,6 @@
void __iomem *mtu_base; /* Assigned by machine code */
/*
- * Kernel assumes that sched_clock can be called early
- * but the MTU may not yet be initialized.
- */
-static cycle_t nmdk_read_timer_dummy(struct clocksource *cs)
-{
- return 0;
-}
-
-/* clocksource: MTU decrements, so we negate the value being read. */
-static cycle_t nmdk_read_timer(struct clocksource *cs)
-{
- return -readl(mtu_base + MTU_VAL(0));
-}
-
-static struct clocksource nmdk_clksrc = {
- .name = "mtu_0",
- .rating = 200,
- .read = nmdk_read_timer_dummy,
- .mask = CLOCKSOURCE_MASK(32),
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-/*
* Override the global weak sched_clock symbol with this
* local implementation which uses the clocksource to get some
* better resolution when scheduling the kernel.
@@ -172,12 +149,10 @@ void __init nmdk_timer_init(void)
writel(0, mtu_base + MTU_BGLR(0));
writel(cr | MTU_CRn_ENA, mtu_base + MTU_CR(0));
- /* Now the clock source is ready */
- nmdk_clksrc.read = nmdk_read_timer;
-
- if (clocksource_register_hz(&nmdk_clksrc, rate))
+ if (clocksource_mmio_init(mtu_base + MTU_VAL(0), "mtu_0",
+ rate, 200, 32, clocksource_mmio_readl_down))
pr_err("timer: failed to initialize clock source %s\n",
- nmdk_clksrc.name);
+ "mtu_0");
init_sched_clock(&cd, nomadik_update_sched_clock, 32, rate);
diff --git a/arch/arm/plat-orion/time.c b/arch/arm/plat-orion/time.c
index 742b032..69a6136 100644
--- a/arch/arm/plat-orion/time.c
+++ b/arch/arm/plat-orion/time.c
@@ -81,24 +81,6 @@ static void __init setup_sched_clock(unsigned long tclk)
}
/*
- * Clocksource handling.
- */
-static cycle_t orion_clksrc_read(struct clocksource *cs)
-{
- return 0xffffffff - readl(timer_base + TIMER0_VAL_OFF);
-}
-
-static struct clocksource orion_clksrc = {
- .name = "orion_clocksource",
- .rating = 300,
- .read = orion_clksrc_read,
- .mask = CLOCKSOURCE_MASK(32),
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-
-
-/*
* Clockevent handling.
*/
static int
@@ -247,7 +229,8 @@ orion_time_init(u32 _bridge_base, u32 _bridge_timer1_clr_mask,
writel(u & ~BRIDGE_INT_TIMER0, bridge_base + BRIDGE_MASK_OFF);
u = readl(timer_base + TIMER_CTRL_OFF);
writel(u | TIMER0_EN | TIMER0_RELOAD_EN, timer_base + TIMER_CTRL_OFF);
- clocksource_register_hz(&orion_clksrc, tclk);
+ clocksource_mmio_init(timer_base + TIMER0_VAL_OFF, "orion_clocksource",
+ tclk, 300, 32, clocksource_mmio_readl_down);
/*
* Setup clockevent timer (interrupt-driven).
--
1.7.4.4
next prev parent reply other threads:[~2011-05-12 12:47 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
2011-05-10 7:27 ` [PATCH 01/13] Make clocksource name const Russell King - ARM Linux
2011-05-10 7:27 ` [PATCH 02/13] ARM: s5p: consolidate selection of timer register Russell King - ARM Linux
2011-05-12 7:01 ` Kukjin Kim
2011-05-10 7:28 ` [PATCH 03/13] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
2011-05-10 12:49 ` Kevin Hilman
2011-05-12 7:25 ` Tony Lindgren
2011-05-10 7:28 ` [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
2011-05-12 7:45 ` Tony Lindgren
2011-05-10 7:28 ` [PATCH 05/13] ARM: update sa1100 to reflect PXA updates Russell King - ARM Linux
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
2011-05-10 8:38 ` Sascha Hauer
2011-05-10 8:46 ` Russell King - ARM Linux
2011-05-12 7:43 ` Tony Lindgren
2011-05-10 9:59 ` Russell King - ARM Linux
2011-05-11 8:15 ` viresh kumar
2011-05-11 8:35 ` [PATCH 06/13 v2] " Russell King - ARM Linux
2011-05-12 8:03 ` [PATCH 06/13] " Thomas Gleixner
2011-05-10 7:29 ` [PATCH 07/13] clocksource: convert ARM 32-bit up counting clocksources Russell King - ARM Linux
2011-05-10 21:10 ` Linus Walleij
2011-05-11 7:52 ` Russell King - ARM Linux
2011-05-11 0:16 ` Hans J. Koch
2011-05-11 7:52 ` Russell King - ARM Linux
2011-05-11 8:07 ` Hans J. Koch
2011-05-15 3:53 ` Colin Cross
2011-05-26 8:32 ` Richard Cochran
2011-05-10 7:31 ` [PATCH 08/13] clocksource: convert ARM 32-bit down " Russell King - ARM Linux
2011-05-10 12:39 ` Nicolas Pitre
2011-05-11 7:53 ` Russell King - ARM Linux
2011-05-11 13:45 ` Nicolas Pitre
2011-05-10 21:04 ` Linus Walleij
2011-05-11 7:53 ` Russell King - ARM Linux
2011-05-12 12:47 ` Russell King - ARM Linux [this message]
2011-05-13 14:30 ` [PATCH 08/13 v2] " Catalin Marinas
2011-05-10 7:31 ` [PATCH 09/13] clocksource: convert W90x900 24-bit down counting clocksource Russell King - ARM Linux
2011-05-10 7:31 ` [PATCH 10/13] clocksource: convert Integrator/AP 16-bit " Russell King - ARM Linux
2011-05-10 7:32 ` [PATCH 11/13] clocksource: convert SPEAr platforms 16-bit up " Russell King - ARM Linux
2011-05-11 3:31 ` viresh kumar
2011-05-11 7:53 ` Russell King - ARM Linux
2011-05-11 8:13 ` viresh kumar
2011-05-10 7:34 ` [PATCH 12/13] clocksource: convert MXS timrotv2 to 32-bit down " Russell King - ARM Linux
2011-05-16 14:31 ` Shawn Guo
2011-05-16 15:16 ` Shawn Guo
2011-05-16 17:18 ` Russell King - ARM Linux
2011-05-10 7:34 ` [PATCH 13/13] clocksource: convert OMAP1 " Russell King - ARM Linux
2011-05-12 7:46 ` Tony Lindgren
2011-05-10 7:39 ` [PATCH 08/13] clocksource: convert ARM 32-bit down counting clocksources Alessandro Rubini
2011-05-10 8:07 ` Russell King - ARM Linux
2011-05-12 13:49 ` [PATCH 14/13] clocksource: ARM sp804: allow clocksource name to be specified Russell King - ARM Linux
2011-05-13 14:32 ` Catalin Marinas
2011-05-12 13:51 ` [PATCH 15/13] clocksource: ARM sp804: obtain sp804 timer rate via clks Russell King - ARM Linux
2011-05-13 15:01 ` Catalin Marinas
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=20110512124710.GE1356@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--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;
as well as URLs for NNTP newsgroup(s).