2 * include/asm-s390/cio.h
3 * include/asm-s390x/cio.h
5 * Common interface for I/O on S/390
7 #ifndef _ASM_S390_CIO_H_
8 #define _ASM_S390_CIO_H_
10 #include <linux/spinlock.h>
11 #include <asm/types.h>
15 #define LPM_ANYPATH 0xff
19 * struct cmd_scsw - command-mode subchannel status word
20 * @key: subchannel key
21 * @sctl: suspend control
23 * @cc: deferred condition code
26 * @isic: initial-status interruption control
27 * @alcc: address-limit checking control
28 * @ssi: suppress-suspended interruption
29 * @zcc: zero condition code
30 * @ectl: extended control
31 * @pno: path not operational
33 * @fctl: function control
34 * @actl: activity control
35 * @stctl: status control
36 * @cpa: channel program address
37 * @dstat: device status
38 * @cstat: subchannel status
39 * @count: residual count
62 } __attribute__ ((packed
));
65 * struct tm_scsw - transport-mode subchannel status word
66 * @key: subchannel key
68 * @cc: deferred condition code
70 * @x: IRB-format control
71 * @q: interrogate-complete
72 * @ectl: extended control
73 * @pno: path not operational
74 * @fctl: function control
75 * @actl: activity control
76 * @stctl: status control
78 * @dstat: device status
79 * @cstat: subchannel status
81 * @schxs: subchannel-extended status
103 } __attribute__ ((packed
));
106 * union scsw - subchannel status word
107 * @cmd: command-mode SCSW
108 * @tm: transport-mode SCSW
113 } __attribute__ ((packed
));
115 int scsw_is_tm(union scsw
*scsw
);
116 u32
scsw_key(union scsw
*scsw
);
117 u32
scsw_eswf(union scsw
*scsw
);
118 u32
scsw_cc(union scsw
*scsw
);
119 u32
scsw_ectl(union scsw
*scsw
);
120 u32
scsw_pno(union scsw
*scsw
);
121 u32
scsw_fctl(union scsw
*scsw
);
122 u32
scsw_actl(union scsw
*scsw
);
123 u32
scsw_stctl(union scsw
*scsw
);
124 u32
scsw_dstat(union scsw
*scsw
);
125 u32
scsw_cstat(union scsw
*scsw
);
126 int scsw_is_solicited(union scsw
*scsw
);
127 int scsw_is_valid_key(union scsw
*scsw
);
128 int scsw_is_valid_eswf(union scsw
*scsw
);
129 int scsw_is_valid_cc(union scsw
*scsw
);
130 int scsw_is_valid_ectl(union scsw
*scsw
);
131 int scsw_is_valid_pno(union scsw
*scsw
);
132 int scsw_is_valid_fctl(union scsw
*scsw
);
133 int scsw_is_valid_actl(union scsw
*scsw
);
134 int scsw_is_valid_stctl(union scsw
*scsw
);
135 int scsw_is_valid_dstat(union scsw
*scsw
);
136 int scsw_is_valid_cstat(union scsw
*scsw
);
137 int scsw_cmd_is_valid_key(union scsw
*scsw
);
138 int scsw_cmd_is_valid_sctl(union scsw
*scsw
);
139 int scsw_cmd_is_valid_eswf(union scsw
*scsw
);
140 int scsw_cmd_is_valid_cc(union scsw
*scsw
);
141 int scsw_cmd_is_valid_fmt(union scsw
*scsw
);
142 int scsw_cmd_is_valid_pfch(union scsw
*scsw
);
143 int scsw_cmd_is_valid_isic(union scsw
*scsw
);
144 int scsw_cmd_is_valid_alcc(union scsw
*scsw
);
145 int scsw_cmd_is_valid_ssi(union scsw
*scsw
);
146 int scsw_cmd_is_valid_zcc(union scsw
*scsw
);
147 int scsw_cmd_is_valid_ectl(union scsw
*scsw
);
148 int scsw_cmd_is_valid_pno(union scsw
*scsw
);
149 int scsw_cmd_is_valid_fctl(union scsw
*scsw
);
150 int scsw_cmd_is_valid_actl(union scsw
*scsw
);
151 int scsw_cmd_is_valid_stctl(union scsw
*scsw
);
152 int scsw_cmd_is_valid_dstat(union scsw
*scsw
);
153 int scsw_cmd_is_valid_cstat(union scsw
*scsw
);
154 int scsw_cmd_is_solicited(union scsw
*scsw
);
155 int scsw_tm_is_valid_key(union scsw
*scsw
);
156 int scsw_tm_is_valid_eswf(union scsw
*scsw
);
157 int scsw_tm_is_valid_cc(union scsw
*scsw
);
158 int scsw_tm_is_valid_fmt(union scsw
*scsw
);
159 int scsw_tm_is_valid_x(union scsw
*scsw
);
160 int scsw_tm_is_valid_q(union scsw
*scsw
);
161 int scsw_tm_is_valid_ectl(union scsw
*scsw
);
162 int scsw_tm_is_valid_pno(union scsw
*scsw
);
163 int scsw_tm_is_valid_fctl(union scsw
*scsw
);
164 int scsw_tm_is_valid_actl(union scsw
*scsw
);
165 int scsw_tm_is_valid_stctl(union scsw
*scsw
);
166 int scsw_tm_is_valid_dstat(union scsw
*scsw
);
167 int scsw_tm_is_valid_cstat(union scsw
*scsw
);
168 int scsw_tm_is_valid_fcxs(union scsw
*scsw
);
169 int scsw_tm_is_valid_schxs(union scsw
*scsw
);
170 int scsw_tm_is_solicited(union scsw
*scsw
);
172 #define SCSW_FCTL_CLEAR_FUNC 0x1
173 #define SCSW_FCTL_HALT_FUNC 0x2
174 #define SCSW_FCTL_START_FUNC 0x4
176 #define SCSW_ACTL_SUSPENDED 0x1
177 #define SCSW_ACTL_DEVACT 0x2
178 #define SCSW_ACTL_SCHACT 0x4
179 #define SCSW_ACTL_CLEAR_PEND 0x8
180 #define SCSW_ACTL_HALT_PEND 0x10
181 #define SCSW_ACTL_START_PEND 0x20
182 #define SCSW_ACTL_RESUME_PEND 0x40
184 #define SCSW_STCTL_STATUS_PEND 0x1
185 #define SCSW_STCTL_SEC_STATUS 0x2
186 #define SCSW_STCTL_PRIM_STATUS 0x4
187 #define SCSW_STCTL_INTER_STATUS 0x8
188 #define SCSW_STCTL_ALERT_STATUS 0x10
190 #define DEV_STAT_ATTENTION 0x80
191 #define DEV_STAT_STAT_MOD 0x40
192 #define DEV_STAT_CU_END 0x20
193 #define DEV_STAT_BUSY 0x10
194 #define DEV_STAT_CHN_END 0x08
195 #define DEV_STAT_DEV_END 0x04
196 #define DEV_STAT_UNIT_CHECK 0x02
197 #define DEV_STAT_UNIT_EXCEP 0x01
199 #define SCHN_STAT_PCI 0x80
200 #define SCHN_STAT_INCORR_LEN 0x40
201 #define SCHN_STAT_PROG_CHECK 0x20
202 #define SCHN_STAT_PROT_CHECK 0x10
203 #define SCHN_STAT_CHN_DATA_CHK 0x08
204 #define SCHN_STAT_CHN_CTRL_CHK 0x04
205 #define SCHN_STAT_INTF_CTRL_CHK 0x02
206 #define SCHN_STAT_CHAIN_CHECK 0x01
209 * architectured values for first sense byte
211 #define SNS0_CMD_REJECT 0x80
212 #define SNS_CMD_REJECT SNS0_CMD_REJEC
213 #define SNS0_INTERVENTION_REQ 0x40
214 #define SNS0_BUS_OUT_CHECK 0x20
215 #define SNS0_EQUIPMENT_CHECK 0x10
216 #define SNS0_DATA_CHECK 0x08
217 #define SNS0_OVERRUN 0x04
218 #define SNS0_INCOMPL_DOMAIN 0x01
221 * architectured values for second sense byte
223 #define SNS1_PERM_ERR 0x80
224 #define SNS1_INV_TRACK_FORMAT 0x40
225 #define SNS1_EOC 0x20
226 #define SNS1_MESSAGE_TO_OPER 0x10
227 #define SNS1_NO_REC_FOUND 0x08
228 #define SNS1_FILE_PROTECTED 0x04
229 #define SNS1_WRITE_INHIBITED 0x02
230 #define SNS1_INPRECISE_END 0x01
233 * architectured values for third sense byte
235 #define SNS2_REQ_INH_WRITE 0x80
236 #define SNS2_CORRECTABLE 0x40
237 #define SNS2_FIRST_LOG_ERR 0x20
238 #define SNS2_ENV_DATA_PRESENT 0x10
239 #define SNS2_INPRECISE_END 0x04
242 * struct ccw1 - channel command word
243 * @cmd_code: command code
244 * @flags: flags, like IDA adressing, etc.
248 * The ccw is the basic structure to build channel programs that perform
249 * operations with the device or the control unit. Only Format-1 channel
250 * command words are supported.
257 } __attribute__ ((packed
,aligned(8)));
259 #define CCW_FLAG_DC 0x80
260 #define CCW_FLAG_CC 0x40
261 #define CCW_FLAG_SLI 0x20
262 #define CCW_FLAG_SKIP 0x10
263 #define CCW_FLAG_PCI 0x08
264 #define CCW_FLAG_IDA 0x04
265 #define CCW_FLAG_SUSPEND 0x02
267 #define CCW_CMD_READ_IPL 0x02
268 #define CCW_CMD_NOOP 0x03
269 #define CCW_CMD_BASIC_SENSE 0x04
270 #define CCW_CMD_TIC 0x08
271 #define CCW_CMD_STLCK 0x14
272 #define CCW_CMD_SENSE_PGID 0x34
273 #define CCW_CMD_SUSPEND_RECONN 0x5B
274 #define CCW_CMD_RDC 0x64
275 #define CCW_CMD_RELEASE 0x94
276 #define CCW_CMD_SET_PGID 0xAF
277 #define CCW_CMD_SENSE_ID 0xE4
278 #define CCW_CMD_DCTL 0xF3
280 #define SENSE_MAX_COUNT 0x20
283 * struct erw - extended report word
285 * @auth: authorization check
286 * @pvrf: path-verification-required flag
287 * @cpt: channel-path timeout
288 * @fsavf: failing storage address validity flag
289 * @cons: concurrent sense
290 * @scavf: secondary ccw address validity flag
291 * @fsaf: failing storage address format
292 * @scnt: sense count, if @cons == %1
306 } __attribute__ ((packed
));
309 * struct sublog - subchannel logout area
311 * @esf: extended status flags
312 * @lpum: last path used mask
313 * @arep: ancillary report
314 * @fvf: field-validity flags
315 * @sacc: storage access code
316 * @termc: termination code
317 * @devsc: device-status check
318 * @serr: secondary error
319 * @ioerr: i/o-error alert
320 * @seqc: sequence code
334 } __attribute__ ((packed
));
337 * struct esw0 - Format 0 Extended Status Word (ESW)
338 * @sublog: subchannel logout
339 * @erw: extended report word
340 * @faddr: failing storage address
341 * @saddr: secondary ccw address
344 struct sublog sublog
;
348 } __attribute__ ((packed
));
351 * struct esw1 - Format 1 Extended Status Word (ESW)
352 * @zero0: reserved zeros
353 * @lpum: last path used mask
354 * @zero16: reserved zeros
355 * @erw: extended report word
356 * @zeros: three fullwords of zeros
364 } __attribute__ ((packed
));
367 * struct esw2 - Format 2 Extended Status Word (ESW)
368 * @zero0: reserved zeros
369 * @lpum: last path used mask
370 * @dcti: device-connect-time interval
371 * @erw: extended report word
372 * @zeros: three fullwords of zeros
380 } __attribute__ ((packed
));
383 * struct esw3 - Format 3 Extended Status Word (ESW)
384 * @zero0: reserved zeros
385 * @lpum: last path used mask
387 * @erw: extended report word
388 * @zeros: three fullwords of zeros
396 } __attribute__ ((packed
));
399 * struct irb - interruption response block
400 * @scsw: subchannel status word
401 * @esw: extened status word, 4 formats
402 * @ecw: extended control word
404 * The irb that is handed to the device driver when an interrupt occurs. For
405 * solicited interrupts, the common I/O layer already performs checks whether
406 * a field is valid; a field not being valid is always passed as %0.
407 * If a unit check occured, @ecw may contain sense data; this is retrieved
408 * by the common I/O layer itself if the device doesn't support concurrent
409 * sense (so that the device driver never needs to perform basic sene itself).
410 * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
422 } __attribute__ ((packed
,aligned(4)));
425 * struct ciw - command information word (CIW) layout
427 * @reserved: reserved bits
430 * @count: command count
438 } __attribute__ ((packed
));
440 #define CIW_TYPE_RCD 0x0 /* read configuration data */
441 #define CIW_TYPE_SII 0x1 /* set interface identifier */
442 #define CIW_TYPE_RNI 0x2 /* read node identifier */
445 * Flags used as input parameters for do_IO()
447 #define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
448 #define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
449 #define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
450 /* ... for suspended CCWs */
451 /* Device or subchannel gone. */
452 #define CIO_GONE 0x0001
453 /* No path to device. */
454 #define CIO_NO_PATH 0x0002
455 /* Device has appeared. */
456 #define CIO_OPER 0x0004
457 /* Sick revalidation of device. */
458 #define CIO_REVALIDATE 0x0008
461 * struct ccw_dev_id - unique identifier for ccw devices
462 * @ssid: subchannel set id
463 * @devno: device number
465 * This structure is not directly based on any hardware structure. The
466 * hardware identifies a device by its device number and its subchannel,
467 * which is in turn identified by its id. In order to get a unique identifier
468 * for ccw devices across subchannel sets, @struct ccw_dev_id has been
477 * ccw_device_id_is_equal() - compare two ccw_dev_ids
478 * @dev_id1: a ccw_dev_id
479 * @dev_id2: another ccw_dev_id
481 * %1 if the two structures are equal field-by-field,
486 static inline int ccw_dev_id_is_equal(struct ccw_dev_id
*dev_id1
,
487 struct ccw_dev_id
*dev_id2
)
489 if ((dev_id1
->ssid
== dev_id2
->ssid
) &&
490 (dev_id1
->devno
== dev_id2
->devno
))
495 extern void wait_cons_dev(void);
497 extern void css_schedule_reprobe(void);
499 extern void reipl_ccw_dev(struct ccw_dev_id
*id
);
506 extern int cio_get_iplinfo(struct cio_iplinfo
*iplinfo
);
508 /* Function from drivers/s390/cio/chsc.c */
509 int chsc_sstpc(void *page
, unsigned int op
, u16 ctrl
);
510 int chsc_sstpi(void *page
, void *result
, size_t size
);