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