root/include/asm-m68k/delay.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __delay
  2. udelay
  3. muldiv

   1 #ifndef _M68K_DELAY_H
   2 #define _M68K_DELAY_H
   3 
   4 /*
   5  * Copyright (C) 1994 Hamish Macdonald
   6  *
   7  * Delay routines, using a pre-computed "loops_per_second" value.
   8  */
   9 
  10 extern __inline__ void __delay(int loops)
     /* [previous][next][first][last][top][bottom][index][help] */
  11 {
  12         __asm__("\n\tmovel %0,%/d0\n1:\tsubql #1,%/d0\n\tbpls 1b\n"
  13                 : /* no outputs */
  14                 : "g" (loops)
  15                 : "d0");
  16 }
  17 
  18 /*
  19  * Use only for very small delays ( < 1 msec).  Should probably use a
  20  * lookup table, really, as the multiplications take much too long with
  21  * short delays.  This is a "reasonable" implementation, though (and the
  22  * first constant multiplications gets optimized away if the delay is
  23  * a constant)  
  24  */
  25 extern __inline__ void udelay(unsigned long usecs)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27         usecs *= 0x000010c6;            /* 2**32 / 1000000 */
  28 
  29         asm ("mulul %1,%0:%2"
  30              : "=d" (usecs)
  31              : "d" (usecs),
  32                "d" (loops_per_sec));
  33         __delay(usecs);
  34 }
  35 
  36 extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
     /* [previous][next][first][last][top][bottom][index][help] */
  37 {
  38         __asm__("mulul %1,%/d0:%0\n\tdivul %2,%/d0:%0"
  39                 :"=d" (a)
  40                 :"d" (b),
  41                 "d" (c),
  42                 "0" (a)
  43                 :"d0");
  44         return a;
  45 }
  46 
  47 #endif /* defined(_M68K_DELAY_H) */

/* [previous][next][first][last][top][bottom][index][help] */