1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3 * 4 * This file is provided under a dual BSD/GPLv2 license. When using or 5 * redistributing this file, you may do so under either license. 6 * 7 * GPL LICENSE SUMMARY 8 * 9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of version 2 of the GNU General Public License as 13 * published by the Free Software Foundation. 14 * 15 * This program is distributed in the hope that it will be useful, but 16 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 23 * The full GNU General Public License is included in this distribution 24 * in the file called LICENSE.GPL. 25 * 26 * BSD LICENSE 27 * 28 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved. 29 * All rights reserved. 30 * 31 * Redistribution and use in source and binary forms, with or without 32 * modification, are permitted provided that the following conditions 33 * are met: 34 * 35 * * Redistributions of source code must retain the above copyright 36 * notice, this list of conditions and the following disclaimer. 37 * * Redistributions in binary form must reproduce the above copyright 38 * notice, this list of conditions and the following disclaimer in 39 * the documentation and/or other materials provided with the 40 * distribution. 41 * 42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 * 54 * $FreeBSD$ 55 */ 56 #ifndef _SATA_H_ 57 #define _SATA_H_ 58 59 #include <dev/isci/types.h> 60 61 /** 62 * @file 63 * 64 * @brief This file defines all of the SATA releated constants, enumerations, 65 * and types. Please note that this file does not necessarily contain 66 * an exhaustive list of all contants and commands. 67 */ 68 69 /** 70 * @name SATA FIS Types 71 * 72 * These constants depict the various SATA FIS types devined in the serial ATA 73 * specification. 74 */ 75 /*@{*/ 76 #define SATA_FIS_TYPE_REGH2D 0x27 77 #define SATA_FIS_TYPE_REGD2H 0x34 78 #define SATA_FIS_TYPE_SETDEVBITS 0xA1 79 #define SATA_FIS_TYPE_DMA_ACTIVATE 0x39 80 #define SATA_FIS_TYPE_DMA_SETUP 0x41 81 #define SATA_FIS_TYPE_BIST_ACTIVATE 0x58 82 #define SATA_FIS_TYPE_PIO_SETUP 0x5F 83 #define SATA_FIS_TYPE_DATA 0x46 84 /*@}*/ 85 86 #define SATA_REGISTER_FIS_SIZE 0x20 87 88 /** 89 * @struct SATA_FIS_HEADER 90 * 91 * @brief This is the common definition for a SATA FIS Header word. A 92 * different header word is defined for any FIS type that does not use 93 * the standard header. 94 */ 95 typedef struct SATA_FIS_HEADER 96 { 97 U32 fis_type :8; // word 0 98 U32 pm_port :4; 99 U32 reserved :1; 100 U32 direction_flag :1; // direction 101 U32 interrupt_flag :1; 102 U32 command_flag :1; // command, auto_activate, or notification 103 U32 status :8; 104 U32 error :8; 105 } SATA_FIS_HEADER_T; 106 107 108 /** 109 * @struct SATA_FIS_REG_H2D 110 * 111 * @brief This is the definition for a SATA Host to Device Register FIS. 112 */ 113 typedef struct SATA_FIS_REG_H2D 114 { 115 U32 fis_type :8; // word 0 116 U32 pm_port :4; 117 U32 reserved0 :3; 118 U32 command_flag :1; 119 U32 command :8; 120 U32 features :8; 121 U32 lba_low :8; // word 1 122 U32 lba_mid :8; 123 U32 lba_high :8; 124 U32 device :8; 125 U32 lba_low_exp :8; // word 2 126 U32 lba_mid_exp :8; 127 U32 lba_high_exp :8; 128 U32 features_exp :8; 129 U32 sector_count :8; // word 3 130 U32 sector_count_exp :8; 131 U32 reserved1 :8; 132 U32 control :8; 133 U32 reserved2; // word 4 134 } SATA_FIS_REG_H2D_T; 135 136 /** 137 * @struct SATA_FIS_REG_D2H 138 * 139 * @brief SATA Device To Host FIS 140 */ 141 typedef struct SATA_FIS_REG_D2H 142 { 143 U32 fis_type :8; // word 0 144 U32 pm_port :4; 145 U32 reserved0 :2; 146 U32 irq :1; 147 U32 reserved1 :1; 148 U32 status :8; 149 U32 error :8; 150 U8 lba_low; // word 1 151 U8 lba_mid; 152 U8 lba_high; 153 U8 device; 154 U8 lba_low_exp; // word 2 155 U8 lba_mid_exp; 156 U8 lba_high_exp; 157 U8 reserved; 158 U8 sector_count; // word 3 159 U8 sector_count_exp; 160 U16 reserved2; 161 U32 reserved3; 162 } SATA_FIS_REG_D2H_T; 163 164 /** 165 * Status field bit definitions 166 */ 167 #define SATA_FIS_STATUS_DEVBITS_MASK (0x77) 168 169 /** 170 * @struct SATA_FIS_SET_DEV_BITS 171 * 172 * @brief SATA Set Device Bits FIS 173 */ 174 typedef struct SATA_FIS_SET_DEV_BITS 175 { 176 U32 fis_type :8; // word 0 177 U32 pm_port :4; 178 U32 reserved0 :2; 179 U32 irq :1; 180 U32 notification :1; 181 U32 status_low :4; 182 U32 status_high :4; 183 U32 error :8; 184 U32 s_active; // word 1 185 } SATA_FIS_SET_DEV_BITS_T; 186 187 /** 188 * @struct SATA_FIS_DMA_ACTIVATE 189 * 190 * @brief SATA DMA Activate FIS 191 */ 192 typedef struct SATA_FIS_DMA_ACTIVATE 193 { 194 U32 fis_type :8; // word 0 195 U32 pm_port :4; 196 U32 reserved0 :24; 197 } SATA_FIS_DMA_ACTIVATE_T; 198 199 /** 200 * The lower 5 bits in the DMA Buffer ID Low field of the DMA Setup 201 * are used to communicate the command tag. 202 */ 203 #define SATA_DMA_SETUP_TAG_ENABLE 0x1F 204 205 #define SATA_DMA_SETUP_AUTO_ACT_ENABLE 0x80 206 207 /** 208 * @struct SATA_FIS_DMA_SETUP 209 * 210 * @brief SATA DMA Setup FIS 211 */ 212 typedef struct SATA_FIS_DMA_SETUP 213 { 214 U32 fis_type :8; // word 0 215 U32 pm_port :4; 216 U32 reserved_00 :1; 217 U32 direction :1; 218 U32 irq :1; 219 U32 auto_activate :1; 220 U32 reserved_01 :16; 221 U32 dma_buffer_id_low; // word 1 222 U32 dma_buffer_id_high; // word 2 223 U32 reserved0; // word 3 224 U32 dma_buffer_offset; // word 4 225 U32 dma_transfer_count; // word 5 226 U32 reserved1; // word 6 227 } SATA_FIS_DMA_SETUP_T; 228 229 /** 230 * @struct SATA_FIS_BIST_ACTIVATE 231 * 232 * @brief SATA BIST Activate FIS 233 */ 234 typedef struct SATA_FIS_BIST_ACTIVATE 235 { 236 U32 fis_type :8; // word 0 237 U32 reserved0 :8; 238 U32 pattern_definition :8; 239 U32 reserved1 :8; 240 U32 data1; // word 1 241 U32 data2; // word 1 242 } SATA_FIS_BIST_ACTIVATE_T; 243 244 /* 245 * SATA PIO Setup FIS 246 */ 247 typedef struct SATA_FIS_PIO_SETUP 248 { 249 U32 fis_type :8; // word 0 250 U32 pm_port :4; 251 U32 reserved_00 :1; 252 U32 direction :1; 253 U32 irq :1; 254 U32 reserved_01 :1; 255 U32 status :8; 256 U32 error :8; 257 U32 lba_low :8; // word 1 258 U32 lba_mid :8; 259 U32 lba_high :8; 260 U32 device :8; 261 U32 lba_low_exp :8; // word 2 262 U32 lba_mid_exp :8; 263 U32 lba_high_exp :8; 264 U32 reserved :8; 265 U32 sector_count :8; // word 3 266 U32 sector_count_exp :8; 267 U32 reserved1 :8; 268 U32 ending_status :8; 269 U32 transfter_count :16; // word 4 270 U32 reserved3 :16; 271 } SATA_FIS_PIO_SETUP_T; 272 273 /** 274 * @struct SATA_FIS_DATA 275 * 276 * @brief SATA Data FIS 277 */ 278 typedef struct SATA_FIS_DATA 279 { 280 U32 fis_type :8; // word 0 281 U32 pm_port :4; 282 U32 reserved0 :24; 283 U8 data[4]; // word 1 284 } SATA_FIS_DATA_T; 285 286 #endif // _SATA_H_ 287