0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _S390_CCWDEV_H_
0010 #define _S390_CCWDEV_H_
0011
0012 #include <linux/device.h>
0013 #include <linux/mod_devicetable.h>
0014 #include <asm/chsc.h>
0015 #include <asm/fcx.h>
0016 #include <asm/irq.h>
0017 #include <asm/schid.h>
0018
0019
0020 struct irb;
0021 struct ccw1;
0022 struct ccw_dev_id;
0023
0024
0025
0026
0027 #define CCW_DEVICE(cu, cum) \
0028 .cu_type=(cu), .cu_model=(cum), \
0029 .match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE \
0030 | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
0031
0032 #define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm) \
0033 .cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
0034 .match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE \
0035 | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) \
0036 | CCW_DEVICE_ID_MATCH_DEVICE_TYPE \
0037 | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
0038
0039
0040
0041
0042
0043
0044 static inline const struct ccw_device_id *
0045 ccw_device_id_match(const struct ccw_device_id *array,
0046 const struct ccw_device_id *match)
0047 {
0048 const struct ccw_device_id *id = array;
0049
0050 for (id = array; id->match_flags; id++) {
0051 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
0052 && (id->cu_type != match->cu_type))
0053 continue;
0054
0055 if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
0056 && (id->cu_model != match->cu_model))
0057 continue;
0058
0059 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
0060 && (id->dev_type != match->dev_type))
0061 continue;
0062
0063 if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
0064 && (id->dev_model != match->dev_model))
0065 continue;
0066
0067 return id;
0068 }
0069
0070 return NULL;
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 struct ccw_device {
0087 spinlock_t *ccwlock;
0088
0089 struct ccw_device_private *private;
0090
0091 struct ccw_device_id id;
0092 struct ccw_driver *drv;
0093 struct device dev;
0094 int online;
0095 void (*handler) (struct ccw_device *, unsigned long, struct irb *);
0096 };
0097
0098
0099
0100
0101 #define PE_NONE 0x0
0102 #define PE_PATH_GONE 0x1
0103 #define PE_PATH_AVAILABLE 0x2
0104
0105 #define PE_PATHGROUP_ESTABLISHED 0x4
0106
0107 #define PE_PATH_FCES_EVENT 0x8
0108
0109
0110
0111
0112
0113 enum uc_todo {
0114 UC_TODO_RETRY,
0115 UC_TODO_RETRY_ON_NEW_PATH,
0116 UC_TODO_STOP
0117 };
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 struct ccw_driver {
0134 struct ccw_device_id *ids;
0135 int (*probe) (struct ccw_device *);
0136 void (*remove) (struct ccw_device *);
0137 int (*set_online) (struct ccw_device *);
0138 int (*set_offline) (struct ccw_device *);
0139 int (*notify) (struct ccw_device *, int);
0140 void (*path_event) (struct ccw_device *, int *);
0141 void (*shutdown) (struct ccw_device *);
0142 enum uc_todo (*uc_handler) (struct ccw_device *, struct irb *);
0143 struct device_driver driver;
0144 enum interruption_class int_class;
0145 };
0146
0147 extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
0148 const char *bus_id);
0149
0150
0151
0152
0153 extern int ccw_driver_register (struct ccw_driver *driver);
0154 extern void ccw_driver_unregister (struct ccw_driver *driver);
0155 extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
0156 extern int ccw_device_set_options(struct ccw_device *, unsigned long);
0157 extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
0158 int ccw_device_is_pathgroup(struct ccw_device *cdev);
0159 int ccw_device_is_multipath(struct ccw_device *cdev);
0160
0161
0162 #define CCWDEV_EARLY_NOTIFICATION 0x0001
0163
0164 #define CCWDEV_REPORT_ALL 0x0002
0165
0166 #define CCWDEV_DO_PATHGROUP 0x0004
0167
0168 #define CCWDEV_ALLOW_FORCE 0x0008
0169
0170 #define CCWDEV_DO_MULTIPATH 0x0010
0171
0172 extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
0173 unsigned long, __u8, unsigned long);
0174 extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
0175 unsigned long, __u8, unsigned long, int);
0176 extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
0177 unsigned long, __u8, __u8, unsigned long);
0178 extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
0179 unsigned long, __u8, __u8,
0180 unsigned long, int);
0181
0182
0183 extern int ccw_device_resume(struct ccw_device *);
0184 extern int ccw_device_halt(struct ccw_device *, unsigned long);
0185 extern int ccw_device_clear(struct ccw_device *, unsigned long);
0186 int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
0187 unsigned long intparm, u8 lpm, u8 key);
0188 int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
0189 unsigned long, u8, u8);
0190 int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
0191 unsigned long, u8, u8, int);
0192 int ccw_device_tm_start(struct ccw_device *, struct tcw *,
0193 unsigned long, u8);
0194 int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
0195 unsigned long, u8, int);
0196 int ccw_device_tm_intrg(struct ccw_device *cdev);
0197
0198 int ccw_device_get_mdc(struct ccw_device *cdev, u8 mask);
0199
0200 extern int ccw_device_set_online(struct ccw_device *cdev);
0201 extern int ccw_device_set_offline(struct ccw_device *cdev);
0202
0203
0204 extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
0205 extern __u8 ccw_device_get_path_mask(struct ccw_device *);
0206 extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
0207
0208 #define get_ccwdev_lock(x) (x)->ccwlock
0209
0210 #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
0211 #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
0212
0213 extern struct ccw_device *ccw_device_create_console(struct ccw_driver *);
0214 extern void ccw_device_destroy_console(struct ccw_device *);
0215 extern int ccw_device_enable_console(struct ccw_device *);
0216 extern void ccw_device_wait_idle(struct ccw_device *);
0217 extern int ccw_device_force_console(struct ccw_device *);
0218
0219 extern void *ccw_device_dma_zalloc(struct ccw_device *cdev, size_t size);
0220 extern void ccw_device_dma_free(struct ccw_device *cdev,
0221 void *cpu_addr, size_t size);
0222
0223 int ccw_device_siosl(struct ccw_device *);
0224
0225 extern void ccw_device_get_schid(struct ccw_device *, struct subchannel_id *);
0226
0227 struct channel_path_desc_fmt0 *ccw_device_get_chp_desc(struct ccw_device *, int);
0228 u8 *ccw_device_get_util_str(struct ccw_device *cdev, int chp_idx);
0229 int ccw_device_pnso(struct ccw_device *cdev,
0230 struct chsc_pnso_area *pnso_area, u8 oc,
0231 struct chsc_pnso_resume_token resume_token, int cnc);
0232 int ccw_device_get_cssid(struct ccw_device *cdev, u8 *cssid);
0233 int ccw_device_get_iid(struct ccw_device *cdev, u8 *iid);
0234 int ccw_device_get_chpid(struct ccw_device *cdev, int chp_idx, u8 *chpid);
0235 int ccw_device_get_chid(struct ccw_device *cdev, int chp_idx, u16 *chid);
0236 #endif