2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * (C) Copyright 2002 (440 port)
6 * Scott McNutt, Artesyn Communication Producs, smcnutt@artsyncp.com
8 * (C) Copyright 2003 (440GX port)
9 * Travis B. Sawyer, Sandburst Corporation, tsawyer@sandburst.com
11 * (C) Copyright 2008 (PPC440X05 port for Virtex 5 FX)
12 * Ricardo Ribalda-Universidad Autonoma de Madrid-ricardo.ribalda@uam.es
13 * Work supported by Qtechnology (htpp://qtec.com)
15 * See file CREDITS for list of people who contributed to this
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License as
20 * published by the Free Software Foundation; either version 2 of
21 * the License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 #include <asm/processor.h>
38 #include <asm/interrupt.h>
39 #include <asm/ppc4xx.h>
40 #include <ppc_asm.tmpl>
43 DECLARE_GLOBAL_DATA_PTR;
46 * CPM interrupt vector functions.
49 interrupt_handler_t *handler;
53 static struct irq_action irq_vecs[IRQ_MAX];
55 #if defined(CONFIG_440)
57 /* SPRN changed in 440 */
58 static __inline__ void set_evpr(unsigned long val)
60 asm volatile("mtspr 0x03f,%0" : : "r" (val));
63 #else /* !defined(CONFIG_440) */
65 static __inline__ void set_pit(unsigned long val)
67 asm volatile("mtpit %0" : : "r" (val));
70 static __inline__ void set_evpr(unsigned long val)
72 asm volatile("mtevpr %0" : : "r" (val));
74 #endif /* defined(CONFIG_440 */
76 int interrupt_init_cpu (unsigned *decrementer_count)
81 /* decrementer is automatically reloaded */
82 *decrementer_count = 0;
85 * Mark all irqs as free
87 for (vec = 0; vec < IRQ_MAX; vec++) {
88 irq_vecs[vec].handler = NULL;
89 irq_vecs[vec].arg = NULL;
90 irq_vecs[vec].count = 0;
97 #if defined(CONFIG_440)
98 val = mfspr( SPRN_TCR );
99 val &= (~0x04400000); /* clear DIS & ARE */
100 mtspr( SPRN_TCR, val );
101 mtspr( SPRN_DEC, 0 ); /* Prevent exception after TSR clear*/
102 mtspr( SPRN_DECAR, 0 ); /* clear reload */
103 mtspr( SPRN_TSR, 0x08000000 ); /* clear DEC status */
104 val = gd->bd->bi_intfreq/1000; /* 1 msec */
105 mtspr( SPRN_DECAR, val ); /* Set auto-reload value */
106 mtspr( SPRN_DEC, val ); /* Set inital val */
108 set_pit(gd->bd->bi_intfreq / 1000);
110 #endif /* CONFIG_4xx */
122 val = mfspr(SPRN_TCR);
124 mtspr(SPRN_TCR, val);
129 set_evpr(0x00000000);
132 * Call uic or xilinx_irq pic_enable
139 void timer_interrupt_cpu(struct pt_regs *regs)
141 /* nothing to do here */
145 void interrupt_run_handler(int vec)
147 irq_vecs[vec].count++;
149 if (irq_vecs[vec].handler != NULL) {
151 (*irq_vecs[vec].handler) (irq_vecs[vec].arg);
153 pic_irq_disable(vec);
154 printf("Masking bogus interrupt vector %d\n", vec);
161 void irq_install_handler(int vec, interrupt_handler_t * handler, void *arg)
164 * Print warning when replacing with a different irq vector
166 if ((irq_vecs[vec].handler != NULL) && (irq_vecs[vec].handler != handler)) {
167 printf("Interrupt vector %d: handler 0x%x replacing 0x%x\n",
168 vec, (uint) handler, (uint) irq_vecs[vec].handler);
170 irq_vecs[vec].handler = handler;
171 irq_vecs[vec].arg = arg;
177 void irq_free_handler(int vec)
179 debug("Free interrupt for vector %d ==> %p\n",
180 vec, irq_vecs[vec].handler);
182 pic_irq_disable(vec);
184 irq_vecs[vec].handler = NULL;
185 irq_vecs[vec].arg = NULL;
189 #if defined(CONFIG_CMD_IRQ)
190 int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
194 printf ("Interrupt-Information:\n");
195 printf ("Nr Routine Arg Count\n");
197 for (vec = 0; vec < IRQ_MAX; vec++) {
198 if (irq_vecs[vec].handler != NULL) {
199 printf ("%02d %08lx %08lx %d\n",
201 (ulong)irq_vecs[vec].handler,
202 (ulong)irq_vecs[vec].arg,
203 irq_vecs[vec].count);