18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Universal Flash Storage Host controller driver 48c2ecf20Sopenharmony_ci * Copyright (C) 2011-2013 Samsung India Software Operations 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Authors: 78c2ecf20Sopenharmony_ci * Santosh Yaraganavi <santosh.sy@samsung.com> 88c2ecf20Sopenharmony_ci * Vinayak Holikatti <h.vinayak@samsung.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _UFS_H 128c2ecf20Sopenharmony_ci#define _UFS_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/mutex.h> 158c2ecf20Sopenharmony_ci#include <linux/types.h> 168c2ecf20Sopenharmony_ci#include <uapi/scsi/scsi_bsg_ufs.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req)) 198c2ecf20Sopenharmony_ci#define QUERY_DESC_MAX_SIZE 255 208c2ecf20Sopenharmony_ci#define QUERY_DESC_MIN_SIZE 2 218c2ecf20Sopenharmony_ci#define QUERY_DESC_HDR_SIZE 2 228c2ecf20Sopenharmony_ci#define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \ 238c2ecf20Sopenharmony_ci (sizeof(struct utp_upiu_header))) 248c2ecf20Sopenharmony_ci#define UFS_SENSE_SIZE 18 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ 278c2ecf20Sopenharmony_ci cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ 288c2ecf20Sopenharmony_ci (byte1 << 8) | (byte0)) 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * UFS device may have standard LUs and LUN id could be from 0x00 to 318c2ecf20Sopenharmony_ci * 0x7F. Standard LUs use "Peripheral Device Addressing Format". 328c2ecf20Sopenharmony_ci * UFS device may also have the Well Known LUs (also referred as W-LU) 338c2ecf20Sopenharmony_ci * which again could be from 0x00 to 0x7F. For W-LUs, device only use 348c2ecf20Sopenharmony_ci * the "Extended Addressing Format" which means the W-LUNs would be 358c2ecf20Sopenharmony_ci * from 0xc100 (SCSI_W_LUN_BASE) onwards. 368c2ecf20Sopenharmony_ci * This means max. LUN number reported from UFS device could be 0xC17F. 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci#define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F 398c2ecf20Sopenharmony_ci#define UFS_MAX_LUNS (SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID) 408c2ecf20Sopenharmony_ci#define UFS_UPIU_WLUN_ID (1 << 7) 418c2ecf20Sopenharmony_ci#define UFS_RPMB_UNIT 0xC4 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* WriteBooster buffer is available only for the logical unit from 0 to 7 */ 448c2ecf20Sopenharmony_ci#define UFS_UPIU_MAX_WB_LUN_ID 8 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* Well known logical unit id in LUN field of UPIU */ 478c2ecf20Sopenharmony_cienum { 488c2ecf20Sopenharmony_ci UFS_UPIU_REPORT_LUNS_WLUN = 0x81, 498c2ecf20Sopenharmony_ci UFS_UPIU_UFS_DEVICE_WLUN = 0xD0, 508c2ecf20Sopenharmony_ci UFS_UPIU_BOOT_WLUN = 0xB0, 518c2ecf20Sopenharmony_ci UFS_UPIU_RPMB_WLUN = 0xC4, 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* 558c2ecf20Sopenharmony_ci * UFS Protocol Information Unit related definitions 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* Task management functions */ 598c2ecf20Sopenharmony_cienum { 608c2ecf20Sopenharmony_ci UFS_ABORT_TASK = 0x01, 618c2ecf20Sopenharmony_ci UFS_ABORT_TASK_SET = 0x02, 628c2ecf20Sopenharmony_ci UFS_CLEAR_TASK_SET = 0x04, 638c2ecf20Sopenharmony_ci UFS_LOGICAL_RESET = 0x08, 648c2ecf20Sopenharmony_ci UFS_QUERY_TASK = 0x80, 658c2ecf20Sopenharmony_ci UFS_QUERY_TASK_SET = 0x81, 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* UTP UPIU Transaction Codes Initiator to Target */ 698c2ecf20Sopenharmony_cienum { 708c2ecf20Sopenharmony_ci UPIU_TRANSACTION_NOP_OUT = 0x00, 718c2ecf20Sopenharmony_ci UPIU_TRANSACTION_COMMAND = 0x01, 728c2ecf20Sopenharmony_ci UPIU_TRANSACTION_DATA_OUT = 0x02, 738c2ecf20Sopenharmony_ci UPIU_TRANSACTION_TASK_REQ = 0x04, 748c2ecf20Sopenharmony_ci UPIU_TRANSACTION_QUERY_REQ = 0x16, 758c2ecf20Sopenharmony_ci}; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* UTP UPIU Transaction Codes Target to Initiator */ 788c2ecf20Sopenharmony_cienum { 798c2ecf20Sopenharmony_ci UPIU_TRANSACTION_NOP_IN = 0x20, 808c2ecf20Sopenharmony_ci UPIU_TRANSACTION_RESPONSE = 0x21, 818c2ecf20Sopenharmony_ci UPIU_TRANSACTION_DATA_IN = 0x22, 828c2ecf20Sopenharmony_ci UPIU_TRANSACTION_TASK_RSP = 0x24, 838c2ecf20Sopenharmony_ci UPIU_TRANSACTION_READY_XFER = 0x31, 848c2ecf20Sopenharmony_ci UPIU_TRANSACTION_QUERY_RSP = 0x36, 858c2ecf20Sopenharmony_ci UPIU_TRANSACTION_REJECT_UPIU = 0x3F, 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* UPIU Read/Write flags */ 898c2ecf20Sopenharmony_cienum { 908c2ecf20Sopenharmony_ci UPIU_CMD_FLAGS_NONE = 0x00, 918c2ecf20Sopenharmony_ci UPIU_CMD_FLAGS_WRITE = 0x20, 928c2ecf20Sopenharmony_ci UPIU_CMD_FLAGS_READ = 0x40, 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* UPIU Task Attributes */ 968c2ecf20Sopenharmony_cienum { 978c2ecf20Sopenharmony_ci UPIU_TASK_ATTR_SIMPLE = 0x00, 988c2ecf20Sopenharmony_ci UPIU_TASK_ATTR_ORDERED = 0x01, 998c2ecf20Sopenharmony_ci UPIU_TASK_ATTR_HEADQ = 0x02, 1008c2ecf20Sopenharmony_ci UPIU_TASK_ATTR_ACA = 0x03, 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* UPIU Query request function */ 1048c2ecf20Sopenharmony_cienum { 1058c2ecf20Sopenharmony_ci UPIU_QUERY_FUNC_STANDARD_READ_REQUEST = 0x01, 1068c2ecf20Sopenharmony_ci UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST = 0x81, 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* Flag idn for Query Requests*/ 1108c2ecf20Sopenharmony_cienum flag_idn { 1118c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_FDEVICEINIT = 0x01, 1128c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_PERMANENT_WPE = 0x02, 1138c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_PWR_ON_WPE = 0x03, 1148c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_BKOPS_EN = 0x04, 1158c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_LIFE_SPAN_MODE_ENABLE = 0x05, 1168c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_PURGE_ENABLE = 0x06, 1178c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_RESERVED2 = 0x07, 1188c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_FPHYRESOURCEREMOVAL = 0x08, 1198c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_BUSY_RTC = 0x09, 1208c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_RESERVED3 = 0x0A, 1218c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_PERMANENTLY_DISABLE_FW_UPDATE = 0x0B, 1228c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_WB_EN = 0x0E, 1238c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN = 0x0F, 1248c2ecf20Sopenharmony_ci QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 = 0x10, 1258c2ecf20Sopenharmony_ci}; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci/* Attribute idn for Query requests */ 1288c2ecf20Sopenharmony_cienum attr_idn { 1298c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_BOOT_LU_EN = 0x00, 1308c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_RESERVED = 0x01, 1318c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_POWER_MODE = 0x02, 1328c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_ACTIVE_ICC_LVL = 0x03, 1338c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_OOO_DATA_EN = 0x04, 1348c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_BKOPS_STATUS = 0x05, 1358c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_PURGE_STATUS = 0x06, 1368c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_MAX_DATA_IN = 0x07, 1378c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_MAX_DATA_OUT = 0x08, 1388c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_DYN_CAP_NEEDED = 0x09, 1398c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_REF_CLK_FREQ = 0x0A, 1408c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_CONF_DESC_LOCK = 0x0B, 1418c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_MAX_NUM_OF_RTT = 0x0C, 1428c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_EE_CONTROL = 0x0D, 1438c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_EE_STATUS = 0x0E, 1448c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_SECONDS_PASSED = 0x0F, 1458c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_CNTX_CONF = 0x10, 1468c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_CORR_PRG_BLK_NUM = 0x11, 1478c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_RESERVED2 = 0x12, 1488c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_RESERVED3 = 0x13, 1498c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_FFU_STATUS = 0x14, 1508c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_PSA_STATE = 0x15, 1518c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_PSA_DATA_SIZE = 0x16, 1528c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME = 0x17, 1538c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_WB_FLUSH_STATUS = 0x1C, 1548c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE = 0x1D, 1558c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E, 1568c2ecf20Sopenharmony_ci QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F, 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/* Descriptor idn for Query requests */ 1608c2ecf20Sopenharmony_cienum desc_idn { 1618c2ecf20Sopenharmony_ci QUERY_DESC_IDN_DEVICE = 0x0, 1628c2ecf20Sopenharmony_ci QUERY_DESC_IDN_CONFIGURATION = 0x1, 1638c2ecf20Sopenharmony_ci QUERY_DESC_IDN_UNIT = 0x2, 1648c2ecf20Sopenharmony_ci QUERY_DESC_IDN_RFU_0 = 0x3, 1658c2ecf20Sopenharmony_ci QUERY_DESC_IDN_INTERCONNECT = 0x4, 1668c2ecf20Sopenharmony_ci QUERY_DESC_IDN_STRING = 0x5, 1678c2ecf20Sopenharmony_ci QUERY_DESC_IDN_RFU_1 = 0x6, 1688c2ecf20Sopenharmony_ci QUERY_DESC_IDN_GEOMETRY = 0x7, 1698c2ecf20Sopenharmony_ci QUERY_DESC_IDN_POWER = 0x8, 1708c2ecf20Sopenharmony_ci QUERY_DESC_IDN_HEALTH = 0x9, 1718c2ecf20Sopenharmony_ci QUERY_DESC_IDN_MAX, 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cienum desc_header_offset { 1758c2ecf20Sopenharmony_ci QUERY_DESC_LENGTH_OFFSET = 0x00, 1768c2ecf20Sopenharmony_ci QUERY_DESC_DESC_TYPE_OFFSET = 0x01, 1778c2ecf20Sopenharmony_ci}; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* Unit descriptor parameters offsets in bytes*/ 1808c2ecf20Sopenharmony_cienum unit_desc_param { 1818c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_LEN = 0x0, 1828c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_TYPE = 0x1, 1838c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_UNIT_INDEX = 0x2, 1848c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_LU_ENABLE = 0x3, 1858c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_BOOT_LUN_ID = 0x4, 1868c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_LU_WR_PROTECT = 0x5, 1878c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_LU_Q_DEPTH = 0x6, 1888c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_PSA_SENSITIVE = 0x7, 1898c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_MEM_TYPE = 0x8, 1908c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_DATA_RELIABILITY = 0x9, 1918c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_LOGICAL_BLK_SIZE = 0xA, 1928c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_LOGICAL_BLK_COUNT = 0xB, 1938c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_ERASE_BLK_SIZE = 0x13, 1948c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_PROVISIONING_TYPE = 0x17, 1958c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_PHY_MEM_RSRC_CNT = 0x18, 1968c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_CTX_CAPABILITIES = 0x20, 1978c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 = 0x22, 1988c2ecf20Sopenharmony_ci UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS = 0x29, 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* Device descriptor parameters offsets in bytes*/ 2028c2ecf20Sopenharmony_cienum device_desc_param { 2038c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_LEN = 0x0, 2048c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_TYPE = 0x1, 2058c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_DEVICE_TYPE = 0x2, 2068c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_DEVICE_CLASS = 0x3, 2078c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_DEVICE_SUB_CLASS = 0x4, 2088c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_PRTCL = 0x5, 2098c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_NUM_LU = 0x6, 2108c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_NUM_WLU = 0x7, 2118c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_BOOT_ENBL = 0x8, 2128c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_DESC_ACCSS_ENBL = 0x9, 2138c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_INIT_PWR_MODE = 0xA, 2148c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_HIGH_PR_LUN = 0xB, 2158c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_SEC_RMV_TYPE = 0xC, 2168c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_SEC_LU = 0xD, 2178c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_BKOP_TERM_LT = 0xE, 2188c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_ACTVE_ICC_LVL = 0xF, 2198c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_SPEC_VER = 0x10, 2208c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_MANF_DATE = 0x12, 2218c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_MANF_NAME = 0x14, 2228c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_PRDCT_NAME = 0x15, 2238c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_SN = 0x16, 2248c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_OEM_ID = 0x17, 2258c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_MANF_ID = 0x18, 2268c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_UD_OFFSET = 0x1A, 2278c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_UD_LEN = 0x1B, 2288c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_RTT_CAP = 0x1C, 2298c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_FRQ_RTC = 0x1D, 2308c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_UFS_FEAT = 0x1F, 2318c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_FFU_TMT = 0x20, 2328c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_Q_DPTH = 0x21, 2338c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_DEV_VER = 0x22, 2348c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_NUM_SEC_WPA = 0x24, 2358c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_PSA_MAX_DATA = 0x25, 2368c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_PSA_TMT = 0x29, 2378c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_PRDCT_REV = 0x2A, 2388c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP = 0x4F, 2398c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN = 0x53, 2408c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_WB_TYPE = 0x54, 2418c2ecf20Sopenharmony_ci DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, 2428c2ecf20Sopenharmony_ci}; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/* Interconnect descriptor parameters offsets in bytes*/ 2458c2ecf20Sopenharmony_cienum interconnect_desc_param { 2468c2ecf20Sopenharmony_ci INTERCONNECT_DESC_PARAM_LEN = 0x0, 2478c2ecf20Sopenharmony_ci INTERCONNECT_DESC_PARAM_TYPE = 0x1, 2488c2ecf20Sopenharmony_ci INTERCONNECT_DESC_PARAM_UNIPRO_VER = 0x2, 2498c2ecf20Sopenharmony_ci INTERCONNECT_DESC_PARAM_MPHY_VER = 0x4, 2508c2ecf20Sopenharmony_ci}; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* Geometry descriptor parameters offsets in bytes*/ 2538c2ecf20Sopenharmony_cienum geometry_desc_param { 2548c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_LEN = 0x0, 2558c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_TYPE = 0x1, 2568c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_DEV_CAP = 0x4, 2578c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_MAX_NUM_LUN = 0xC, 2588c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_SEG_SIZE = 0xD, 2598c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ALLOC_UNIT_SIZE = 0x11, 2608c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_MIN_BLK_SIZE = 0x12, 2618c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_OPT_RD_BLK_SIZE = 0x13, 2628c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_OPT_WR_BLK_SIZE = 0x14, 2638c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_MAX_IN_BUF_SIZE = 0x15, 2648c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_MAX_OUT_BUF_SIZE = 0x16, 2658c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_RPMB_RW_SIZE = 0x17, 2668c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_DYN_CAP_RSRC_PLC = 0x18, 2678c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_DATA_ORDER = 0x19, 2688c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_MAX_NUM_CTX = 0x1A, 2698c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_TAG_UNIT_SIZE = 0x1B, 2708c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_TAG_RSRC_SIZE = 0x1C, 2718c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_SEC_RM_TYPES = 0x1D, 2728c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_MEM_TYPES = 0x1E, 2738c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_SCM_MAX_NUM_UNITS = 0x20, 2748c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_SCM_CAP_ADJ_FCTR = 0x24, 2758c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_NPM_MAX_NUM_UNITS = 0x26, 2768c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_NPM_CAP_ADJ_FCTR = 0x2A, 2778c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM1_MAX_NUM_UNITS = 0x2C, 2788c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM1_CAP_ADJ_FCTR = 0x30, 2798c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM2_MAX_NUM_UNITS = 0x32, 2808c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM2_CAP_ADJ_FCTR = 0x36, 2818c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM3_MAX_NUM_UNITS = 0x38, 2828c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM3_CAP_ADJ_FCTR = 0x3C, 2838c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM4_MAX_NUM_UNITS = 0x3E, 2848c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_ENM4_CAP_ADJ_FCTR = 0x42, 2858c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_OPT_LOG_BLK_SIZE = 0x44, 2868c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_WB_MAX_ALLOC_UNITS = 0x4F, 2878c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_WB_MAX_WB_LUNS = 0x53, 2888c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_WB_BUFF_CAP_ADJ = 0x54, 2898c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_WB_SUP_RED_TYPE = 0x55, 2908c2ecf20Sopenharmony_ci GEOMETRY_DESC_PARAM_WB_SUP_WB_TYPE = 0x56, 2918c2ecf20Sopenharmony_ci}; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci/* Health descriptor parameters offsets in bytes*/ 2948c2ecf20Sopenharmony_cienum health_desc_param { 2958c2ecf20Sopenharmony_ci HEALTH_DESC_PARAM_LEN = 0x0, 2968c2ecf20Sopenharmony_ci HEALTH_DESC_PARAM_TYPE = 0x1, 2978c2ecf20Sopenharmony_ci HEALTH_DESC_PARAM_EOL_INFO = 0x2, 2988c2ecf20Sopenharmony_ci HEALTH_DESC_PARAM_LIFE_TIME_EST_A = 0x3, 2998c2ecf20Sopenharmony_ci HEALTH_DESC_PARAM_LIFE_TIME_EST_B = 0x4, 3008c2ecf20Sopenharmony_ci}; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci/* WriteBooster buffer mode */ 3038c2ecf20Sopenharmony_cienum { 3048c2ecf20Sopenharmony_ci WB_BUF_MODE_LU_DEDICATED = 0x0, 3058c2ecf20Sopenharmony_ci WB_BUF_MODE_SHARED = 0x1, 3068c2ecf20Sopenharmony_ci}; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci/* 3098c2ecf20Sopenharmony_ci * Logical Unit Write Protect 3108c2ecf20Sopenharmony_ci * 00h: LU not write protected 3118c2ecf20Sopenharmony_ci * 01h: LU write protected when fPowerOnWPEn =1 3128c2ecf20Sopenharmony_ci * 02h: LU permanently write protected when fPermanentWPEn =1 3138c2ecf20Sopenharmony_ci */ 3148c2ecf20Sopenharmony_cienum ufs_lu_wp_type { 3158c2ecf20Sopenharmony_ci UFS_LU_NO_WP = 0x00, 3168c2ecf20Sopenharmony_ci UFS_LU_POWER_ON_WP = 0x01, 3178c2ecf20Sopenharmony_ci UFS_LU_PERM_WP = 0x02, 3188c2ecf20Sopenharmony_ci}; 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci/* bActiveICCLevel parameter current units */ 3218c2ecf20Sopenharmony_cienum { 3228c2ecf20Sopenharmony_ci UFSHCD_NANO_AMP = 0, 3238c2ecf20Sopenharmony_ci UFSHCD_MICRO_AMP = 1, 3248c2ecf20Sopenharmony_ci UFSHCD_MILI_AMP = 2, 3258c2ecf20Sopenharmony_ci UFSHCD_AMP = 3, 3268c2ecf20Sopenharmony_ci}; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci/* Possible values for dExtendedUFSFeaturesSupport */ 3298c2ecf20Sopenharmony_cienum { 3308c2ecf20Sopenharmony_ci UFS_DEV_WRITE_BOOSTER_SUP = BIT(8), 3318c2ecf20Sopenharmony_ci}; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci#define POWER_DESC_MAX_SIZE 0x62 3348c2ecf20Sopenharmony_ci#define POWER_DESC_MAX_ACTV_ICC_LVLS 16 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci/* Attribute bActiveICCLevel parameter bit masks definitions */ 3378c2ecf20Sopenharmony_ci#define ATTR_ICC_LVL_UNIT_OFFSET 14 3388c2ecf20Sopenharmony_ci#define ATTR_ICC_LVL_UNIT_MASK (0x3 << ATTR_ICC_LVL_UNIT_OFFSET) 3398c2ecf20Sopenharmony_ci#define ATTR_ICC_LVL_VALUE_MASK 0x3FF 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci/* Power descriptor parameters offsets in bytes */ 3428c2ecf20Sopenharmony_cienum power_desc_param_offset { 3438c2ecf20Sopenharmony_ci PWR_DESC_LEN = 0x0, 3448c2ecf20Sopenharmony_ci PWR_DESC_TYPE = 0x1, 3458c2ecf20Sopenharmony_ci PWR_DESC_ACTIVE_LVLS_VCC_0 = 0x2, 3468c2ecf20Sopenharmony_ci PWR_DESC_ACTIVE_LVLS_VCCQ_0 = 0x22, 3478c2ecf20Sopenharmony_ci PWR_DESC_ACTIVE_LVLS_VCCQ2_0 = 0x42, 3488c2ecf20Sopenharmony_ci}; 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci/* Exception event mask values */ 3518c2ecf20Sopenharmony_cienum { 3528c2ecf20Sopenharmony_ci MASK_EE_STATUS = 0xFFFF, 3538c2ecf20Sopenharmony_ci MASK_EE_URGENT_BKOPS = (1 << 2), 3548c2ecf20Sopenharmony_ci}; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci/* Background operation status */ 3578c2ecf20Sopenharmony_cienum bkops_status { 3588c2ecf20Sopenharmony_ci BKOPS_STATUS_NO_OP = 0x0, 3598c2ecf20Sopenharmony_ci BKOPS_STATUS_NON_CRITICAL = 0x1, 3608c2ecf20Sopenharmony_ci BKOPS_STATUS_PERF_IMPACT = 0x2, 3618c2ecf20Sopenharmony_ci BKOPS_STATUS_CRITICAL = 0x3, 3628c2ecf20Sopenharmony_ci BKOPS_STATUS_MAX = BKOPS_STATUS_CRITICAL, 3638c2ecf20Sopenharmony_ci}; 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci/* UTP QUERY Transaction Specific Fields OpCode */ 3668c2ecf20Sopenharmony_cienum query_opcode { 3678c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_NOP = 0x0, 3688c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_READ_DESC = 0x1, 3698c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_WRITE_DESC = 0x2, 3708c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_READ_ATTR = 0x3, 3718c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4, 3728c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_READ_FLAG = 0x5, 3738c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_SET_FLAG = 0x6, 3748c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7, 3758c2ecf20Sopenharmony_ci UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8, 3768c2ecf20Sopenharmony_ci}; 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ci/* bRefClkFreq attribute values */ 3798c2ecf20Sopenharmony_cienum ufs_ref_clk_freq { 3808c2ecf20Sopenharmony_ci REF_CLK_FREQ_19_2_MHZ = 0, 3818c2ecf20Sopenharmony_ci REF_CLK_FREQ_26_MHZ = 1, 3828c2ecf20Sopenharmony_ci REF_CLK_FREQ_38_4_MHZ = 2, 3838c2ecf20Sopenharmony_ci REF_CLK_FREQ_52_MHZ = 3, 3848c2ecf20Sopenharmony_ci REF_CLK_FREQ_INVAL = -1, 3858c2ecf20Sopenharmony_ci}; 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_cistruct ufs_ref_clk { 3888c2ecf20Sopenharmony_ci unsigned long freq_hz; 3898c2ecf20Sopenharmony_ci enum ufs_ref_clk_freq val; 3908c2ecf20Sopenharmony_ci}; 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci/* Query response result code */ 3938c2ecf20Sopenharmony_cienum { 3948c2ecf20Sopenharmony_ci QUERY_RESULT_SUCCESS = 0x00, 3958c2ecf20Sopenharmony_ci QUERY_RESULT_NOT_READABLE = 0xF6, 3968c2ecf20Sopenharmony_ci QUERY_RESULT_NOT_WRITEABLE = 0xF7, 3978c2ecf20Sopenharmony_ci QUERY_RESULT_ALREADY_WRITTEN = 0xF8, 3988c2ecf20Sopenharmony_ci QUERY_RESULT_INVALID_LENGTH = 0xF9, 3998c2ecf20Sopenharmony_ci QUERY_RESULT_INVALID_VALUE = 0xFA, 4008c2ecf20Sopenharmony_ci QUERY_RESULT_INVALID_SELECTOR = 0xFB, 4018c2ecf20Sopenharmony_ci QUERY_RESULT_INVALID_INDEX = 0xFC, 4028c2ecf20Sopenharmony_ci QUERY_RESULT_INVALID_IDN = 0xFD, 4038c2ecf20Sopenharmony_ci QUERY_RESULT_INVALID_OPCODE = 0xFE, 4048c2ecf20Sopenharmony_ci QUERY_RESULT_GENERAL_FAILURE = 0xFF, 4058c2ecf20Sopenharmony_ci}; 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci/* UTP Transfer Request Command Type (CT) */ 4088c2ecf20Sopenharmony_cienum { 4098c2ecf20Sopenharmony_ci UPIU_COMMAND_SET_TYPE_SCSI = 0x0, 4108c2ecf20Sopenharmony_ci UPIU_COMMAND_SET_TYPE_UFS = 0x1, 4118c2ecf20Sopenharmony_ci UPIU_COMMAND_SET_TYPE_QUERY = 0x2, 4128c2ecf20Sopenharmony_ci}; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci/* UTP Transfer Request Command Offset */ 4158c2ecf20Sopenharmony_ci#define UPIU_COMMAND_TYPE_OFFSET 28 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci/* Offset of the response code in the UPIU header */ 4188c2ecf20Sopenharmony_ci#define UPIU_RSP_CODE_OFFSET 8 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_cienum { 4218c2ecf20Sopenharmony_ci MASK_SCSI_STATUS = 0xFF, 4228c2ecf20Sopenharmony_ci MASK_TASK_RESPONSE = 0xFF00, 4238c2ecf20Sopenharmony_ci MASK_RSP_UPIU_RESULT = 0xFFFF, 4248c2ecf20Sopenharmony_ci MASK_QUERY_DATA_SEG_LEN = 0xFFFF, 4258c2ecf20Sopenharmony_ci MASK_RSP_UPIU_DATA_SEG_LEN = 0xFFFF, 4268c2ecf20Sopenharmony_ci MASK_RSP_EXCEPTION_EVENT = 0x10000, 4278c2ecf20Sopenharmony_ci MASK_TM_SERVICE_RESP = 0xFF, 4288c2ecf20Sopenharmony_ci MASK_TM_FUNC = 0xFF, 4298c2ecf20Sopenharmony_ci}; 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci/* Task management service response */ 4328c2ecf20Sopenharmony_cienum { 4338c2ecf20Sopenharmony_ci UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00, 4348c2ecf20Sopenharmony_ci UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04, 4358c2ecf20Sopenharmony_ci UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08, 4368c2ecf20Sopenharmony_ci UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05, 4378c2ecf20Sopenharmony_ci UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09, 4388c2ecf20Sopenharmony_ci}; 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci/* UFS device power modes */ 4418c2ecf20Sopenharmony_cienum ufs_dev_pwr_mode { 4428c2ecf20Sopenharmony_ci UFS_ACTIVE_PWR_MODE = 1, 4438c2ecf20Sopenharmony_ci UFS_SLEEP_PWR_MODE = 2, 4448c2ecf20Sopenharmony_ci UFS_POWERDOWN_PWR_MODE = 3, 4458c2ecf20Sopenharmony_ci}; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci#define UFS_WB_BUF_REMAIN_PERCENT(val) ((val) / 10) 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci/** 4508c2ecf20Sopenharmony_ci * struct utp_cmd_rsp - Response UPIU structure 4518c2ecf20Sopenharmony_ci * @residual_transfer_count: Residual transfer count DW-3 4528c2ecf20Sopenharmony_ci * @reserved: Reserved double words DW-4 to DW-7 4538c2ecf20Sopenharmony_ci * @sense_data_len: Sense data length DW-8 U16 4548c2ecf20Sopenharmony_ci * @sense_data: Sense data field DW-8 to DW-12 4558c2ecf20Sopenharmony_ci */ 4568c2ecf20Sopenharmony_cistruct utp_cmd_rsp { 4578c2ecf20Sopenharmony_ci __be32 residual_transfer_count; 4588c2ecf20Sopenharmony_ci __be32 reserved[4]; 4598c2ecf20Sopenharmony_ci __be16 sense_data_len; 4608c2ecf20Sopenharmony_ci u8 sense_data[UFS_SENSE_SIZE]; 4618c2ecf20Sopenharmony_ci}; 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci/** 4648c2ecf20Sopenharmony_ci * struct utp_upiu_rsp - general upiu response structure 4658c2ecf20Sopenharmony_ci * @header: UPIU header structure DW-0 to DW-2 4668c2ecf20Sopenharmony_ci * @sr: fields structure for scsi command DW-3 to DW-12 4678c2ecf20Sopenharmony_ci * @qr: fields structure for query request DW-3 to DW-7 4688c2ecf20Sopenharmony_ci */ 4698c2ecf20Sopenharmony_cistruct utp_upiu_rsp { 4708c2ecf20Sopenharmony_ci struct utp_upiu_header header; 4718c2ecf20Sopenharmony_ci union { 4728c2ecf20Sopenharmony_ci struct utp_cmd_rsp sr; 4738c2ecf20Sopenharmony_ci struct utp_upiu_query qr; 4748c2ecf20Sopenharmony_ci }; 4758c2ecf20Sopenharmony_ci}; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci/** 4788c2ecf20Sopenharmony_ci * struct ufs_query_req - parameters for building a query request 4798c2ecf20Sopenharmony_ci * @query_func: UPIU header query function 4808c2ecf20Sopenharmony_ci * @upiu_req: the query request data 4818c2ecf20Sopenharmony_ci */ 4828c2ecf20Sopenharmony_cistruct ufs_query_req { 4838c2ecf20Sopenharmony_ci u8 query_func; 4848c2ecf20Sopenharmony_ci struct utp_upiu_query upiu_req; 4858c2ecf20Sopenharmony_ci}; 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci/** 4888c2ecf20Sopenharmony_ci * struct ufs_query_resp - UPIU QUERY 4898c2ecf20Sopenharmony_ci * @response: device response code 4908c2ecf20Sopenharmony_ci * @upiu_res: query response data 4918c2ecf20Sopenharmony_ci */ 4928c2ecf20Sopenharmony_cistruct ufs_query_res { 4938c2ecf20Sopenharmony_ci u8 response; 4948c2ecf20Sopenharmony_ci struct utp_upiu_query upiu_res; 4958c2ecf20Sopenharmony_ci}; 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci#define UFS_VREG_VCC_MIN_UV 2700000 /* uV */ 4988c2ecf20Sopenharmony_ci#define UFS_VREG_VCC_MAX_UV 3600000 /* uV */ 4998c2ecf20Sopenharmony_ci#define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */ 5008c2ecf20Sopenharmony_ci#define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */ 5018c2ecf20Sopenharmony_ci#define UFS_VREG_VCCQ_MIN_UV 1140000 /* uV */ 5028c2ecf20Sopenharmony_ci#define UFS_VREG_VCCQ_MAX_UV 1260000 /* uV */ 5038c2ecf20Sopenharmony_ci#define UFS_VREG_VCCQ2_MIN_UV 1700000 /* uV */ 5048c2ecf20Sopenharmony_ci#define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */ 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci/* 5078c2ecf20Sopenharmony_ci * VCCQ & VCCQ2 current requirement when UFS device is in sleep state 5088c2ecf20Sopenharmony_ci * and link is in Hibern8 state. 5098c2ecf20Sopenharmony_ci */ 5108c2ecf20Sopenharmony_ci#define UFS_VREG_LPM_LOAD_UA 1000 /* uA */ 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_cistruct ufs_vreg { 5138c2ecf20Sopenharmony_ci struct regulator *reg; 5148c2ecf20Sopenharmony_ci const char *name; 5158c2ecf20Sopenharmony_ci bool enabled; 5168c2ecf20Sopenharmony_ci int min_uV; 5178c2ecf20Sopenharmony_ci int max_uV; 5188c2ecf20Sopenharmony_ci int max_uA; 5198c2ecf20Sopenharmony_ci}; 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_cistruct ufs_vreg_info { 5228c2ecf20Sopenharmony_ci struct ufs_vreg *vcc; 5238c2ecf20Sopenharmony_ci struct ufs_vreg *vccq; 5248c2ecf20Sopenharmony_ci struct ufs_vreg *vccq2; 5258c2ecf20Sopenharmony_ci struct ufs_vreg *vdd_hba; 5268c2ecf20Sopenharmony_ci}; 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_cistruct ufs_dev_info { 5298c2ecf20Sopenharmony_ci bool f_power_on_wp_en; 5308c2ecf20Sopenharmony_ci /* Keeps information if any of the LU is power on write protected */ 5318c2ecf20Sopenharmony_ci bool is_lu_power_on_wp; 5328c2ecf20Sopenharmony_ci /* Maximum number of general LU supported by the UFS device */ 5338c2ecf20Sopenharmony_ci u8 max_lu_supported; 5348c2ecf20Sopenharmony_ci u8 wb_dedicated_lu; 5358c2ecf20Sopenharmony_ci u16 wmanufacturerid; 5368c2ecf20Sopenharmony_ci /*UFS device Product Name */ 5378c2ecf20Sopenharmony_ci u8 *model; 5388c2ecf20Sopenharmony_ci u16 wspecversion; 5398c2ecf20Sopenharmony_ci u32 clk_gating_wait_us; 5408c2ecf20Sopenharmony_ci u32 d_ext_ufs_feature_sup; 5418c2ecf20Sopenharmony_ci u8 b_wb_buffer_type; 5428c2ecf20Sopenharmony_ci u32 d_wb_alloc_units; 5438c2ecf20Sopenharmony_ci bool b_rpm_dev_flush_capable; 5448c2ecf20Sopenharmony_ci u8 b_presrv_uspc_en; 5458c2ecf20Sopenharmony_ci}; 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci/** 5488c2ecf20Sopenharmony_ci * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor 5498c2ecf20Sopenharmony_ci * @dev_info: pointer of instance of struct ufs_dev_info 5508c2ecf20Sopenharmony_ci * @lun: LU number to check 5518c2ecf20Sopenharmony_ci * @return: true if the lun has a matching unit descriptor, false otherwise 5528c2ecf20Sopenharmony_ci */ 5538c2ecf20Sopenharmony_cistatic inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, 5548c2ecf20Sopenharmony_ci u8 lun, u8 param_offset) 5558c2ecf20Sopenharmony_ci{ 5568c2ecf20Sopenharmony_ci if (!dev_info || !dev_info->max_lu_supported) { 5578c2ecf20Sopenharmony_ci pr_err("Max General LU supported by UFS isn't initialized\n"); 5588c2ecf20Sopenharmony_ci return false; 5598c2ecf20Sopenharmony_ci } 5608c2ecf20Sopenharmony_ci /* WB is available only for the logical unit from 0 to 7 */ 5618c2ecf20Sopenharmony_ci if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS) 5628c2ecf20Sopenharmony_ci return lun < UFS_UPIU_MAX_WB_LUN_ID; 5638c2ecf20Sopenharmony_ci return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported); 5648c2ecf20Sopenharmony_ci} 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci#endif /* End of Header */ 567