12cc2e845SMatthew Dillon /* 22cc2e845SMatthew Dillon * Copyright (c) 2009 The DragonFly Project. All rights reserved. 32cc2e845SMatthew Dillon * 42cc2e845SMatthew Dillon * This code is derived from software contributed to The DragonFly Project 52cc2e845SMatthew Dillon * by Matthew Dillon <dillon@backplane.com> 62cc2e845SMatthew Dillon * 72cc2e845SMatthew Dillon * Redistribution and use in source and binary forms, with or without 82cc2e845SMatthew Dillon * modification, are permitted provided that the following conditions 92cc2e845SMatthew Dillon * are met: 102cc2e845SMatthew Dillon * 112cc2e845SMatthew Dillon * 1. Redistributions of source code must retain the above copyright 122cc2e845SMatthew Dillon * notice, this list of conditions and the following disclaimer. 132cc2e845SMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright 142cc2e845SMatthew Dillon * notice, this list of conditions and the following disclaimer in 152cc2e845SMatthew Dillon * the documentation and/or other materials provided with the 162cc2e845SMatthew Dillon * distribution. 172cc2e845SMatthew Dillon * 3. Neither the name of The DragonFly Project nor the names of its 182cc2e845SMatthew Dillon * contributors may be used to endorse or promote products derived 192cc2e845SMatthew Dillon * from this software without specific, prior written permission. 202cc2e845SMatthew Dillon * 212cc2e845SMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 222cc2e845SMatthew Dillon * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 232cc2e845SMatthew Dillon * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 242cc2e845SMatthew Dillon * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 252cc2e845SMatthew Dillon * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 262cc2e845SMatthew Dillon * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 272cc2e845SMatthew Dillon * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 282cc2e845SMatthew Dillon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 292cc2e845SMatthew Dillon * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 302cc2e845SMatthew Dillon * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 312cc2e845SMatthew Dillon * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 322cc2e845SMatthew Dillon * SUCH DAMAGE. 332cc2e845SMatthew Dillon */ 342cc2e845SMatthew Dillon 352cc2e845SMatthew Dillon /* 362cc2e845SMatthew Dillon * SATA port multiplier registers 372cc2e845SMatthew Dillon */ 382cc2e845SMatthew Dillon #define SATA_PMREG_SSTS 0 /* use SATA_PM_SSTS_ bit defs */ 392cc2e845SMatthew Dillon #define SATA_PMREG_SERR 1 /* use SATA_PM_SERR_ bit defs */ 402cc2e845SMatthew Dillon #define SATA_PMREG_SCTL 2 /* use SATA_PM_SCTL_ bit defs */ 412cc2e845SMatthew Dillon #define SATA_PMREG_SACT 3 /* (not implemented on PM) */ 422cc2e845SMatthew Dillon 432cc2e845SMatthew Dillon #define SATA_PM_SSTS_DET 0xf /* Device Detection */ 442cc2e845SMatthew Dillon #define SATA_PM_SSTS_DET_NONE 0x0 452cc2e845SMatthew Dillon #define SATA_PM_SSTS_DET_DEV_NE 0x1 462cc2e845SMatthew Dillon #define SATA_PM_SSTS_DET_DEV 0x3 472cc2e845SMatthew Dillon #define SATA_PM_SSTS_DET_PHYOFFLINE 0x4 482cc2e845SMatthew Dillon #define SATA_PM_SSTS_SPD 0xf0 /* Current Interface Speed */ 492cc2e845SMatthew Dillon #define SATA_PM_SSTS_SPD_NONE 0x00 502cc2e845SMatthew Dillon #define SATA_PM_SSTS_SPD_GEN1 0x10 512cc2e845SMatthew Dillon #define SATA_PM_SSTS_SPD_GEN2 0x20 528986d351SMatthew Dillon #define SATA_PM_SSTS_SPD_GEN3 0x30 532cc2e845SMatthew Dillon #define SATA_PM_SSTS_IPM 0xf00 /* Interface Power Management */ 542cc2e845SMatthew Dillon #define SATA_PM_SSTS_IPM_NONE 0x000 552cc2e845SMatthew Dillon #define SATA_PM_SSTS_IPM_ACTIVE 0x100 562cc2e845SMatthew Dillon #define SATA_PM_SSTS_IPM_PARTIAL 0x200 572cc2e845SMatthew Dillon #define SATA_PM_SSTS_IPM_SLUMBER 0x600 582cc2e845SMatthew Dillon 592cc2e845SMatthew Dillon #define SATA_PM_SCTL_DET 0xf /* Device Detection */ 602cc2e845SMatthew Dillon #define SATA_PM_SCTL_DET_NONE 0x0 612cc2e845SMatthew Dillon #define SATA_PM_SCTL_DET_INIT 0x1 622cc2e845SMatthew Dillon #define SATA_PM_SCTL_DET_DISABLE 0x4 632cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPD 0xf0 /* Speed Allowed */ 642cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPD_ANY 0x00 652cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPD_GEN1 0x10 662cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPD_GEN2 0x20 678986d351SMatthew Dillon #define SATA_PM_SCTL_SPD_GEN3 0x30 682cc2e845SMatthew Dillon #define SATA_PM_SCTL_IPM 0xf00 /* Interface Power Management */ 692cc2e845SMatthew Dillon #define SATA_PM_SCTL_IPM_NONE 0x000 702cc2e845SMatthew Dillon #define SATA_PM_SCTL_IPM_NOPARTIAL 0x100 712cc2e845SMatthew Dillon #define SATA_PM_SCTL_IPM_NOSLUMBER 0x200 722cc2e845SMatthew Dillon #define SATA_PM_SCTL_IPM_DISABLED 0x300 732cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPM 0xf000 /* Select Power Management */ 742cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPM_NONE 0x0000 752cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPM_NOPARTIAL 0x1000 762cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPM_NOSLUMBER 0x2000 772cc2e845SMatthew Dillon #define SATA_PM_SCTL_SPM_DISABLED 0x3000 782cc2e845SMatthew Dillon #define SATA_PM_SCTL_PMP 0xf0000 /* Set PM port for xmit FISes */ 792cc2e845SMatthew Dillon #define SATA_PM_SCTL_PMP_SHIFT 16 802cc2e845SMatthew Dillon 812cc2e845SMatthew Dillon #define SATA_PM_SERR_ERR_I (1<<0) /* Recovered Data Integrity */ 822cc2e845SMatthew Dillon #define SATA_PM_SERR_ERR_M (1<<1) /* Recovered Communications */ 832cc2e845SMatthew Dillon #define SATA_PM_SERR_ERR_T (1<<8) /* Transient Data Integrity */ 842cc2e845SMatthew Dillon #define SATA_PM_SERR_ERR_C (1<<9) /* Persistent Comm/Data */ 852cc2e845SMatthew Dillon #define SATA_PM_SERR_ERR_P (1<<10) /* Protocol */ 862cc2e845SMatthew Dillon #define SATA_PM_SERR_ERR_E (1<<11) /* Internal */ 872cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_N (1<<16) /* PhyRdy Change */ 882cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_I (1<<17) /* Phy Internal Error */ 892cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_W (1<<18) /* Comm Wake */ 902cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_B (1<<19) /* 10B to 8B Decode Error */ 912cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_D (1<<20) /* Disparity Error */ 922cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_C (1<<21) /* CRC Error */ 932cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_H (1<<22) /* Handshake Error */ 942cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_S (1<<23) /* Link Sequence Error */ 952cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_T (1<<24) /* Transport State Trans Err */ 962cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_F (1<<25) /* Unknown FIS Type */ 972cc2e845SMatthew Dillon #define SATA_PM_SERR_DIAG_X (1<<26) /* Exchanged */ 982cc2e845SMatthew Dillon 992cc2e845SMatthew Dillon #define SATA_PFMT_SERR "\020" \ 1002cc2e845SMatthew Dillon "\033DIAG.X" "\032DIAG.F" "\031DIAG.T" "\030DIAG.S" \ 1012cc2e845SMatthew Dillon "\027DIAG.H" "\026DIAG.C" "\025DIAG.D" "\024DIAG.B" \ 1022cc2e845SMatthew Dillon "\023DIAG.W" "\022DIAG.I" "\021DIAG.N" \ 1032cc2e845SMatthew Dillon "\014ERR.E" "\013ERR.P" "\012ERR.C" "\011ERR.T" \ 1042cc2e845SMatthew Dillon "\002ERR.M" "\001ERR.I" 1052cc2e845SMatthew Dillon 1062cc2e845SMatthew Dillon /* 1072cc2e845SMatthew Dillon * AHCI port multiplier revision information SCR[1] (see ahci_pm_read) 1082cc2e845SMatthew Dillon * 1092cc2e845SMatthew Dillon * Rev 1.1 is the one that should support async notification. 1102cc2e845SMatthew Dillon */ 1112cc2e845SMatthew Dillon #define SATA_PMREV_PM1_0 0x00000002 1122cc2e845SMatthew Dillon #define SATA_PMREV_PM1_1 0x00000004 113*46d04d11SMatthew Dillon #define SATA_PMREV_PM1_2 0x00000008 114*46d04d11SMatthew Dillon #define SATA_PMREV_MASK 0x0000000F 115*46d04d11SMatthew Dillon #define SATA_PFMT_PM_REV "\20" "\004PM1.2" "\003PM1.1" "\002PM1.0" 1162cc2e845SMatthew Dillon 1172cc2e845SMatthew Dillon /* 1182cc2e845SMatthew Dillon * GSCR[64] and GSCR[96] - Port Multiplier features available and features 1192cc2e845SMatthew Dillon * enabled. 1202cc2e845SMatthew Dillon */ 1212cc2e845SMatthew Dillon #define SATA_PMREG_FEA 64 1222cc2e845SMatthew Dillon #define SATA_PMREG_FEAEN 96 /* (features enabled) */ 1232cc2e845SMatthew Dillon #define SATA_PMFEA_BIST 0x00000001 /* BIST Support */ 1242cc2e845SMatthew Dillon #define SATA_PMFEA_PMREQ 0x00000002 /* Can issue PMREQp to host */ 1252cc2e845SMatthew Dillon #define SATA_PMFEA_DYNSSC 0x00000004 /* Dynamic SSC transmit enab */ 1262cc2e845SMatthew Dillon #define SATA_PMFEA_ASYNCNOTIFY 0x00000008 /* Async notification */ 1272cc2e845SMatthew Dillon 1282cc2e845SMatthew Dillon #define SATA_PFMT_PM_FEA "\20" \ 1292cc2e845SMatthew Dillon "\004AsyncNotify" \ 1302cc2e845SMatthew Dillon "\003DynamicSSC" \ 1312cc2e845SMatthew Dillon "\002PMREQ" \ 1322cc2e845SMatthew Dillon "\001BIST" 1332cc2e845SMatthew Dillon 1342cc2e845SMatthew Dillon /* 1352cc2e845SMatthew Dillon * Enable generation of async notify events for individual targets 1362cc2e845SMatthew Dillon * via the PMEENA register. Each bit in PMEINFO is a wire-or of all 1372cc2e845SMatthew Dillon * SERROR bits for that target. To enable a new notification event 1382cc2e845SMatthew Dillon * the SERROR bits in PMSERROR_REGNO must be cleared. 1392cc2e845SMatthew Dillon */ 1402cc2e845SMatthew Dillon #define SATA_PMREG_EINFO 32 /* error info 16 ports */ 1412cc2e845SMatthew Dillon #define SATA_PMREG_EEENA 33 /* error info enable 16 ports */ 142