Skip to content

Commit c4df6ee

Browse files
Stanley Chumartinkpetersen
authored andcommitted
scsi: ufs: Introduce device quirk "DELAY_AFTER_LPM"
Some UFS devices require delay after VCC power rail is turned off. Introduce a device quirk "DELAY_AFTER_LPM" to add 5ms delay after VCC power-off during suspend flow. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Andy Teng <[email protected]> Reviewed-by: Peter Wang <[email protected]> Reviewed-by: Can Guo <[email protected]> Acked-by: Avri Altman <[email protected]> Signed-off-by: Stanley Chu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent bb2e331 commit c4df6ee

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/scsi/ufs/ufs_quirks.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,11 @@ struct ufs_dev_fix {
109109
*/
110110
#define UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES (1 << 10)
111111

112+
/*
113+
* Some UFS devices require delay after VCC power rail is turned-off.
114+
* Enable this quirk to introduce 5ms delays after VCC power-off during
115+
* suspend flow.
116+
*/
117+
#define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11)
118+
112119
#endif /* UFS_QUIRKS_H_ */

drivers/scsi/ufs/ufshcd.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8107,6 +8107,8 @@ static int ufshcd_link_state_transition(struct ufs_hba *hba,
81078107

81088108
static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)
81098109
{
8110+
bool vcc_off = false;
8111+
81108112
/*
81118113
* It seems some UFS devices may keep drawing more than sleep current
81128114
* (atleast for 500us) from UFS rails (especially from VCCQ rail).
@@ -8135,13 +8137,22 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)
81358137
if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba) &&
81368138
!hba->dev_info.is_lu_power_on_wp) {
81378139
ufshcd_setup_vreg(hba, false);
8140+
vcc_off = true;
81388141
} else if (!ufshcd_is_ufs_dev_active(hba)) {
81398142
ufshcd_toggle_vreg(hba->dev, hba->vreg_info.vcc, false);
8143+
vcc_off = true;
81408144
if (!ufshcd_is_link_active(hba)) {
81418145
ufshcd_config_vreg_lpm(hba, hba->vreg_info.vccq);
81428146
ufshcd_config_vreg_lpm(hba, hba->vreg_info.vccq2);
81438147
}
81448148
}
8149+
8150+
/*
8151+
* Some UFS devices require delay after VCC power rail is turned-off.
8152+
*/
8153+
if (vcc_off && hba->vreg_info.vcc &&
8154+
hba->dev_quirks & UFS_DEVICE_QUIRK_DELAY_AFTER_LPM)
8155+
usleep_range(5000, 5100);
81458156
}
81468157

81478158
static int ufshcd_vreg_set_hpm(struct ufs_hba *hba)

0 commit comments

Comments
 (0)