File: delay.h

package info (click to toggle)
linux 4.19.194-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 967,940 kB
  • sloc: ansic: 16,799,826; asm: 272,028; makefile: 38,421; sh: 33,838; perl: 27,701; python: 21,148; cpp: 5,066; yacc: 4,650; lex: 2,584; awk: 1,385; ruby: 25; sed: 5
file content (39 lines) | stat: -rw-r--r-- 935 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
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2005-2017 Andes Technology Corporation

#ifndef __NDS32_DELAY_H__
#define __NDS32_DELAY_H__

#include <asm/param.h>

/* There is no clocksource cycle counter in the CPU. */
static inline void __delay(unsigned long loops)
{
	__asm__ __volatile__(".align 2\n"
			     "1:\n"
			     "\taddi\t%0, %0, -1\n"
			     "\tbgtz\t%0, 1b\n"
			     :"=r"(loops)
			     :"0"(loops));
}

static inline void __udelay(unsigned long usecs, unsigned long lpj)
{
	usecs *= (unsigned long)(((0x8000000000000000ULL / (500000 / HZ)) +
				  0x80000000ULL) >> 32);
	usecs = (unsigned long)(((unsigned long long)usecs * lpj) >> 32);
	__delay(usecs);
}

#define udelay(usecs) __udelay((usecs), loops_per_jiffy)

/* make sure "usecs *= ..." in udelay do not overflow. */
#if HZ >= 1000
#define MAX_UDELAY_MS	1
#elif HZ <= 200
#define MAX_UDELAY_MS	5
#else
#define MAX_UDELAY_MS	(1000 / HZ)
#endif

#endif