delay.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* MN10300 Short delay interpolation routines
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/sched.h>
  13. #include <linux/delay.h>
  14. #include <asm/div64.h>
  15. /*
  16. * basic delay loop
  17. */
  18. void __delay(unsigned long loops)
  19. {
  20. int d0;
  21. asm volatile(
  22. " bra 1f \n"
  23. " .align 4 \n"
  24. "1: bra 2f \n"
  25. " .align 4 \n"
  26. "2: add -1,%0 \n"
  27. " bne 2b \n"
  28. : "=&d" (d0)
  29. : "0" (loops)
  30. : "cc");
  31. }
  32. EXPORT_SYMBOL(__delay);
  33. /*
  34. * handle a delay specified in terms of microseconds
  35. */
  36. void __udelay(unsigned long usecs)
  37. {
  38. unsigned long start, stop, cnt;
  39. /* usecs * CLK / 1E6 */
  40. stop = __muldiv64u(usecs, MN10300_TSCCLK, 1000000);
  41. start = TMTSCBC;
  42. do {
  43. cnt = start - TMTSCBC;
  44. } while (cnt < stop);
  45. }
  46. EXPORT_SYMBOL(__udelay);