xref: /freebsd/sys/dev/isci/scil/intel_sata.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
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 #ifndef _SATA_H_
55f11c7f63SJim Harris #define _SATA_H_
56f11c7f63SJim Harris 
57f11c7f63SJim Harris #include <dev/isci/types.h>
58f11c7f63SJim Harris 
59f11c7f63SJim Harris /**
60f11c7f63SJim Harris  * @file
61f11c7f63SJim Harris  *
62f11c7f63SJim Harris  * @brief This file defines all of the SATA releated constants, enumerations,
63f11c7f63SJim Harris  *        and types. Please note that this file does not necessarily contain
64f11c7f63SJim Harris  *        an exhaustive list of all contants and commands.
65f11c7f63SJim Harris  */
66f11c7f63SJim Harris 
67f11c7f63SJim Harris /**
68f11c7f63SJim Harris  * @name SATA FIS Types
69f11c7f63SJim Harris  *
70f11c7f63SJim Harris  * These constants depict the various SATA FIS types devined in the serial ATA
71f11c7f63SJim Harris  * specification.
72f11c7f63SJim Harris  */
73f11c7f63SJim Harris /*@{*/
74f11c7f63SJim Harris #define SATA_FIS_TYPE_REGH2D          0x27
75f11c7f63SJim Harris #define SATA_FIS_TYPE_REGD2H          0x34
76f11c7f63SJim Harris #define SATA_FIS_TYPE_SETDEVBITS      0xA1
77f11c7f63SJim Harris #define SATA_FIS_TYPE_DMA_ACTIVATE    0x39
78f11c7f63SJim Harris #define SATA_FIS_TYPE_DMA_SETUP       0x41
79f11c7f63SJim Harris #define SATA_FIS_TYPE_BIST_ACTIVATE   0x58
80f11c7f63SJim Harris #define SATA_FIS_TYPE_PIO_SETUP       0x5F
81f11c7f63SJim Harris #define SATA_FIS_TYPE_DATA            0x46
82f11c7f63SJim Harris /*@}*/
83f11c7f63SJim Harris 
84f11c7f63SJim Harris #define SATA_REGISTER_FIS_SIZE 0x20
85f11c7f63SJim Harris 
86f11c7f63SJim Harris /**
87f11c7f63SJim Harris  * @struct  SATA_FIS_HEADER
88f11c7f63SJim Harris  *
89f11c7f63SJim Harris  * @brief This is the common definition for a SATA FIS Header word.  A
90f11c7f63SJim Harris  *        different header word is defined for any FIS type that does not use
91f11c7f63SJim Harris  *        the standard header.
92f11c7f63SJim Harris  */
93f11c7f63SJim Harris typedef struct SATA_FIS_HEADER
94f11c7f63SJim Harris {
95f11c7f63SJim Harris    U32 fis_type         :8;   // word 0
96f11c7f63SJim Harris    U32 pm_port          :4;
97f11c7f63SJim Harris    U32 reserved         :1;
98f11c7f63SJim Harris    U32 direction_flag   :1;   // direction
99f11c7f63SJim Harris    U32 interrupt_flag   :1;
100f11c7f63SJim Harris    U32 command_flag     :1;   // command, auto_activate, or notification
101f11c7f63SJim Harris    U32 status           :8;
102f11c7f63SJim Harris    U32 error            :8;
103f11c7f63SJim Harris } SATA_FIS_HEADER_T;
104f11c7f63SJim Harris 
105f11c7f63SJim Harris 
106f11c7f63SJim Harris /**
107f11c7f63SJim Harris  * @struct SATA_FIS_REG_H2D
108f11c7f63SJim Harris  *
109f11c7f63SJim Harris  * @brief This is the definition for a SATA Host to Device Register FIS.
110f11c7f63SJim Harris  */
111f11c7f63SJim Harris typedef struct SATA_FIS_REG_H2D
112f11c7f63SJim Harris {
113f11c7f63SJim Harris    U32 fis_type         :8;     // word 0
114f11c7f63SJim Harris    U32 pm_port          :4;
115f11c7f63SJim Harris    U32 reserved0        :3;
116f11c7f63SJim Harris    U32 command_flag     :1;
117f11c7f63SJim Harris    U32 command          :8;
118f11c7f63SJim Harris    U32 features         :8;
119f11c7f63SJim Harris    U32 lba_low          :8;     // word 1
120f11c7f63SJim Harris    U32 lba_mid          :8;
121f11c7f63SJim Harris    U32 lba_high         :8;
122f11c7f63SJim Harris    U32 device           :8;
123f11c7f63SJim Harris    U32 lba_low_exp      :8;     // word 2
124f11c7f63SJim Harris    U32 lba_mid_exp      :8;
125f11c7f63SJim Harris    U32 lba_high_exp     :8;
126f11c7f63SJim Harris    U32 features_exp     :8;
127f11c7f63SJim Harris    U32 sector_count     :8;     // word 3
128f11c7f63SJim Harris    U32 sector_count_exp :8;
129f11c7f63SJim Harris    U32 reserved1        :8;
130f11c7f63SJim Harris    U32 control          :8;
131f11c7f63SJim Harris    U32 reserved2;               // word 4
132f11c7f63SJim Harris } SATA_FIS_REG_H2D_T;
133f11c7f63SJim Harris 
134f11c7f63SJim Harris /**
135f11c7f63SJim Harris  * @struct SATA_FIS_REG_D2H
136f11c7f63SJim Harris  *
137f11c7f63SJim Harris  * @brief SATA Device To Host FIS
138f11c7f63SJim Harris  */
139f11c7f63SJim Harris typedef struct SATA_FIS_REG_D2H
140f11c7f63SJim Harris {
141f11c7f63SJim Harris    U32 fis_type   :8;         // word 0
142f11c7f63SJim Harris    U32 pm_port    :4;
143f11c7f63SJim Harris    U32 reserved0  :2;
144f11c7f63SJim Harris    U32 irq        :1;
145f11c7f63SJim Harris    U32 reserved1  :1;
146f11c7f63SJim Harris    U32 status     :8;
147f11c7f63SJim Harris    U32 error      :8;
148f11c7f63SJim Harris    U8 lba_low;               // word 1
149f11c7f63SJim Harris    U8 lba_mid;
150f11c7f63SJim Harris    U8 lba_high;
151f11c7f63SJim Harris    U8 device;
152f11c7f63SJim Harris    U8 lba_low_exp;           // word 2
153f11c7f63SJim Harris    U8 lba_mid_exp;
154f11c7f63SJim Harris    U8 lba_high_exp;
155f11c7f63SJim Harris    U8 reserved;
156f11c7f63SJim Harris    U8 sector_count;          // word 3
157f11c7f63SJim Harris    U8 sector_count_exp;
158f11c7f63SJim Harris    U16 reserved2;
159f11c7f63SJim Harris    U32 reserved3;
160f11c7f63SJim Harris } SATA_FIS_REG_D2H_T;
161f11c7f63SJim Harris 
162f11c7f63SJim Harris /**
163f11c7f63SJim Harris  *  Status field bit definitions
164f11c7f63SJim Harris  */
165f11c7f63SJim Harris #define SATA_FIS_STATUS_DEVBITS_MASK  (0x77)
166f11c7f63SJim Harris 
167f11c7f63SJim Harris /**
168f11c7f63SJim Harris  * @struct SATA_FIS_SET_DEV_BITS
169f11c7f63SJim Harris  *
170f11c7f63SJim Harris  * @brief SATA Set Device Bits FIS
171f11c7f63SJim Harris  */
172f11c7f63SJim Harris typedef struct SATA_FIS_SET_DEV_BITS
173f11c7f63SJim Harris {
174f11c7f63SJim Harris    U32 fis_type      :8;   // word 0
175f11c7f63SJim Harris    U32 pm_port       :4;
176f11c7f63SJim Harris    U32 reserved0     :2;
177f11c7f63SJim Harris    U32 irq           :1;
178f11c7f63SJim Harris    U32 notification  :1;
179f11c7f63SJim Harris    U32 status_low    :4;
180f11c7f63SJim Harris    U32 status_high   :4;
181f11c7f63SJim Harris    U32 error         :8;
182f11c7f63SJim Harris    U32 s_active;           // word 1
183f11c7f63SJim Harris } SATA_FIS_SET_DEV_BITS_T;
184f11c7f63SJim Harris 
185f11c7f63SJim Harris /**
186f11c7f63SJim Harris  * @struct SATA_FIS_DMA_ACTIVATE
187f11c7f63SJim Harris  *
188f11c7f63SJim Harris  * @brief SATA DMA Activate FIS
189f11c7f63SJim Harris  */
190f11c7f63SJim Harris typedef struct SATA_FIS_DMA_ACTIVATE
191f11c7f63SJim Harris {
192f11c7f63SJim Harris    U32 fis_type      :8;   // word 0
193f11c7f63SJim Harris    U32 pm_port       :4;
194f11c7f63SJim Harris    U32 reserved0     :24;
195f11c7f63SJim Harris } SATA_FIS_DMA_ACTIVATE_T;
196f11c7f63SJim Harris 
197f11c7f63SJim Harris /**
198f11c7f63SJim Harris  * The lower 5 bits in the DMA Buffer ID Low field of the DMA Setup
199f11c7f63SJim Harris  * are used to communicate the command tag.
200f11c7f63SJim Harris  */
201f11c7f63SJim Harris #define SATA_DMA_SETUP_TAG_ENABLE      0x1F
202f11c7f63SJim Harris 
203f11c7f63SJim Harris #define SATA_DMA_SETUP_AUTO_ACT_ENABLE 0x80
204f11c7f63SJim Harris 
205f11c7f63SJim Harris /**
206f11c7f63SJim Harris  * @struct SATA_FIS_DMA_SETUP
207f11c7f63SJim Harris  *
208f11c7f63SJim Harris  * @brief SATA DMA Setup FIS
209f11c7f63SJim Harris  */
210f11c7f63SJim Harris typedef struct SATA_FIS_DMA_SETUP
211f11c7f63SJim Harris {
212f11c7f63SJim Harris    U32 fis_type            :8;   // word 0
213f11c7f63SJim Harris    U32 pm_port             :4;
214f11c7f63SJim Harris    U32 reserved_00         :1;
215f11c7f63SJim Harris    U32 direction           :1;
216f11c7f63SJim Harris    U32 irq                 :1;
217f11c7f63SJim Harris    U32 auto_activate       :1;
218f11c7f63SJim Harris    U32 reserved_01         :16;
219f11c7f63SJim Harris    U32 dma_buffer_id_low;        // word 1
220f11c7f63SJim Harris    U32 dma_buffer_id_high;       // word 2
221f11c7f63SJim Harris    U32 reserved0;                // word 3
222f11c7f63SJim Harris    U32 dma_buffer_offset;        // word 4
223f11c7f63SJim Harris    U32 dma_transfer_count;       // word 5
224f11c7f63SJim Harris    U32 reserved1;                // word 6
225f11c7f63SJim Harris } SATA_FIS_DMA_SETUP_T;
226f11c7f63SJim Harris 
227f11c7f63SJim Harris /**
228f11c7f63SJim Harris  *  @struct SATA_FIS_BIST_ACTIVATE
229f11c7f63SJim Harris  *
230f11c7f63SJim Harris  *  @brief SATA BIST Activate FIS
231f11c7f63SJim Harris  */
232f11c7f63SJim Harris typedef struct SATA_FIS_BIST_ACTIVATE
233f11c7f63SJim Harris {
234f11c7f63SJim Harris    U32 fis_type               :8;   // word 0
235f11c7f63SJim Harris    U32 reserved0              :8;
236f11c7f63SJim Harris    U32 pattern_definition     :8;
237f11c7f63SJim Harris    U32 reserved1              :8;
238f11c7f63SJim Harris    U32 data1;                       // word 1
239f11c7f63SJim Harris    U32 data2;                       // word 1
240f11c7f63SJim Harris } SATA_FIS_BIST_ACTIVATE_T;
241f11c7f63SJim Harris 
242f11c7f63SJim Harris /*
243f11c7f63SJim Harris  *  SATA PIO Setup FIS
244f11c7f63SJim Harris  */
245f11c7f63SJim Harris typedef struct SATA_FIS_PIO_SETUP
246f11c7f63SJim Harris {
247f11c7f63SJim Harris    U32 fis_type         :8;   // word 0
248f11c7f63SJim Harris    U32 pm_port          :4;
249f11c7f63SJim Harris    U32 reserved_00      :1;
250f11c7f63SJim Harris    U32 direction        :1;
251f11c7f63SJim Harris    U32 irq              :1;
252f11c7f63SJim Harris    U32 reserved_01      :1;
253f11c7f63SJim Harris    U32 status           :8;
254f11c7f63SJim Harris    U32 error            :8;
255f11c7f63SJim Harris    U32 lba_low          :8;   // word 1
256f11c7f63SJim Harris    U32 lba_mid          :8;
257f11c7f63SJim Harris    U32 lba_high         :8;
258f11c7f63SJim Harris    U32 device           :8;
259f11c7f63SJim Harris    U32 lba_low_exp      :8;   // word 2
260f11c7f63SJim Harris    U32 lba_mid_exp      :8;
261f11c7f63SJim Harris    U32 lba_high_exp     :8;
262f11c7f63SJim Harris    U32 reserved         :8;
263f11c7f63SJim Harris    U32 sector_count     :8;   // word 3
264f11c7f63SJim Harris    U32 sector_count_exp :8;
265f11c7f63SJim Harris    U32 reserved1        :8;
266f11c7f63SJim Harris    U32 ending_status    :8;
267f11c7f63SJim Harris    U32 transfter_count  :16;  // word 4
268f11c7f63SJim Harris    U32 reserved3        :16;
269f11c7f63SJim Harris } SATA_FIS_PIO_SETUP_T;
270f11c7f63SJim Harris 
271f11c7f63SJim Harris /**
272f11c7f63SJim Harris  * @struct SATA_FIS_DATA
273f11c7f63SJim Harris  *
274f11c7f63SJim Harris  * @brief SATA Data FIS
275f11c7f63SJim Harris  */
276f11c7f63SJim Harris typedef struct SATA_FIS_DATA
277f11c7f63SJim Harris {
278f11c7f63SJim Harris    U32 fis_type      :8;   // word 0
279f11c7f63SJim Harris    U32 pm_port       :4;
280f11c7f63SJim Harris    U32 reserved0     :24;
281f11c7f63SJim Harris    U8  data[4];            // word 1
282f11c7f63SJim Harris } SATA_FIS_DATA_T;
283f11c7f63SJim Harris 
284f11c7f63SJim Harris #endif // _SATA_H_
285