diff options
-rw-r--r-- | arch/arm/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-tegra/timer.c | 23 |
2 files changed, 22 insertions, 2 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 0e1a9667a869..ec7b0274d46a 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -570,6 +570,7 @@ config ARCH_TEGRA | |||
570 | select GENERIC_CLOCKEVENTS | 570 | select GENERIC_CLOCKEVENTS |
571 | select GENERIC_GPIO | 571 | select GENERIC_GPIO |
572 | select HAVE_CLK | 572 | select HAVE_CLK |
573 | select HAVE_SCHED_CLOCK | ||
573 | select COMMON_CLKDEV | 574 | select COMMON_CLKDEV |
574 | select ARCH_HAS_BARRIERS if CACHE_L2X0 | 575 | select ARCH_HAS_BARRIERS if CACHE_L2X0 |
575 | select ARCH_HAS_CPUFREQ | 576 | select ARCH_HAS_CPUFREQ |
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c index c52bd84652e5..7b8ad1f98f44 100644 --- a/arch/arm/mach-tegra/timer.c +++ b/arch/arm/mach-tegra/timer.c | |||
@@ -26,10 +26,10 @@ | |||
26 | #include <linux/clocksource.h> | 26 | #include <linux/clocksource.h> |
27 | #include <linux/clk.h> | 27 | #include <linux/clk.h> |
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/cnt32_to_63.h> | ||
30 | 29 | ||
31 | #include <asm/mach/time.h> | 30 | #include <asm/mach/time.h> |
32 | #include <asm/localtimer.h> | 31 | #include <asm/localtimer.h> |
32 | #include <asm/sched_clock.h> | ||
33 | 33 | ||
34 | #include <mach/iomap.h> | 34 | #include <mach/iomap.h> |
35 | #include <mach/irqs.h> | 35 | #include <mach/irqs.h> |
@@ -111,9 +111,25 @@ static struct clocksource tegra_clocksource = { | |||
111 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 111 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
112 | }; | 112 | }; |
113 | 113 | ||
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 | |||
114 | unsigned long long notrace sched_clock(void) | 123 | unsigned long long notrace sched_clock(void) |
115 | { | 124 | { |
116 | return cnt32_to_63(timer_readl(TIMERUS_CNTR_1US)) * 1000; | 125 | u32 cyc = timer_readl(TIMERUS_CNTR_1US); |
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(); |