ccwdev.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * Copyright IBM Corp. 2002, 2009
  3. *
  4. * Author(s): Arnd Bergmann <arndb@de.ibm.com>
  5. *
  6. * Interface for CCW device drivers
  7. */
  8. #ifndef _S390_CCWDEV_H_
  9. #define _S390_CCWDEV_H_
  10. #include <linux/device.h>
  11. #include <linux/mod_devicetable.h>
  12. #include <asm/fcx.h>
  13. /* structs from asm/cio.h */
  14. struct irb;
  15. struct ccw1;
  16. struct ccw_dev_id;
  17. /* simplified initializers for struct ccw_device:
  18. * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
  19. * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
  20. #define CCW_DEVICE(cu, cum) \
  21. .cu_type=(cu), .cu_model=(cum), \
  22. .match_flags=(CCW_DEVICE_ID_MATCH_CU_TYPE \
  23. | (cum ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0))
  24. #define CCW_DEVICE_DEVTYPE(cu, cum, dev, devm) \
  25. .cu_type=(cu), .cu_model=(cum), .dev_type=(dev), .dev_model=(devm),\
  26. .match_flags=CCW_DEVICE_ID_MATCH_CU_TYPE \
  27. | ((cum) ? CCW_DEVICE_ID_MATCH_CU_MODEL : 0) \
  28. | CCW_DEVICE_ID_MATCH_DEVICE_TYPE \
  29. | ((devm) ? CCW_DEVICE_ID_MATCH_DEVICE_MODEL : 0)
  30. /* scan through an array of device ids and return the first
  31. * entry that matches the device.
  32. *
  33. * the array must end with an entry containing zero match_flags
  34. */
  35. static inline const struct ccw_device_id *
  36. ccw_device_id_match(const struct ccw_device_id *array,
  37. const struct ccw_device_id *match)
  38. {
  39. const struct ccw_device_id *id = array;
  40. for (id = array; id->match_flags; id++) {
  41. if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_TYPE)
  42. && (id->cu_type != match->cu_type))
  43. continue;
  44. if ((id->match_flags & CCW_DEVICE_ID_MATCH_CU_MODEL)
  45. && (id->cu_model != match->cu_model))
  46. continue;
  47. if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_TYPE)
  48. && (id->dev_type != match->dev_type))
  49. continue;
  50. if ((id->match_flags & CCW_DEVICE_ID_MATCH_DEVICE_MODEL)
  51. && (id->dev_model != match->dev_model))
  52. continue;
  53. return id;
  54. }
  55. return NULL;
  56. }
  57. /**
  58. * struct ccw_device - channel attached device
  59. * @ccwlock: pointer to device lock
  60. * @id: id of this device
  61. * @drv: ccw driver for this device
  62. * @dev: embedded device structure
  63. * @online: online status of device
  64. * @handler: interrupt handler
  65. *
  66. * @handler is a member of the device rather than the driver since a driver
  67. * can have different interrupt handlers for different ccw devices
  68. * (multi-subchannel drivers).
  69. */
  70. struct ccw_device {
  71. spinlock_t *ccwlock;
  72. /* private: */
  73. struct ccw_device_private *private; /* cio private information */
  74. /* public: */
  75. struct ccw_device_id id;
  76. struct ccw_driver *drv;
  77. struct device dev;
  78. int online;
  79. void (*handler) (struct ccw_device *, unsigned long, struct irb *);
  80. };
  81. /*
  82. * Possible events used by the path_event notifier.
  83. */
  84. #define PE_NONE 0x0
  85. #define PE_PATH_GONE 0x1 /* A path is no longer available. */
  86. #define PE_PATH_AVAILABLE 0x2 /* A path has become available and
  87. was successfully verified. */
  88. #define PE_PATHGROUP_ESTABLISHED 0x4 /* A pathgroup was reset and had
  89. to be established again. */
  90. /*
  91. * Possible CIO actions triggered by the unit check handler.
  92. */
  93. enum uc_todo {
  94. UC_TODO_RETRY,
  95. UC_TODO_RETRY_ON_NEW_PATH,
  96. UC_TODO_STOP
  97. };
  98. /**
  99. * struct ccw driver - device driver for channel attached devices
  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
  106. * @path_event: notify driver of channel path events
  107. * @shutdown: called at device shutdown
  108. * @prepare: prepare for pm state transition
  109. * @complete: undo work done in @prepare
  110. * @freeze: callback for freezing during hibernation snapshotting
  111. * @thaw: undo work done in @freeze
  112. * @restore: callback for restoring after hibernation
  113. * @uc_handler: callback for unit check handler
  114. * @driver: embedded device driver structure
  115. */
  116. struct ccw_driver {
  117. struct ccw_device_id *ids;
  118. int (*probe) (struct ccw_device *);
  119. void (*remove) (struct ccw_device *);
  120. int (*set_online) (struct ccw_device *);
  121. int (*set_offline) (struct ccw_device *);
  122. int (*notify) (struct ccw_device *, int);
  123. void (*path_event) (struct ccw_device *, int *);
  124. void (*shutdown) (struct ccw_device *);
  125. int (*prepare) (struct ccw_device *);
  126. void (*complete) (struct ccw_device *);
  127. int (*freeze)(struct ccw_device *);
  128. int (*thaw) (struct ccw_device *);
  129. int (*restore)(struct ccw_device *);
  130. enum uc_todo (*uc_handler) (struct ccw_device *, struct irb *);
  131. struct device_driver driver;
  132. };
  133. extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
  134. const char *bus_id);
  135. /* devices drivers call these during module load and unload.
  136. * When a driver is registered, its probe method is called
  137. * when new devices for its type pop up */
  138. extern int ccw_driver_register (struct ccw_driver *driver);
  139. extern void ccw_driver_unregister (struct ccw_driver *driver);
  140. struct ccw1;
  141. extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
  142. extern int ccw_device_set_options(struct ccw_device *, unsigned long);
  143. extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
  144. int ccw_device_is_pathgroup(struct ccw_device *cdev);
  145. int ccw_device_is_multipath(struct ccw_device *cdev);
  146. /* Allow for i/o completion notification after primary interrupt status. */
  147. #define CCWDEV_EARLY_NOTIFICATION 0x0001
  148. /* Report all interrupt conditions. */
  149. #define CCWDEV_REPORT_ALL 0x0002
  150. /* Try to perform path grouping. */
  151. #define CCWDEV_DO_PATHGROUP 0x0004
  152. /* Allow forced onlining of boxed devices. */
  153. #define CCWDEV_ALLOW_FORCE 0x0008
  154. /* Try to use multipath mode. */
  155. #define CCWDEV_DO_MULTIPATH 0x0010
  156. extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
  157. unsigned long, __u8, unsigned long);
  158. extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
  159. unsigned long, __u8, unsigned long, int);
  160. extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
  161. unsigned long, __u8, __u8, unsigned long);
  162. extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
  163. unsigned long, __u8, __u8,
  164. unsigned long, int);
  165. extern int ccw_device_resume(struct ccw_device *);
  166. extern int ccw_device_halt(struct ccw_device *, unsigned long);
  167. extern int ccw_device_clear(struct ccw_device *, unsigned long);
  168. int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
  169. unsigned long intparm, u8 lpm, u8 key);
  170. int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
  171. unsigned long, u8, u8);
  172. int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
  173. unsigned long, u8, u8, int);
  174. int ccw_device_tm_start(struct ccw_device *, struct tcw *,
  175. unsigned long, u8);
  176. int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
  177. unsigned long, u8, int);
  178. int ccw_device_tm_intrg(struct ccw_device *cdev);
  179. int ccw_device_get_mdc(struct ccw_device *cdev, u8 mask);
  180. extern int ccw_device_set_online(struct ccw_device *cdev);
  181. extern int ccw_device_set_offline(struct ccw_device *cdev);
  182. extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
  183. extern __u8 ccw_device_get_path_mask(struct ccw_device *);
  184. extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
  185. #define get_ccwdev_lock(x) (x)->ccwlock
  186. #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
  187. #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
  188. extern struct ccw_device *ccw_device_probe_console(void);
  189. extern int ccw_device_force_console(void);
  190. int ccw_device_siosl(struct ccw_device *);
  191. // FIXME: these have to go
  192. extern int _ccw_device_get_subchannel_number(struct ccw_device *);
  193. extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
  194. #endif /* _S390_CCWDEV_H_ */