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

Subversion Repositories or1k

[/] [or1k/] [tags/] [LINUX_2_4_26_OR32/] [linux/] [linux-2.4/] [include/] [asm-m68k/] [delay.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
#ifndef _M68K_DELAY_H
2
#define _M68K_DELAY_H
3
 
4
#include <asm/param.h>
5
 
6
/*
7
 * Copyright (C) 1994 Hamish Macdonald
8
 *
9
 * Delay routines, using a pre-computed "loops_per_jiffy" value.
10
 */
11
 
12
static inline void __delay(unsigned long loops)
13
{
14
        __asm__ __volatile__ ("1: subql #1,%0; jcc 1b"
15
                : "=d" (loops) : "0" (loops));
16
}
17
 
18
extern void __bad_udelay(void);
19
extern void __bad_ndelay(void);
20
 
21
/*
22
 * Use only for very small delays ( < 1 msec).  Should probably use a
23
 * lookup table, really, as the multiplications take much too long with
24
 * short delays.  This is a "reasonable" implementation, though (and the
25
 * first constant multiplications gets optimized away if the delay is
26
 * a constant)
27
 */
28
static inline void __const_udelay(unsigned long xloops)
29
{
30
        unsigned long tmp;
31
 
32
        __asm__ ("mulul %2,%0:%1"
33
                : "=d" (xloops), "=d" (tmp)
34
                : "d" (xloops), "1" (loops_per_jiffy));
35
        __delay(xloops * HZ);
36
}
37
 
38
static inline void __udelay(unsigned long usecs)
39
{
40
        __const_udelay(usecs * 4295);   /* 2**32 / 1000000 */
41
}
42
 
43
static inline void __ndelay(unsigned long nsecs)
44
{
45
        __const_udelay(nsecs * 5);      /* 2**32 / 1000000000 */
46
}
47
 
48
#define udelay(n) (__builtin_constant_p(n) ? \
49
        ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 4295)) : \
50
        __udelay(n))
51
 
52
#define ndelay(n) (__builtin_constant_p(n) ? \
53
        ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5)) : \
54
        __ndelay(n))
55
 
56
static inline unsigned long muldiv(unsigned long a, unsigned long b,
57
                                   unsigned long c)
58
{
59
        unsigned long tmp;
60
 
61
        __asm__ ("mulul %2,%0:%1; divul %3,%0:%1"
62
                : "=d" (tmp), "=d" (a)
63
                : "d" (b), "d" (c), "1" (a));
64
        return a;
65
}
66
 
67
#endif /* defined(_M68K_DELAY_H) */

powered by: WebSVN 2.1.0

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