2024-09-09 08:52:07 +00:00
|
|
|
#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));
|
2024-09-09 08:57:42 +00:00
|
|
|
b = get_ccount();
|
2024-09-09 08:52:07 +00:00
|
|
|
if (i == LOOPS)
|
|
|
|
a = b;
|
|
|
|
} while (--i >= 0);
|
|
|
|
b -= a;
|
2024-09-09 08:57:42 +00:00
|
|
|
ccount_freq = b * (100000UL / LOOPS);
|
2024-09-09 08:52:07 +00:00
|
|
|
}
|