[BNX2]: Use msleep().
[linux-2.6/verdex.git] / include / asm-s390 / ccwdev.h
blob1aeda27d5a8bb33e9aae6408391d387b7614699b
1 /*
2 * include/asm-s390/ccwdev.h
3 * include/asm-s390x/ccwdev.h
5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Arnd Bergmann <arndb@de.ibm.com>
8 * Interface for CCW device drivers
9 */
10 #ifndef _S390_CCWDEV_H_
11 #define _S390_CCWDEV_H_
13 #include <linux/device.h>
14 #include <linux/mod_devicetable.h>
16 /* structs from asm/cio.h */
17 struct irb;
18 struct ccw1;
19 struct ccw_dev_id;
21 /* simplified initializers for struct ccw_device:
22 * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
23 * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
24 #define CCW_DEVICE(cu, cum) \
25 .cu_type=(cu), .cu_model=(cum), \
26 .match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE \
27 | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
29 #define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm) \
30 .cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
31 .match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE \
32 | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) \
33 | CCW_DEVICE_ID_MATCH_DEVICE_TYPE \
34 | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
36 /* scan through an array of device ids and return the first
37 * entry that matches the device.
39 * the array must end with an entry containing zero match_flags
41 static inline const struct ccw_device_id *
42 ccw_device_id_match(const struct ccw_device_id *array,
43 const struct ccw_device_id *match)
45 const struct ccw_device_id *id = array;
47 for (id = array; id->match_flags; id++) {
48 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
49 && (id->cu_type != match->cu_type))
50 continue;
52 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
53 && (id->cu_model != match->cu_model))
54 continue;
56 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
57 && (id->dev_type != match->dev_type))
58 continue;
60 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
61 && (id->dev_model != match->dev_model))
62 continue;
64 return id;
67 return NULL;
70 /* The struct ccw device is our replacement for the globally accessible
71 * ioinfo array. ioinfo will mutate into a subchannel device later.
73 * Reference: Documentation/s390/driver-model.txt */
74 struct ccw_device {
75 spinlock_t *ccwlock;
76 struct ccw_device_private *private; /* cio private information */
77 struct ccw_device_id id; /* id of this device, driver_info is
78 set by ccw_find_driver */
79 struct ccw_driver *drv; /* */
80 struct device dev; /* */
81 int online;
82 /* This is sick, but a driver can have different interrupt handlers
83 for different ccw_devices (multi-subchannel drivers)... */
84 void (*handler) (struct ccw_device *, unsigned long, struct irb *);
88 /* Each ccw driver registers with the ccw root bus */
89 struct ccw_driver {
90 struct module *owner; /* for automatic MOD_INC_USE_COUNT */
91 struct ccw_device_id *ids; /* probe driver with these devs */
92 int (*probe) (struct ccw_device *); /* ask driver to probe dev */
93 void (*remove) (struct ccw_device *);
94 /* device is no longer available */
95 int (*set_online) (struct ccw_device *);
96 int (*set_offline) (struct ccw_device *);
97 int (*notify) (struct ccw_device *, int);
98 struct device_driver driver; /* higher level structure, don't init
99 this from your driver */
100 char *name;
103 extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
104 const char *bus_id);
106 /* devices drivers call these during module load and unload.
107 * When a driver is registered, its probe method is called
108 * when new devices for its type pop up */
109 extern int ccw_driver_register (struct ccw_driver *driver);
110 extern void ccw_driver_unregister (struct ccw_driver *driver);
112 struct ccw1;
114 extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
115 extern int ccw_device_set_options(struct ccw_device *, unsigned long);
116 extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
118 /* Allow for i/o completion notification after primary interrupt status. */
119 #define CCWDEV_EARLY_NOTIFICATION 0x0001
120 /* Report all interrupt conditions. */
121 #define CCWDEV_REPORT_ALL 0x0002
122 /* Try to perform path grouping. */
123 #define CCWDEV_DO_PATHGROUP 0x0004
124 /* Allow forced onlining of boxed devices. */
125 #define CCWDEV_ALLOW_FORCE 0x0008
128 * ccw_device_start()
130 * Start a S/390 channel program. When the interrupt arrives, the
131 * IRQ handler is called, either immediately, delayed (dev-end missing,
132 * or sense required) or never (no IRQ handler registered).
133 * Depending on the action taken, ccw_device_start() returns:
134 * 0 - Success
135 * -EBUSY - Device busy, or status pending
136 * -ENODEV - Device not operational
137 * -EINVAL - Device invalid for operation
139 extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
140 unsigned long, __u8, unsigned long);
142 * ccw_device_start_timeout()
144 * This function notifies the device driver if the channel program has not
145 * completed during the specified time. If a timeout occurs, the channel
146 * program is terminated via xsch(), hsch() or csch().
148 extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
149 unsigned long, __u8, unsigned long, int);
151 * ccw_device_start_key()
152 * ccw_device_start_key_timeout()
154 * Same as ccw_device_start() and ccw_device_start_timeout(), except a
155 * storage key != default key can be provided for the I/O.
157 extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
158 unsigned long, __u8, __u8, unsigned long);
159 extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
160 unsigned long, __u8, __u8,
161 unsigned long, int);
164 extern int ccw_device_resume(struct ccw_device *);
165 extern int ccw_device_halt(struct ccw_device *, unsigned long);
166 extern int ccw_device_clear(struct ccw_device *, unsigned long);
168 extern int ccw_device_set_online(struct ccw_device *cdev);
169 extern int ccw_device_set_offline(struct ccw_device *cdev);
172 extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
173 extern __u8 ccw_device_get_path_mask(struct ccw_device *);
174 extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
176 #define get_ccwdev_lock(x) (x)->ccwlock
178 #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
179 #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
181 extern struct ccw_device *ccw_device_probe_console(void);
183 // FIXME: these have to go
184 extern int _ccw_device_get_subchannel_number(struct ccw_device *);
186 extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
187 #endif /* _S390_CCWDEV_H_ */