2 * Copyright (C) 2010 Magnus Damm
3 * Copyright (C) 2008 Renesas Solutions Corp.
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.
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.
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
18 #include <mach/irqs.h>
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 */
29 .macro get_irqnr_preamble, base, tmp
30 ldr \base, =INTCA_BASE
33 .macro arch_ret_to_user, tmp1, tmp2
36 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
37 /* The single INTFLGA read access below results in the following:
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
44 ldr \irqnr, [\base, #INTFLGA_OFFS]
46 /* Restore INTLVLA with the value saved in INTLVLB.
47 * This is required to support interrupt priorities properly.
49 ldrb \tmp, [\base, #INTLVLB_OFFS]
50 strb \tmp, [\base, #INTLVLA_OFFS]
52 /* Handle invalid vector number case */
56 /* Convert vector to irq number, same as the evt2irq() macro */
57 lsr \irqnr, \irqnr, #0x5
58 subs \irqnr, \irqnr, #16