Path: blob/master/include/scsi/scsi_transport_spi.h
10820 views
/*1* Parallel SCSI (SPI) transport specific attributes exported to sysfs.2*3* Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/19#ifndef SCSI_TRANSPORT_SPI_H20#define SCSI_TRANSPORT_SPI_H2122#include <linux/transport_class.h>23#include <linux/mutex.h>2425struct scsi_transport_template;26struct scsi_target;27struct scsi_device;28struct Scsi_Host;2930struct spi_transport_attrs {31int period; /* value in the PPR/SDTR command */32int min_period;33int offset;34int max_offset;35unsigned int width:1; /* 0 - narrow, 1 - wide */36unsigned int max_width:1;37unsigned int iu:1; /* Information Units enabled */38unsigned int max_iu:1;39unsigned int dt:1; /* DT clocking enabled */40unsigned int qas:1; /* Quick Arbitration and Selection enabled */41unsigned int max_qas:1;42unsigned int wr_flow:1; /* Write Flow control enabled */43unsigned int rd_strm:1; /* Read streaming enabled */44unsigned int rti:1; /* Retain Training Information */45unsigned int pcomp_en:1;/* Precompensation enabled */46unsigned int hold_mcs:1;/* Hold Margin Control Settings */47unsigned int initial_dv:1; /* DV done to this target yet */48unsigned long flags; /* flags field for drivers to use */49/* Device Properties fields */50unsigned int support_sync:1; /* synchronous support */51unsigned int support_wide:1; /* wide support */52unsigned int support_dt:1; /* allows DT phases */53unsigned int support_dt_only; /* disallows ST phases */54unsigned int support_ius; /* support Information Units */55unsigned int support_qas; /* supports quick arbitration and selection */56/* Private Fields */57unsigned int dv_pending:1; /* Internal flag: DV Requested */58unsigned int dv_in_progress:1; /* Internal: DV started */59struct mutex dv_mutex; /* semaphore to serialise dv */60};6162enum spi_signal_type {63SPI_SIGNAL_UNKNOWN = 1,64SPI_SIGNAL_SE,65SPI_SIGNAL_LVD,66SPI_SIGNAL_HVD,67};6869struct spi_host_attrs {70enum spi_signal_type signalling;71};7273/* accessor functions */74#define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period)75#define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period)76#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset)77#define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset)78#define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width)79#define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width)80#define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu)81#define spi_max_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_iu)82#define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt)83#define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)84#define spi_max_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_qas)85#define spi_wr_flow(x) (((struct spi_transport_attrs *)&(x)->starget_data)->wr_flow)86#define spi_rd_strm(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm)87#define spi_rti(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rti)88#define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en)89#define spi_hold_mcs(x) (((struct spi_transport_attrs *)&(x)->starget_data)->hold_mcs)90#define spi_initial_dv(x) (((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv)91#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)9293#define spi_support_sync(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_sync)94#define spi_support_wide(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_wide)95#define spi_support_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt)96#define spi_support_dt_only(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt_only)97#define spi_support_ius(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_ius)98#define spi_support_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_qas)99100#define spi_flags(x) (((struct spi_transport_attrs *)&(x)->starget_data)->flags)101#define spi_signalling(h) (((struct spi_host_attrs *)(h)->shost_data)->signalling)102103104105/* The functions by which the transport class and the driver communicate */106struct spi_function_template {107void (*get_period)(struct scsi_target *);108void (*set_period)(struct scsi_target *, int);109void (*get_offset)(struct scsi_target *);110void (*set_offset)(struct scsi_target *, int);111void (*get_width)(struct scsi_target *);112void (*set_width)(struct scsi_target *, int);113void (*get_iu)(struct scsi_target *);114void (*set_iu)(struct scsi_target *, int);115void (*get_dt)(struct scsi_target *);116void (*set_dt)(struct scsi_target *, int);117void (*get_qas)(struct scsi_target *);118void (*set_qas)(struct scsi_target *, int);119void (*get_wr_flow)(struct scsi_target *);120void (*set_wr_flow)(struct scsi_target *, int);121void (*get_rd_strm)(struct scsi_target *);122void (*set_rd_strm)(struct scsi_target *, int);123void (*get_rti)(struct scsi_target *);124void (*set_rti)(struct scsi_target *, int);125void (*get_pcomp_en)(struct scsi_target *);126void (*set_pcomp_en)(struct scsi_target *, int);127void (*get_hold_mcs)(struct scsi_target *);128void (*set_hold_mcs)(struct scsi_target *, int);129void (*get_signalling)(struct Scsi_Host *);130void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type);131int (*deny_binding)(struct scsi_target *);132/* The driver sets these to tell the transport class it133* wants the attributes displayed in sysfs. If the show_ flag134* is not set, the attribute will be private to the transport135* class */136unsigned long show_period:1;137unsigned long show_offset:1;138unsigned long show_width:1;139unsigned long show_iu:1;140unsigned long show_dt:1;141unsigned long show_qas:1;142unsigned long show_wr_flow:1;143unsigned long show_rd_strm:1;144unsigned long show_rti:1;145unsigned long show_pcomp_en:1;146unsigned long show_hold_mcs:1;147};148149struct scsi_transport_template *spi_attach_transport(struct spi_function_template *);150void spi_release_transport(struct scsi_transport_template *);151void spi_schedule_dv_device(struct scsi_device *);152void spi_dv_device(struct scsi_device *);153void spi_display_xfer_agreement(struct scsi_target *);154int spi_print_msg(const unsigned char *);155int spi_populate_width_msg(unsigned char *msg, int width);156int spi_populate_sync_msg(unsigned char *msg, int period, int offset);157int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width,158int options);159160#endif /* SCSI_TRANSPORT_SPI_H */161162163