blob: 82d417ef4b5bc2933a75f5863ba1c68d36c14dc4 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
2 * File: arch/blackfin/mach-common/interrupt.S
3 * Based on:
4 * Author: D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>
5 * Kenneth Albanowski <kjahds@kjahds.com>
6 *
7 * Created: ?
8 * Description: Interrupt Entries
9 *
10 * Modified:
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
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.
19 *
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.
24 *
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
29 */
30
31#include <asm/blackfin.h>
Bryan Wu639f6572008-08-27 10:51:02 +080032#include <mach/irq.h>
Bryan Wu1394f032007-05-06 14:50:22 -070033#include <linux/linkage.h>
34#include <asm/entry.h>
35#include <asm/asm-offsets.h>
Robin Getz669b7922007-06-21 16:34:08 +080036#include <asm/trace.h>
Robin Getz13fe24f2008-01-27 15:38:56 +080037#include <asm/traps.h>
38#include <asm/thread_info.h>
Bryan Wu1394f032007-05-06 14:50:22 -070039
Bryan Wu639f6572008-08-27 10:51:02 +080040#include <asm/context.S>
Bryan Wu1394f032007-05-06 14:50:22 -070041
Robin Getz13fe24f2008-01-27 15:38:56 +080042.extern _ret_from_exception
43
Bryan Wu1394f032007-05-06 14:50:22 -070044#ifdef CONFIG_I_ENTRY_L1
45.section .l1.text
46#else
47.text
48#endif
49
50.align 4 /* just in case */
51
Bryan Wu1394f032007-05-06 14:50:22 -070052/* Common interrupt entry code. First we do CLI, then push
53 * RETI, to keep interrupts disabled, but to allow this state to be changed
54 * by local_bh_enable.
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. */
57__common_int_entry:
58 [--sp] = fp;
59 [--sp] = usp;
60
61 [--sp] = i0;
62 [--sp] = i1;
63 [--sp] = i2;
64 [--sp] = i3;
65
66 [--sp] = m0;
67 [--sp] = m1;
68 [--sp] = m2;
69 [--sp] = m3;
70
71 [--sp] = l0;
72 [--sp] = l1;
73 [--sp] = l2;
74 [--sp] = l3;
75
76 [--sp] = b0;
77 [--sp] = b1;
78 [--sp] = b2;
79 [--sp] = b3;
80 [--sp] = a0.x;
81 [--sp] = a0.w;
82 [--sp] = a1.x;
83 [--sp] = a1.w;
84
85 [--sp] = LC0;
86 [--sp] = LC1;
87 [--sp] = LT0;
88 [--sp] = LT1;
89 [--sp] = LB0;
90 [--sp] = LB1;
91
92 [--sp] = ASTAT;
93
94 [--sp] = r0; /* Skip reserved */
95 [--sp] = RETS;
96 r2 = RETI;
97 [--sp] = r2;
98 [--sp] = RETX;
99 [--sp] = RETN;
100 [--sp] = RETE;
101 [--sp] = SEQSTAT;
102 [--sp] = r1; /* IPEND - R1 may or may not be set up before jumping here. */
103
104 /* Switch to other method of keeping interrupts disabled. */
105#ifdef CONFIG_DEBUG_HWERR
106 r1 = 0x3f;
107 sti r1;
108#else
109 cli r1;
110#endif
111 [--sp] = RETI; /* orig_pc */
112 /* Clear all L registers. */
113 r1 = 0 (x);
114 l0 = r1;
115 l1 = r1;
116 l2 = r1;
117 l3 = r1;
118#ifdef CONFIG_FRAME_POINTER
119 fp = 0;
120#endif
121
Robin Getzdedfd5d2009-08-26 15:54:10 +0000122 ANOMALY_283_315_WORKAROUND(p5, r7)
123
Bryan Wu1394f032007-05-06 14:50:22 -0700124 r1 = sp;
125 SP += -12;
Yi Li6a01f232009-01-07 23:14:39 +0800126#ifdef CONFIG_IPIPE
127 call ___ipipe_grab_irq
128 SP += 12;
129 cc = r0 == 0;
130 if cc jump .Lcommon_restore_context;
131#else /* CONFIG_IPIPE */
Bryan Wu1394f032007-05-06 14:50:22 -0700132 call _do_irq;
133 SP += 12;
Yi Li6a01f232009-01-07 23:14:39 +0800134#endif /* CONFIG_IPIPE */
Bryan Wu1394f032007-05-06 14:50:22 -0700135 call _return_from_int;
136.Lcommon_restore_context:
137 RESTORE_CONTEXT
138 rti;
139
140/* interrupt routine for ivhw - 5 */
141ENTRY(_evt_ivhw)
Robin Getzb9a38992009-05-18 18:33:26 +0000142 /* 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.
146 */
147 SSYNC;
148 SSYNC;
149
Robin Getz13fe24f2008-01-27 15:38:56 +0800150 SAVE_ALL_SYS
Bryan Wu1394f032007-05-06 14:50:22 -0700151#ifdef CONFIG_FRAME_POINTER
152 fp = 0;
153#endif
Robin Getz13fe24f2008-01-27 15:38:56 +0800154
Robin Getzdedfd5d2009-08-26 15:54:10 +0000155 ANOMALY_283_315_WORKAROUND(p5, r7)
Robin Getz669b7922007-06-21 16:34:08 +0800156
Robin Getzb9a38992009-05-18 18:33:26 +0000157 /* Handle all stacked hardware errors
158 * To make sure we don't hang forever, only do it 10 times
159 */
160 R0 = 0;
161 R2 = 10;
1621:
163 P0.L = LO(ILAT);
164 P0.H = HI(ILAT);
165 R1 = [P0];
166 CC = BITTST(R1, EVT_IVHW_P);
167 IF ! CC JUMP 2f;
168 /* OK a hardware error is pending - clear it */
169 R1 = EVT_IVHW_P;
170 [P0] = R1;
171 R0 += 1;
172 CC = R1 == R2;
173 if CC JUMP 2f;
174 JUMP 1b;
1752:
Graf Yangf9946072009-01-07 23:14:39 +0800176 # We are going to dump something out, so make sure we print IPEND properly
177 p2.l = lo(IPEND);
178 p2.h = hi(IPEND);
179 r0 = [p2];
180 [sp + PT_IPEND] = r0;
181
Robin Getz13fe24f2008-01-27 15:38:56 +0800182 /* 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);
186 R0 = R0 | R1;
187 [sp + PT_SEQSTAT] = R0;
188
189 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
Bryan Wu1394f032007-05-06 14:50:22 -0700190 SP += -12;
Robin Getz13fe24f2008-01-27 15:38:56 +0800191 call _trap_c;
Bryan Wu1394f032007-05-06 14:50:22 -0700192 SP += 12;
Robin Getz13fe24f2008-01-27 15:38:56 +0800193
Robin Getz1d5ff7e2008-10-09 17:06:32 +0800194#ifdef EBIU_ERRMST
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);
199 w[p0] = r0.l;
200#endif
201
Robin Getz13fe24f2008-01-27 15:38:56 +0800202 call _ret_from_exception;
Robin Getz1d5ff7e2008-10-09 17:06:32 +0800203
Robin Getz13fe24f2008-01-27 15:38:56 +0800204.Lcommon_restore_all_sys:
205 RESTORE_ALL_SYS
Bryan Wu1394f032007-05-06 14:50:22 -0700206 rti;
Robin Getz13fe24f2008-01-27 15:38:56 +0800207ENDPROC(_evt_ivhw)
208
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800209/* Interrupt routine for evt2 (NMI).
210 * We don't actually use this, so just return.
211 * For inner circle type details, please see:
Robin Getze48df472009-02-04 16:49:45 +0800212 * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:nmi
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800213 */
214ENTRY(_evt_nmi)
215.weak _evt_nmi
Bryan Wu1394f032007-05-06 14:50:22 -0700216 rtn;
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800217ENDPROC(_evt_nmi)
Bryan Wu1394f032007-05-06 14:50:22 -0700218
219/* interrupt routine for core timer - 6 */
220ENTRY(_evt_timer)
221 TIMER_INTERRUPT_ENTRY(EVT_IVTMR_P)
222
223/* interrupt routine for evt7 - 7 */
224ENTRY(_evt_evt7)
225 INTERRUPT_ENTRY(EVT_IVG7_P)
226ENTRY(_evt_evt8)
227 INTERRUPT_ENTRY(EVT_IVG8_P)
228ENTRY(_evt_evt9)
229 INTERRUPT_ENTRY(EVT_IVG9_P)
230ENTRY(_evt_evt10)
231 INTERRUPT_ENTRY(EVT_IVG10_P)
232ENTRY(_evt_evt11)
233 INTERRUPT_ENTRY(EVT_IVG11_P)
234ENTRY(_evt_evt12)
235 INTERRUPT_ENTRY(EVT_IVG12_P)
236ENTRY(_evt_evt13)
237 INTERRUPT_ENTRY(EVT_IVG13_P)
238
239
240 /* interrupt routine for system_call - 15 */
241ENTRY(_evt_system_call)
242 SAVE_CONTEXT_SYSCALL
243#ifdef CONFIG_FRAME_POINTER
244 fp = 0;
245#endif
246 call _system_call;
247 jump .Lcommon_restore_context;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800248ENDPROC(_evt_system_call)
Yi Li6a01f232009-01-07 23:14:39 +0800249
250#ifdef CONFIG_IPIPE
Philippe Gerum7a7967d2009-06-22 18:25:52 +0200251/*
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.
256 *
257 * We currently use this facility in two occasions:
258 *
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.
265 *
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.
272 *
273 * r0: address of user-defined routine
274 * context: caller must have preempted EVT15, hw interrupts must be off.
275 */
Yi Li6a01f232009-01-07 23:14:39 +0800276ENTRY(___ipipe_call_irqtail)
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800277 p0 = r0;
Yi Li6a01f232009-01-07 23:14:39 +0800278 r0.l = 1f;
279 r0.h = 1f;
280 reti = r0;
281 rti;
2821:
283 [--sp] = rets;
284 [--sp] = ( r7:4, p5:3 );
Yi Li6a01f232009-01-07 23:14:39 +0800285 sp += -12;
286 call (p0);
287 sp += 12;
288 ( r7:4, p5:3 ) = [sp++];
289 rets = [sp++];
290
Philippe Gerum70f47202009-06-22 18:24:18 +0200291#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);
295#else
296 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
297 r0 = (EVT_IVG14 | \
298 EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
299#endif
Yi Li6a01f232009-01-07 23:14:39 +0800300 sti r0;
Philippe Gerumfc9afb92009-06-22 18:24:02 +0200301 raise 14; /* Branches to _evt_evt14 */
Yi Li6a01f232009-01-07 23:14:39 +08003022:
303 jump 2b; /* Likely paranoid. */
Yi Li6a01f232009-01-07 23:14:39 +0800304ENDPROC(___ipipe_call_irqtail)
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800305
Yi Li6a01f232009-01-07 23:14:39 +0800306#endif /* CONFIG_IPIPE */