2 * include/asm-arm/arch-lh7a40x/entry-macro.S
4 * Low-level IRQ helper macros for LH7A40x platforms
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.
10 #include <asm/hardware.h>
11 #include <asm/arch/irqs.h>
13 /* In order to allow there to be support for both of the processor
14 classes at the same time, we make a hack here that isn't very
15 pretty. At startup, the link pointed to with the
16 branch_irq_lh7a400 symbol is replaced with a NOP when the CPU is
17 detected as a lh7a404.
19 *** FIXME: we should clean this up so that there is only one
20 implementation for each CPU's design.
24 #if defined (CONFIG_ARCH_LH7A400) && defined (CONFIG_ARCH_LH7A404)
29 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
31 branch_irq_lh7a400: b 1000f
33 @ Implementation of the LH7A404 get_irqnr_and_base.
35 mov \irqnr, #0 @ VIC1 irq base
36 mov \base, #io_p2v(0x80000000) @ APB registers
37 add \base, \base, #0x8000
38 ldr \tmp, [\base, #0x0030] @ VIC1_VECTADDR
39 tst \tmp, #VA_VECTORED @ Direct vectored
41 tst \tmp, #VA_VIC1DEFAULT @ Default vectored VIC1
42 ldrne \irqstat, [\base, #0] @ VIC1_IRQSTATUS
44 add \base, \base, #(0xa000 - 0x8000)
45 ldr \tmp, [\base, #0x0030] @ VIC2_VECTADDR
46 tst \tmp, #VA_VECTORED @ Direct vectored
48 ldr \irqstat, [\base, #0] @ VIC2_IRQSTATUS
49 mov \irqnr, #32 @ VIC2 irq base
51 1001: movs \irqstat, \irqstat, lsr #1 @ Shift into carry
52 bcs 1008f @ Bit set; irq found
53 add \irqnr, \irqnr, #1
54 bne 1001b @ Until no bits
55 b 1009f @ Nothing? Hmm.
56 1002: and \irqnr, \tmp, #0x3f @ Mask for valid bits
57 1008: movs \irqstat, #1 @ Force !Z
58 str \tmp, [\base, #0x0030] @ Clear vector
61 @ Implementation of the LH7A400 get_irqnr_and_base.
64 mov \base, #io_p2v(0x80000000) @ APB registers
65 ldr \irqstat, [\base, #0x500] @ PIC INTSR
67 1001: movs \irqstat, \irqstat, lsr #1 @ Shift into carry
68 bcs 1008f @ Bit set; irq found
69 add \irqnr, \irqnr, #1
70 bne 1001b @ Until no bits
71 b 1009f @ Nothing? Hmm.
72 1008: movs \irqstat, #1 @ Force !Z
79 #elif defined (CONFIG_ARCH_LH7A400)
83 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
85 mov \base, #io_p2v(0x80000000) @ APB registers
86 ldr \irqstat, [\base, #0x500] @ PIC INTSR
88 1001: movs \irqstat, \irqstat, lsr #1 @ Shift into carry
89 bcs 1008f @ Bit set; irq found
90 add \irqnr, \irqnr, #1
91 bne 1001b @ Until no bits
92 b 1009f @ Nothing? Hmm.
93 1008: movs \irqstat, #1 @ Force !Z
97 #elif defined(CONFIG_ARCH_LH7A404)
102 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
103 mov \irqnr, #0 @ VIC1 irq base
104 mov \base, #io_p2v(0x80000000) @ APB registers
105 add \base, \base, #0x8000
106 ldr \tmp, [\base, #0x0030] @ VIC1_VECTADDR
107 tst \tmp, #VA_VECTORED @ Direct vectored
109 tst \tmp, #VA_VIC1DEFAULT @ Default vectored VIC1
110 ldrne \irqstat, [\base, #0] @ VIC1_IRQSTATUS
112 add \base, \base, #(0xa000 - 0x8000)
113 ldr \tmp, [\base, #0x0030] @ VIC2_VECTADDR
114 tst \tmp, #VA_VECTORED @ Direct vectored
116 ldr \irqstat, [\base, #0] @ VIC2_IRQSTATUS
117 mov \irqnr, #32 @ VIC2 irq base
119 1001: movs \irqstat, \irqstat, lsr #1 @ Shift into carry
120 bcs 1008f @ Bit set; irq found
121 add \irqnr, \irqnr, #1
122 bne 1001b @ Until no bits
123 b 1009f @ Nothing? Hmm.
124 1002: and \irqnr, \tmp, #0x3f @ Mask for valid bits
125 1008: movs \irqstat, #1 @ Force !Z
126 str \tmp, [\base, #0x0030] @ Clear vector