gsi_emulation.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #if !defined(_GSI_EMULATION_H_)
  6. # define _GSI_EMULATION_H_
  7. # include <linux/interrupt.h>
  8. # include "gsi.h"
  9. #if defined(CONFIG_IPA_EMULATION)
  10. # include "gsi_emulation_stubs.h"
  11. #endif
  12. # define gsi_emu_readl(c) (readl_relaxed(c))
  13. # define gsi_emu_writel(v, c) ({ __iowmb(); writel_relaxed((v), (c)); })
  14. # define CNTRLR_BASE 0
  15. /*
  16. * The following file contains definitions and declarations that are
  17. * germane only to the IPA emulation system, which is run from an X86
  18. * environment. Declaration's for non-X86 (ie. arm) are merely stubs
  19. * to facilitate compile and link.
  20. *
  21. * Interrupt controller registers.
  22. * Descriptions taken from the EMULATION interrupt controller SWI.
  23. * - There is only one Master Enable register
  24. * - Each group of 32 interrupt lines (range) is controlled by 8 registers,
  25. * which are consecutive in memory:
  26. * GE_INT_ENABLE_n
  27. * GE_INT_ENABLE_CLEAR_n
  28. * GE_INT_ENABLE_SET_n
  29. * GE_INT_TYPE_n
  30. * GE_IRQ_STATUS_n
  31. * GE_RAW_STATUS_n
  32. * GE_INT_CLEAR_n
  33. * GE_SOFT_INT_n
  34. * - After the above 8 registers, there are the registers of the next
  35. * group (range) of 32 interrupt lines, and so on.
  36. */
  37. /** @brief The interrupt controller version and interrupt count register.
  38. * Specifies interrupt controller version (upper 16 bits) and the
  39. * number of interrupt lines supported by HW (lower 16 bits).
  40. */
  41. # define GE_INT_CTL_VER_CNT \
  42. (CNTRLR_BASE + 0x0000)
  43. /** @brief Enable or disable physical IRQ output signal to the system,
  44. * not affecting any status registers.
  45. *
  46. * 0x0 : DISABLE IRQ output disabled
  47. * 0x1 : ENABLE IRQ output enabled
  48. */
  49. # define GE_INT_OUT_ENABLE \
  50. (CNTRLR_BASE + 0x0004)
  51. /** @brief The IRQ master enable register.
  52. * Bit #0: IRQ_ENABLE, set 0 to disable, 1 to enable.
  53. */
  54. # define GE_INT_MASTER_ENABLE \
  55. (CNTRLR_BASE + 0x0008)
  56. # define GE_INT_MASTER_STATUS \
  57. (CNTRLR_BASE + 0x000C)
  58. /** @brief Each bit disables (bit=0, default) or enables (bit=1) the
  59. * corresponding interrupt source
  60. */
  61. # define GE_INT_ENABLE_n(n) \
  62. (CNTRLR_BASE + 0x0010 + 0x20 * (n))
  63. /** @brief Write bit=1 to clear (to 0) the corresponding bit(s) in INT_ENABLE.
  64. * Does nothing for bit=0
  65. */
  66. # define GE_INT_ENABLE_CLEAR_n(n) \
  67. (CNTRLR_BASE + 0x0014 + 0x20 * (n))
  68. /** @brief Write bit=1 to set (to 1) the corresponding bit(s) in INT_ENABLE.
  69. * Does nothing for bit=0
  70. */
  71. # define GE_INT_ENABLE_SET_n(n) \
  72. (CNTRLR_BASE + 0x0018 + 0x20 * (n))
  73. /** @brief Select level (bit=0, default) or edge (bit=1) sensitive input
  74. * detection logic for each corresponding interrupt source
  75. */
  76. # define GE_INT_TYPE_n(n) \
  77. (CNTRLR_BASE + 0x001C + 0x20 * (n))
  78. /** @brief Shows the interrupt sources captured in RAW_STATUS that have been
  79. * steered to irq_n by INT_SELECT. Interrupts must also be enabled by
  80. * INT_ENABLE and MASTER_ENABLE. Read only register.
  81. * Bit values: 1=active, 0=inactive
  82. */
  83. # define GE_IRQ_STATUS_n(n) \
  84. (CNTRLR_BASE + 0x0020 + 0x20 * (n))
  85. /** @brief Shows the interrupt sources that have been latched by the input
  86. * logic of the Interrupt Controller. Read only register.
  87. * Bit values: 1=active, 0=inactive
  88. */
  89. # define GE_RAW_STATUS_n(n) \
  90. (CNTRLR_BASE + 0x0024 + 0x20 * (n))
  91. /** @brief Write bit=1 to clear the corresponding bit(s) in RAW_STATUS.
  92. * Does nothing for bit=0
  93. */
  94. # define GE_INT_CLEAR_n(n) \
  95. (CNTRLR_BASE + 0x0028 + 0x20 * (n))
  96. /** @brief Write bit=1 to set the corresponding bit(s) in RAW_STATUS.
  97. * Does nothing for bit=0.
  98. * @note Only functional for edge detected interrupts
  99. */
  100. # define GE_SOFT_INT_n(n) \
  101. (CNTRLR_BASE + 0x002C + 0x20 * (n))
  102. /** @brief Maximal number of ranges in SW. Each range supports 32 interrupt
  103. * lines. If HW is extended considerably, increase this value
  104. */
  105. # define DEO_IC_MAX_RANGE_CNT 8
  106. /** @brief Size of the registers of one range in memory, in bytes */
  107. # define DEO_IC_RANGE_MEM_SIZE 32 /* SWI: 8 registers, no gaps */
  108. /** @brief Minimal Interrupt controller HW version */
  109. # define DEO_IC_INT_CTL_VER_MIN 0x0102
  110. #if defined(CONFIG_IPA_EMULATION) /* declarations to follow */
  111. /*
  112. * *****************************************************************************
  113. * The following used to set up the EMULATION interrupt controller...
  114. * *****************************************************************************
  115. */
  116. int setup_emulator_cntrlr(
  117. void __iomem *intcntrlr_base,
  118. u32 intcntrlr_mem_size);
  119. /*
  120. * *****************************************************************************
  121. * The following for EMULATION hard irq...
  122. * *****************************************************************************
  123. */
  124. irqreturn_t emulator_hard_irq_isr(
  125. int irq,
  126. void *ctxt);
  127. /*
  128. * *****************************************************************************
  129. * The following for EMULATION soft irq...
  130. * *****************************************************************************
  131. */
  132. irqreturn_t emulator_soft_irq_isr(
  133. int irq,
  134. void *ctxt);
  135. # else /* #if !defined(CONFIG_IPA_EMULATION) then definitions to follow */
  136. static inline int setup_emulator_cntrlr(
  137. void __iomem *intcntrlr_base,
  138. u32 intcntrlr_mem_size)
  139. {
  140. return 0;
  141. }
  142. static inline irqreturn_t emulator_hard_irq_isr(
  143. int irq,
  144. void *ctxt)
  145. {
  146. return IRQ_NONE;
  147. }
  148. static inline irqreturn_t emulator_soft_irq_isr(
  149. int irq,
  150. void *ctxt)
  151. {
  152. return IRQ_HANDLED;
  153. }
  154. # endif /* #if defined(CONFIG_IPA_EMULATION) */
  155. #endif /* #if !defined(_GSI_EMULATION_H_) */