aboutsummaryrefslogtreecommitdiffstats
path: root/arch/xtensa/variants/s6000/delay.c
diff options
context:
space:
mode:
authorOskar Schirmer <os@emlix.com>2009-05-11 15:43:36 +0200
committerChris Zankel <chris@zankel.net>2009-05-11 22:00:17 -0700
commitb070a03f6490b0ac8d95c51b55a64e433d9160ab (patch)
tree4715316e494f17980504ee2902a14e1a7d495d05 /arch/xtensa/variants/s6000/delay.c
parentxtensa: fix wrong extern declaration renamed in code using it (diff)
downloadlinux-dev-b070a03f6490b0ac8d95c51b55a64e433d9160ab.tar.xz
linux-dev-b070a03f6490b0ac8d95c51b55a64e433d9160ab.zip
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 '')
-rw-r--r--arch/xtensa/variants/s6000/delay.c27
1 files changed, 27 insertions, 0 deletions
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 @@
+#include <asm/delay.h>
+#include <asm/timex.h>
+#include <asm/io.h>
+#include <variant/hardware.h>
+
+#define LOOPS 10
+void platform_calibrate_ccount(void)
+{
+ u32 uninitialized_var(a);
+ u32 uninitialized_var(u);
+ u32 b;
+ u32 tstamp = S6_REG_GREG1 + S6_GREG1_GLOBAL_TIMER;
+ int i = LOOPS+1;
+ do {
+ u32 t = u;
+ asm volatile(
+ "1: l32i %0, %2, 0 ;"
+ " beq %0, %1, 1b ;"
+ : "=&a"(u) : "a"(t), "a"(tstamp));
+ b = xtensa_get_ccount();
+ if (i == LOOPS)
+ a = b;
+ } while (--i >= 0);
+ b -= a;
+ nsec_per_ccount = (LOOPS * 10000) / b;
+ ccount_per_jiffy = b * (100000UL / (LOOPS * HZ));
+}