entry-macro.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. * Configure the interrupt base on the first interrupt.
  36. * See also omap_irq_base_init for setting omap_irq_base.
  37. */
  38. .macro get_irqnr_preamble, base, tmp
  39. ldr \base, =omap_irq_base @ irq base address
  40. ldr \base, [\base, #0] @ irq base value
  41. .endm
  42. /* Check the pending interrupts. Note that base already set */
  43. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  44. tst \base, #0x100 @ gic address?
  45. bne 4401f @ found gic
  46. /* Handle omap2 and omap3 */
  47. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  48. cmp \irqnr, #0x0
  49. bne 9998f
  50. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  51. cmp \irqnr, #0x0
  52. bne 9998f
  53. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  54. cmp \irqnr, #0x0
  55. bne 9998f
  56. /*
  57. * ti816x has additional IRQ pending register. Checking this
  58. * register on omap2 & omap3 has no effect (read as 0).
  59. */
  60. ldr \irqnr, [\base, #0xf8] /* IRQ pending reg 4 */
  61. cmp \irqnr, #0x0
  62. 9998:
  63. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  64. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  65. b 9999f
  66. /* Handle omap4 */
  67. 4401: ldr \irqstat, [\base, #GIC_CPU_INTACK]
  68. ldr \tmp, =1021
  69. bic \irqnr, \irqstat, #0x1c00
  70. cmp \irqnr, #29
  71. cmpcc \irqnr, \irqnr
  72. cmpne \irqnr, \tmp
  73. cmpcs \irqnr, \irqnr
  74. 9999:
  75. .endm
  76. #ifdef CONFIG_SMP
  77. /* We assume that irqstat (the raw value of the IRQ acknowledge
  78. * register) is preserved from the macro above.
  79. * If there is an IPI, we immediately signal end of interrupt
  80. * on the controller, since this requires the original irqstat
  81. * value which we won't easily be able to recreate later.
  82. */
  83. .macro test_for_ipi, irqnr, irqstat, base, tmp
  84. bic \irqnr, \irqstat, #0x1c00
  85. cmp \irqnr, #16
  86. it cc
  87. strcc \irqstat, [\base, #GIC_CPU_EOI]
  88. it cs
  89. cmpcs \irqnr, \irqnr
  90. .endm
  91. /* As above, this assumes that irqstat and base are preserved */
  92. .macro test_for_ltirq, irqnr, irqstat, base, tmp
  93. bic \irqnr, \irqstat, #0x1c00
  94. mov \tmp, #0
  95. cmp \irqnr, #29
  96. itt eq
  97. moveq \tmp, #1
  98. streq \irqstat, [\base, #GIC_CPU_EOI]
  99. cmp \tmp, #0
  100. .endm
  101. #endif /* CONFIG_SMP */
  102. #else /* MULTI_OMAP2 */
  103. /*
  104. * Optimized irq functions for omap2, 3 and 4
  105. */
  106. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  107. .macro get_irqnr_preamble, base, tmp
  108. #ifdef CONFIG_ARCH_OMAP2
  109. ldr \base, =OMAP2_IRQ_BASE
  110. #else
  111. ldr \base, =OMAP3_IRQ_BASE
  112. #endif
  113. .endm
  114. /* Check the pending interrupts. Note that base already set */
  115. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  116. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  117. cmp \irqnr, #0x0
  118. bne 9999f
  119. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  120. cmp \irqnr, #0x0
  121. bne 9999f
  122. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  123. cmp \irqnr, #0x0
  124. #ifdef CONFIG_SOC_OMAPTI816X
  125. bne 9999f
  126. ldr \irqnr, [\base, #0xf8] /* IRQ pending reg 4 */
  127. cmp \irqnr, #0x0
  128. #endif
  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 */