Commit f8ca1b01 authored by James Bottomley's avatar James Bottomley Committed by James Bottomley

[PATCH] Add full complement of SPI transport attributes

This patch does two things:

1. Add all the other ppr type transport attributes to the spi class
2. make period settable as the ppr/sdtr period, but display in ns for
the user.
parent 9167017d
...@@ -43,9 +43,16 @@ static void __exit spi_transport_exit(void) ...@@ -43,9 +43,16 @@ static void __exit spi_transport_exit(void)
static int spi_setup_transport_attrs(struct scsi_device *sdev) static int spi_setup_transport_attrs(struct scsi_device *sdev)
{ {
/* FIXME: should callback into the driver to get these values */ spi_period(sdev) = -1; /* illegal value */
spi_period(sdev) = -1; spi_offset(sdev) = 0; /* async */
spi_offset(sdev) = -1; spi_width(sdev) = 0; /* narrow */
spi_iu(sdev) = 0; /* no IU */
spi_dt(sdev) = 0; /* ST */
spi_qas(sdev) = 0;
spi_wr_flow(sdev) = 0;
spi_rd_strm(sdev) = 0;
spi_rti(sdev) = 0;
spi_pcomp_en(sdev) = 0;
return 0; return 0;
} }
...@@ -71,12 +78,78 @@ show_spi_transport_##field (struct class_device *cdev, char *buf) \ ...@@ -71,12 +78,78 @@ show_spi_transport_##field (struct class_device *cdev, char *buf) \
static CLASS_DEVICE_ATTR( field, S_IRUGO, show_spi_transport_##field, NULL) static CLASS_DEVICE_ATTR( field, S_IRUGO, show_spi_transport_##field, NULL)
/* The Parallel SCSI Tranport Attributes: */ /* The Parallel SCSI Tranport Attributes: */
spi_transport_rd_attr(period, "%d\n");
spi_transport_rd_attr(offset, "%d\n"); spi_transport_rd_attr(offset, "%d\n");
spi_transport_rd_attr(width, "%d\n");
spi_transport_rd_attr(iu, "%d\n");
spi_transport_rd_attr(dt, "%d\n");
spi_transport_rd_attr(qas, "%d\n");
spi_transport_rd_attr(wr_flow, "%d\n");
spi_transport_rd_attr(rd_strm, "%d\n");
spi_transport_rd_attr(rti, "%d\n");
spi_transport_rd_attr(pcomp_en, "%d\n");
/* Translate the period into ns according to the current spec
* for SDTR/PPR messages */
static ssize_t show_spi_transport_period(struct class_device *cdev, char *buf)
{
struct scsi_device *sdev = transport_class_to_sdev(cdev);
struct spi_transport_attrs *tp;
char *str;
tp = (struct spi_transport_attrs *)&sdev->transport_data;
switch(tp->period) {
case 0x00 ... 0x06:
str = "reserved";
break;
case 0x07:
str = "3.125";
break;
case 0x08:
str = "6.25";
break;
case 0x09:
str = "12.5";
break;
case 0x0a:
str = "25";
break;
case 0x0b:
str = "30.3";
break;
case 0x0c:
str = "50";
case 0x0d ... 0xff:
return sprintf(buf, "%d\n", tp->period * 4);
default:
str = "unknown";
}
return sprintf(buf, "%s\n", str);
}
static CLASS_DEVICE_ATTR(period, S_IRUGO, show_spi_transport_period, NULL);
struct class_device_attribute *spi_transport_attrs[] = { struct class_device_attribute *spi_transport_attrs[] = {
&class_device_attr_period, &class_device_attr_period,
&class_device_attr_offset, &class_device_attr_offset,
&class_device_attr_width,
&class_device_attr_iu,
&class_device_attr_dt,
&class_device_attr_qas,
&class_device_attr_wr_flow,
&class_device_attr_rd_strm,
&class_device_attr_rti,
&class_device_attr_pcomp_en,
NULL NULL
}; };
......
...@@ -25,14 +25,29 @@ ...@@ -25,14 +25,29 @@
struct scsi_transport_template; struct scsi_transport_template;
struct spi_transport_attrs { struct spi_transport_attrs {
int period; int period; /* value in the PPR/SDTR command */
int offset; int offset;
int width:1; /* 0 - narrow, 1 - wide */
int iu:1; /* Information Units enabled */
int dt:1; /* DT clocking enabled */
int qas:1; /* Quick Arbitration and Selection enabled */
int wr_flow:1; /* Write Flow control enabled */
int rd_strm:1; /* Read streaming enabled */
int rti:1; /* Retain Training Information */
int pcomp_en:1; /* Precompensation enabled */
}; };
/* accessor functions */ /* accessor functions */
#define spi_period(x) (((struct spi_transport_attrs *)&(x)->transport_data)->period) #define spi_period(x) (((struct spi_transport_attrs *)&(x)->transport_data)->period)
#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->transport_data)->offset) #define spi_offset(x) (((struct spi_transport_attrs *)&(x)->transport_data)->offset)
#define spi_width(x) (((struct spi_transport_attrs *)&(x)->transport_data)->width)
#define spi_iu(x) (((struct spi_transport_attrs *)&(x)->transport_data)->iu)
#define spi_dt(x) (((struct spi_transport_attrs *)&(x)->transport_data)->dt)
#define spi_qas(x) (((struct spi_transport_attrs *)&(x)->transport_data)->qas)
#define spi_wr_flow(x) (((struct spi_transport_attrs *)&(x)->transport_data)->wr_flow)
#define spi_rd_strm(x) (((struct spi_transport_attrs *)&(x)->transport_data)->rd_strm)
#define spi_rti(x) (((struct spi_transport_attrs *)&(x)->transport_data)->rti)
#define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->transport_data)->pcomp_en)
extern struct scsi_transport_template spi_transport_template; extern struct scsi_transport_template spi_transport_template;
#endif /* SCSI_TRANSPORT_SPI_H */ #endif /* SCSI_TRANSPORT_SPI_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment