irqflags-arcv2.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. /* 0 is highest level, but taken by FIRQs, if present in design */
  28. #define ARCV2_IRQ_DEF_PRIO 0
  29. /* seed value for status register */
  30. #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
  31. (ARCV2_IRQ_DEF_PRIO << 1))
  32. /* SLEEP needs default irq priority (<=) which can interrupt the doze */
  33. #define ISA_SLEEP_ARG (0x10 | ARCV2_IRQ_DEF_PRIO)
  34. #ifndef __ASSEMBLY__
  35. /*
  36. * Save IRQ state and disable IRQs
  37. */
  38. static inline long arch_local_irq_save(void)
  39. {
  40. unsigned long flags;
  41. __asm__ __volatile__(" clri %0 \n" : "=r" (flags) : : "memory");
  42. return flags;
  43. }
  44. /*
  45. * restore saved IRQ state
  46. */
  47. static inline void arch_local_irq_restore(unsigned long flags)
  48. {
  49. __asm__ __volatile__(" seti %0 \n" : : "r" (flags) : "memory");
  50. }
  51. /*
  52. * Unconditionally Enable IRQs
  53. */
  54. static inline void arch_local_irq_enable(void)
  55. {
  56. unsigned int irqact = read_aux_reg(AUX_IRQ_ACT);
  57. if (irqact & 0xffff)
  58. write_aux_reg(AUX_IRQ_ACT, irqact & ~0xffff);
  59. __asm__ __volatile__(" seti \n" : : : "memory");
  60. }
  61. /*
  62. * Unconditionally Disable IRQs
  63. */
  64. static inline void arch_local_irq_disable(void)
  65. {
  66. __asm__ __volatile__(" clri \n" : : : "memory");
  67. }
  68. /*
  69. * save IRQ state
  70. */
  71. static inline long arch_local_save_flags(void)
  72. {
  73. unsigned long temp;
  74. __asm__ __volatile__(
  75. " lr %0, [status32] \n"
  76. : "=&r"(temp)
  77. :
  78. : "memory");
  79. return temp;
  80. }
  81. /*
  82. * Query IRQ state
  83. */
  84. static inline int arch_irqs_disabled_flags(unsigned long flags)
  85. {
  86. return !(flags & (STATUS_IE_MASK));
  87. }
  88. static inline int arch_irqs_disabled(void)
  89. {
  90. return arch_irqs_disabled_flags(arch_local_save_flags());
  91. }
  92. static inline void arc_softirq_trigger(int irq)
  93. {
  94. write_aux_reg(AUX_IRQ_HINT, irq);
  95. }
  96. static inline void arc_softirq_clear(int irq)
  97. {
  98. write_aux_reg(AUX_IRQ_HINT, 0);
  99. }
  100. #else
  101. .macro IRQ_DISABLE scratch
  102. clri
  103. .endm
  104. .macro IRQ_ENABLE scratch
  105. seti
  106. .endm
  107. #endif /* __ASSEMBLY__ */
  108. #endif