[ARM] 3684/1: ARM: Convert l7200 to generic irq handling
[linux-2.6/kvm.git] / arch / s390 / lib / delay.c
blob468f4ea33f99efdf1f83802ed4433146ac485b57
1 /*
2 * arch/s390/kernel/delay.c
3 * Precise Delay Loops for S390
5 * S390 version
6 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
9 * Derived from "arch/i386/lib/delay.c"
10 * Copyright (C) 1993 Linus Torvalds
11 * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
14 #include <linux/sched.h>
15 #include <linux/delay.h>
17 #ifdef CONFIG_SMP
18 #include <asm/smp.h>
19 #endif
21 void __delay(unsigned long loops)
24 * To end the bloody studid and useless discussion about the
25 * BogoMips number I took the liberty to define the __delay
26 * function in a way that that resulting BogoMips number will
27 * yield the megahertz number of the cpu. The important function
28 * is udelay and that is done using the tod clock. -- martin.
30 __asm__ __volatile__(
31 "0: brct %0,0b"
32 : /* no outputs */ : "r" ((loops/2) + 1));
36 * Waits for 'usecs' microseconds using the tod clock, giving up the time slice
37 * of the virtual PU inbetween to avoid congestion.
39 void __udelay(unsigned long usecs)
41 uint64_t start_cc, end_cc;
43 if (usecs == 0)
44 return;
45 asm volatile ("STCK %0" : "=m" (start_cc));
46 do {
47 cpu_relax();
48 asm volatile ("STCK %0" : "=m" (end_cc));
49 } while (((end_cc - start_cc)/4096) < usecs);