scsi: ufs: core: Let delay value after LPM can be modified by vendor
Subsystems (2)
PATCH v2 1/1 scsi: ufs: core: Let delay value after LPM can be modified by vendor
From: Zhe Wang <[email protected]>
Some UFS devices require that the VCC should drop below 0.1V after turning off, otherwise device may not resume successfully. And because the power-off rate is different on different SOC platforms. Therefore, we hope that the delay can be modified by vendor to adjust the most appropriate delay value.
---
V1 -> V2
- move turnoff_delay_us to struct ufs_vreg instead
- replace usleep_range with ufshcd_delay_us
drivers/ufs/core/ufshcd.c | 9 ++++++++- include/ufs/ufs.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +8 -1
@@ -89,6 +89,9 @@/* Polling time to wait for fDeviceInit */ #define FDEVICEINIT_COMPL_TIMEOUT 1500/* millisecs */ +/* Default value of turn off VCC rail: 5000us */ +#define UFS_VCC_TURNOFF_DELAY_US 5000 +#define ufshcd_toggle_vreg (_dev, _vreg, _on) \ ({ \ int _ret; \
@@ -7784,6 +7787,10 @@ static int ufs_get_device_desc(struct ufs_hba *hba)ufs_fixup_device_setup (hba); +if (hba->dev_quirks &UFS_DEVICE_QUIRK_DELAY_AFTER_LPM && + !hba->vreg_info.vcc->turnoff_delay_us) + hba->vreg_info.vcc->turnoff_delay_us =UFS_VCC_TURNOFF_DELAY_US ; +ufshcd_wb_probe (hba, desc_buf);ufshcd_temp_notif_probe (hba, desc_buf);
@@ -8918,7 +8925,7 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)*/ if (vcc_off && hba->vreg_info.vcc && hba->dev_quirks &UFS_DEVICE_QUIRK_DELAY_AFTER_LPM ) -usleep_range (5000 ,5100 ); +ufshcd_delay_us (hba->vreg_info.vcc->turnoff_delay_us,100 ); }#ifdef CONFIG_PM
include/ufs/ufs.h +1 -0
@@ -569,6 +569,7 @@ struct ufs_vreg {bool always_on;bool enabled;int max_uA; +u32 turnoff_delay_us; };struct ufs_vreg_info {
Signature · 1 line
2.17.1
Avri Altman
reviewerQuoted 33 lines
From: Zhe Wang <[email protected]>
Some UFS devices require that the VCC should drop below 0.1V after turning off, otherwise device may not resume successfully. And because the power-off rate is different on different SOC platforms. Therefore, we hope that the delay can be modified by vendor to adjust the most appropriate delay value.
Signed-off-by Zhe Wang <[email protected]>---
V1 -> V2
- moveturnoff_delay_usto structufs_vreginstead
- replaceusleep_rangewithufshcd_delay_usdrivers/ufs/core/ufshcd.c | 9 ++++++++- include/ufs/ufs.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)drivers/ufs/core/ufshcd.c +3
-0@@ -89,6 +89,9 @@/* Polling time to wait for fDeviceInit */ #define FDEVICEINIT_COMPL_TIMEOUT 1500/* millisecs */ +/* Default value of turn off VCC rail: 5000us */ +#define UFS_VCC_TURNOFF_DELAY_US 5000 +#define ufshcd_toggle_vreg (_dev, _vreg, _on) \ ({ \ int _ret; \
drivers/ufs/core/ufshcd.c static int ufs_get_device_desc(struct ufs_hba *hba) · line 7794
Quoted 8 lines
drivers/ufs/core/ufshcd.c +4
-0@@ -7784,6 +7787,10 @@ static int ufs_get_device_desc(struct ufs_hba *hba)ufs_fixup_device_setup (hba); +if (hba->dev_quirks &UFS_DEVICE_QUIRK_DELAY_AFTER_LPM && + !hba->vreg_info.vcc->turnoff_delay_us) + hba->vreg_info.vcc->turnoff_delay_us =UFS_VCC_TURNOFF_DELAY_US ; +
You answered my question to your v1 - where otherwise you are setting this value:
"We are still preparing and discussing our own UFS host driver code, which will be uploaded once we are done."
Well until then - this isn't very useful.
Thanks,
Avri
Quoted 26 lines
drivers/ufs/core/ufshcd.c +0
-0ufshcd_wb_probe (hba, desc_buf);ufshcd_temp_notif_probe(hba, desc_buf);drivers/ufs/core/ufshcd.c +1
-1@@ -8918,7 +8925,7 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)*/ if (vcc_off && hba->vreg_info.vcc && hba->dev_quirks &UFS_DEVICE_QUIRK_DELAY_AFTER_LPM ) -usleep_range (5000 ,5100 ); +ufshcd_delay_us (hba->vreg_info.vcc->turnoff_delay_us,100 ); }#ifdef CONFIG_PM include/ufs/ufs.h +1
-1@@ -569,6 +569,7 @@ struct ufs_vreg {bool always_on;bool enabled;int max_uA; +u32 turnoff_delay_us; };struct ufs_vreg_info { --2.17.1
Quoted 73 lines
Quoted 33 lines
From: Zhe Wang <[email protected]>
Some UFS devices require that the VCC should drop below 0.1V after turning off, otherwise device may not resume successfully. And because the power-off rate is different on different SOC platforms. Therefore, we hope that the delay can be modified by vendor to adjust the most appropriate delay value.
Signed-off-by Zhe Wang <[email protected]>---
V1 -> V2
- moveturnoff_delay_usto structufs_vreginstead
- replaceusleep_rangewithufshcd_delay_usdrivers/ufs/core/ufshcd.c | 9 ++++++++- include/ufs/ufs.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)drivers/ufs/core/ufshcd.c +3
-0@@ -89,6 +89,9 @@/* Polling time to wait for fDeviceInit */ #define FDEVICEINIT_COMPL_TIMEOUT 1500/* millisecs */ +/* Default value of turn off VCC rail: 5000us */ +#define UFS_VCC_TURNOFF_DELAY_US 5000 +#define ufshcd_toggle_vreg (_dev, _vreg, _on) \ ({ \ int _ret; \drivers/ufs/core/ufshcd.c static int ufs_get_device_desc(struct ufs_hba *hba) · line 7794
Quoted 8 lines
drivers/ufs/core/ufshcd.c +4
-0@@ -7784,6 +7787,10 @@ static int ufs_get_device_desc(struct ufs_hba *hba)ufs_fixup_device_setup (hba); +if (hba->dev_quirks &UFS_DEVICE_QUIRK_DELAY_AFTER_LPM && + !hba->vreg_info.vcc->turnoff_delay_us) + hba->vreg_info.vcc->turnoff_delay_us =UFS_VCC_TURNOFF_DELAY_US ; +You answered my question to your v1 - where otherwise you are setting this value:
"We are still preparing and discussing our own UFS host driver code, which will be uploaded once we are done."Well until then - this isn't very useful.
Thanks,
AvriQuoted 23 lines
drivers/ufs/core/ufshcd.c +0
-0ufshcd_wb_probe (hba, desc_buf);ufshcd_temp_notif_probe(hba, desc_buf);drivers/ufs/core/ufshcd.c +1
-1@@ -8918,7 +8925,7 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)*/ if (vcc_off && hba->vreg_info.vcc && hba->dev_quirks &UFS_DEVICE_QUIRK_DELAY_AFTER_LPM ) -usleep_range (5000 ,5100 ); +ufshcd_delay_us (hba->vreg_info.vcc->turnoff_delay_us,100 ); }#ifdef CONFIG_PM include/ufs/ufs.h +1
-0@@ -569,6 +569,7 @@ struct ufs_vreg {bool always_on;bool enabled;int max_uA; +u32 turnoff_delay_us; };
Quoted 4 lines
Quoted 3 lines
include/ufs/ufs.h +0
-1struct ufs_vreg_info { --2.17.1
OK, thanks for your review.
Thanks,
Zhe Wang