time.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * asm-blackfin/time.h:
  3. *
  4. * Copyright 2004-2008 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef _ASM_BLACKFIN_TIME_H
  9. #define _ASM_BLACKFIN_TIME_H
  10. /*
  11. * The way that the Blackfin core timer works is:
  12. * - CCLK is divided by a programmable 8-bit pre-scaler (TSCALE)
  13. * - Every time TSCALE ticks, a 32bit is counted down (TCOUNT)
  14. *
  15. * If you take the fastest clock (1ns, or 1GHz to make the math work easier)
  16. * 10ms is 10,000,000 clock ticks, which fits easy into a 32-bit counter
  17. * (32 bit counter is 4,294,967,296ns or 4.2 seconds) so, we don't need
  18. * to use TSCALE, and program it to zero (which is pass CCLK through).
  19. * If you feel like using it, try to keep HZ * TIMESCALE to some
  20. * value that divides easy (like power of 2).
  21. */
  22. #ifndef CONFIG_CPU_FREQ
  23. # define TIME_SCALE 1
  24. #else
  25. /*
  26. * Blackfin CPU frequency scaling supports max Core Clock 1, 1/2 and 1/4 .
  27. * Whenever we change the Core Clock frequency changes we immediately
  28. * adjust the Core Timer Presale Register. This way we don't lose time.
  29. */
  30. #define TIME_SCALE 4
  31. # ifdef CONFIG_CYCLES_CLOCKSOURCE
  32. extern unsigned long long __bfin_cycles_off;
  33. extern unsigned int __bfin_cycles_mod;
  34. # endif
  35. #endif
  36. #if defined(CONFIG_TICKSOURCE_CORETMR)
  37. extern void bfin_coretmr_init(void);
  38. extern void bfin_coretmr_clockevent_init(void);
  39. #endif
  40. #endif