intel_sata.h revision 230557
1139749Simp/*-
2158078Smarcel * This file is provided under a dual BSD/GPLv2 license.  When using or
3158078Smarcel * redistributing this file, you may do so under either license.
4158078Smarcel *
5119815Smarcel * GPL LICENSE SUMMARY
6119815Smarcel *
7119815Smarcel * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8119815Smarcel *
9119815Smarcel * This program is free software; you can redistribute it and/or modify
10119815Smarcel * it under the terms of version 2 of the GNU General Public License as
11119815Smarcel * published by the Free Software Foundation.
12119815Smarcel *
13119815Smarcel * This program is distributed in the hope that it will be useful, but
14119815Smarcel * WITHOUT ANY WARRANTY; without even the implied warranty of
15119815Smarcel * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16119815Smarcel * General Public License for more details.
17119815Smarcel *
18119815Smarcel * You should have received a copy of the GNU General Public License
19119815Smarcel * along with this program; if not, write to the Free Software
20119815Smarcel * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21119815Smarcel * The full GNU General Public License is included in this distribution
22119815Smarcel * in the file called LICENSE.GPL.
23119815Smarcel *
24119815Smarcel * BSD LICENSE
25119815Smarcel *
26119815Smarcel * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
27119815Smarcel * All rights reserved.
28119815Smarcel *
29119815Smarcel * Redistribution and use in source and binary forms, with or without
30119815Smarcel * modification, are permitted provided that the following conditions
31119815Smarcel * are met:
32119815Smarcel *
33119815Smarcel *   * Redistributions of source code must retain the above copyright
34119815Smarcel *     notice, this list of conditions and the following disclaimer.
35119815Smarcel *   * Redistributions in binary form must reproduce the above copyright
36119815Smarcel *     notice, this list of conditions and the following disclaimer in
37119815Smarcel *     the documentation and/or other materials provided with the
38119815Smarcel *     distribution.
39119815Smarcel *
40119815Smarcel * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41119815Smarcel * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42119815Smarcel * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43119815Smarcel * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44119815Smarcel * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45158058Smarcel * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46158058Smarcel * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47119815Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48119815Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49119815Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50119815Smarcel * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51119815Smarcel *
52119815Smarcel * $FreeBSD$
53119815Smarcel */
54246243Savg#ifndef _SATA_H_
55246300Smarius#define _SATA_H_
56119815Smarcel
57119815Smarcel#include <dev/isci/types.h>
58119815Smarcel
59119815Smarcel/**
60119815Smarcel * @file
61119815Smarcel *
62119815Smarcel * @brief This file defines all of the SATA releated constants, enumerations,
63119815Smarcel *        and types. Please note that this file does not necessarily contain
64119815Smarcel *        an exhaustive list of all contants and commands.
65158058Smarcel */
66158058Smarcel
67158058Smarcel/**
68158058Smarcel * @name SATA FIS Types
69119815Smarcel *
70119815Smarcel * These constants depict the various SATA FIS types devined in the serial ATA
71158058Smarcel * specification.
72119815Smarcel */
73119815Smarcel/*@{*/
74246300Smarius#define SATA_FIS_TYPE_REGH2D          0x27
75158078Smarcel#define SATA_FIS_TYPE_REGD2H          0x34
76158078Smarcel#define SATA_FIS_TYPE_SETDEVBITS      0xA1
77158078Smarcel#define SATA_FIS_TYPE_DMA_ACTIVATE    0x39
78158078Smarcel#define SATA_FIS_TYPE_DMA_SETUP       0x41
79158058Smarcel#define SATA_FIS_TYPE_BIST_ACTIVATE   0x58
80158058Smarcel#define SATA_FIS_TYPE_PIO_SETUP       0x5F
81158078Smarcel#define SATA_FIS_TYPE_DATA            0x46
82158078Smarcel/*@}*/
83169646Smarcel
84158078Smarcel#define SATA_REGISTER_FIS_SIZE 0x20
85261998Smarcel
86158058Smarcel/**
87158058Smarcel * @struct  SATA_FIS_HEADER
88223874Sjhb *
89158058Smarcel * @brief This is the common definition for a SATA FIS Header word.  A
90158058Smarcel *        different header word is defined for any FIS type that does not use
91158058Smarcel *        the standard header.
92158058Smarcel */
93158058Smarceltypedef struct SATA_FIS_HEADER
94158058Smarcel{
95158058Smarcel   U32 fis_type         :8;   // word 0
96158058Smarcel   U32 pm_port          :4;
97158058Smarcel   U32 reserved         :1;
98158078Smarcel   U32 direction_flag   :1;   // direction
99158078Smarcel   U32 interrupt_flag   :1;
100158058Smarcel   U32 command_flag     :1;   // command, auto_activate, or notification
101158058Smarcel   U32 status           :8;
102188472Skaiw   U32 error            :8;
103158078Smarcel} SATA_FIS_HEADER_T;
104158078Smarcel
105158078Smarcel
106158078Smarcel/**
107158078Smarcel * @struct SATA_FIS_REG_H2D
108158078Smarcel *
109158078Smarcel * @brief This is the definition for a SATA Host to Device Register FIS.
110158078Smarcel */
111158078Smarceltypedef struct SATA_FIS_REG_H2D
112158078Smarcel{
113158078Smarcel   U32 fis_type         :8;     // word 0
114158078Smarcel   U32 pm_port          :4;
115230327Seadler   U32 reserved0        :3;
116158078Smarcel   U32 command_flag     :1;
117264761Smarius   U32 command          :8;
118264761Smarius   U32 features         :8;
119228947Skib   U32 lba_low          :8;     // word 1
120249803Seadler   U32 lba_mid          :8;
121232967Skib   U32 lba_high         :8;
122229971Skib   U32 device           :8;
123229971Skib   U32 lba_low_exp      :8;     // word 2
124229379Skevlo   U32 lba_mid_exp      :8;
125229379Skevlo   U32 lba_high_exp     :8;
126229379Skevlo   U32 features_exp     :8;
127229379Skevlo   U32 sector_count     :8;     // word 3
128266436Smarius   U32 sector_count_exp :8;
129200257Smav   U32 reserved1        :8;
130189407Sjhb   U32 control          :8;
131200230Smarcel   U32 reserved2;               // word 4
132223672Shselasky} SATA_FIS_REG_H2D_T;
133223672Shselasky
134204533Sdelphij/**
135204533Sdelphij * @struct SATA_FIS_REG_D2H
136232639Sremko *
137232639Sremko * @brief SATA Device To Host FIS
138158058Smarcel */
139158058Smarceltypedef struct SATA_FIS_REG_D2H
140119815Smarcel{
141119815Smarcel   U32 fis_type   :8;         // word 0
142246300Smarius   U32 pm_port    :4;
143246300Smarius   U32 reserved0  :2;
144119815Smarcel   U32 irq        :1;
145158058Smarcel   U32 reserved1  :1;
146119815Smarcel   U32 status     :8;
147158058Smarcel   U32 error      :8;
148158058Smarcel   U8 lba_low;               // word 1
149158058Smarcel   U8 lba_mid;
150158058Smarcel   U8 lba_high;
151119815Smarcel   U8 device;
152158058Smarcel   U8 lba_low_exp;           // word 2
153158058Smarcel   U8 lba_mid_exp;
154158058Smarcel   U8 lba_high_exp;
155158058Smarcel   U8 reserved;
156158058Smarcel   U8 sector_count;          // word 3
157158058Smarcel   U8 sector_count_exp;
158158058Smarcel   U16 reserved2;
159158058Smarcel   U32 reserved3;
160158058Smarcel} SATA_FIS_REG_D2H_T;
161158058Smarcel
162119815Smarcel/**
163119815Smarcel *  Status field bit definitions
164119815Smarcel */
165119815Smarcel#define SATA_FIS_STATUS_DEVBITS_MASK  (0x77)
166119815Smarcel
167119815Smarcel/**
168246300Smarius * @struct SATA_FIS_SET_DEV_BITS
169253654Smarcel *
170119815Smarcel * @brief SATA Set Device Bits FIS
171119815Smarcel */
172119815Smarceltypedef struct SATA_FIS_SET_DEV_BITS
173158058Smarcel{
174119815Smarcel   U32 fis_type      :8;   // word 0
175119815Smarcel   U32 pm_port       :4;
176119815Smarcel   U32 reserved0     :2;
177119815Smarcel   U32 irq           :1;
178119815Smarcel   U32 notification  :1;
179119815Smarcel   U32 status_low    :4;
180119815Smarcel   U32 status_high   :4;
181119815Smarcel   U32 error         :8;
182253654Smarcel   U32 s_active;           // word 1
183253654Smarcel} SATA_FIS_SET_DEV_BITS_T;
184253654Smarcel
185253654Smarcel/**
186253654Smarcel * @struct SATA_FIS_DMA_ACTIVATE
187119815Smarcel *
188119815Smarcel * @brief SATA DMA Activate FIS
189253654Smarcel */
190119815Smarceltypedef struct SATA_FIS_DMA_ACTIVATE
191119815Smarcel{
192246300Smarius   U32 fis_type      :8;   // word 0
193   U32 pm_port       :4;
194   U32 reserved0     :24;
195} SATA_FIS_DMA_ACTIVATE_T;
196
197/**
198 * The lower 5 bits in the DMA Buffer ID Low field of the DMA Setup
199 * are used to communicate the command tag.
200 */
201#define SATA_DMA_SETUP_TAG_ENABLE      0x1F
202
203#define SATA_DMA_SETUP_AUTO_ACT_ENABLE 0x80
204
205/**
206 * @struct SATA_FIS_DMA_SETUP
207 *
208 * @brief SATA DMA Setup FIS
209 */
210typedef struct SATA_FIS_DMA_SETUP
211{
212   U32 fis_type            :8;   // word 0
213   U32 pm_port             :4;
214   U32 reserved_00         :1;
215   U32 direction           :1;
216   U32 irq                 :1;
217   U32 auto_activate       :1;
218   U32 reserved_01         :16;
219   U32 dma_buffer_id_low;        // word 1
220   U32 dma_buffer_id_high;       // word 2
221   U32 reserved0;                // word 3
222   U32 dma_buffer_offset;        // word 4
223   U32 dma_transfer_count;       // word 5
224   U32 reserved1;                // word 6
225} SATA_FIS_DMA_SETUP_T;
226
227/**
228 *  @struct SATA_FIS_BIST_ACTIVATE
229 *
230 *  @brief SATA BIST Activate FIS
231 */
232typedef struct SATA_FIS_BIST_ACTIVATE
233{
234   U32 fis_type               :8;   // word 0
235   U32 reserved0              :8;
236   U32 pattern_definition     :8;
237   U32 reserved1              :8;
238   U32 data1;                       // word 1
239   U32 data2;                       // word 1
240} SATA_FIS_BIST_ACTIVATE_T;
241
242/*
243 *  SATA PIO Setup FIS
244 */
245typedef struct SATA_FIS_PIO_SETUP
246{
247   U32 fis_type         :8;   // word 0
248   U32 pm_port          :4;
249   U32 reserved_00      :1;
250   U32 direction        :1;
251   U32 irq              :1;
252   U32 reserved_01      :1;
253   U32 status           :8;
254   U32 error            :8;
255   U32 lba_low          :8;   // word 1
256   U32 lba_mid          :8;
257   U32 lba_high         :8;
258   U32 device           :8;
259   U32 lba_low_exp      :8;   // word 2
260   U32 lba_mid_exp      :8;
261   U32 lba_high_exp     :8;
262   U32 reserved         :8;
263   U32 sector_count     :8;   // word 3
264   U32 sector_count_exp :8;
265   U32 reserved1        :8;
266   U32 ending_status    :8;
267   U32 transfter_count  :16;  // word 4
268   U32 reserved3        :16;
269} SATA_FIS_PIO_SETUP_T;
270
271/**
272 * @struct SATA_FIS_DATA
273 *
274 * @brief SATA Data FIS
275 */
276typedef struct SATA_FIS_DATA
277{
278   U32 fis_type      :8;   // word 0
279   U32 pm_port       :4;
280   U32 reserved0     :24;
281   U8  data[4];            // word 1
282} SATA_FIS_DATA_T;
283
284#endif // _SATA_H_
285