irqflags-arcv2.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #define AUX_USER_SP 0x00D
  17. #define AUX_IRQ_CTRL 0x00E
  18. #define AUX_IRQ_ACT 0x043 /* Active Intr across all levels */
  19. #define AUX_IRQ_LVL_PEND 0x200 /* Pending Intr across all levels */
  20. #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
  21. #define AUX_IRQ_PRIORITY 0x206
  22. #define ICAUSE 0x40a
  23. #define AUX_IRQ_SELECT 0x40b
  24. #define AUX_IRQ_ENABLE 0x40c
  25. /* Was Intr taken in User Mode */
  26. #define AUX_IRQ_ACT_BIT_U 31
  27. /*
  28. * User space should be interruptable even by lowest prio interrupt
  29. * Safe even if actual interrupt priorities is fewer or even one
  30. */
  31. #define ARCV2_IRQ_DEF_PRIO 15
  32. /* seed value for status register */
  33. #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
  34. (ARCV2_IRQ_DEF_PRIO << 1))
  35. /* SLEEP needs default irq priority (<=) which can interrupt the doze */
  36. #define ISA_SLEEP_ARG (0x10 | ARCV2_IRQ_DEF_PRIO)
  37. #ifndef __ASSEMBLY__
  38. /*
  39. * Save IRQ state and disable IRQs
  40. */
  41. static inline long arch_local_irq_save(void)
  42. {
  43. unsigned long flags;
  44. __asm__ __volatile__(" clri %0 \n" : "=r" (flags) : : "memory");
  45. return flags;
  46. }
  47. /*
  48. * restore saved IRQ state
  49. */
  50. static inline void arch_local_irq_restore(unsigned long flags)
  51. {
  52. __asm__ __volatile__(" seti %0 \n" : : "r" (flags) : "memory");
  53. }
  54. /*
  55. * Unconditionally Enable IRQs
  56. */
  57. static inline void arch_local_irq_enable(void)
  58. {
  59. unsigned int irqact = read_aux_reg(AUX_IRQ_ACT);
  60. if (irqact & 0xffff)
  61. write_aux_reg(AUX_IRQ_ACT, irqact & ~0xffff);
  62. __asm__ __volatile__(" seti \n" : : : "memory");
  63. }
  64. /*
  65. * Unconditionally Disable IRQs
  66. */
  67. static inline void arch_local_irq_disable(void)
  68. {
  69. __asm__ __volatile__(" clri \n" : : : "memory");
  70. }
  71. /*
  72. * save IRQ state
  73. */
  74. static inline long arch_local_save_flags(void)
  75. {
  76. unsigned long temp;
  77. __asm__ __volatile__(
  78. " lr %0, [status32] \n"
  79. : "=&r"(temp)
  80. :
  81. : "memory");
  82. return temp;
  83. }
  84. /*
  85. * Query IRQ state
  86. */
  87. static inline int arch_irqs_disabled_flags(unsigned long flags)
  88. {
  89. return !(flags & (STATUS_IE_MASK));
  90. }
  91. static inline int arch_irqs_disabled(void)
  92. {
  93. return arch_irqs_disabled_flags(arch_local_save_flags());
  94. }
  95. static inline void arc_softirq_trigger(int irq)
  96. {
  97. write_aux_reg(AUX_IRQ_HINT, irq);
  98. }
  99. static inline void arc_softirq_clear(int irq)
  100. {
  101. write_aux_reg(AUX_IRQ_HINT, 0);
  102. }
  103. #else
  104. .macro IRQ_DISABLE scratch
  105. clri
  106. .endm
  107. .macro IRQ_ENABLE scratch
  108. seti
  109. .endm
  110. #endif /* __ASSEMBLY__ */
  111. #endif