ARM: mach-shmobile: INTC interrupt priority level demux fix
[pandora-kernel.git] / arch / arm / mach-shmobile / include / mach / entry-macro.S
1 /*
2  * Copyright (C) 2010 Magnus Damm
3  * Copyright (C) 2008 Renesas Solutions Corp.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; version 2 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 #include <mach/irqs.h>
19
20 #define INTCA_BASE      0xe6980000
21 #define INTFLGA_OFFS    0x00000018 /* accept pending interrupt */
22 #define INTEVTA_OFFS    0x00000020 /* vector number of accepted interrupt */
23 #define INTLVLA_OFFS    0x00000030 /* priority level of accepted interrupt */
24 #define INTLVLB_OFFS    0x00000034 /* previous priority level */
25
26         .macro  disable_fiq
27         .endm
28
29         .macro  get_irqnr_preamble, base, tmp
30         ldr     \base, =INTCA_BASE
31         .endm
32
33         .macro  arch_ret_to_user, tmp1, tmp2
34         .endm
35
36         .macro  get_irqnr_and_base, irqnr, irqstat, base, tmp
37         /* The single INTFLGA read access below results in the following:
38          *
39          * 1. INTLVLB is updated with old priority value from INTLVLA
40          * 2. Highest priority interrupt is accepted
41          * 3. INTLVLA is updated to contain priority of accepted interrupt
42          * 4. Accepted interrupt vector is stored in INTFLGA and INTEVTA
43          */
44         ldr     \irqnr, [\base, #INTFLGA_OFFS]
45
46         /* Restore INTLVLA with the value saved in INTLVLB.
47          * This is required to support interrupt priorities properly.
48          */
49         ldrb    \tmp, [\base, #INTLVLB_OFFS]
50         strb    \tmp, [\base, #INTLVLA_OFFS]
51
52         /* Handle invalid vector number case */
53         cmp     \irqnr, #0
54         beq     1000f
55
56         /* Convert vector to irq number, same as the evt2irq() macro */
57         lsr     \irqnr, \irqnr, #0x5
58         subs    \irqnr, \irqnr, #16
59
60 1000:
61         .endm