ccwdev.h 7.7 KB

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