1230557Sjimharris/*- 2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license. When using or 3230557Sjimharris * redistributing this file, you may do so under either license. 4230557Sjimharris * 5230557Sjimharris * GPL LICENSE SUMMARY 6230557Sjimharris * 7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8230557Sjimharris * 9230557Sjimharris * This program is free software; you can redistribute it and/or modify 10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as 11230557Sjimharris * published by the Free Software Foundation. 12230557Sjimharris * 13230557Sjimharris * This program is distributed in the hope that it will be useful, but 14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of 15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16230557Sjimharris * General Public License for more details. 17230557Sjimharris * 18230557Sjimharris * You should have received a copy of the GNU General Public License 19230557Sjimharris * along with this program; if not, write to the Free Software 20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21230557Sjimharris * The full GNU General Public License is included in this distribution 22230557Sjimharris * in the file called LICENSE.GPL. 23230557Sjimharris * 24230557Sjimharris * BSD LICENSE 25230557Sjimharris * 26230557Sjimharris * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved. 27230557Sjimharris * All rights reserved. 28230557Sjimharris * 29230557Sjimharris * Redistribution and use in source and binary forms, with or without 30230557Sjimharris * modification, are permitted provided that the following conditions 31230557Sjimharris * are met: 32230557Sjimharris * 33230557Sjimharris * * Redistributions of source code must retain the above copyright 34230557Sjimharris * notice, this list of conditions and the following disclaimer. 35230557Sjimharris * * Redistributions in binary form must reproduce the above copyright 36230557Sjimharris * notice, this list of conditions and the following disclaimer in 37230557Sjimharris * the documentation and/or other materials provided with the 38230557Sjimharris * distribution. 39230557Sjimharris * 40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51230557Sjimharris * 52230557Sjimharris * $FreeBSD$ 53230557Sjimharris */ 54230557Sjimharris#ifndef _SATA_H_ 55230557Sjimharris#define _SATA_H_ 56230557Sjimharris 57230557Sjimharris#include <dev/isci/types.h> 58230557Sjimharris 59230557Sjimharris/** 60230557Sjimharris * @file 61230557Sjimharris * 62230557Sjimharris * @brief This file defines all of the SATA releated constants, enumerations, 63230557Sjimharris * and types. Please note that this file does not necessarily contain 64230557Sjimharris * an exhaustive list of all contants and commands. 65230557Sjimharris */ 66230557Sjimharris 67230557Sjimharris/** 68230557Sjimharris * @name SATA FIS Types 69230557Sjimharris * 70230557Sjimharris * These constants depict the various SATA FIS types devined in the serial ATA 71230557Sjimharris * specification. 72230557Sjimharris */ 73230557Sjimharris/*@{*/ 74230557Sjimharris#define SATA_FIS_TYPE_REGH2D 0x27 75230557Sjimharris#define SATA_FIS_TYPE_REGD2H 0x34 76230557Sjimharris#define SATA_FIS_TYPE_SETDEVBITS 0xA1 77230557Sjimharris#define SATA_FIS_TYPE_DMA_ACTIVATE 0x39 78230557Sjimharris#define SATA_FIS_TYPE_DMA_SETUP 0x41 79230557Sjimharris#define SATA_FIS_TYPE_BIST_ACTIVATE 0x58 80230557Sjimharris#define SATA_FIS_TYPE_PIO_SETUP 0x5F 81230557Sjimharris#define SATA_FIS_TYPE_DATA 0x46 82230557Sjimharris/*@}*/ 83230557Sjimharris 84230557Sjimharris#define SATA_REGISTER_FIS_SIZE 0x20 85230557Sjimharris 86230557Sjimharris/** 87230557Sjimharris * @struct SATA_FIS_HEADER 88230557Sjimharris * 89230557Sjimharris * @brief This is the common definition for a SATA FIS Header word. A 90230557Sjimharris * different header word is defined for any FIS type that does not use 91230557Sjimharris * the standard header. 92230557Sjimharris */ 93230557Sjimharristypedef struct SATA_FIS_HEADER 94230557Sjimharris{ 95230557Sjimharris U32 fis_type :8; // word 0 96230557Sjimharris U32 pm_port :4; 97230557Sjimharris U32 reserved :1; 98230557Sjimharris U32 direction_flag :1; // direction 99230557Sjimharris U32 interrupt_flag :1; 100230557Sjimharris U32 command_flag :1; // command, auto_activate, or notification 101230557Sjimharris U32 status :8; 102230557Sjimharris U32 error :8; 103230557Sjimharris} SATA_FIS_HEADER_T; 104230557Sjimharris 105230557Sjimharris 106230557Sjimharris/** 107230557Sjimharris * @struct SATA_FIS_REG_H2D 108230557Sjimharris * 109230557Sjimharris * @brief This is the definition for a SATA Host to Device Register FIS. 110230557Sjimharris */ 111230557Sjimharristypedef struct SATA_FIS_REG_H2D 112230557Sjimharris{ 113230557Sjimharris U32 fis_type :8; // word 0 114230557Sjimharris U32 pm_port :4; 115230557Sjimharris U32 reserved0 :3; 116230557Sjimharris U32 command_flag :1; 117230557Sjimharris U32 command :8; 118230557Sjimharris U32 features :8; 119230557Sjimharris U32 lba_low :8; // word 1 120230557Sjimharris U32 lba_mid :8; 121230557Sjimharris U32 lba_high :8; 122230557Sjimharris U32 device :8; 123230557Sjimharris U32 lba_low_exp :8; // word 2 124230557Sjimharris U32 lba_mid_exp :8; 125230557Sjimharris U32 lba_high_exp :8; 126230557Sjimharris U32 features_exp :8; 127230557Sjimharris U32 sector_count :8; // word 3 128230557Sjimharris U32 sector_count_exp :8; 129230557Sjimharris U32 reserved1 :8; 130230557Sjimharris U32 control :8; 131230557Sjimharris U32 reserved2; // word 4 132230557Sjimharris} SATA_FIS_REG_H2D_T; 133230557Sjimharris 134230557Sjimharris/** 135230557Sjimharris * @struct SATA_FIS_REG_D2H 136230557Sjimharris * 137230557Sjimharris * @brief SATA Device To Host FIS 138230557Sjimharris */ 139230557Sjimharristypedef struct SATA_FIS_REG_D2H 140230557Sjimharris{ 141230557Sjimharris U32 fis_type :8; // word 0 142230557Sjimharris U32 pm_port :4; 143230557Sjimharris U32 reserved0 :2; 144230557Sjimharris U32 irq :1; 145230557Sjimharris U32 reserved1 :1; 146230557Sjimharris U32 status :8; 147230557Sjimharris U32 error :8; 148230557Sjimharris U8 lba_low; // word 1 149230557Sjimharris U8 lba_mid; 150230557Sjimharris U8 lba_high; 151230557Sjimharris U8 device; 152230557Sjimharris U8 lba_low_exp; // word 2 153230557Sjimharris U8 lba_mid_exp; 154230557Sjimharris U8 lba_high_exp; 155230557Sjimharris U8 reserved; 156230557Sjimharris U8 sector_count; // word 3 157230557Sjimharris U8 sector_count_exp; 158230557Sjimharris U16 reserved2; 159230557Sjimharris U32 reserved3; 160230557Sjimharris} SATA_FIS_REG_D2H_T; 161230557Sjimharris 162230557Sjimharris/** 163230557Sjimharris * Status field bit definitions 164230557Sjimharris */ 165230557Sjimharris#define SATA_FIS_STATUS_DEVBITS_MASK (0x77) 166230557Sjimharris 167230557Sjimharris/** 168230557Sjimharris * @struct SATA_FIS_SET_DEV_BITS 169230557Sjimharris * 170230557Sjimharris * @brief SATA Set Device Bits FIS 171230557Sjimharris */ 172230557Sjimharristypedef struct SATA_FIS_SET_DEV_BITS 173230557Sjimharris{ 174230557Sjimharris U32 fis_type :8; // word 0 175230557Sjimharris U32 pm_port :4; 176230557Sjimharris U32 reserved0 :2; 177230557Sjimharris U32 irq :1; 178230557Sjimharris U32 notification :1; 179230557Sjimharris U32 status_low :4; 180230557Sjimharris U32 status_high :4; 181230557Sjimharris U32 error :8; 182230557Sjimharris U32 s_active; // word 1 183230557Sjimharris} SATA_FIS_SET_DEV_BITS_T; 184230557Sjimharris 185230557Sjimharris/** 186230557Sjimharris * @struct SATA_FIS_DMA_ACTIVATE 187230557Sjimharris * 188230557Sjimharris * @brief SATA DMA Activate FIS 189230557Sjimharris */ 190230557Sjimharristypedef struct SATA_FIS_DMA_ACTIVATE 191230557Sjimharris{ 192230557Sjimharris U32 fis_type :8; // word 0 193230557Sjimharris U32 pm_port :4; 194230557Sjimharris U32 reserved0 :24; 195230557Sjimharris} SATA_FIS_DMA_ACTIVATE_T; 196230557Sjimharris 197230557Sjimharris/** 198230557Sjimharris * The lower 5 bits in the DMA Buffer ID Low field of the DMA Setup 199230557Sjimharris * are used to communicate the command tag. 200230557Sjimharris */ 201230557Sjimharris#define SATA_DMA_SETUP_TAG_ENABLE 0x1F 202230557Sjimharris 203230557Sjimharris#define SATA_DMA_SETUP_AUTO_ACT_ENABLE 0x80 204230557Sjimharris 205230557Sjimharris/** 206230557Sjimharris * @struct SATA_FIS_DMA_SETUP 207230557Sjimharris * 208230557Sjimharris * @brief SATA DMA Setup FIS 209230557Sjimharris */ 210230557Sjimharristypedef struct SATA_FIS_DMA_SETUP 211230557Sjimharris{ 212230557Sjimharris U32 fis_type :8; // word 0 213230557Sjimharris U32 pm_port :4; 214230557Sjimharris U32 reserved_00 :1; 215230557Sjimharris U32 direction :1; 216230557Sjimharris U32 irq :1; 217230557Sjimharris U32 auto_activate :1; 218230557Sjimharris U32 reserved_01 :16; 219230557Sjimharris U32 dma_buffer_id_low; // word 1 220230557Sjimharris U32 dma_buffer_id_high; // word 2 221230557Sjimharris U32 reserved0; // word 3 222230557Sjimharris U32 dma_buffer_offset; // word 4 223230557Sjimharris U32 dma_transfer_count; // word 5 224230557Sjimharris U32 reserved1; // word 6 225230557Sjimharris} SATA_FIS_DMA_SETUP_T; 226230557Sjimharris 227230557Sjimharris/** 228230557Sjimharris * @struct SATA_FIS_BIST_ACTIVATE 229230557Sjimharris * 230230557Sjimharris * @brief SATA BIST Activate FIS 231230557Sjimharris */ 232230557Sjimharristypedef struct SATA_FIS_BIST_ACTIVATE 233230557Sjimharris{ 234230557Sjimharris U32 fis_type :8; // word 0 235230557Sjimharris U32 reserved0 :8; 236230557Sjimharris U32 pattern_definition :8; 237230557Sjimharris U32 reserved1 :8; 238230557Sjimharris U32 data1; // word 1 239230557Sjimharris U32 data2; // word 1 240230557Sjimharris} SATA_FIS_BIST_ACTIVATE_T; 241230557Sjimharris 242230557Sjimharris/* 243230557Sjimharris * SATA PIO Setup FIS 244230557Sjimharris */ 245230557Sjimharristypedef struct SATA_FIS_PIO_SETUP 246230557Sjimharris{ 247230557Sjimharris U32 fis_type :8; // word 0 248230557Sjimharris U32 pm_port :4; 249230557Sjimharris U32 reserved_00 :1; 250230557Sjimharris U32 direction :1; 251230557Sjimharris U32 irq :1; 252230557Sjimharris U32 reserved_01 :1; 253230557Sjimharris U32 status :8; 254230557Sjimharris U32 error :8; 255230557Sjimharris U32 lba_low :8; // word 1 256230557Sjimharris U32 lba_mid :8; 257230557Sjimharris U32 lba_high :8; 258230557Sjimharris U32 device :8; 259230557Sjimharris U32 lba_low_exp :8; // word 2 260230557Sjimharris U32 lba_mid_exp :8; 261230557Sjimharris U32 lba_high_exp :8; 262230557Sjimharris U32 reserved :8; 263230557Sjimharris U32 sector_count :8; // word 3 264230557Sjimharris U32 sector_count_exp :8; 265230557Sjimharris U32 reserved1 :8; 266230557Sjimharris U32 ending_status :8; 267230557Sjimharris U32 transfter_count :16; // word 4 268230557Sjimharris U32 reserved3 :16; 269230557Sjimharris} SATA_FIS_PIO_SETUP_T; 270230557Sjimharris 271230557Sjimharris/** 272230557Sjimharris * @struct SATA_FIS_DATA 273230557Sjimharris * 274230557Sjimharris * @brief SATA Data FIS 275230557Sjimharris */ 276230557Sjimharristypedef struct SATA_FIS_DATA 277230557Sjimharris{ 278230557Sjimharris U32 fis_type :8; // word 0 279230557Sjimharris U32 pm_port :4; 280230557Sjimharris U32 reserved0 :24; 281230557Sjimharris U8 data[4]; // word 1 282230557Sjimharris} SATA_FIS_DATA_T; 283230557Sjimharris 284230557Sjimharris#endif // _SATA_H_ 285