ccwdev.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 CIO actions triggered by the unit check handler.
  83. */
  84. enum uc_todo {
  85. UC_TODO_RETRY,
  86. UC_TODO_RETRY_ON_NEW_PATH,
  87. UC_TODO_STOP
  88. };
  89. /**
  90. * struct ccw driver - device driver for channel attached devices
  91. * @owner: owning module
  92. * @ids: ids supported by this driver
  93. * @probe: function called on probe
  94. * @remove: function called on remove
  95. * @set_online: called when setting device online
  96. * @set_offline: called when setting device offline
  97. * @notify: notify driver of device state changes
  98. * @shutdown: called at device shutdown
  99. * @prepare: prepare for pm state transition
  100. * @complete: undo work done in @prepare
  101. * @freeze: callback for freezing during hibernation snapshotting
  102. * @thaw: undo work done in @freeze
  103. * @restore: callback for restoring after hibernation
  104. * @uc_handler: callback for unit check handler
  105. * @driver: embedded device driver structure
  106. * @name: device driver name
  107. */
  108. struct ccw_driver {
  109. struct module *owner;
  110. struct ccw_device_id *ids;
  111. int (*probe) (struct ccw_device *);
  112. void (*remove) (struct ccw_device *);
  113. int (*set_online) (struct ccw_device *);
  114. int (*set_offline) (struct ccw_device *);
  115. int (*notify) (struct ccw_device *, int);
  116. void (*shutdown) (struct ccw_device *);
  117. int (*prepare) (struct ccw_device *);
  118. void (*complete) (struct ccw_device *);
  119. int (*freeze)(struct ccw_device *);
  120. int (*thaw) (struct ccw_device *);
  121. int (*restore)(struct ccw_device *);
  122. enum uc_todo (*uc_handler) (struct ccw_device *, struct irb *);
  123. struct device_driver driver;
  124. char *name;
  125. };
  126. extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
  127. const char *bus_id);
  128. /* devices drivers call these during module load and unload.
  129. * When a driver is registered, its probe method is called
  130. * when new devices for its type pop up */
  131. extern int ccw_driver_register (struct ccw_driver *driver);
  132. extern void ccw_driver_unregister (struct ccw_driver *driver);
  133. struct ccw1;
  134. extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
  135. extern int ccw_device_set_options(struct ccw_device *, unsigned long);
  136. extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
  137. int ccw_device_is_pathgroup(struct ccw_device *cdev);
  138. int ccw_device_is_multipath(struct ccw_device *cdev);
  139. /* Allow for i/o completion notification after primary interrupt status. */
  140. #define CCWDEV_EARLY_NOTIFICATION 0x0001
  141. /* Report all interrupt conditions. */
  142. #define CCWDEV_REPORT_ALL 0x0002
  143. /* Try to perform path grouping. */
  144. #define CCWDEV_DO_PATHGROUP 0x0004
  145. /* Allow forced onlining of boxed devices. */
  146. #define CCWDEV_ALLOW_FORCE 0x0008
  147. /* Try to use multipath mode. */
  148. #define CCWDEV_DO_MULTIPATH 0x0010
  149. extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
  150. unsigned long, __u8, unsigned long);
  151. extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
  152. unsigned long, __u8, unsigned long, int);
  153. extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
  154. unsigned long, __u8, __u8, unsigned long);
  155. extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
  156. unsigned long, __u8, __u8,
  157. unsigned long, int);
  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);
  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);
  172. extern int ccw_device_set_online(struct ccw_device *cdev);
  173. extern int ccw_device_set_offline(struct ccw_device *cdev);
  174. extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
  175. extern __u8 ccw_device_get_path_mask(struct ccw_device *);
  176. extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
  177. #define get_ccwdev_lock(x) (x)->ccwlock
  178. #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
  179. #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
  180. extern struct ccw_device *ccw_device_probe_console(void);
  181. extern int ccw_device_force_console(void);
  182. int ccw_device_siosl(struct ccw_device *);
  183. // FIXME: these have to go
  184. extern int _ccw_device_get_subchannel_number(struct ccw_device *);
  185. extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
  186. #endif /* _S390_CCWDEV_H_ */