Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* delay.c: Delay loops for sparc64 |
| 2 | * |
David S. Miller | 3763be3 | 2006-02-17 12:33:13 -0800 | [diff] [blame] | 3 | * Copyright (C) 2004, 2006 David S. Miller <davem@davemloft.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | * Based heavily upon x86 variant which is: |
| 6 | * Copyright (C) 1993 Linus Torvalds |
| 7 | * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz> |
| 8 | */ |
| 9 | |
| 10 | #include <linux/delay.h> |
David S. Miller | 3763be3 | 2006-02-17 12:33:13 -0800 | [diff] [blame] | 11 | #include <asm/timer.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | void __delay(unsigned long loops) |
| 14 | { |
David S. Miller | 3763be3 | 2006-02-17 12:33:13 -0800 | [diff] [blame] | 15 | unsigned long bclock, now; |
| 16 | |
| 17 | bclock = tick_ops->get_tick(); |
| 18 | do { |
| 19 | now = tick_ops->get_tick(); |
| 20 | } while ((now-bclock) < loops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | /* We used to multiply by HZ after shifting down by 32 bits |
| 24 | * but that runs into problems for higher values of HZ and |
| 25 | * slow cpus. |
| 26 | */ |
| 27 | void __const_udelay(unsigned long n) |
| 28 | { |
| 29 | n *= 4; |
| 30 | |
Ingo Molnar | 39c715b | 2005-06-21 17:14:34 -0700 | [diff] [blame] | 31 | n *= (cpu_data(raw_smp_processor_id()).udelay_val * (HZ/4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | n >>= 32; |
| 33 | |
| 34 | __delay(n + 1); |
| 35 | } |
| 36 | |
| 37 | void __udelay(unsigned long n) |
| 38 | { |
| 39 | __const_udelay(n * 0x10c7UL); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | void __ndelay(unsigned long n) |
| 44 | { |
| 45 | __const_udelay(n * 0x5UL); |
| 46 | } |