diff options
Diffstat (limited to 'drivers/scsi/ufs/ufs.h')
-rw-r--r-- | drivers/scsi/ufs/ufs.h | 132 |
1 files changed, 129 insertions, 3 deletions
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index fafcf5e354c6..42c459a9d3fe 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h | |||
@@ -49,6 +49,27 @@ | |||
49 | #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ | 49 | #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ |
50 | cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ | 50 | cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ |
51 | (byte1 << 8) | (byte0)) | 51 | (byte1 << 8) | (byte0)) |
52 | /* | ||
53 | * UFS device may have standard LUs and LUN id could be from 0x00 to | ||
54 | * 0x7F. Standard LUs use "Peripheral Device Addressing Format". | ||
55 | * UFS device may also have the Well Known LUs (also referred as W-LU) | ||
56 | * which again could be from 0x00 to 0x7F. For W-LUs, device only use | ||
57 | * the "Extended Addressing Format" which means the W-LUNs would be | ||
58 | * from 0xc100 (SCSI_W_LUN_BASE) onwards. | ||
59 | * This means max. LUN number reported from UFS device could be 0xC17F. | ||
60 | */ | ||
61 | #define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F | ||
62 | #define UFS_MAX_LUNS (SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID) | ||
63 | #define UFS_UPIU_WLUN_ID (1 << 7) | ||
64 | #define UFS_UPIU_MAX_GENERAL_LUN 8 | ||
65 | |||
66 | /* Well known logical unit id in LUN field of UPIU */ | ||
67 | enum { | ||
68 | UFS_UPIU_REPORT_LUNS_WLUN = 0x81, | ||
69 | UFS_UPIU_UFS_DEVICE_WLUN = 0xD0, | ||
70 | UFS_UPIU_BOOT_WLUN = 0xB0, | ||
71 | UFS_UPIU_RPMB_WLUN = 0xC4, | ||
72 | }; | ||
52 | 73 | ||
53 | /* | 74 | /* |
54 | * UFS Protocol Information Unit related definitions | 75 | * UFS Protocol Information Unit related definitions |
@@ -108,11 +129,13 @@ enum { | |||
108 | /* Flag idn for Query Requests*/ | 129 | /* Flag idn for Query Requests*/ |
109 | enum flag_idn { | 130 | enum flag_idn { |
110 | QUERY_FLAG_IDN_FDEVICEINIT = 0x01, | 131 | QUERY_FLAG_IDN_FDEVICEINIT = 0x01, |
132 | QUERY_FLAG_IDN_PWR_ON_WPE = 0x03, | ||
111 | QUERY_FLAG_IDN_BKOPS_EN = 0x04, | 133 | QUERY_FLAG_IDN_BKOPS_EN = 0x04, |
112 | }; | 134 | }; |
113 | 135 | ||
114 | /* Attribute idn for Query requests */ | 136 | /* Attribute idn for Query requests */ |
115 | enum attr_idn { | 137 | enum attr_idn { |
138 | QUERY_ATTR_IDN_ACTIVE_ICC_LVL = 0x03, | ||
116 | QUERY_ATTR_IDN_BKOPS_STATUS = 0x05, | 139 | QUERY_ATTR_IDN_BKOPS_STATUS = 0x05, |
117 | QUERY_ATTR_IDN_EE_CONTROL = 0x0D, | 140 | QUERY_ATTR_IDN_EE_CONTROL = 0x0D, |
118 | QUERY_ATTR_IDN_EE_STATUS = 0x0E, | 141 | QUERY_ATTR_IDN_EE_STATUS = 0x0E, |
@@ -129,10 +152,29 @@ enum desc_idn { | |||
129 | QUERY_DESC_IDN_RFU_1 = 0x6, | 152 | QUERY_DESC_IDN_RFU_1 = 0x6, |
130 | QUERY_DESC_IDN_GEOMETRY = 0x7, | 153 | QUERY_DESC_IDN_GEOMETRY = 0x7, |
131 | QUERY_DESC_IDN_POWER = 0x8, | 154 | QUERY_DESC_IDN_POWER = 0x8, |
132 | QUERY_DESC_IDN_RFU_2 = 0x9, | 155 | QUERY_DESC_IDN_MAX, |
156 | }; | ||
157 | |||
158 | enum desc_header_offset { | ||
159 | QUERY_DESC_LENGTH_OFFSET = 0x00, | ||
160 | QUERY_DESC_DESC_TYPE_OFFSET = 0x01, | ||
161 | }; | ||
162 | |||
163 | enum ufs_desc_max_size { | ||
164 | QUERY_DESC_DEVICE_MAX_SIZE = 0x1F, | ||
165 | QUERY_DESC_CONFIGURAION_MAX_SIZE = 0x90, | ||
166 | QUERY_DESC_UNIT_MAX_SIZE = 0x23, | ||
167 | QUERY_DESC_INTERCONNECT_MAX_SIZE = 0x06, | ||
168 | /* | ||
169 | * Max. 126 UNICODE characters (2 bytes per character) plus 2 bytes | ||
170 | * of descriptor header. | ||
171 | */ | ||
172 | QUERY_DESC_STRING_MAX_SIZE = 0xFE, | ||
173 | QUERY_DESC_GEOMETRY_MAZ_SIZE = 0x44, | ||
174 | QUERY_DESC_POWER_MAX_SIZE = 0x62, | ||
175 | QUERY_DESC_RFU_MAX_SIZE = 0x00, | ||
133 | }; | 176 | }; |
134 | 177 | ||
135 | #define UNIT_DESC_MAX_SIZE 0x22 | ||
136 | /* Unit descriptor parameters offsets in bytes*/ | 178 | /* Unit descriptor parameters offsets in bytes*/ |
137 | enum unit_desc_param { | 179 | enum unit_desc_param { |
138 | UNIT_DESC_PARAM_LEN = 0x0, | 180 | UNIT_DESC_PARAM_LEN = 0x0, |
@@ -153,6 +195,43 @@ enum unit_desc_param { | |||
153 | UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 = 0x22, | 195 | UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 = 0x22, |
154 | }; | 196 | }; |
155 | 197 | ||
198 | /* | ||
199 | * Logical Unit Write Protect | ||
200 | * 00h: LU not write protected | ||
201 | * 01h: LU write protected when fPowerOnWPEn =1 | ||
202 | * 02h: LU permanently write protected when fPermanentWPEn =1 | ||
203 | */ | ||
204 | enum ufs_lu_wp_type { | ||
205 | UFS_LU_NO_WP = 0x00, | ||
206 | UFS_LU_POWER_ON_WP = 0x01, | ||
207 | UFS_LU_PERM_WP = 0x02, | ||
208 | }; | ||
209 | |||
210 | /* bActiveICCLevel parameter current units */ | ||
211 | enum { | ||
212 | UFSHCD_NANO_AMP = 0, | ||
213 | UFSHCD_MICRO_AMP = 1, | ||
214 | UFSHCD_MILI_AMP = 2, | ||
215 | UFSHCD_AMP = 3, | ||
216 | }; | ||
217 | |||
218 | #define POWER_DESC_MAX_SIZE 0x62 | ||
219 | #define POWER_DESC_MAX_ACTV_ICC_LVLS 16 | ||
220 | |||
221 | /* Attribute bActiveICCLevel parameter bit masks definitions */ | ||
222 | #define ATTR_ICC_LVL_UNIT_OFFSET 14 | ||
223 | #define ATTR_ICC_LVL_UNIT_MASK (0x3 << ATTR_ICC_LVL_UNIT_OFFSET) | ||
224 | #define ATTR_ICC_LVL_VALUE_MASK 0x3FF | ||
225 | |||
226 | /* Power descriptor parameters offsets in bytes */ | ||
227 | enum power_desc_param_offset { | ||
228 | PWR_DESC_LEN = 0x0, | ||
229 | PWR_DESC_TYPE = 0x1, | ||
230 | PWR_DESC_ACTIVE_LVLS_VCC_0 = 0x2, | ||
231 | PWR_DESC_ACTIVE_LVLS_VCCQ_0 = 0x22, | ||
232 | PWR_DESC_ACTIVE_LVLS_VCCQ2_0 = 0x42, | ||
233 | }; | ||
234 | |||
156 | /* Exception event mask values */ | 235 | /* Exception event mask values */ |
157 | enum { | 236 | enum { |
158 | MASK_EE_STATUS = 0xFFFF, | 237 | MASK_EE_STATUS = 0xFFFF, |
@@ -160,11 +239,12 @@ enum { | |||
160 | }; | 239 | }; |
161 | 240 | ||
162 | /* Background operation status */ | 241 | /* Background operation status */ |
163 | enum { | 242 | enum bkops_status { |
164 | BKOPS_STATUS_NO_OP = 0x0, | 243 | BKOPS_STATUS_NO_OP = 0x0, |
165 | BKOPS_STATUS_NON_CRITICAL = 0x1, | 244 | BKOPS_STATUS_NON_CRITICAL = 0x1, |
166 | BKOPS_STATUS_PERF_IMPACT = 0x2, | 245 | BKOPS_STATUS_PERF_IMPACT = 0x2, |
167 | BKOPS_STATUS_CRITICAL = 0x3, | 246 | BKOPS_STATUS_CRITICAL = 0x3, |
247 | BKOPS_STATUS_MAX = BKOPS_STATUS_CRITICAL, | ||
168 | }; | 248 | }; |
169 | 249 | ||
170 | /* UTP QUERY Transaction Specific Fields OpCode */ | 250 | /* UTP QUERY Transaction Specific Fields OpCode */ |
@@ -225,6 +305,14 @@ enum { | |||
225 | UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05, | 305 | UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05, |
226 | UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09, | 306 | UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09, |
227 | }; | 307 | }; |
308 | |||
309 | /* UFS device power modes */ | ||
310 | enum ufs_dev_pwr_mode { | ||
311 | UFS_ACTIVE_PWR_MODE = 1, | ||
312 | UFS_SLEEP_PWR_MODE = 2, | ||
313 | UFS_POWERDOWN_PWR_MODE = 3, | ||
314 | }; | ||
315 | |||
228 | /** | 316 | /** |
229 | * struct utp_upiu_header - UPIU header structure | 317 | * struct utp_upiu_header - UPIU header structure |
230 | * @dword_0: UPIU header DW-0 | 318 | * @dword_0: UPIU header DW-0 |
@@ -362,4 +450,42 @@ struct ufs_query_res { | |||
362 | struct utp_upiu_query upiu_res; | 450 | struct utp_upiu_query upiu_res; |
363 | }; | 451 | }; |
364 | 452 | ||
453 | #define UFS_VREG_VCC_MIN_UV 2700000 /* uV */ | ||
454 | #define UFS_VREG_VCC_MAX_UV 3600000 /* uV */ | ||
455 | #define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */ | ||
456 | #define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */ | ||
457 | #define UFS_VREG_VCCQ_MIN_UV 1100000 /* uV */ | ||
458 | #define UFS_VREG_VCCQ_MAX_UV 1300000 /* uV */ | ||
459 | #define UFS_VREG_VCCQ2_MIN_UV 1650000 /* uV */ | ||
460 | #define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */ | ||
461 | |||
462 | /* | ||
463 | * VCCQ & VCCQ2 current requirement when UFS device is in sleep state | ||
464 | * and link is in Hibern8 state. | ||
465 | */ | ||
466 | #define UFS_VREG_LPM_LOAD_UA 1000 /* uA */ | ||
467 | |||
468 | struct ufs_vreg { | ||
469 | struct regulator *reg; | ||
470 | const char *name; | ||
471 | bool enabled; | ||
472 | int min_uV; | ||
473 | int max_uV; | ||
474 | int min_uA; | ||
475 | int max_uA; | ||
476 | }; | ||
477 | |||
478 | struct ufs_vreg_info { | ||
479 | struct ufs_vreg *vcc; | ||
480 | struct ufs_vreg *vccq; | ||
481 | struct ufs_vreg *vccq2; | ||
482 | struct ufs_vreg *vdd_hba; | ||
483 | }; | ||
484 | |||
485 | struct ufs_dev_info { | ||
486 | bool f_power_on_wp_en; | ||
487 | /* Keeps information if any of the LU is power on write protected */ | ||
488 | bool is_lu_power_on_wp; | ||
489 | }; | ||
490 | |||
365 | #endif /* End of Header */ | 491 | #endif /* End of Header */ |