Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[deliverable/linux.git] / arch / s390 / include / asm / ccwdev.h
CommitLineData
1da177e4 1/*
a53c8fab 2 * Copyright IBM Corp. 2002, 2009
1da177e4 3 *
823d494a 4 * Author(s): Arnd Bergmann <arndb@de.ibm.com>
1da177e4 5 *
823d494a 6 * Interface for CCW device drivers
1da177e4
LT
7 */
8#ifndef _S390_CCWDEV_H_
9#define _S390_CCWDEV_H_
10
11#include <linux/device.h>
12#include <linux/mod_devicetable.h>
83262d63 13#include <asm/fcx.h>
de400d6b 14#include <asm/irq.h>
1f1c9610 15#include <asm/schid.h>
1da177e4
LT
16
17/* structs from asm/cio.h */
18struct irb;
19struct ccw1;
9a92fe48 20struct ccw_dev_id;
1da177e4
LT
21
22/* simplified initializers for struct ccw_device:
23 * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
24 * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
25#define CCW_DEVICE(cu, cum) \
26 .cu_type=(cu), .cu_model=(cum), \
27 .match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE \
28 | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
29
30#define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm) \
31 .cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
32 .match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE \
33 | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) \
34 | CCW_DEVICE_ID_MATCH_DEVICE_TYPE \
35 | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
36
37/* scan through an array of device ids and return the first
38 * entry that matches the device.
39 *
40 * the array must end with an entry containing zero match_flags
41 */
42static inline const struct ccw_device_id *
43ccw_device_id_match(const struct ccw_device_id *array,
44 const struct ccw_device_id *match)
45{
46 const struct ccw_device_id *id = array;
47
48 for (id = array; id->match_flags; id++) {
49 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
50 && (id->cu_type != match->cu_type))
51 continue;
52
53 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
54 && (id->cu_model != match->cu_model))
55 continue;
56
57 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
58 && (id->dev_type != match->dev_type))
59 continue;
60
61 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
62 && (id->dev_model != match->dev_model))
63 continue;
64
65 return id;
66 }
67
d2c993d8 68 return NULL;
1da177e4
LT
69}
70
b2ffd8e9
CH
71/**
72 * struct ccw_device - channel attached device
73 * @ccwlock: pointer to device lock
74 * @id: id of this device
75 * @drv: ccw driver for this device
76 * @dev: embedded device structure
77 * @online: online status of device
78 * @handler: interrupt handler
1da177e4 79 *
b2ffd8e9
CH
80 * @handler is a member of the device rather than the driver since a driver
81 * can have different interrupt handlers for different ccw devices
82 * (multi-subchannel drivers).
83 */
1da177e4
LT
84struct ccw_device {
85 spinlock_t *ccwlock;
b2ffd8e9 86/* private: */
1da177e4 87 struct ccw_device_private *private; /* cio private information */
b2ffd8e9
CH
88/* public: */
89 struct ccw_device_id id;
90 struct ccw_driver *drv;
91 struct device dev;
1da177e4 92 int online;
1da177e4
LT
93 void (*handler) (struct ccw_device *, unsigned long, struct irb *);
94};
95
585b954e
SO
96/*
97 * Possible events used by the path_event notifier.
98 */
99#define PE_NONE 0x0
100#define PE_PATH_GONE 0x1 /* A path is no longer available. */
101#define PE_PATH_AVAILABLE 0x2 /* A path has become available and
102 was successfully verified. */
103#define PE_PATHGROUP_ESTABLISHED 0x4 /* A pathgroup was reset and had
104 to be established again. */
105
094f2100
ME
106/*
107 * Possible CIO actions triggered by the unit check handler.
108 */
109enum uc_todo {
110 UC_TODO_RETRY,
111 UC_TODO_RETRY_ON_NEW_PATH,
112 UC_TODO_STOP
113};
1da177e4 114
b2ffd8e9
CH
115/**
116 * struct ccw driver - device driver for channel attached devices
b2ffd8e9
CH
117 * @ids: ids supported by this driver
118 * @probe: function called on probe
119 * @remove: function called on remove
120 * @set_online: called when setting device online
121 * @set_offline: called when setting device offline
122 * @notify: notify driver of device state changes
585b954e 123 * @path_event: notify driver of channel path events
958974fb 124 * @shutdown: called at device shutdown
823d494a
SO
125 * @prepare: prepare for pm state transition
126 * @complete: undo work done in @prepare
127 * @freeze: callback for freezing during hibernation snapshotting
128 * @thaw: undo work done in @freeze
129 * @restore: callback for restoring after hibernation
094f2100 130 * @uc_handler: callback for unit check handler
b2ffd8e9 131 * @driver: embedded device driver structure
de400d6b 132 * @int_class: interruption class to use for accounting interrupts
b2ffd8e9 133 */
1da177e4 134struct ccw_driver {
b2ffd8e9
CH
135 struct ccw_device_id *ids;
136 int (*probe) (struct ccw_device *);
1da177e4 137 void (*remove) (struct ccw_device *);
1da177e4
LT
138 int (*set_online) (struct ccw_device *);
139 int (*set_offline) (struct ccw_device *);
140 int (*notify) (struct ccw_device *, int);
585b954e 141 void (*path_event) (struct ccw_device *, int *);
958974fb 142 void (*shutdown) (struct ccw_device *);
823d494a
SO
143 int (*prepare) (struct ccw_device *);
144 void (*complete) (struct ccw_device *);
145 int (*freeze)(struct ccw_device *);
146 int (*thaw) (struct ccw_device *);
147 int (*restore)(struct ccw_device *);
094f2100 148 enum uc_todo (*uc_handler) (struct ccw_device *, struct irb *);
b2ffd8e9 149 struct device_driver driver;
de400d6b 150 enum interruption_class int_class;
1da177e4
LT
151};
152
153extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
154 const char *bus_id);
155
156/* devices drivers call these during module load and unload.
157 * When a driver is registered, its probe method is called
158 * when new devices for its type pop up */
159extern int ccw_driver_register (struct ccw_driver *driver);
160extern void ccw_driver_unregister (struct ccw_driver *driver);
161
162struct ccw1;
163
4dd3cc5c 164extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
1da177e4 165extern int ccw_device_set_options(struct ccw_device *, unsigned long);
4dd3cc5c 166extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
454e1fa1
PO
167int ccw_device_is_pathgroup(struct ccw_device *cdev);
168int ccw_device_is_multipath(struct ccw_device *cdev);
1da177e4
LT
169
170/* Allow for i/o completion notification after primary interrupt status. */
171#define CCWDEV_EARLY_NOTIFICATION 0x0001
172/* Report all interrupt conditions. */
173#define CCWDEV_REPORT_ALL 0x0002
174/* Try to perform path grouping. */
175#define CCWDEV_DO_PATHGROUP 0x0004
176/* Allow forced onlining of boxed devices. */
177#define CCWDEV_ALLOW_FORCE 0x0008
454e1fa1
PO
178/* Try to use multipath mode. */
179#define CCWDEV_DO_MULTIPATH 0x0010
1da177e4 180
1da177e4
LT
181extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
182 unsigned long, __u8, unsigned long);
1da177e4
LT
183extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
184 unsigned long, __u8, unsigned long, int);
1da177e4
LT
185extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
186 unsigned long, __u8, __u8, unsigned long);
187extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
188 unsigned long, __u8, __u8,
189 unsigned long, int);
190
191
192extern int ccw_device_resume(struct ccw_device *);
193extern int ccw_device_halt(struct ccw_device *, unsigned long);
194extern int ccw_device_clear(struct ccw_device *, unsigned long);
83262d63
PO
195int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
196 unsigned long intparm, u8 lpm, u8 key);
197int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
198 unsigned long, u8, u8);
199int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
200 unsigned long, u8, u8, int);
201int ccw_device_tm_start(struct ccw_device *, struct tcw *,
202 unsigned long, u8);
203int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
204 unsigned long, u8, int);
205int ccw_device_tm_intrg(struct ccw_device *cdev);
1da177e4 206
ce322ccd
SO
207int ccw_device_get_mdc(struct ccw_device *cdev, u8 mask);
208
1da177e4
LT
209extern int ccw_device_set_online(struct ccw_device *cdev);
210extern int ccw_device_set_offline(struct ccw_device *cdev);
211
212
213extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
214extern __u8 ccw_device_get_path_mask(struct ccw_device *);
9a92fe48 215extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
1da177e4
LT
216
217#define get_ccwdev_lock(x) (x)->ccwlock
218
219#define to_ccwdev(n) container_of(n, struct ccw_device, dev)
220#define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
221
1e532096
SO
222extern struct ccw_device *ccw_device_create_console(struct ccw_driver *);
223extern void ccw_device_destroy_console(struct ccw_device *);
224extern int ccw_device_enable_console(struct ccw_device *);
188561a4 225extern void ccw_device_wait_idle(struct ccw_device *);
f10ccca7 226extern int ccw_device_force_console(struct ccw_device *);
1da177e4 227
fd0457a6
ME
228int ccw_device_siosl(struct ccw_device *);
229
9368dac4
CH
230extern void ccw_device_get_schid(struct ccw_device *, struct subchannel_id *);
231
2bf29df7 232struct channel_path_desc *ccw_device_get_chp_desc(struct ccw_device *, int);
1da177e4 233#endif /* _S390_CCWDEV_H_ */
This page took 0.775024 seconds and 5 git commands to generate.