diff options
| -rw-r--r-- | arch/arm/Kconfig | 1 | ||||
| -rw-r--r-- | arch/arm/plat-omap/counter_32k.c | 24 |
2 files changed, 23 insertions, 2 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 58e2fe30715b..726279fe3f53 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -839,6 +839,7 @@ config ARCH_OMAP | |||
| 839 | select ARCH_REQUIRE_GPIOLIB | 839 | select ARCH_REQUIRE_GPIOLIB |
| 840 | select ARCH_HAS_CPUFREQ | 840 | select ARCH_HAS_CPUFREQ |
| 841 | select GENERIC_CLOCKEVENTS | 841 | select GENERIC_CLOCKEVENTS |
| 842 | select HAVE_SCHED_CLOCK | ||
| 842 | select ARCH_HAS_HOLES_MEMORYMODEL | 843 | select ARCH_HAS_HOLES_MEMORYMODEL |
| 843 | help | 844 | help |
| 844 | Support for TI's OMAP platform (OMAP1/2/3/4). | 845 | Support for TI's OMAP platform (OMAP1/2/3/4). |
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c index aed301bfa2f9..1b558efbe732 100644 --- a/arch/arm/plat-omap/counter_32k.c +++ b/arch/arm/plat-omap/counter_32k.c | |||
| @@ -18,6 +18,8 @@ | |||
| 18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
| 19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
| 20 | 20 | ||
| 21 | #include <asm/sched_clock.h> | ||
| 22 | |||
| 21 | #include <plat/common.h> | 23 | #include <plat/common.h> |
| 22 | #include <plat/board.h> | 24 | #include <plat/board.h> |
| 23 | 25 | ||
| @@ -110,10 +112,25 @@ static struct clocksource clocksource_32k = { | |||
| 110 | * Returns current time from boot in nsecs. It's OK for this to wrap | 112 | * Returns current time from boot in nsecs. It's OK for this to wrap |
| 111 | * around for now, as it's just a relative time stamp. | 113 | * around for now, as it's just a relative time stamp. |
| 112 | */ | 114 | */ |
| 115 | static DEFINE_CLOCK_DATA(cd); | ||
| 116 | |||
| 117 | /* | ||
| 118 | * Constants generated by clocks_calc_mult_shift(m, s, 32768, NSEC_PER_SEC, 60). | ||
| 119 | * This gives a resolution of about 30us and a wrap period of about 36hrs. | ||
| 120 | */ | ||
| 121 | #define SC_MULT 4000000000u | ||
| 122 | #define SC_SHIFT 17 | ||
| 123 | |||
| 113 | unsigned long long notrace sched_clock(void) | 124 | unsigned long long notrace sched_clock(void) |
| 114 | { | 125 | { |
| 115 | return clocksource_cyc2ns(clocksource_32k.read(&clocksource_32k), | 126 | u32 cyc = clocksource_32k.read(&clocksource_32k); |
| 116 | clocksource_32k.mult, clocksource_32k.shift); | 127 | return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT); |
| 128 | } | ||
| 129 | |||
| 130 | static void notrace omap_update_sched_clock(void) | ||
| 131 | { | ||
| 132 | u32 cyc = clocksource_32k.read(&clocksource_32k); | ||
| 133 | update_sched_clock(&cd, cyc, (u32)~0); | ||
| 117 | } | 134 | } |
| 118 | 135 | ||
| 119 | /** | 136 | /** |
| @@ -171,6 +188,9 @@ static int __init omap_init_clocksource_32k(void) | |||
| 171 | 188 | ||
| 172 | if (clocksource_register_hz(&clocksource_32k, 32768)) | 189 | if (clocksource_register_hz(&clocksource_32k, 32768)) |
| 173 | printk(err, clocksource_32k.name); | 190 | printk(err, clocksource_32k.name); |
| 191 | |||
| 192 | init_fixed_sched_clock(&cd, omap_update_sched_clock, 32, | ||
| 193 | 32768, SC_MULT, SC_SHIFT); | ||
| 174 | } | 194 | } |
| 175 | return 0; | 195 | return 0; |
| 176 | } | 196 | } |
