Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright 2016,2017 IBM Corporation.
0004  */
0005 #ifndef _ASM_POWERPC_XIVE_REGS_H
0006 #define _ASM_POWERPC_XIVE_REGS_H
0007 
0008 /*
0009  * "magic" Event State Buffer (ESB) MMIO offsets.
0010  *
0011  * Each interrupt source has a 2-bit state machine called ESB
0012  * which can be controlled by MMIO. It's made of 2 bits, P and
0013  * Q. P indicates that an interrupt is pending (has been sent
0014  * to a queue and is waiting for an EOI). Q indicates that the
0015  * interrupt has been triggered while pending.
0016  *
0017  * This acts as a coalescing mechanism in order to guarantee
0018  * that a given interrupt only occurs at most once in a queue.
0019  *
0020  * When doing an EOI, the Q bit will indicate if the interrupt
0021  * needs to be re-triggered.
0022  *
0023  * The following offsets into the ESB MMIO allow to read or
0024  * manipulate the PQ bits. They must be used with an 8-bytes
0025  * load instruction. They all return the previous state of the
0026  * interrupt (atomically).
0027  *
0028  * Additionally, some ESB pages support doing an EOI via a
0029  * store at 0 and some ESBs support doing a trigger via a
0030  * separate trigger page.
0031  */
0032 #define XIVE_ESB_STORE_EOI  0x400 /* Store */
0033 #define XIVE_ESB_LOAD_EOI   0x000 /* Load */
0034 #define XIVE_ESB_GET        0x800 /* Load */
0035 #define XIVE_ESB_SET_PQ_00  0xc00 /* Load */
0036 #define XIVE_ESB_SET_PQ_01  0xd00 /* Load */
0037 #define XIVE_ESB_SET_PQ_10  0xe00 /* Load */
0038 #define XIVE_ESB_SET_PQ_11  0xf00 /* Load */
0039 
0040 /*
0041  * Load-after-store ordering
0042  *
0043  * Adding this offset to the load address will enforce
0044  * load-after-store ordering. This is required to use StoreEOI.
0045  */
0046 #define XIVE_ESB_LD_ST_MO   0x40 /* Load-after-store ordering */
0047 
0048 #define XIVE_ESB_VAL_P      0x2
0049 #define XIVE_ESB_VAL_Q      0x1
0050 #define XIVE_ESB_INVALID    0xFF
0051 
0052 /*
0053  * Thread Management (aka "TM") registers
0054  */
0055 
0056 /* TM register offsets */
0057 #define TM_QW0_USER     0x000 /* All rings */
0058 #define TM_QW1_OS       0x010 /* Ring 0..2 */
0059 #define TM_QW2_HV_POOL      0x020 /* Ring 0..1 */
0060 #define TM_QW3_HV_PHYS      0x030 /* Ring 0..1 */
0061 
0062 /* Byte offsets inside a QW             QW0 QW1 QW2 QW3 */
0063 #define TM_NSR          0x0  /*  +   +   -   +  */
0064 #define TM_CPPR         0x1  /*  -   +   -   +  */
0065 #define TM_IPB          0x2  /*  -   +   +   +  */
0066 #define TM_LSMFB        0x3  /*  -   +   +   +  */
0067 #define TM_ACK_CNT      0x4  /*  -   +   -   -  */
0068 #define TM_INC          0x5  /*  -   +   -   +  */
0069 #define TM_AGE          0x6  /*  -   +   -   +  */
0070 #define TM_PIPR         0x7  /*  -   +   -   +  */
0071 
0072 #define TM_WORD0        0x0
0073 #define TM_WORD1        0x4
0074 
0075 /*
0076  * QW word 2 contains the valid bit at the top and other fields
0077  * depending on the QW.
0078  */
0079 #define TM_WORD2        0x8
0080 #define   TM_QW0W2_VU       PPC_BIT32(0)
0081 #define   TM_QW0W2_LOGIC_SERV   PPC_BITMASK32(1,31) // XX 2,31 ?
0082 #define   TM_QW1W2_VO       PPC_BIT32(0)
0083 #define   TM_QW1W2_HO           PPC_BIT32(1) /* P10 XIVE2 */
0084 #define   TM_QW1W2_OS_CAM   PPC_BITMASK32(8,31)
0085 #define   TM_QW2W2_VP       PPC_BIT32(0)
0086 #define   TM_QW2W2_HP           PPC_BIT32(1) /* P10 XIVE2 */
0087 #define   TM_QW2W2_POOL_CAM PPC_BITMASK32(8,31)
0088 #define   TM_QW3W2_VT       PPC_BIT32(0)
0089 #define   TM_QW3W2_HT           PPC_BIT32(1) /* P10 XIVE2 */
0090 #define   TM_QW3W2_LP       PPC_BIT32(6)
0091 #define   TM_QW3W2_LE       PPC_BIT32(7)
0092 #define   TM_QW3W2_T        PPC_BIT32(31)
0093 
0094 /*
0095  * In addition to normal loads to "peek" and writes (only when invalid)
0096  * using 4 and 8 bytes accesses, the above registers support these
0097  * "special" byte operations:
0098  *
0099  *   - Byte load from QW0[NSR] - User level NSR (EBB)
0100  *   - Byte store to QW0[NSR] - User level NSR (EBB)
0101  *   - Byte load/store to QW1[CPPR] and QW3[CPPR] - CPPR access
0102  *   - Byte load from QW3[TM_WORD2] - Read VT||00000||LP||LE on thrd 0
0103  *                                    otherwise VT||0000000
0104  *   - Byte store to QW3[TM_WORD2] - Set VT bit (and LP/LE if present)
0105  *
0106  * Then we have all these "special" CI ops at these offset that trigger
0107  * all sorts of side effects:
0108  */
0109 #define TM_SPC_ACK_EBB      0x800   /* Load8 ack EBB to reg*/
0110 #define TM_SPC_ACK_OS_REG   0x810   /* Load16 ack OS irq to reg */
0111 #define TM_SPC_PUSH_USR_CTX 0x808   /* Store32 Push/Validate user context */
0112 #define TM_SPC_PULL_USR_CTX 0x808   /* Load32 Pull/Invalidate user context */
0113 #define TM_SPC_SET_OS_PENDING   0x812   /* Store8 Set OS irq pending bit */
0114 #define TM_SPC_PULL_OS_CTX  0x818   /* Load32/Load64 Pull/Invalidate OS context to reg */
0115 #define TM_SPC_PULL_POOL_CTX    0x828   /* Load32/Load64 Pull/Invalidate Pool context to reg*/
0116 #define TM_SPC_ACK_HV_REG   0x830   /* Load16 ack HV irq to reg */
0117 #define TM_SPC_PULL_USR_CTX_OL  0xc08   /* Store8 Pull/Inval usr ctx to odd line */
0118 #define TM_SPC_ACK_OS_EL    0xc10   /* Store8 ack OS irq to even line */
0119 #define TM_SPC_ACK_HV_POOL_EL   0xc20   /* Store8 ack HV evt pool to even line */
0120 #define TM_SPC_ACK_HV_EL    0xc30   /* Store8 ack HV irq to even line */
0121 /* XXX more... */
0122 
0123 /* NSR fields for the various QW ack types */
0124 #define TM_QW0_NSR_EB       PPC_BIT8(0)
0125 #define TM_QW1_NSR_EO       PPC_BIT8(0)
0126 #define TM_QW3_NSR_HE       PPC_BITMASK8(0,1)
0127 #define  TM_QW3_NSR_HE_NONE 0
0128 #define  TM_QW3_NSR_HE_POOL 1
0129 #define  TM_QW3_NSR_HE_PHYS 2
0130 #define  TM_QW3_NSR_HE_LSI  3
0131 #define TM_QW3_NSR_I        PPC_BIT8(2)
0132 #define TM_QW3_NSR_GRP_LVL  PPC_BIT8(3,7)
0133 
0134 #endif /* _ASM_POWERPC_XIVE_REGS_H */