ccwdev.h 6.8 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. /* 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. /* The struct ccw device is our replacement for the globally accessible
  59. * ioinfo array. ioinfo will mutate into a subchannel device later.
  60. *
  61. * Reference: Documentation/s390/driver-model.txt */
  62. struct ccw_device {
  63. spinlock_t *ccwlock;
  64. struct ccw_device_private *private; /* cio private information */
  65. struct ccw_device_id id; /* id of this device, driver_info is
  66. set by ccw_find_driver */
  67. struct ccw_driver *drv; /* */
  68. struct device dev; /* */
  69. int online;
  70. /* This is sick, but a driver can have different interrupt handlers
  71. for different ccw_devices (multi-subchannel drivers)... */
  72. void (*handler) (struct ccw_device *, unsigned long, struct irb *);
  73. };
  74. /* Each ccw driver registers with the ccw root bus */
  75. struct ccw_driver {
  76. struct module *owner; /* for automatic MOD_INC_USE_COUNT */
  77. struct ccw_device_id *ids; /* probe driver with these devs */
  78. int (*probe) (struct ccw_device *); /* ask driver to probe dev */
  79. void (*remove) (struct ccw_device *);
  80. /* device is no longer available */
  81. int (*set_online) (struct ccw_device *);
  82. int (*set_offline) (struct ccw_device *);
  83. int (*notify) (struct ccw_device *, int);
  84. struct device_driver driver; /* higher level structure, don't init
  85. this from your driver */
  86. char *name;
  87. };
  88. extern struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
  89. const char *bus_id);
  90. /* devices drivers call these during module load and unload.
  91. * When a driver is registered, its probe method is called
  92. * when new devices for its type pop up */
  93. extern int ccw_driver_register (struct ccw_driver *driver);
  94. extern void ccw_driver_unregister (struct ccw_driver *driver);
  95. struct ccw1;
  96. extern int ccw_device_set_options_mask(struct ccw_device *, unsigned long);
  97. extern int ccw_device_set_options(struct ccw_device *, unsigned long);
  98. extern void ccw_device_clear_options(struct ccw_device *, unsigned long);
  99. /* Allow for i/o completion notification after primary interrupt status. */
  100. #define CCWDEV_EARLY_NOTIFICATION 0x0001
  101. /* Report all interrupt conditions. */
  102. #define CCWDEV_REPORT_ALL 0x0002
  103. /* Try to perform path grouping. */
  104. #define CCWDEV_DO_PATHGROUP 0x0004
  105. /* Allow forced onlining of boxed devices. */
  106. #define CCWDEV_ALLOW_FORCE 0x0008
  107. /*
  108. * ccw_device_start()
  109. *
  110. * Start a S/390 channel program. When the interrupt arrives, the
  111. * IRQ handler is called, either immediately, delayed (dev-end missing,
  112. * or sense required) or never (no IRQ handler registered).
  113. * Depending on the action taken, ccw_device_start() returns:
  114. * 0 - Success
  115. * -EBUSY - Device busy, or status pending
  116. * -ENODEV - Device not operational
  117. * -EINVAL - Device invalid for operation
  118. */
  119. extern int ccw_device_start(struct ccw_device *, struct ccw1 *,
  120. unsigned long, __u8, unsigned long);
  121. /*
  122. * ccw_device_start_timeout()
  123. *
  124. * This function notifies the device driver if the channel program has not
  125. * completed during the specified time. If a timeout occurs, the channel
  126. * program is terminated via xsch(), hsch() or csch().
  127. */
  128. extern int ccw_device_start_timeout(struct ccw_device *, struct ccw1 *,
  129. unsigned long, __u8, unsigned long, int);
  130. /*
  131. * ccw_device_start_key()
  132. * ccw_device_start_key_timeout()
  133. *
  134. * Same as ccw_device_start() and ccw_device_start_timeout(), except a
  135. * storage key != default key can be provided for the I/O.
  136. */
  137. extern int ccw_device_start_key(struct ccw_device *, struct ccw1 *,
  138. unsigned long, __u8, __u8, unsigned long);
  139. extern int ccw_device_start_timeout_key(struct ccw_device *, struct ccw1 *,
  140. unsigned long, __u8, __u8,
  141. unsigned long, int);
  142. extern int ccw_device_resume(struct ccw_device *);
  143. extern int ccw_device_halt(struct ccw_device *, unsigned long);
  144. extern int ccw_device_clear(struct ccw_device *, unsigned long);
  145. extern int __deprecated read_dev_chars(struct ccw_device *cdev, void **buffer, int length);
  146. extern int __deprecated read_conf_data(struct ccw_device *cdev, void **buffer, int *length);
  147. extern int __deprecated read_conf_data_lpm(struct ccw_device *cdev, void **buffer,
  148. int *length, __u8 lpm);
  149. extern int ccw_device_set_online(struct ccw_device *cdev);
  150. extern int ccw_device_set_offline(struct ccw_device *cdev);
  151. extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
  152. extern __u8 ccw_device_get_path_mask(struct ccw_device *);
  153. extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
  154. #define get_ccwdev_lock(x) (x)->ccwlock
  155. #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
  156. #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
  157. extern struct ccw_device *ccw_device_probe_console(void);
  158. // FIXME: these have to go
  159. extern int _ccw_device_get_subchannel_number(struct ccw_device *);
  160. extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
  161. #endif /* _S390_CCWDEV_H_ */