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 571ba41c9SSebastian Ott #include <linux/jump_label.h> 671ba41c9SSebastian 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 101062f0024SMatthew Rosato /* Set Interruption Controls Operation Controls */ 102062f0024SMatthew Rosato #define SIC_IRQ_MODE_ALL 0 103062f0024SMatthew Rosato #define SIC_IRQ_MODE_SINGLE 1 104*98b1d33dSMatthew Rosato #define SIC_SET_AENI_CONTROLS 2 105062f0024SMatthew Rosato #define SIC_IRQ_MODE_DIRECT 4 106062f0024SMatthew Rosato #define SIC_IRQ_MODE_D_ALL 16 107062f0024SMatthew Rosato #define SIC_IRQ_MODE_D_SINGLE 17 108062f0024SMatthew Rosato #define SIC_IRQ_MODE_SET_CPU 18 109062f0024SMatthew Rosato 110e979ce7bSSebastian Ott /* directed interruption information block */ 111e979ce7bSSebastian Ott struct zpci_diib { 112e979ce7bSSebastian Ott u32 : 1; 113e979ce7bSSebastian Ott u32 isc : 3; 114e979ce7bSSebastian Ott u32 : 28; 115e979ce7bSSebastian Ott u16 : 16; 116e979ce7bSSebastian Ott u16 nr_cpus; 117e979ce7bSSebastian Ott u64 disb_addr; 118e979ce7bSSebastian Ott u64 : 64; 119e979ce7bSSebastian Ott u64 : 64; 120e979ce7bSSebastian Ott } __packed __aligned(8); 121e979ce7bSSebastian Ott 122e979ce7bSSebastian Ott /* cpu directed interruption information block */ 123e979ce7bSSebastian Ott struct zpci_cdiib { 124e979ce7bSSebastian Ott u64 : 64; 125e979ce7bSSebastian Ott u64 dibv_addr; 126e979ce7bSSebastian Ott u64 : 64; 127e979ce7bSSebastian Ott u64 : 64; 128e979ce7bSSebastian Ott u64 : 64; 129e979ce7bSSebastian Ott } __packed __aligned(8); 130e979ce7bSSebastian Ott 131*98b1d33dSMatthew Rosato /* adapter interruption parameters block */ 132*98b1d33dSMatthew Rosato struct zpci_aipb { 133*98b1d33dSMatthew Rosato u64 faisb; 134*98b1d33dSMatthew Rosato u64 gait; 135*98b1d33dSMatthew Rosato u16 : 13; 136*98b1d33dSMatthew Rosato u16 afi : 3; 137*98b1d33dSMatthew Rosato u32 : 32; 138*98b1d33dSMatthew Rosato u16 faal; 139*98b1d33dSMatthew Rosato } __packed __aligned(8); 140*98b1d33dSMatthew Rosato 141e979ce7bSSebastian Ott union zpci_sic_iib { 142e979ce7bSSebastian Ott struct zpci_diib diib; 143e979ce7bSSebastian Ott struct zpci_cdiib cdiib; 144*98b1d33dSMatthew Rosato struct zpci_aipb aipb; 145e979ce7bSSebastian Ott }; 146e979ce7bSSebastian Ott 14771ba41c9SSebastian Ott DECLARE_STATIC_KEY_FALSE(have_mio); 14871ba41c9SSebastian Ott 1494dfbd3efSSebastian Ott u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status); 1509389339fSMartin Schwidefsky int zpci_refresh_trans(u64 fn, u64 addr, u64 range); 15181deca12SSebastian Ott int __zpci_load(u64 *data, u64 req, u64 offset); 15281deca12SSebastian Ott int zpci_load(u64 *data, const volatile void __iomem *addr, unsigned long len); 15381deca12SSebastian Ott int __zpci_store(u64 data, u64 req, u64 offset); 15481deca12SSebastian Ott int zpci_store(const volatile void __iomem *addr, u64 data, unsigned long len); 15581deca12SSebastian Ott int __zpci_store_block(const u64 *data, u64 req, u64 offset); 15671ba41c9SSebastian Ott void zpci_barrier(void); 157062f0024SMatthew Rosato int zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib); 158cd248341SJan Glauber 159cd248341SJan Glauber #endif 160