Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Parallel SCSI (SPI) transport specific attributes exported to sysfs. |
| 3 | * |
| 4 | * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef SCSI_TRANSPORT_SPI_H |
| 21 | #define SCSI_TRANSPORT_SPI_H |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/transport_class.h> |
Andrew Morton | c8d338c | 2006-01-18 17:42:22 -0800 | [diff] [blame] | 24 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | struct scsi_transport_template; |
Matthew Wilcox | 829b846 | 2005-12-13 10:29:31 -0700 | [diff] [blame] | 27 | struct scsi_target; |
| 28 | struct scsi_device; |
| 29 | struct Scsi_Host; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | struct spi_transport_attrs { |
| 32 | int period; /* value in the PPR/SDTR command */ |
James Bottomley | 62a8612 | 2005-05-06 18:05:20 -0500 | [diff] [blame] | 33 | int min_period; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | int offset; |
James Bottomley | 62a8612 | 2005-05-06 18:05:20 -0500 | [diff] [blame] | 35 | int max_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | unsigned int width:1; /* 0 - narrow, 1 - wide */ |
James Bottomley | 62a8612 | 2005-05-06 18:05:20 -0500 | [diff] [blame] | 37 | unsigned int max_width:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | unsigned int iu:1; /* Information Units enabled */ |
James Bottomley | ea44319 | 2009-06-13 12:19:05 -0500 | [diff] [blame] | 39 | unsigned int max_iu:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | unsigned int dt:1; /* DT clocking enabled */ |
| 41 | unsigned int qas:1; /* Quick Arbitration and Selection enabled */ |
James Bottomley | ea44319 | 2009-06-13 12:19:05 -0500 | [diff] [blame] | 42 | unsigned int max_qas:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | unsigned int wr_flow:1; /* Write Flow control enabled */ |
| 44 | unsigned int rd_strm:1; /* Read streaming enabled */ |
| 45 | unsigned int rti:1; /* Retain Training Information */ |
| 46 | unsigned int pcomp_en:1;/* Precompensation enabled */ |
James Bottomley | d872ebe | 2005-08-03 15:43:52 -0500 | [diff] [blame] | 47 | unsigned int hold_mcs:1;/* Hold Margin Control Settings */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | unsigned int initial_dv:1; /* DV done to this target yet */ |
| 49 | unsigned long flags; /* flags field for drivers to use */ |
| 50 | /* Device Properties fields */ |
| 51 | unsigned int support_sync:1; /* synchronous support */ |
| 52 | unsigned int support_wide:1; /* wide support */ |
| 53 | unsigned int support_dt:1; /* allows DT phases */ |
| 54 | unsigned int support_dt_only; /* disallows ST phases */ |
| 55 | unsigned int support_ius; /* support Information Units */ |
| 56 | unsigned int support_qas; /* supports quick arbitration and selection */ |
| 57 | /* Private Fields */ |
James Bottomley | dfdc58b | 2006-09-20 12:00:18 -0400 | [diff] [blame] | 58 | unsigned int dv_pending:1; /* Internal flag: DV Requested */ |
| 59 | unsigned int dv_in_progress:1; /* Internal: DV started */ |
Jes Sorensen | d158d26 | 2006-01-13 16:05:44 -0800 | [diff] [blame] | 60 | struct mutex dv_mutex; /* semaphore to serialise dv */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | enum spi_signal_type { |
| 64 | SPI_SIGNAL_UNKNOWN = 1, |
| 65 | SPI_SIGNAL_SE, |
| 66 | SPI_SIGNAL_LVD, |
| 67 | SPI_SIGNAL_HVD, |
| 68 | }; |
| 69 | |
| 70 | struct spi_host_attrs { |
| 71 | enum spi_signal_type signalling; |
| 72 | }; |
| 73 | |
| 74 | /* accessor functions */ |
| 75 | #define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period) |
James Bottomley | 62a8612 | 2005-05-06 18:05:20 -0500 | [diff] [blame] | 76 | #define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset) |
James Bottomley | 62a8612 | 2005-05-06 18:05:20 -0500 | [diff] [blame] | 78 | #define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | #define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width) |
James Bottomley | 62a8612 | 2005-05-06 18:05:20 -0500 | [diff] [blame] | 80 | #define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | #define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu) |
James Bottomley | ea44319 | 2009-06-13 12:19:05 -0500 | [diff] [blame] | 82 | #define spi_max_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_iu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt) |
| 84 | #define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas) |
James Bottomley | ea44319 | 2009-06-13 12:19:05 -0500 | [diff] [blame] | 85 | #define spi_max_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_qas) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | #define spi_wr_flow(x) (((struct spi_transport_attrs *)&(x)->starget_data)->wr_flow) |
| 87 | #define spi_rd_strm(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm) |
| 88 | #define spi_rti(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rti) |
| 89 | #define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en) |
James Bottomley | d872ebe | 2005-08-03 15:43:52 -0500 | [diff] [blame] | 90 | #define spi_hold_mcs(x) (((struct spi_transport_attrs *)&(x)->starget_data)->hold_mcs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #define spi_initial_dv(x) (((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv) |
Eric Moore | 502c62f | 2007-01-29 09:41:12 -0700 | [diff] [blame] | 92 | #define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | #define spi_support_sync(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_sync) |
| 95 | #define spi_support_wide(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_wide) |
| 96 | #define spi_support_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt) |
| 97 | #define spi_support_dt_only(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt_only) |
| 98 | #define spi_support_ius(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_ius) |
| 99 | #define spi_support_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_qas) |
| 100 | |
| 101 | #define spi_flags(x) (((struct spi_transport_attrs *)&(x)->starget_data)->flags) |
| 102 | #define spi_signalling(h) (((struct spi_host_attrs *)(h)->shost_data)->signalling) |
| 103 | |
| 104 | |
| 105 | |
| 106 | /* The functions by which the transport class and the driver communicate */ |
| 107 | struct spi_function_template { |
| 108 | void (*get_period)(struct scsi_target *); |
| 109 | void (*set_period)(struct scsi_target *, int); |
| 110 | void (*get_offset)(struct scsi_target *); |
| 111 | void (*set_offset)(struct scsi_target *, int); |
| 112 | void (*get_width)(struct scsi_target *); |
| 113 | void (*set_width)(struct scsi_target *, int); |
| 114 | void (*get_iu)(struct scsi_target *); |
| 115 | void (*set_iu)(struct scsi_target *, int); |
| 116 | void (*get_dt)(struct scsi_target *); |
| 117 | void (*set_dt)(struct scsi_target *, int); |
| 118 | void (*get_qas)(struct scsi_target *); |
| 119 | void (*set_qas)(struct scsi_target *, int); |
| 120 | void (*get_wr_flow)(struct scsi_target *); |
| 121 | void (*set_wr_flow)(struct scsi_target *, int); |
| 122 | void (*get_rd_strm)(struct scsi_target *); |
| 123 | void (*set_rd_strm)(struct scsi_target *, int); |
| 124 | void (*get_rti)(struct scsi_target *); |
| 125 | void (*set_rti)(struct scsi_target *, int); |
| 126 | void (*get_pcomp_en)(struct scsi_target *); |
| 127 | void (*set_pcomp_en)(struct scsi_target *, int); |
James Bottomley | d872ebe | 2005-08-03 15:43:52 -0500 | [diff] [blame] | 128 | void (*get_hold_mcs)(struct scsi_target *); |
| 129 | void (*set_hold_mcs)(struct scsi_target *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | void (*get_signalling)(struct Scsi_Host *); |
| 131 | void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type); |
James Bottomley | 10c1b88 | 2005-08-14 14:34:06 -0500 | [diff] [blame] | 132 | int (*deny_binding)(struct scsi_target *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | /* The driver sets these to tell the transport class it |
| 134 | * wants the attributes displayed in sysfs. If the show_ flag |
| 135 | * is not set, the attribute will be private to the transport |
| 136 | * class */ |
| 137 | unsigned long show_period:1; |
| 138 | unsigned long show_offset:1; |
| 139 | unsigned long show_width:1; |
| 140 | unsigned long show_iu:1; |
| 141 | unsigned long show_dt:1; |
| 142 | unsigned long show_qas:1; |
| 143 | unsigned long show_wr_flow:1; |
| 144 | unsigned long show_rd_strm:1; |
| 145 | unsigned long show_rti:1; |
| 146 | unsigned long show_pcomp_en:1; |
James Bottomley | d872ebe | 2005-08-03 15:43:52 -0500 | [diff] [blame] | 147 | unsigned long show_hold_mcs:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | struct scsi_transport_template *spi_attach_transport(struct spi_function_template *); |
| 151 | void spi_release_transport(struct scsi_transport_template *); |
| 152 | void spi_schedule_dv_device(struct scsi_device *); |
| 153 | void spi_dv_device(struct scsi_device *); |
| 154 | void spi_display_xfer_agreement(struct scsi_target *); |
Matthew Wilcox | 1abfd37 | 2005-12-15 16:22:01 -0500 | [diff] [blame] | 155 | int spi_print_msg(const unsigned char *); |
Matthew Wilcox | 6ea3c0b | 2006-02-07 07:54:46 -0700 | [diff] [blame] | 156 | int spi_populate_width_msg(unsigned char *msg, int width); |
| 157 | int spi_populate_sync_msg(unsigned char *msg, int period, int offset); |
| 158 | int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width, |
| 159 | int options); |
Christoph Hellwig | 5066863 | 2014-10-30 14:30:06 +0100 | [diff] [blame] | 160 | int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | #endif /* SCSI_TRANSPORT_SPI_H */ |