1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2cd248341SJan Glauber #ifndef _ASM_S390_PCI_INSN_H 3cd248341SJan Glauber #define _ASM_S390_PCI_INSN_H 4cd248341SJan Glauber 5*71ba41c9SSebastian Ott #include <linux/jump_label.h> 6*71ba41c9SSebastian Ott 7cd248341SJan Glauber /* Load/Store status codes */ 8cd248341SJan Glauber #define ZPCI_PCI_ST_FUNC_NOT_ENABLED 4 9cd248341SJan Glauber #define ZPCI_PCI_ST_FUNC_IN_ERR 8 10cd248341SJan Glauber #define ZPCI_PCI_ST_BLOCKED 12 11cd248341SJan Glauber #define ZPCI_PCI_ST_INSUF_RES 16 12cd248341SJan Glauber #define ZPCI_PCI_ST_INVAL_AS 20 13cd248341SJan Glauber #define ZPCI_PCI_ST_FUNC_ALREADY_ENABLED 24 14cd248341SJan Glauber #define ZPCI_PCI_ST_DMA_AS_NOT_ENABLED 28 15cd248341SJan Glauber #define ZPCI_PCI_ST_2ND_OP_IN_INV_AS 36 16cd248341SJan Glauber #define ZPCI_PCI_ST_FUNC_NOT_AVAIL 40 17cd248341SJan Glauber #define ZPCI_PCI_ST_ALREADY_IN_RQ_STATE 44 18cd248341SJan Glauber 19cd248341SJan Glauber /* Load/Store return codes */ 20cd248341SJan Glauber #define ZPCI_PCI_LS_OK 0 21cd248341SJan Glauber #define ZPCI_PCI_LS_ERR 1 22cd248341SJan Glauber #define ZPCI_PCI_LS_BUSY 2 23cd248341SJan Glauber #define ZPCI_PCI_LS_INVAL_HANDLE 3 24cd248341SJan Glauber 25cd248341SJan Glauber /* Load/Store address space identifiers */ 26cd248341SJan Glauber #define ZPCI_PCIAS_MEMIO_0 0 27cd248341SJan Glauber #define ZPCI_PCIAS_MEMIO_1 1 28cd248341SJan Glauber #define ZPCI_PCIAS_MEMIO_2 2 29cd248341SJan Glauber #define ZPCI_PCIAS_MEMIO_3 3 30cd248341SJan Glauber #define ZPCI_PCIAS_MEMIO_4 4 31cd248341SJan Glauber #define ZPCI_PCIAS_MEMIO_5 5 32cd248341SJan Glauber #define ZPCI_PCIAS_CFGSPC 15 33cd248341SJan Glauber 34cd248341SJan Glauber /* Modify PCI Function Controls */ 35cd248341SJan Glauber #define ZPCI_MOD_FC_REG_INT 2 36cd248341SJan Glauber #define ZPCI_MOD_FC_DEREG_INT 3 37cd248341SJan Glauber #define ZPCI_MOD_FC_REG_IOAT 4 38cd248341SJan Glauber #define ZPCI_MOD_FC_DEREG_IOAT 5 39cd248341SJan Glauber #define ZPCI_MOD_FC_REREG_IOAT 6 40cd248341SJan Glauber #define ZPCI_MOD_FC_RESET_ERROR 7 41cd248341SJan Glauber #define ZPCI_MOD_FC_RESET_BLOCK 9 42cd248341SJan Glauber #define ZPCI_MOD_FC_SET_MEASURE 10 43e979ce7bSSebastian Ott #define ZPCI_MOD_FC_REG_INT_D 16 44e979ce7bSSebastian Ott #define ZPCI_MOD_FC_DEREG_INT_D 17 45cd248341SJan Glauber 46cd248341SJan Glauber /* FIB function controls */ 47cd248341SJan Glauber #define ZPCI_FIB_FC_ENABLED 0x80 48cd248341SJan Glauber #define ZPCI_FIB_FC_ERROR 0x40 49cd248341SJan Glauber #define ZPCI_FIB_FC_LS_BLOCKED 0x20 50cd248341SJan Glauber #define ZPCI_FIB_FC_DMAAS_REG 0x10 51cd248341SJan Glauber 52cd248341SJan Glauber /* FIB function controls */ 53cd248341SJan Glauber #define ZPCI_FIB_FC_ENABLED 0x80 54cd248341SJan Glauber #define ZPCI_FIB_FC_ERROR 0x40 55cd248341SJan Glauber #define ZPCI_FIB_FC_LS_BLOCKED 0x20 56cd248341SJan Glauber #define ZPCI_FIB_FC_DMAAS_REG 0x10 57cd248341SJan Glauber 58e979ce7bSSebastian Ott struct zpci_fib_fmt0 { 59cd248341SJan Glauber u32 : 1; 60cd248341SJan Glauber u32 isc : 3; /* Interrupt subclass */ 61cd248341SJan Glauber u32 noi : 12; /* Number of interrupts */ 62cd248341SJan Glauber u32 : 2; 63cd248341SJan Glauber u32 aibvo : 6; /* Adapter interrupt bit vector offset */ 64cd248341SJan Glauber u32 sum : 1; /* Adapter int summary bit enabled */ 65cd248341SJan Glauber u32 : 1; 66cd248341SJan Glauber u32 aisbo : 6; /* Adapter int summary bit offset */ 67cb4deb69SSebastian Ott u32 : 32; 68cd248341SJan Glauber u64 aibv; /* Adapter int bit vector address */ 69cd248341SJan Glauber u64 aisb; /* Adapter int summary bit address */ 70e979ce7bSSebastian Ott }; 71e979ce7bSSebastian Ott 72e979ce7bSSebastian Ott struct zpci_fib_fmt1 { 73e979ce7bSSebastian Ott u32 : 4; 74e979ce7bSSebastian Ott u32 noi : 12; 75e979ce7bSSebastian Ott u32 : 16; 76e979ce7bSSebastian Ott u32 dibvo : 16; 77e979ce7bSSebastian Ott u32 : 16; 78e979ce7bSSebastian Ott u64 : 64; 79e979ce7bSSebastian Ott u64 : 64; 80e979ce7bSSebastian Ott }; 81e979ce7bSSebastian Ott 82e979ce7bSSebastian Ott /* Function Information Block */ 83e979ce7bSSebastian Ott struct zpci_fib { 84e979ce7bSSebastian Ott u32 fmt : 8; /* format */ 85e979ce7bSSebastian Ott u32 : 24; 86e979ce7bSSebastian Ott u32 : 32; 87e979ce7bSSebastian Ott u8 fc; /* function controls */ 88e979ce7bSSebastian Ott u64 : 56; 89e979ce7bSSebastian Ott u64 pba; /* PCI base address */ 90e979ce7bSSebastian Ott u64 pal; /* PCI address limit */ 91e979ce7bSSebastian Ott u64 iota; /* I/O Translation Anchor */ 92e979ce7bSSebastian Ott union { 93e979ce7bSSebastian Ott struct zpci_fib_fmt0 fmt0; 94e979ce7bSSebastian Ott struct zpci_fib_fmt1 fmt1; 95e979ce7bSSebastian Ott }; 96cd248341SJan Glauber u64 fmb_addr; /* Function measurement block address and key */ 97cb4deb69SSebastian Ott u32 : 32; 98cb4deb69SSebastian Ott u32 gd; 99cb4deb69SSebastian Ott } __packed __aligned(8); 100cd248341SJan Glauber 101e979ce7bSSebastian Ott /* directed interruption information block */ 102e979ce7bSSebastian Ott struct zpci_diib { 103e979ce7bSSebastian Ott u32 : 1; 104e979ce7bSSebastian Ott u32 isc : 3; 105e979ce7bSSebastian Ott u32 : 28; 106e979ce7bSSebastian Ott u16 : 16; 107e979ce7bSSebastian Ott u16 nr_cpus; 108e979ce7bSSebastian Ott u64 disb_addr; 109e979ce7bSSebastian Ott u64 : 64; 110e979ce7bSSebastian Ott u64 : 64; 111e979ce7bSSebastian Ott } __packed __aligned(8); 112e979ce7bSSebastian Ott 113e979ce7bSSebastian Ott /* cpu directed interruption information block */ 114e979ce7bSSebastian Ott struct zpci_cdiib { 115e979ce7bSSebastian Ott u64 : 64; 116e979ce7bSSebastian Ott u64 dibv_addr; 117e979ce7bSSebastian Ott u64 : 64; 118e979ce7bSSebastian Ott u64 : 64; 119e979ce7bSSebastian Ott u64 : 64; 120e979ce7bSSebastian Ott } __packed __aligned(8); 121e979ce7bSSebastian Ott 122e979ce7bSSebastian Ott union zpci_sic_iib { 123e979ce7bSSebastian Ott struct zpci_diib diib; 124e979ce7bSSebastian Ott struct zpci_cdiib cdiib; 125e979ce7bSSebastian Ott }; 126e979ce7bSSebastian Ott 127*71ba41c9SSebastian Ott DECLARE_STATIC_KEY_FALSE(have_mio); 128*71ba41c9SSebastian Ott 1294dfbd3efSSebastian Ott u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status); 1309389339fSMartin Schwidefsky int zpci_refresh_trans(u64 fn, u64 addr, u64 range); 13181deca12SSebastian Ott int __zpci_load(u64 *data, u64 req, u64 offset); 13281deca12SSebastian Ott int zpci_load(u64 *data, const volatile void __iomem *addr, unsigned long len); 13381deca12SSebastian Ott int __zpci_store(u64 data, u64 req, u64 offset); 13481deca12SSebastian Ott int zpci_store(const volatile void __iomem *addr, u64 data, unsigned long len); 13581deca12SSebastian Ott int __zpci_store_block(const u64 *data, u64 req, u64 offset); 136*71ba41c9SSebastian Ott void zpci_barrier(void); 137e979ce7bSSebastian Ott int __zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib); 138e979ce7bSSebastian Ott 139e979ce7bSSebastian Ott static inline int zpci_set_irq_ctrl(u16 ctl, u8 isc) 140e979ce7bSSebastian Ott { 141e979ce7bSSebastian Ott union zpci_sic_iib iib = {{0}}; 142e979ce7bSSebastian Ott 143e979ce7bSSebastian Ott return __zpci_set_irq_ctrl(ctl, isc, &iib); 144e979ce7bSSebastian Ott } 145cd248341SJan Glauber 146cd248341SJan Glauber #endif 147