blob: da180f738477ef23040d68549c953969e7c524ff [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/transport_class.h>
Andrew Mortonc8d338c2006-01-18 17:42:22 -080024#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26struct scsi_transport_template;
Matthew Wilcox829b8462005-12-13 10:29:31 -070027struct scsi_target;
28struct scsi_device;
29struct Scsi_Host;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31struct spi_transport_attrs {
32 int period; /* value in the PPR/SDTR command */
James Bottomley 62a86122005-05-06 18:05:20 -050033 int min_period;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 int offset;
James Bottomley 62a86122005-05-06 18:05:20 -050035 int max_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 unsigned int width:1; /* 0 - narrow, 1 - wide */
James Bottomley 62a86122005-05-06 18:05:20 -050037 unsigned int max_width:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 unsigned int iu:1; /* Information Units enabled */
39 unsigned int dt:1; /* DT clocking enabled */
40 unsigned int qas:1; /* Quick Arbitration and Selection enabled */
41 unsigned int wr_flow:1; /* Write Flow control enabled */
42 unsigned int rd_strm:1; /* Read streaming enabled */
43 unsigned int rti:1; /* Retain Training Information */
44 unsigned int pcomp_en:1;/* Precompensation enabled */
James Bottomleyd872ebe2005-08-03 15:43:52 -050045 unsigned int hold_mcs:1;/* Hold Margin Control Settings */
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 unsigned int initial_dv:1; /* DV done to this target yet */
47 unsigned long flags; /* flags field for drivers to use */
48 /* Device Properties fields */
49 unsigned int support_sync:1; /* synchronous support */
50 unsigned int support_wide:1; /* wide support */
51 unsigned int support_dt:1; /* allows DT phases */
52 unsigned int support_dt_only; /* disallows ST phases */
53 unsigned int support_ius; /* support Information Units */
54 unsigned int support_qas; /* supports quick arbitration and selection */
55 /* Private Fields */
James Bottomleydfdc58b2006-09-20 12:00:18 -040056 unsigned int dv_pending:1; /* Internal flag: DV Requested */
57 unsigned int dv_in_progress:1; /* Internal: DV started */
Jes Sorensend158d262006-01-13 16:05:44 -080058 struct mutex dv_mutex; /* semaphore to serialise dv */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059};
60
61enum spi_signal_type {
62 SPI_SIGNAL_UNKNOWN = 1,
63 SPI_SIGNAL_SE,
64 SPI_SIGNAL_LVD,
65 SPI_SIGNAL_HVD,
66};
67
68struct spi_host_attrs {
69 enum spi_signal_type signalling;
70};
71
72/* accessor functions */
73#define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period)
James Bottomley 62a86122005-05-06 18:05:20 -050074#define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset)
James Bottomley 62a86122005-05-06 18:05:20 -050076#define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width)
James Bottomley 62a86122005-05-06 18:05:20 -050078#define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu)
80#define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt)
81#define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
82#define spi_wr_flow(x) (((struct spi_transport_attrs *)&(x)->starget_data)->wr_flow)
83#define spi_rd_strm(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm)
84#define spi_rti(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rti)
85#define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en)
James Bottomleyd872ebe2005-08-03 15:43:52 -050086#define spi_hold_mcs(x) (((struct spi_transport_attrs *)&(x)->starget_data)->hold_mcs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087#define spi_initial_dv(x) (((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv)
88
89#define spi_support_sync(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_sync)
90#define spi_support_wide(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_wide)
91#define spi_support_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt)
92#define spi_support_dt_only(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt_only)
93#define spi_support_ius(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_ius)
94#define spi_support_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_qas)
95
96#define spi_flags(x) (((struct spi_transport_attrs *)&(x)->starget_data)->flags)
97#define spi_signalling(h) (((struct spi_host_attrs *)(h)->shost_data)->signalling)
98
99
100
101/* The functions by which the transport class and the driver communicate */
102struct spi_function_template {
103 void (*get_period)(struct scsi_target *);
104 void (*set_period)(struct scsi_target *, int);
105 void (*get_offset)(struct scsi_target *);
106 void (*set_offset)(struct scsi_target *, int);
107 void (*get_width)(struct scsi_target *);
108 void (*set_width)(struct scsi_target *, int);
109 void (*get_iu)(struct scsi_target *);
110 void (*set_iu)(struct scsi_target *, int);
111 void (*get_dt)(struct scsi_target *);
112 void (*set_dt)(struct scsi_target *, int);
113 void (*get_qas)(struct scsi_target *);
114 void (*set_qas)(struct scsi_target *, int);
115 void (*get_wr_flow)(struct scsi_target *);
116 void (*set_wr_flow)(struct scsi_target *, int);
117 void (*get_rd_strm)(struct scsi_target *);
118 void (*set_rd_strm)(struct scsi_target *, int);
119 void (*get_rti)(struct scsi_target *);
120 void (*set_rti)(struct scsi_target *, int);
121 void (*get_pcomp_en)(struct scsi_target *);
122 void (*set_pcomp_en)(struct scsi_target *, int);
James Bottomleyd872ebe2005-08-03 15:43:52 -0500123 void (*get_hold_mcs)(struct scsi_target *);
124 void (*set_hold_mcs)(struct scsi_target *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 void (*get_signalling)(struct Scsi_Host *);
126 void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type);
James Bottomley10c1b882005-08-14 14:34:06 -0500127 int (*deny_binding)(struct scsi_target *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 /* The driver sets these to tell the transport class it
129 * wants the attributes displayed in sysfs. If the show_ flag
130 * is not set, the attribute will be private to the transport
131 * class */
132 unsigned long show_period:1;
133 unsigned long show_offset:1;
134 unsigned long show_width:1;
135 unsigned long show_iu:1;
136 unsigned long show_dt:1;
137 unsigned long show_qas:1;
138 unsigned long show_wr_flow:1;
139 unsigned long show_rd_strm:1;
140 unsigned long show_rti:1;
141 unsigned long show_pcomp_en:1;
James Bottomleyd872ebe2005-08-03 15:43:52 -0500142 unsigned long show_hold_mcs:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143};
144
145struct scsi_transport_template *spi_attach_transport(struct spi_function_template *);
146void spi_release_transport(struct scsi_transport_template *);
147void spi_schedule_dv_device(struct scsi_device *);
148void spi_dv_device(struct scsi_device *);
149void spi_display_xfer_agreement(struct scsi_target *);
Matthew Wilcox1abfd372005-12-15 16:22:01 -0500150int spi_print_msg(const unsigned char *);
Matthew Wilcox6ea3c0b2006-02-07 07:54:46 -0700151int spi_populate_width_msg(unsigned char *msg, int width);
152int spi_populate_sync_msg(unsigned char *msg, int period, int offset);
153int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width,
154 int options);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
156#endif /* SCSI_TRANSPORT_SPI_H */