time.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * (C) Copyright 2000, 2001
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2007
  6. * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. /* Implemented by SPARC CPUs */
  12. extern void cpu_wait_ticks(unsigned long ticks);
  13. extern unsigned long cpu_usec2ticks(unsigned long usec);
  14. extern unsigned long cpu_ticks2usec(unsigned long ticks);
  15. /* ------------------------------------------------------------------------- */
  16. void wait_ticks(unsigned long ticks)
  17. {
  18. cpu_wait_ticks(ticks);
  19. }
  20. /*
  21. * This function is intended for SHORT delays only.
  22. */
  23. unsigned long usec2ticks(unsigned long usec)
  24. {
  25. return cpu_usec2ticks(usec);
  26. }
  27. /* ------------------------------------------------------------------------- */
  28. /*
  29. * We implement the delay by converting the delay (the number of
  30. * microseconds to wait) into a number of time base ticks; then we
  31. * watch the time base until it has incremented by that amount.
  32. */
  33. void __udelay(unsigned long usec)
  34. {
  35. ulong ticks = usec2ticks(usec);
  36. wait_ticks(ticks);
  37. }
  38. /* ------------------------------------------------------------------------- */
  39. unsigned long ticks2usec(unsigned long ticks)
  40. {
  41. return cpu_ticks2usec(ticks);
  42. }
  43. /* ------------------------------------------------------------------------- */
  44. int init_timebase(void)
  45. {
  46. return (0);
  47. }
  48. /* ------------------------------------------------------------------------- */