diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-05-08 09:09:47 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-05-23 13:04:51 -0400 |
commit | 234b6ceddb4fc2a4bc5b9a7670f070f6e69e0868 (patch) | |
tree | 891f57ca663b5ec0bb61bb3e38c5306e0d13d2bd | |
parent | 442c8176d2efa468577738e3a99a6e051f6e8e55 (diff) |
clocksource: convert ARM 32-bit up counting clocksources
Convert ixp4xx, lpc32xx, mxc, netx, pxa, sa1100, tcc8k, tegra and u300
to use the generic mmio clocksource recently introduced.
Cc: Imre Kaloz <kaloz@openwrt.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Acked-by: Eric Miao <eric.y.miao@gmail.com>
Acked-by: "Hans J. Koch" <hjk@hansjkoch.de>
Acked-by: Colin Cross <ccross@android.com>
Cc: Erik Gilling <konkers@android.com>
Cc: Olof Johansson <olof@lixom.net>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/Kconfig | 9 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/common.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-lpc32xx/timer.c | 17 | ||||
-rw-r--r-- | arch/arm/mach-netx/time.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-pxa/time.c | 17 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/time.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-tcc8k/time.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-tegra/timer.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-u300/timer.c | 18 | ||||
-rw-r--r-- | arch/arm/plat-mxc/time.c | 38 |
10 files changed, 34 insertions, 145 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 377a7a595b08..9aa551497034 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -366,6 +366,7 @@ config ARCH_MXC | |||
366 | select GENERIC_CLOCKEVENTS | 366 | select GENERIC_CLOCKEVENTS |
367 | select ARCH_REQUIRE_GPIOLIB | 367 | select ARCH_REQUIRE_GPIOLIB |
368 | select CLKDEV_LOOKUP | 368 | select CLKDEV_LOOKUP |
369 | select CLKSRC_MMIO | ||
369 | select HAVE_SCHED_CLOCK | 370 | select HAVE_SCHED_CLOCK |
370 | help | 371 | help |
371 | Support for Freescale MXC/iMX-based family of processors | 372 | Support for Freescale MXC/iMX-based family of processors |
@@ -390,6 +391,7 @@ config ARCH_STMP3XXX | |||
390 | 391 | ||
391 | config ARCH_NETX | 392 | config ARCH_NETX |
392 | bool "Hilscher NetX based" | 393 | bool "Hilscher NetX based" |
394 | select CLKSRC_MMIO | ||
393 | select CPU_ARM926T | 395 | select CPU_ARM926T |
394 | select ARM_VIC | 396 | select ARM_VIC |
395 | select GENERIC_CLOCKEVENTS | 397 | select GENERIC_CLOCKEVENTS |
@@ -457,6 +459,7 @@ config ARCH_IXP2000 | |||
457 | config ARCH_IXP4XX | 459 | config ARCH_IXP4XX |
458 | bool "IXP4xx-based" | 460 | bool "IXP4xx-based" |
459 | depends on MMU | 461 | depends on MMU |
462 | select CLKSRC_MMIO | ||
460 | select CPU_XSCALE | 463 | select CPU_XSCALE |
461 | select GENERIC_GPIO | 464 | select GENERIC_GPIO |
462 | select GENERIC_CLOCKEVENTS | 465 | select GENERIC_CLOCKEVENTS |
@@ -497,6 +500,7 @@ config ARCH_LOKI | |||
497 | 500 | ||
498 | config ARCH_LPC32XX | 501 | config ARCH_LPC32XX |
499 | bool "NXP LPC32XX" | 502 | bool "NXP LPC32XX" |
503 | select CLKSRC_MMIO | ||
500 | select CPU_ARM926T | 504 | select CPU_ARM926T |
501 | select ARCH_REQUIRE_GPIOLIB | 505 | select ARCH_REQUIRE_GPIOLIB |
502 | select HAVE_IDE | 506 | select HAVE_IDE |
@@ -592,6 +596,7 @@ config ARCH_NUC93X | |||
592 | config ARCH_TEGRA | 596 | config ARCH_TEGRA |
593 | bool "NVIDIA Tegra" | 597 | bool "NVIDIA Tegra" |
594 | select CLKDEV_LOOKUP | 598 | select CLKDEV_LOOKUP |
599 | select CLKSRC_MMIO | ||
595 | select GENERIC_TIME | 600 | select GENERIC_TIME |
596 | select GENERIC_CLOCKEVENTS | 601 | select GENERIC_CLOCKEVENTS |
597 | select GENERIC_GPIO | 602 | select GENERIC_GPIO |
@@ -617,6 +622,7 @@ config ARCH_PXA | |||
617 | select ARCH_MTD_XIP | 622 | select ARCH_MTD_XIP |
618 | select ARCH_HAS_CPUFREQ | 623 | select ARCH_HAS_CPUFREQ |
619 | select CLKDEV_LOOKUP | 624 | select CLKDEV_LOOKUP |
625 | select CLKSRC_MMIO | ||
620 | select ARCH_REQUIRE_GPIOLIB | 626 | select ARCH_REQUIRE_GPIOLIB |
621 | select GENERIC_CLOCKEVENTS | 627 | select GENERIC_CLOCKEVENTS |
622 | select HAVE_SCHED_CLOCK | 628 | select HAVE_SCHED_CLOCK |
@@ -667,6 +673,7 @@ config ARCH_RPC | |||
667 | 673 | ||
668 | config ARCH_SA1100 | 674 | config ARCH_SA1100 |
669 | bool "SA1100-based" | 675 | bool "SA1100-based" |
676 | select CLKSRC_MMIO | ||
670 | select CPU_SA1100 | 677 | select CPU_SA1100 |
671 | select ISA | 678 | select ISA |
672 | select ARCH_SPARSEMEM_ENABLE | 679 | select ARCH_SPARSEMEM_ENABLE |
@@ -803,6 +810,7 @@ config ARCH_SHARK | |||
803 | 810 | ||
804 | config ARCH_TCC_926 | 811 | config ARCH_TCC_926 |
805 | bool "Telechips TCC ARM926-based systems" | 812 | bool "Telechips TCC ARM926-based systems" |
813 | select CLKSRC_MMIO | ||
806 | select CPU_ARM926T | 814 | select CPU_ARM926T |
807 | select HAVE_CLK | 815 | select HAVE_CLK |
808 | select CLKDEV_LOOKUP | 816 | select CLKDEV_LOOKUP |
@@ -813,6 +821,7 @@ config ARCH_TCC_926 | |||
813 | config ARCH_U300 | 821 | config ARCH_U300 |
814 | bool "ST-Ericsson U300 Series" | 822 | bool "ST-Ericsson U300 Series" |
815 | depends on MMU | 823 | depends on MMU |
824 | select CLKSRC_MMIO | ||
816 | select CPU_ARM926T | 825 | select CPU_ARM926T |
817 | select HAVE_SCHED_CLOCK | 826 | select HAVE_SCHED_CLOCK |
818 | select HAVE_TCM | 827 | select HAVE_TCM |
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c index ed19bc314318..74ed81a3cb1a 100644 --- a/arch/arm/mach-ixp4xx/common.c +++ b/arch/arm/mach-ixp4xx/common.c | |||
@@ -419,26 +419,14 @@ static void notrace ixp4xx_update_sched_clock(void) | |||
419 | /* | 419 | /* |
420 | * clocksource | 420 | * clocksource |
421 | */ | 421 | */ |
422 | static cycle_t ixp4xx_get_cycles(struct clocksource *cs) | ||
423 | { | ||
424 | return *IXP4XX_OSTS; | ||
425 | } | ||
426 | |||
427 | static struct clocksource clocksource_ixp4xx = { | ||
428 | .name = "OSTS", | ||
429 | .rating = 200, | ||
430 | .read = ixp4xx_get_cycles, | ||
431 | .mask = CLOCKSOURCE_MASK(32), | ||
432 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
433 | }; | ||
434 | |||
435 | unsigned long ixp4xx_timer_freq = IXP4XX_TIMER_FREQ; | 422 | unsigned long ixp4xx_timer_freq = IXP4XX_TIMER_FREQ; |
436 | EXPORT_SYMBOL(ixp4xx_timer_freq); | 423 | EXPORT_SYMBOL(ixp4xx_timer_freq); |
437 | static void __init ixp4xx_clocksource_init(void) | 424 | static void __init ixp4xx_clocksource_init(void) |
438 | { | 425 | { |
439 | init_sched_clock(&cd, ixp4xx_update_sched_clock, 32, ixp4xx_timer_freq); | 426 | init_sched_clock(&cd, ixp4xx_update_sched_clock, 32, ixp4xx_timer_freq); |
440 | 427 | ||
441 | clocksource_register_hz(&clocksource_ixp4xx, ixp4xx_timer_freq); | 428 | clocksource_mmio_init(&IXP4XX_OSTS, "OSTS", ixp4xx_timer_freq, 200, 32, |
429 | clocksource_mmio_readl_up); | ||
442 | } | 430 | } |
443 | 431 | ||
444 | /* | 432 | /* |
diff --git a/arch/arm/mach-lpc32xx/timer.c b/arch/arm/mach-lpc32xx/timer.c index 6162ac308c20..b42c909bbeeb 100644 --- a/arch/arm/mach-lpc32xx/timer.c +++ b/arch/arm/mach-lpc32xx/timer.c | |||
@@ -31,19 +31,6 @@ | |||
31 | #include <mach/platform.h> | 31 | #include <mach/platform.h> |
32 | #include "common.h" | 32 | #include "common.h" |
33 | 33 | ||
34 | static cycle_t lpc32xx_clksrc_read(struct clocksource *cs) | ||
35 | { | ||
36 | return (cycle_t)__raw_readl(LCP32XX_TIMER_TC(LPC32XX_TIMER1_BASE)); | ||
37 | } | ||
38 | |||
39 | static struct clocksource lpc32xx_clksrc = { | ||
40 | .name = "lpc32xx_clksrc", | ||
41 | .rating = 300, | ||
42 | .read = lpc32xx_clksrc_read, | ||
43 | .mask = CLOCKSOURCE_MASK(32), | ||
44 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
45 | }; | ||
46 | |||
47 | static int lpc32xx_clkevt_next_event(unsigned long delta, | 34 | static int lpc32xx_clkevt_next_event(unsigned long delta, |
48 | struct clock_event_device *dev) | 35 | struct clock_event_device *dev) |
49 | { | 36 | { |
@@ -170,7 +157,9 @@ static void __init lpc32xx_timer_init(void) | |||
170 | __raw_writel(0, LCP32XX_TIMER_MCR(LPC32XX_TIMER1_BASE)); | 157 | __raw_writel(0, LCP32XX_TIMER_MCR(LPC32XX_TIMER1_BASE)); |
171 | __raw_writel(LCP32XX_TIMER_CNTR_TCR_EN, | 158 | __raw_writel(LCP32XX_TIMER_CNTR_TCR_EN, |
172 | LCP32XX_TIMER_TCR(LPC32XX_TIMER1_BASE)); | 159 | LCP32XX_TIMER_TCR(LPC32XX_TIMER1_BASE)); |
173 | clocksource_register_hz(&lpc32xx_clksrc, clkrate); | 160 | |
161 | clocksource_mmio_init(LCP32XX_TIMER_TC(LPC32XX_TIMER1_BASE), | ||
162 | "lpc32xx_clksrc", clkrate, 300, 32, clocksource_mmio_readl_up); | ||
174 | } | 163 | } |
175 | 164 | ||
176 | struct sys_timer lpc32xx_timer = { | 165 | struct sys_timer lpc32xx_timer = { |
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c index f12f22d09b6c..e24c141ba489 100644 --- a/arch/arm/mach-netx/time.c +++ b/arch/arm/mach-netx/time.c | |||
@@ -104,19 +104,6 @@ static struct irqaction netx_timer_irq = { | |||
104 | .handler = netx_timer_interrupt, | 104 | .handler = netx_timer_interrupt, |
105 | }; | 105 | }; |
106 | 106 | ||
107 | cycle_t netx_get_cycles(struct clocksource *cs) | ||
108 | { | ||
109 | return readl(NETX_GPIO_COUNTER_CURRENT(TIMER_CLOCKSOURCE)); | ||
110 | } | ||
111 | |||
112 | static struct clocksource clocksource_netx = { | ||
113 | .name = "netx_timer", | ||
114 | .rating = 200, | ||
115 | .read = netx_get_cycles, | ||
116 | .mask = CLOCKSOURCE_MASK(32), | ||
117 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
118 | }; | ||
119 | |||
120 | /* | 107 | /* |
121 | * Set up timer interrupt | 108 | * Set up timer interrupt |
122 | */ | 109 | */ |
@@ -150,7 +137,8 @@ static void __init netx_timer_init(void) | |||
150 | writel(NETX_GPIO_COUNTER_CTRL_RUN, | 137 | writel(NETX_GPIO_COUNTER_CTRL_RUN, |
151 | NETX_GPIO_COUNTER_CTRL(TIMER_CLOCKSOURCE)); | 138 | NETX_GPIO_COUNTER_CTRL(TIMER_CLOCKSOURCE)); |
152 | 139 | ||
153 | clocksource_register_hz(&clocksource_netx, CLOCK_TICK_RATE); | 140 | clocksource_mmio_init(NETX_GPIO_COUNTER_CURRENT(TIMER_CLOCKSOURCE), |
141 | "netx_timer", CLOCK_TICK_RATE, 200, 32, clocksource_mmio_readl_up); | ||
154 | 142 | ||
155 | netx_clockevent.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, | 143 | netx_clockevent.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, |
156 | netx_clockevent.shift); | 144 | netx_clockevent.shift); |
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c index 428da3ff33a5..de684701449c 100644 --- a/arch/arm/mach-pxa/time.c +++ b/arch/arm/mach-pxa/time.c | |||
@@ -105,19 +105,6 @@ static struct clock_event_device ckevt_pxa_osmr0 = { | |||
105 | .set_mode = pxa_osmr0_set_mode, | 105 | .set_mode = pxa_osmr0_set_mode, |
106 | }; | 106 | }; |
107 | 107 | ||
108 | static cycle_t pxa_read_oscr(struct clocksource *cs) | ||
109 | { | ||
110 | return OSCR; | ||
111 | } | ||
112 | |||
113 | static struct clocksource cksrc_pxa_oscr0 = { | ||
114 | .name = "oscr0", | ||
115 | .rating = 200, | ||
116 | .read = pxa_read_oscr, | ||
117 | .mask = CLOCKSOURCE_MASK(32), | ||
118 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
119 | }; | ||
120 | |||
121 | static struct irqaction pxa_ost0_irq = { | 108 | static struct irqaction pxa_ost0_irq = { |
122 | .name = "ost0", | 109 | .name = "ost0", |
123 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, | 110 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, |
@@ -134,7 +121,6 @@ static void __init pxa_timer_init(void) | |||
134 | 121 | ||
135 | init_sched_clock(&cd, pxa_update_sched_clock, 32, clock_tick_rate); | 122 | init_sched_clock(&cd, pxa_update_sched_clock, 32, clock_tick_rate); |
136 | 123 | ||
137 | clocksource_calc_mult_shift(&cksrc_pxa_oscr0, clock_tick_rate, 4); | ||
138 | clockevents_calc_mult_shift(&ckevt_pxa_osmr0, clock_tick_rate, 4); | 124 | clockevents_calc_mult_shift(&ckevt_pxa_osmr0, clock_tick_rate, 4); |
139 | ckevt_pxa_osmr0.max_delta_ns = | 125 | ckevt_pxa_osmr0.max_delta_ns = |
140 | clockevent_delta2ns(0x7fffffff, &ckevt_pxa_osmr0); | 126 | clockevent_delta2ns(0x7fffffff, &ckevt_pxa_osmr0); |
@@ -144,7 +130,8 @@ static void __init pxa_timer_init(void) | |||
144 | 130 | ||
145 | setup_irq(IRQ_OST0, &pxa_ost0_irq); | 131 | setup_irq(IRQ_OST0, &pxa_ost0_irq); |
146 | 132 | ||
147 | clocksource_register_hz(&cksrc_pxa_oscr0, clock_tick_rate); | 133 | clocksource_mmio_init(&OSCR, "oscr0", clock_tick_rate, 200, 32, |
134 | clocksource_mmio_readl_up); | ||
148 | clockevents_register_device(&ckevt_pxa_osmr0); | 135 | clockevents_register_device(&ckevt_pxa_osmr0); |
149 | } | 136 | } |
150 | 137 | ||
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c index 51c05292d145..fa6602491d54 100644 --- a/arch/arm/mach-sa1100/time.c +++ b/arch/arm/mach-sa1100/time.c | |||
@@ -97,19 +97,6 @@ static struct clock_event_device ckevt_sa1100_osmr0 = { | |||
97 | .set_mode = sa1100_osmr0_set_mode, | 97 | .set_mode = sa1100_osmr0_set_mode, |
98 | }; | 98 | }; |
99 | 99 | ||
100 | static cycle_t sa1100_read_oscr(struct clocksource *s) | ||
101 | { | ||
102 | return OSCR; | ||
103 | } | ||
104 | |||
105 | static struct clocksource cksrc_sa1100_oscr = { | ||
106 | .name = "oscr", | ||
107 | .rating = 200, | ||
108 | .read = sa1100_read_oscr, | ||
109 | .mask = CLOCKSOURCE_MASK(32), | ||
110 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
111 | }; | ||
112 | |||
113 | static struct irqaction sa1100_timer_irq = { | 100 | static struct irqaction sa1100_timer_irq = { |
114 | .name = "ost0", | 101 | .name = "ost0", |
115 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, | 102 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, |
@@ -134,7 +121,8 @@ static void __init sa1100_timer_init(void) | |||
134 | 121 | ||
135 | setup_irq(IRQ_OST0, &sa1100_timer_irq); | 122 | setup_irq(IRQ_OST0, &sa1100_timer_irq); |
136 | 123 | ||
137 | clocksource_register_hz(&cksrc_sa1100_oscr, CLOCK_TICK_RATE); | 124 | clocksource_mmio_init(&OSCR, "oscr", CLOCK_TICK_RATE, 200, 32, |
125 | clocksource_mmio_readl_up); | ||
138 | clockevents_register_device(&ckevt_sa1100_osmr0); | 126 | clockevents_register_device(&ckevt_sa1100_osmr0); |
139 | } | 127 | } |
140 | 128 | ||
diff --git a/arch/arm/mach-tcc8k/time.c b/arch/arm/mach-tcc8k/time.c index e0a8d609afe1..a96babe83771 100644 --- a/arch/arm/mach-tcc8k/time.c +++ b/arch/arm/mach-tcc8k/time.c | |||
@@ -25,19 +25,6 @@ | |||
25 | 25 | ||
26 | static void __iomem *timer_base; | 26 | static void __iomem *timer_base; |
27 | 27 | ||
28 | static cycle_t tcc_get_cycles(struct clocksource *cs) | ||
29 | { | ||
30 | return __raw_readl(timer_base + TC32MCNT_OFFS); | ||
31 | } | ||
32 | |||
33 | static struct clocksource clocksource_tcc = { | ||
34 | .name = "tcc_tc32", | ||
35 | .rating = 200, | ||
36 | .read = tcc_get_cycles, | ||
37 | .mask = CLOCKSOURCE_MASK(32), | ||
38 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
39 | }; | ||
40 | |||
41 | static int tcc_set_next_event(unsigned long evt, | 28 | static int tcc_set_next_event(unsigned long evt, |
42 | struct clock_event_device *unused) | 29 | struct clock_event_device *unused) |
43 | { | 30 | { |
@@ -102,7 +89,8 @@ static int __init tcc_clockevent_init(struct clk *clock) | |||
102 | { | 89 | { |
103 | unsigned int c = clk_get_rate(clock); | 90 | unsigned int c = clk_get_rate(clock); |
104 | 91 | ||
105 | clocksource_register_hz(&clocksource_tcc, c); | 92 | clocksource_mmio_init(timer_base + TC32MCNT_OFFS, "tcc_tc32", c, |
93 | 200, 32, clocksource_mmio_readl_up); | ||
106 | 94 | ||
107 | clockevent_tcc.mult = div_sc(c, NSEC_PER_SEC, | 95 | clockevent_tcc.mult = div_sc(c, NSEC_PER_SEC, |
108 | clockevent_tcc.shift); | 96 | clockevent_tcc.shift); |
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c index 0fcb1eb4214d..90350420c4e9 100644 --- a/arch/arm/mach-tegra/timer.c +++ b/arch/arm/mach-tegra/timer.c | |||
@@ -98,11 +98,6 @@ static void tegra_timer_set_mode(enum clock_event_mode mode, | |||
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | static cycle_t tegra_clocksource_read(struct clocksource *cs) | ||
102 | { | ||
103 | return timer_readl(TIMERUS_CNTR_1US); | ||
104 | } | ||
105 | |||
106 | static struct clock_event_device tegra_clockevent = { | 101 | static struct clock_event_device tegra_clockevent = { |
107 | .name = "timer0", | 102 | .name = "timer0", |
108 | .rating = 300, | 103 | .rating = 300, |
@@ -111,14 +106,6 @@ static struct clock_event_device tegra_clockevent = { | |||
111 | .set_mode = tegra_timer_set_mode, | 106 | .set_mode = tegra_timer_set_mode, |
112 | }; | 107 | }; |
113 | 108 | ||
114 | static struct clocksource tegra_clocksource = { | ||
115 | .name = "timer_us", | ||
116 | .rating = 300, | ||
117 | .read = tegra_clocksource_read, | ||
118 | .mask = CLOCKSOURCE_MASK(32), | ||
119 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
120 | }; | ||
121 | |||
122 | static DEFINE_CLOCK_DATA(cd); | 109 | static DEFINE_CLOCK_DATA(cd); |
123 | 110 | ||
124 | /* | 111 | /* |
@@ -234,7 +221,8 @@ static void __init tegra_init_timer(void) | |||
234 | init_fixed_sched_clock(&cd, tegra_update_sched_clock, 32, | 221 | init_fixed_sched_clock(&cd, tegra_update_sched_clock, 32, |
235 | 1000000, SC_MULT, SC_SHIFT); | 222 | 1000000, SC_MULT, SC_SHIFT); |
236 | 223 | ||
237 | if (clocksource_register_hz(&tegra_clocksource, 1000000)) { | 224 | if (clocksource_mmio_init(timer_reg_base + TIMERUS_CNTR_1US, |
225 | "timer_us", 1000000, 300, 32, clocksource_mmio_readl_up)) { | ||
238 | printk(KERN_ERR "Failed to register clocksource\n"); | 226 | printk(KERN_ERR "Failed to register clocksource\n"); |
239 | BUG(); | 227 | BUG(); |
240 | } | 228 | } |
diff --git a/arch/arm/mach-u300/timer.c b/arch/arm/mach-u300/timer.c index 3ec58bd2d6e4..891cf44591e0 100644 --- a/arch/arm/mach-u300/timer.c +++ b/arch/arm/mach-u300/timer.c | |||
@@ -333,20 +333,6 @@ static struct irqaction u300_timer_irq = { | |||
333 | .handler = u300_timer_interrupt, | 333 | .handler = u300_timer_interrupt, |
334 | }; | 334 | }; |
335 | 335 | ||
336 | /* Use general purpose timer 2 as clock source */ | ||
337 | static cycle_t u300_get_cycles(struct clocksource *cs) | ||
338 | { | ||
339 | return (cycles_t) readl(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC); | ||
340 | } | ||
341 | |||
342 | static struct clocksource clocksource_u300_1mhz = { | ||
343 | .name = "GPT2", | ||
344 | .rating = 300, /* Reasonably fast and accurate clock source */ | ||
345 | .read = u300_get_cycles, | ||
346 | .mask = CLOCKSOURCE_MASK(32), /* 32 bits */ | ||
347 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
348 | }; | ||
349 | |||
350 | /* | 336 | /* |
351 | * Override the global weak sched_clock symbol with this | 337 | * Override the global weak sched_clock symbol with this |
352 | * local implementation which uses the clocksource to get some | 338 | * local implementation which uses the clocksource to get some |
@@ -422,7 +408,9 @@ static void __init u300_timer_init(void) | |||
422 | writel(U300_TIMER_APP_EGPT2_TIMER_ENABLE, | 408 | writel(U300_TIMER_APP_EGPT2_TIMER_ENABLE, |
423 | U300_TIMER_APP_VBASE + U300_TIMER_APP_EGPT2); | 409 | U300_TIMER_APP_VBASE + U300_TIMER_APP_EGPT2); |
424 | 410 | ||
425 | if (clocksource_register_hz(&clocksource_u300_1mhz, rate)) | 411 | /* Use general purpose timer 2 as clock source */ |
412 | if (clocksource_mmio_init(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC, | ||
413 | "GPT2", rate, 300, 32, clocksource_mmio_readl_up)) | ||
426 | printk(KERN_ERR "timer: failed to initialize clock " | 414 | printk(KERN_ERR "timer: failed to initialize clock " |
427 | "source %s\n", clocksource_u300_1mhz.name); | 415 | "source %s\n", clocksource_u300_1mhz.name); |
428 | 416 | ||
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c index 2237ff8b434f..e4ac94a86832 100644 --- a/arch/arm/plat-mxc/time.c +++ b/arch/arm/plat-mxc/time.c | |||
@@ -106,56 +106,32 @@ static void gpt_irq_acknowledge(void) | |||
106 | __raw_writel(V2_TSTAT_OF1, timer_base + V2_TSTAT); | 106 | __raw_writel(V2_TSTAT_OF1, timer_base + V2_TSTAT); |
107 | } | 107 | } |
108 | 108 | ||
109 | static cycle_t dummy_get_cycles(struct clocksource *cs) | 109 | static void __iomem *sched_clock_reg; |
110 | { | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static cycle_t mx1_2_get_cycles(struct clocksource *cs) | ||
115 | { | ||
116 | return __raw_readl(timer_base + MX1_2_TCN); | ||
117 | } | ||
118 | |||
119 | static cycle_t v2_get_cycles(struct clocksource *cs) | ||
120 | { | ||
121 | return __raw_readl(timer_base + V2_TCN); | ||
122 | } | ||
123 | |||
124 | static struct clocksource clocksource_mxc = { | ||
125 | .name = "mxc_timer1", | ||
126 | .rating = 200, | ||
127 | .read = dummy_get_cycles, | ||
128 | .mask = CLOCKSOURCE_MASK(32), | ||
129 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
130 | }; | ||
131 | 110 | ||
132 | static DEFINE_CLOCK_DATA(cd); | 111 | static DEFINE_CLOCK_DATA(cd); |
133 | unsigned long long notrace sched_clock(void) | 112 | unsigned long long notrace sched_clock(void) |
134 | { | 113 | { |
135 | cycle_t cyc = clocksource_mxc.read(&clocksource_mxc); | 114 | cycle_t cyc = sched_clock_reg ? __raw_readl(sched_clock_reg) : 0; |
136 | 115 | ||
137 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); | 116 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); |
138 | } | 117 | } |
139 | 118 | ||
140 | static void notrace mxc_update_sched_clock(void) | 119 | static void notrace mxc_update_sched_clock(void) |
141 | { | 120 | { |
142 | cycle_t cyc = clocksource_mxc.read(&clocksource_mxc); | 121 | cycle_t cyc = sched_clock_reg ? __raw_readl(sched_clock_reg) : 0; |
143 | update_sched_clock(&cd, cyc, (u32)~0); | 122 | update_sched_clock(&cd, cyc, (u32)~0); |
144 | } | 123 | } |
145 | 124 | ||
146 | static int __init mxc_clocksource_init(struct clk *timer_clk) | 125 | static int __init mxc_clocksource_init(struct clk *timer_clk) |
147 | { | 126 | { |
148 | unsigned int c = clk_get_rate(timer_clk); | 127 | unsigned int c = clk_get_rate(timer_clk); |
128 | void __iomem *reg = timer_base + (timer_is_v2() ? V2_TCN : MX1_2_TCN); | ||
149 | 129 | ||
150 | if (timer_is_v2()) | 130 | sched_clock_reg = reg; |
151 | clocksource_mxc.read = v2_get_cycles; | ||
152 | else | ||
153 | clocksource_mxc.read = mx1_2_get_cycles; | ||
154 | 131 | ||
155 | init_sched_clock(&cd, mxc_update_sched_clock, 32, c); | 132 | init_sched_clock(&cd, mxc_update_sched_clock, 32, c); |
156 | clocksource_register_hz(&clocksource_mxc, c); | 133 | return clocksource_mmio_init(reg, "mxc_timer1", c, 200, 32, |
157 | 134 | clocksource_mmio_readl_up); | |
158 | return 0; | ||
159 | } | 135 | } |
160 | 136 | ||
161 | /* clock event */ | 137 | /* clock event */ |