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