1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <common.h>
19#include <watchdog.h>
20#include <command.h>
21#include <asm/processor.h>
22#include <asm/interrupt.h>
23#include <asm/ppc4xx.h>
24#include <ppc_asm.tmpl>
25#include <commproc.h>
26
27DECLARE_GLOBAL_DATA_PTR;
28
29
30
31
32struct irq_action {
33 interrupt_handler_t *handler;
34 void *arg;
35 int count;
36};
37static struct irq_action irq_vecs[IRQ_MAX];
38
39#if defined(CONFIG_440)
40
41
42static __inline__ void set_evpr(unsigned long val)
43{
44 asm volatile("mtspr 0x03f,%0" : : "r" (val));
45}
46
47#else
48
49static __inline__ void set_pit(unsigned long val)
50{
51 asm volatile("mtpit %0" : : "r" (val));
52}
53
54static __inline__ void set_evpr(unsigned long val)
55{
56 asm volatile("mtevpr %0" : : "r" (val));
57}
58#endif
59
60int interrupt_init_cpu (unsigned *decrementer_count)
61{
62 int vec;
63 unsigned long val;
64
65
66 *decrementer_count = 0;
67
68
69
70
71 for (vec = 0; vec < IRQ_MAX; vec++) {
72 irq_vecs[vec].handler = NULL;
73 irq_vecs[vec].arg = NULL;
74 irq_vecs[vec].count = 0;
75 }
76
77#ifdef CONFIG_4xx
78
79
80
81#if defined(CONFIG_440)
82 val = mfspr( SPRN_TCR );
83 val &= (~0x04400000);
84 mtspr( SPRN_TCR, val );
85 mtspr( SPRN_DEC, 0 );
86 mtspr( SPRN_DECAR, 0 );
87 mtspr( SPRN_TSR, 0x08000000 );
88 val = gd->bd->bi_intfreq/1000;
89 mtspr( SPRN_DECAR, val );
90 mtspr( SPRN_DEC, val );
91#else
92 set_pit(gd->bd->bi_intfreq / 1000);
93#endif
94#endif
95
96#ifdef CONFIG_ADCIOP
97
98
99
100 set_pit(66000);
101#endif
102
103
104
105
106 val = mfspr(SPRN_TCR);
107 val |= 0x04400000;
108 mtspr(SPRN_TCR, val);
109
110
111
112
113 set_evpr(0x00000000);
114
115
116
117
118 pic_enable();
119
120 return (0);
121}
122
123void timer_interrupt_cpu(struct pt_regs *regs)
124{
125
126 return;
127}
128
129void interrupt_run_handler(int vec)
130{
131 irq_vecs[vec].count++;
132
133 if (irq_vecs[vec].handler != NULL) {
134
135 (*irq_vecs[vec].handler) (irq_vecs[vec].arg);
136 } else {
137 pic_irq_disable(vec);
138 printf("Masking bogus interrupt vector %d\n", vec);
139 }
140
141 pic_irq_ack(vec);
142 return;
143}
144
145void irq_install_handler(int vec, interrupt_handler_t * handler, void *arg)
146{
147
148
149
150 if ((irq_vecs[vec].handler != NULL) && (irq_vecs[vec].handler != handler)) {
151 printf("Interrupt vector %d: handler 0x%x replacing 0x%x\n",
152 vec, (uint) handler, (uint) irq_vecs[vec].handler);
153 }
154 irq_vecs[vec].handler = handler;
155 irq_vecs[vec].arg = arg;
156
157 pic_irq_enable(vec);
158 return;
159}
160
161void irq_free_handler(int vec)
162{
163 debug("Free interrupt for vector %d ==> %p\n",
164 vec, irq_vecs[vec].handler);
165
166 pic_irq_disable(vec);
167
168 irq_vecs[vec].handler = NULL;
169 irq_vecs[vec].arg = NULL;
170 return;
171}
172
173#if defined(CONFIG_CMD_IRQ)
174int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
175{
176 int vec;
177
178 printf ("Interrupt-Information:\n");
179 printf ("Nr Routine Arg Count\n");
180
181 for (vec = 0; vec < IRQ_MAX; vec++) {
182 if (irq_vecs[vec].handler != NULL) {
183 printf ("%02d %08lx %08lx %d\n",
184 vec,
185 (ulong)irq_vecs[vec].handler,
186 (ulong)irq_vecs[vec].arg,
187 irq_vecs[vec].count);
188 }
189 }
190
191 return 0;
192}
193#endif
194