Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Feb 2009 23:17:52 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r188877 - head/sys/dev/ata/chipsets
Message-ID:  <200902202317.n1KNHqmh042109@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Feb 20 23:17:52 2009
New Revision: 188877
URL: http://svn.freebsd.org/changeset/base/188877

Log:
  Disable port hardware on detach. First switch it to slumber mode to
  power-down peer transmitter, then disable completely.
  Side effect of this is saving about 0.5W of power per detached device.

Modified:
  head/sys/dev/ata/chipsets/ata-ahci.c

Modified: head/sys/dev/ata/chipsets/ata-ahci.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-ahci.c	Fri Feb 20 23:16:47 2009	(r188876)
+++ head/sys/dev/ata/chipsets/ata-ahci.c	Fri Feb 20 23:17:52 2009	(r188877)
@@ -230,6 +230,22 @@ ata_ahci_ch_attach(device_t dev)
 int
 ata_ahci_ch_detach(device_t dev)
 {
+    struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
+    struct ata_channel *ch = device_get_softc(dev);
+    int offset = ch->unit << 7;
+
+    /* Disable port interrupts. */
+    ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_IE + offset, 0);
+    /* Reset command register. */
+    ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_CMD + offset, 0);
+
+    /* Allow everything including partial and slumber modes. */
+    ATA_IDX_OUTL(ch, ATA_SCONTROL, 0);
+    /* Request slumber mode transition and give some time to get there. */
+    ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_CMD + offset, ATA_AHCI_P_CMD_SLUMBER);
+    DELAY(100);
+    /* Disable PHY. */
+    ATA_IDX_OUTL(ch, ATA_SCONTROL, ATA_SC_DET_DISABLE);
 
     ata_dmafini(dev);
     return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902202317.n1KNHqmh042109>