irqflags-arcv2.h 2.6 KB

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