Merge branch 'linus' into core/printk
[sfrench/cifs-2.6.git] / arch / blackfin / mach-common / interrupt.S
1 /*
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>
32 #include <mach/irq.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>
39
40 #include <asm/context.S>
41
42 .extern _ret_from_exception
43
44 #ifdef CONFIG_I_ENTRY_L1
45 .section .l1.text
46 #else
47 .text
48 #endif
49
50 .align 4        /* just in case */
51
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
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
122 #if ANOMALY_05000283 || ANOMALY_05000315
123         cc = r7 == r7;
124         p5.h = HI(CHIPID);
125         p5.l = LO(CHIPID);
126         if cc jump 1f;
127         r7.l = W[p5];
128 1:
129 #endif
130         r1 =  sp;
131         SP += -12;
132 #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 */
138         call _do_irq;
139         SP += 12;
140 #endif /* CONFIG_IPIPE */
141         call _return_from_int;
142 .Lcommon_restore_context:
143         RESTORE_CONTEXT
144         rti;
145
146 /* interrupt routine for ivhw - 5 */
147 ENTRY(_evt_ivhw)
148         SAVE_ALL_SYS
149 #ifdef CONFIG_FRAME_POINTER
150         fp = 0;
151 #endif
152
153 #if ANOMALY_05000283 || ANOMALY_05000315
154         cc = r7 == r7;
155         p5.h = HI(CHIPID);
156         p5.l = LO(CHIPID);
157         if cc jump 1f;
158         r7.l = W[p5];
159 1:
160 #endif
161
162         # 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
168         /* set the EXCAUSE to HWERR for trap_c */
169         r0 = [sp + PT_SEQSTAT];
170         R1.L = LO(VEC_HWERR);
171         R1.H = HI(VEC_HWERR);
172         R0 = R0 | R1;
173         [sp + PT_SEQSTAT] = R0;
174
175         r0 = sp;        /* stack frame pt_regs pointer argument ==> r0 */
176         SP += -12;
177         call _trap_c;
178         SP += 12;
179
180 #ifdef EBIU_ERRMST
181         /* make sure EBIU_ERRMST is clear */
182         p0.l = LO(EBIU_ERRMST);
183         p0.h = HI(EBIU_ERRMST);
184         r0.l = (CORE_ERROR | CORE_MERROR);
185         w[p0] = r0.l;
186 #endif
187
188         call _ret_from_exception;
189
190 .Lcommon_restore_all_sys:
191         RESTORE_ALL_SYS
192         rti;
193 ENDPROC(_evt_ivhw)
194
195 /* Interrupt routine for evt2 (NMI).
196  * We don't actually use this, so just return.
197  * For inner circle type details, please see:
198  * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:nmi
199  */
200 ENTRY(_evt_nmi)
201 .weak _evt_nmi
202         rtn;
203 ENDPROC(_evt_nmi)
204
205 /* interrupt routine for core timer - 6 */
206 ENTRY(_evt_timer)
207         TIMER_INTERRUPT_ENTRY(EVT_IVTMR_P)
208
209 /* interrupt routine for evt7 - 7 */
210 ENTRY(_evt_evt7)
211         INTERRUPT_ENTRY(EVT_IVG7_P)
212 ENTRY(_evt_evt8)
213         INTERRUPT_ENTRY(EVT_IVG8_P)
214 ENTRY(_evt_evt9)
215         INTERRUPT_ENTRY(EVT_IVG9_P)
216 ENTRY(_evt_evt10)
217         INTERRUPT_ENTRY(EVT_IVG10_P)
218 ENTRY(_evt_evt11)
219         INTERRUPT_ENTRY(EVT_IVG11_P)
220 ENTRY(_evt_evt12)
221         INTERRUPT_ENTRY(EVT_IVG12_P)
222 ENTRY(_evt_evt13)
223         INTERRUPT_ENTRY(EVT_IVG13_P)
224
225
226  /* interrupt routine for system_call - 15 */
227 ENTRY(_evt_system_call)
228         SAVE_CONTEXT_SYSCALL
229 #ifdef CONFIG_FRAME_POINTER
230         fp = 0;
231 #endif
232         call _system_call;
233         jump .Lcommon_restore_context;
234 ENDPROC(_evt_system_call)
235
236 #ifdef CONFIG_IPIPE
237 ENTRY(___ipipe_call_irqtail)
238         p0 = r0;
239         r0.l = 1f;
240         r0.h = 1f;
241         reti = r0;
242         rti;
243 1:
244         [--sp] = rets;
245         [--sp] = ( r7:4, p5:3 );
246         sp += -12;
247         call (p0);
248         sp += 12;
249         ( r7:4, p5:3 ) = [sp++];
250         rets = [sp++];
251
252         [--sp] = reti;
253         reti = [sp++];          /* IRQs are off. */
254         r0.h = 3f;
255         r0.l = 3f;
256         p0.l = lo(EVT14);
257         p0.h = hi(EVT14);
258         [p0] = r0;
259         csync;
260         r0 = 0x401f (z);
261         sti r0;
262         raise 14;
263         [--sp] = reti;          /* IRQs on. */
264 2:
265         jump 2b;                /* Likely paranoid. */
266 3:
267         sp += 4;                /* Discard saved RETI */
268         r0.h = _evt14_softirq;
269         r0.l = _evt14_softirq;
270         p0.l = lo(EVT14);
271         p0.h = hi(EVT14);
272         [p0] = r0;
273         csync;
274         p0.l = _bfin_irq_flags;
275         p0.h = _bfin_irq_flags;
276         r0 = [p0];
277         sti r0;
278         rts;
279 ENDPROC(___ipipe_call_irqtail)
280
281 #endif /* CONFIG_IPIPE */