ccwdev.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * include/asm-s390/ccwdev.h
  3. * include/asm-s390x/ccwdev.h
  4. *
  5. * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6. * Author(s): Arnd Bergmann <arndb@de.ibm.com>
  7. *
  8. * Interface for CCW device drivers
  9. */
  10. #ifndef _S390_CCWDEV_H_
  11. #define _S390_CCWDEV_H_
  12. #include <linux/device.h>
  13. #include <linux/mod_devicetable.h>
  14. #include <asm/fcx.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. * struct ccw driver - device driver for channel attached devices
  85. * @owner: owning module
  86. * @ids: ids supported by this driver
  87. * @probe: function called on probe
  88. * @remove: function called on remove
  89. * @set_online: called when setting device online
  90. * @set_offline: called when setting device offline
  91. * @notify: notify driver of device state changes
  92. * @shutdown: called at device shutdown
  93. * @driver: embedded device driver structure
  94. * @name: device driver name
  95. */
  96. struct ccw_driver {
  97. struct module *owner;
  98. struct ccw_device_id *ids;
  99. int (*probe) (struct ccw_device *);
  100. void (*remove) (struct ccw_device *);
  101. int (*set_online) (struct ccw_device *);
  102. int (*set_offline) (struct ccw_device *);
  103. int (*notify) (struct ccw_device *, int);
  104. void (*shutdown) (struct ccw_device *);
  105. struct device_driver driver;
  106. char *name;
  107. };
  108. extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
  109. const char *bus_id);
  110. /* devices drivers call these during module load and unload.
  111. * When a driver is registered, its probe method is called
  112. * when new devices for its type pop up */
  113. extern int ccw_driver_register (struct ccw_driver *driver);
  114. extern void ccw_driver_unregister (struct ccw_driver *driver);
  115. struct ccw1;
  116. extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
  117. extern int ccw_device_set_options(struct ccw_device *, unsigned long);
  118. extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
  119. /* Allow for i/o completion notification after primary interrupt status. */
  120. #define CCWDEV_EARLY_NOTIFICATION 0x0001
  121. /* Report all interrupt conditions. */
  122. #define CCWDEV_REPORT_ALL 0x0002
  123. /* Try to perform path grouping. */
  124. #define CCWDEV_DO_PATHGROUP 0x0004
  125. /* Allow forced onlining of boxed devices. */
  126. #define CCWDEV_ALLOW_FORCE 0x0008
  127. extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
  128. unsigned long, __u8, unsigned long);
  129. extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
  130. unsigned long, __u8, unsigned long, int);
  131. extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
  132. unsigned long, __u8, __u8, unsigned long);
  133. extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
  134. unsigned long, __u8, __u8,
  135. unsigned long, int);
  136. extern int ccw_device_resume(struct ccw_device *);
  137. extern int ccw_device_halt(struct ccw_device *, unsigned long);
  138. extern int ccw_device_clear(struct ccw_device *, unsigned long);
  139. int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
  140. unsigned long intparm, u8 lpm, u8 key);
  141. int ccw_device_tm_start_key(struct ccw_device *, struct tcw *,
  142. unsigned long, u8, u8);
  143. int ccw_device_tm_start_timeout_key(struct ccw_device *, struct tcw *,
  144. unsigned long, u8, u8, int);
  145. int ccw_device_tm_start(struct ccw_device *, struct tcw *,
  146. unsigned long, u8);
  147. int ccw_device_tm_start_timeout(struct ccw_device *, struct tcw *,
  148. unsigned long, u8, int);
  149. int ccw_device_tm_intrg(struct ccw_device *cdev);
  150. extern int ccw_device_set_online(struct ccw_device *cdev);
  151. extern int ccw_device_set_offline(struct ccw_device *cdev);
  152. extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
  153. extern __u8 ccw_device_get_path_mask(struct ccw_device *);
  154. extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
  155. #define get_ccwdev_lock(x) (x)->ccwlock
  156. #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
  157. #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
  158. extern struct ccw_device *ccw_device_probe_console(void);
  159. // FIXME: these have to go
  160. extern int _ccw_device_get_subchannel_number(struct ccw_device *);
  161. extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
  162. #endif /* _S390_CCWDEV_H_ */