Commit 7b9726a7a0d8c70ea44a5ed23726748de344f223
1 parent
e7d7deca60
Exists in
master
and in
4 other branches
sh: Fix up the sh64 build.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Showing 2 changed files with 7 additions and 19 deletions Inline Diff
arch/sh/lib64/udelay.c
1 | /* | 1 | /* |
2 | * arch/sh/lib64/udelay.c | 2 | * arch/sh/lib64/udelay.c |
3 | * | 3 | * |
4 | * Delay routines, using a pre-computed "loops_per_jiffy" value. | 4 | * Delay routines, using a pre-computed "loops_per_jiffy" value. |
5 | * | 5 | * |
6 | * Copyright (C) 2000, 2001 Paolo Alberelli | 6 | * Copyright (C) 2000, 2001 Paolo Alberelli |
7 | * Copyright (C) 2003, 2004 Paul Mundt | 7 | * Copyright (C) 2003, 2004 Paul Mundt |
8 | * | 8 | * |
9 | * This file is subject to the terms and conditions of the GNU General Public | 9 | * This file is subject to the terms and conditions of the GNU General Public |
10 | * License. See the file "COPYING" in the main directory of this archive | 10 | * License. See the file "COPYING" in the main directory of this archive |
11 | * for more details. | 11 | * for more details. |
12 | */ | 12 | */ |
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <asm/param.h> | 14 | #include <asm/param.h> |
15 | 15 | ||
16 | /* | 16 | /* |
17 | * Use only for very small delays (< 1 msec). | 17 | * Use only for very small delays (< 1 msec). |
18 | * | 18 | * |
19 | * The active part of our cycle counter is only 32-bits wide, and | 19 | * The active part of our cycle counter is only 32-bits wide, and |
20 | * we're treating the difference between two marks as signed. On | 20 | * we're treating the difference between two marks as signed. On |
21 | * a 1GHz box, that's about 2 seconds. | 21 | * a 1GHz box, that's about 2 seconds. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | void __delay(int loops) | 24 | void __delay(unsigned long loops) |
25 | { | 25 | { |
26 | long long dummy; | 26 | long long dummy; |
27 | __asm__ __volatile__("gettr tr0, %1\n\t" | 27 | __asm__ __volatile__("gettr tr0, %1\n\t" |
28 | "pta $+4, tr0\n\t" | 28 | "pta $+4, tr0\n\t" |
29 | "addi %0, -1, %0\n\t" | 29 | "addi %0, -1, %0\n\t" |
30 | "bne %0, r63, tr0\n\t" | 30 | "bne %0, r63, tr0\n\t" |
31 | "ptabs %1, tr0\n\t":"=r"(loops), | 31 | "ptabs %1, tr0\n\t":"=r"(loops), |
32 | "=r"(dummy) | 32 | "=r"(dummy) |
33 | :"0"(loops)); | 33 | :"0"(loops)); |
34 | } | 34 | } |
35 | 35 | ||
36 | void __udelay(unsigned long long usecs, unsigned long lpj) | 36 | inline void __const_udelay(unsigned long xloops) |
37 | { | 37 | { |
38 | usecs *= (((unsigned long long) HZ << 32) / 1000000) * lpj; | 38 | __delay(xloops * (HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy)); |
39 | __delay((long long) usecs >> 32); | ||
40 | } | 39 | } |
41 | 40 | ||
42 | void __ndelay(unsigned long long nsecs, unsigned long lpj) | 41 | void __udelay(unsigned long usecs) |
43 | { | 42 | { |
44 | nsecs *= (((unsigned long long) HZ << 32) / 1000000000) * lpj; | 43 | __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */ |
45 | __delay((long long) nsecs >> 32); | ||
46 | } | 44 | } |
47 | 45 | ||
48 | void udelay(unsigned long usecs) | 46 | void __ndelay(unsigned long nsecs) |
49 | { | 47 | { |
50 | __udelay(usecs, cpu_data[raw_smp_processor_id()].loops_per_jiffy); | 48 | __const_udelay(nsecs * 0x00000005); |
51 | } | ||
52 | |||
53 | void ndelay(unsigned long nsecs) | ||
54 | { | ||
55 | __ndelay(nsecs, cpu_data[raw_smp_processor_id()].loops_per_jiffy); | ||
56 | } | 49 | } |
57 | 50 |
include/asm-sh/delay.h
1 | #ifndef __ASM_SH_DELAY_H | 1 | #ifndef __ASM_SH_DELAY_H |
2 | #define __ASM_SH_DELAY_H | 2 | #define __ASM_SH_DELAY_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * Copyright (C) 1993 Linus Torvalds | 5 | * Copyright (C) 1993 Linus Torvalds |
6 | * | 6 | * |
7 | * Delay routines calling functions in arch/sh/lib/delay.c | 7 | * Delay routines calling functions in arch/sh/lib/delay.c |
8 | */ | 8 | */ |
9 | 9 | ||
10 | extern void __bad_udelay(void); | 10 | extern void __bad_udelay(void); |
11 | extern void __bad_ndelay(void); | 11 | extern void __bad_ndelay(void); |
12 | 12 | ||
13 | extern void __udelay(unsigned long usecs); | 13 | extern void __udelay(unsigned long usecs); |
14 | extern void __ndelay(unsigned long nsecs); | 14 | extern void __ndelay(unsigned long nsecs); |
15 | extern void __const_udelay(unsigned long xloops); | 15 | extern void __const_udelay(unsigned long xloops); |
16 | extern void __delay(unsigned long loops); | 16 | extern void __delay(unsigned long loops); |
17 | 17 | ||
18 | #ifdef CONFIG_SUPERH32 | ||
19 | #define udelay(n) (__builtin_constant_p(n) ? \ | 18 | #define udelay(n) (__builtin_constant_p(n) ? \ |
20 | ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \ | 19 | ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \ |
21 | __udelay(n)) | 20 | __udelay(n)) |
22 | 21 | ||
23 | #define ndelay(n) (__builtin_constant_p(n) ? \ | 22 | #define ndelay(n) (__builtin_constant_p(n) ? \ |
24 | ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ | 23 | ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ |
25 | __ndelay(n)) | 24 | __ndelay(n)) |
26 | #else | ||
27 | extern void udelay(unsigned long usecs); | ||
28 | extern void ndelay(unsigned long nsecs); | ||
29 | #endif | ||
30 | 25 | ||
31 | #endif /* __ASM_SH_DELAY_H */ | 26 | #endif /* __ASM_SH_DELAY_H */ |
32 | 27 |