]>
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 | |
3b1d0580 | 5 | * Copyright (C) 2011-2013 Samsung India Software Operations |
7a3e97b0 | 6 | * |
3b1d0580 VH |
7 | * Authors: |
8 | * Santosh Yaraganavi <santosh.sy@samsung.com> | |
9 | * Vinayak Holikatti <h.vinayak@samsung.com> | |
7a3e97b0 SY |
10 | * |
11 | * This program is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU General Public License | |
13 | * as published by the Free Software Foundation; either version 2 | |
14 | * of the License, or (at your option) any later version. | |
3b1d0580 VH |
15 | * See the COPYING file in the top-level directory or visit |
16 | * <http://www.gnu.org/licenses/gpl-2.0.html> | |
7a3e97b0 SY |
17 | * |
18 | * This program is distributed in the hope that it will be useful, | |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | * GNU General Public License for more details. | |
22 | * | |
3b1d0580 VH |
23 | * This program is provided "AS IS" and "WITH ALL FAULTS" and |
24 | * without warranty of any kind. You are solely responsible for | |
25 | * determining the appropriateness of using and distributing | |
26 | * the program and assume all risks associated with your exercise | |
27 | * of rights with respect to the program, including but not limited | |
28 | * to infringement of third party rights, the risks and costs of | |
29 | * program errors, damage to or loss of data, programs or equipment, | |
30 | * and unavailability or interruption of operations. Under no | |
31 | * circumstances will the contributor of this Program be liable for | |
32 | * any damages of any kind arising from your use or distribution of | |
33 | * this program. | |
7a3e97b0 SY |
34 | */ |
35 | ||
36 | #ifndef _UFS_H | |
37 | #define _UFS_H | |
38 | ||
5a0b0cb9 SRT |
39 | #include <linux/mutex.h> |
40 | #include <linux/types.h> | |
41 | ||
7a3e97b0 | 42 | #define MAX_CDB_SIZE 16 |
68078d5c | 43 | #define GENERAL_UPIU_REQUEST_SIZE 32 |
d44a5f98 DR |
44 | #define QUERY_DESC_MAX_SIZE 255 |
45 | #define QUERY_DESC_MIN_SIZE 2 | |
b573d484 | 46 | #define QUERY_DESC_HDR_SIZE 2 |
68078d5c DR |
47 | #define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \ |
48 | (sizeof(struct utp_upiu_header))) | |
7a3e97b0 SY |
49 | |
50 | #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ | |
5a0b0cb9 | 51 | cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ |
7a3e97b0 | 52 | (byte1 << 8) | (byte0)) |
0ce147d4 SJ |
53 | /* |
54 | * UFS device may have standard LUs and LUN id could be from 0x00 to | |
55 | * 0x7F. Standard LUs use "Peripheral Device Addressing Format". | |
56 | * UFS device may also have the Well Known LUs (also referred as W-LU) | |
57 | * which again could be from 0x00 to 0x7F. For W-LUs, device only use | |
58 | * the "Extended Addressing Format" which means the W-LUNs would be | |
59 | * from 0xc100 (SCSI_W_LUN_BASE) onwards. | |
60 | * This means max. LUN number reported from UFS device could be 0xC17F. | |
61 | */ | |
62 | #define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F | |
63 | #define UFS_MAX_LUNS (SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID) | |
64 | #define UFS_UPIU_WLUN_ID (1 << 7) | |
da461cec SJ |
65 | #define UFS_UPIU_MAX_GENERAL_LUN 8 |
66 | ||
0ce147d4 SJ |
67 | /* Well known logical unit id in LUN field of UPIU */ |
68 | enum { | |
69 | UFS_UPIU_REPORT_LUNS_WLUN = 0x81, | |
70 | UFS_UPIU_UFS_DEVICE_WLUN = 0xD0, | |
71 | UFS_UPIU_BOOT_WLUN = 0xB0, | |
72 | UFS_UPIU_RPMB_WLUN = 0xC4, | |
73 | }; | |
74 | ||
7a3e97b0 SY |
75 | /* |
76 | * UFS Protocol Information Unit related definitions | |
77 | */ | |
78 | ||
79 | /* Task management functions */ | |
80 | enum { | |
81 | UFS_ABORT_TASK = 0x01, | |
82 | UFS_ABORT_TASK_SET = 0x02, | |
83 | UFS_CLEAR_TASK_SET = 0x04, | |
84 | UFS_LOGICAL_RESET = 0x08, | |
85 | UFS_QUERY_TASK = 0x80, | |
86 | UFS_QUERY_TASK_SET = 0x81, | |
87 | }; | |
88 | ||
89 | /* UTP UPIU Transaction Codes Initiator to Target */ | |
90 | enum { | |
91 | UPIU_TRANSACTION_NOP_OUT = 0x00, | |
92 | UPIU_TRANSACTION_COMMAND = 0x01, | |
93 | UPIU_TRANSACTION_DATA_OUT = 0x02, | |
94 | UPIU_TRANSACTION_TASK_REQ = 0x04, | |
68078d5c | 95 | UPIU_TRANSACTION_QUERY_REQ = 0x16, |
7a3e97b0 SY |
96 | }; |
97 | ||
98 | /* UTP UPIU Transaction Codes Target to Initiator */ | |
99 | enum { | |
100 | UPIU_TRANSACTION_NOP_IN = 0x20, | |
101 | UPIU_TRANSACTION_RESPONSE = 0x21, | |
102 | UPIU_TRANSACTION_DATA_IN = 0x22, | |
103 | UPIU_TRANSACTION_TASK_RSP = 0x24, | |
104 | UPIU_TRANSACTION_READY_XFER = 0x31, | |
105 | UPIU_TRANSACTION_QUERY_RSP = 0x36, | |
5a0b0cb9 | 106 | UPIU_TRANSACTION_REJECT_UPIU = 0x3F, |
7a3e97b0 SY |
107 | }; |
108 | ||
109 | /* UPIU Read/Write flags */ | |
110 | enum { | |
111 | UPIU_CMD_FLAGS_NONE = 0x00, | |
112 | UPIU_CMD_FLAGS_WRITE = 0x20, | |
113 | UPIU_CMD_FLAGS_READ = 0x40, | |
114 | }; | |
115 | ||
116 | /* UPIU Task Attributes */ | |
117 | enum { | |
118 | UPIU_TASK_ATTR_SIMPLE = 0x00, | |
119 | UPIU_TASK_ATTR_ORDERED = 0x01, | |
120 | UPIU_TASK_ATTR_HEADQ = 0x02, | |
121 | UPIU_TASK_ATTR_ACA = 0x03, | |
122 | }; | |
123 | ||
68078d5c | 124 | /* UPIU Query request function */ |
7a3e97b0 | 125 | enum { |
68078d5c DR |
126 | UPIU_QUERY_FUNC_STANDARD_READ_REQUEST = 0x01, |
127 | UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST = 0x81, | |
128 | }; | |
129 | ||
130 | /* Flag idn for Query Requests*/ | |
131 | enum flag_idn { | |
132 | QUERY_FLAG_IDN_FDEVICEINIT = 0x01, | |
57d104c1 | 133 | QUERY_FLAG_IDN_PWR_ON_WPE = 0x03, |
66ec6d59 SRT |
134 | QUERY_FLAG_IDN_BKOPS_EN = 0x04, |
135 | }; | |
136 | ||
137 | /* Attribute idn for Query requests */ | |
138 | enum attr_idn { | |
3a4bf06d | 139 | QUERY_ATTR_IDN_ACTIVE_ICC_LVL = 0x03, |
66ec6d59 SRT |
140 | QUERY_ATTR_IDN_BKOPS_STATUS = 0x05, |
141 | QUERY_ATTR_IDN_EE_CONTROL = 0x0D, | |
142 | QUERY_ATTR_IDN_EE_STATUS = 0x0E, | |
143 | }; | |
144 | ||
d44a5f98 DR |
145 | /* Descriptor idn for Query requests */ |
146 | enum desc_idn { | |
147 | QUERY_DESC_IDN_DEVICE = 0x0, | |
148 | QUERY_DESC_IDN_CONFIGURAION = 0x1, | |
149 | QUERY_DESC_IDN_UNIT = 0x2, | |
150 | QUERY_DESC_IDN_RFU_0 = 0x3, | |
151 | QUERY_DESC_IDN_INTERCONNECT = 0x4, | |
152 | QUERY_DESC_IDN_STRING = 0x5, | |
153 | QUERY_DESC_IDN_RFU_1 = 0x6, | |
154 | QUERY_DESC_IDN_GEOMETRY = 0x7, | |
155 | QUERY_DESC_IDN_POWER = 0x8, | |
da461cec SJ |
156 | QUERY_DESC_IDN_MAX, |
157 | }; | |
158 | ||
159 | enum desc_header_offset { | |
160 | QUERY_DESC_LENGTH_OFFSET = 0x00, | |
161 | QUERY_DESC_DESC_TYPE_OFFSET = 0x01, | |
162 | }; | |
163 | ||
164 | enum ufs_desc_max_size { | |
165 | QUERY_DESC_DEVICE_MAX_SIZE = 0x1F, | |
166 | QUERY_DESC_CONFIGURAION_MAX_SIZE = 0x90, | |
167 | QUERY_DESC_UNIT_MAX_SIZE = 0x23, | |
168 | QUERY_DESC_INTERCONNECT_MAX_SIZE = 0x06, | |
169 | /* | |
170 | * Max. 126 UNICODE characters (2 bytes per character) plus 2 bytes | |
171 | * of descriptor header. | |
172 | */ | |
173 | QUERY_DESC_STRING_MAX_SIZE = 0xFE, | |
1ce21794 | 174 | QUERY_DESC_GEOMETRY_MAX_SIZE = 0x44, |
da461cec SJ |
175 | QUERY_DESC_POWER_MAX_SIZE = 0x62, |
176 | QUERY_DESC_RFU_MAX_SIZE = 0x00, | |
d44a5f98 DR |
177 | }; |
178 | ||
1b3e8956 DR |
179 | /* Unit descriptor parameters offsets in bytes*/ |
180 | enum unit_desc_param { | |
181 | UNIT_DESC_PARAM_LEN = 0x0, | |
182 | UNIT_DESC_PARAM_TYPE = 0x1, | |
183 | UNIT_DESC_PARAM_UNIT_INDEX = 0x2, | |
184 | UNIT_DESC_PARAM_LU_ENABLE = 0x3, | |
185 | UNIT_DESC_PARAM_BOOT_LUN_ID = 0x4, | |
186 | UNIT_DESC_PARAM_LU_WR_PROTECT = 0x5, | |
187 | UNIT_DESC_PARAM_LU_Q_DEPTH = 0x6, | |
188 | UNIT_DESC_PARAM_MEM_TYPE = 0x8, | |
189 | UNIT_DESC_PARAM_DATA_RELIABILITY = 0x9, | |
190 | UNIT_DESC_PARAM_LOGICAL_BLK_SIZE = 0xA, | |
191 | UNIT_DESC_PARAM_LOGICAL_BLK_COUNT = 0xB, | |
192 | UNIT_DESC_PARAM_ERASE_BLK_SIZE = 0x13, | |
193 | UNIT_DESC_PARAM_PROVISIONING_TYPE = 0x17, | |
194 | UNIT_DESC_PARAM_PHY_MEM_RSRC_CNT = 0x18, | |
195 | UNIT_DESC_PARAM_CTX_CAPABILITIES = 0x20, | |
196 | UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 = 0x22, | |
197 | }; | |
198 | ||
c58ab7aa YG |
199 | /* Device descriptor parameters offsets in bytes*/ |
200 | enum device_desc_param { | |
201 | DEVICE_DESC_PARAM_LEN = 0x0, | |
202 | DEVICE_DESC_PARAM_TYPE = 0x1, | |
203 | DEVICE_DESC_PARAM_DEVICE_TYPE = 0x2, | |
204 | DEVICE_DESC_PARAM_DEVICE_CLASS = 0x3, | |
205 | DEVICE_DESC_PARAM_DEVICE_SUB_CLASS = 0x4, | |
206 | DEVICE_DESC_PARAM_PRTCL = 0x5, | |
207 | DEVICE_DESC_PARAM_NUM_LU = 0x6, | |
208 | DEVICE_DESC_PARAM_NUM_WLU = 0x7, | |
209 | DEVICE_DESC_PARAM_BOOT_ENBL = 0x8, | |
210 | DEVICE_DESC_PARAM_DESC_ACCSS_ENBL = 0x9, | |
211 | DEVICE_DESC_PARAM_INIT_PWR_MODE = 0xA, | |
212 | DEVICE_DESC_PARAM_HIGH_PR_LUN = 0xB, | |
213 | DEVICE_DESC_PARAM_SEC_RMV_TYPE = 0xC, | |
214 | DEVICE_DESC_PARAM_SEC_LU = 0xD, | |
215 | DEVICE_DESC_PARAM_BKOP_TERM_LT = 0xE, | |
216 | DEVICE_DESC_PARAM_ACTVE_ICC_LVL = 0xF, | |
217 | DEVICE_DESC_PARAM_SPEC_VER = 0x10, | |
218 | DEVICE_DESC_PARAM_MANF_DATE = 0x12, | |
219 | DEVICE_DESC_PARAM_MANF_NAME = 0x14, | |
220 | DEVICE_DESC_PARAM_PRDCT_NAME = 0x15, | |
221 | DEVICE_DESC_PARAM_SN = 0x16, | |
222 | DEVICE_DESC_PARAM_OEM_ID = 0x17, | |
223 | DEVICE_DESC_PARAM_MANF_ID = 0x18, | |
224 | DEVICE_DESC_PARAM_UD_OFFSET = 0x1A, | |
225 | DEVICE_DESC_PARAM_UD_LEN = 0x1B, | |
226 | DEVICE_DESC_PARAM_RTT_CAP = 0x1C, | |
227 | DEVICE_DESC_PARAM_FRQ_RTC = 0x1D, | |
228 | }; | |
229 | ||
57d104c1 SJ |
230 | /* |
231 | * Logical Unit Write Protect | |
232 | * 00h: LU not write protected | |
233 | * 01h: LU write protected when fPowerOnWPEn =1 | |
234 | * 02h: LU permanently write protected when fPermanentWPEn =1 | |
235 | */ | |
236 | enum ufs_lu_wp_type { | |
237 | UFS_LU_NO_WP = 0x00, | |
238 | UFS_LU_POWER_ON_WP = 0x01, | |
239 | UFS_LU_PERM_WP = 0x02, | |
240 | }; | |
241 | ||
3a4bf06d YG |
242 | /* bActiveICCLevel parameter current units */ |
243 | enum { | |
244 | UFSHCD_NANO_AMP = 0, | |
245 | UFSHCD_MICRO_AMP = 1, | |
246 | UFSHCD_MILI_AMP = 2, | |
247 | UFSHCD_AMP = 3, | |
248 | }; | |
249 | ||
250 | #define POWER_DESC_MAX_SIZE 0x62 | |
251 | #define POWER_DESC_MAX_ACTV_ICC_LVLS 16 | |
252 | ||
253 | /* Attribute bActiveICCLevel parameter bit masks definitions */ | |
254 | #define ATTR_ICC_LVL_UNIT_OFFSET 14 | |
255 | #define ATTR_ICC_LVL_UNIT_MASK (0x3 << ATTR_ICC_LVL_UNIT_OFFSET) | |
256 | #define ATTR_ICC_LVL_VALUE_MASK 0x3FF | |
257 | ||
258 | /* Power descriptor parameters offsets in bytes */ | |
259 | enum power_desc_param_offset { | |
260 | PWR_DESC_LEN = 0x0, | |
261 | PWR_DESC_TYPE = 0x1, | |
262 | PWR_DESC_ACTIVE_LVLS_VCC_0 = 0x2, | |
263 | PWR_DESC_ACTIVE_LVLS_VCCQ_0 = 0x22, | |
264 | PWR_DESC_ACTIVE_LVLS_VCCQ2_0 = 0x42, | |
265 | }; | |
266 | ||
66ec6d59 SRT |
267 | /* Exception event mask values */ |
268 | enum { | |
269 | MASK_EE_STATUS = 0xFFFF, | |
270 | MASK_EE_URGENT_BKOPS = (1 << 2), | |
271 | }; | |
272 | ||
273 | /* Background operation status */ | |
57d104c1 | 274 | enum bkops_status { |
66ec6d59 SRT |
275 | BKOPS_STATUS_NO_OP = 0x0, |
276 | BKOPS_STATUS_NON_CRITICAL = 0x1, | |
277 | BKOPS_STATUS_PERF_IMPACT = 0x2, | |
278 | BKOPS_STATUS_CRITICAL = 0x3, | |
57d104c1 | 279 | BKOPS_STATUS_MAX = BKOPS_STATUS_CRITICAL, |
68078d5c DR |
280 | }; |
281 | ||
282 | /* UTP QUERY Transaction Specific Fields OpCode */ | |
283 | enum query_opcode { | |
7a3e97b0 SY |
284 | UPIU_QUERY_OPCODE_NOP = 0x0, |
285 | UPIU_QUERY_OPCODE_READ_DESC = 0x1, | |
286 | UPIU_QUERY_OPCODE_WRITE_DESC = 0x2, | |
287 | UPIU_QUERY_OPCODE_READ_ATTR = 0x3, | |
288 | UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4, | |
289 | UPIU_QUERY_OPCODE_READ_FLAG = 0x5, | |
290 | UPIU_QUERY_OPCODE_SET_FLAG = 0x6, | |
291 | UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7, | |
292 | UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8, | |
293 | }; | |
294 | ||
68078d5c DR |
295 | /* Query response result code */ |
296 | enum { | |
297 | QUERY_RESULT_SUCCESS = 0x00, | |
298 | QUERY_RESULT_NOT_READABLE = 0xF6, | |
299 | QUERY_RESULT_NOT_WRITEABLE = 0xF7, | |
300 | QUERY_RESULT_ALREADY_WRITTEN = 0xF8, | |
301 | QUERY_RESULT_INVALID_LENGTH = 0xF9, | |
302 | QUERY_RESULT_INVALID_VALUE = 0xFA, | |
303 | QUERY_RESULT_INVALID_SELECTOR = 0xFB, | |
304 | QUERY_RESULT_INVALID_INDEX = 0xFC, | |
305 | QUERY_RESULT_INVALID_IDN = 0xFD, | |
306 | QUERY_RESULT_INVALID_OPCODE = 0xFE, | |
307 | QUERY_RESULT_GENERAL_FAILURE = 0xFF, | |
308 | }; | |
309 | ||
7a3e97b0 SY |
310 | /* UTP Transfer Request Command Type (CT) */ |
311 | enum { | |
312 | UPIU_COMMAND_SET_TYPE_SCSI = 0x0, | |
313 | UPIU_COMMAND_SET_TYPE_UFS = 0x1, | |
314 | UPIU_COMMAND_SET_TYPE_QUERY = 0x2, | |
315 | }; | |
316 | ||
5a0b0cb9 SRT |
317 | /* UTP Transfer Request Command Offset */ |
318 | #define UPIU_COMMAND_TYPE_OFFSET 28 | |
319 | ||
320 | /* Offset of the response code in the UPIU header */ | |
321 | #define UPIU_RSP_CODE_OFFSET 8 | |
322 | ||
7a3e97b0 | 323 | enum { |
68078d5c DR |
324 | MASK_SCSI_STATUS = 0xFF, |
325 | MASK_TASK_RESPONSE = 0xFF00, | |
326 | MASK_RSP_UPIU_RESULT = 0xFFFF, | |
327 | MASK_QUERY_DATA_SEG_LEN = 0xFFFF, | |
1c2623c5 | 328 | MASK_RSP_UPIU_DATA_SEG_LEN = 0xFFFF, |
66ec6d59 | 329 | MASK_RSP_EXCEPTION_EVENT = 0x10000, |
7a3e97b0 SY |
330 | }; |
331 | ||
332 | /* Task management service response */ | |
333 | enum { | |
334 | UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00, | |
335 | UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04, | |
336 | UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08, | |
337 | UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05, | |
338 | UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09, | |
339 | }; | |
57d104c1 SJ |
340 | |
341 | /* UFS device power modes */ | |
342 | enum ufs_dev_pwr_mode { | |
343 | UFS_ACTIVE_PWR_MODE = 1, | |
344 | UFS_SLEEP_PWR_MODE = 2, | |
345 | UFS_POWERDOWN_PWR_MODE = 3, | |
346 | }; | |
347 | ||
7a3e97b0 SY |
348 | /** |
349 | * struct utp_upiu_header - UPIU header structure | |
350 | * @dword_0: UPIU header DW-0 | |
351 | * @dword_1: UPIU header DW-1 | |
352 | * @dword_2: UPIU header DW-2 | |
353 | */ | |
354 | struct utp_upiu_header { | |
e8c8e82a SRT |
355 | __be32 dword_0; |
356 | __be32 dword_1; | |
357 | __be32 dword_2; | |
7a3e97b0 SY |
358 | }; |
359 | ||
360 | /** | |
361 | * struct utp_upiu_cmd - Command UPIU structure | |
7a3e97b0 SY |
362 | * @data_transfer_len: Data Transfer Length DW-3 |
363 | * @cdb: Command Descriptor Block CDB DW-4 to DW-7 | |
364 | */ | |
365 | struct utp_upiu_cmd { | |
e8c8e82a | 366 | __be32 exp_data_transfer_len; |
7a3e97b0 SY |
367 | u8 cdb[MAX_CDB_SIZE]; |
368 | }; | |
369 | ||
68078d5c DR |
370 | /** |
371 | * struct utp_upiu_query - upiu request buffer structure for | |
372 | * query request. | |
373 | * @opcode: command to perform B-0 | |
374 | * @idn: a value that indicates the particular type of data B-1 | |
375 | * @index: Index to further identify data B-2 | |
376 | * @selector: Index to further identify data B-3 | |
377 | * @reserved_osf: spec reserved field B-4,5 | |
378 | * @length: number of descriptor bytes to read/write B-6,7 | |
379 | * @value: Attribute value to be written DW-5 | |
380 | * @reserved: spec reserved DW-6,7 | |
381 | */ | |
382 | struct utp_upiu_query { | |
383 | u8 opcode; | |
384 | u8 idn; | |
385 | u8 index; | |
386 | u8 selector; | |
e8c8e82a SRT |
387 | __be16 reserved_osf; |
388 | __be16 length; | |
389 | __be32 value; | |
390 | __be32 reserved[2]; | |
68078d5c DR |
391 | }; |
392 | ||
7a3e97b0 | 393 | /** |
5a0b0cb9 SRT |
394 | * struct utp_upiu_req - general upiu request structure |
395 | * @header:UPIU header structure DW-0 to DW-2 | |
396 | * @sc: fields structure for scsi command DW-3 to DW-7 | |
68078d5c | 397 | * @qr: fields structure for query request DW-3 to DW-7 |
5a0b0cb9 SRT |
398 | */ |
399 | struct utp_upiu_req { | |
400 | struct utp_upiu_header header; | |
68078d5c DR |
401 | union { |
402 | struct utp_upiu_cmd sc; | |
403 | struct utp_upiu_query qr; | |
404 | }; | |
5a0b0cb9 SRT |
405 | }; |
406 | ||
407 | /** | |
408 | * struct utp_cmd_rsp - Response UPIU structure | |
7a3e97b0 SY |
409 | * @residual_transfer_count: Residual transfer count DW-3 |
410 | * @reserved: Reserved double words DW-4 to DW-7 | |
411 | * @sense_data_len: Sense data length DW-8 U16 | |
412 | * @sense_data: Sense data field DW-8 to DW-12 | |
413 | */ | |
5a0b0cb9 | 414 | struct utp_cmd_rsp { |
e8c8e82a SRT |
415 | __be32 residual_transfer_count; |
416 | __be32 reserved[4]; | |
417 | __be16 sense_data_len; | |
7a3e97b0 SY |
418 | u8 sense_data[18]; |
419 | }; | |
420 | ||
5a0b0cb9 SRT |
421 | /** |
422 | * struct utp_upiu_rsp - general upiu response structure | |
423 | * @header: UPIU header structure DW-0 to DW-2 | |
424 | * @sr: fields structure for scsi command DW-3 to DW-12 | |
68078d5c | 425 | * @qr: fields structure for query request DW-3 to DW-7 |
5a0b0cb9 SRT |
426 | */ |
427 | struct utp_upiu_rsp { | |
428 | struct utp_upiu_header header; | |
68078d5c DR |
429 | union { |
430 | struct utp_cmd_rsp sr; | |
431 | struct utp_upiu_query qr; | |
432 | }; | |
5a0b0cb9 SRT |
433 | }; |
434 | ||
7a3e97b0 SY |
435 | /** |
436 | * struct utp_upiu_task_req - Task request UPIU structure | |
437 | * @header - UPIU header structure DW0 to DW-2 | |
438 | * @input_param1: Input parameter 1 DW-3 | |
439 | * @input_param2: Input parameter 2 DW-4 | |
440 | * @input_param3: Input parameter 3 DW-5 | |
441 | * @reserved: Reserved double words DW-6 to DW-7 | |
442 | */ | |
443 | struct utp_upiu_task_req { | |
444 | struct utp_upiu_header header; | |
e8c8e82a SRT |
445 | __be32 input_param1; |
446 | __be32 input_param2; | |
447 | __be32 input_param3; | |
448 | __be32 reserved[2]; | |
7a3e97b0 SY |
449 | }; |
450 | ||
451 | /** | |
452 | * struct utp_upiu_task_rsp - Task Management Response UPIU structure | |
453 | * @header: UPIU header structure DW0-DW-2 | |
454 | * @output_param1: Ouput parameter 1 DW3 | |
455 | * @output_param2: Output parameter 2 DW4 | |
456 | * @reserved: Reserved double words DW-5 to DW-7 | |
457 | */ | |
458 | struct utp_upiu_task_rsp { | |
459 | struct utp_upiu_header header; | |
e8c8e82a SRT |
460 | __be32 output_param1; |
461 | __be32 output_param2; | |
462 | __be32 reserved[3]; | |
7a3e97b0 SY |
463 | }; |
464 | ||
68078d5c DR |
465 | /** |
466 | * struct ufs_query_req - parameters for building a query request | |
467 | * @query_func: UPIU header query function | |
468 | * @upiu_req: the query request data | |
469 | */ | |
470 | struct ufs_query_req { | |
471 | u8 query_func; | |
472 | struct utp_upiu_query upiu_req; | |
473 | }; | |
474 | ||
475 | /** | |
476 | * struct ufs_query_resp - UPIU QUERY | |
477 | * @response: device response code | |
478 | * @upiu_res: query response data | |
479 | */ | |
480 | struct ufs_query_res { | |
481 | u8 response; | |
482 | struct utp_upiu_query upiu_res; | |
483 | }; | |
484 | ||
aa497613 SRT |
485 | #define UFS_VREG_VCC_MIN_UV 2700000 /* uV */ |
486 | #define UFS_VREG_VCC_MAX_UV 3600000 /* uV */ | |
487 | #define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */ | |
488 | #define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */ | |
489 | #define UFS_VREG_VCCQ_MIN_UV 1100000 /* uV */ | |
490 | #define UFS_VREG_VCCQ_MAX_UV 1300000 /* uV */ | |
491 | #define UFS_VREG_VCCQ2_MIN_UV 1650000 /* uV */ | |
492 | #define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */ | |
493 | ||
57d104c1 SJ |
494 | /* |
495 | * VCCQ & VCCQ2 current requirement when UFS device is in sleep state | |
496 | * and link is in Hibern8 state. | |
497 | */ | |
498 | #define UFS_VREG_LPM_LOAD_UA 1000 /* uA */ | |
499 | ||
aa497613 SRT |
500 | struct ufs_vreg { |
501 | struct regulator *reg; | |
502 | const char *name; | |
503 | bool enabled; | |
60f01870 | 504 | bool unused; |
aa497613 SRT |
505 | int min_uV; |
506 | int max_uV; | |
507 | int min_uA; | |
508 | int max_uA; | |
509 | }; | |
510 | ||
511 | struct ufs_vreg_info { | |
512 | struct ufs_vreg *vcc; | |
513 | struct ufs_vreg *vccq; | |
514 | struct ufs_vreg *vccq2; | |
6a771a65 | 515 | struct ufs_vreg *vdd_hba; |
aa497613 SRT |
516 | }; |
517 | ||
57d104c1 SJ |
518 | struct ufs_dev_info { |
519 | bool f_power_on_wp_en; | |
520 | /* Keeps information if any of the LU is power on write protected */ | |
521 | bool is_lu_power_on_wp; | |
522 | }; | |
523 | ||
7a3e97b0 | 524 | #endif /* End of Header */ |