Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / arch / xtensa / variants / s6000 / delay.c
blob39154563ee176f2b75506c0b06241e2f7ad3e578
1 #include <asm/timex.h>
2 #include <asm/io.h>
3 #include <variant/hardware.h>
5 #define LOOPS 10
6 void platform_calibrate_ccount(void)
8 u32 uninitialized_var(a);
9 u32 uninitialized_var(u);
10 u32 b;
11 u32 tstamp = S6_REG_GREG1 + S6_GREG1_GLOBAL_TIMER;
12 int i = LOOPS+1;
13 do {
14 u32 t = u;
15 asm volatile(
16 "1: l32i %0, %2, 0 ;"
17 " beq %0, %1, 1b ;"
18 : "=&a"(u) : "a"(t), "a"(tstamp));
19 b = get_ccount();
20 if (i == LOOPS)
21 a = b;
22 } while (--i >= 0);
23 b -= a;
24 ccount_freq = b * (100000UL / LOOPS);