diff options
author | Oskar Schirmer <os@emlix.com> | 2009-05-11 09:43:36 -0400 |
---|---|---|
committer | Chris Zankel <chris@zankel.net> | 2009-05-12 01:00:17 -0400 |
commit | b070a03f6490b0ac8d95c51b55a64e433d9160ab (patch) | |
tree | 4715316e494f17980504ee2902a14e1a7d495d05 /arch | |
parent | d15f05eb8cc4ad59699c16b8ae834b85c6d39bfe (diff) |
xtensa: implement ccount calibration for s6000
Calculate core frequency from timers at boot time
instead of assuming a fixed frequency. This is
useful as the true frequency is set up by the
boot loader, thus variable.
Signed-off-by: Oskar Schirmer <os@emlix.com>
Signed-off-by: Chris Zankel <chris@zankel.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/xtensa/Kconfig | 1 | ||||
-rw-r--r-- | arch/xtensa/variants/s6000/Makefile | 1 | ||||
-rw-r--r-- | arch/xtensa/variants/s6000/delay.c | 27 |
3 files changed, 29 insertions, 0 deletions
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 30d21a9e2ef5..ebe228d02b08 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig | |||
@@ -80,6 +80,7 @@ config XTENSA_VARIANT_S6000 | |||
80 | bool "s6000 - Stretch software configurable processor" | 80 | bool "s6000 - Stretch software configurable processor" |
81 | select VARIANT_IRQ_SWITCH | 81 | select VARIANT_IRQ_SWITCH |
82 | select ARCH_REQUIRE_GPIOLIB | 82 | select ARCH_REQUIRE_GPIOLIB |
83 | select XTENSA_CALIBRATE_CCOUNT | ||
83 | endchoice | 84 | endchoice |
84 | 85 | ||
85 | config XTENSA_UNALIGNED_USER | 86 | config XTENSA_UNALIGNED_USER |
diff --git a/arch/xtensa/variants/s6000/Makefile b/arch/xtensa/variants/s6000/Makefile index 03b3975468bd..d83f3805130c 100644 --- a/arch/xtensa/variants/s6000/Makefile +++ b/arch/xtensa/variants/s6000/Makefile | |||
@@ -1,3 +1,4 @@ | |||
1 | # s6000 Makefile | 1 | # s6000 Makefile |
2 | 2 | ||
3 | obj-y += irq.o gpio.o | 3 | obj-y += irq.o gpio.o |
4 | obj-$(CONFIG_XTENSA_CALIBRATE_CCOUNT) += delay.o | ||
diff --git a/arch/xtensa/variants/s6000/delay.c b/arch/xtensa/variants/s6000/delay.c new file mode 100644 index 000000000000..54b2b573f166 --- /dev/null +++ b/arch/xtensa/variants/s6000/delay.c | |||
@@ -0,0 +1,27 @@ | |||
1 | #include <asm/delay.h> | ||
2 | #include <asm/timex.h> | ||
3 | #include <asm/io.h> | ||
4 | #include <variant/hardware.h> | ||
5 | |||
6 | #define LOOPS 10 | ||
7 | void platform_calibrate_ccount(void) | ||
8 | { | ||
9 | u32 uninitialized_var(a); | ||
10 | u32 uninitialized_var(u); | ||
11 | u32 b; | ||
12 | u32 tstamp = S6_REG_GREG1 + S6_GREG1_GLOBAL_TIMER; | ||
13 | int i = LOOPS+1; | ||
14 | do { | ||
15 | u32 t = u; | ||
16 | asm volatile( | ||
17 | "1: l32i %0, %2, 0 ;" | ||
18 | " beq %0, %1, 1b ;" | ||
19 | : "=&a"(u) : "a"(t), "a"(tstamp)); | ||
20 | b = xtensa_get_ccount(); | ||
21 | if (i == LOOPS) | ||
22 | a = b; | ||
23 | } while (--i >= 0); | ||
24 | b -= a; | ||
25 | nsec_per_ccount = (LOOPS * 10000) / b; | ||
26 | ccount_per_jiffy = b * (100000UL / (LOOPS * HZ)); | ||
27 | } | ||