ccwdev.h 8.0 KB

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