This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / asm-arm / arch-s3c2410 / entry-macro.S
1 /*
2  * include/asm-arm/arch-s3c2410/entry-macro.S
3  *
4  * Low-level IRQ helper macros for S3C2410-based platforms
5  *
6  * This file is licensed under  the terms of the GNU General Public
7  * License version 2. This program is licensed "as is" without any
8  * warranty of any kind, whether express or implied.
9  */
10
11
12         .macro  get_irqnr_and_base, irqnr, irqstat, base, tmp
13
14                 mov     \tmp, #S3C2410_VA_IRQ
15                 ldr     \irqnr, [ \tmp, #0x14 ]         @ get irq no
16 30000:
17                 teq     \irqnr, #4
18                 teqne   \irqnr, #5
19                 beq     1002f                           @ external irq reg
20
21                 @ debug check to see if interrupt reported is the same
22                 @ as the offset....
23
24                 teq     \irqnr, #0
25                 beq     20002f
26                 ldr     \irqstat, [ \tmp, #0x10 ]       @ INTPND
27                 mov     \irqstat, \irqstat, lsr \irqnr
28                 tst     \irqstat, #1
29                 bne     20002f
30
31                 /* debug/warning if we get an invalud response from the
32                  * INTOFFSET register */
33 #if 1
34                 stmfd   r13!, { r0 - r4 , r8-r12, r14 }
35                 ldr     r1,     [ \tmp, #0x14 ]         @ INTOFFSET
36                 ldr     r2,     [ \tmp, #0x10 ]         @ INTPND
37                 ldr     r3,     [ \tmp, #0x00 ]         @ SRCPND
38                 adr     r0, 20003f
39                 bl      printk
40                 b       20004f
41
42 20003:
43                 .ascii  "<7>irq: err - bad offset %d, intpnd=%08x, srcpnd=%08x\n"
44                 .byte   0
45                 .align  4
46 20004:
47                 mov     r1, #1
48                 mov     \tmp, #S3C2410_VA_IRQ
49                 ldmfd   r13!, { r0 - r4 , r8-r12, r14 }
50 #endif
51
52                 @ try working out interrupt number for ourselves
53                 mov     \irqnr, #0
54                 ldr     \irqstat, [ \tmp, #0x10 ]       @ INTPND
55 10021:
56                 movs    \irqstat, \irqstat, lsr#1
57                 bcs     30000b          @ try and re-start the proccess
58                 add     \irqnr, \irqnr, #1
59                 cmp     \irqnr, #32
60                 ble     10021b
61
62                 @ found no interrupt, set Z flag and leave
63                 movs    \irqnr, #0
64                 b       1001f
65
66 20005:
67 20002:          @ exit
68                 @ we base the s3c2410x interrupts at 16 and above to allow
69                 @ isa peripherals to have their standard interrupts, also
70                 @ ensure that Z flag is un-set on exit
71
72                 @ note, we cannot be sure if we get IRQ_EINT0 (0) that
73                 @ there is simply no interrupt pending, so in all other
74                 @ cases we jump to say we have found something, otherwise
75                 @ we check to see if the interrupt really is assrted
76                 adds    \irqnr, \irqnr, #IRQ_EINT0
77                 teq     \irqnr, #IRQ_EINT0
78                 bne     1001f                           @ exit
79                 ldr     \irqstat, [ \tmp, #0x10 ]       @ INTPND
80                 teq     \irqstat, #0
81                 moveq   \irqnr, #0
82                 b       1001f
83
84                 @ we get here from no main or external interrupts pending
85 1002:
86                 add     \tmp, \tmp, #S3C2410_VA_GPIO - S3C2410_VA_IRQ
87                 ldr     \irqstat, [ \tmp, # 0xa8 ]      @ EXTINTPEND
88                 ldr     \irqnr, [ \tmp, # 0xa4 ]        @ EXTINTMASK
89
90                 bic     \irqstat, \irqstat, \irqnr      @ clear masked irqs
91
92                 mov     \irqnr, #IRQ_EINT4              @ start extint nos
93                 mov     \irqstat, \irqstat, lsr#4       @ ignore bottom 4 bits
94 10021:
95                 movs    \irqstat, \irqstat, lsr#1
96                 bcs     1004f
97                 add     \irqnr, \irqnr, #1
98                 cmp     \irqnr, #IRQ_EINT23
99                 ble     10021b
100
101                 @ found no interrupt, set Z flag and leave
102                 movs    \irqnr, #0
103
104 1004:           @ ensure Z flag clear in case our MOVS shifted out the last bit
105                 teq     \irqnr, #0
106 1001:
107                 @ exit irq routine
108                 .endm
109
110
111                 /* currently don't need an disable_fiq macro */
112
113                 .macro  disable_fiq
114                 .endm
115
116