timer.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * timer.h -- ColdFire internal TIMER support defines.
  3. *
  4. * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
  5. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. /****************************************************************************/
  26. #ifndef timer_h
  27. #define timer_h
  28. /****************************************************************************/
  29. /****************************************************************************/
  30. /* Timer structure */
  31. /****************************************************************************/
  32. /* DMA Timer module registers */
  33. typedef struct dtimer_ctrl {
  34. #if defined(CONFIG_M5249) || defined(CONFIG_M5253)
  35. u16 tmr; /* 0x00 Mode register */
  36. u16 res1; /* 0x02 */
  37. u16 trr; /* 0x04 Reference register */
  38. u16 res2; /* 0x06 */
  39. u16 tcr; /* 0x08 Capture register */
  40. u16 res3; /* 0x0A */
  41. u16 tcn; /* 0x0C Counter register */
  42. u16 res4; /* 0x0E */
  43. u8 res6; /* 0x10 */
  44. u8 ter; /* 0x11 Event register */
  45. u16 res7; /* 0x12 */
  46. #else
  47. u16 tmr; /* 0x00 Mode register */
  48. u8 txmr; /* 0x02 Extended Mode register */
  49. u8 ter; /* 0x03 Event register */
  50. u32 trr; /* 0x04 Reference register */
  51. u32 tcr; /* 0x08 Capture register */
  52. u32 tcn; /* 0x0C Counter register */
  53. #endif
  54. } dtmr_t;
  55. /*Programmable Interrupt Timer */
  56. typedef struct pit_ctrl {
  57. u16 pcsr; /* 0x00 Control and Status Register */
  58. u16 pmr; /* 0x02 Modulus Register */
  59. u16 pcntr; /* 0x04 Count Register */
  60. } pit_t;
  61. /*********************************************************************
  62. * DMA Timers (DTIM)
  63. *********************************************************************/
  64. /* Bit definitions and macros for DTMR */
  65. #define DTIM_DTMR_RST (0x0001) /* Reset */
  66. #define DTIM_DTMR_CLK(x) (((x)&0x0003)<<1) /* Input clock source */
  67. #define DTIM_DTMR_FRR (0x0008) /* Free run/restart */
  68. #define DTIM_DTMR_ORRI (0x0010) /* Output reference request/interrupt enable */
  69. #define DTIM_DTMR_OM (0x0020) /* Output Mode */
  70. #define DTIM_DTMR_CE(x) (((x)&0x0003)<<6) /* Capture Edge */
  71. #define DTIM_DTMR_PS(x) (((x)&0x00FF)<<8) /* Prescaler value */
  72. #define DTIM_DTMR_RST_EN (0x0001)
  73. #define DTIM_DTMR_RST_RST (0x0000)
  74. #define DTIM_DTMR_CE_ANY (0x00C0)
  75. #define DTIM_DTMR_CE_FALL (0x0080)
  76. #define DTIM_DTMR_CE_RISE (0x0040)
  77. #define DTIM_DTMR_CE_NONE (0x0000)
  78. #define DTIM_DTMR_CLK_DTIN (0x0006)
  79. #define DTIM_DTMR_CLK_DIV16 (0x0004)
  80. #define DTIM_DTMR_CLK_DIV1 (0x0002)
  81. #define DTIM_DTMR_CLK_STOP (0x0000)
  82. /* Bit definitions and macros for DTXMR */
  83. #define DTIM_DTXMR_MODE16 (0x01) /* Increment Mode */
  84. #define DTIM_DTXMR_DMAEN (0x80) /* DMA request */
  85. /* Bit definitions and macros for DTER */
  86. #define DTIM_DTER_CAP (0x01) /* Capture event */
  87. #define DTIM_DTER_REF (0x02) /* Output reference event */
  88. /*********************************************************************
  89. *
  90. * Programmable Interrupt Timer Modules (PIT)
  91. *
  92. *********************************************************************/
  93. /* Bit definitions and macros for PCSR */
  94. #define PIT_PCSR_EN (0x0001)
  95. #define PIT_PCSR_RLD (0x0002)
  96. #define PIT_PCSR_PIF (0x0004)
  97. #define PIT_PCSR_PIE (0x0008)
  98. #define PIT_PCSR_OVW (0x0010)
  99. #define PIT_PCSR_HALTED (0x0020)
  100. #define PIT_PCSR_DOZE (0x0040)
  101. #define PIT_PCSR_PRE(x) (((x)&0x000F)<<8)
  102. /* Bit definitions and macros for PMR */
  103. #define PIT_PMR_PM(x) (x)
  104. /* Bit definitions and macros for PCNTR */
  105. #define PIT_PCNTR_PC(x) (x)
  106. /****************************************************************************/
  107. #endif /* timer_h */