1
2
3
4
5
6
7
8
9#ifndef _S390_CCWDEV_H_
10#define _S390_CCWDEV_H_
11
12#include <linux/device.h>
13#include <linux/mod_devicetable.h>
14#include <asm/chsc.h>
15#include <asm/fcx.h>
16#include <asm/irq.h>
17#include <asm/schid.h>
18
19
20struct irb;
21struct ccw1;
22struct ccw_dev_id;
23
24
25
26
27#define CCW_DEVICE(cu, cum) \
28 .cu_type=(cu), .cu_model=(cum), \
29 .match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE \
30 | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
31
32#define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm) \
33 .cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
34 .match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE \
35 | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) \
36 | CCW_DEVICE_ID_MATCH_DEVICE_TYPE \
37 | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
38
39
40
41
42
43
44static inline const struct ccw_device_id *
45ccw_device_id_match(const struct ccw_device_id *array,
46 const struct ccw_device_id *match)
47{
48 const struct ccw_device_id *id = array;
49
50 for (id = array; id->match_flags; id++) {
51 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
52 && (id->cu_type != match->cu_type))
53 continue;
54
55 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
56 && (id->cu_model != match->cu_model))
57 continue;
58
59 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
60 && (id->dev_type != match->dev_type))
61 continue;
62
63 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
64 && (id->dev_model != match->dev_model))
65 continue;
66
67 return id;
68 }
69
70 return NULL;
71}
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86struct ccw_device {
87 spinlock_t *ccwlock;
88
89 struct ccw_device_private *private;
90
91 struct ccw_device_id id;
92 struct ccw_driver *drv;
93 struct device dev;
94 int online;
95 void (*handler) (struct ccw_device *, unsigned long, struct irb *);
96};
97
98
99
100
101#define PE_NONE 0x0
102#define PE_PATH_GONE 0x1
103#define PE_PATH_AVAILABLE 0x2
104
105#define PE_PATHGROUP_ESTABLISHED 0x4
106
107
108
109
110
111enum uc_todo {
112 UC_TODO_RETRY,
113 UC_TODO_RETRY_ON_NEW_PATH,
114 UC_TODO_STOP
115};
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136struct ccw_driver {
137 struct ccw_device_id *ids;
138 int (*probe) (struct ccw_device *);
139 void (*remove) (struct ccw_device *);
140 int (*set_online) (struct ccw_device *);
141 int (*set_offline) (struct ccw_device *);
142 int (*notify) (struct ccw_device *, int);
143 void (*path_event) (struct ccw_device *, int *);
144 void (*shutdown) (struct ccw_device *);
145 int (*prepare) (struct ccw_device *);
146 void (*complete) (struct ccw_device *);
147 int (*freeze)(struct ccw_device *);
148 int (*thaw) (struct ccw_device *);
149 int (*restore)(struct ccw_device *);
150 enum uc_todo (*uc_handler) (struct ccw_device *, struct irb *);
151 struct device_driver driver;
152 enum interruption_class int_class;
153};
154
155extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
156 const char *bus_id);
157
158
159
160
161extern int ccw_driver_register (struct ccw_driver *driver);
162extern void ccw_driver_unregister (struct ccw_driver *driver);
163
164struct ccw1;
165
166extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
167extern int ccw_device_set_options(struct ccw_device *, unsigned long);
168extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
169int ccw_device_is_pathgroup(struct ccw_device *cdev);
170int ccw_device_is_multipath(struct ccw_device *cdev);
171
172
173#define CCWDEV_EARLY_NOTIFICATION 0x0001
174
175#define CCWDEV_REPORT_ALL 0x0002
176
177#define CCWDEV_DO_PATHGROUP 0x0004
178
179#define CCWDEV_ALLOW_FORCE 0x0008
180
181#define CCWDEV_DO_MULTIPATH 0x0010
182
183extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
184 unsigned long, __u8, unsigned long);
185extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
186 unsigned long, __u8, unsigned long, int);
187extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
188 unsigned long, __u8, __u8, unsigned long);
189extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
190 unsigned long, __u8, __u8,
191 unsigned long, int);
192
193
194extern int ccw_device_resume(struct ccw_device *);
195extern int ccw_device_halt(struct ccw_device *, unsigned long);
196extern int ccw_device_clear(struct ccw_device *, unsigned long);
197int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
198 unsigned long intparm, u8 lpm, u8 key);
199int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
200 unsigned long, u8, u8);
201int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
202 unsigned long, u8, u8, int);
203int ccw_device_tm_start(struct ccw_device *, struct tcw *,
204 unsigned long, u8);
205int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
206 unsigned long, u8, int);
207int ccw_device_tm_intrg(struct ccw_device *cdev);
208
209int ccw_device_get_mdc(struct ccw_device *cdev, u8 mask);
210
211extern int ccw_device_set_online(struct ccw_device *cdev);
212extern int ccw_device_set_offline(struct ccw_device *cdev);
213
214
215extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
216extern __u8 ccw_device_get_path_mask(struct ccw_device *);
217extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
218
219#define get_ccwdev_lock(x) (x)->ccwlock
220
221#define to_ccwdev(n) container_of(n, struct ccw_device, dev)
222#define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
223
224extern struct ccw_device *ccw_device_create_console(struct ccw_driver *);
225extern void ccw_device_destroy_console(struct ccw_device *);
226extern int ccw_device_enable_console(struct ccw_device *);
227extern void ccw_device_wait_idle(struct ccw_device *);
228extern int ccw_device_force_console(struct ccw_device *);
229
230extern void *ccw_device_dma_zalloc(struct ccw_device *cdev, size_t size);
231extern void ccw_device_dma_free(struct ccw_device *cdev,
232 void *cpu_addr, size_t size);
233
234int ccw_device_siosl(struct ccw_device *);
235
236extern void ccw_device_get_schid(struct ccw_device *, struct subchannel_id *);
237
238struct channel_path_desc_fmt0 *ccw_device_get_chp_desc(struct ccw_device *, int);
239u8 *ccw_device_get_util_str(struct ccw_device *cdev, int chp_idx);
240int ccw_device_pnso(struct ccw_device *cdev,
241 struct chsc_pnso_area *pnso_area,
242 struct chsc_pnso_resume_token resume_token,
243 int cnc);
244#endif
245