162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2016,2017 IBM Corporation. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci#ifndef _ASM_POWERPC_XIVE_REGS_H 662306a36Sopenharmony_ci#define _ASM_POWERPC_XIVE_REGS_H 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci/* 962306a36Sopenharmony_ci * "magic" Event State Buffer (ESB) MMIO offsets. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * Each interrupt source has a 2-bit state machine called ESB 1262306a36Sopenharmony_ci * which can be controlled by MMIO. It's made of 2 bits, P and 1362306a36Sopenharmony_ci * Q. P indicates that an interrupt is pending (has been sent 1462306a36Sopenharmony_ci * to a queue and is waiting for an EOI). Q indicates that the 1562306a36Sopenharmony_ci * interrupt has been triggered while pending. 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci * This acts as a coalescing mechanism in order to guarantee 1862306a36Sopenharmony_ci * that a given interrupt only occurs at most once in a queue. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * When doing an EOI, the Q bit will indicate if the interrupt 2162306a36Sopenharmony_ci * needs to be re-triggered. 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * The following offsets into the ESB MMIO allow to read or 2462306a36Sopenharmony_ci * manipulate the PQ bits. They must be used with an 8-bytes 2562306a36Sopenharmony_ci * load instruction. They all return the previous state of the 2662306a36Sopenharmony_ci * interrupt (atomically). 2762306a36Sopenharmony_ci * 2862306a36Sopenharmony_ci * Additionally, some ESB pages support doing an EOI via a 2962306a36Sopenharmony_ci * store at 0 and some ESBs support doing a trigger via a 3062306a36Sopenharmony_ci * separate trigger page. 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_ci#define XIVE_ESB_STORE_EOI 0x400 /* Store */ 3362306a36Sopenharmony_ci#define XIVE_ESB_LOAD_EOI 0x000 /* Load */ 3462306a36Sopenharmony_ci#define XIVE_ESB_GET 0x800 /* Load */ 3562306a36Sopenharmony_ci#define XIVE_ESB_SET_PQ_00 0xc00 /* Load */ 3662306a36Sopenharmony_ci#define XIVE_ESB_SET_PQ_01 0xd00 /* Load */ 3762306a36Sopenharmony_ci#define XIVE_ESB_SET_PQ_10 0xe00 /* Load */ 3862306a36Sopenharmony_ci#define XIVE_ESB_SET_PQ_11 0xf00 /* Load */ 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* 4162306a36Sopenharmony_ci * Load-after-store ordering 4262306a36Sopenharmony_ci * 4362306a36Sopenharmony_ci * Adding this offset to the load address will enforce 4462306a36Sopenharmony_ci * load-after-store ordering. This is required to use StoreEOI. 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci#define XIVE_ESB_LD_ST_MO 0x40 /* Load-after-store ordering */ 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define XIVE_ESB_VAL_P 0x2 4962306a36Sopenharmony_ci#define XIVE_ESB_VAL_Q 0x1 5062306a36Sopenharmony_ci#define XIVE_ESB_INVALID 0xFF 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci/* 5362306a36Sopenharmony_ci * Thread Management (aka "TM") registers 5462306a36Sopenharmony_ci */ 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* TM register offsets */ 5762306a36Sopenharmony_ci#define TM_QW0_USER 0x000 /* All rings */ 5862306a36Sopenharmony_ci#define TM_QW1_OS 0x010 /* Ring 0..2 */ 5962306a36Sopenharmony_ci#define TM_QW2_HV_POOL 0x020 /* Ring 0..1 */ 6062306a36Sopenharmony_ci#define TM_QW3_HV_PHYS 0x030 /* Ring 0..1 */ 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* Byte offsets inside a QW QW0 QW1 QW2 QW3 */ 6362306a36Sopenharmony_ci#define TM_NSR 0x0 /* + + - + */ 6462306a36Sopenharmony_ci#define TM_CPPR 0x1 /* - + - + */ 6562306a36Sopenharmony_ci#define TM_IPB 0x2 /* - + + + */ 6662306a36Sopenharmony_ci#define TM_LSMFB 0x3 /* - + + + */ 6762306a36Sopenharmony_ci#define TM_ACK_CNT 0x4 /* - + - - */ 6862306a36Sopenharmony_ci#define TM_INC 0x5 /* - + - + */ 6962306a36Sopenharmony_ci#define TM_AGE 0x6 /* - + - + */ 7062306a36Sopenharmony_ci#define TM_PIPR 0x7 /* - + - + */ 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#define TM_WORD0 0x0 7362306a36Sopenharmony_ci#define TM_WORD1 0x4 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* 7662306a36Sopenharmony_ci * QW word 2 contains the valid bit at the top and other fields 7762306a36Sopenharmony_ci * depending on the QW. 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci#define TM_WORD2 0x8 8062306a36Sopenharmony_ci#define TM_QW0W2_VU PPC_BIT32(0) 8162306a36Sopenharmony_ci#define TM_QW0W2_LOGIC_SERV PPC_BITMASK32(1,31) // XX 2,31 ? 8262306a36Sopenharmony_ci#define TM_QW1W2_VO PPC_BIT32(0) 8362306a36Sopenharmony_ci#define TM_QW1W2_HO PPC_BIT32(1) /* P10 XIVE2 */ 8462306a36Sopenharmony_ci#define TM_QW1W2_OS_CAM PPC_BITMASK32(8,31) 8562306a36Sopenharmony_ci#define TM_QW2W2_VP PPC_BIT32(0) 8662306a36Sopenharmony_ci#define TM_QW2W2_HP PPC_BIT32(1) /* P10 XIVE2 */ 8762306a36Sopenharmony_ci#define TM_QW2W2_POOL_CAM PPC_BITMASK32(8,31) 8862306a36Sopenharmony_ci#define TM_QW3W2_VT PPC_BIT32(0) 8962306a36Sopenharmony_ci#define TM_QW3W2_HT PPC_BIT32(1) /* P10 XIVE2 */ 9062306a36Sopenharmony_ci#define TM_QW3W2_LP PPC_BIT32(6) 9162306a36Sopenharmony_ci#define TM_QW3W2_LE PPC_BIT32(7) 9262306a36Sopenharmony_ci#define TM_QW3W2_T PPC_BIT32(31) 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci/* 9562306a36Sopenharmony_ci * In addition to normal loads to "peek" and writes (only when invalid) 9662306a36Sopenharmony_ci * using 4 and 8 bytes accesses, the above registers support these 9762306a36Sopenharmony_ci * "special" byte operations: 9862306a36Sopenharmony_ci * 9962306a36Sopenharmony_ci * - Byte load from QW0[NSR] - User level NSR (EBB) 10062306a36Sopenharmony_ci * - Byte store to QW0[NSR] - User level NSR (EBB) 10162306a36Sopenharmony_ci * - Byte load/store to QW1[CPPR] and QW3[CPPR] - CPPR access 10262306a36Sopenharmony_ci * - Byte load from QW3[TM_WORD2] - Read VT||00000||LP||LE on thrd 0 10362306a36Sopenharmony_ci * otherwise VT||0000000 10462306a36Sopenharmony_ci * - Byte store to QW3[TM_WORD2] - Set VT bit (and LP/LE if present) 10562306a36Sopenharmony_ci * 10662306a36Sopenharmony_ci * Then we have all these "special" CI ops at these offset that trigger 10762306a36Sopenharmony_ci * all sorts of side effects: 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_ci#define TM_SPC_ACK_EBB 0x800 /* Load8 ack EBB to reg*/ 11062306a36Sopenharmony_ci#define TM_SPC_ACK_OS_REG 0x810 /* Load16 ack OS irq to reg */ 11162306a36Sopenharmony_ci#define TM_SPC_PUSH_USR_CTX 0x808 /* Store32 Push/Validate user context */ 11262306a36Sopenharmony_ci#define TM_SPC_PULL_USR_CTX 0x808 /* Load32 Pull/Invalidate user context */ 11362306a36Sopenharmony_ci#define TM_SPC_SET_OS_PENDING 0x812 /* Store8 Set OS irq pending bit */ 11462306a36Sopenharmony_ci#define TM_SPC_PULL_OS_CTX 0x818 /* Load32/Load64 Pull/Invalidate OS context to reg */ 11562306a36Sopenharmony_ci#define TM_SPC_PULL_POOL_CTX 0x828 /* Load32/Load64 Pull/Invalidate Pool context to reg*/ 11662306a36Sopenharmony_ci#define TM_SPC_ACK_HV_REG 0x830 /* Load16 ack HV irq to reg */ 11762306a36Sopenharmony_ci#define TM_SPC_PULL_USR_CTX_OL 0xc08 /* Store8 Pull/Inval usr ctx to odd line */ 11862306a36Sopenharmony_ci#define TM_SPC_ACK_OS_EL 0xc10 /* Store8 ack OS irq to even line */ 11962306a36Sopenharmony_ci#define TM_SPC_ACK_HV_POOL_EL 0xc20 /* Store8 ack HV evt pool to even line */ 12062306a36Sopenharmony_ci#define TM_SPC_ACK_HV_EL 0xc30 /* Store8 ack HV irq to even line */ 12162306a36Sopenharmony_ci/* XXX more... */ 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci/* NSR fields for the various QW ack types */ 12462306a36Sopenharmony_ci#define TM_QW0_NSR_EB PPC_BIT8(0) 12562306a36Sopenharmony_ci#define TM_QW1_NSR_EO PPC_BIT8(0) 12662306a36Sopenharmony_ci#define TM_QW3_NSR_HE PPC_BITMASK8(0,1) 12762306a36Sopenharmony_ci#define TM_QW3_NSR_HE_NONE 0 12862306a36Sopenharmony_ci#define TM_QW3_NSR_HE_POOL 1 12962306a36Sopenharmony_ci#define TM_QW3_NSR_HE_PHYS 2 13062306a36Sopenharmony_ci#define TM_QW3_NSR_HE_LSI 3 13162306a36Sopenharmony_ci#define TM_QW3_NSR_I PPC_BIT8(2) 13262306a36Sopenharmony_ci#define TM_QW3_NSR_GRP_LVL PPC_BIT8(3,7) 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci#endif /* _ASM_POWERPC_XIVE_REGS_H */ 135