entry-macro.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * arch/arm/plat-omap/include/mach/entry-macro.S
  3. *
  4. * Low-level IRQ helper macros for OMAP-based platforms
  5. *
  6. * Copyright (C) 2009 Texas Instruments
  7. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <mach/hardware.h>
  14. #include <mach/io.h>
  15. #include <mach/irqs.h>
  16. #include <asm/hardware/gic.h>
  17. #include <plat/omap24xx.h>
  18. #include <plat/omap34xx.h>
  19. #include <plat/omap44xx.h>
  20. #include <plat/multi.h>
  21. #define OMAP2_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP24XX_IC_BASE)
  22. #define OMAP3_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP34XX_IC_BASE)
  23. #define OMAP4_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP44XX_GIC_CPU_BASE)
  24. #define INTCPS_SIR_IRQ_OFFSET 0x0040 /* omap2/3 active interrupt offset */
  25. #define ACTIVEIRQ_MASK 0x7f /* omap2/3 active interrupt bits */
  26. .macro disable_fiq
  27. .endm
  28. .macro arch_ret_to_user, tmp1, tmp2
  29. .endm
  30. /*
  31. * Unoptimized irq functions for multi-omap2, 3 and 4
  32. */
  33. #ifdef MULTI_OMAP2
  34. /*
  35. * We use __glue to avoid errors with multiple definitions of
  36. * .globl omap_irq_base as it's included from entry-armv.S but not
  37. * from entry-common.S.
  38. */
  39. #ifdef __glue
  40. .pushsection .data
  41. .globl omap_irq_base
  42. omap_irq_base:
  43. .word 0
  44. .popsection
  45. #endif
  46. /*
  47. * Configure the interrupt base on the first interrupt.
  48. * See also omap_irq_base_init for setting omap_irq_base.
  49. */
  50. .macro get_irqnr_preamble, base, tmp
  51. ldr \base, =omap_irq_base @ irq base address
  52. ldr \base, [\base, #0] @ irq base value
  53. .endm
  54. /* Check the pending interrupts. Note that base already set */
  55. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  56. tst \base, #0x100 @ gic address?
  57. bne 4401f @ found gic
  58. /* Handle omap2 and omap3 */
  59. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  60. cmp \irqnr, #0x0
  61. bne 9998f
  62. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  63. cmp \irqnr, #0x0
  64. bne 9998f
  65. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  66. cmp \irqnr, #0x0
  67. 9998:
  68. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  69. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  70. b 9999f
  71. /* Handle omap4 */
  72. 4401: ldr \irqstat, [\base, #GIC_CPU_INTACK]
  73. ldr \tmp, =1021
  74. bic \irqnr, \irqstat, #0x1c00
  75. cmp \irqnr, #29
  76. cmpcc \irqnr, \irqnr
  77. cmpne \irqnr, \tmp
  78. cmpcs \irqnr, \irqnr
  79. 9999:
  80. .endm
  81. #ifdef CONFIG_SMP
  82. /* We assume that irqstat (the raw value of the IRQ acknowledge
  83. * register) is preserved from the macro above.
  84. * If there is an IPI, we immediately signal end of interrupt
  85. * on the controller, since this requires the original irqstat
  86. * value which we won't easily be able to recreate later.
  87. */
  88. .macro test_for_ipi, irqnr, irqstat, base, tmp
  89. bic \irqnr, \irqstat, #0x1c00
  90. cmp \irqnr, #16
  91. it cc
  92. strcc \irqstat, [\base, #GIC_CPU_EOI]
  93. it cs
  94. cmpcs \irqnr, \irqnr
  95. .endm
  96. /* As above, this assumes that irqstat and base are preserved */
  97. .macro test_for_ltirq, irqnr, irqstat, base, tmp
  98. bic \irqnr, \irqstat, #0x1c00
  99. mov \tmp, #0
  100. cmp \irqnr, #29
  101. itt eq
  102. moveq \tmp, #1
  103. streq \irqstat, [\base, #GIC_CPU_EOI]
  104. cmp \tmp, #0
  105. .endm
  106. #endif /* CONFIG_SMP */
  107. #else /* MULTI_OMAP2 */
  108. /*
  109. * Optimized irq functions for omap2, 3 and 4
  110. */
  111. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  112. .macro get_irqnr_preamble, base, tmp
  113. #ifdef CONFIG_ARCH_OMAP2
  114. ldr \base, =OMAP2_IRQ_BASE
  115. #else
  116. ldr \base, =OMAP3_IRQ_BASE
  117. #endif
  118. .endm
  119. /* Check the pending interrupts. Note that base already set */
  120. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  121. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  122. cmp \irqnr, #0x0
  123. bne 9999f
  124. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  125. cmp \irqnr, #0x0
  126. bne 9999f
  127. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  128. cmp \irqnr, #0x0
  129. 9999:
  130. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  131. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  132. .endm
  133. #endif
  134. #ifdef CONFIG_ARCH_OMAP4
  135. #define HAVE_GET_IRQNR_PREAMBLE
  136. #include <asm/hardware/entry-macro-gic.S>
  137. .macro get_irqnr_preamble, base, tmp
  138. ldr \base, =OMAP4_IRQ_BASE
  139. .endm
  140. #endif
  141. #endif /* MULTI_OMAP2 */
  142. .macro irq_prio_table
  143. .endm