18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2016,2017 IBM Corporation. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_XIVE_REGS_H 68c2ecf20Sopenharmony_ci#define _ASM_POWERPC_XIVE_REGS_H 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* 98c2ecf20Sopenharmony_ci * "magic" Event State Buffer (ESB) MMIO offsets. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * Each interrupt source has a 2-bit state machine called ESB 128c2ecf20Sopenharmony_ci * which can be controlled by MMIO. It's made of 2 bits, P and 138c2ecf20Sopenharmony_ci * Q. P indicates that an interrupt is pending (has been sent 148c2ecf20Sopenharmony_ci * to a queue and is waiting for an EOI). Q indicates that the 158c2ecf20Sopenharmony_ci * interrupt has been triggered while pending. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * This acts as a coalescing mechanism in order to guarantee 188c2ecf20Sopenharmony_ci * that a given interrupt only occurs at most once in a queue. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * When doing an EOI, the Q bit will indicate if the interrupt 218c2ecf20Sopenharmony_ci * needs to be re-triggered. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * The following offsets into the ESB MMIO allow to read or 248c2ecf20Sopenharmony_ci * manipulate the PQ bits. They must be used with an 8-bytes 258c2ecf20Sopenharmony_ci * load instruction. They all return the previous state of the 268c2ecf20Sopenharmony_ci * interrupt (atomically). 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * Additionally, some ESB pages support doing an EOI via a 298c2ecf20Sopenharmony_ci * store at 0 and some ESBs support doing a trigger via a 308c2ecf20Sopenharmony_ci * separate trigger page. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci#define XIVE_ESB_STORE_EOI 0x400 /* Store */ 338c2ecf20Sopenharmony_ci#define XIVE_ESB_LOAD_EOI 0x000 /* Load */ 348c2ecf20Sopenharmony_ci#define XIVE_ESB_GET 0x800 /* Load */ 358c2ecf20Sopenharmony_ci#define XIVE_ESB_SET_PQ_00 0xc00 /* Load */ 368c2ecf20Sopenharmony_ci#define XIVE_ESB_SET_PQ_01 0xd00 /* Load */ 378c2ecf20Sopenharmony_ci#define XIVE_ESB_SET_PQ_10 0xe00 /* Load */ 388c2ecf20Sopenharmony_ci#define XIVE_ESB_SET_PQ_11 0xf00 /* Load */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* 418c2ecf20Sopenharmony_ci * Load-after-store ordering 428c2ecf20Sopenharmony_ci * 438c2ecf20Sopenharmony_ci * Adding this offset to the load address will enforce 448c2ecf20Sopenharmony_ci * load-after-store ordering. This is required to use StoreEOI. 458c2ecf20Sopenharmony_ci */ 468c2ecf20Sopenharmony_ci#define XIVE_ESB_LD_ST_MO 0x40 /* Load-after-store ordering */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define XIVE_ESB_VAL_P 0x2 498c2ecf20Sopenharmony_ci#define XIVE_ESB_VAL_Q 0x1 508c2ecf20Sopenharmony_ci#define XIVE_ESB_INVALID 0xFF 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * Thread Management (aka "TM") registers 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* TM register offsets */ 578c2ecf20Sopenharmony_ci#define TM_QW0_USER 0x000 /* All rings */ 588c2ecf20Sopenharmony_ci#define TM_QW1_OS 0x010 /* Ring 0..2 */ 598c2ecf20Sopenharmony_ci#define TM_QW2_HV_POOL 0x020 /* Ring 0..1 */ 608c2ecf20Sopenharmony_ci#define TM_QW3_HV_PHYS 0x030 /* Ring 0..1 */ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* Byte offsets inside a QW QW0 QW1 QW2 QW3 */ 638c2ecf20Sopenharmony_ci#define TM_NSR 0x0 /* + + - + */ 648c2ecf20Sopenharmony_ci#define TM_CPPR 0x1 /* - + - + */ 658c2ecf20Sopenharmony_ci#define TM_IPB 0x2 /* - + + + */ 668c2ecf20Sopenharmony_ci#define TM_LSMFB 0x3 /* - + + + */ 678c2ecf20Sopenharmony_ci#define TM_ACK_CNT 0x4 /* - + - - */ 688c2ecf20Sopenharmony_ci#define TM_INC 0x5 /* - + - + */ 698c2ecf20Sopenharmony_ci#define TM_AGE 0x6 /* - + - + */ 708c2ecf20Sopenharmony_ci#define TM_PIPR 0x7 /* - + - + */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define TM_WORD0 0x0 738c2ecf20Sopenharmony_ci#define TM_WORD1 0x4 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * QW word 2 contains the valid bit at the top and other fields 778c2ecf20Sopenharmony_ci * depending on the QW. 788c2ecf20Sopenharmony_ci */ 798c2ecf20Sopenharmony_ci#define TM_WORD2 0x8 808c2ecf20Sopenharmony_ci#define TM_QW0W2_VU PPC_BIT32(0) 818c2ecf20Sopenharmony_ci#define TM_QW0W2_LOGIC_SERV PPC_BITMASK32(1,31) // XX 2,31 ? 828c2ecf20Sopenharmony_ci#define TM_QW1W2_VO PPC_BIT32(0) 838c2ecf20Sopenharmony_ci#define TM_QW1W2_OS_CAM PPC_BITMASK32(8,31) 848c2ecf20Sopenharmony_ci#define TM_QW2W2_VP PPC_BIT32(0) 858c2ecf20Sopenharmony_ci#define TM_QW2W2_POOL_CAM PPC_BITMASK32(8,31) 868c2ecf20Sopenharmony_ci#define TM_QW3W2_VT PPC_BIT32(0) 878c2ecf20Sopenharmony_ci#define TM_QW3W2_LP PPC_BIT32(6) 888c2ecf20Sopenharmony_ci#define TM_QW3W2_LE PPC_BIT32(7) 898c2ecf20Sopenharmony_ci#define TM_QW3W2_T PPC_BIT32(31) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* 928c2ecf20Sopenharmony_ci * In addition to normal loads to "peek" and writes (only when invalid) 938c2ecf20Sopenharmony_ci * using 4 and 8 bytes accesses, the above registers support these 948c2ecf20Sopenharmony_ci * "special" byte operations: 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * - Byte load from QW0[NSR] - User level NSR (EBB) 978c2ecf20Sopenharmony_ci * - Byte store to QW0[NSR] - User level NSR (EBB) 988c2ecf20Sopenharmony_ci * - Byte load/store to QW1[CPPR] and QW3[CPPR] - CPPR access 998c2ecf20Sopenharmony_ci * - Byte load from QW3[TM_WORD2] - Read VT||00000||LP||LE on thrd 0 1008c2ecf20Sopenharmony_ci * otherwise VT||0000000 1018c2ecf20Sopenharmony_ci * - Byte store to QW3[TM_WORD2] - Set VT bit (and LP/LE if present) 1028c2ecf20Sopenharmony_ci * 1038c2ecf20Sopenharmony_ci * Then we have all these "special" CI ops at these offset that trigger 1048c2ecf20Sopenharmony_ci * all sorts of side effects: 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_ci#define TM_SPC_ACK_EBB 0x800 /* Load8 ack EBB to reg*/ 1078c2ecf20Sopenharmony_ci#define TM_SPC_ACK_OS_REG 0x810 /* Load16 ack OS irq to reg */ 1088c2ecf20Sopenharmony_ci#define TM_SPC_PUSH_USR_CTX 0x808 /* Store32 Push/Validate user context */ 1098c2ecf20Sopenharmony_ci#define TM_SPC_PULL_USR_CTX 0x808 /* Load32 Pull/Invalidate user context */ 1108c2ecf20Sopenharmony_ci#define TM_SPC_SET_OS_PENDING 0x812 /* Store8 Set OS irq pending bit */ 1118c2ecf20Sopenharmony_ci#define TM_SPC_PULL_OS_CTX 0x818 /* Load32/Load64 Pull/Invalidate OS context to reg */ 1128c2ecf20Sopenharmony_ci#define TM_SPC_PULL_POOL_CTX 0x828 /* Load32/Load64 Pull/Invalidate Pool context to reg*/ 1138c2ecf20Sopenharmony_ci#define TM_SPC_ACK_HV_REG 0x830 /* Load16 ack HV irq to reg */ 1148c2ecf20Sopenharmony_ci#define TM_SPC_PULL_USR_CTX_OL 0xc08 /* Store8 Pull/Inval usr ctx to odd line */ 1158c2ecf20Sopenharmony_ci#define TM_SPC_ACK_OS_EL 0xc10 /* Store8 ack OS irq to even line */ 1168c2ecf20Sopenharmony_ci#define TM_SPC_ACK_HV_POOL_EL 0xc20 /* Store8 ack HV evt pool to even line */ 1178c2ecf20Sopenharmony_ci#define TM_SPC_ACK_HV_EL 0xc30 /* Store8 ack HV irq to even line */ 1188c2ecf20Sopenharmony_ci/* XXX more... */ 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci/* NSR fields for the various QW ack types */ 1218c2ecf20Sopenharmony_ci#define TM_QW0_NSR_EB PPC_BIT8(0) 1228c2ecf20Sopenharmony_ci#define TM_QW1_NSR_EO PPC_BIT8(0) 1238c2ecf20Sopenharmony_ci#define TM_QW3_NSR_HE PPC_BITMASK8(0,1) 1248c2ecf20Sopenharmony_ci#define TM_QW3_NSR_HE_NONE 0 1258c2ecf20Sopenharmony_ci#define TM_QW3_NSR_HE_POOL 1 1268c2ecf20Sopenharmony_ci#define TM_QW3_NSR_HE_PHYS 2 1278c2ecf20Sopenharmony_ci#define TM_QW3_NSR_HE_LSI 3 1288c2ecf20Sopenharmony_ci#define TM_QW3_NSR_I PPC_BIT8(2) 1298c2ecf20Sopenharmony_ci#define TM_QW3_NSR_GRP_LVL PPC_BIT8(3,7) 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_XIVE_REGS_H */ 132