refactor(ufs): adds a function for fdeviceinit
time taken for device init varies based on different devices, instead of waiting for 200ms - we can poll on fdevice init until it gets cleared, similar to what linux does Change-Id: I571649231732fde0cd6d5be89b6f14fe905fcaff Signed-off-by: anans <anans@google.com>
This commit is contained in:
parent
863296898a
commit
50593e696e
|
@ -734,16 +734,41 @@ size_t ufs_write_blocks(int lun, int lba, const uintptr_t buf, size_t size)
|
||||||
return size - resp->res_trans_cnt;
|
return size - resp->res_trans_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ufs_set_fdevice_init(void)
|
||||||
|
{
|
||||||
|
unsigned int result;
|
||||||
|
int timeout;
|
||||||
|
|
||||||
|
ufs_set_flag(FLAG_DEVICE_INIT);
|
||||||
|
|
||||||
|
timeout = FDEVICEINIT_TIMEOUT_MS;
|
||||||
|
do {
|
||||||
|
result = ufs_read_flag(FLAG_DEVICE_INIT);
|
||||||
|
if (!result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mdelay(5);
|
||||||
|
timeout -= 5;
|
||||||
|
} while (timeout > 0);
|
||||||
|
|
||||||
|
if (result != 0U) {
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void ufs_enum(void)
|
static void ufs_enum(void)
|
||||||
{
|
{
|
||||||
unsigned int blk_num, blk_size;
|
unsigned int blk_num, blk_size;
|
||||||
int i;
|
int i, result;
|
||||||
|
|
||||||
ufs_verify_init();
|
ufs_verify_init();
|
||||||
ufs_verify_ready();
|
ufs_verify_ready();
|
||||||
|
|
||||||
ufs_set_flag(FLAG_DEVICE_INIT);
|
result = ufs_set_fdevice_init();
|
||||||
mdelay(200);
|
assert(result == 0);
|
||||||
|
|
||||||
/* dump available LUNs */
|
/* dump available LUNs */
|
||||||
for (i = 0; i < UFS_MAX_LUNS; i++) {
|
for (i = 0; i < UFS_MAX_LUNS; i++) {
|
||||||
ufs_read_capacity(i, &blk_num, &blk_size);
|
ufs_read_capacity(i, &blk_num, &blk_size);
|
||||||
|
@ -752,6 +777,8 @@ static void ufs_enum(void)
|
||||||
i, blk_num, blk_size);
|
i, blk_num, blk_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ufs_get_device_info(struct ufs_dev_desc *card_data)
|
static void ufs_get_device_info(struct ufs_dev_desc *card_data)
|
||||||
|
|
|
@ -265,6 +265,8 @@
|
||||||
#define HCE_ENABLE_INNER_RETRIES 50
|
#define HCE_ENABLE_INNER_RETRIES 50
|
||||||
#define HCE_ENABLE_TIMEOUT_US 100
|
#define HCE_ENABLE_TIMEOUT_US 100
|
||||||
|
|
||||||
|
#define FDEVICEINIT_TIMEOUT_MS 1500
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ufs_dev_desc - ufs device details from the device descriptor
|
* ufs_dev_desc - ufs device details from the device descriptor
|
||||||
* @wmanufacturerid: card details
|
* @wmanufacturerid: card details
|
||||||
|
|
Loading…
Reference in New Issue