interrupts.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <watchdog.h>
  25. #ifdef CONFIG_M5272
  26. #include <asm/m5272.h>
  27. #endif
  28. #ifdef CONFIG_M5282
  29. #include <asm/m5282.h>
  30. #endif
  31. #include <asm/mcftimer.h>
  32. #include <asm/processor.h>
  33. #include <commproc.h>
  34. static ulong timestamp;
  35. static unsigned short lastinc;
  36. void coldfire_timer_init (void)
  37. {
  38. volatile unsigned short *timerp;
  39. timerp = (volatile unsigned short *) (MCF_MBAR + MCFTIMER_BASE4);
  40. timestamp = 0;
  41. #ifdef CONFIG_M5272
  42. /* Set up TIMER 4 as poll clock */
  43. timerp[MCFTIMER_TMR] = MCFTIMER_TMR_DISABLE;
  44. timerp[MCFTIMER_TRR] = lastinc = 0;
  45. timerp[MCFTIMER_TMR] = (65 << 8) | MCFTIMER_TMR_CLK1 |
  46. MCFTIMER_TMR_FREERUN | MCFTIMER_TMR_ENABLE;
  47. #endif
  48. #ifdef CONFIG_M5282
  49. /* Set up TIMER 4 as poll clock */
  50. timerp[MCFTIMER_PCSR] = MCFTIMER_PCSR_OVW;
  51. timerp[MCFTIMER_PMR] = lastinc = 0;
  52. timerp[MCFTIMER_PCSR] =
  53. (5 << 8) | MCFTIMER_PCSR_EN | MCFTIMER_PCSR_OVW;
  54. #endif
  55. }
  56. void irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
  57. {
  58. }
  59. void irq_free_handler (int vec)
  60. {
  61. }
  62. int interrupt_init (void)
  63. {
  64. coldfire_timer_init ();
  65. return 0;
  66. }
  67. void enable_interrupts ()
  68. {
  69. }
  70. int disable_interrupts ()
  71. {
  72. return 0;
  73. }
  74. void set_timer (ulong t)
  75. {
  76. volatile unsigned short *timerp;
  77. timerp = (volatile unsigned short *) (MCF_MBAR + MCFTIMER_BASE4);
  78. timestamp = 0;
  79. #ifdef CONFIG_M5272
  80. timerp[MCFTIMER_TRR] = lastinc = 0;
  81. #endif
  82. #ifdef CONFIG_M5282
  83. timerp[MCFTIMER_PMR] = lastinc = 0;
  84. #endif
  85. }
  86. ulong get_timer (ulong base)
  87. {
  88. unsigned short now, diff;
  89. volatile unsigned short *timerp;
  90. timerp = (volatile unsigned short *) (MCF_MBAR + MCFTIMER_BASE4);
  91. #ifdef CONFIG_M5272
  92. now = timerp[MCFTIMER_TCN];
  93. diff = (now - lastinc);
  94. #endif
  95. #ifdef CONFIG_M5282
  96. now = timerp[MCFTIMER_PCNTR];
  97. diff = -(now - lastinc);
  98. #endif
  99. timestamp += diff;
  100. lastinc = now;
  101. return timestamp - base;
  102. }
  103. void wait_ticks (unsigned long ticks)
  104. {
  105. set_timer (0);
  106. while (get_timer (0) < ticks);
  107. }