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