xive-regs.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2016,2017 IBM Corporation.
  4. */
  5. #ifndef _ASM_POWERPC_XIVE_REGS_H
  6. #define _ASM_POWERPC_XIVE_REGS_H
  7. /*
  8. * "magic" Event State Buffer (ESB) MMIO offsets.
  9. *
  10. * Each interrupt source has a 2-bit state machine called ESB
  11. * which can be controlled by MMIO. It's made of 2 bits, P and
  12. * Q. P indicates that an interrupt is pending (has been sent
  13. * to a queue and is waiting for an EOI). Q indicates that the
  14. * interrupt has been triggered while pending.
  15. *
  16. * This acts as a coalescing mechanism in order to guarantee
  17. * that a given interrupt only occurs at most once in a queue.
  18. *
  19. * When doing an EOI, the Q bit will indicate if the interrupt
  20. * needs to be re-triggered.
  21. *
  22. * The following offsets into the ESB MMIO allow to read or
  23. * manipulate the PQ bits. They must be used with an 8-bytes
  24. * load instruction. They all return the previous state of the
  25. * interrupt (atomically).
  26. *
  27. * Additionally, some ESB pages support doing an EOI via a
  28. * store at 0 and some ESBs support doing a trigger via a
  29. * separate trigger page.
  30. */
  31. #define XIVE_ESB_STORE_EOI 0x400 /* Store */
  32. #define XIVE_ESB_LOAD_EOI 0x000 /* Load */
  33. #define XIVE_ESB_GET 0x800 /* Load */
  34. #define XIVE_ESB_SET_PQ_00 0xc00 /* Load */
  35. #define XIVE_ESB_SET_PQ_01 0xd00 /* Load */
  36. #define XIVE_ESB_SET_PQ_10 0xe00 /* Load */
  37. #define XIVE_ESB_SET_PQ_11 0xf00 /* Load */
  38. /*
  39. * Load-after-store ordering
  40. *
  41. * Adding this offset to the load address will enforce
  42. * load-after-store ordering. This is required to use StoreEOI.
  43. */
  44. #define XIVE_ESB_LD_ST_MO 0x40 /* Load-after-store ordering */
  45. #define XIVE_ESB_VAL_P 0x2
  46. #define XIVE_ESB_VAL_Q 0x1
  47. #define XIVE_ESB_INVALID 0xFF
  48. /*
  49. * Thread Management (aka "TM") registers
  50. */
  51. /* TM register offsets */
  52. #define TM_QW0_USER 0x000 /* All rings */
  53. #define TM_QW1_OS 0x010 /* Ring 0..2 */
  54. #define TM_QW2_HV_POOL 0x020 /* Ring 0..1 */
  55. #define TM_QW3_HV_PHYS 0x030 /* Ring 0..1 */
  56. /* Byte offsets inside a QW QW0 QW1 QW2 QW3 */
  57. #define TM_NSR 0x0 /* + + - + */
  58. #define TM_CPPR 0x1 /* - + - + */
  59. #define TM_IPB 0x2 /* - + + + */
  60. #define TM_LSMFB 0x3 /* - + + + */
  61. #define TM_ACK_CNT 0x4 /* - + - - */
  62. #define TM_INC 0x5 /* - + - + */
  63. #define TM_AGE 0x6 /* - + - + */
  64. #define TM_PIPR 0x7 /* - + - + */
  65. #define TM_WORD0 0x0
  66. #define TM_WORD1 0x4
  67. /*
  68. * QW word 2 contains the valid bit at the top and other fields
  69. * depending on the QW.
  70. */
  71. #define TM_WORD2 0x8
  72. #define TM_QW0W2_VU PPC_BIT32(0)
  73. #define TM_QW0W2_LOGIC_SERV PPC_BITMASK32(1,31) // XX 2,31 ?
  74. #define TM_QW1W2_VO PPC_BIT32(0)
  75. #define TM_QW1W2_HO PPC_BIT32(1) /* P10 XIVE2 */
  76. #define TM_QW1W2_OS_CAM PPC_BITMASK32(8,31)
  77. #define TM_QW2W2_VP PPC_BIT32(0)
  78. #define TM_QW2W2_HP PPC_BIT32(1) /* P10 XIVE2 */
  79. #define TM_QW2W2_POOL_CAM PPC_BITMASK32(8,31)
  80. #define TM_QW3W2_VT PPC_BIT32(0)
  81. #define TM_QW3W2_HT PPC_BIT32(1) /* P10 XIVE2 */
  82. #define TM_QW3W2_LP PPC_BIT32(6)
  83. #define TM_QW3W2_LE PPC_BIT32(7)
  84. #define TM_QW3W2_T PPC_BIT32(31)
  85. /*
  86. * In addition to normal loads to "peek" and writes (only when invalid)
  87. * using 4 and 8 bytes accesses, the above registers support these
  88. * "special" byte operations:
  89. *
  90. * - Byte load from QW0[NSR] - User level NSR (EBB)
  91. * - Byte store to QW0[NSR] - User level NSR (EBB)
  92. * - Byte load/store to QW1[CPPR] and QW3[CPPR] - CPPR access
  93. * - Byte load from QW3[TM_WORD2] - Read VT||00000||LP||LE on thrd 0
  94. * otherwise VT||0000000
  95. * - Byte store to QW3[TM_WORD2] - Set VT bit (and LP/LE if present)
  96. *
  97. * Then we have all these "special" CI ops at these offset that trigger
  98. * all sorts of side effects:
  99. */
  100. #define TM_SPC_ACK_EBB 0x800 /* Load8 ack EBB to reg*/
  101. #define TM_SPC_ACK_OS_REG 0x810 /* Load16 ack OS irq to reg */
  102. #define TM_SPC_PUSH_USR_CTX 0x808 /* Store32 Push/Validate user context */
  103. #define TM_SPC_PULL_USR_CTX 0x808 /* Load32 Pull/Invalidate user context */
  104. #define TM_SPC_SET_OS_PENDING 0x812 /* Store8 Set OS irq pending bit */
  105. #define TM_SPC_PULL_OS_CTX 0x818 /* Load32/Load64 Pull/Invalidate OS context to reg */
  106. #define TM_SPC_PULL_POOL_CTX 0x828 /* Load32/Load64 Pull/Invalidate Pool context to reg*/
  107. #define TM_SPC_ACK_HV_REG 0x830 /* Load16 ack HV irq to reg */
  108. #define TM_SPC_PULL_USR_CTX_OL 0xc08 /* Store8 Pull/Inval usr ctx to odd line */
  109. #define TM_SPC_ACK_OS_EL 0xc10 /* Store8 ack OS irq to even line */
  110. #define TM_SPC_ACK_HV_POOL_EL 0xc20 /* Store8 ack HV evt pool to even line */
  111. #define TM_SPC_ACK_HV_EL 0xc30 /* Store8 ack HV irq to even line */
  112. /* XXX more... */
  113. /* NSR fields for the various QW ack types */
  114. #define TM_QW0_NSR_EB PPC_BIT8(0)
  115. #define TM_QW1_NSR_EO PPC_BIT8(0)
  116. #define TM_QW3_NSR_HE PPC_BITMASK8(0,1)
  117. #define TM_QW3_NSR_HE_NONE 0
  118. #define TM_QW3_NSR_HE_POOL 1
  119. #define TM_QW3_NSR_HE_PHYS 2
  120. #define TM_QW3_NSR_HE_LSI 3
  121. #define TM_QW3_NSR_I PPC_BIT8(2)
  122. #define TM_QW3_NSR_GRP_LVL PPC_BIT8(3,7)
  123. #endif /* _ASM_POWERPC_XIVE_REGS_H */