File: delay.h

package info (click to toggle)
kernel-source-2.1.125 2.1.125-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 61,100 kB
  • ctags: 177,944
  • sloc: ansic: 1,045,652; asm: 47,658; makefile: 7,656; sh: 1,038; perl: 836; cpp: 521; tcl: 427; lisp: 218; awk: 133; sed: 72
file content (33 lines) | stat: -rw-r--r-- 841 bytes parent folder | download | duplicates (4)
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
28
29
30
31
32
33
#ifndef _PPC_DELAY_H
#define _PPC_DELAY_H

/*
 * Copyright 1996, Paul Mackerras.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

extern unsigned long loops_per_sec;

extern __inline__ void __delay(unsigned int loops)
{
	if (loops != 0)
		__asm__ __volatile__("mtctr %0; 1: bdnz 1b" : :
				     "r" (loops) : "ctr");
}

extern __inline__ void udelay(unsigned long usecs)
{
	unsigned long loops;

	/* compute (usecs * 2^32 / 10^6) * loops_per_sec / 2^32 */
	usecs *= 0x10c6;		/* 2^32 / 10^6 */
	__asm__("mulhwu %0,%1,%2" : "=r" (loops) :
		"r" (usecs), "r" (loops_per_sec));
	__delay(loops);
}

#endif /* defined(_PPC_DELAY_H) */