x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / metag / lib / delay.c
blob0b308f48b37a20cf35836674b5abc6b6e0216a0d
1 /*
2 * Precise Delay Loops for Meta
4 * Copyright (C) 1993 Linus Torvalds
5 * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 * Copyright (C) 2007,2009 Imagination Technologies Ltd.
8 */
10 #include <linux/export.h>
11 #include <linux/sched.h>
12 #include <linux/delay.h>
14 #include <asm/core_reg.h>
15 #include <asm/processor.h>
18 * TXTACTCYC is only 24 bits, so on chips with fast clocks it will wrap
19 * many times per-second. If it does wrap __delay will return prematurely,
20 * but this is only likely with large delay values.
22 * We also can't implement read_current_timer() with TXTACTCYC due to
23 * this wrapping behaviour.
25 #define rdtimer(t) t = __core_reg_get(TXTACTCYC)
27 void __delay(unsigned long loops)
29 unsigned long bclock, now;
31 rdtimer(bclock);
32 do {
33 asm("NOP");
34 rdtimer(now);
35 } while ((now-bclock) < loops);
37 EXPORT_SYMBOL(__delay);
39 inline void __const_udelay(unsigned long xloops)
41 u64 loops = (u64)xloops * (u64)loops_per_jiffy * HZ;
42 __delay(loops >> 32);
44 EXPORT_SYMBOL(__const_udelay);
46 void __udelay(unsigned long usecs)
48 __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
50 EXPORT_SYMBOL(__udelay);
52 void __ndelay(unsigned long nsecs)
54 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
56 EXPORT_SYMBOL(__ndelay);