1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Common interface for I/O on S/390
5 #ifndef _ASM_S390_CIO_H_
6 #define _ASM_S390_CIO_H_
8 #include <linux/spinlock.h>
9 #include <linux/bitops.h>
10 #include <linux/genalloc.h>
11 #include <asm/types.h>
13 #define LPM_ANYPATH 0xff
15 #define __MAX_SUBCHANNEL 65535
21 * struct ccw1 - channel command word
22 * @cmd_code: command code
23 * @flags: flags, like IDA addressing, etc.
27 * The ccw is the basic structure to build channel programs that perform
28 * operations with the device or the control unit. Only Format-1 channel
29 * command words are supported.
36 } __attribute__ ((packed
,aligned(8)));
39 * struct ccw0 - channel command word
40 * @cmd_code: command code
42 * @flags: flags, like IDA addressing, etc.
43 * @reserved: will be ignored
46 * The format-0 ccw structure.
54 } __packed
__aligned(8);
56 #define CCW_FLAG_DC 0x80
57 #define CCW_FLAG_CC 0x40
58 #define CCW_FLAG_SLI 0x20
59 #define CCW_FLAG_SKIP 0x10
60 #define CCW_FLAG_PCI 0x08
61 #define CCW_FLAG_IDA 0x04
62 #define CCW_FLAG_SUSPEND 0x02
64 #define CCW_CMD_READ_IPL 0x02
65 #define CCW_CMD_NOOP 0x03
66 #define CCW_CMD_BASIC_SENSE 0x04
67 #define CCW_CMD_TIC 0x08
68 #define CCW_CMD_STLCK 0x14
69 #define CCW_CMD_SENSE_PGID 0x34
70 #define CCW_CMD_SUSPEND_RECONN 0x5B
71 #define CCW_CMD_RDC 0x64
72 #define CCW_CMD_RELEASE 0x94
73 #define CCW_CMD_SET_PGID 0xAF
74 #define CCW_CMD_SENSE_ID 0xE4
75 #define CCW_CMD_DCTL 0xF3
77 #define SENSE_MAX_COUNT 0x20
80 * struct erw - extended report word
82 * @auth: authorization check
83 * @pvrf: path-verification-required flag
84 * @cpt: channel-path timeout
85 * @fsavf: failing storage address validity flag
86 * @cons: concurrent sense
87 * @scavf: secondary ccw address validity flag
88 * @fsaf: failing storage address format
89 * @scnt: sense count, if @cons == %1
103 } __attribute__ ((packed
));
106 * struct erw_eadm - EADM Subchannel extended report word
118 * struct sublog - subchannel logout area
120 * @esf: extended status flags
121 * @lpum: last path used mask
122 * @arep: ancillary report
123 * @fvf: field-validity flags
124 * @sacc: storage access code
125 * @termc: termination code
126 * @devsc: device-status check
127 * @serr: secondary error
128 * @ioerr: i/o-error alert
129 * @seqc: sequence code
143 } __attribute__ ((packed
));
146 * struct esw0 - Format 0 Extended Status Word (ESW)
147 * @sublog: subchannel logout
148 * @erw: extended report word
149 * @faddr: failing storage address
150 * @saddr: secondary ccw address
153 struct sublog sublog
;
157 } __attribute__ ((packed
));
160 * struct esw1 - Format 1 Extended Status Word (ESW)
161 * @zero0: reserved zeros
162 * @lpum: last path used mask
163 * @zero16: reserved zeros
164 * @erw: extended report word
165 * @zeros: three fullwords of zeros
173 } __attribute__ ((packed
));
176 * struct esw2 - Format 2 Extended Status Word (ESW)
177 * @zero0: reserved zeros
178 * @lpum: last path used mask
179 * @dcti: device-connect-time interval
180 * @erw: extended report word
181 * @zeros: three fullwords of zeros
189 } __attribute__ ((packed
));
192 * struct esw3 - Format 3 Extended Status Word (ESW)
193 * @zero0: reserved zeros
194 * @lpum: last path used mask
196 * @erw: extended report word
197 * @zeros: three fullwords of zeros
205 } __attribute__ ((packed
));
208 * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
209 * @sublog: subchannel logout
210 * @erw: extended report word
221 * struct irb - interruption response block
222 * @scsw: subchannel status word
223 * @esw: extended status word
224 * @ecw: extended control word
226 * The irb that is handed to the device driver when an interrupt occurs. For
227 * solicited interrupts, the common I/O layer already performs checks whether
228 * a field is valid; a field not being valid is always passed as %0.
229 * If a unit check occurred, @ecw may contain sense data; this is retrieved
230 * by the common I/O layer itself if the device doesn't support concurrent
231 * sense (so that the device driver never needs to perform basic sense itself).
232 * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
242 struct esw_eadm eadm
;
245 } __attribute__ ((packed
,aligned(4)));
248 * struct ciw - command information word (CIW) layout
250 * @reserved: reserved bits
253 * @count: command count
261 } __attribute__ ((packed
));
263 #define CIW_TYPE_RCD 0x0 /* read configuration data */
264 #define CIW_TYPE_SII 0x1 /* set interface identifier */
265 #define CIW_TYPE_RNI 0x2 /* read node identifier */
268 * Node Descriptor as defined in SA22-7204, "Common I/O-Device Commands"
271 #define ND_VALIDITY_VALID 0
272 #define ND_VALIDITY_OUTDATED 1
273 #define ND_VALIDITY_INVALID 2
275 struct node_descriptor
{
285 /* Node parameters. */
291 char manufacturer
[3];
298 * Flags used as input parameters for do_IO()
300 #define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
301 #define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
302 #define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
303 /* ... for suspended CCWs */
304 /* Device or subchannel gone. */
305 #define CIO_GONE 0x0001
306 /* No path to device. */
307 #define CIO_NO_PATH 0x0002
308 /* Device has appeared. */
309 #define CIO_OPER 0x0004
310 /* Sick revalidation of device. */
311 #define CIO_REVALIDATE 0x0008
312 /* Device did not respond in time. */
313 #define CIO_BOXED 0x0010
316 * struct ccw_dev_id - unique identifier for ccw devices
317 * @ssid: subchannel set id
318 * @devno: device number
320 * This structure is not directly based on any hardware structure. The
321 * hardware identifies a device by its device number and its subchannel,
322 * which is in turn identified by its id. In order to get a unique identifier
323 * for ccw devices across subchannel sets, @struct ccw_dev_id has been
332 * ccw_device_id_is_equal() - compare two ccw_dev_ids
333 * @dev_id1: a ccw_dev_id
334 * @dev_id2: another ccw_dev_id
336 * %1 if the two structures are equal field-by-field,
341 static inline int ccw_dev_id_is_equal(struct ccw_dev_id
*dev_id1
,
342 struct ccw_dev_id
*dev_id2
)
344 if ((dev_id1
->ssid
== dev_id2
->ssid
) &&
345 (dev_id1
->devno
== dev_id2
->devno
))
351 * pathmask_to_pos() - find the position of the left-most bit in a pathmask
352 * @mask: pathmask with at least one bit set
354 static inline u8
pathmask_to_pos(u8 mask
)
356 return 8 - ffs(mask
);
359 void channel_subsystem_reinit(void);
360 extern void css_schedule_reprobe(void);
362 extern void *cio_dma_zalloc(size_t size
);
363 extern void cio_dma_free(void *cpu_addr
, size_t size
);
364 extern struct device
*cio_get_dma_css_dev(void);
366 void *cio_gp_dma_zalloc(struct gen_pool
*gp_dma
, struct device
*dma_dev
,
368 void cio_gp_dma_free(struct gen_pool
*gp_dma
, void *cpu_addr
, size_t size
);
369 void cio_gp_dma_destroy(struct gen_pool
*gp_dma
, struct device
*dma_dev
);
370 struct gen_pool
*cio_gp_dma_create(struct device
*dma_dev
, int nr_pages
);
372 /* Function from drivers/s390/cio/chsc.c */
373 int chsc_sstpc(void *page
, unsigned int op
, u16 ctrl
, u64
*clock_delta
);
374 int chsc_sstpi(void *page
, void *result
, size_t size
);
375 int chsc_sgib(u32 origin
);