scsi_transport_spi.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
  4. *
  5. * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
  6. */
  7. #ifndef SCSI_TRANSPORT_SPI_H
  8. #define SCSI_TRANSPORT_SPI_H
  9. #include <linux/transport_class.h>
  10. #include <linux/mutex.h>
  11. struct scsi_transport_template;
  12. struct scsi_target;
  13. struct scsi_device;
  14. struct Scsi_Host;
  15. struct spi_transport_attrs {
  16. int period; /* value in the PPR/SDTR command */
  17. int min_period;
  18. int offset;
  19. int max_offset;
  20. unsigned int width:1; /* 0 - narrow, 1 - wide */
  21. unsigned int max_width:1;
  22. unsigned int iu:1; /* Information Units enabled */
  23. unsigned int max_iu:1;
  24. unsigned int dt:1; /* DT clocking enabled */
  25. unsigned int qas:1; /* Quick Arbitration and Selection enabled */
  26. unsigned int max_qas:1;
  27. unsigned int wr_flow:1; /* Write Flow control enabled */
  28. unsigned int rd_strm:1; /* Read streaming enabled */
  29. unsigned int rti:1; /* Retain Training Information */
  30. unsigned int pcomp_en:1;/* Precompensation enabled */
  31. unsigned int hold_mcs:1;/* Hold Margin Control Settings */
  32. unsigned int initial_dv:1; /* DV done to this target yet */
  33. unsigned long flags; /* flags field for drivers to use */
  34. /* Device Properties fields */
  35. unsigned int support_sync:1; /* synchronous support */
  36. unsigned int support_wide:1; /* wide support */
  37. unsigned int support_dt:1; /* allows DT phases */
  38. unsigned int support_dt_only; /* disallows ST phases */
  39. unsigned int support_ius; /* support Information Units */
  40. unsigned int support_qas; /* supports quick arbitration and selection */
  41. /* Private Fields */
  42. unsigned int dv_pending:1; /* Internal flag: DV Requested */
  43. unsigned int dv_in_progress:1; /* Internal: DV started */
  44. struct mutex dv_mutex; /* semaphore to serialise dv */
  45. };
  46. enum spi_signal_type {
  47. SPI_SIGNAL_UNKNOWN = 1,
  48. SPI_SIGNAL_SE,
  49. SPI_SIGNAL_LVD,
  50. SPI_SIGNAL_HVD,
  51. };
  52. struct spi_host_attrs {
  53. enum spi_signal_type signalling;
  54. };
  55. /* accessor functions */
  56. #define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period)
  57. #define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period)
  58. #define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset)
  59. #define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset)
  60. #define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width)
  61. #define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width)
  62. #define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu)
  63. #define spi_max_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_iu)
  64. #define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt)
  65. #define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
  66. #define spi_max_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_qas)
  67. #define spi_wr_flow(x) (((struct spi_transport_attrs *)&(x)->starget_data)->wr_flow)
  68. #define spi_rd_strm(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm)
  69. #define spi_rti(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rti)
  70. #define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en)
  71. #define spi_hold_mcs(x) (((struct spi_transport_attrs *)&(x)->starget_data)->hold_mcs)
  72. #define spi_initial_dv(x) (((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv)
  73. #define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
  74. #define spi_support_sync(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_sync)
  75. #define spi_support_wide(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_wide)
  76. #define spi_support_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt)
  77. #define spi_support_dt_only(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt_only)
  78. #define spi_support_ius(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_ius)
  79. #define spi_support_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_qas)
  80. #define spi_flags(x) (((struct spi_transport_attrs *)&(x)->starget_data)->flags)
  81. #define spi_signalling(h) (((struct spi_host_attrs *)(h)->shost_data)->signalling)
  82. /* The functions by which the transport class and the driver communicate */
  83. struct spi_function_template {
  84. void (*get_period)(struct scsi_target *);
  85. void (*set_period)(struct scsi_target *, int);
  86. void (*get_offset)(struct scsi_target *);
  87. void (*set_offset)(struct scsi_target *, int);
  88. void (*get_width)(struct scsi_target *);
  89. void (*set_width)(struct scsi_target *, int);
  90. void (*get_iu)(struct scsi_target *);
  91. void (*set_iu)(struct scsi_target *, int);
  92. void (*get_dt)(struct scsi_target *);
  93. void (*set_dt)(struct scsi_target *, int);
  94. void (*get_qas)(struct scsi_target *);
  95. void (*set_qas)(struct scsi_target *, int);
  96. void (*get_wr_flow)(struct scsi_target *);
  97. void (*set_wr_flow)(struct scsi_target *, int);
  98. void (*get_rd_strm)(struct scsi_target *);
  99. void (*set_rd_strm)(struct scsi_target *, int);
  100. void (*get_rti)(struct scsi_target *);
  101. void (*set_rti)(struct scsi_target *, int);
  102. void (*get_pcomp_en)(struct scsi_target *);
  103. void (*set_pcomp_en)(struct scsi_target *, int);
  104. void (*get_hold_mcs)(struct scsi_target *);
  105. void (*set_hold_mcs)(struct scsi_target *, int);
  106. void (*get_signalling)(struct Scsi_Host *);
  107. void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type);
  108. int (*deny_binding)(struct scsi_target *);
  109. /* The driver sets these to tell the transport class it
  110. * wants the attributes displayed in sysfs. If the show_ flag
  111. * is not set, the attribute will be private to the transport
  112. * class */
  113. unsigned long show_period:1;
  114. unsigned long show_offset:1;
  115. unsigned long show_width:1;
  116. unsigned long show_iu:1;
  117. unsigned long show_dt:1;
  118. unsigned long show_qas:1;
  119. unsigned long show_wr_flow:1;
  120. unsigned long show_rd_strm:1;
  121. unsigned long show_rti:1;
  122. unsigned long show_pcomp_en:1;
  123. unsigned long show_hold_mcs:1;
  124. };
  125. struct scsi_transport_template *spi_attach_transport(struct spi_function_template *);
  126. void spi_release_transport(struct scsi_transport_template *);
  127. void spi_schedule_dv_device(struct scsi_device *);
  128. void spi_dv_device(struct scsi_device *);
  129. void spi_display_xfer_agreement(struct scsi_target *);
  130. int spi_print_msg(const unsigned char *);
  131. int spi_populate_width_msg(unsigned char *msg, int width);
  132. int spi_populate_sync_msg(unsigned char *msg, int period, int offset);
  133. int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width,
  134. int options);
  135. int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd);
  136. #endif /* SCSI_TRANSPORT_SPI_H */