aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/nds32/include/asm/delay.h39
-rw-r--r--arch/nds32/include/asm/linkage.h11
-rw-r--r--arch/nds32/include/uapi/asm/byteorder.h13
3 files changed, 63 insertions, 0 deletions
diff --git a/arch/nds32/include/asm/delay.h b/arch/nds32/include/asm/delay.h
new file mode 100644
index 000000000000..519ba97acb6e
--- /dev/null
+++ b/arch/nds32/include/asm/delay.h
@@ -0,0 +1,39 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2005-2017 Andes Technology Corporation
3
4#ifndef __NDS32_DELAY_H__
5#define __NDS32_DELAY_H__
6
7#include <asm/param.h>
8
9/* There is no clocksource cycle counter in the CPU. */
10static inline void __delay(unsigned long loops)
11{
12 __asm__ __volatile__(".align 2\n"
13 "1:\n"
14 "\taddi\t%0, %0, -1\n"
15 "\tbgtz\t%0, 1b\n"
16 :"=r"(loops)
17 :"0"(loops));
18}
19
20static inline void __udelay(unsigned long usecs, unsigned long lpj)
21{
22 usecs *= (unsigned long)(((0x8000000000000000ULL / (500000 / HZ)) +
23 0x80000000ULL) >> 32);
24 usecs = (unsigned long)(((unsigned long long)usecs * lpj) >> 32);
25 __delay(usecs);
26}
27
28#define udelay(usecs) __udelay((usecs), loops_per_jiffy)
29
30/* make sure "usecs *= ..." in udelay do not overflow. */
31#if HZ >= 1000
32#define MAX_UDELAY_MS 1
33#elif HZ <= 200
34#define MAX_UDELAY_MS 5
35#else
36#define MAX_UDELAY_MS (1000 / HZ)
37#endif
38
39#endif
diff --git a/arch/nds32/include/asm/linkage.h b/arch/nds32/include/asm/linkage.h
new file mode 100644
index 000000000000..e708c8bdb926
--- /dev/null
+++ b/arch/nds32/include/asm/linkage.h
@@ -0,0 +1,11 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2005-2017 Andes Technology Corporation
3
4#ifndef __ASM_LINKAGE_H
5#define __ASM_LINKAGE_H
6
7/* This file is required by include/linux/linkage.h */
8#define __ALIGN .align 2
9#define __ALIGN_STR ".align 2"
10
11#endif
diff --git a/arch/nds32/include/uapi/asm/byteorder.h b/arch/nds32/include/uapi/asm/byteorder.h
new file mode 100644
index 000000000000..a23f6f3a2468
--- /dev/null
+++ b/arch/nds32/include/uapi/asm/byteorder.h
@@ -0,0 +1,13 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2005-2017 Andes Technology Corporation
3
4#ifndef __NDS32_BYTEORDER_H__
5#define __NDS32_BYTEORDER_H__
6
7#ifdef __NDS32_EB__
8#include <linux/byteorder/big_endian.h>
9#else
10#include <linux/byteorder/little_endian.h>
11#endif
12
13#endif /* __NDS32_BYTEORDER_H__ */