svn commit: r188877 - head/sys/dev/ata/chipsets

Alexander Motin mav at FreeBSD.org
Fri Feb 20 15:17:53 PST 2009


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);


More information about the svn-src-head mailing list