The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/mvs/mvs.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2010 Alexander Motin <mav@FreeBSD.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer,
   10  *    without modification, immediately at the beginning of the file.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 
   29 #include "mvs_if.h"
   30 
   31 /* Chip registers */
   32 #define CHIP_PCIEIC             0x1900  /* PCIe Interrupt Cause */
   33 #define CHIP_PCIEIM             0x1910  /* PCIe Interrupt Mask */
   34 #define CHIP_PCIIC              0x1d58  /* PCI Interrupt Cause */
   35 #define CHIP_PCIIM              0x1d5c  /* PCI Interrupt Mask */
   36 #define CHIP_MIC                0x1d60  /* Main Interrupt Cause */
   37 #define CHIP_MIM                0x1d64  /* Main Interrupt Mask */
   38 #define CHIP_SOC_MIC            0x20    /* SoC Main Interrupt Cause */
   39 #define CHIP_SOC_MIM            0x24    /* SoC Main Interrupt Mask */
   40 #define IC_ERR_IRQ               (1 << 0)       /* shift by (2 * port #) */
   41 #define IC_DONE_IRQ              (1 << 1)       /* shift by (2 * port #) */
   42 #define IC_HC0                   0x000001ff     /* bits 0-8 = HC0 */
   43 #define IC_HC_SHIFT              9              /* HC1 shift */
   44 #define IC_HC1                   (IC_HC0 << IC_HC_SHIFT) /* 9-17 = HC1 */
   45 #define IC_ERR_HC0               0x00000055     /* HC0 ERR_IRQ */
   46 #define IC_DONE_HC0              0x000000aa     /* HC0 DONE_IRQ */
   47 #define IC_ERR_HC1               (IC_ERR_HC0 << IC_HC_SHIFT) /* HC1 ERR_IRQ */
   48 #define IC_DONE_HC1              (IC_DONE_HC0 << IC_HC_SHIFT) /* HC1 DONE_IRQ */
   49 #define IC_HC0_COAL_DONE         (1 << 8)       /* HC0 IRQ coalescing */
   50 #define IC_HC1_COAL_DONE         (1 << 17)      /* HC1 IRQ coalescing */
   51 #define IC_PCI_ERR               (1 << 18)
   52 #define IC_TRAN_COAL_LO_DONE     (1 << 19)      /* transaction coalescing */
   53 #define IC_TRAN_COAL_HI_DONE     (1 << 20)      /* transaction coalescing */
   54 #define IC_ALL_PORTS_COAL_DONE   (1 << 21)      /* GEN_II(E) IRQ coalescing */
   55 #define IC_GPIO_INT              (1 << 22)
   56 #define IC_SELF_INT              (1 << 23)
   57 #define IC_TWSI_INT              (1 << 24)
   58 #define IC_MAIN_RSVD             (0xfe000000)   /* bits 31-25 */
   59 #define IC_MAIN_RSVD_5           (0xfff10000)   /* bits 31-19 */
   60 #define IC_MAIN_RSVD_SOC         (0xfffffec0)   /* bits 31-9, 7-6 */
   61 
   62 #define CHIP_SOC_LED            0x2C    /* SoC LED Configuration */
   63 
   64 /* Chip CCC registers */
   65 #define CHIP_ICC                0x18008
   66 #define CHIP_ICC_ALL_PORTS       (1 << 4)       /* all ports irq event */
   67 #define CHIP_ICT                0x180cc
   68 #define CHIP_ITT                0x180d0
   69 #define CHIP_TRAN_COAL_CAUSE_LO 0x18088
   70 #define CHIP_TRAN_COAL_CAUSE_HI 0x1808c
   71 
   72 /* Host Controller registers */
   73 #define HC_SIZE                 0x10000
   74 #define HC_OFFSET               0x20000
   75 #define HC_BASE(hc)             ((hc) * HC_SIZE + HC_OFFSET)
   76 
   77 #define HC_CFG                  0x0     /* Configuration */
   78 #define HC_CFG_TIMEOUT_MASK      (0xff << 0)
   79 #define HC_CFG_NODMABS           (1 << 8)
   80 #define HC_CFG_NOEDMABS          (1 << 9)
   81 #define HC_CFG_NOPRDBS           (1 << 10)
   82 #define HC_CFG_TIMEOUTEN         (1 << 16)      /* Timer Enable */
   83 #define HC_CFG_COALDIS(p)        (1 << ((p) + 24))/* Coalescing Disable*/
   84 #define HC_RQOP                 0x4     /* Request Queue Out-Pointer */
   85 #define HC_RQIP                 0x8     /* Response Queue In-Pointer */
   86 #define HC_ICT                  0xc     /* Interrupt Coalescing Threshold */
   87 #define HC_ICT_SAICOALT_MASK     0x000000ff
   88 #define HC_ITT                  0x10    /* Interrupt Time Threshold */
   89 #define HC_ITT_SAITMTH_MASK      0x00ffffff
   90 #define HC_IC                   0x14    /* Interrupt Cause */
   91 #define HC_IC_DONE(p)            (1 << (p))     /* SaCrpb/DMA Done */
   92 #define HC_IC_COAL               (1 << 4)       /* Intr Coalescing */
   93 #define HC_IC_DEV(p)             (1 << ((p) + 8)) /* Device Intr */
   94 
   95 /* Port registers */
   96 #define PORT_SIZE               0x2000
   97 #define PORT_OFFSET             0x2000
   98 #define PORT_BASE(hc)           ((hc) * PORT_SIZE + PORT_OFFSET)
   99 
  100 #define EDMA_CFG                0x0     /* Configuration */
  101 #define EDMA_CFG_RESERVED        (0x1f << 0)    /* Queue len ? */
  102 #define EDMA_CFG_ESATANATVCMDQUE (1 << 5)
  103 #define EDMA_CFG_ERDBSZ          (1 << 8)
  104 #define EDMA_CFG_EQUE            (1 << 9)
  105 #define EDMA_CFG_ERDBSZEXT       (1 << 11)
  106 #define EDMA_CFG_RESERVED2       (1 << 12)
  107 #define EDMA_CFG_EWRBUFFERLEN    (1 << 13)
  108 #define EDMA_CFG_EDEVERR         (1 << 14)
  109 #define EDMA_CFG_EEDMAFBS        (1 << 16)
  110 #define EDMA_CFG_ECUTTHROUGHEN   (1 << 17)
  111 #define EDMA_CFG_EEARLYCOMPLETIONEN (1 << 18)
  112 #define EDMA_CFG_EEDMAQUELEN     (1 << 19)
  113 #define EDMA_CFG_EHOSTQUEUECACHEEN (1 << 22)
  114 #define EDMA_CFG_EMASKRXPM       (1 << 23)
  115 #define EDMA_CFG_RESUMEDIS       (1 << 24)
  116 #define EDMA_CFG_EDMAFBS         (1 << 26)
  117 #define EDMA_T                  0x4     /* Timer */
  118 #define EDMA_IEC                0x8     /* Interrupt Error Cause */
  119 #define EDMA_IEM                0xc     /* Interrupt Error Mask */
  120 #define EDMA_IE_EDEVERR          (1 << 2)       /* EDMA Device Error */
  121 #define EDMA_IE_EDEVDIS          (1 << 3)       /* EDMA Dev Disconn */
  122 #define EDMA_IE_EDEVCON          (1 << 4)       /* EDMA Dev Conn */
  123 #define EDMA_IE_SERRINT          (1 << 5)
  124 #define EDMA_IE_ESELFDIS         (1 << 7)       /* EDMA Self Disable */
  125 #define EDMA_IE_ETRANSINT        (1 << 8)       /* Transport Layer */
  126 #define EDMA_IE_EIORDYERR        (1 << 12)      /* EDMA IORdy Error */
  127 #define EDMA_IE_LINKXERR_SATACRC (1 << 0)       /* SATA CRC error */
  128 #define EDMA_IE_LINKXERR_INTERNALFIFO   (1 << 1)        /* internal FIFO err */
  129 #define EDMA_IE_LINKXERR_LINKLAYERRESET (1 << 2)
  130         /* Link Layer is reset by the reception of SYNC primitive from device */
  131 #define EDMA_IE_LINKXERR_OTHERERRORS    (1 << 3)
  132         /*
  133          * Link state errors, coding errors, or running disparity errors occur
  134          * during FIS reception.
  135          */
  136 #define EDMA_IE_LINKTXERR_FISTXABORTED   (1 << 4)       /* FIS Tx is aborted */
  137 #define EDMA_IE_LINKCTLRXERR(x)         ((x) << 13)     /* Link Ctrl Recv Err */
  138 #define EDMA_IE_LINKDATARXERR(x)        ((x) << 17)     /* Link Data Recv Err */
  139 #define EDMA_IE_LINKCTLTXERR(x)         ((x) << 21)     /* Link Ctrl Tx Error */
  140 #define EDMA_IE_LINKDATATXERR(x)        ((x) << 26)     /* Link Data Tx Error */
  141 #define EDMA_IE_TRANSPROTERR            (1 << 31)       /* Transport Proto E */
  142 #define EDMA_IE_TRANSIENT               (EDMA_IE_LINKCTLRXERR(0x0b) | \
  143                                          EDMA_IE_LINKCTLTXERR(0x1f))
  144                                                         /* Non-fatal Errors */
  145 #define EDMA_REQQBAH            0x10    /* Request Queue Base Address High */
  146 #define EDMA_REQQIP             0x14    /* Request Queue In-Pointer */
  147 #define EDMA_REQQOP             0x18    /* Request Queue Out-Pointer */
  148 #define EDMA_REQQP_ERQQP_SHIFT   5
  149 #define EDMA_REQQP_ERQQP_MASK    0x000003e0
  150 #define EDMA_REQQP_ERQQBAP_MASK  0x00000c00
  151 #define EDMA_REQQP_ERQQBA_MASK   0xfffff000
  152 #define EDMA_RESQBAH            0x1c    /* Response Queue Base Address High */
  153 #define EDMA_RESQIP             0x20    /* Response Queue In-Pointer */
  154 #define EDMA_RESQOP             0x24    /* Response Queue Out-Pointer */
  155 #define EDMA_RESQP_ERPQP_SHIFT   3
  156 #define EDMA_RESQP_ERPQP_MASK    0x000000f8
  157 #define EDMA_RESQP_ERPQBAP_MASK  0x00000300
  158 #define EDMA_RESQP_ERPQBA_MASK   0xfffffc00
  159 #define EDMA_CMD                0x28    /* Command */
  160 #define EDMA_CMD_EENEDMA         (1 << 0)       /* Enable EDMA */
  161 #define EDMA_CMD_EDSEDMA         (1 << 1)       /* Disable EDMA */
  162 #define EDMA_CMD_EATARST         (1 << 2)       /* ATA Device Reset */
  163 #define EDMA_CMD_EEDMAFRZ        (1 << 4)       /* EDMA Freeze */
  164 #define EDMA_TC                 0x2c    /* Test Control */
  165 #define EDMA_S                  0x30    /* Status */
  166 #define EDMA_S_EDEVQUETAG(s)     ((s) & 0x0000001f)
  167 #define EDMA_S_EDEVDIR_WRITE     (0 << 5)
  168 #define EDMA_S_EDEVDIR_READ      (1 << 5)
  169 #define EDMA_S_ECACHEEMPTY       (1 << 6)
  170 #define EDMA_S_EDMAIDLE          (1 << 7)
  171 #define EDMA_S_ESTATE(s)         (((s) & 0x0000ff00) >> 8)
  172 #define EDMA_S_EIOID(s)          (((s) & 0x003f0000) >> 16)
  173 #define EDMA_IORT               0x34    /* IORdy Timeout */
  174 #define EDMA_CDT                0x40    /* Command Delay Threshold */
  175 #define EDMA_HC                 0x60    /* Halt Condition */
  176 #define EDMA_UNKN_RESD          0x6C    /* Unknown register */
  177 #define EDMA_CQDCQOS(x)         (0x90 + ((x) << 2)
  178                                         /* NCQ Done/TCQ Outstanding Status */
  179 
  180 /* ATA register defines */
  181 #define ATA_DATA                        0x100   /* (RW) data */
  182 #define ATA_FEATURE                     0x104   /* (W) feature */
  183 #define         ATA_F_DMA                0x01   /* enable DMA */
  184 #define         ATA_F_OVL                0x02   /* enable overlap */
  185 #define ATA_ERROR                       0x104   /* (R) error */
  186 #define         ATA_E_ILI                0x01   /* illegal length */
  187 #define         ATA_E_NM                 0x02   /* no media */
  188 #define         ATA_E_ABORT              0x04   /* command aborted */
  189 #define         ATA_E_MCR                0x08   /* media change request */
  190 #define         ATA_E_IDNF               0x10   /* ID not found */
  191 #define         ATA_E_MC                 0x20   /* media changed */
  192 #define         ATA_E_UNC                0x40   /* uncorrectable data */
  193 #define         ATA_E_ICRC               0x80   /* UDMA crc error */
  194 #define         ATA_E_ATAPI_SENSE_MASK   0xf0   /* ATAPI sense key mask */
  195 #define ATA_COUNT                       0x108   /* (W) sector count */
  196 #define ATA_IREASON                     0x108   /* (R) interrupt reason */
  197 #define         ATA_I_CMD                0x01   /* cmd (1) | data (0) */
  198 #define         ATA_I_IN                 0x02   /* read (1) | write (0) */
  199 #define         ATA_I_RELEASE            0x04   /* released bus (1) */
  200 #define         ATA_I_TAGMASK            0xf8   /* tag mask */
  201 #define ATA_SECTOR                      0x10c   /* (RW) sector # */
  202 #define ATA_CYL_LSB                     0x110   /* (RW) cylinder# LSB */
  203 #define ATA_CYL_MSB                     0x114   /* (RW) cylinder# MSB */
  204 #define ATA_DRIVE                       0x118   /* (W) Sector/Drive/Head */
  205 #define         ATA_D_LBA                0x40   /* use LBA addressing */
  206 #define         ATA_D_IBM                0xa0   /* 512 byte sectors, ECC */
  207 #define ATA_COMMAND                     0x11c   /* (W) command */
  208 #define ATA_STATUS                      0x11c   /* (R) status */
  209 #define         ATA_S_ERROR              0x01   /* error */
  210 #define         ATA_S_INDEX              0x02   /* index */
  211 #define         ATA_S_CORR               0x04   /* data corrected */
  212 #define         ATA_S_DRQ                0x08   /* data request */
  213 #define         ATA_S_DSC                0x10   /* drive seek completed */
  214 #define         ATA_S_SERVICE            0x10   /* drive needs service */
  215 #define         ATA_S_DWF                0x20   /* drive write fault */
  216 #define         ATA_S_DMA                0x20   /* DMA ready */
  217 #define         ATA_S_READY              0x40   /* drive ready */
  218 #define         ATA_S_BUSY               0x80   /* busy */
  219 #define ATA_CONTROL                     0x120   /* (W) control */
  220 #define         ATA_A_IDS                0x02   /* disable interrupts */
  221 #define         ATA_A_RESET              0x04   /* RESET controller */
  222 #define         ATA_A_4BIT               0x08   /* 4 head bits */
  223 #define         ATA_A_HOB                0x80   /* High Order Byte enable */
  224 #define ATA_ALTSTAT                     0x120   /* (R) alternate status */
  225 #define ATAPI_P_READ                    (ATA_S_DRQ | ATA_I_IN)
  226 #define ATAPI_P_WRITE                   (ATA_S_DRQ)
  227 #define ATAPI_P_CMDOUT                  (ATA_S_DRQ | ATA_I_CMD)
  228 #define ATAPI_P_DONEDRQ                 (ATA_S_DRQ | ATA_I_CMD | ATA_I_IN)
  229 #define ATAPI_P_DONE                    (ATA_I_CMD | ATA_I_IN)
  230 #define ATAPI_P_ABORT                   0
  231 
  232 /* Basic DMA Registers */
  233 #define DMA_C                           0x224   /* Basic DMA Command */
  234 #define DMA_C_START                      (1 << 0)
  235 #define DMA_C_READ                       (1 << 3)
  236 #define DMA_C_DREGIONVALID               (1 << 8)
  237 #define DMA_C_DREGIONLAST                (1 << 9)
  238 #define DMA_C_CONTFROMPREV               (1 << 10)
  239 #define DMA_C_DRBC(n)                    (((n) & 0xffff) << 16)
  240 #define DMA_S                           0x228   /* Basic DMA Status */
  241 #define DMA_S_ACT                        (1 << 0) /* Active */
  242 #define DMA_S_ERR                        (1 << 1) /* Error */
  243 #define DMA_S_PAUSED                     (1 << 2) /* Paused */
  244 #define DMA_S_LAST                       (1 << 3) /* Last */
  245 #define DMA_DTLBA                       0x22c   /* Descriptor Table Low Base Address */
  246 #define DMA_DTLBA_MASK                   0xfffffff0
  247 #define DMA_DTHBA                       0x230   /* Descriptor Table High Base Address */
  248 #define DMA_DRLA                        0x234   /* Data Region Low Address */
  249 #define DMA_DRHA                        0x238   /* Data Region High Address */
  250 
  251 /* Serial-ATA Registers */
  252 #define SATA_SS                         0x300   /* SStatus */
  253 #define        SATA_SS_DET_MASK         0x0000000f
  254 #define        SATA_SS_DET_NO_DEVICE    0x00000000
  255 #define        SATA_SS_DET_DEV_PRESENT  0x00000001
  256 #define        SATA_SS_DET_PHY_ONLINE   0x00000003
  257 #define        SATA_SS_DET_PHY_OFFLINE  0x00000004
  258 
  259 #define        SATA_SS_SPD_MASK         0x000000f0
  260 #define        SATA_SS_SPD_NO_SPEED     0x00000000
  261 #define        SATA_SS_SPD_GEN1         0x00000010
  262 #define        SATA_SS_SPD_GEN2         0x00000020
  263 #define        SATA_SS_SPD_GEN3         0x00000040
  264 
  265 #define        SATA_SS_IPM_MASK         0x00000f00
  266 #define        SATA_SS_IPM_NO_DEVICE    0x00000000
  267 #define        SATA_SS_IPM_ACTIVE       0x00000100
  268 #define        SATA_SS_IPM_PARTIAL      0x00000200
  269 #define        SATA_SS_IPM_SLUMBER      0x00000600
  270 #define SATA_SE                         0x304   /* SError */
  271 #define SATA_SEIM                       0x340   /* SError Interrupt Mask */
  272 #define        SATA_SE_DATA_CORRECTED   0x00000001
  273 #define        SATA_SE_COMM_CORRECTED   0x00000002
  274 #define        SATA_SE_DATA_ERR         0x00000100
  275 #define        SATA_SE_COMM_ERR         0x00000200
  276 #define        SATA_SE_PROT_ERR         0x00000400
  277 #define        SATA_SE_HOST_ERR         0x00000800
  278 #define        SATA_SE_PHY_CHANGED      0x00010000
  279 #define        SATA_SE_PHY_IERROR       0x00020000
  280 #define        SATA_SE_COMM_WAKE        0x00040000
  281 #define        SATA_SE_DECODE_ERR       0x00080000
  282 #define        SATA_SE_PARITY_ERR       0x00100000
  283 #define        SATA_SE_CRC_ERR          0x00200000
  284 #define        SATA_SE_HANDSHAKE_ERR    0x00400000
  285 #define        SATA_SE_LINKSEQ_ERR      0x00800000
  286 #define        SATA_SE_TRANSPORT_ERR    0x01000000
  287 #define        SATA_SE_UNKNOWN_FIS      0x02000000
  288 #define SATA_SC                         0x308   /* SControl */
  289 #define        SATA_SC_DET_MASK         0x0000000f
  290 #define        SATA_SC_DET_IDLE         0x00000000
  291 #define        SATA_SC_DET_RESET        0x00000001
  292 #define        SATA_SC_DET_DISABLE      0x00000004
  293 
  294 #define        SATA_SC_SPD_MASK         0x000000f0
  295 #define        SATA_SC_SPD_NO_SPEED     0x00000000
  296 #define        SATA_SC_SPD_SPEED_GEN1   0x00000010
  297 #define        SATA_SC_SPD_SPEED_GEN2   0x00000020
  298 #define        SATA_SC_SPD_SPEED_GEN3   0x00000040
  299 
  300 #define        SATA_SC_IPM_MASK         0x00000f00
  301 #define        SATA_SC_IPM_NONE         0x00000000
  302 #define        SATA_SC_IPM_DIS_PARTIAL  0x00000100
  303 #define        SATA_SC_IPM_DIS_SLUMBER  0x00000200
  304 
  305 #define        SATA_SC_SPM_MASK         0x0000f000
  306 #define        SATA_SC_SPM_NONE         0x00000000
  307 #define        SATA_SC_SPM_PARTIAL      0x00001000
  308 #define        SATA_SC_SPM_SLUMBER      0x00002000
  309 #define        SATA_SC_SPM_ACTIVE       0x00004000
  310 #define SATA_LTM                        0x30c   /* LTMode */
  311 #define SATA_PHYM3                      0x310   /* PHY Mode 3 */
  312 #define SATA_PHYM4                      0x314   /* PHY Mode 4 */
  313 #define SATA_PHYM1                      0x32c   /* PHY Mode 1 */
  314 #define SATA_PHYM2                      0x330   /* PHY Mode 2 */
  315 #define SATA_BISTC                      0x334   /* BIST Control */
  316 #define SATA_BISTDW1                    0x338   /* BIST DW1 */
  317 #define SATA_BISTDW2                    0x33c   /* BIST DW2 */
  318 #define SATA_SATAICFG                   0x050   /* Serial-ATA Interface Configuration */
  319 #define SATA_SATAICFG_REFCLKCNF_20MHZ    (0 << 0)
  320 #define SATA_SATAICFG_REFCLKCNF_25MHZ    (1 << 0)
  321 #define SATA_SATAICFG_REFCLKCNF_30MHZ    (2 << 0)
  322 #define SATA_SATAICFG_REFCLKCNF_40MHZ    (3 << 0)
  323 #define SATA_SATAICFG_REFCLKCNF_MASK     (3 << 0)
  324 #define SATA_SATAICFG_REFCLKDIV_1        (0 << 2)
  325 #define SATA_SATAICFG_REFCLKDIV_2        (1 << 2)       /* Used 20 or 25MHz */
  326 #define SATA_SATAICFG_REFCLKDIV_4        (2 << 2)       /* Used 40MHz */
  327 #define SATA_SATAICFG_REFCLKDIV_3        (3 << 2)       /* Used 30MHz */
  328 #define SATA_SATAICFG_REFCLKDIV_MASK     (3 << 2)
  329 #define SATA_SATAICFG_REFCLKFEEDDIV_50   (0 << 4)       /* or 100, when Gen2En is 1 */
  330 #define SATA_SATAICFG_REFCLKFEEDDIV_60   (1 << 4)       /* or 120. Used 25MHz */
  331 #define SATA_SATAICFG_REFCLKFEEDDIV_75   (2 << 4)       /* or 150. Used 20MHz */
  332 #define SATA_SATAICFG_REFCLKFEEDDIV_90   (3 << 4)       /* or 180 */
  333 #define SATA_SATAICFG_REFCLKFEEDDIV_MASK (3 << 4)
  334 #define SATA_SATAICFG_PHYSSCEN           (1 << 6)
  335 #define SATA_SATAICFG_GEN2EN             (1 << 7)
  336 #define SATA_SATAICFG_COMMEN             (1 << 8)
  337 #define SATA_SATAICFG_PHYSHUTDOWN        (1 << 9)
  338 #define SATA_SATAICFG_TARGETMODE         (1 << 10)      /* 1 = Initiator */
  339 #define SATA_SATAICFG_COMCHANNEL         (1 << 11)
  340 #define SATA_SATAICFG_IGNOREBSY          (1 << 24)
  341 #define SATA_SATAICFG_LINKRSTEN          (1 << 25)
  342 #define SATA_SATAICFG_CMDRETXDS          (1 << 26)
  343 #define SATA_SATAICTL                   0x344   /* Serial-ATA Interface Control */
  344 #define SATA_SATAICTL_PMPTX_MASK         0x0000000f
  345 #define SATA_SATAICTL_PMPTX_SHIFT        0
  346 #define SATA_SATAICTL_VUM                (1 << 8)
  347 #define SATA_SATAICTL_VUS                (1 << 9)
  348 #define SATA_SATAICTL_EDMAACT            (1 << 16)
  349 #define SATA_SATAICTL_CLEARSTAT          (1 << 24)
  350 #define SATA_SATAICTL_SRST               (1 << 25)
  351 #define SATA_SATAITC                    0x348   /* Serial-ATA Interface Test Control */
  352 #define SATA_SATAIS                     0x34c   /* Serial-ATA Interface Status */
  353 #define SATA_VU                         0x35c   /* Vendor Unique */
  354 #define SATA_FISC                       0x360   /* FIS Configuration */
  355 #define SATA_FISC_FISWAIT4RDYEN_B0       (1 << 0) /* Device to Host FIS */
  356 #define SATA_FISC_FISWAIT4RDYEN_B1       (1 << 1) /* SDB FIS rcv with <N>bit 0 */
  357 #define SATA_FISC_FISWAIT4RDYEN_B2       (1 << 2) /* DMA Activate FIS */
  358 #define SATA_FISC_FISWAIT4RDYEN_B3       (1 << 3) /* DMA Setup FIS */
  359 #define SATA_FISC_FISWAIT4RDYEN_B4       (1 << 4) /* Data FIS first DW */
  360 #define SATA_FISC_FISWAIT4RDYEN_B5       (1 << 5) /* Data FIS entire FIS */
  361 #define SATA_FISC_FISWAIT4HOSTRDYEN_B0   (1 << 8)
  362                                 /* Device to Host FIS with <ERR> or <DF> */
  363 #define SATA_FISC_FISWAIT4HOSTRDYEN_B1   (1 << 9) /* SDB FIS rcv with <N>bit */
  364 #define SATA_FISC_FISWAIT4HOSTRDYEN_B2   (1 << 10) /* SDB FIS rcv with <ERR> */
  365 #define SATA_FISC_FISWAIT4HOSTRDYEN_B3   (1 << 11) /* BIST Acivate FIS */
  366 #define SATA_FISC_FISWAIT4HOSTRDYEN_B4   (1 << 12) /* PIO Setup FIS */
  367 #define SATA_FISC_FISWAIT4HOSTRDYEN_B5   (1 << 13) /* Data FIS with Link error */
  368 #define SATA_FISC_FISWAIT4HOSTRDYEN_B6   (1 << 14) /* Unrecognized FIS type */
  369 #define SATA_FISC_FISWAIT4HOSTRDYEN_B7   (1 << 15) /* Any FIS */
  370 #define SATA_FISC_FISDMAACTIVATESYNCRESP (1 << 16)
  371 #define SATA_FISC_FISUNRECTYPECONT       (1 << 17)
  372 #define SATA_FISIC                      0x364   /* FIS Interrupt Cause */
  373 #define SATA_FISIM                      0x368   /* FIS Interrupt Mask */
  374 #define SATA_FISDW0                     0x370   /* FIS DW0 */
  375 #define SATA_FISDW1                     0x374   /* FIS DW1 */
  376 #define SATA_FISDW2                     0x378   /* FIS DW2 */
  377 #define SATA_FISDW3                     0x37c   /* FIS DW3 */
  378 #define SATA_FISDW4                     0x380   /* FIS DW4 */
  379 #define SATA_FISDW5                     0x384   /* FIS DW5 */
  380 #define SATA_FISDW6                     0x388   /* FIS DW6 */
  381 
  382 #define SATA_PHYM9_GEN2                 0x398
  383 #define SATA_PHYM9_GEN1                 0x39c
  384 #define SATA_PHYCFG_OFS                 0x3a0   /* 65nm SoCs only */
  385 
  386 #define MVS_MAX_PORTS                   8
  387 #define MVS_MAX_SLOTS                   32
  388 
  389 /* Pessimistic prognosis on number of required S/G entries */
  390 #define MVS_SG_ENTRIES          (btoc(MAXPHYS) + 1)
  391 
  392 /* EDMA Command Request Block (CRQB) Data */
  393 struct mvs_crqb {
  394         uint32_t cprdbl;        /* cPRD Desriptor Table Base Low Address */
  395         uint32_t cprdbh;        /* cPRD Desriptor Table Base High Address */
  396         uint16_t ctrlflg;       /* Control Flags */
  397 #define MVS_CRQB_READ           0x0001
  398 #define MVS_CRQB_TAG_MASK       0x003e
  399 #define MVS_CRQB_TAG_SHIFT      1
  400 #define MVS_CRQB_PMP_MASK       0xf000
  401 #define MVS_CRQB_PMP_SHIFT      12
  402         uint8_t cmd[22];
  403 } __packed;
  404 
  405 struct mvs_crqb_gen2e {
  406         uint32_t cprdbl;        /* cPRD Desriptor Table Base Low Address */
  407         uint32_t cprdbh;        /* cPRD Desriptor Table Base High Address */
  408         uint32_t ctrlflg;       /* Control Flags */
  409 #define MVS_CRQB2E_READ         0x00000001
  410 #define MVS_CRQB2E_DTAG_MASK    0x0000003e
  411 #define MVS_CRQB2E_DTAG_SHIFT   1
  412 #define MVS_CRQB2E_PMP_MASK     0x0000f000
  413 #define MVS_CRQB2E_PMP_SHIFT    12
  414 #define MVS_CRQB2E_CPRD         0x00010000
  415 #define MVS_CRQB2E_HTAG_MASK    0x003e0000
  416 #define MVS_CRQB2E_HTAG_SHIFT   17
  417         uint32_t drbc;          /* Data Region Byte Count */
  418         uint8_t cmd[16];
  419 } __packed;
  420 
  421 /* EDMA Phisical Region Descriptors (ePRD) Table Data Structure */
  422 struct mvs_eprd {
  423         uint32_t prdbal;        /* Address bits[31:1] */
  424         uint32_t bytecount;     /* Byte Count */
  425 #define MVS_EPRD_MASK           0x0000ffff      /* max 64KB */
  426 #define MVS_EPRD_MAX            (MVS_EPRD_MASK + 1)
  427 #define MVS_EPRD_EOF            0x80000000
  428         uint32_t prdbah;        /* Address bits[63:32] */
  429         uint32_t resv;
  430 } __packed;
  431 
  432 /* Command request blocks. 32 commands. First 1Kbyte aligned. */
  433 #define MVS_CRQB_OFFSET         0
  434 #define MVS_CRQB_SIZE           32      /* sizeof(struct mvs_crqb) */
  435 #define MVS_CRQB_MASK           0x000003e0
  436 #define MVS_CRQB_SHIFT          5
  437 #define MVS_CRQB_TO_ADDR(slot)  ((slot) << MVS_CRQB_SHIFT)
  438 #define MVS_ADDR_TO_CRQB(addr)  (((addr) & MVS_CRQB_MASK) >> MVS_CRQB_SHIFT)
  439 /* ePRD blocks. Up to 32 commands, Each 16byte aligned. */
  440 #define MVS_EPRD_OFFSET         (MVS_CRQB_OFFSET + MVS_CRQB_SIZE * MVS_MAX_SLOTS)
  441 #define MVS_EPRD_SIZE           (MVS_SG_ENTRIES * 16) /* sizeof(struct mvs_eprd) */
  442 /* Request work area. */
  443 #define MVS_WORKRQ_SIZE         (MVS_EPRD_OFFSET + MVS_EPRD_SIZE * MVS_MAX_SLOTS)
  444 
  445 /* EDMA Command Response Block (CRPB) Data */
  446 struct mvs_crpb {
  447         uint16_t id;            /* CRPB ID */
  448 #define MVS_CRPB_TAG_MASK       0x001F
  449 #define MVS_CRPB_TAG_SHIFT      0
  450         uint16_t rspflg;        /* CPRB Response Flags */
  451 #define MVS_CRPB_EDMASTS_MASK   0x007F
  452 #define MVS_CRPB_EDMASTS_SHIFT  0
  453 #define MVS_CRPB_ATASTS_MASK    0xFF00
  454 #define MVS_CRPB_ATASTS_SHIFT   8
  455         uint32_t ts;            /* CPRB Time Stamp */
  456 } __packed;
  457 
  458 /* Command response blocks. 32 commands. First 256byte aligned. */
  459 #define MVS_CRPB_OFFSET         0
  460 #define MVS_CRPB_SIZE           sizeof(struct mvs_crpb)
  461 #define MVS_CRPB_MASK           0x000000f8
  462 #define MVS_CRPB_SHIFT          3
  463 #define MVS_CRPB_TO_ADDR(slot)  ((slot) << MVS_CRPB_SHIFT)
  464 #define MVS_ADDR_TO_CRPB(addr)  (((addr) & MVS_CRPB_MASK) >> MVS_CRPB_SHIFT)
  465 /* Request work area. */
  466 #define MVS_WORKRP_SIZE         (MVS_CRPB_OFFSET + MVS_CRPB_SIZE * MVS_MAX_SLOTS)
  467 
  468 /* misc defines */
  469 #define ATA_IRQ_RID             0
  470 #define ATA_INTR_FLAGS          (INTR_MPSAFE|INTR_TYPE_BIO|INTR_ENTROPY)
  471 
  472 struct ata_dmaslot {
  473     bus_dmamap_t                data_map;       /* Data DMA map */
  474     bus_addr_t                  addr;           /* Data address */
  475     uint16_t                    len;            /* Data size */
  476 };
  477 
  478 /* structure holding DMA related information */
  479 struct mvs_dma {
  480     bus_dma_tag_t               workrq_tag;     /* Request workspace DMA tag */
  481     bus_dmamap_t                workrq_map;     /* Request workspace DMA map */
  482     uint8_t                     *workrq;        /* Request workspace */
  483     bus_addr_t                  workrq_bus;     /* Request bus address */
  484     bus_dma_tag_t               workrp_tag;     /* Reply workspace DMA tag */
  485     bus_dmamap_t                workrp_map;     /* Reply workspace DMA map */
  486     uint8_t                     *workrp;        /* Reply workspace */
  487     bus_addr_t                  workrp_bus;     /* Reply bus address */
  488     bus_dma_tag_t               data_tag;       /* Data DMA tag */
  489 };
  490 
  491 enum mvs_slot_states {
  492         MVS_SLOT_EMPTY,
  493         MVS_SLOT_LOADING,
  494         MVS_SLOT_RUNNING,
  495         MVS_SLOT_EXECUTING
  496 };
  497 
  498 struct mvs_slot {
  499     device_t                    dev;            /* Device handle */
  500     int                         slot;           /* Number of this slot */
  501     int                         tag;            /* Used command tag */
  502     enum mvs_slot_states        state;          /* Slot state */
  503     union ccb                   *ccb;           /* CCB occupying slot */
  504     struct ata_dmaslot          dma;            /* DMA data of this slot */
  505     struct callout              timeout;        /* Execution timeout */
  506 };
  507 
  508 struct mvs_device {
  509         int                     revision;
  510         int                     mode;
  511         u_int                   bytecount;
  512         u_int                   atapi;
  513         u_int                   tags;
  514         u_int                   caps;
  515 };
  516 
  517 enum mvs_edma_mode {
  518         MVS_EDMA_UNKNOWN,
  519         MVS_EDMA_OFF,
  520         MVS_EDMA_ON,
  521         MVS_EDMA_QUEUED,
  522         MVS_EDMA_NCQ,
  523 };
  524 
  525 /* structure describing an ATA channel */
  526 struct mvs_channel {
  527         device_t                dev;            /* Device handle */
  528         int                     unit;           /* Physical channel */
  529         struct resource         *r_mem;         /* Memory of this channel */
  530         struct resource         *r_irq;         /* Interrupt of this channel */
  531         void                    *ih;            /* Interrupt handle */
  532         struct mvs_dma          dma;            /* DMA data */
  533         struct cam_sim          *sim;
  534         struct cam_path         *path;
  535         int                     quirks;
  536 #define MVS_Q_GENI      1
  537 #define MVS_Q_GENII     2
  538 #define MVS_Q_GENIIE    4
  539 #define MVS_Q_SOC       8
  540 #define MVS_Q_CT        16
  541 #define MVS_Q_SOC65     32
  542         int                     pm_level;       /* power management level */
  543 
  544         struct mvs_slot         slot[MVS_MAX_SLOTS];
  545         union ccb               *hold[MVS_MAX_SLOTS];
  546         int                     holdtag[MVS_MAX_SLOTS]; /* Tags used for held commands. */
  547         struct mtx              mtx;            /* state lock */
  548         int                     devices;        /* What is present */
  549         int                     pm_present;     /* PM presence reported */
  550         enum mvs_edma_mode      curr_mode;      /* Current EDMA mode */
  551         int                     fbs_enabled;    /* FIS-based switching enabled */
  552         uint32_t                oslots;         /* Occupied slots */
  553         uint32_t                otagspd[16];    /* Occupied device tags */
  554         uint32_t                rslots;         /* Running slots */
  555         uint32_t                aslots;         /* Slots with atomic commands  */
  556         uint32_t                eslots;         /* Slots in error */
  557         uint32_t                toslots;        /* Slots in timeout */
  558         int                     numrslots;      /* Number of running slots */
  559         int                     numrslotspd[16];/* Number of running slots per dev */
  560         int                     numpslots;      /* Number of PIO slots */
  561         int                     numdslots;      /* Number of DMA slots */
  562         int                     numtslots;      /* Number of NCQ slots */
  563         int                     numtslotspd[16];/* Number of NCQ slots per dev */
  564         int                     numhslots;      /* Number of held slots */
  565         int                     recoverycmd;    /* Our READ LOG active */
  566         int                     fatalerr;       /* Fatal error happend */
  567         int                     lastslot;       /* Last used slot */
  568         int                     taggedtarget;   /* Last tagged target */
  569         int                     resetting;      /* Hard-reset in progress. */
  570         int                     resetpolldiv;   /* Hard-reset poll divider. */
  571         int                     out_idx;        /* Next written CRQB */
  572         int                     in_idx;         /* Next read CRPB */
  573         u_int                   transfersize;   /* PIO transfer size */
  574         u_int                   donecount;      /* PIO bytes sent/received */
  575         u_int                   basic_dma;      /* Basic DMA used for ATAPI */
  576         u_int                   fake_busy;      /* Fake busy bit after command submission */
  577         union ccb               *frozen;        /* Frozen command */
  578         struct callout          pm_timer;       /* Power management events */
  579         struct callout          reset_timer;    /* Hard-reset timeout */
  580 
  581         struct mvs_device       user[16];       /* User-specified settings */
  582         struct mvs_device       curr[16];       /* Current settings */
  583 };
  584 
  585 /* structure describing a MVS controller */
  586 struct mvs_controller {
  587         device_t                dev;
  588         int                     r_rid;
  589         struct resource         *r_mem;
  590         struct rman             sc_iomem;
  591         struct mvs_controller_irq {
  592                 struct resource         *r_irq;
  593                 void                    *handle;
  594                 int                     r_irq_rid;
  595         } irq;
  596         int                     quirks;
  597         int                     channels;
  598         int                     ccc;            /* CCC timeout */
  599         int                     cccc;           /* CCC commands */
  600         struct mtx              mtx;            /* MIM access lock */
  601         int                     gmim;           /* Globally wanted MIM bits */
  602         int                     pmim;           /* Port wanted MIM bits */
  603         int                     mim;            /* Current MIM bits */
  604         int                     msi;            /* MSI enabled */
  605         int                     msia;           /* MSI active */
  606         struct {
  607                 void                    (*function)(void *);
  608                 void                    *argument;
  609         } interrupt[MVS_MAX_PORTS];
  610 };
  611 
  612 enum mvs_err_type {
  613         MVS_ERR_NONE,           /* No error */
  614         MVS_ERR_INVALID,        /* Error detected by us before submitting. */
  615         MVS_ERR_INNOCENT,       /* Innocent victim. */
  616         MVS_ERR_TFE,            /* Task File Error. */
  617         MVS_ERR_SATA,           /* SATA error. */
  618         MVS_ERR_TIMEOUT,        /* Command execution timeout. */
  619         MVS_ERR_NCQ,            /* NCQ command error. CCB should be put on hold
  620                                  * until READ LOG executed to reveal error. */
  621 };
  622 
  623 struct mvs_intr_arg {
  624         void *arg;
  625         u_int cause;
  626 };
  627 
  628 extern devclass_t mvs_devclass;
  629 
  630 /* macros to hide busspace uglyness */
  631 #define ATA_INB(res, offset) \
  632         bus_read_1((res), (offset))
  633 #define ATA_INW(res, offset) \
  634         bus_read_2((res), (offset))
  635 #define ATA_INL(res, offset) \
  636         bus_read_4((res), (offset))
  637 #define ATA_INSW(res, offset, addr, count) \
  638         bus_read_multi_2((res), (offset), (addr), (count))
  639 #define ATA_INSW_STRM(res, offset, addr, count) \
  640         bus_read_multi_stream_2((res), (offset), (addr), (count))
  641 #define ATA_INSL(res, offset, addr, count) \
  642         bus_read_multi_4((res), (offset), (addr), (count))
  643 #define ATA_INSL_STRM(res, offset, addr, count) \
  644         bus_read_multi_stream_4((res), (offset), (addr), (count))
  645 #define ATA_OUTB(res, offset, value) \
  646         bus_write_1((res), (offset), (value))
  647 #define ATA_OUTW(res, offset, value) \
  648         bus_write_2((res), (offset), (value))
  649 #define ATA_OUTL(res, offset, value) \
  650         bus_write_4((res), (offset), (value));
  651 #define ATA_OUTSW(res, offset, addr, count) \
  652         bus_write_multi_2((res), (offset), (addr), (count))
  653 #define ATA_OUTSW_STRM(res, offset, addr, count) \
  654         bus_write_multi_stream_2((res), (offset), (addr), (count))
  655 #define ATA_OUTSL(res, offset, addr, count) \
  656         bus_write_multi_4((res), (offset), (addr), (count))
  657 #define ATA_OUTSL_STRM(res, offset, addr, count) \
  658         bus_write_multi_stream_4((res), (offset), (addr), (count))

Cache object: 930e7d8990964902b82ef4ca066280ba


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.