ccwdev.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. * struct ccw driver - device driver for channel attached devices
  83. * @owner: owning module
  84. * @ids: ids supported by this driver
  85. * @probe: function called on probe
  86. * @remove: function called on remove
  87. * @set_online: called when setting device online
  88. * @set_offline: called when setting device offline
  89. * @notify: notify driver of device state changes
  90. * @shutdown: called at device shutdown
  91. * @prepare: prepare for pm state transition
  92. * @complete: undo work done in @prepare
  93. * @freeze: callback for freezing during hibernation snapshotting
  94. * @thaw: undo work done in @freeze
  95. * @restore: callback for restoring after hibernation
  96. * @driver: embedded device driver structure
  97. * @name: device driver name
  98. */
  99. struct ccw_driver {
  100. struct module *owner;
  101. struct ccw_device_id *ids;
  102. int (*probe) (struct ccw_device *);
  103. void (*remove) (struct ccw_device *);
  104. int (*set_online) (struct ccw_device *);
  105. int (*set_offline) (struct ccw_device *);
  106. int (*notify) (struct ccw_device *, int);
  107. void (*shutdown) (struct ccw_device *);
  108. int (*prepare) (struct ccw_device *);
  109. void (*complete) (struct ccw_device *);
  110. int (*freeze)(struct ccw_device *);
  111. int (*thaw) (struct ccw_device *);
  112. int (*restore)(struct ccw_device *);
  113. struct device_driver driver;
  114. char *name;
  115. };
  116. extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
  117. const char *bus_id);
  118. /* devices drivers call these during module load and unload.
  119. * When a driver is registered, its probe method is called
  120. * when new devices for its type pop up */
  121. extern int ccw_driver_register (struct ccw_driver *driver);
  122. extern void ccw_driver_unregister (struct ccw_driver *driver);
  123. struct ccw1;
  124. extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
  125. extern int ccw_device_set_options(struct ccw_device *, unsigned long);
  126. extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
  127. /* Allow for i/o completion notification after primary interrupt status. */
  128. #define CCWDEV_EARLY_NOTIFICATION 0x0001
  129. /* Report all interrupt conditions. */
  130. #define CCWDEV_REPORT_ALL 0x0002
  131. /* Try to perform path grouping. */
  132. #define CCWDEV_DO_PATHGROUP 0x0004
  133. /* Allow forced onlining of boxed devices. */
  134. #define CCWDEV_ALLOW_FORCE 0x0008
  135. extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
  136. unsigned long, __u8, unsigned long);
  137. extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
  138. unsigned long, __u8, unsigned long, int);
  139. extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
  140. unsigned long, __u8, __u8, unsigned long);
  141. extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
  142. unsigned long, __u8, __u8,
  143. unsigned long, int);
  144. extern int ccw_device_resume(struct ccw_device *);
  145. extern int ccw_device_halt(struct ccw_device *, unsigned long);
  146. extern int ccw_device_clear(struct ccw_device *, unsigned long);
  147. int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
  148. unsigned long intparm, u8 lpm, u8 key);
  149. int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
  150. unsigned long, u8, u8);
  151. int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
  152. unsigned long, u8, u8, int);
  153. int ccw_device_tm_start(struct ccw_device *, struct tcw *,
  154. unsigned long, u8);
  155. int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
  156. unsigned long, u8, int);
  157. int ccw_device_tm_intrg(struct ccw_device *cdev);
  158. extern int ccw_device_set_online(struct ccw_device *cdev);
  159. extern int ccw_device_set_offline(struct ccw_device *cdev);
  160. extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
  161. extern __u8 ccw_device_get_path_mask(struct ccw_device *);
  162. extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
  163. #define get_ccwdev_lock(x) (x)->ccwlock
  164. #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
  165. #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
  166. extern struct ccw_device *ccw_device_probe_console(void);
  167. extern int ccw_device_force_console(void);
  168. // FIXME: these have to go
  169. extern int _ccw_device_get_subchannel_number(struct ccw_device *);
  170. extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
  171. #endif /* _S390_CCWDEV_H_ */