root/include/asm-mips/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 __ASM_MIPS_DELAY_H
   2 #define __ASM_MIPS_DELAY_H
   3 
   4 extern __inline__ void __delay(int loops)
     /* [previous][next][first][last][top][bottom][index][help] */
   5 {
   6         __asm__ __volatile__ (
   7                 ".set\tnoreorder\n\t"
   8                 ".set\tnoat\n\t"
   9                 "1:\tbne\t$0,%0,1b\n\t"
  10                 "subu\t%0,%0,1\n\t"
  11                 ".set\tat\n\t"
  12                 ".set\treorder"
  13                 :"=r" (loops)
  14                 :"0" (loops));
  15 }
  16 
  17 /*
  18  * division by multiplication: you don't have to worry about
  19  * loss of precision.
  20  *
  21  * Use only for very small delays ( < 1 msec).  Should probably use a
  22  * lookup table, really, as the multiplications take much too long with
  23  * short delays.  This is a "reasonable" implementation, though (and the
  24  * first constant multiplications gets optimized away if the delay is
  25  * a constant)
  26  */
  27 extern __inline__ void udelay(unsigned long usecs)
     /* [previous][next][first][last][top][bottom][index][help] */
  28 {
  29         usecs *= 0x000010c6;            /* 2**32 / 1000000 */
  30         __asm__("multu\t%0,%1\n\t"
  31                 "mfhi\t%0"
  32                 :"=r" (usecs)
  33                 :"0" (usecs),"r" (loops_per_sec));
  34         __delay(usecs);
  35 }
  36 
  37 /*
  38  * The different variants for 32/64 bit are pure paranoia. The typical
  39  * range of numbers that appears for MIPS machines avoids overflows.
  40  */
  41 extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43         return (a*b)/c;
  44 }
  45 
  46 #endif /* __ASM_MIPS_DELAY_H */

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