blob: 9c46680186e4de2cab991257451d2f96c50e3dde [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 Getzb9a38992009-05-18 18:33:26 +0000148 /* In case a single action kicks off multiple memory transactions, (like
149 * a cache line fetch, - this can cause multiple hardware errors, let's
150 * catch them all. First - make sure all the actions are complete, and
151 * the core sees the hardware errors.
152 */
153 SSYNC;
154 SSYNC;
155
Robin Getz13fe24f2008-01-27 15:38:56 +0800156 SAVE_ALL_SYS
Bryan Wu1394f032007-05-06 14:50:22 -0700157#ifdef CONFIG_FRAME_POINTER
158 fp = 0;
159#endif
Robin Getz13fe24f2008-01-27 15:38:56 +0800160
Michael Hennerich5e9e7682008-10-09 12:31:03 +0800161#if ANOMALY_05000283 || ANOMALY_05000315
Bryan Wu1394f032007-05-06 14:50:22 -0700162 cc = r7 == r7;
Robin Getz0626d792007-12-21 17:46:33 +0800163 p5.h = HI(CHIPID);
164 p5.l = LO(CHIPID);
Bryan Wu1394f032007-05-06 14:50:22 -0700165 if cc jump 1f;
166 r7.l = W[p5];
1671:
168#endif
Robin Getz669b7922007-06-21 16:34:08 +0800169
Robin Getzb9a38992009-05-18 18:33:26 +0000170 /* Handle all stacked hardware errors
171 * To make sure we don't hang forever, only do it 10 times
172 */
173 R0 = 0;
174 R2 = 10;
1751:
176 P0.L = LO(ILAT);
177 P0.H = HI(ILAT);
178 R1 = [P0];
179 CC = BITTST(R1, EVT_IVHW_P);
180 IF ! CC JUMP 2f;
181 /* OK a hardware error is pending - clear it */
182 R1 = EVT_IVHW_P;
183 [P0] = R1;
184 R0 += 1;
185 CC = R1 == R2;
186 if CC JUMP 2f;
187 JUMP 1b;
1882:
Graf Yangf9946072009-01-07 23:14:39 +0800189 # We are going to dump something out, so make sure we print IPEND properly
190 p2.l = lo(IPEND);
191 p2.h = hi(IPEND);
192 r0 = [p2];
193 [sp + PT_IPEND] = r0;
194
Robin Getz13fe24f2008-01-27 15:38:56 +0800195 /* set the EXCAUSE to HWERR for trap_c */
196 r0 = [sp + PT_SEQSTAT];
197 R1.L = LO(VEC_HWERR);
198 R1.H = HI(VEC_HWERR);
199 R0 = R0 | R1;
200 [sp + PT_SEQSTAT] = R0;
201
202 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
Bryan Wu1394f032007-05-06 14:50:22 -0700203 SP += -12;
Robin Getz13fe24f2008-01-27 15:38:56 +0800204 call _trap_c;
Bryan Wu1394f032007-05-06 14:50:22 -0700205 SP += 12;
Robin Getz13fe24f2008-01-27 15:38:56 +0800206
Robin Getz1d5ff7e2008-10-09 17:06:32 +0800207#ifdef EBIU_ERRMST
208 /* make sure EBIU_ERRMST is clear */
209 p0.l = LO(EBIU_ERRMST);
210 p0.h = HI(EBIU_ERRMST);
211 r0.l = (CORE_ERROR | CORE_MERROR);
212 w[p0] = r0.l;
213#endif
214
Robin Getz13fe24f2008-01-27 15:38:56 +0800215 call _ret_from_exception;
Robin Getz1d5ff7e2008-10-09 17:06:32 +0800216
Robin Getz13fe24f2008-01-27 15:38:56 +0800217.Lcommon_restore_all_sys:
218 RESTORE_ALL_SYS
Bryan Wu1394f032007-05-06 14:50:22 -0700219 rti;
Robin Getz13fe24f2008-01-27 15:38:56 +0800220ENDPROC(_evt_ivhw)
221
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800222/* Interrupt routine for evt2 (NMI).
223 * We don't actually use this, so just return.
224 * For inner circle type details, please see:
Robin Getze48df472009-02-04 16:49:45 +0800225 * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:nmi
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800226 */
227ENTRY(_evt_nmi)
228.weak _evt_nmi
Bryan Wu1394f032007-05-06 14:50:22 -0700229 rtn;
Mike Frysingerf0b5d122007-08-05 17:03:59 +0800230ENDPROC(_evt_nmi)
Bryan Wu1394f032007-05-06 14:50:22 -0700231
232/* interrupt routine for core timer - 6 */
233ENTRY(_evt_timer)
234 TIMER_INTERRUPT_ENTRY(EVT_IVTMR_P)
235
236/* interrupt routine for evt7 - 7 */
237ENTRY(_evt_evt7)
238 INTERRUPT_ENTRY(EVT_IVG7_P)
239ENTRY(_evt_evt8)
240 INTERRUPT_ENTRY(EVT_IVG8_P)
241ENTRY(_evt_evt9)
242 INTERRUPT_ENTRY(EVT_IVG9_P)
243ENTRY(_evt_evt10)
244 INTERRUPT_ENTRY(EVT_IVG10_P)
245ENTRY(_evt_evt11)
246 INTERRUPT_ENTRY(EVT_IVG11_P)
247ENTRY(_evt_evt12)
248 INTERRUPT_ENTRY(EVT_IVG12_P)
249ENTRY(_evt_evt13)
250 INTERRUPT_ENTRY(EVT_IVG13_P)
251
252
253 /* interrupt routine for system_call - 15 */
254ENTRY(_evt_system_call)
255 SAVE_CONTEXT_SYSCALL
256#ifdef CONFIG_FRAME_POINTER
257 fp = 0;
258#endif
259 call _system_call;
260 jump .Lcommon_restore_context;
Mike Frysinger51be24c2007-06-11 15:31:30 +0800261ENDPROC(_evt_system_call)
Yi Li6a01f232009-01-07 23:14:39 +0800262
263#ifdef CONFIG_IPIPE
264ENTRY(___ipipe_call_irqtail)
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800265 p0 = r0;
Yi Li6a01f232009-01-07 23:14:39 +0800266 r0.l = 1f;
267 r0.h = 1f;
268 reti = r0;
269 rti;
2701:
271 [--sp] = rets;
272 [--sp] = ( r7:4, p5:3 );
Yi Li6a01f232009-01-07 23:14:39 +0800273 sp += -12;
274 call (p0);
275 sp += 12;
276 ( r7:4, p5:3 ) = [sp++];
277 rets = [sp++];
278
279 [--sp] = reti;
280 reti = [sp++]; /* IRQs are off. */
281 r0.h = 3f;
282 r0.l = 3f;
283 p0.l = lo(EVT14);
284 p0.h = hi(EVT14);
285 [p0] = r0;
286 csync;
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800287 r0 = 0x401f (z);
Yi Li6a01f232009-01-07 23:14:39 +0800288 sti r0;
289 raise 14;
290 [--sp] = reti; /* IRQs on. */
2912:
292 jump 2b; /* Likely paranoid. */
2933:
294 sp += 4; /* Discard saved RETI */
295 r0.h = _evt14_softirq;
296 r0.l = _evt14_softirq;
297 p0.l = lo(EVT14);
298 p0.h = hi(EVT14);
299 [p0] = r0;
300 csync;
301 p0.l = _bfin_irq_flags;
302 p0.h = _bfin_irq_flags;
303 r0 = [p0];
304 sti r0;
Yi Li6a01f232009-01-07 23:14:39 +0800305 rts;
306ENDPROC(___ipipe_call_irqtail)
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800307
Yi Li6a01f232009-01-07 23:14:39 +0800308#endif /* CONFIG_IPIPE */