Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 1 | /* |
Wing Li | b7e9308 | 2021-12-23 11:32:08 -0800 | [diff] [blame] | 2 | * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved. |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 7 | #include <assert.h> |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 8 | #include <endian.h> |
| 9 | #include <errno.h> |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 10 | #include <stdint.h> |
| 11 | #include <string.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | |
| 13 | #include <platform_def.h> |
| 14 | |
| 15 | #include <arch_helpers.h> |
| 16 | #include <common/debug.h> |
| 17 | #include <drivers/delay_timer.h> |
| 18 | #include <drivers/ufs.h> |
| 19 | #include <lib/mmio.h> |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 20 | |
| 21 | #define CDB_ADDR_MASK 127 |
| 22 | #define ALIGN_CDB(x) (((x) + CDB_ADDR_MASK) & ~CDB_ADDR_MASK) |
| 23 | #define ALIGN_8(x) (((x) + 7) & ~7) |
| 24 | |
| 25 | #define UFS_DESC_SIZE 0x400 |
| 26 | #define MAX_UFS_DESC_SIZE 0x8000 /* 32 descriptors */ |
| 27 | |
| 28 | #define MAX_PRDT_SIZE 0x40000 /* 256KB */ |
| 29 | |
| 30 | static ufs_params_t ufs_params; |
| 31 | static int nutrs; /* Number of UTP Transfer Request Slots */ |
| 32 | |
| 33 | int ufshc_send_uic_cmd(uintptr_t base, uic_cmd_t *cmd) |
| 34 | { |
| 35 | unsigned int data; |
| 36 | |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 37 | if (base == 0 || cmd == NULL) |
| 38 | return -EINVAL; |
| 39 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 40 | data = mmio_read_32(base + HCS); |
| 41 | if ((data & HCS_UCRDY) == 0) |
| 42 | return -EBUSY; |
| 43 | mmio_write_32(base + IS, ~0); |
| 44 | mmio_write_32(base + UCMDARG1, cmd->arg1); |
| 45 | mmio_write_32(base + UCMDARG2, cmd->arg2); |
| 46 | mmio_write_32(base + UCMDARG3, cmd->arg3); |
| 47 | mmio_write_32(base + UICCMD, cmd->op); |
| 48 | |
| 49 | do { |
| 50 | data = mmio_read_32(base + IS); |
| 51 | } while ((data & UFS_INT_UCCS) == 0); |
| 52 | mmio_write_32(base + IS, UFS_INT_UCCS); |
Haojian Zhuang | 836eadc | 2017-06-12 22:18:15 +0800 | [diff] [blame] | 53 | return mmio_read_32(base + UCMDARG2) & CONFIG_RESULT_CODE_MASK; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | int ufshc_dme_get(unsigned int attr, unsigned int idx, unsigned int *val) |
| 57 | { |
| 58 | uintptr_t base; |
| 59 | unsigned int data; |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 60 | int result, retries; |
| 61 | uic_cmd_t cmd; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 62 | |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 63 | assert(ufs_params.reg_base != 0); |
| 64 | |
| 65 | if (val == NULL) |
| 66 | return -EINVAL; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 67 | |
| 68 | base = ufs_params.reg_base; |
| 69 | for (retries = 0; retries < 100; retries++) { |
| 70 | data = mmio_read_32(base + HCS); |
| 71 | if ((data & HCS_UCRDY) != 0) |
| 72 | break; |
| 73 | mdelay(1); |
| 74 | } |
| 75 | if (retries >= 100) |
| 76 | return -EBUSY; |
| 77 | |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 78 | cmd.arg1 = (attr << 16) | GEN_SELECTOR_IDX(idx); |
| 79 | cmd.arg2 = 0; |
| 80 | cmd.arg3 = 0; |
| 81 | cmd.op = DME_GET; |
| 82 | for (retries = 0; retries < UFS_UIC_COMMAND_RETRIES; ++retries) { |
| 83 | result = ufshc_send_uic_cmd(base, &cmd); |
| 84 | if (result == 0) |
| 85 | break; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 86 | data = mmio_read_32(base + IS); |
| 87 | if (data & UFS_INT_UE) |
| 88 | return -EINVAL; |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 89 | } |
| 90 | if (retries >= UFS_UIC_COMMAND_RETRIES) |
| 91 | return -EIO; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 92 | |
| 93 | *val = mmio_read_32(base + UCMDARG3); |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | int ufshc_dme_set(unsigned int attr, unsigned int idx, unsigned int val) |
| 98 | { |
| 99 | uintptr_t base; |
| 100 | unsigned int data; |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 101 | int result, retries; |
| 102 | uic_cmd_t cmd; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 103 | |
| 104 | assert((ufs_params.reg_base != 0)); |
| 105 | |
| 106 | base = ufs_params.reg_base; |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 107 | cmd.arg1 = (attr << 16) | GEN_SELECTOR_IDX(idx); |
| 108 | cmd.arg2 = 0; |
| 109 | cmd.arg3 = val; |
| 110 | cmd.op = DME_SET; |
| 111 | |
| 112 | for (retries = 0; retries < UFS_UIC_COMMAND_RETRIES; ++retries) { |
| 113 | result = ufshc_send_uic_cmd(base, &cmd); |
| 114 | if (result == 0) |
| 115 | break; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 116 | data = mmio_read_32(base + IS); |
| 117 | if (data & UFS_INT_UE) |
| 118 | return -EINVAL; |
Jorge Troncoso | 453e5e7 | 2021-09-23 17:14:29 -0700 | [diff] [blame] | 119 | } |
| 120 | if (retries >= UFS_UIC_COMMAND_RETRIES) |
| 121 | return -EIO; |
| 122 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 123 | return 0; |
| 124 | } |
| 125 | |
Jorge Troncoso | 5f44916 | 2021-09-30 16:29:32 -0700 | [diff] [blame] | 126 | static int ufshc_hce_enable(uintptr_t base) |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 127 | { |
| 128 | unsigned int data; |
Jorge Troncoso | 5f44916 | 2021-09-30 16:29:32 -0700 | [diff] [blame] | 129 | int retries; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 130 | |
| 131 | /* Enable Host Controller */ |
| 132 | mmio_write_32(base + HCE, HCE_ENABLE); |
Jorge Troncoso | 5f44916 | 2021-09-30 16:29:32 -0700 | [diff] [blame] | 133 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 134 | /* Wait until basic initialization sequence completed */ |
Jorge Troncoso | 5f44916 | 2021-09-30 16:29:32 -0700 | [diff] [blame] | 135 | for (retries = 0; retries < HCE_ENABLE_INNER_RETRIES; ++retries) { |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 136 | data = mmio_read_32(base + HCE); |
Jorge Troncoso | 5f44916 | 2021-09-30 16:29:32 -0700 | [diff] [blame] | 137 | if (data & HCE_ENABLE) { |
| 138 | break; |
| 139 | } |
| 140 | udelay(HCE_ENABLE_TIMEOUT_US); |
| 141 | } |
| 142 | if (retries >= HCE_ENABLE_INNER_RETRIES) { |
| 143 | return -ETIMEDOUT; |
| 144 | } |
| 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | static int ufshc_reset(uintptr_t base) |
| 150 | { |
| 151 | unsigned int data; |
| 152 | int retries, result; |
| 153 | |
| 154 | for (retries = 0; retries < HCE_ENABLE_OUTER_RETRIES; ++retries) { |
| 155 | result = ufshc_hce_enable(base); |
| 156 | if (result == 0) { |
| 157 | break; |
| 158 | } |
| 159 | } |
| 160 | if (retries >= HCE_ENABLE_OUTER_RETRIES) { |
| 161 | return -EIO; |
| 162 | } |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 163 | |
| 164 | /* Enable Interrupts */ |
| 165 | data = UFS_INT_UCCS | UFS_INT_ULSS | UFS_INT_UE | UFS_INT_UTPES | |
| 166 | UFS_INT_DFES | UFS_INT_HCFES | UFS_INT_SBFES; |
| 167 | mmio_write_32(base + IE, data); |
Jorge Troncoso | 5f44916 | 2021-09-30 16:29:32 -0700 | [diff] [blame] | 168 | |
| 169 | return 0; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 170 | } |
| 171 | |
Jorge Troncoso | 63d7c16 | 2021-10-05 22:46:35 -0700 | [diff] [blame] | 172 | static int ufshc_dme_link_startup(uintptr_t base) |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 173 | { |
| 174 | uic_cmd_t cmd; |
Jorge Troncoso | 63d7c16 | 2021-10-05 22:46:35 -0700 | [diff] [blame] | 175 | |
| 176 | memset(&cmd, 0, sizeof(cmd)); |
| 177 | cmd.op = DME_LINKSTARTUP; |
| 178 | return ufshc_send_uic_cmd(base, &cmd); |
| 179 | } |
| 180 | |
| 181 | static int ufshc_link_startup(uintptr_t base) |
| 182 | { |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 183 | int data, result; |
| 184 | int retries; |
| 185 | |
Jorge Troncoso | 63d7c16 | 2021-10-05 22:46:35 -0700 | [diff] [blame] | 186 | for (retries = DME_LINKSTARTUP_RETRIES; retries > 0; retries--) { |
| 187 | result = ufshc_dme_link_startup(base); |
| 188 | if (result != 0) { |
| 189 | /* Reset controller before trying again */ |
| 190 | result = ufshc_reset(base); |
| 191 | if (result != 0) { |
| 192 | return result; |
| 193 | } |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 194 | continue; |
Jorge Troncoso | 63d7c16 | 2021-10-05 22:46:35 -0700 | [diff] [blame] | 195 | } |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 196 | while ((mmio_read_32(base + HCS) & HCS_DP) == 0) |
| 197 | ; |
| 198 | data = mmio_read_32(base + IS); |
| 199 | if (data & UFS_INT_ULSS) |
| 200 | mmio_write_32(base + IS, UFS_INT_ULSS); |
| 201 | return 0; |
| 202 | } |
| 203 | return -EIO; |
| 204 | } |
| 205 | |
| 206 | /* Check Door Bell register to get an empty slot */ |
| 207 | static int get_empty_slot(int *slot) |
| 208 | { |
| 209 | unsigned int data; |
| 210 | int i; |
| 211 | |
| 212 | data = mmio_read_32(ufs_params.reg_base + UTRLDBR); |
| 213 | for (i = 0; i < nutrs; i++) { |
| 214 | if ((data & 1) == 0) |
| 215 | break; |
| 216 | data = data >> 1; |
| 217 | } |
| 218 | if (i >= nutrs) |
| 219 | return -EBUSY; |
| 220 | *slot = i; |
| 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | static void get_utrd(utp_utrd_t *utrd) |
| 225 | { |
| 226 | uintptr_t base; |
| 227 | int slot = 0, result; |
| 228 | utrd_header_t *hd; |
| 229 | |
| 230 | assert(utrd != NULL); |
| 231 | result = get_empty_slot(&slot); |
| 232 | assert(result == 0); |
| 233 | |
| 234 | /* clear utrd */ |
| 235 | memset((void *)utrd, 0, sizeof(utp_utrd_t)); |
| 236 | base = ufs_params.desc_base + (slot * UFS_DESC_SIZE); |
| 237 | /* clear the descriptor */ |
| 238 | memset((void *)base, 0, UFS_DESC_SIZE); |
| 239 | |
| 240 | utrd->header = base; |
| 241 | utrd->task_tag = slot + 1; |
| 242 | /* CDB address should be aligned with 128 bytes */ |
| 243 | utrd->upiu = ALIGN_CDB(utrd->header + sizeof(utrd_header_t)); |
| 244 | utrd->resp_upiu = ALIGN_8(utrd->upiu + sizeof(cmd_upiu_t)); |
| 245 | utrd->size_upiu = utrd->resp_upiu - utrd->upiu; |
| 246 | utrd->size_resp_upiu = ALIGN_8(sizeof(resp_upiu_t)); |
| 247 | utrd->prdt = utrd->resp_upiu + utrd->size_resp_upiu; |
| 248 | |
| 249 | hd = (utrd_header_t *)utrd->header; |
| 250 | hd->ucdba = utrd->upiu & UINT32_MAX; |
| 251 | hd->ucdbau = (utrd->upiu >> 32) & UINT32_MAX; |
| 252 | /* Both RUL and RUO is based on DWORD */ |
| 253 | hd->rul = utrd->size_resp_upiu >> 2; |
| 254 | hd->ruo = utrd->size_upiu >> 2; |
| 255 | (void)result; |
| 256 | } |
| 257 | |
| 258 | /* |
| 259 | * Prepare UTRD, Command UPIU, Response UPIU. |
| 260 | */ |
| 261 | static int ufs_prepare_cmd(utp_utrd_t *utrd, uint8_t op, uint8_t lun, |
| 262 | int lba, uintptr_t buf, size_t length) |
| 263 | { |
| 264 | utrd_header_t *hd; |
| 265 | cmd_upiu_t *upiu; |
| 266 | prdt_t *prdt; |
| 267 | unsigned int ulba; |
| 268 | unsigned int lba_cnt; |
| 269 | int prdt_size; |
| 270 | |
| 271 | |
| 272 | mmio_write_32(ufs_params.reg_base + UTRLBA, |
| 273 | utrd->header & UINT32_MAX); |
| 274 | mmio_write_32(ufs_params.reg_base + UTRLBAU, |
| 275 | (utrd->upiu >> 32) & UINT32_MAX); |
| 276 | |
| 277 | hd = (utrd_header_t *)utrd->header; |
| 278 | upiu = (cmd_upiu_t *)utrd->upiu; |
| 279 | |
| 280 | hd->i = 1; |
| 281 | hd->ct = CT_UFS_STORAGE; |
| 282 | hd->ocs = OCS_MASK; |
| 283 | |
| 284 | upiu->trans_type = CMD_UPIU; |
| 285 | upiu->task_tag = utrd->task_tag; |
| 286 | upiu->cdb[0] = op; |
| 287 | ulba = (unsigned int)lba; |
| 288 | lba_cnt = (unsigned int)(length >> UFS_BLOCK_SHIFT); |
| 289 | switch (op) { |
| 290 | case CDBCMD_TEST_UNIT_READY: |
| 291 | break; |
| 292 | case CDBCMD_READ_CAPACITY_10: |
| 293 | hd->dd = DD_OUT; |
| 294 | upiu->flags = UPIU_FLAGS_R | UPIU_FLAGS_ATTR_S; |
| 295 | upiu->lun = lun; |
| 296 | break; |
| 297 | case CDBCMD_READ_10: |
| 298 | hd->dd = DD_OUT; |
| 299 | upiu->flags = UPIU_FLAGS_R | UPIU_FLAGS_ATTR_S; |
| 300 | upiu->lun = lun; |
| 301 | upiu->cdb[1] = RW_WITHOUT_CACHE; |
| 302 | /* set logical block address */ |
| 303 | upiu->cdb[2] = (ulba >> 24) & 0xff; |
| 304 | upiu->cdb[3] = (ulba >> 16) & 0xff; |
| 305 | upiu->cdb[4] = (ulba >> 8) & 0xff; |
| 306 | upiu->cdb[5] = ulba & 0xff; |
| 307 | /* set transfer length */ |
| 308 | upiu->cdb[7] = (lba_cnt >> 8) & 0xff; |
| 309 | upiu->cdb[8] = lba_cnt & 0xff; |
| 310 | break; |
| 311 | case CDBCMD_WRITE_10: |
| 312 | hd->dd = DD_IN; |
| 313 | upiu->flags = UPIU_FLAGS_W | UPIU_FLAGS_ATTR_S; |
| 314 | upiu->lun = lun; |
| 315 | upiu->cdb[1] = RW_WITHOUT_CACHE; |
| 316 | /* set logical block address */ |
| 317 | upiu->cdb[2] = (ulba >> 24) & 0xff; |
| 318 | upiu->cdb[3] = (ulba >> 16) & 0xff; |
| 319 | upiu->cdb[4] = (ulba >> 8) & 0xff; |
| 320 | upiu->cdb[5] = ulba & 0xff; |
| 321 | /* set transfer length */ |
| 322 | upiu->cdb[7] = (lba_cnt >> 8) & 0xff; |
| 323 | upiu->cdb[8] = lba_cnt & 0xff; |
| 324 | break; |
| 325 | default: |
| 326 | assert(0); |
Jonathan Wright | 39b4221 | 2018-03-13 15:24:29 +0000 | [diff] [blame] | 327 | break; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 328 | } |
| 329 | if (hd->dd == DD_IN) |
| 330 | flush_dcache_range(buf, length); |
| 331 | else if (hd->dd == DD_OUT) |
| 332 | inv_dcache_range(buf, length); |
| 333 | if (length) { |
| 334 | upiu->exp_data_trans_len = htobe32(length); |
| 335 | assert(lba_cnt <= UINT16_MAX); |
| 336 | prdt = (prdt_t *)utrd->prdt; |
| 337 | |
| 338 | prdt_size = 0; |
| 339 | while (length > 0) { |
| 340 | prdt->dba = (unsigned int)(buf & UINT32_MAX); |
| 341 | prdt->dbau = (unsigned int)((buf >> 32) & UINT32_MAX); |
| 342 | /* prdt->dbc counts from 0 */ |
| 343 | if (length > MAX_PRDT_SIZE) { |
| 344 | prdt->dbc = MAX_PRDT_SIZE - 1; |
| 345 | length = length - MAX_PRDT_SIZE; |
| 346 | } else { |
| 347 | prdt->dbc = length - 1; |
| 348 | length = 0; |
| 349 | } |
| 350 | buf += MAX_PRDT_SIZE; |
| 351 | prdt++; |
| 352 | prdt_size += sizeof(prdt_t); |
| 353 | } |
| 354 | utrd->size_prdt = ALIGN_8(prdt_size); |
| 355 | hd->prdtl = utrd->size_prdt >> 2; |
| 356 | hd->prdto = (utrd->size_upiu + utrd->size_resp_upiu) >> 2; |
| 357 | } |
| 358 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 359 | flush_dcache_range((uintptr_t)utrd->header, UFS_DESC_SIZE); |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | static int ufs_prepare_query(utp_utrd_t *utrd, uint8_t op, uint8_t idn, |
| 364 | uint8_t index, uint8_t sel, |
| 365 | uintptr_t buf, size_t length) |
| 366 | { |
| 367 | utrd_header_t *hd; |
| 368 | query_upiu_t *query_upiu; |
| 369 | |
| 370 | |
| 371 | hd = (utrd_header_t *)utrd->header; |
| 372 | query_upiu = (query_upiu_t *)utrd->upiu; |
| 373 | |
| 374 | mmio_write_32(ufs_params.reg_base + UTRLBA, |
| 375 | utrd->header & UINT32_MAX); |
| 376 | mmio_write_32(ufs_params.reg_base + UTRLBAU, |
| 377 | (utrd->header >> 32) & UINT32_MAX); |
| 378 | |
| 379 | |
| 380 | hd->i = 1; |
| 381 | hd->ct = CT_UFS_STORAGE; |
| 382 | hd->ocs = OCS_MASK; |
| 383 | |
| 384 | query_upiu->trans_type = QUERY_REQUEST_UPIU; |
| 385 | query_upiu->task_tag = utrd->task_tag; |
| 386 | query_upiu->ts.desc.opcode = op; |
| 387 | query_upiu->ts.desc.idn = idn; |
| 388 | query_upiu->ts.desc.index = index; |
| 389 | query_upiu->ts.desc.selector = sel; |
| 390 | switch (op) { |
| 391 | case QUERY_READ_DESC: |
| 392 | query_upiu->query_func = QUERY_FUNC_STD_READ; |
| 393 | query_upiu->ts.desc.length = htobe16(length); |
| 394 | break; |
| 395 | case QUERY_WRITE_DESC: |
| 396 | query_upiu->query_func = QUERY_FUNC_STD_WRITE; |
| 397 | query_upiu->ts.desc.length = htobe16(length); |
| 398 | memcpy((void *)(utrd->upiu + sizeof(query_upiu_t)), |
| 399 | (void *)buf, length); |
| 400 | break; |
| 401 | case QUERY_READ_ATTR: |
| 402 | case QUERY_READ_FLAG: |
| 403 | query_upiu->query_func = QUERY_FUNC_STD_READ; |
| 404 | break; |
| 405 | case QUERY_CLEAR_FLAG: |
| 406 | case QUERY_SET_FLAG: |
| 407 | query_upiu->query_func = QUERY_FUNC_STD_WRITE; |
| 408 | break; |
| 409 | case QUERY_WRITE_ATTR: |
| 410 | query_upiu->query_func = QUERY_FUNC_STD_WRITE; |
| 411 | memcpy((void *)&query_upiu->ts.attr.value, (void *)buf, length); |
| 412 | break; |
| 413 | default: |
| 414 | assert(0); |
Jonathan Wright | 39b4221 | 2018-03-13 15:24:29 +0000 | [diff] [blame] | 415 | break; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 416 | } |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 417 | flush_dcache_range((uintptr_t)utrd->header, UFS_DESC_SIZE); |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | static void ufs_prepare_nop_out(utp_utrd_t *utrd) |
| 422 | { |
| 423 | utrd_header_t *hd; |
| 424 | nop_out_upiu_t *nop_out; |
| 425 | |
| 426 | mmio_write_32(ufs_params.reg_base + UTRLBA, |
| 427 | utrd->header & UINT32_MAX); |
| 428 | mmio_write_32(ufs_params.reg_base + UTRLBAU, |
| 429 | (utrd->header >> 32) & UINT32_MAX); |
| 430 | |
| 431 | hd = (utrd_header_t *)utrd->header; |
| 432 | nop_out = (nop_out_upiu_t *)utrd->upiu; |
| 433 | |
| 434 | hd->i = 1; |
| 435 | hd->ct = CT_UFS_STORAGE; |
| 436 | hd->ocs = OCS_MASK; |
| 437 | |
| 438 | nop_out->trans_type = 0; |
| 439 | nop_out->task_tag = utrd->task_tag; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 440 | flush_dcache_range((uintptr_t)utrd->header, UFS_DESC_SIZE); |
| 441 | } |
| 442 | |
| 443 | static void ufs_send_request(int task_tag) |
| 444 | { |
| 445 | unsigned int data; |
| 446 | int slot; |
| 447 | |
| 448 | slot = task_tag - 1; |
| 449 | /* clear all interrupts */ |
| 450 | mmio_write_32(ufs_params.reg_base + IS, ~0); |
| 451 | |
| 452 | mmio_write_32(ufs_params.reg_base + UTRLRSR, 1); |
| 453 | do { |
| 454 | data = mmio_read_32(ufs_params.reg_base + UTRLRSR); |
| 455 | } while (data == 0); |
| 456 | |
| 457 | data = UTRIACR_IAEN | UTRIACR_CTR | UTRIACR_IACTH(0x1F) | |
| 458 | UTRIACR_IATOVAL(0xFF); |
| 459 | mmio_write_32(ufs_params.reg_base + UTRIACR, data); |
| 460 | /* send request */ |
| 461 | mmio_setbits_32(ufs_params.reg_base + UTRLDBR, 1 << slot); |
| 462 | } |
| 463 | |
| 464 | static int ufs_check_resp(utp_utrd_t *utrd, int trans_type) |
| 465 | { |
| 466 | utrd_header_t *hd; |
| 467 | resp_upiu_t *resp; |
| 468 | unsigned int data; |
| 469 | int slot; |
| 470 | |
| 471 | hd = (utrd_header_t *)utrd->header; |
| 472 | resp = (resp_upiu_t *)utrd->resp_upiu; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 473 | do { |
| 474 | data = mmio_read_32(ufs_params.reg_base + IS); |
| 475 | if ((data & ~(UFS_INT_UCCS | UFS_INT_UTRCS)) != 0) |
| 476 | return -EIO; |
| 477 | } while ((data & UFS_INT_UTRCS) == 0); |
| 478 | slot = utrd->task_tag - 1; |
| 479 | |
| 480 | data = mmio_read_32(ufs_params.reg_base + UTRLDBR); |
| 481 | assert((data & (1 << slot)) == 0); |
Channagoud kadabi | e57e580 | 2022-03-14 18:56:03 -0700 | [diff] [blame] | 482 | /* |
| 483 | * Invalidate the header after DMA read operation has |
| 484 | * completed to avoid cpu referring to the prefetched |
| 485 | * data brought in before DMA completion. |
| 486 | */ |
| 487 | inv_dcache_range((uintptr_t)hd, UFS_DESC_SIZE); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 488 | assert(hd->ocs == OCS_SUCCESS); |
| 489 | assert((resp->trans_type & TRANS_TYPE_CODE_MASK) == trans_type); |
| 490 | (void)resp; |
| 491 | (void)slot; |
| 492 | return 0; |
| 493 | } |
| 494 | |
anans | 9cbd2b0 | 2022-03-11 20:07:39 +0530 | [diff] [blame] | 495 | static void ufs_send_cmd(utp_utrd_t *utrd, uint8_t cmd_op, uint8_t lun, int lba, uintptr_t buf, |
| 496 | size_t length) |
| 497 | { |
| 498 | int result; |
| 499 | |
| 500 | get_utrd(utrd); |
| 501 | |
| 502 | result = ufs_prepare_cmd(utrd, cmd_op, lun, lba, buf, length); |
| 503 | assert(result == 0); |
| 504 | ufs_send_request(utrd->task_tag); |
| 505 | result = ufs_check_resp(utrd, RESPONSE_UPIU); |
| 506 | assert(result == 0); |
| 507 | (void)result; |
| 508 | } |
| 509 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 510 | #ifdef UFS_RESP_DEBUG |
| 511 | static void dump_upiu(utp_utrd_t *utrd) |
| 512 | { |
| 513 | utrd_header_t *hd; |
| 514 | int i; |
| 515 | |
| 516 | hd = (utrd_header_t *)utrd->header; |
| 517 | INFO("utrd:0x%x, ruo:0x%x, rul:0x%x, ocs:0x%x, UTRLDBR:0x%x\n", |
| 518 | (unsigned int)(uintptr_t)utrd, hd->ruo, hd->rul, hd->ocs, |
| 519 | mmio_read_32(ufs_params.reg_base + UTRLDBR)); |
| 520 | for (i = 0; i < sizeof(utrd_header_t); i += 4) { |
| 521 | INFO("[%lx]:0x%x\n", |
| 522 | (uintptr_t)utrd->header + i, |
| 523 | *(unsigned int *)((uintptr_t)utrd->header + i)); |
| 524 | } |
| 525 | |
| 526 | for (i = 0; i < sizeof(cmd_upiu_t); i += 4) { |
| 527 | INFO("cmd[%lx]:0x%x\n", |
| 528 | utrd->upiu + i, |
| 529 | *(unsigned int *)(utrd->upiu + i)); |
| 530 | } |
| 531 | for (i = 0; i < sizeof(resp_upiu_t); i += 4) { |
| 532 | INFO("resp[%lx]:0x%x\n", |
| 533 | utrd->resp_upiu + i, |
| 534 | *(unsigned int *)(utrd->resp_upiu + i)); |
| 535 | } |
| 536 | for (i = 0; i < sizeof(prdt_t); i += 4) { |
| 537 | INFO("prdt[%lx]:0x%x\n", |
| 538 | utrd->prdt + i, |
| 539 | *(unsigned int *)(utrd->prdt + i)); |
| 540 | } |
| 541 | } |
| 542 | #endif |
| 543 | |
| 544 | static void ufs_verify_init(void) |
| 545 | { |
| 546 | utp_utrd_t utrd; |
| 547 | int result; |
| 548 | |
| 549 | get_utrd(&utrd); |
| 550 | ufs_prepare_nop_out(&utrd); |
| 551 | ufs_send_request(utrd.task_tag); |
| 552 | result = ufs_check_resp(&utrd, NOP_IN_UPIU); |
| 553 | assert(result == 0); |
| 554 | (void)result; |
| 555 | } |
| 556 | |
| 557 | static void ufs_verify_ready(void) |
| 558 | { |
| 559 | utp_utrd_t utrd; |
anans | 9cbd2b0 | 2022-03-11 20:07:39 +0530 | [diff] [blame] | 560 | ufs_send_cmd(&utrd, CDBCMD_TEST_UNIT_READY, 0, 0, 0, 0); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | static void ufs_query(uint8_t op, uint8_t idn, uint8_t index, uint8_t sel, |
| 564 | uintptr_t buf, size_t size) |
| 565 | { |
| 566 | utp_utrd_t utrd; |
| 567 | query_resp_upiu_t *resp; |
| 568 | int result; |
| 569 | |
| 570 | switch (op) { |
| 571 | case QUERY_READ_FLAG: |
| 572 | case QUERY_READ_ATTR: |
| 573 | case QUERY_READ_DESC: |
| 574 | case QUERY_WRITE_DESC: |
| 575 | case QUERY_WRITE_ATTR: |
| 576 | assert(((buf & 3) == 0) && (size != 0)); |
| 577 | break; |
Jonathan Wright | 39b4221 | 2018-03-13 15:24:29 +0000 | [diff] [blame] | 578 | default: |
| 579 | /* Do nothing in default case */ |
| 580 | break; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 581 | } |
| 582 | get_utrd(&utrd); |
| 583 | ufs_prepare_query(&utrd, op, idn, index, sel, buf, size); |
| 584 | ufs_send_request(utrd.task_tag); |
| 585 | result = ufs_check_resp(&utrd, QUERY_RESPONSE_UPIU); |
| 586 | assert(result == 0); |
| 587 | resp = (query_resp_upiu_t *)utrd.resp_upiu; |
| 588 | #ifdef UFS_RESP_DEBUG |
| 589 | dump_upiu(&utrd); |
| 590 | #endif |
| 591 | assert(resp->query_resp == QUERY_RESP_SUCCESS); |
| 592 | |
| 593 | switch (op) { |
| 594 | case QUERY_READ_FLAG: |
| 595 | *(uint32_t *)buf = (uint32_t)resp->ts.flag.value; |
| 596 | break; |
| 597 | case QUERY_READ_ATTR: |
| 598 | case QUERY_READ_DESC: |
| 599 | memcpy((void *)buf, |
| 600 | (void *)(utrd.resp_upiu + sizeof(query_resp_upiu_t)), |
| 601 | size); |
| 602 | break; |
Jonathan Wright | 39b4221 | 2018-03-13 15:24:29 +0000 | [diff] [blame] | 603 | default: |
| 604 | /* Do nothing in default case */ |
| 605 | break; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 606 | } |
| 607 | (void)result; |
| 608 | } |
| 609 | |
| 610 | unsigned int ufs_read_attr(int idn) |
| 611 | { |
| 612 | unsigned int value; |
| 613 | |
| 614 | ufs_query(QUERY_READ_ATTR, idn, 0, 0, |
| 615 | (uintptr_t)&value, sizeof(value)); |
| 616 | return value; |
| 617 | } |
| 618 | |
| 619 | void ufs_write_attr(int idn, unsigned int value) |
| 620 | { |
| 621 | ufs_query(QUERY_WRITE_ATTR, idn, 0, 0, |
| 622 | (uintptr_t)&value, sizeof(value)); |
| 623 | } |
| 624 | |
| 625 | unsigned int ufs_read_flag(int idn) |
| 626 | { |
| 627 | unsigned int value; |
| 628 | |
| 629 | ufs_query(QUERY_READ_FLAG, idn, 0, 0, |
| 630 | (uintptr_t)&value, sizeof(value)); |
| 631 | return value; |
| 632 | } |
| 633 | |
| 634 | void ufs_set_flag(int idn) |
| 635 | { |
| 636 | ufs_query(QUERY_SET_FLAG, idn, 0, 0, 0, 0); |
| 637 | } |
| 638 | |
| 639 | void ufs_clear_flag(int idn) |
| 640 | { |
| 641 | ufs_query(QUERY_CLEAR_FLAG, idn, 0, 0, 0, 0); |
| 642 | } |
| 643 | |
| 644 | void ufs_read_desc(int idn, int index, uintptr_t buf, size_t size) |
| 645 | { |
| 646 | ufs_query(QUERY_READ_DESC, idn, index, 0, buf, size); |
| 647 | } |
| 648 | |
| 649 | void ufs_write_desc(int idn, int index, uintptr_t buf, size_t size) |
| 650 | { |
| 651 | ufs_query(QUERY_WRITE_DESC, idn, index, 0, buf, size); |
| 652 | } |
| 653 | |
Florian La Roche | 231c244 | 2019-01-27 14:30:12 +0100 | [diff] [blame] | 654 | static void ufs_read_capacity(int lun, unsigned int *num, unsigned int *size) |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 655 | { |
| 656 | utp_utrd_t utrd; |
| 657 | resp_upiu_t *resp; |
| 658 | sense_data_t *sense; |
| 659 | unsigned char data[CACHE_WRITEBACK_GRANULE << 1]; |
| 660 | uintptr_t buf; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 661 | int retry; |
| 662 | |
| 663 | assert((ufs_params.reg_base != 0) && |
| 664 | (ufs_params.desc_base != 0) && |
| 665 | (ufs_params.desc_size >= UFS_DESC_SIZE) && |
| 666 | (num != NULL) && (size != NULL)); |
| 667 | |
| 668 | /* align buf address */ |
| 669 | buf = (uintptr_t)data; |
| 670 | buf = (buf + CACHE_WRITEBACK_GRANULE - 1) & |
| 671 | ~(CACHE_WRITEBACK_GRANULE - 1); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 672 | do { |
anans | 9cbd2b0 | 2022-03-11 20:07:39 +0530 | [diff] [blame] | 673 | ufs_send_cmd(&utrd, CDBCMD_READ_CAPACITY_10, lun, 0, |
| 674 | buf, READ_CAPACITY_LENGTH); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 675 | #ifdef UFS_RESP_DEBUG |
| 676 | dump_upiu(&utrd); |
| 677 | #endif |
| 678 | resp = (resp_upiu_t *)utrd.resp_upiu; |
| 679 | retry = 0; |
| 680 | sense = &resp->sd.sense; |
| 681 | if (sense->resp_code == SENSE_DATA_VALID) { |
| 682 | if ((sense->sense_key == SENSE_KEY_UNIT_ATTENTION) && |
| 683 | (sense->asc == 0x29) && (sense->ascq == 0)) { |
| 684 | retry = 1; |
| 685 | } |
| 686 | } |
| 687 | inv_dcache_range(buf, CACHE_WRITEBACK_GRANULE); |
| 688 | /* last logical block address */ |
| 689 | *num = be32toh(*(unsigned int *)buf); |
| 690 | if (*num) |
| 691 | *num += 1; |
| 692 | /* logical block length in bytes */ |
| 693 | *size = be32toh(*(unsigned int *)(buf + 4)); |
| 694 | } while (retry); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | size_t ufs_read_blocks(int lun, int lba, uintptr_t buf, size_t size) |
| 698 | { |
| 699 | utp_utrd_t utrd; |
| 700 | resp_upiu_t *resp; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 701 | |
| 702 | assert((ufs_params.reg_base != 0) && |
| 703 | (ufs_params.desc_base != 0) && |
| 704 | (ufs_params.desc_size >= UFS_DESC_SIZE)); |
| 705 | |
anans | 9cbd2b0 | 2022-03-11 20:07:39 +0530 | [diff] [blame] | 706 | ufs_send_cmd(&utrd, CDBCMD_READ_10, lun, lba, buf, size); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 707 | #ifdef UFS_RESP_DEBUG |
| 708 | dump_upiu(&utrd); |
| 709 | #endif |
Channagoud kadabi | e57e580 | 2022-03-14 18:56:03 -0700 | [diff] [blame] | 710 | /* |
| 711 | * Invalidate prefetched cache contents before cpu |
| 712 | * accesses the buf. |
| 713 | */ |
| 714 | inv_dcache_range(buf, size); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 715 | resp = (resp_upiu_t *)utrd.resp_upiu; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 716 | return size - resp->res_trans_cnt; |
| 717 | } |
| 718 | |
| 719 | size_t ufs_write_blocks(int lun, int lba, const uintptr_t buf, size_t size) |
| 720 | { |
| 721 | utp_utrd_t utrd; |
| 722 | resp_upiu_t *resp; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 723 | |
| 724 | assert((ufs_params.reg_base != 0) && |
| 725 | (ufs_params.desc_base != 0) && |
| 726 | (ufs_params.desc_size >= UFS_DESC_SIZE)); |
| 727 | |
anans | 9cbd2b0 | 2022-03-11 20:07:39 +0530 | [diff] [blame] | 728 | ufs_send_cmd(&utrd, CDBCMD_WRITE_10, lun, lba, buf, size); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 729 | #ifdef UFS_RESP_DEBUG |
| 730 | dump_upiu(&utrd); |
| 731 | #endif |
| 732 | resp = (resp_upiu_t *)utrd.resp_upiu; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 733 | return size - resp->res_trans_cnt; |
| 734 | } |
| 735 | |
| 736 | static void ufs_enum(void) |
| 737 | { |
| 738 | unsigned int blk_num, blk_size; |
| 739 | int i; |
| 740 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 741 | ufs_verify_init(); |
| 742 | ufs_verify_ready(); |
| 743 | |
| 744 | ufs_set_flag(FLAG_DEVICE_INIT); |
John Stultz | 938d1dc | 2019-05-13 16:56:19 -0700 | [diff] [blame] | 745 | mdelay(200); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 746 | /* dump available LUNs */ |
| 747 | for (i = 0; i < UFS_MAX_LUNS; i++) { |
| 748 | ufs_read_capacity(i, &blk_num, &blk_size); |
| 749 | if (blk_num && blk_size) { |
| 750 | INFO("UFS LUN%d contains %d blocks with %d-byte size\n", |
| 751 | i, blk_num, blk_size); |
| 752 | } |
| 753 | } |
| 754 | } |
| 755 | |
fengbaopeng | 44070ef | 2018-02-12 20:53:54 +0800 | [diff] [blame] | 756 | static void ufs_get_device_info(struct ufs_dev_desc *card_data) |
| 757 | { |
| 758 | uint8_t desc_buf[DESC_DEVICE_MAX_SIZE]; |
| 759 | |
| 760 | ufs_query(QUERY_READ_DESC, DESC_TYPE_DEVICE, 0, 0, |
| 761 | (uintptr_t)desc_buf, DESC_DEVICE_MAX_SIZE); |
| 762 | |
| 763 | /* |
| 764 | * getting vendor (manufacturerID) and Bank Index in big endian |
| 765 | * format |
| 766 | */ |
| 767 | card_data->wmanufacturerid = (uint16_t)((desc_buf[DEVICE_DESC_PARAM_MANF_ID] << 8) | |
| 768 | (desc_buf[DEVICE_DESC_PARAM_MANF_ID + 1])); |
| 769 | } |
| 770 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 771 | int ufs_init(const ufs_ops_t *ops, ufs_params_t *params) |
| 772 | { |
| 773 | int result; |
| 774 | unsigned int data; |
| 775 | uic_cmd_t cmd; |
fengbaopeng | 44070ef | 2018-02-12 20:53:54 +0800 | [diff] [blame] | 776 | struct ufs_dev_desc card = {0}; |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 777 | |
| 778 | assert((params != NULL) && |
| 779 | (params->reg_base != 0) && |
| 780 | (params->desc_base != 0) && |
| 781 | (params->desc_size >= UFS_DESC_SIZE)); |
| 782 | |
| 783 | memcpy(&ufs_params, params, sizeof(ufs_params_t)); |
| 784 | |
anans | 3696bd0 | 2022-03-15 13:37:37 +0530 | [diff] [blame] | 785 | /* 0 means 1 slot */ |
| 786 | nutrs = (mmio_read_32(ufs_params.reg_base + CAP) & CAP_NUTRS_MASK) + 1; |
| 787 | if (nutrs > (ufs_params.desc_size / UFS_DESC_SIZE)) { |
| 788 | nutrs = ufs_params.desc_size / UFS_DESC_SIZE; |
| 789 | } |
| 790 | |
| 791 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 792 | if (ufs_params.flags & UFS_FLAGS_SKIPINIT) { |
| 793 | result = ufshc_dme_get(0x1571, 0, &data); |
| 794 | assert(result == 0); |
| 795 | result = ufshc_dme_get(0x41, 0, &data); |
| 796 | assert(result == 0); |
| 797 | if (data == 1) { |
| 798 | /* prepare to exit hibernate mode */ |
| 799 | memset(&cmd, 0, sizeof(uic_cmd_t)); |
| 800 | cmd.op = DME_HIBERNATE_EXIT; |
| 801 | result = ufshc_send_uic_cmd(ufs_params.reg_base, |
| 802 | &cmd); |
| 803 | assert(result == 0); |
| 804 | data = mmio_read_32(ufs_params.reg_base + UCMDARG2); |
| 805 | assert(data == 0); |
| 806 | do { |
| 807 | data = mmio_read_32(ufs_params.reg_base + IS); |
| 808 | } while ((data & UFS_INT_UHXS) == 0); |
| 809 | mmio_write_32(ufs_params.reg_base + IS, UFS_INT_UHXS); |
| 810 | data = mmio_read_32(ufs_params.reg_base + HCS); |
| 811 | assert((data & HCS_UPMCRS_MASK) == HCS_PWR_LOCAL); |
| 812 | } |
| 813 | result = ufshc_dme_get(0x1568, 0, &data); |
| 814 | assert(result == 0); |
| 815 | assert((data > 0) && (data <= 3)); |
| 816 | } else { |
| 817 | assert((ops != NULL) && (ops->phy_init != NULL) && |
| 818 | (ops->phy_set_pwr_mode != NULL)); |
| 819 | |
Jorge Troncoso | 5f44916 | 2021-09-30 16:29:32 -0700 | [diff] [blame] | 820 | result = ufshc_reset(ufs_params.reg_base); |
| 821 | assert(result == 0); |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 822 | ops->phy_init(&ufs_params); |
| 823 | result = ufshc_link_startup(ufs_params.reg_base); |
| 824 | assert(result == 0); |
fengbaopeng | 44070ef | 2018-02-12 20:53:54 +0800 | [diff] [blame] | 825 | |
| 826 | ufs_enum(); |
| 827 | |
| 828 | ufs_get_device_info(&card); |
| 829 | if (card.wmanufacturerid == UFS_VENDOR_SKHYNIX) { |
| 830 | ufs_params.flags |= UFS_FLAGS_VENDOR_SKHYNIX; |
| 831 | } |
| 832 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 833 | ops->phy_set_pwr_mode(&ufs_params); |
| 834 | } |
| 835 | |
Haojian Zhuang | 20cd323 | 2017-05-31 11:00:15 +0800 | [diff] [blame] | 836 | (void)result; |
| 837 | return 0; |
| 838 | } |