irqflags-arcv2.h 2.4 KB

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