Commit | Line | Data |
---|---|---|
7a3e97b0 SY |
1 | /* |
2 | * Universal Flash Storage Host controller driver | |
3 | * | |
4 | * This code is based on drivers/scsi/ufs/ufs.h | |
5 | * Copyright (C) 2011-2012 Samsung India Software Operations | |
6 | * | |
7 | * Santosh Yaraganavi <santosh.sy@samsung.com> | |
8 | * Vinayak Holikatti <h.vinayak@samsung.com> | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU General Public License | |
12 | * as published by the Free Software Foundation; either version 2 | |
13 | * of the License, or (at your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * NO WARRANTY | |
21 | * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR | |
22 | * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT | |
23 | * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, | |
24 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is | |
25 | * solely responsible for determining the appropriateness of using and | |
26 | * distributing the Program and assumes all risks associated with its | |
27 | * exercise of rights under this Agreement, including but not limited to | |
28 | * the risks and costs of program errors, damage to or loss of data, | |
29 | * programs or equipment, and unavailability or interruption of operations. | |
30 | ||
31 | * DISCLAIMER OF LIABILITY | |
32 | * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY | |
33 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
34 | * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND | |
35 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
36 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | |
37 | * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED | |
38 | * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES | |
39 | ||
40 | * You should have received a copy of the GNU General Public License | |
41 | * along with this program; if not, write to the Free Software | |
42 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | |
43 | * USA. | |
44 | */ | |
45 | ||
46 | #ifndef _UFS_H | |
47 | #define _UFS_H | |
48 | ||
49 | #define MAX_CDB_SIZE 16 | |
50 | ||
51 | #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ | |
52 | ((byte3 << 24) | (byte2 << 16) |\ | |
53 | (byte1 << 8) | (byte0)) | |
54 | ||
55 | /* | |
56 | * UFS Protocol Information Unit related definitions | |
57 | */ | |
58 | ||
59 | /* Task management functions */ | |
60 | enum { | |
61 | UFS_ABORT_TASK = 0x01, | |
62 | UFS_ABORT_TASK_SET = 0x02, | |
63 | UFS_CLEAR_TASK_SET = 0x04, | |
64 | UFS_LOGICAL_RESET = 0x08, | |
65 | UFS_QUERY_TASK = 0x80, | |
66 | UFS_QUERY_TASK_SET = 0x81, | |
67 | }; | |
68 | ||
69 | /* UTP UPIU Transaction Codes Initiator to Target */ | |
70 | enum { | |
71 | UPIU_TRANSACTION_NOP_OUT = 0x00, | |
72 | UPIU_TRANSACTION_COMMAND = 0x01, | |
73 | UPIU_TRANSACTION_DATA_OUT = 0x02, | |
74 | UPIU_TRANSACTION_TASK_REQ = 0x04, | |
75 | UPIU_TRANSACTION_QUERY_REQ = 0x26, | |
76 | }; | |
77 | ||
78 | /* UTP UPIU Transaction Codes Target to Initiator */ | |
79 | enum { | |
80 | UPIU_TRANSACTION_NOP_IN = 0x20, | |
81 | UPIU_TRANSACTION_RESPONSE = 0x21, | |
82 | UPIU_TRANSACTION_DATA_IN = 0x22, | |
83 | UPIU_TRANSACTION_TASK_RSP = 0x24, | |
84 | UPIU_TRANSACTION_READY_XFER = 0x31, | |
85 | UPIU_TRANSACTION_QUERY_RSP = 0x36, | |
86 | }; | |
87 | ||
88 | /* UPIU Read/Write flags */ | |
89 | enum { | |
90 | UPIU_CMD_FLAGS_NONE = 0x00, | |
91 | UPIU_CMD_FLAGS_WRITE = 0x20, | |
92 | UPIU_CMD_FLAGS_READ = 0x40, | |
93 | }; | |
94 | ||
95 | /* UPIU Task Attributes */ | |
96 | enum { | |
97 | UPIU_TASK_ATTR_SIMPLE = 0x00, | |
98 | UPIU_TASK_ATTR_ORDERED = 0x01, | |
99 | UPIU_TASK_ATTR_HEADQ = 0x02, | |
100 | UPIU_TASK_ATTR_ACA = 0x03, | |
101 | }; | |
102 | ||
103 | /* UTP QUERY Transaction Specific Fields OpCode */ | |
104 | enum { | |
105 | UPIU_QUERY_OPCODE_NOP = 0x0, | |
106 | UPIU_QUERY_OPCODE_READ_DESC = 0x1, | |
107 | UPIU_QUERY_OPCODE_WRITE_DESC = 0x2, | |
108 | UPIU_QUERY_OPCODE_READ_ATTR = 0x3, | |
109 | UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4, | |
110 | UPIU_QUERY_OPCODE_READ_FLAG = 0x5, | |
111 | UPIU_QUERY_OPCODE_SET_FLAG = 0x6, | |
112 | UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7, | |
113 | UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8, | |
114 | }; | |
115 | ||
116 | /* UTP Transfer Request Command Type (CT) */ | |
117 | enum { | |
118 | UPIU_COMMAND_SET_TYPE_SCSI = 0x0, | |
119 | UPIU_COMMAND_SET_TYPE_UFS = 0x1, | |
120 | UPIU_COMMAND_SET_TYPE_QUERY = 0x2, | |
121 | }; | |
122 | ||
123 | enum { | |
124 | MASK_SCSI_STATUS = 0xFF, | |
125 | MASK_TASK_RESPONSE = 0xFF00, | |
126 | MASK_RSP_UPIU_RESULT = 0xFFFF, | |
127 | }; | |
128 | ||
129 | /* Task management service response */ | |
130 | enum { | |
131 | UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00, | |
132 | UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04, | |
133 | UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08, | |
134 | UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05, | |
135 | UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09, | |
136 | }; | |
137 | /** | |
138 | * struct utp_upiu_header - UPIU header structure | |
139 | * @dword_0: UPIU header DW-0 | |
140 | * @dword_1: UPIU header DW-1 | |
141 | * @dword_2: UPIU header DW-2 | |
142 | */ | |
143 | struct utp_upiu_header { | |
144 | u32 dword_0; | |
145 | u32 dword_1; | |
146 | u32 dword_2; | |
147 | }; | |
148 | ||
149 | /** | |
150 | * struct utp_upiu_cmd - Command UPIU structure | |
151 | * @header: UPIU header structure DW-0 to DW-2 | |
152 | * @data_transfer_len: Data Transfer Length DW-3 | |
153 | * @cdb: Command Descriptor Block CDB DW-4 to DW-7 | |
154 | */ | |
155 | struct utp_upiu_cmd { | |
156 | struct utp_upiu_header header; | |
157 | u32 exp_data_transfer_len; | |
158 | u8 cdb[MAX_CDB_SIZE]; | |
159 | }; | |
160 | ||
161 | /** | |
162 | * struct utp_upiu_rsp - Response UPIU structure | |
163 | * @header: UPIU header DW-0 to DW-2 | |
164 | * @residual_transfer_count: Residual transfer count DW-3 | |
165 | * @reserved: Reserved double words DW-4 to DW-7 | |
166 | * @sense_data_len: Sense data length DW-8 U16 | |
167 | * @sense_data: Sense data field DW-8 to DW-12 | |
168 | */ | |
169 | struct utp_upiu_rsp { | |
170 | struct utp_upiu_header header; | |
171 | u32 residual_transfer_count; | |
172 | u32 reserved[4]; | |
173 | u16 sense_data_len; | |
174 | u8 sense_data[18]; | |
175 | }; | |
176 | ||
177 | /** | |
178 | * struct utp_upiu_task_req - Task request UPIU structure | |
179 | * @header - UPIU header structure DW0 to DW-2 | |
180 | * @input_param1: Input parameter 1 DW-3 | |
181 | * @input_param2: Input parameter 2 DW-4 | |
182 | * @input_param3: Input parameter 3 DW-5 | |
183 | * @reserved: Reserved double words DW-6 to DW-7 | |
184 | */ | |
185 | struct utp_upiu_task_req { | |
186 | struct utp_upiu_header header; | |
187 | u32 input_param1; | |
188 | u32 input_param2; | |
189 | u32 input_param3; | |
190 | u32 reserved[2]; | |
191 | }; | |
192 | ||
193 | /** | |
194 | * struct utp_upiu_task_rsp - Task Management Response UPIU structure | |
195 | * @header: UPIU header structure DW0-DW-2 | |
196 | * @output_param1: Ouput parameter 1 DW3 | |
197 | * @output_param2: Output parameter 2 DW4 | |
198 | * @reserved: Reserved double words DW-5 to DW-7 | |
199 | */ | |
200 | struct utp_upiu_task_rsp { | |
201 | struct utp_upiu_header header; | |
202 | u32 output_param1; | |
203 | u32 output_param2; | |
204 | u32 reserved[3]; | |
205 | }; | |
206 | ||
207 | #endif /* End of Header */ |