delay.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }
  31. EXPORT_SYMBOL(__delay);
  32. /*
  33. * handle a delay specified in terms of microseconds
  34. */
  35. void __udelay(unsigned long usecs)
  36. {
  37. signed long ioclk, stop;
  38. /* usecs * CLK / 1E6 */
  39. stop = __muldiv64u(usecs, MN10300_TSCCLK, 1000000);
  40. stop = TMTSCBC - stop;
  41. do {
  42. ioclk = TMTSCBC;
  43. } while (stop < ioclk);
  44. }
  45. EXPORT_SYMBOL(__udelay);