ccwdev.h 5.8 KB

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