Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-s390/ccwdev.h |
| 3 | * include/asm-s390x/ccwdev.h |
| 4 | * |
| 5 | * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation |
| 6 | * Author(s): Arnd Bergmann <arndb@de.ibm.com> |
| 7 | * |
| 8 | * Interface for CCW device drivers |
| 9 | */ |
| 10 | #ifndef _S390_CCWDEV_H_ |
| 11 | #define _S390_CCWDEV_H_ |
| 12 | |
| 13 | #include <linux/device.h> |
| 14 | #include <linux/mod_devicetable.h> |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 15 | #include <asm/fcx.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | /* structs from asm/cio.h */ |
| 18 | struct irb; |
| 19 | struct ccw1; |
Cornelia Huck | 9a92fe4 | 2007-05-10 15:45:42 +0200 | [diff] [blame] | 20 | struct ccw_dev_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
| 42 | static inline const struct ccw_device_id * |
| 43 | ccw_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 | |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 68 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | * |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | struct ccw_device { |
| 85 | spinlock_t *ccwlock; |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 86 | /* private: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct ccw_device_private *private; /* cio private information */ |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 88 | /* public: */ |
| 89 | struct ccw_device_id id; |
| 90 | struct ccw_driver *drv; |
| 91 | struct device dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | int online; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | void (*handler) (struct ccw_device *, unsigned long, struct irb *); |
| 94 | }; |
| 95 | |
| 96 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 97 | /** |
| 98 | * struct ccw driver - device driver for channel attached devices |
| 99 | * @owner: owning module |
| 100 | * @ids: ids supported by this driver |
| 101 | * @probe: function called on probe |
| 102 | * @remove: function called on remove |
| 103 | * @set_online: called when setting device online |
| 104 | * @set_offline: called when setting device offline |
| 105 | * @notify: notify driver of device state changes |
Cornelia Huck | 958974fb | 2007-10-12 16:11:21 +0200 | [diff] [blame] | 106 | * @shutdown: called at device shutdown |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 107 | * @driver: embedded device driver structure |
| 108 | * @name: device driver name |
| 109 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | struct ccw_driver { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 111 | struct module *owner; |
| 112 | struct ccw_device_id *ids; |
| 113 | int (*probe) (struct ccw_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | void (*remove) (struct ccw_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | int (*set_online) (struct ccw_device *); |
| 116 | int (*set_offline) (struct ccw_device *); |
| 117 | int (*notify) (struct ccw_device *, int); |
Cornelia Huck | 958974fb | 2007-10-12 16:11:21 +0200 | [diff] [blame] | 118 | void (*shutdown) (struct ccw_device *); |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 119 | struct device_driver driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | char *name; |
| 121 | }; |
| 122 | |
| 123 | extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv, |
| 124 | const char *bus_id); |
| 125 | |
| 126 | /* devices drivers call these during module load and unload. |
| 127 | * When a driver is registered, its probe method is called |
| 128 | * when new devices for its type pop up */ |
| 129 | extern int ccw_driver_register (struct ccw_driver *driver); |
| 130 | extern void ccw_driver_unregister (struct ccw_driver *driver); |
| 131 | |
| 132 | struct ccw1; |
| 133 | |
Cornelia Huck | 4dd3cc5 | 2007-02-12 15:47:18 +0100 | [diff] [blame] | 134 | extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | extern int ccw_device_set_options(struct ccw_device *, unsigned long); |
Cornelia Huck | 4dd3cc5 | 2007-02-12 15:47:18 +0100 | [diff] [blame] | 136 | extern void ccw_device_clear_options(struct ccw_device *, unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
| 138 | /* Allow for i/o completion notification after primary interrupt status. */ |
| 139 | #define CCWDEV_EARLY_NOTIFICATION 0x0001 |
| 140 | /* Report all interrupt conditions. */ |
| 141 | #define CCWDEV_REPORT_ALL 0x0002 |
| 142 | /* Try to perform path grouping. */ |
| 143 | #define CCWDEV_DO_PATHGROUP 0x0004 |
| 144 | /* Allow forced onlining of boxed devices. */ |
| 145 | #define CCWDEV_ALLOW_FORCE 0x0008 |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | extern int ccw_device_start(struct ccw_device *, struct ccw1 *, |
| 148 | unsigned long, __u8, unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *, |
| 150 | unsigned long, __u8, unsigned long, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *, |
| 152 | unsigned long, __u8, __u8, unsigned long); |
| 153 | extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *, |
| 154 | unsigned long, __u8, __u8, |
| 155 | unsigned long, int); |
| 156 | |
| 157 | |
| 158 | extern int ccw_device_resume(struct ccw_device *); |
| 159 | extern int ccw_device_halt(struct ccw_device *, unsigned long); |
| 160 | extern int ccw_device_clear(struct ccw_device *, unsigned long); |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 161 | int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw, |
| 162 | unsigned long intparm, u8 lpm, u8 key); |
| 163 | int ccw_device_tm_start_key(struct ccw_device *, struct tcw *, |
| 164 | unsigned long, u8, u8); |
| 165 | int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *, |
| 166 | unsigned long, u8, u8, int); |
| 167 | int ccw_device_tm_start(struct ccw_device *, struct tcw *, |
| 168 | unsigned long, u8); |
| 169 | int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *, |
| 170 | unsigned long, u8, int); |
| 171 | int ccw_device_tm_intrg(struct ccw_device *cdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | extern int ccw_device_set_online(struct ccw_device *cdev); |
| 174 | extern int ccw_device_set_offline(struct ccw_device *cdev); |
| 175 | |
| 176 | |
| 177 | extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd); |
| 178 | extern __u8 ccw_device_get_path_mask(struct ccw_device *); |
Cornelia Huck | 9a92fe4 | 2007-05-10 15:45:42 +0200 | [diff] [blame] | 179 | extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
| 181 | #define get_ccwdev_lock(x) (x)->ccwlock |
| 182 | |
| 183 | #define to_ccwdev(n) container_of(n, struct ccw_device, dev) |
| 184 | #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver) |
| 185 | |
| 186 | extern struct ccw_device *ccw_device_probe_console(void); |
| 187 | |
| 188 | // FIXME: these have to go |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | extern int _ccw_device_get_subchannel_number(struct ccw_device *); |
| 190 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | extern void *ccw_device_get_chp_desc(struct ccw_device *, int); |
| 192 | #endif /* _S390_CCWDEV_H_ */ |