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 * SPDX-License-Identifier: GPL-2.0+
21 #include <asm/processor.h>
22 #include <asm/interrupt.h>
23 #include <asm/ppc4xx.h>
24 #include <ppc_asm.tmpl>
27 DECLARE_GLOBAL_DATA_PTR;
30 * CPM interrupt vector functions.
33 interrupt_handler_t *handler;
37 static struct irq_action irq_vecs[IRQ_MAX];
39 #if defined(CONFIG_440)
41 /* SPRN changed in 440 */
42 static __inline__ void set_evpr(unsigned long val)
44 asm volatile("mtspr 0x03f,%0" : : "r" (val));
47 #else /* !defined(CONFIG_440) */
49 static __inline__ void set_pit(unsigned long val)
51 asm volatile("mtpit %0" : : "r" (val));
54 static __inline__ void set_evpr(unsigned long val)
56 asm volatile("mtevpr %0" : : "r" (val));
58 #endif /* defined(CONFIG_440 */
60 int interrupt_init_cpu (unsigned *decrementer_count)
65 /* decrementer is automatically reloaded */
66 *decrementer_count = 0;
69 * Mark all irqs as free
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;
81 #if defined(CONFIG_440)
82 val = mfspr( SPRN_TCR );
83 val &= (~0x04400000); /* clear DIS & ARE */
84 mtspr( SPRN_TCR, val );
85 mtspr( SPRN_DEC, 0 ); /* Prevent exception after TSR clear*/
86 mtspr( SPRN_DECAR, 0 ); /* clear reload */
87 mtspr( SPRN_TSR, 0x08000000 ); /* clear DEC status */
88 val = gd->bd->bi_intfreq/1000; /* 1 msec */
89 mtspr( SPRN_DECAR, val ); /* Set auto-reload value */
90 mtspr( SPRN_DEC, val ); /* Set inital val */
92 set_pit(gd->bd->bi_intfreq / 1000);
94 #endif /* CONFIG_4xx */
106 val = mfspr(SPRN_TCR);
108 mtspr(SPRN_TCR, val);
113 set_evpr(0x00000000);
116 * Call uic or xilinx_irq pic_enable
123 void timer_interrupt_cpu(struct pt_regs *regs)
125 /* nothing to do here */
129 void interrupt_run_handler(int vec)
131 irq_vecs[vec].count++;
133 if (irq_vecs[vec].handler != NULL) {
135 (*irq_vecs[vec].handler) (irq_vecs[vec].arg);
137 pic_irq_disable(vec);
138 printf("Masking bogus interrupt vector %d\n", vec);
145 void irq_install_handler(int vec, interrupt_handler_t * handler, void *arg)
148 * Print warning when replacing with a different irq vector
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);
154 irq_vecs[vec].handler = handler;
155 irq_vecs[vec].arg = arg;
161 void irq_free_handler(int vec)
163 debug("Free interrupt for vector %d ==> %p\n",
164 vec, irq_vecs[vec].handler);
166 pic_irq_disable(vec);
168 irq_vecs[vec].handler = NULL;
169 irq_vecs[vec].arg = NULL;
173 #if defined(CONFIG_CMD_IRQ)
174 int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
178 printf ("Interrupt-Information:\n");
179 printf ("Nr Routine Arg Count\n");
181 for (vec = 0; vec < IRQ_MAX; vec++) {
182 if (irq_vecs[vec].handler != NULL) {
183 printf ("%02d %08lx %08lx %d\n",
185 (ulong)irq_vecs[vec].handler,
186 (ulong)irq_vecs[vec].arg,
187 irq_vecs[vec].count);