irqflags-arcv2.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_IRQFLAGS_ARCV2_H
  9. #define __ASM_IRQFLAGS_ARCV2_H
  10. #include <asm/arcregs.h>
  11. /* status32 Bits */
  12. #define STATUS_AD_BIT 19 /* Disable Align chk: core supports non-aligned */
  13. #define STATUS_IE_BIT 31
  14. #define STATUS_AD_MASK (1<<STATUS_AD_BIT)
  15. #define STATUS_IE_MASK (1<<STATUS_IE_BIT)
  16. /* status32 Bits as encoded/expected by CLRI/SETI */
  17. #define CLRI_STATUS_IE_BIT 4
  18. #define CLRI_STATUS_E_MASK 0xF
  19. #define CLRI_STATUS_IE_MASK (1 << CLRI_STATUS_IE_BIT)
  20. #define AUX_USER_SP 0x00D
  21. #define AUX_IRQ_CTRL 0x00E
  22. #define AUX_IRQ_ACT 0x043 /* Active Intr across all levels */
  23. #define AUX_IRQ_LVL_PEND 0x200 /* Pending Intr across all levels */
  24. #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
  25. #define AUX_IRQ_PRIORITY 0x206
  26. #define ICAUSE 0x40a
  27. #define AUX_IRQ_SELECT 0x40b
  28. #define AUX_IRQ_ENABLE 0x40c
  29. /* Was Intr taken in User Mode */
  30. #define AUX_IRQ_ACT_BIT_U 31
  31. /*
  32. * Hardware supports 16 priorities (0 highest, 15 lowest)
  33. * Linux by default runs at 1, priority 0 reserved for NMI style interrupts
  34. */
  35. #define ARCV2_IRQ_DEF_PRIO 1
  36. /* seed value for status register */
  37. #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
  38. (ARCV2_IRQ_DEF_PRIO << 1))
  39. #ifndef __ASSEMBLY__
  40. /*
  41. * Save IRQ state and disable IRQs
  42. */
  43. static inline long arch_local_irq_save(void)
  44. {
  45. unsigned long flags;
  46. __asm__ __volatile__(" clri %0 \n" : "=r" (flags) : : "memory");
  47. return flags;
  48. }
  49. /*
  50. * restore saved IRQ state
  51. */
  52. static inline void arch_local_irq_restore(unsigned long flags)
  53. {
  54. __asm__ __volatile__(" seti %0 \n" : : "r" (flags) : "memory");
  55. }
  56. /*
  57. * Unconditionally Enable IRQs
  58. */
  59. static inline void arch_local_irq_enable(void)
  60. {
  61. unsigned int irqact = read_aux_reg(AUX_IRQ_ACT);
  62. if (irqact & 0xffff)
  63. write_aux_reg(AUX_IRQ_ACT, irqact & ~0xffff);
  64. __asm__ __volatile__(" seti \n" : : : "memory");
  65. }
  66. /*
  67. * Unconditionally Disable IRQs
  68. */
  69. static inline void arch_local_irq_disable(void)
  70. {
  71. __asm__ __volatile__(" clri \n" : : : "memory");
  72. }
  73. /*
  74. * save IRQ state
  75. */
  76. static inline long arch_local_save_flags(void)
  77. {
  78. unsigned long temp;
  79. __asm__ __volatile__(
  80. " lr %0, [status32] \n"
  81. : "=&r"(temp)
  82. :
  83. : "memory");
  84. /* To be compatible with irq_save()/irq_restore()
  85. * encode the irq bits as expected by CLRI/SETI
  86. * (this was needed to make CONFIG_TRACE_IRQFLAGS work)
  87. */
  88. temp = (1 << 5) |
  89. ((!!(temp & STATUS_IE_MASK)) << CLRI_STATUS_IE_BIT) |
  90. ((temp >> 1) & CLRI_STATUS_E_MASK);
  91. return temp;
  92. }
  93. /*
  94. * Query IRQ state
  95. */
  96. static inline int arch_irqs_disabled_flags(unsigned long flags)
  97. {
  98. return !(flags & CLRI_STATUS_IE_MASK);
  99. }
  100. static inline int arch_irqs_disabled(void)
  101. {
  102. return arch_irqs_disabled_flags(arch_local_save_flags());
  103. }
  104. static inline void arc_softirq_trigger(int irq)
  105. {
  106. write_aux_reg(AUX_IRQ_HINT, irq);
  107. }
  108. static inline void arc_softirq_clear(int irq)
  109. {
  110. write_aux_reg(AUX_IRQ_HINT, 0);
  111. }
  112. #else
  113. #ifdef CONFIG_TRACE_IRQFLAGS
  114. .macro TRACE_ASM_IRQ_DISABLE
  115. bl trace_hardirqs_off
  116. .endm
  117. .macro TRACE_ASM_IRQ_ENABLE
  118. bl trace_hardirqs_on
  119. .endm
  120. #else
  121. .macro TRACE_ASM_IRQ_DISABLE
  122. .endm
  123. .macro TRACE_ASM_IRQ_ENABLE
  124. .endm
  125. #endif
  126. .macro IRQ_DISABLE scratch
  127. clri
  128. TRACE_ASM_IRQ_DISABLE
  129. .endm
  130. .macro IRQ_ENABLE scratch
  131. TRACE_ASM_IRQ_ENABLE
  132. seti
  133. .endm
  134. #endif /* __ASSEMBLY__ */
  135. #endif