diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-01-05 13:09:03 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-01-05 13:09:03 -0500 |
commit | 58daf18cdcab550262a5f4681e1f1e073e21965a (patch) | |
tree | 2096324b947761a567dd451f33664f17ee1de2cd /arch/arm/mach-tegra | |
parent | aa312be1987d43216e72ffce42bccf6bf81f62ed (diff) | |
parent | 0af85dda39d9b673aca8c0ebae004ea70f3efc93 (diff) |
Merge branch 'clksrc' into devel
Conflicts:
arch/arm/mach-vexpress/v2m.c
arch/arm/plat-omap/counter_32k.c
arch/arm/plat-versatile/Makefile
Diffstat (limited to 'arch/arm/mach-tegra')
-rw-r--r-- | arch/arm/mach-tegra/timer.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c index 9057d6fd1d31..7b8ad1f98f44 100644 --- a/arch/arm/mach-tegra/timer.c +++ b/arch/arm/mach-tegra/timer.c | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/sched.h> | ||
21 | #include <linux/time.h> | 22 | #include <linux/time.h> |
22 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
23 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
@@ -25,10 +26,10 @@ | |||
25 | #include <linux/clocksource.h> | 26 | #include <linux/clocksource.h> |
26 | #include <linux/clk.h> | 27 | #include <linux/clk.h> |
27 | #include <linux/io.h> | 28 | #include <linux/io.h> |
28 | #include <linux/cnt32_to_63.h> | ||
29 | 29 | ||
30 | #include <asm/mach/time.h> | 30 | #include <asm/mach/time.h> |
31 | #include <asm/localtimer.h> | 31 | #include <asm/localtimer.h> |
32 | #include <asm/sched_clock.h> | ||
32 | 33 | ||
33 | #include <mach/iomap.h> | 34 | #include <mach/iomap.h> |
34 | #include <mach/irqs.h> | 35 | #include <mach/irqs.h> |
@@ -91,7 +92,7 @@ static void tegra_timer_set_mode(enum clock_event_mode mode, | |||
91 | 92 | ||
92 | static cycle_t tegra_clocksource_read(struct clocksource *cs) | 93 | static cycle_t tegra_clocksource_read(struct clocksource *cs) |
93 | { | 94 | { |
94 | return cnt32_to_63(timer_readl(TIMERUS_CNTR_1US)); | 95 | return timer_readl(TIMERUS_CNTR_1US); |
95 | } | 96 | } |
96 | 97 | ||
97 | static struct clock_event_device tegra_clockevent = { | 98 | static struct clock_event_device tegra_clockevent = { |
@@ -106,14 +107,29 @@ static struct clocksource tegra_clocksource = { | |||
106 | .name = "timer_us", | 107 | .name = "timer_us", |
107 | .rating = 300, | 108 | .rating = 300, |
108 | .read = tegra_clocksource_read, | 109 | .read = tegra_clocksource_read, |
109 | .mask = 0x7FFFFFFFFFFFFFFFULL, | 110 | .mask = CLOCKSOURCE_MASK(32), |
110 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 111 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
111 | }; | 112 | }; |
112 | 113 | ||
113 | unsigned long long sched_clock(void) | 114 | static DEFINE_CLOCK_DATA(cd); |
115 | |||
116 | /* | ||
117 | * Constants generated by clocks_calc_mult_shift(m, s, 1MHz, NSEC_PER_SEC, 60). | ||
118 | * This gives a resolution of about 1us and a wrap period of about 1h11min. | ||
119 | */ | ||
120 | #define SC_MULT 4194304000u | ||
121 | #define SC_SHIFT 22 | ||
122 | |||
123 | unsigned long long notrace sched_clock(void) | ||
114 | { | 124 | { |
115 | return clocksource_cyc2ns(tegra_clocksource.read(&tegra_clocksource), | 125 | u32 cyc = timer_readl(TIMERUS_CNTR_1US); |
116 | tegra_clocksource.mult, tegra_clocksource.shift); | 126 | return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT); |
127 | } | ||
128 | |||
129 | static void notrace tegra_update_sched_clock(void) | ||
130 | { | ||
131 | u32 cyc = timer_readl(TIMERUS_CNTR_1US); | ||
132 | update_sched_clock(&cd, cyc, (u32)~0); | ||
117 | } | 133 | } |
118 | 134 | ||
119 | static irqreturn_t tegra_timer_interrupt(int irq, void *dev_id) | 135 | static irqreturn_t tegra_timer_interrupt(int irq, void *dev_id) |
@@ -158,6 +174,9 @@ static void __init tegra_init_timer(void) | |||
158 | WARN(1, "Unknown clock rate"); | 174 | WARN(1, "Unknown clock rate"); |
159 | } | 175 | } |
160 | 176 | ||
177 | init_fixed_sched_clock(&cd, tegra_update_sched_clock, 32, | ||
178 | 1000000, SC_MULT, SC_SHIFT); | ||
179 | |||
161 | if (clocksource_register_hz(&tegra_clocksource, 1000000)) { | 180 | if (clocksource_register_hz(&tegra_clocksource, 1000000)) { |
162 | printk(KERN_ERR "Failed to register clocksource\n"); | 181 | printk(KERN_ERR "Failed to register clocksource\n"); |
163 | BUG(); | 182 | BUG(); |