.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Universal Flash Storage Host controller driver |
---|
3 | | - * |
---|
4 | | - * This code is based on drivers/scsi/ufs/ufs.h |
---|
5 | 4 | * Copyright (C) 2011-2013 Samsung India Software Operations |
---|
6 | 5 | * |
---|
7 | 6 | * Authors: |
---|
8 | 7 | * Santosh Yaraganavi <santosh.sy@samsung.com> |
---|
9 | 8 | * Vinayak Holikatti <h.vinayak@samsung.com> |
---|
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. |
---|
15 | | - * See the COPYING file in the top-level directory or visit |
---|
16 | | - * <http://www.gnu.org/licenses/gpl-2.0.html> |
---|
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 | | - * |
---|
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. |
---|
34 | 9 | */ |
---|
35 | 10 | |
---|
36 | 11 | #ifndef _UFS_H |
---|
.. | .. |
---|
38 | 13 | |
---|
39 | 14 | #include <linux/mutex.h> |
---|
40 | 15 | #include <linux/types.h> |
---|
| 16 | +#include <linux/android_kabi.h> |
---|
| 17 | +#include <uapi/scsi/scsi_bsg_ufs.h> |
---|
41 | 18 | |
---|
42 | | -#define MAX_CDB_SIZE 16 |
---|
43 | | -#define GENERAL_UPIU_REQUEST_SIZE 32 |
---|
| 19 | +#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req)) |
---|
44 | 20 | #define QUERY_DESC_MAX_SIZE 255 |
---|
45 | 21 | #define QUERY_DESC_MIN_SIZE 2 |
---|
46 | 22 | #define QUERY_DESC_HDR_SIZE 2 |
---|
47 | 23 | #define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \ |
---|
48 | 24 | (sizeof(struct utp_upiu_header))) |
---|
49 | | -#define RESPONSE_UPIU_SENSE_DATA_LENGTH 18 |
---|
| 25 | +#define UFS_SENSE_SIZE 18 |
---|
50 | 26 | |
---|
51 | 27 | #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ |
---|
52 | 28 | cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ |
---|
.. | .. |
---|
63 | 39 | #define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F |
---|
64 | 40 | #define UFS_MAX_LUNS (SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID) |
---|
65 | 41 | #define UFS_UPIU_WLUN_ID (1 << 7) |
---|
66 | | -#define UFS_UPIU_MAX_GENERAL_LUN 8 |
---|
| 42 | +#define UFS_RPMB_UNIT 0xC4 |
---|
| 43 | + |
---|
| 44 | +/* WriteBooster buffer is available only for the logical unit from 0 to 7 */ |
---|
| 45 | +#define UFS_UPIU_MAX_WB_LUN_ID 8 |
---|
67 | 46 | |
---|
68 | 47 | /* Well known logical unit id in LUN field of UPIU */ |
---|
69 | 48 | enum { |
---|
.. | .. |
---|
141 | 120 | QUERY_FLAG_IDN_BUSY_RTC = 0x09, |
---|
142 | 121 | QUERY_FLAG_IDN_RESERVED3 = 0x0A, |
---|
143 | 122 | QUERY_FLAG_IDN_PERMANENTLY_DISABLE_FW_UPDATE = 0x0B, |
---|
| 123 | + QUERY_FLAG_IDN_WB_EN = 0x0E, |
---|
| 124 | + QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN = 0x0F, |
---|
| 125 | + QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 = 0x10, |
---|
| 126 | + QUERY_FLAG_IDN_HPB_RESET = 0x11, |
---|
| 127 | + QUERY_FLAG_IDN_HPB_EN = 0x12, |
---|
144 | 128 | }; |
---|
145 | 129 | |
---|
146 | 130 | /* Attribute idn for Query requests */ |
---|
147 | 131 | enum attr_idn { |
---|
148 | 132 | QUERY_ATTR_IDN_BOOT_LU_EN = 0x00, |
---|
149 | | - QUERY_ATTR_IDN_RESERVED = 0x01, |
---|
| 133 | + QUERY_ATTR_IDN_MAX_HPB_SINGLE_CMD = 0x01, |
---|
150 | 134 | QUERY_ATTR_IDN_POWER_MODE = 0x02, |
---|
151 | 135 | QUERY_ATTR_IDN_ACTIVE_ICC_LVL = 0x03, |
---|
152 | 136 | QUERY_ATTR_IDN_OOO_DATA_EN = 0x04, |
---|
.. | .. |
---|
168 | 152 | QUERY_ATTR_IDN_FFU_STATUS = 0x14, |
---|
169 | 153 | QUERY_ATTR_IDN_PSA_STATE = 0x15, |
---|
170 | 154 | QUERY_ATTR_IDN_PSA_DATA_SIZE = 0x16, |
---|
| 155 | + QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME = 0x17, |
---|
| 156 | + QUERY_ATTR_IDN_WB_FLUSH_STATUS = 0x1C, |
---|
| 157 | + QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE = 0x1D, |
---|
| 158 | + QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E, |
---|
| 159 | + QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F, |
---|
171 | 160 | }; |
---|
172 | 161 | |
---|
173 | 162 | /* Descriptor idn for Query requests */ |
---|
.. | .. |
---|
190 | 179 | QUERY_DESC_DESC_TYPE_OFFSET = 0x01, |
---|
191 | 180 | }; |
---|
192 | 181 | |
---|
193 | | -enum ufs_desc_def_size { |
---|
194 | | - QUERY_DESC_DEVICE_DEF_SIZE = 0x40, |
---|
195 | | - QUERY_DESC_CONFIGURATION_DEF_SIZE = 0x90, |
---|
196 | | - QUERY_DESC_UNIT_DEF_SIZE = 0x23, |
---|
197 | | - QUERY_DESC_INTERCONNECT_DEF_SIZE = 0x06, |
---|
198 | | - QUERY_DESC_GEOMETRY_DEF_SIZE = 0x48, |
---|
199 | | - QUERY_DESC_POWER_DEF_SIZE = 0x62, |
---|
200 | | - QUERY_DESC_HEALTH_DEF_SIZE = 0x25, |
---|
201 | | -}; |
---|
202 | | - |
---|
203 | 182 | /* Unit descriptor parameters offsets in bytes*/ |
---|
204 | 183 | enum unit_desc_param { |
---|
205 | 184 | UNIT_DESC_PARAM_LEN = 0x0, |
---|
.. | .. |
---|
219 | 198 | UNIT_DESC_PARAM_PHY_MEM_RSRC_CNT = 0x18, |
---|
220 | 199 | UNIT_DESC_PARAM_CTX_CAPABILITIES = 0x20, |
---|
221 | 200 | UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 = 0x22, |
---|
| 201 | + UNIT_DESC_PARAM_HPB_LU_MAX_ACTIVE_RGNS = 0x23, |
---|
| 202 | + UNIT_DESC_PARAM_HPB_PIN_RGN_START_OFF = 0x25, |
---|
| 203 | + UNIT_DESC_PARAM_HPB_NUM_PIN_RGNS = 0x27, |
---|
| 204 | + UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS = 0x29, |
---|
222 | 205 | }; |
---|
223 | 206 | |
---|
224 | 207 | /* Device descriptor parameters offsets in bytes*/ |
---|
.. | .. |
---|
258 | 241 | DEVICE_DESC_PARAM_PSA_MAX_DATA = 0x25, |
---|
259 | 242 | DEVICE_DESC_PARAM_PSA_TMT = 0x29, |
---|
260 | 243 | DEVICE_DESC_PARAM_PRDCT_REV = 0x2A, |
---|
| 244 | + DEVICE_DESC_PARAM_HPB_VER = 0x40, |
---|
| 245 | + DEVICE_DESC_PARAM_HPB_CONTROL = 0x42, |
---|
| 246 | + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP = 0x4F, |
---|
| 247 | + DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN = 0x53, |
---|
| 248 | + DEVICE_DESC_PARAM_WB_TYPE = 0x54, |
---|
| 249 | + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, |
---|
261 | 250 | }; |
---|
262 | 251 | |
---|
263 | 252 | /* Interconnect descriptor parameters offsets in bytes*/ |
---|
.. | .. |
---|
302 | 291 | GEOMETRY_DESC_PARAM_ENM4_MAX_NUM_UNITS = 0x3E, |
---|
303 | 292 | GEOMETRY_DESC_PARAM_ENM4_CAP_ADJ_FCTR = 0x42, |
---|
304 | 293 | GEOMETRY_DESC_PARAM_OPT_LOG_BLK_SIZE = 0x44, |
---|
| 294 | + GEOMETRY_DESC_PARAM_HPB_REGION_SIZE = 0x48, |
---|
| 295 | + GEOMETRY_DESC_PARAM_HPB_NUMBER_LU = 0x49, |
---|
| 296 | + GEOMETRY_DESC_PARAM_HPB_SUBREGION_SIZE = 0x4A, |
---|
| 297 | + GEOMETRY_DESC_PARAM_HPB_MAX_ACTIVE_REGS = 0x4B, |
---|
| 298 | + GEOMETRY_DESC_PARAM_WB_MAX_ALLOC_UNITS = 0x4F, |
---|
| 299 | + GEOMETRY_DESC_PARAM_WB_MAX_WB_LUNS = 0x53, |
---|
| 300 | + GEOMETRY_DESC_PARAM_WB_BUFF_CAP_ADJ = 0x54, |
---|
| 301 | + GEOMETRY_DESC_PARAM_WB_SUP_RED_TYPE = 0x55, |
---|
| 302 | + GEOMETRY_DESC_PARAM_WB_SUP_WB_TYPE = 0x56, |
---|
305 | 303 | }; |
---|
306 | 304 | |
---|
307 | 305 | /* Health descriptor parameters offsets in bytes*/ |
---|
.. | .. |
---|
311 | 309 | HEALTH_DESC_PARAM_EOL_INFO = 0x2, |
---|
312 | 310 | HEALTH_DESC_PARAM_LIFE_TIME_EST_A = 0x3, |
---|
313 | 311 | HEALTH_DESC_PARAM_LIFE_TIME_EST_B = 0x4, |
---|
| 312 | +}; |
---|
| 313 | + |
---|
| 314 | +/* WriteBooster buffer mode */ |
---|
| 315 | +enum { |
---|
| 316 | + WB_BUF_MODE_LU_DEDICATED = 0x0, |
---|
| 317 | + WB_BUF_MODE_SHARED = 0x1, |
---|
314 | 318 | }; |
---|
315 | 319 | |
---|
316 | 320 | /* |
---|
.. | .. |
---|
332 | 336 | UFSHCD_MILI_AMP = 2, |
---|
333 | 337 | UFSHCD_AMP = 3, |
---|
334 | 338 | }; |
---|
| 339 | + |
---|
| 340 | +/* Possible values for dExtendedUFSFeaturesSupport */ |
---|
| 341 | +enum { |
---|
| 342 | + UFS_DEV_HPB_SUPPORT = BIT(7), |
---|
| 343 | + UFS_DEV_WRITE_BOOSTER_SUP = BIT(8), |
---|
| 344 | +}; |
---|
| 345 | +#define UFS_DEV_HPB_SUPPORT_VERSION 0x310 |
---|
335 | 346 | |
---|
336 | 347 | #define POWER_DESC_MAX_SIZE 0x62 |
---|
337 | 348 | #define POWER_DESC_MAX_ACTV_ICC_LVLS 16 |
---|
.. | .. |
---|
378 | 389 | UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8, |
---|
379 | 390 | }; |
---|
380 | 391 | |
---|
| 392 | +/* bRefClkFreq attribute values */ |
---|
| 393 | +enum ufs_ref_clk_freq { |
---|
| 394 | + REF_CLK_FREQ_19_2_MHZ = 0, |
---|
| 395 | + REF_CLK_FREQ_26_MHZ = 1, |
---|
| 396 | + REF_CLK_FREQ_38_4_MHZ = 2, |
---|
| 397 | + REF_CLK_FREQ_52_MHZ = 3, |
---|
| 398 | + REF_CLK_FREQ_INVAL = -1, |
---|
| 399 | +}; |
---|
| 400 | + |
---|
| 401 | +struct ufs_ref_clk { |
---|
| 402 | + unsigned long freq_hz; |
---|
| 403 | + enum ufs_ref_clk_freq val; |
---|
| 404 | +}; |
---|
| 405 | + |
---|
381 | 406 | /* Query response result code */ |
---|
382 | 407 | enum { |
---|
383 | 408 | QUERY_RESULT_SUCCESS = 0x00, |
---|
.. | .. |
---|
414 | 439 | MASK_RSP_UPIU_DATA_SEG_LEN = 0xFFFF, |
---|
415 | 440 | MASK_RSP_EXCEPTION_EVENT = 0x10000, |
---|
416 | 441 | MASK_TM_SERVICE_RESP = 0xFF, |
---|
| 442 | + MASK_TM_FUNC = 0xFF, |
---|
417 | 443 | }; |
---|
418 | 444 | |
---|
419 | 445 | /* Task management service response */ |
---|
.. | .. |
---|
432 | 458 | UFS_POWERDOWN_PWR_MODE = 3, |
---|
433 | 459 | }; |
---|
434 | 460 | |
---|
435 | | -/** |
---|
436 | | - * struct utp_upiu_header - UPIU header structure |
---|
437 | | - * @dword_0: UPIU header DW-0 |
---|
438 | | - * @dword_1: UPIU header DW-1 |
---|
439 | | - * @dword_2: UPIU header DW-2 |
---|
440 | | - */ |
---|
441 | | -struct utp_upiu_header { |
---|
442 | | - __be32 dword_0; |
---|
443 | | - __be32 dword_1; |
---|
444 | | - __be32 dword_2; |
---|
445 | | -}; |
---|
446 | | - |
---|
447 | | -/** |
---|
448 | | - * struct utp_upiu_cmd - Command UPIU structure |
---|
449 | | - * @data_transfer_len: Data Transfer Length DW-3 |
---|
450 | | - * @cdb: Command Descriptor Block CDB DW-4 to DW-7 |
---|
451 | | - */ |
---|
452 | | -struct utp_upiu_cmd { |
---|
453 | | - __be32 exp_data_transfer_len; |
---|
454 | | - u8 cdb[MAX_CDB_SIZE]; |
---|
455 | | -}; |
---|
456 | | - |
---|
457 | | -/** |
---|
458 | | - * struct utp_upiu_query - upiu request buffer structure for |
---|
459 | | - * query request. |
---|
460 | | - * @opcode: command to perform B-0 |
---|
461 | | - * @idn: a value that indicates the particular type of data B-1 |
---|
462 | | - * @index: Index to further identify data B-2 |
---|
463 | | - * @selector: Index to further identify data B-3 |
---|
464 | | - * @reserved_osf: spec reserved field B-4,5 |
---|
465 | | - * @length: number of descriptor bytes to read/write B-6,7 |
---|
466 | | - * @value: Attribute value to be written DW-5 |
---|
467 | | - * @reserved: spec reserved DW-6,7 |
---|
468 | | - */ |
---|
469 | | -struct utp_upiu_query { |
---|
470 | | - u8 opcode; |
---|
471 | | - u8 idn; |
---|
472 | | - u8 index; |
---|
473 | | - u8 selector; |
---|
474 | | - __be16 reserved_osf; |
---|
475 | | - __be16 length; |
---|
476 | | - __be32 value; |
---|
477 | | - __be32 reserved[2]; |
---|
478 | | -}; |
---|
479 | | - |
---|
480 | | -/** |
---|
481 | | - * struct utp_upiu_req - general upiu request structure |
---|
482 | | - * @header:UPIU header structure DW-0 to DW-2 |
---|
483 | | - * @sc: fields structure for scsi command DW-3 to DW-7 |
---|
484 | | - * @qr: fields structure for query request DW-3 to DW-7 |
---|
485 | | - */ |
---|
486 | | -struct utp_upiu_req { |
---|
487 | | - struct utp_upiu_header header; |
---|
488 | | - union { |
---|
489 | | - struct utp_upiu_cmd sc; |
---|
490 | | - struct utp_upiu_query qr; |
---|
491 | | - }; |
---|
492 | | -}; |
---|
| 461 | +#define UFS_WB_BUF_REMAIN_PERCENT(val) ((val) / 10) |
---|
493 | 462 | |
---|
494 | 463 | /** |
---|
495 | 464 | * struct utp_cmd_rsp - Response UPIU structure |
---|
.. | .. |
---|
502 | 471 | __be32 residual_transfer_count; |
---|
503 | 472 | __be32 reserved[4]; |
---|
504 | 473 | __be16 sense_data_len; |
---|
505 | | - u8 sense_data[RESPONSE_UPIU_SENSE_DATA_LENGTH]; |
---|
| 474 | + u8 sense_data[UFS_SENSE_SIZE]; |
---|
506 | 475 | }; |
---|
| 476 | + |
---|
| 477 | +struct ufshpb_active_field { |
---|
| 478 | + __be16 active_rgn; |
---|
| 479 | + __be16 active_srgn; |
---|
| 480 | +}; |
---|
| 481 | +#define HPB_ACT_FIELD_SIZE 4 |
---|
| 482 | + |
---|
| 483 | +/** |
---|
| 484 | + * struct utp_hpb_rsp - Response UPIU structure |
---|
| 485 | + * @residual_transfer_count: Residual transfer count DW-3 |
---|
| 486 | + * @reserved1: Reserved double words DW-4 to DW-7 |
---|
| 487 | + * @sense_data_len: Sense data length DW-8 U16 |
---|
| 488 | + * @desc_type: Descriptor type of sense data |
---|
| 489 | + * @additional_len: Additional length of sense data |
---|
| 490 | + * @hpb_op: HPB operation type |
---|
| 491 | + * @lun: LUN of response UPIU |
---|
| 492 | + * @active_rgn_cnt: Active region count |
---|
| 493 | + * @inactive_rgn_cnt: Inactive region count |
---|
| 494 | + * @hpb_active_field: Recommended to read HPB region and subregion |
---|
| 495 | + * @hpb_inactive_field: To be inactivated HPB region and subregion |
---|
| 496 | + */ |
---|
| 497 | +struct utp_hpb_rsp { |
---|
| 498 | + __be32 residual_transfer_count; |
---|
| 499 | + __be32 reserved1[4]; |
---|
| 500 | + __be16 sense_data_len; |
---|
| 501 | + u8 desc_type; |
---|
| 502 | + u8 additional_len; |
---|
| 503 | + u8 hpb_op; |
---|
| 504 | + u8 lun; |
---|
| 505 | + u8 active_rgn_cnt; |
---|
| 506 | + u8 inactive_rgn_cnt; |
---|
| 507 | + struct ufshpb_active_field hpb_active_field[2]; |
---|
| 508 | + __be16 hpb_inactive_field[2]; |
---|
| 509 | +}; |
---|
| 510 | +#define UTP_HPB_RSP_SIZE 40 |
---|
507 | 511 | |
---|
508 | 512 | /** |
---|
509 | 513 | * struct utp_upiu_rsp - general upiu response structure |
---|
.. | .. |
---|
515 | 519 | struct utp_upiu_header header; |
---|
516 | 520 | union { |
---|
517 | 521 | struct utp_cmd_rsp sr; |
---|
| 522 | + struct utp_hpb_rsp hr; |
---|
518 | 523 | struct utp_upiu_query qr; |
---|
519 | 524 | }; |
---|
520 | | -}; |
---|
521 | | - |
---|
522 | | -/** |
---|
523 | | - * struct utp_upiu_task_req - Task request UPIU structure |
---|
524 | | - * @header - UPIU header structure DW0 to DW-2 |
---|
525 | | - * @input_param1: Input parameter 1 DW-3 |
---|
526 | | - * @input_param2: Input parameter 2 DW-4 |
---|
527 | | - * @input_param3: Input parameter 3 DW-5 |
---|
528 | | - * @reserved: Reserved double words DW-6 to DW-7 |
---|
529 | | - */ |
---|
530 | | -struct utp_upiu_task_req { |
---|
531 | | - struct utp_upiu_header header; |
---|
532 | | - __be32 input_param1; |
---|
533 | | - __be32 input_param2; |
---|
534 | | - __be32 input_param3; |
---|
535 | | - __be32 reserved[2]; |
---|
536 | | -}; |
---|
537 | | - |
---|
538 | | -/** |
---|
539 | | - * struct utp_upiu_task_rsp - Task Management Response UPIU structure |
---|
540 | | - * @header: UPIU header structure DW0-DW-2 |
---|
541 | | - * @output_param1: Ouput parameter 1 DW3 |
---|
542 | | - * @output_param2: Output parameter 2 DW4 |
---|
543 | | - * @reserved: Reserved double words DW-5 to DW-7 |
---|
544 | | - */ |
---|
545 | | -struct utp_upiu_task_rsp { |
---|
546 | | - struct utp_upiu_header header; |
---|
547 | | - __be32 output_param1; |
---|
548 | | - __be32 output_param2; |
---|
549 | | - __be32 reserved[3]; |
---|
550 | 525 | }; |
---|
551 | 526 | |
---|
552 | 527 | /** |
---|
.. | .. |
---|
573 | 548 | #define UFS_VREG_VCC_MAX_UV 3600000 /* uV */ |
---|
574 | 549 | #define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */ |
---|
575 | 550 | #define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */ |
---|
576 | | -#define UFS_VREG_VCCQ_MIN_UV 1100000 /* uV */ |
---|
577 | | -#define UFS_VREG_VCCQ_MAX_UV 1300000 /* uV */ |
---|
578 | | -#define UFS_VREG_VCCQ2_MIN_UV 1650000 /* uV */ |
---|
| 551 | +#define UFS_VREG_VCCQ_MIN_UV 1140000 /* uV */ |
---|
| 552 | +#define UFS_VREG_VCCQ_MAX_UV 1260000 /* uV */ |
---|
| 553 | +#define UFS_VREG_VCCQ2_MIN_UV 1700000 /* uV */ |
---|
579 | 554 | #define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */ |
---|
580 | 555 | |
---|
581 | 556 | /* |
---|
.. | .. |
---|
587 | 562 | struct ufs_vreg { |
---|
588 | 563 | struct regulator *reg; |
---|
589 | 564 | const char *name; |
---|
| 565 | + bool always_on; |
---|
590 | 566 | bool enabled; |
---|
591 | | - bool unused; |
---|
592 | 567 | int min_uV; |
---|
593 | 568 | int max_uV; |
---|
594 | | - int min_uA; |
---|
595 | 569 | int max_uA; |
---|
596 | 570 | }; |
---|
597 | 571 | |
---|
.. | .. |
---|
606 | 580 | bool f_power_on_wp_en; |
---|
607 | 581 | /* Keeps information if any of the LU is power on write protected */ |
---|
608 | 582 | bool is_lu_power_on_wp; |
---|
609 | | -}; |
---|
610 | | - |
---|
611 | | -#define MAX_MODEL_LEN 16 |
---|
612 | | -/** |
---|
613 | | - * ufs_dev_desc - ufs device details from the device descriptor |
---|
614 | | - * |
---|
615 | | - * @wmanufacturerid: card details |
---|
616 | | - * @model: card model |
---|
617 | | - */ |
---|
618 | | -struct ufs_dev_desc { |
---|
| 583 | + /* Maximum number of general LU supported by the UFS device */ |
---|
| 584 | + u8 max_lu_supported; |
---|
| 585 | + u8 wb_dedicated_lu; |
---|
619 | 586 | u16 wmanufacturerid; |
---|
620 | | - char model[MAX_MODEL_LEN + 1]; |
---|
| 587 | + /*UFS device Product Name */ |
---|
| 588 | + u8 *model; |
---|
| 589 | + u16 wspecversion; |
---|
| 590 | + u32 clk_gating_wait_us; |
---|
| 591 | + u32 d_ext_ufs_feature_sup; |
---|
| 592 | + u8 b_wb_buffer_type; |
---|
| 593 | + u32 d_wb_alloc_units; |
---|
| 594 | + bool b_rpm_dev_flush_capable; |
---|
| 595 | + u8 b_presrv_uspc_en; |
---|
| 596 | + /* UFS HPB related flag */ |
---|
| 597 | + bool hpb_enabled; |
---|
| 598 | + ANDROID_KABI_RESERVE(1); |
---|
621 | 599 | }; |
---|
622 | 600 | |
---|
623 | 601 | /** |
---|
624 | 602 | * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor |
---|
| 603 | + * @dev_info: pointer of instance of struct ufs_dev_info |
---|
625 | 604 | * @lun: LU number to check |
---|
626 | 605 | * @return: true if the lun has a matching unit descriptor, false otherwise |
---|
627 | 606 | */ |
---|
628 | | -static inline bool ufs_is_valid_unit_desc_lun(u8 lun) |
---|
| 607 | +static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, |
---|
| 608 | + u8 lun, u8 param_offset) |
---|
629 | 609 | { |
---|
630 | | - return lun == UFS_UPIU_RPMB_WLUN || (lun < UFS_UPIU_MAX_GENERAL_LUN); |
---|
| 610 | + if (!dev_info || !dev_info->max_lu_supported) { |
---|
| 611 | + pr_err("Max General LU supported by UFS isn't initialized\n"); |
---|
| 612 | + return false; |
---|
| 613 | + } |
---|
| 614 | + /* WB is available only for the logical unit from 0 to 7 */ |
---|
| 615 | + if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS) |
---|
| 616 | + return lun < UFS_UPIU_MAX_WB_LUN_ID; |
---|
| 617 | + return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported); |
---|
631 | 618 | } |
---|
632 | 619 | |
---|
633 | 620 | #endif /* End of Header */ |
---|