OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-mips/] [delay.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
2
 * This file is subject to the terms and conditions of the GNU General Public
3
 * License.  See the file "COPYING" in the main directory of this archive
4
 * for more details.
5
 *
6
 * Copyright (C) 1994 by Waldorf Electronics
7
 * Copyright (C) 1995 - 1998, 2001 by Ralf Baechle
8
 */
9
#ifndef _ASM_DELAY_H
10
#define _ASM_DELAY_H
11
 
12
#include <linux/config.h>
13
#include <linux/param.h>
14
 
15
extern unsigned long loops_per_jiffy;
16
 
17
static __inline__ void __delay(unsigned long loops)
18
{
19
        __asm__ __volatile__ (
20
                ".set\tnoreorder\n"
21
                "1:\tbnez\t%0,1b\n\t"
22
                "subu\t%0,1\n\t"
23
                ".set\treorder"
24
                :"=r" (loops)
25
                :"0" (loops));
26
}
27
 
28
/*
29
 * Division by multiplication: you don't have to worry about
30
 * loss of precision.
31
 *
32
 * Use only for very small delays ( < 1 msec).  Should probably use a
33
 * lookup table, really, as the multiplications take much too long with
34
 * short delays.  This is a "reasonable" implementation, though (and the
35
 * first constant multiplications gets optimized away if the delay is
36
 * a constant)
37
 */
38
static __inline__ void __udelay(unsigned long usecs, unsigned long lpj)
39
{
40
        unsigned long lo;
41
 
42
        /*
43
         * Excessive precission?  Probably ...
44
         */
45
        usecs *= (unsigned long) (((0x8000000000000000ULL / (500000 / HZ)) +
46
                                   0x80000000ULL) >> 32);
47
        __asm__("multu\t%2,%3"
48
                :"=h" (usecs), "=l" (lo)
49
                :"r" (usecs),"r" (lpj));
50
        __delay(usecs);
51
}
52
 
53
static __inline__ void __ndelay(unsigned long nsecs, unsigned long lpj)
54
{
55
        unsigned long lo;
56
 
57
        /*
58
         * Excessive precission?  Probably ...
59
         */
60
        nsecs *= (unsigned long) (((0x8000000000000000ULL / (500000000 / HZ)) +
61
                                   0x80000000ULL) >> 32);
62
        __asm__("multu\t%2,%3"
63
                :"=h" (nsecs), "=l" (lo)
64
                :"r" (nsecs),"r" (lpj));
65
        __delay(nsecs);
66
}
67
 
68
#ifdef CONFIG_SMP
69
#define __udelay_val cpu_data[smp_processor_id()].udelay_val
70
#else
71
#define __udelay_val loops_per_jiffy
72
#endif
73
 
74
#define udelay(usecs) __udelay((usecs),__udelay_val)
75
#define ndelay(nsecs) __ndelay((nsecs),__udelay_val)
76
 
77
#endif /* _ASM_DELAY_H */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.