blob: c1bdd1edc8eb651ee31d289f8abdfb0fd456a821 [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
Mike Frysinger1aafd902007-07-25 11:19:14 +0800122#if ANOMALY_05000283 || ANOMALY_05000315
Bryan Wu1394f032007-05-06 14:50:22 -0700123 cc = r7 == r7;
Robin Getz0626d792007-12-21 17:46:33 +0800124 p5.h = HI(CHIPID);
125 p5.l = LO(CHIPID);
Bryan Wu1394f032007-05-06 14:50:22 -0700126 if cc jump 1f;
127 r7.l = W[p5];
1281:
129#endif
130 r1 = sp;
131 SP += -12;
Yi Li6a01f232009-01-07 23:14:39 +0800132#ifdef CONFIG_IPIPE
133 call ___ipipe_grab_irq
134 SP += 12;
135 cc = r0 == 0;
136 if cc jump .Lcommon_restore_context;
137#else /* CONFIG_IPIPE */
Bryan Wu1394f032007-05-06 14:50:22 -0700138 call _do_irq;
139 SP += 12;
Yi Li6a01f232009-01-07 23:14:39 +0800140#endif /* CONFIG_IPIPE */
Bryan Wu1394f032007-05-06 14:50:22 -0700141 call _return_from_int;
142.Lcommon_restore_context:
143 RESTORE_CONTEXT
144 rti;
145
146/* interrupt routine for ivhw - 5 */
147ENTRY(_evt_ivhw)
Robin Getz13fe24f2008-01-27 15:38:56 +0800148 SAVE_ALL_SYS
Bryan Wu1394f032007-05-06 14:50:22 -0700149#ifdef CONFIG_FRAME_POINTER
150 fp = 0;
151#endif
Robin Getz13fe24f2008-01-27 15:38:56 +0800152
Michael Hennerich5e9e7682008-10-09 12:31:03 +0800153#if ANOMALY_05000283 || ANOMALY_05000315
Bryan Wu1394f032007-05-06 14:50:22 -0700154 cc = r7 == r7;
Robin Getz0626d792007-12-21 17:46:33 +0800155 p5.h = HI(CHIPID);
156 p5.l = LO(CHIPID);
Bryan Wu1394f032007-05-06 14:50:22 -0700157 if cc jump 1f;
158 r7.l = W[p5];
1591:
160#endif
Robin Getz669b7922007-06-21 16:34:08 +0800161
Graf Yangf9946072009-01-07 23:14:39 +0800162 # We are going to dump something out, so make sure we print IPEND properly
163 p2.l = lo(IPEND);
164 p2.h = hi(IPEND);
165 r0 = [p2];
166 [sp + PT_IPEND] = r0;
167
Bryan Wu1394f032007-05-06 14:50:22 -0700168#ifdef CONFIG_HARDWARE_PM
Robin Getz13fe24f2008-01-27 15:38:56 +0800169 r7 = [sp + PT_SEQSTAT];
Bryan Wu1394f032007-05-06 14:50:22 -0700170 r7 = r7 >>> 0xe;
171 r6 = 0x1F;
172 r7 = r7 & r6;
173 r5 = 0x12;
174 cc = r7 == r5;
175 if cc jump .Lcall_do_ovf; /* deal with performance counter overflow */
176#endif
177
Robin Getz13fe24f2008-01-27 15:38:56 +0800178 /* set the EXCAUSE to HWERR for trap_c */
179 r0 = [sp + PT_SEQSTAT];
180 R1.L = LO(VEC_HWERR);
181 R1.H = HI(VEC_HWERR);
182 R0 = R0 | R1;
183 [sp + PT_SEQSTAT] = R0;
184
185 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
Bryan Wu1394f032007-05-06 14:50:22 -0700186 SP += -12;
Robin Getz13fe24f2008-01-27 15:38:56 +0800187 call _trap_c;
Bryan Wu1394f032007-05-06 14:50:22 -0700188 SP += 12;
Robin Getz13fe24f2008-01-27 15:38:56 +0800189
Robin Getz1d5ff7e2008-10-09 17:06:32 +0800190#ifdef EBIU_ERRMST
191 /* make sure EBIU_ERRMST is clear */
192 p0.l = LO(EBIU_ERRMST);
193 p0.h = HI(EBIU_ERRMST);
194 r0.l = (CORE_ERROR | CORE_MERROR);
195 w[p0] = r0.l;
196#endif
197
Robin Getz13fe24f2008-01-27 15:38:56 +0800198 call _ret_from_exception;
Robin Getz1d5ff7e2008-10-09 17:06:32 +0800199
Robin Getz13fe24f2008-01-27 15:38:56 +0800200.Lcommon_restore_all_sys:
201 RESTORE_ALL_SYS
Bryan Wu1394f032007-05-06 14:50:22 -0700202 rti;
Robin Getz13fe24f2008-01-27 15:38:56 +0800203
Bryan Wu1394f032007-05-06 14:50:22 -0700204#ifdef CONFIG_HARDWARE_PM
205.Lcall_do_ovf:
206
Graf Yangf9946072009-01-07 23:14:39 +0800207 R0 = SP;
Bryan Wu1394f032007-05-06 14:50:22 -0700208 SP += -12;
209 call _pm_overflow;
210 SP += 12;
211
Robin Getz13fe24f2008-01-27 15:38:56 +0800212 jump .Lcommon_restore_all_sys;
Bryan Wu1394f032007-05-06 14:50:22 -0700213#endif
214
Robin Getz13fe24f2008-01-27 15:38:56 +0800215ENDPROC(_evt_ivhw)
216
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800217/* Interrupt routine for evt2 (NMI).
218 * We don't actually use this, so just return.
219 * For inner circle type details, please see:
220 * http://docs.blackfin.uclinux.org/doku.php?id=linux:nmi
221 */
222ENTRY(_evt_nmi)
223.weak _evt_nmi
Bryan Wu1394f032007-05-06 14:50:22 -0700224 rtn;
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800225ENDPROC(_evt_nmi)
Bryan Wu1394f032007-05-06 14:50:22 -0700226
227/* interrupt routine for core timer - 6 */
228ENTRY(_evt_timer)
229 TIMER_INTERRUPT_ENTRY(EVT_IVTMR_P)
230
231/* interrupt routine for evt7 - 7 */
232ENTRY(_evt_evt7)
233 INTERRUPT_ENTRY(EVT_IVG7_P)
234ENTRY(_evt_evt8)
235 INTERRUPT_ENTRY(EVT_IVG8_P)
236ENTRY(_evt_evt9)
237 INTERRUPT_ENTRY(EVT_IVG9_P)
238ENTRY(_evt_evt10)
239 INTERRUPT_ENTRY(EVT_IVG10_P)
240ENTRY(_evt_evt11)
241 INTERRUPT_ENTRY(EVT_IVG11_P)
242ENTRY(_evt_evt12)
243 INTERRUPT_ENTRY(EVT_IVG12_P)
244ENTRY(_evt_evt13)
245 INTERRUPT_ENTRY(EVT_IVG13_P)
246
247
248 /* interrupt routine for system_call - 15 */
249ENTRY(_evt_system_call)
250 SAVE_CONTEXT_SYSCALL
251#ifdef CONFIG_FRAME_POINTER
252 fp = 0;
253#endif
254 call _system_call;
255 jump .Lcommon_restore_context;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800256ENDPROC(_evt_system_call)
Yi Li6a01f232009-01-07 23:14:39 +0800257
258#ifdef CONFIG_IPIPE
259ENTRY(___ipipe_call_irqtail)
260 r0.l = 1f;
261 r0.h = 1f;
262 reti = r0;
263 rti;
2641:
265 [--sp] = rets;
266 [--sp] = ( r7:4, p5:3 );
267 p0.l = ___ipipe_irq_tail_hook;
268 p0.h = ___ipipe_irq_tail_hook;
269 p0 = [p0];
270 sp += -12;
271 call (p0);
272 sp += 12;
273 ( r7:4, p5:3 ) = [sp++];
274 rets = [sp++];
275
276 [--sp] = reti;
277 reti = [sp++]; /* IRQs are off. */
278 r0.h = 3f;
279 r0.l = 3f;
280 p0.l = lo(EVT14);
281 p0.h = hi(EVT14);
282 [p0] = r0;
283 csync;
284 r0 = 0x401f;
285 sti r0;
286 raise 14;
287 [--sp] = reti; /* IRQs on. */
2882:
289 jump 2b; /* Likely paranoid. */
2903:
291 sp += 4; /* Discard saved RETI */
292 r0.h = _evt14_softirq;
293 r0.l = _evt14_softirq;
294 p0.l = lo(EVT14);
295 p0.h = hi(EVT14);
296 [p0] = r0;
297 csync;
298 p0.l = _bfin_irq_flags;
299 p0.h = _bfin_irq_flags;
300 r0 = [p0];
301 sti r0;
302#if 0 /* FIXME: this actually raises scheduling latencies */
303 /* Reenable interrupts */
304 [--sp] = reti;
305 r0 = [sp++];
306#endif
307 rts;
308ENDPROC(___ipipe_call_irqtail)
309#endif /* CONFIG_IPIPE */