WIP FPC-III support
[linux/fpc-iii.git] / arch / s390 / lib / delay.c
blobf289afeb3f3169c26723f6de6f9f42eba438c2b1
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Precise Delay Loops for S390
5 * Copyright IBM Corp. 1999, 2008
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 * Heiko Carstens <heiko.carstens@de.ibm.com>,
8 */
10 #include <linux/sched.h>
11 #include <linux/delay.h>
12 #include <linux/timex.h>
13 #include <linux/export.h>
14 #include <linux/irqflags.h>
15 #include <linux/interrupt.h>
16 #include <linux/jump_label.h>
17 #include <linux/irq.h>
18 #include <asm/vtimer.h>
19 #include <asm/div64.h>
20 #include <asm/idle.h>
22 void __delay(unsigned long loops)
25 * To end the bloody studid and useless discussion about the
26 * BogoMips number I took the liberty to define the __delay
27 * function in a way that that resulting BogoMips number will
28 * yield the megahertz number of the cpu. The important function
29 * is udelay and that is done using the tod clock. -- martin.
31 asm volatile("0: brct %0,0b" : : "d" ((loops/2) + 1));
33 EXPORT_SYMBOL(__delay);
35 static void delay_loop(unsigned long delta)
37 unsigned long end;
39 end = get_tod_clock_monotonic() + delta;
40 while (!tod_after(get_tod_clock_monotonic(), end))
41 cpu_relax();
44 void __udelay(unsigned long usecs)
46 delay_loop(usecs << 12);
48 EXPORT_SYMBOL(__udelay);
50 void __ndelay(unsigned long nsecs)
52 nsecs <<= 9;
53 do_div(nsecs, 125);
54 delay_loop(nsecs);
56 EXPORT_SYMBOL(__ndelay);