blob: 6dcf497bf46dc485e4b61800ff7d4429b3506919 [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
23#include <linux/config.h>
24#include <linux/transport_class.h>
25
26struct scsi_transport_template;
27
28struct spi_transport_attrs {
29 int period; /* value in the PPR/SDTR command */
30 int offset;
31 unsigned int width:1; /* 0 - narrow, 1 - wide */
32 unsigned int iu:1; /* Information Units enabled */
33 unsigned int dt:1; /* DT clocking enabled */
34 unsigned int qas:1; /* Quick Arbitration and Selection enabled */
35 unsigned int wr_flow:1; /* Write Flow control enabled */
36 unsigned int rd_strm:1; /* Read streaming enabled */
37 unsigned int rti:1; /* Retain Training Information */
38 unsigned int pcomp_en:1;/* Precompensation enabled */
39 unsigned int initial_dv:1; /* DV done to this target yet */
40 unsigned long flags; /* flags field for drivers to use */
41 /* Device Properties fields */
42 unsigned int support_sync:1; /* synchronous support */
43 unsigned int support_wide:1; /* wide support */
44 unsigned int support_dt:1; /* allows DT phases */
45 unsigned int support_dt_only; /* disallows ST phases */
46 unsigned int support_ius; /* support Information Units */
47 unsigned int support_qas; /* supports quick arbitration and selection */
48 /* Private Fields */
49 unsigned int dv_pending:1; /* Internal flag */
50 struct semaphore dv_sem; /* semaphore to serialise dv */
51};
52
53enum spi_signal_type {
54 SPI_SIGNAL_UNKNOWN = 1,
55 SPI_SIGNAL_SE,
56 SPI_SIGNAL_LVD,
57 SPI_SIGNAL_HVD,
58};
59
60struct spi_host_attrs {
61 enum spi_signal_type signalling;
62};
63
64/* accessor functions */
65#define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period)
66#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset)
67#define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width)
68#define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu)
69#define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt)
70#define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
71#define spi_wr_flow(x) (((struct spi_transport_attrs *)&(x)->starget_data)->wr_flow)
72#define spi_rd_strm(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm)
73#define spi_rti(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rti)
74#define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en)
75#define spi_initial_dv(x) (((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv)
76
77#define spi_support_sync(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_sync)
78#define spi_support_wide(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_wide)
79#define spi_support_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt)
80#define spi_support_dt_only(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt_only)
81#define spi_support_ius(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_ius)
82#define spi_support_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_qas)
83
84#define spi_flags(x) (((struct spi_transport_attrs *)&(x)->starget_data)->flags)
85#define spi_signalling(h) (((struct spi_host_attrs *)(h)->shost_data)->signalling)
86
87
88
89/* The functions by which the transport class and the driver communicate */
90struct spi_function_template {
91 void (*get_period)(struct scsi_target *);
92 void (*set_period)(struct scsi_target *, int);
93 void (*get_offset)(struct scsi_target *);
94 void (*set_offset)(struct scsi_target *, int);
95 void (*get_width)(struct scsi_target *);
96 void (*set_width)(struct scsi_target *, int);
97 void (*get_iu)(struct scsi_target *);
98 void (*set_iu)(struct scsi_target *, int);
99 void (*get_dt)(struct scsi_target *);
100 void (*set_dt)(struct scsi_target *, int);
101 void (*get_qas)(struct scsi_target *);
102 void (*set_qas)(struct scsi_target *, int);
103 void (*get_wr_flow)(struct scsi_target *);
104 void (*set_wr_flow)(struct scsi_target *, int);
105 void (*get_rd_strm)(struct scsi_target *);
106 void (*set_rd_strm)(struct scsi_target *, int);
107 void (*get_rti)(struct scsi_target *);
108 void (*set_rti)(struct scsi_target *, int);
109 void (*get_pcomp_en)(struct scsi_target *);
110 void (*set_pcomp_en)(struct scsi_target *, int);
111 void (*get_signalling)(struct Scsi_Host *);
112 void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type);
113 /* The driver sets these to tell the transport class it
114 * wants the attributes displayed in sysfs. If the show_ flag
115 * is not set, the attribute will be private to the transport
116 * class */
117 unsigned long show_period:1;
118 unsigned long show_offset:1;
119 unsigned long show_width:1;
120 unsigned long show_iu:1;
121 unsigned long show_dt:1;
122 unsigned long show_qas:1;
123 unsigned long show_wr_flow:1;
124 unsigned long show_rd_strm:1;
125 unsigned long show_rti:1;
126 unsigned long show_pcomp_en:1;
127};
128
129struct scsi_transport_template *spi_attach_transport(struct spi_function_template *);
130void spi_release_transport(struct scsi_transport_template *);
131void spi_schedule_dv_device(struct scsi_device *);
132void spi_dv_device(struct scsi_device *);
133void spi_display_xfer_agreement(struct scsi_target *);
134
135#endif /* SCSI_TRANSPORT_SPI_H */