spi: fsl-espi: add support for dual output read mode
[linux-2.6/btrfs-unstable.git] / arch / nios2 / lib / delay.c
blob088119cd0cc542a8b1d8e42ba08e20f7b5a73a37
1 /* Copyright Altera Corporation (C) 2014. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License, version 2,
5 * as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <linux/module.h>
18 #include <asm/delay.h>
19 #include <asm/param.h>
20 #include <asm/processor.h>
21 #include <asm/timex.h>
23 void __delay(unsigned long cycles)
25 cycles_t start = get_cycles();
27 while ((get_cycles() - start) < cycles)
28 cpu_relax();
30 EXPORT_SYMBOL(__delay);
32 void __const_udelay(unsigned long xloops)
34 u64 loops;
36 loops = (u64)xloops * loops_per_jiffy * HZ;
38 __delay(loops >> 32);
40 EXPORT_SYMBOL(__const_udelay);
42 void __udelay(unsigned long usecs)
44 __const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
46 EXPORT_SYMBOL(__udelay);
48 void __ndelay(unsigned long nsecs)
50 __const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
52 EXPORT_SYMBOL(__ndelay);