timer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. u16 tmr; /* 0x00 Mode register */
  35. u8 txmr; /* 0x02 Extended Mode register */
  36. u8 ter; /* 0x03 Event register */
  37. u32 trr; /* 0x04 Reference register */
  38. u32 tcr; /* 0x08 Capture register */
  39. u32 tcn; /* 0x0C Counter register */
  40. } dtmr_t;
  41. /*Programmable Interrupt Timer */
  42. typedef struct pit_ctrl {
  43. u16 pcsr; /* 0x00 Control and Status Register */
  44. u16 pmr; /* 0x02 Modulus Register */
  45. u16 pcntr; /* 0x04 Count Register */
  46. } pit_t;
  47. /*********************************************************************
  48. * DMA Timers (DTIM)
  49. *********************************************************************/
  50. /* Bit definitions and macros for DTMR */
  51. #define DTIM_DTMR_RST (0x0001) /* Reset */
  52. #define DTIM_DTMR_CLK(x) (((x)&0x0003)<<1) /* Input clock source */
  53. #define DTIM_DTMR_FRR (0x0008) /* Free run/restart */
  54. #define DTIM_DTMR_ORRI (0x0010) /* Output reference request/interrupt enable */
  55. #define DTIM_DTMR_OM (0x0020) /* Output Mode */
  56. #define DTIM_DTMR_CE(x) (((x)&0x0003)<<6) /* Capture Edge */
  57. #define DTIM_DTMR_PS(x) (((x)&0x00FF)<<8) /* Prescaler value */
  58. #define DTIM_DTMR_RST_EN (0x0001)
  59. #define DTIM_DTMR_RST_RST (0x0000)
  60. #define DTIM_DTMR_CE_ANY (0x00C0)
  61. #define DTIM_DTMR_CE_FALL (0x0080)
  62. #define DTIM_DTMR_CE_RISE (0x0040)
  63. #define DTIM_DTMR_CE_NONE (0x0000)
  64. #define DTIM_DTMR_CLK_DTIN (0x0006)
  65. #define DTIM_DTMR_CLK_DIV16 (0x0004)
  66. #define DTIM_DTMR_CLK_DIV1 (0x0002)
  67. #define DTIM_DTMR_CLK_STOP (0x0000)
  68. /* Bit definitions and macros for DTXMR */
  69. #define DTIM_DTXMR_MODE16 (0x01) /* Increment Mode */
  70. #define DTIM_DTXMR_DMAEN (0x80) /* DMA request */
  71. /* Bit definitions and macros for DTER */
  72. #define DTIM_DTER_CAP (0x01) /* Capture event */
  73. #define DTIM_DTER_REF (0x02) /* Output reference event */
  74. /*********************************************************************
  75. *
  76. * Programmable Interrupt Timer Modules (PIT)
  77. *
  78. *********************************************************************/
  79. /* Bit definitions and macros for PCSR */
  80. #define PIT_PCSR_EN (0x0001)
  81. #define PIT_PCSR_RLD (0x0002)
  82. #define PIT_PCSR_PIF (0x0004)
  83. #define PIT_PCSR_PIE (0x0008)
  84. #define PIT_PCSR_OVW (0x0010)
  85. #define PIT_PCSR_HALTED (0x0020)
  86. #define PIT_PCSR_DOZE (0x0040)
  87. #define PIT_PCSR_PRE(x) (((x)&0x000F)<<8)
  88. /* Bit definitions and macros for PMR */
  89. #define PIT_PMR_PM(x) (x)
  90. /* Bit definitions and macros for PCNTR */
  91. #define PIT_PCNTR_PC(x) (x)
  92. /****************************************************************************/
  93. #endif /* timer_h */