ccwdev.h 6.5 KB

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