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(struct ccw_device
*, unsigned long);
115 /* Allow for i/o completion notification after primary interrupt status. */
116 #define CCWDEV_EARLY_NOTIFICATION 0x0001
117 /* Report all interrupt conditions. */
118 #define CCWDEV_REPORT_ALL 0x0002
119 /* Try to perform path grouping. */
120 #define CCWDEV_DO_PATHGROUP 0x0004
121 /* Allow forced onlining of boxed devices. */
122 #define CCWDEV_ALLOW_FORCE 0x0008
127 * Start a S/390 channel program. When the interrupt arrives, the
128 * IRQ handler is called, either immediately, delayed (dev-end missing,
129 * or sense required) or never (no IRQ handler registered).
130 * Depending on the action taken, ccw_device_start() returns:
132 * -EBUSY - Device busy, or status pending
133 * -ENODEV - Device not operational
134 * -EINVAL - Device invalid for operation
136 extern int ccw_device_start(struct ccw_device
*, struct ccw1
*,
137 unsigned long, __u8
, unsigned long);
139 * ccw_device_start_timeout()
141 * This function notifies the device driver if the channel program has not
142 * completed during the specified time. If a timeout occurs, the channel
143 * program is terminated via xsch(), hsch() or csch().
145 extern int ccw_device_start_timeout(struct ccw_device
*, struct ccw1
*,
146 unsigned long, __u8
, unsigned long, int);
148 extern int ccw_device_resume(struct ccw_device
*);
149 extern int ccw_device_halt(struct ccw_device
*, unsigned long);
150 extern int ccw_device_clear(struct ccw_device
*, unsigned long);
152 extern int read_dev_chars(struct ccw_device
*cdev
, void **buffer
, int length
);
153 extern int read_conf_data(struct ccw_device
*cdev
, void **buffer
, int *length
);
155 extern int ccw_device_set_online(struct ccw_device
*cdev
);
156 extern int ccw_device_set_offline(struct ccw_device
*cdev
);
159 extern struct ciw
*ccw_device_get_ciw(struct ccw_device
*, __u32 cmd
);
160 extern __u8
ccw_device_get_path_mask(struct ccw_device
*);
162 #define get_ccwdev_lock(x) (x)->ccwlock
164 #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
165 #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
167 extern struct ccw_device
*ccw_device_probe_console(void);
169 // FIXME: these have to go
170 extern int _ccw_device_get_device_number(struct ccw_device
*);
171 extern int _ccw_device_get_subchannel_number(struct ccw_device
*);
173 extern struct device
*s390_root_dev_register(const char *);
174 extern void s390_root_dev_unregister(struct device
*);
176 #endif /* _S390_CCWDEV_H_ */