blob: e34347d567a6eadcf92f42d7e754cf6ef19507dd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/asm-s390/cio.h
3 * include/asm-s390x/cio.h
4 *
5 * Common interface for I/O on S/390
6 */
7#ifndef _ASM_S390_CIO_H_
8#define _ASM_S390_CIO_H_
9
10#include <linux/spinlock.h>
11#include <asm/types.h>
12
13#ifdef __KERNEL__
14
15#define LPM_ANYPATH 0xff
Peter Oberparleitere5854a52007-04-27 16:01:31 +020016#define __MAX_CSSID 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Heiko Carstens62733e52009-09-11 10:28:15 +020018#include <asm/scsw.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020020/**
21 * struct ccw1 - channel command word
22 * @cmd_code: command code
Daniel Mack3ad2f3f2010-02-03 08:01:28 +080023 * @flags: flags, like IDA addressing, etc.
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020024 * @count: byte count
25 * @cda: data address
26 *
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.
30 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070031struct ccw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020032 __u8 cmd_code;
33 __u8 flags;
34 __u16 count;
35 __u32 cda;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036} __attribute__ ((packed,aligned(8)));
37
38#define CCW_FLAG_DC 0x80
39#define CCW_FLAG_CC 0x40
40#define CCW_FLAG_SLI 0x20
41#define CCW_FLAG_SKIP 0x10
42#define CCW_FLAG_PCI 0x08
43#define CCW_FLAG_IDA 0x04
44#define CCW_FLAG_SUSPEND 0x02
45
46#define CCW_CMD_READ_IPL 0x02
47#define CCW_CMD_NOOP 0x03
48#define CCW_CMD_BASIC_SENSE 0x04
49#define CCW_CMD_TIC 0x08
50#define CCW_CMD_STLCK 0x14
51#define CCW_CMD_SENSE_PGID 0x34
52#define CCW_CMD_SUSPEND_RECONN 0x5B
53#define CCW_CMD_RDC 0x64
54#define CCW_CMD_RELEASE 0x94
55#define CCW_CMD_SET_PGID 0xAF
56#define CCW_CMD_SENSE_ID 0xE4
57#define CCW_CMD_DCTL 0xF3
58
59#define SENSE_MAX_COUNT 0x20
60
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020061/**
62 * struct erw - extended report word
63 * @res0: reserved
64 * @auth: authorization check
65 * @pvrf: path-verification-required flag
66 * @cpt: channel-path timeout
67 * @fsavf: failing storage address validity flag
68 * @cons: concurrent sense
69 * @scavf: secondary ccw address validity flag
70 * @fsaf: failing storage address format
71 * @scnt: sense count, if @cons == %1
72 * @res16: reserved
73 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070074struct erw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020075 __u32 res0 : 3;
76 __u32 auth : 1;
77 __u32 pvrf : 1;
78 __u32 cpt : 1;
79 __u32 fsavf : 1;
80 __u32 cons : 1;
81 __u32 scavf : 1;
82 __u32 fsaf : 1;
83 __u32 scnt : 6;
84 __u32 res16 : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085} __attribute__ ((packed));
86
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020087/**
88 * struct sublog - subchannel logout area
89 * @res0: reserved
90 * @esf: extended status flags
91 * @lpum: last path used mask
92 * @arep: ancillary report
93 * @fvf: field-validity flags
94 * @sacc: storage access code
95 * @termc: termination code
96 * @devsc: device-status check
97 * @serr: secondary error
98 * @ioerr: i/o-error alert
99 * @seqc: sequence code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 */
101struct sublog {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200102 __u32 res0 : 1;
103 __u32 esf : 7;
104 __u32 lpum : 8;
105 __u32 arep : 1;
106 __u32 fvf : 5;
107 __u32 sacc : 2;
108 __u32 termc : 2;
109 __u32 devsc : 1;
110 __u32 serr : 1;
111 __u32 ioerr : 1;
112 __u32 seqc : 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113} __attribute__ ((packed));
114
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200115/**
116 * struct esw0 - Format 0 Extended Status Word (ESW)
117 * @sublog: subchannel logout
118 * @erw: extended report word
119 * @faddr: failing storage address
120 * @saddr: secondary ccw address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 */
122struct esw0 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200123 struct sublog sublog;
124 struct erw erw;
125 __u32 faddr[2];
126 __u32 saddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127} __attribute__ ((packed));
128
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200129/**
130 * struct esw1 - Format 1 Extended Status Word (ESW)
131 * @zero0: reserved zeros
132 * @lpum: last path used mask
133 * @zero16: reserved zeros
134 * @erw: extended report word
135 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 */
137struct esw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200138 __u8 zero0;
139 __u8 lpum;
140 __u16 zero16;
141 struct erw erw;
142 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143} __attribute__ ((packed));
144
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200145/**
146 * struct esw2 - Format 2 Extended Status Word (ESW)
147 * @zero0: reserved zeros
148 * @lpum: last path used mask
149 * @dcti: device-connect-time interval
150 * @erw: extended report word
151 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 */
153struct esw2 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200154 __u8 zero0;
155 __u8 lpum;
156 __u16 dcti;
157 struct erw erw;
158 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159} __attribute__ ((packed));
160
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200161/**
162 * struct esw3 - Format 3 Extended Status Word (ESW)
163 * @zero0: reserved zeros
164 * @lpum: last path used mask
165 * @res: reserved
166 * @erw: extended report word
167 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 */
169struct esw3 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200170 __u8 zero0;
171 __u8 lpum;
172 __u16 res;
173 struct erw erw;
174 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175} __attribute__ ((packed));
176
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200177/**
178 * struct irb - interruption response block
179 * @scsw: subchannel status word
180 * @esw: extened status word, 4 formats
181 * @ecw: extended control word
182 *
183 * The irb that is handed to the device driver when an interrupt occurs. For
184 * solicited interrupts, the common I/O layer already performs checks whether
185 * a field is valid; a field not being valid is always passed as %0.
186 * If a unit check occured, @ecw may contain sense data; this is retrieved
187 * by the common I/O layer itself if the device doesn't support concurrent
188 * sense (so that the device driver never needs to perform basic sene itself).
189 * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
190 * if applicable).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 */
192struct irb {
Peter Oberparleiter23d805b2008-07-14 09:58:50 +0200193 union scsw scsw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200194 union {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 struct esw0 esw0;
196 struct esw1 esw1;
197 struct esw2 esw2;
198 struct esw3 esw3;
199 } esw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200200 __u8 ecw[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201} __attribute__ ((packed,aligned(4)));
202
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200203/**
204 * struct ciw - command information word (CIW) layout
205 * @et: entry type
206 * @reserved: reserved bits
207 * @ct: command type
208 * @cmd: command code
209 * @count: command count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 */
211struct ciw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200212 __u32 et : 2;
213 __u32 reserved : 2;
214 __u32 ct : 4;
215 __u32 cmd : 8;
216 __u32 count : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217} __attribute__ ((packed));
218
219#define CIW_TYPE_RCD 0x0 /* read configuration data */
220#define CIW_TYPE_SII 0x1 /* set interface identifier */
221#define CIW_TYPE_RNI 0x2 /* read node identifier */
222
223/*
224 * Flags used as input parameters for do_IO()
225 */
226#define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
227#define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
228#define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
229 /* ... for suspended CCWs */
230/* Device or subchannel gone. */
231#define CIO_GONE 0x0001
232/* No path to device. */
233#define CIO_NO_PATH 0x0002
234/* Device has appeared. */
235#define CIO_OPER 0x0004
236/* Sick revalidation of device. */
237#define CIO_REVALIDATE 0x0008
Sebastian Ott47593bf2009-03-31 19:16:05 +0200238/* Device did not respond in time. */
239#define CIO_BOXED 0x0010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200241/**
242 * struct ccw_dev_id - unique identifier for ccw devices
243 * @ssid: subchannel set id
244 * @devno: device number
245 *
246 * This structure is not directly based on any hardware structure. The
247 * hardware identifies a device by its device number and its subchannel,
248 * which is in turn identified by its id. In order to get a unique identifier
249 * for ccw devices across subchannel sets, @struct ccw_dev_id has been
250 * introduced.
251 */
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200252struct ccw_dev_id {
253 u8 ssid;
254 u16 devno;
255};
256
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200257/**
258 * ccw_device_id_is_equal() - compare two ccw_dev_ids
259 * @dev_id1: a ccw_dev_id
260 * @dev_id2: another ccw_dev_id
261 * Returns:
262 * %1 if the two structures are equal field-by-field,
263 * %0 if not.
264 * Context:
265 * any
266 */
Cornelia Huck78964262006-10-11 15:31:38 +0200267static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
268 struct ccw_dev_id *dev_id2)
269{
Cornelia Huckce26a852006-12-04 15:40:54 +0100270 if ((dev_id1->ssid == dev_id2->ssid) &&
271 (dev_id1->devno == dev_id2->devno))
272 return 1;
273 return 0;
Cornelia Huck78964262006-10-11 15:31:38 +0200274}
275
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276extern void wait_cons_dev(void);
277
Peter Oberparleiter40154b82006-06-29 14:57:03 +0200278extern void css_schedule_reprobe(void);
279
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200280extern void reipl_ccw_dev(struct ccw_dev_id *id);
281
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200282struct cio_iplinfo {
283 u16 devno;
284 int is_qdio;
285};
286
287extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
288
Heiko Carstensa8061702008-04-17 07:46:26 +0200289/* Function from drivers/s390/cio/chsc.c */
290int chsc_sstpc(void *page, unsigned int op, u16 ctrl);
291int chsc_sstpi(void *page, void *result, size_t size);
292
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293#endif
294
295#endif