mcftimer.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * mcftimer.h -- ColdFire internal TIMER support defines.
  3. *
  4. * Based on mcftimer.h of uCLinux distribution:
  5. * (C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com)
  6. * (C) Copyright 2000, Lineo Inc. (www.lineo.com)
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. /****************************************************************************/
  27. #ifndef mcftimer_h
  28. #define mcftimer_h
  29. /****************************************************************************/
  30. #include <linux/config.h>
  31. /*
  32. * Get address specific defines for this ColdFire member.
  33. */
  34. #if defined(CONFIG_M5204) || defined(CONFIG_M5206) || defined(CONFIG_M5206e)
  35. #define MCFTIMER_BASE1 0x100 /* Base address of TIMER1 */
  36. #define MCFTIMER_BASE2 0x120 /* Base address of TIMER2 */
  37. #elif defined(CONFIG_M5272)
  38. #define MCFTIMER_BASE1 0x200 /* Base address of TIMER1 */
  39. #define MCFTIMER_BASE2 0x220 /* Base address of TIMER2 */
  40. #define MCFTIMER_BASE3 0x240 /* Base address of TIMER4 */
  41. #define MCFTIMER_BASE4 0x260 /* Base address of TIMER3 */
  42. #elif defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407)
  43. #define MCFTIMER_BASE1 0x140 /* Base address of TIMER1 */
  44. #define MCFTIMER_BASE2 0x180 /* Base address of TIMER2 */
  45. #elif defined(CONFIG_M5282) | defined(CONFIG_M5271)
  46. #define MCFTIMER_BASE1 0x150000 /* Base address of TIMER1 */
  47. #define MCFTIMER_BASE2 0x160000 /* Base address of TIMER2 */
  48. #define MCFTIMER_BASE3 0x170000 /* Base address of TIMER4 */
  49. #define MCFTIMER_BASE4 0x180000 /* Base address of TIMER3 */
  50. #endif
  51. /*
  52. * Define the TIMER register set addresses.
  53. */
  54. #define MCFTIMER_TMR 0x00 /* Timer Mode reg (r/w) */
  55. #define MCFTIMER_TRR 0x02 /* Timer Reference (r/w) */
  56. #define MCFTIMER_TCR 0x04 /* Timer Capture reg (r/w) */
  57. #define MCFTIMER_TCN 0x06 /* Timer Counter reg (r/w) */
  58. #define MCFTIMER_TER 0x11 /* Timer Event reg (r/w) */
  59. /*
  60. * Define the TIMER register set addresses for 5282.
  61. */
  62. #define MCFTIMER_PCSR 0
  63. #define MCFTIMER_PMR 1
  64. #define MCFTIMER_PCNTR 2
  65. /*
  66. * Bit definitions for the Timer Mode Register (TMR).
  67. * Register bit flags are common accross ColdFires.
  68. */
  69. #define MCFTIMER_TMR_PREMASK 0xff00 /* Prescalar mask */
  70. #define MCFTIMER_TMR_DISCE 0x0000 /* Disable capture */
  71. #define MCFTIMER_TMR_ANYCE 0x00c0 /* Capture any edge */
  72. #define MCFTIMER_TMR_FALLCE 0x0080 /* Capture fallingedge */
  73. #define MCFTIMER_TMR_RISECE 0x0040 /* Capture rising edge */
  74. #define MCFTIMER_TMR_ENOM 0x0020 /* Enable output toggle */
  75. #define MCFTIMER_TMR_DISOM 0x0000 /* Do single output pulse */
  76. #define MCFTIMER_TMR_ENORI 0x0010 /* Enable ref interrupt */
  77. #define MCFTIMER_TMR_DISORI 0x0000 /* Disable ref interrupt */
  78. #define MCFTIMER_TMR_RESTART 0x0008 /* Restart counter */
  79. #define MCFTIMER_TMR_FREERUN 0x0000 /* Free running counter */
  80. #define MCFTIMER_TMR_CLKTIN 0x0006 /* Input clock is TIN */
  81. #define MCFTIMER_TMR_CLK16 0x0004 /* Input clock is /16 */
  82. #define MCFTIMER_TMR_CLK1 0x0002 /* Input clock is /1 */
  83. #define MCFTIMER_TMR_CLKSTOP 0x0000 /* Stop counter */
  84. #define MCFTIMER_TMR_ENABLE 0x0001 /* Enable timer */
  85. #define MCFTIMER_TMR_DISABLE 0x0000 /* Disable timer */
  86. /*
  87. * Bit definitions for the Timer Event Registers (TER).
  88. */
  89. #define MCFTIMER_TER_CAP 0x01 /* Capture event */
  90. #define MCFTIMER_TER_REF 0x02 /* Refernece event */
  91. /*
  92. * Bit definitions for the 5282 PIT Control and Status Register (PCSR).
  93. */
  94. #define MCFTIMER_PCSR_EN 0x0001
  95. #define MCFTIMER_PCSR_RLD 0x0002
  96. #define MCFTIMER_PCSR_PIF 0x0004
  97. #define MCFTIMER_PCSR_PIE 0x0008
  98. #define MCFTIMER_PCSR_OVW 0x0010
  99. #define MCFTIMER_PCSR_HALTED 0x0020
  100. #define MCFTIMER_PCSR_DOZE 0x0040
  101. /****************************************************************************/
  102. /* New Timer structure */
  103. /****************************************************************************/
  104. /* DMA Timer module registers */
  105. typedef struct dtimer_ctrl {
  106. u16 tmr; /* 0x00 Mode register */
  107. u8 txmr; /* 0x02 Extended Mode register */
  108. u8 ter; /* 0x03 Event register */
  109. u32 trr; /* 0x04 Reference register */
  110. u32 tcr; /* 0x08 Capture register */
  111. u32 tcn; /* 0x0C Counter register */
  112. } dtmr_t;
  113. /*Programmable Interrupt Timer */
  114. typedef struct pit_ctrl {
  115. u16 pcsr; /* 0x00 Control and Status Register */
  116. u16 pmr; /* 0x02 Modulus Register */
  117. u16 pcntr; /* 0x04 Count Register */
  118. } pit_t;
  119. /*********************************************************************
  120. * DMA Timers (DTIM)
  121. *********************************************************************/
  122. /* Bit definitions and macros for DTMR */
  123. #define DTIM_DTMR_RST (0x0001) /* Reset */
  124. #define DTIM_DTMR_CLK(x) (((x)&0x0003)<<1) /* Input clock source */
  125. #define DTIM_DTMR_FRR (0x0008) /* Free run/restart */
  126. #define DTIM_DTMR_ORRI (0x0010) /* Output reference request/interrupt enable */
  127. #define DTIM_DTMR_OM (0x0020) /* Output Mode */
  128. #define DTIM_DTMR_CE(x) (((x)&0x0003)<<6) /* Capture Edge */
  129. #define DTIM_DTMR_PS(x) (((x)&0x00FF)<<8) /* Prescaler value */
  130. #define DTIM_DTMR_RST_EN (0x0001)
  131. #define DTIM_DTMR_RST_RST (0x0000)
  132. #define DTIM_DTMR_CE_ANY (0x00C0)
  133. #define DTIM_DTMR_CE_FALL (0x0080)
  134. #define DTIM_DTMR_CE_RISE (0x0040)
  135. #define DTIM_DTMR_CE_NONE (0x0000)
  136. #define DTIM_DTMR_CLK_DTIN (0x0006)
  137. #define DTIM_DTMR_CLK_DIV16 (0x0004)
  138. #define DTIM_DTMR_CLK_DIV1 (0x0002)
  139. #define DTIM_DTMR_CLK_STOP (0x0000)
  140. /* Bit definitions and macros for DTXMR */
  141. #define DTIM_DTXMR_MODE16 (0x01) /* Increment Mode */
  142. #define DTIM_DTXMR_DMAEN (0x80) /* DMA request */
  143. /* Bit definitions and macros for DTER */
  144. #define DTIM_DTER_CAP (0x01) /* Capture event */
  145. #define DTIM_DTER_REF (0x02) /* Output reference event */
  146. /*********************************************************************
  147. *
  148. * Programmable Interrupt Timer Modules (PIT)
  149. *
  150. *********************************************************************/
  151. /* Bit definitions and macros for PCSR */
  152. #define PIT_PCSR_EN (0x0001)
  153. #define PIT_PCSR_RLD (0x0002)
  154. #define PIT_PCSR_PIF (0x0004)
  155. #define PIT_PCSR_PIE (0x0008)
  156. #define PIT_PCSR_OVW (0x0010)
  157. #define PIT_PCSR_HALTED (0x0020)
  158. #define PIT_PCSR_DOZE (0x0040)
  159. #define PIT_PCSR_PRE(x) (((x)&0x000F)<<8)
  160. /* Bit definitions and macros for PMR */
  161. #define PIT_PMR_PM(x) (x)
  162. /* Bit definitions and macros for PCNTR */
  163. #define PIT_PCNTR_PC(x) (x)
  164. /****************************************************************************/
  165. #endif /* mcftimer_h */