public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@us.ibm.com>
To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: alexisb@us.ibm.com
Subject: [PATCH 12/15] sas_ata: Implement sata phy control
Date: Fri, 17 Nov 2006 13:08:24 -0800	[thread overview]
Message-ID: <20061117210824.17052.1005.stgit@localhost.localdomain> (raw)
In-Reply-To: <20061117210737.17052.67041.stgit@localhost.localdomain>


This patch requires "libsas: Add a sysfs knob to enable/disable a phy"
to be applied.  It hooks the SControl write function to provide basic
SATA phy control for phy enable/disable and speed limits.  Power
management is still broken, though it is unclear that libata actually
uses those SControl bits anyway.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 drivers/scsi/libsas/sas_ata.c       |   42 ++++++++++++++++++++++++++++++++++-
 drivers/scsi/libsas/sas_scsi_host.c |    1 +
 2 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index e2650fa..e897140 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -270,6 +270,46 @@ static void sas_ata_tf_read(struct ata_p
 	memcpy(tf, &dev->sata_dev.tf, sizeof (*tf));
 }
 
+static void sas_ata_scontrol_write(struct domain_device *dev, u32 val)
+{
+	u32 tmp = dev->sata_dev.scontrol;
+	struct sas_phy *phy = dev->port->phy;
+
+	val &= 0x0FF; /* only set max spd and dev ctrl */
+	val |= 0x300; /* disallow host pm */
+	val |= tmp & 0xFFFFF000; /* preserve upper bits */
+
+	/* disable phy */
+	if ((val & 0x4) && !(tmp & 0x4))
+		sas_phy_enable(phy, 0);
+
+	/* enable phy */
+	if (!(val & 0x4) && (tmp & 0x4))
+		sas_phy_enable(phy, 1);
+
+	/* reset phy */
+	if ((val & 0x1) && !(tmp & 0x1))
+		sas_phy_reset(phy, 0);
+
+	/* speed limit */
+	if ((val & 0xF0) != (tmp & 0xF0)) {
+		struct sas_phy_linkrates rates = {0};
+
+		switch ((val & 0xF0) >> 4) {
+		case 0:
+		case 2:
+			rates.maximum_linkrate = SAS_LINK_RATE_3_0_GBPS;
+			break;
+		case 1:
+			rates.maximum_linkrate = SAS_LINK_RATE_1_5_GBPS;
+			break;
+		}
+		sas_set_phy_speed(phy, &rates);
+	}
+
+	dev->sata_dev.scontrol = val;
+}
+
 static void sas_ata_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
 			      u32 val)
 {
@@ -281,7 +321,7 @@ static void sas_ata_scr_write(struct ata
 			dev->sata_dev.sstatus = val;
 			break;
 		case SCR_CONTROL:
-			dev->sata_dev.scontrol = val;
+			sas_ata_scontrol_write(dev, val);
 			break;
 		case SCR_ERROR:
 			dev->sata_dev.serror = val;
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 25639b5..59409be 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -938,3 +938,4 @@ EXPORT_SYMBOL_GPL(sas_ioctl);
 EXPORT_SYMBOL_GPL(sas_task_abort);
 EXPORT_SYMBOL_GPL(sas_phy_reset);
 EXPORT_SYMBOL_GPL(sas_phy_enable);
+EXPORT_SYMBOL_GPL(sas_set_phy_speed);

  parent reply	other threads:[~2006-11-17 21:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-17 21:07 [PATCH 00/15] Roll-up of my libsas, aic94xx and sas_ata patches Darrick J. Wong
2006-11-17 21:07 ` [PATCH 01/15] aic94xx: Handle REQ_DEVICE_RESET Darrick J. Wong
2006-11-17 21:07 ` [PATCH 02/15] libsas: Clean up rphys/port dev list after a discovery error Darrick J. Wong
2006-11-17 21:07 ` [PATCH 03/15] aic94xx: Delete ascb timers when freeing queues Darrick J. Wong
2006-11-17 21:07 ` [PATCH 04/15] libsas: Don't give scsi_cmnds to the EH if they never made it to the SAS LLDD or have already returned Darrick J. Wong
2006-11-25  6:58   ` [PATCH v2] " Darrick J. Wong
2006-11-25 19:02     ` James Bottomley
2006-11-17 21:07 ` [PATCH 05/15] libsas: Add a sysfs knob to enable/disable a phy Darrick J. Wong
2006-11-17 21:07 ` [PATCH 06/15] sas_ata: Require CONFIG_ATA in Kconfig Darrick J. Wong
2006-11-17 21:08 ` [PATCH 07/15] sas_ata: Satisfy libata qc function locking requirements Darrick J. Wong
2006-11-17 21:08 ` [PATCH 08/15] sas_ata: sas_ata_qc_issue should return AC_ERR_* Darrick J. Wong
2006-11-17 21:08 ` [PATCH 09/15] sas_ata: ata_post_internal should abort the sas_task Darrick J. Wong
2006-11-17 21:08 ` [PATCH 10/15] aic94xx: Don't call pci_map_sg for already-mapped scatterlists Darrick J. Wong
2006-11-17 21:08 ` [PATCH 11/15] sas_ata: Don't copy aic94xx's sactive to ata_port Darrick J. Wong
2006-11-17 21:08 ` Darrick J. Wong [this message]
2006-11-17 21:08 ` [PATCH 13/15] sas_ata: Implement a libata error handler Darrick J. Wong
2006-11-17 21:08 ` [PATCH 14/15] libsas: Provide a generic SATL registration function Darrick J. Wong
2006-11-17 21:08 ` [PATCH 15/15] sas_ata: Make this a module separate from libsas Darrick J. Wong
2006-11-21  1:16 ` [PATCH 00/15] Roll-up of my libsas, aic94xx and sas_ata patches Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061117210824.17052.1005.stgit@localhost.localdomain \
    --to=djwong@us.ibm.com \
    --cc=alexisb@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox