2 * File: arch/blackfin/mach-common/interrupt.S
4 * Author: D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>
5 * Kenneth Albanowski <kjahds@kjahds.com>
8 * Description: Interrupt Entries
11 * Copyright 2004-2006 Analog Devices Inc.
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <asm/blackfin.h>
33 #include <linux/linkage.h>
34 #include <asm/entry.h>
35 #include <asm/asm-offsets.h>
36 #include <asm/trace.h>
37 #include <asm/traps.h>
38 #include <asm/thread_info.h>
40 #include <asm/context.S>
42 .extern _ret_from_exception
44 #ifdef CONFIG_I_ENTRY_L1
50 .align 4 /* just in case */
52 /* Common interrupt entry code. First we do CLI, then push
53 * RETI, to keep interrupts disabled, but to allow this state to be changed
55 * R0 contains the interrupt number, while R1 may contain the value of IPEND,
56 * or garbage if IPEND won't be needed by the ISR. */
94 [--sp] = r0; /* Skip reserved */
102 [--sp] = r1; /* IPEND - R1 may or may not be set up before jumping here. */
104 /* Switch to other method of keeping interrupts disabled. */
105 #ifdef CONFIG_DEBUG_HWERR
111 [--sp] = RETI; /* orig_pc */
112 /* Clear all L registers. */
118 #ifdef CONFIG_FRAME_POINTER
122 ANOMALY_283_315_WORKAROUND(p5, r7)
127 call ___ipipe_grab_irq
130 if cc jump .Lcommon_restore_context;
131 #else /* CONFIG_IPIPE */
134 #endif /* CONFIG_IPIPE */
135 call _return_from_int;
136 .Lcommon_restore_context:
140 /* interrupt routine for ivhw - 5 */
142 /* In case a single action kicks off multiple memory transactions, (like
143 * a cache line fetch, - this can cause multiple hardware errors, let's
144 * catch them all. First - make sure all the actions are complete, and
145 * the core sees the hardware errors.
151 #ifdef CONFIG_FRAME_POINTER
155 ANOMALY_283_315_WORKAROUND(p5, r7)
157 /* Handle all stacked hardware errors
158 * To make sure we don't hang forever, only do it 10 times
166 CC = BITTST(R1, EVT_IVHW_P);
168 /* OK a hardware error is pending - clear it */
176 # We are going to dump something out, so make sure we print IPEND properly
180 [sp + PT_IPEND] = r0;
182 /* set the EXCAUSE to HWERR for trap_c */
183 r0 = [sp + PT_SEQSTAT];
184 R1.L = LO(VEC_HWERR);
185 R1.H = HI(VEC_HWERR);
187 [sp + PT_SEQSTAT] = R0;
189 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
195 /* make sure EBIU_ERRMST is clear */
196 p0.l = LO(EBIU_ERRMST);
197 p0.h = HI(EBIU_ERRMST);
198 r0.l = (CORE_ERROR | CORE_MERROR);
202 call _ret_from_exception;
204 .Lcommon_restore_all_sys:
209 /* Interrupt routine for evt2 (NMI).
210 * We don't actually use this, so just return.
211 * For inner circle type details, please see:
212 * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:nmi
219 /* interrupt routine for core timer - 6 */
221 TIMER_INTERRUPT_ENTRY(EVT_IVTMR_P)
223 /* interrupt routine for evt7 - 7 */
225 INTERRUPT_ENTRY(EVT_IVG7_P)
227 INTERRUPT_ENTRY(EVT_IVG8_P)
229 INTERRUPT_ENTRY(EVT_IVG9_P)
231 INTERRUPT_ENTRY(EVT_IVG10_P)
233 INTERRUPT_ENTRY(EVT_IVG11_P)
235 INTERRUPT_ENTRY(EVT_IVG12_P)
237 INTERRUPT_ENTRY(EVT_IVG13_P)
240 /* interrupt routine for system_call - 15 */
241 ENTRY(_evt_system_call)
243 #ifdef CONFIG_FRAME_POINTER
247 jump .Lcommon_restore_context;
248 ENDPROC(_evt_system_call)
252 * __ipipe_call_irqtail: lowers the current priority level to EVT15
253 * before running a user-defined routine, then raises the priority
254 * level to EVT14 to prepare the caller for a normal interrupt
255 * return through RTI.
257 * We currently use this facility in two occasions:
259 * - to branch to __ipipe_irq_tail_hook as requested by a high
260 * priority domain after the pipeline delivered an interrupt,
261 * e.g. such as Xenomai, in order to start its rescheduling
262 * procedure, since we may not switch tasks when IRQ levels are
263 * nested on the Blackfin, so we have to fake an interrupt return
264 * so that we may reschedule immediately.
266 * - to branch to sync_root_irqs, in order to play any interrupt
267 * pending for the root domain (i.e. the Linux kernel). This lowers
268 * the core priority level enough so that Linux IRQ handlers may
269 * never delay interrupts handled by high priority domains; we defer
270 * those handlers until this point instead. This is a substitute
271 * to using a threaded interrupt model for the Linux kernel.
273 * r0: address of user-defined routine
274 * context: caller must have preempted EVT15, hw interrupts must be off.
276 ENTRY(___ipipe_call_irqtail)
284 [--sp] = ( r7:4, p5:3 );
288 ( r7:4, p5:3 ) = [sp++];
291 #ifdef CONFIG_DEBUG_HWERR
292 /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
293 r0 = (EVT_IVG14 | EVT_IVHW | \
294 EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
296 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
298 EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
301 raise 14; /* Branches to _evt_evt14 */
303 jump 2b; /* Likely paranoid. */
304 ENDPROC(___ipipe_call_irqtail)
306 #endif /* CONFIG_IPIPE */