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
)
30 EXPORT_SYMBOL(__delay
);
32 void __const_udelay(unsigned long xloops
)
36 loops
= (u64
)xloops
* loops_per_jiffy
* HZ
;
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
);