v850e_timer_d.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * include/asm-v850/v850e_timer_d.h -- `Timer D' component often used
  3. * with the V850E cpu core
  4. *
  5. * Copyright (C) 2001,02,03 NEC Electronics Corporation
  6. * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General
  9. * Public License. See the file COPYING in the main directory of this
  10. * archive for more details.
  11. *
  12. * Written by Miles Bader <miles@gnu.org>
  13. */
  14. #ifndef __V850_V850E_TIMER_D_H__
  15. #define __V850_V850E_TIMER_D_H__
  16. #include <asm/types.h>
  17. #include <asm/machdep.h> /* Pick up chip-specific defs. */
  18. /* Timer D (16-bit interval timers). */
  19. /* Count registers for timer D. */
  20. #define V850E_TIMER_D_TMD_ADDR(n) (V850E_TIMER_D_TMD_BASE_ADDR + 0x10 * (n))
  21. #define V850E_TIMER_D_TMD(n) (*(volatile u16 *)V850E_TIMER_D_TMD_ADDR(n))
  22. /* Count compare registers for timer D. */
  23. #define V850E_TIMER_D_CMD_ADDR(n) (V850E_TIMER_D_CMD_BASE_ADDR + 0x10 * (n))
  24. #define V850E_TIMER_D_CMD(n) (*(volatile u16 *)V850E_TIMER_D_CMD_ADDR(n))
  25. /* Control registers for timer D. */
  26. #define V850E_TIMER_D_TMCD_ADDR(n) (V850E_TIMER_D_TMCD_BASE_ADDR + 0x10 * (n))
  27. #define V850E_TIMER_D_TMCD(n) (*(volatile u8 *)V850E_TIMER_D_TMCD_ADDR(n))
  28. /* Control bits for timer D. */
  29. #define V850E_TIMER_D_TMCD_CE 0x2 /* count enable */
  30. #define V850E_TIMER_D_TMCD_CAE 0x1 /* clock action enable */
  31. /* Clock divider setting (log2). */
  32. #define V850E_TIMER_D_TMCD_CS(divlog2) (((divlog2) - V850E_TIMER_D_TMCD_CS_MIN) << 4)
  33. /* Minimum clock divider setting (log2). */
  34. #ifndef V850E_TIMER_D_TMCD_CS_MIN /* Can be overridden by mach-specific hdrs */
  35. #define V850E_TIMER_D_TMCD_CS_MIN 2 /* Default is correct for the v850e/ma1 */
  36. #endif
  37. /* Maximum clock divider setting (log2). */
  38. #define V850E_TIMER_D_TMCD_CS_MAX (V850E_TIMER_D_TMCD_CS_MIN + 7)
  39. /* Return the clock-divider (log2) of timer D unit N. */
  40. #define V850E_TIMER_D_DIVLOG2(n) \
  41. (((V850E_TIMER_D_TMCD(n) >> 4) & 0x7) + V850E_TIMER_D_TMCD_CS_MIN)
  42. #ifndef __ASSEMBLY__
  43. /* Start interval timer TIMER (0-3). The timer will issue the
  44. corresponding INTCMD interrupt RATE times per second. This function
  45. does not enable the interrupt. */
  46. extern void v850e_timer_d_configure (unsigned timer, unsigned rate);
  47. #endif /* !__ASSEMBLY__ */
  48. #endif /* __V850_V850E_TIMER_D_H__ */