blob: f4277529a9b94b7d7e4e115a1bf167644febd0d3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Yoshinori Satoa71a29d2015-01-28 02:48:15 +09002/*
3 * delay loops
4 *
5 * Copyright (C) 2015 Yoshinori Sato
6 */
7
8#include <linux/module.h>
9#include <linux/delay.h>
10#include <asm/param.h>
11#include <asm/processor.h>
12#include <asm/timex.h>
13
14void __delay(unsigned long cycles)
15{
16 __asm__ volatile ("1: dec.l #1,%0\n\t"
17 "bne 1b":"=r"(cycles):"0"(cycles));
18}
19EXPORT_SYMBOL(__delay);
20
21void __const_udelay(unsigned long xloops)
22{
23 u64 loops;
24
25 loops = (u64)xloops * loops_per_jiffy * HZ;
26
27 __delay(loops >> 32);
28}
29EXPORT_SYMBOL(__const_udelay);
30
31void __udelay(unsigned long usecs)
32{
33 __const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
34}
35EXPORT_SYMBOL(__udelay);
36
37void __ndelay(unsigned long nsecs)
38{
39 __const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
40}
41EXPORT_SYMBOL(__ndelay);