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
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 */
20 /* simplified initializers for struct ccw_device:
21 * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
22 * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
23 #define CCW_DEVICE(cu, cum) \
24 .cu_type=(cu), .cu_model=(cum), \
25 .match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE \
26 | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
28 #define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm) \
29 .cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
30 .match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE \
31 | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) \
32 | CCW_DEVICE_ID_MATCH_DEVICE_TYPE \
33 | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
35 /* scan through an array of device ids and return the first
36 * entry that matches the device.
38 * the array must end with an entry containing zero match_flags
40 static inline const struct ccw_device_id *
41 ccw_device_id_match(const struct ccw_device_id *array,
42 const struct ccw_device_id *match)
44 const struct ccw_device_id *id = array;
46 for (id = array; id->match_flags; id++) {
47 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
48 && (id->cu_type != match->cu_type))
51 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
52 && (id->cu_model != match->cu_model))
55 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
56 && (id->dev_type != match->dev_type))
59 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
60 && (id->dev_model != match->dev_model))
69 /* The struct ccw device is our replacement for the globally accessible
70 * ioinfo array. ioinfo will mutate into a subchannel device later.
72 * Reference: Documentation/s390/driver-model.txt */
75 struct ccw_device_private *private; /* cio private information */
76 struct ccw_device_id id; /* id of this device, driver_info is
77 set by ccw_find_driver */
78 struct ccw_driver *drv; /* */
79 struct device dev; /* */
81 /* This is sick, but a driver can have different interrupt handlers
82 for different ccw_devices (multi-subchannel drivers)... */
83 void (*handler) (struct ccw_device *, unsigned long, struct irb *);
87 /* Each ccw driver registers with the ccw root bus */
89 struct module *owner; /* for automatic MOD_INC_USE_COUNT */
90 struct ccw_device_id *ids; /* probe driver with these devs */
91 int (*probe) (struct ccw_device *); /* ask driver to probe dev */
92 void (*remove) (struct ccw_device *);
93 /* device is no longer available */
94 int (*set_online) (struct ccw_device *);
95 int (*set_offline) (struct ccw_device *);
96 int (*notify) (struct ccw_device *, int);
97 struct device_driver driver; /* higher level structure, don't init
98 this from your driver */
102 extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
105 /* devices drivers call these during module load and unload.
106 * When a driver is registered, its probe method is called
107 * when new devices for its type pop up */
108 extern int ccw_driver_register (struct ccw_driver *driver);
109 extern void ccw_driver_unregister (struct ccw_driver *driver);
113 extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
114 extern int ccw_device_set_options(struct ccw_device *, unsigned long);
115 extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
117 /* Allow for i/o completion notification after primary interrupt status. */
118 #define CCWDEV_EARLY_NOTIFICATION 0x0001
119 /* Report all interrupt conditions. */
120 #define CCWDEV_REPORT_ALL 0x0002
121 /* Try to perform path grouping. */
122 #define CCWDEV_DO_PATHGROUP 0x0004
123 /* Allow forced onlining of boxed devices. */
124 #define CCWDEV_ALLOW_FORCE 0x0008
129 * Start a S/390 channel program. When the interrupt arrives, the
130 * IRQ handler is called, either immediately, delayed (dev-end missing,
131 * or sense required) or never (no IRQ handler registered).
132 * Depending on the action taken, ccw_device_start() returns:
134 * -EBUSY - Device busy, or status pending
135 * -ENODEV - Device not operational
136 * -EINVAL - Device invalid for operation
138 extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
139 unsigned long, __u8, unsigned long);
141 * ccw_device_start_timeout()
143 * This function notifies the device driver if the channel program has not
144 * completed during the specified time. If a timeout occurs, the channel
145 * program is terminated via xsch(), hsch() or csch().
147 extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
148 unsigned long, __u8, unsigned long, int);
150 * ccw_device_start_key()
151 * ccw_device_start_key_timeout()
153 * Same as ccw_device_start() and ccw_device_start_timeout(), except a
154 * storage key != default key can be provided for the I/O.
156 extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
157 unsigned long, __u8, __u8, unsigned long);
158 extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
159 unsigned long, __u8, __u8,
163 extern int ccw_device_resume(struct ccw_device *);
164 extern int ccw_device_halt(struct ccw_device *, unsigned long);
165 extern int ccw_device_clear(struct ccw_device *, unsigned long);
167 extern int read_dev_chars(struct ccw_device *cdev, void **buffer, int length);
168 extern int read_conf_data(struct ccw_device *cdev, void **buffer, int *length);
169 extern int read_conf_data_lpm(struct ccw_device *cdev, void **buffer,
170 int *length, __u8 lpm);
172 extern int ccw_device_set_online(struct ccw_device *cdev);
173 extern int ccw_device_set_offline(struct ccw_device *cdev);
176 extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
177 extern __u8 ccw_device_get_path_mask(struct ccw_device *);
179 #define get_ccwdev_lock(x) (x)->ccwlock
181 #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
182 #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
184 extern struct ccw_device *ccw_device_probe_console(void);
186 // FIXME: these have to go
187 extern int _ccw_device_get_device_number(struct ccw_device *);
188 extern int _ccw_device_get_subchannel_number(struct ccw_device *);
190 extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
191 #endif /* _S390_CCWDEV_H_ */