Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/s390/lib/delay.c
26424 views
1
// SPDX-License-Identifier: GPL-2.0
2
/*
3
* Precise Delay Loops for S390
4
*
5
* Copyright IBM Corp. 1999, 2008
6
* Author(s): Martin Schwidefsky <[email protected]>,
7
*/
8
9
#include <linux/processor.h>
10
#include <linux/export.h>
11
#include <linux/delay.h>
12
#include <asm/div64.h>
13
#include <asm/timex.h>
14
15
void __delay(unsigned long loops)
16
{
17
/*
18
* Loop 'loops' times. Callers must not assume a specific
19
* amount of time passes before this function returns.
20
*/
21
asm volatile("0: brct %0,0b" : : "d" ((loops/2) + 1));
22
}
23
EXPORT_SYMBOL(__delay);
24
25
static void delay_loop(unsigned long delta)
26
{
27
unsigned long end;
28
29
end = get_tod_clock_monotonic() + delta;
30
while (!tod_after(get_tod_clock_monotonic(), end))
31
cpu_relax();
32
}
33
34
void __udelay(unsigned long usecs)
35
{
36
delay_loop(usecs << 12);
37
}
38
EXPORT_SYMBOL(__udelay);
39
40
void __ndelay(unsigned long nsecs)
41
{
42
nsecs <<= 9;
43
do_div(nsecs, 125);
44
delay_loop(nsecs);
45
}
46
EXPORT_SYMBOL(__ndelay);
47
48