]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - cpu/coldfire/interrupts.c
* Patch by Bernhard Kuhn, 28 Nov 2003:
[karo-tx-uboot.git] / cpu / coldfire / interrupts.c
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
24 #include <common.h>
25 #include <watchdog.h>
26 #ifdef CONFIG_M5272
27 #include <asm/m5272.h>
28 #endif
29 #ifdef CONFIG_M5282
30 #include <asm/m5282.h>
31 #endif
32 #include <asm/mcftimer.h>
33 #include <asm/processor.h>
34 #include <commproc.h>
35
36 static ulong timestamp;
37 static unsigned short lastinc;
38
39 void coldfire_timer_init (void)
40 {
41         volatile unsigned short *timerp;
42
43         timerp = (volatile unsigned short *) (MCF_MBAR + MCFTIMER_BASE4);
44         timestamp = 0;
45
46 #ifdef CONFIG_M5272
47         /* Set up TIMER 4 as poll clock */
48         timerp[MCFTIMER_TMR] = MCFTIMER_TMR_DISABLE;
49         timerp[MCFTIMER_TRR] = lastinc = 0;
50         timerp[MCFTIMER_TMR] = (65 << 8) | MCFTIMER_TMR_CLK1 |
51                 MCFTIMER_TMR_FREERUN | MCFTIMER_TMR_ENABLE;
52 #endif
53
54 #ifdef CONFIG_M5282
55         /* Set up TIMER 4 as poll clock */
56         timerp[MCFTIMER_PCSR] = MCFTIMER_PCSR_OVW;
57         timerp[MCFTIMER_PMR] = lastinc = 0;
58         timerp[MCFTIMER_PCSR] =
59                 (5 << 8) | MCFTIMER_PCSR_EN | MCFTIMER_PCSR_OVW;
60 #endif
61 }
62
63
64 void irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
65 {
66 }
67 void irq_free_handler (int vec)
68 {
69 }
70
71 int interrupt_init (void)
72 {
73         coldfire_timer_init ();
74         return 0;
75 }
76
77 void enable_interrupts ()
78 {
79 }
80 int disable_interrupts ()
81 {
82         return 0;
83 }
84
85 void set_timer (ulong t)
86 {
87         volatile unsigned short *timerp;
88
89         timerp = (volatile unsigned short *) (MCF_MBAR + MCFTIMER_BASE4);
90         timestamp = 0;
91
92 #ifdef CONFIG_M5272
93         timerp[MCFTIMER_TRR] = lastinc = 0;
94 #endif
95
96 #ifdef CONFIG_M5282
97         timerp[MCFTIMER_PMR] = lastinc = 0;
98 #endif
99 }
100
101 ulong get_timer (ulong base)
102 {
103         unsigned short now, diff;
104         volatile unsigned short *timerp;
105
106         timerp = (volatile unsigned short *) (MCF_MBAR + MCFTIMER_BASE4);
107
108 #ifdef CONFIG_M5272
109         now = timerp[MCFTIMER_TCN];
110         diff = (now - lastinc);
111 #endif
112
113 #ifdef CONFIG_M5282
114         now = timerp[MCFTIMER_PCNTR];
115         diff = -(now - lastinc);
116 #endif
117
118         timestamp += diff;
119         lastinc = now;
120         return timestamp - base;
121 }
122
123 void wait_ticks (unsigned long ticks)
124 {
125         set_timer (0);
126         while (get_timer (0) < ticks);
127 }