File: delay.c

package info (click to toggle)
linux 3.2.73-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 692,996 kB
  • sloc: ansic: 9,719,677; asm: 244,034; xml: 40,377; makefile: 23,845; perl: 16,079; python: 4,929; sh: 4,425; cpp: 3,598; yacc: 2,979; lex: 1,726; awk: 708; pascal: 231; lisp: 218; sed: 30
file content (27 lines) | stat: -rw-r--r-- 581 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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));
}