scsi: ufs: Fix ufs power down/on specs violation

As per specs, while powering off/on the ufs device, RST_N signal and
REF_CLK signal should be between VSS(Ground) and VCCQ/VCCQ2.

Power down:
1. Assert RST_N low
2. Turn-off REF_CLK
3. Turn-off VCC
4. Turn-off VCCQ/VCCQ2.
power on:
1. Turn-on VCC
2. Turn-on VCCQ/VCCQ2
3. Turn-On REF_CLK
4. Deassert RST_N high.

Change-Id: I602e632d284a9d78431bf897558a4b8300ad3611
Signed-off-by: Ziqi Chen <ziqichen@codeaurora.org>
This commit is contained in:
Ziqi Chen 2020-10-20 16:55:27 +08:00
commit 8586ea7063
2 changed files with 34 additions and 3 deletions

View file

@ -1166,6 +1166,12 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
err = ufs_qcom_unvote_qos_all(hba);
}
#if defined(CONFIG_SCSI_UFSHCD_QTI)
/* reset the connected UFS device during power down */
if (!err && ufs_qcom_is_link_off(hba) && host->device_reset)
gpiod_set_value_cansleep(host->device_reset, 1);
#endif
return err;
}

View file

@ -8791,10 +8791,9 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
ret = ufshcd_link_state_transition(hba, req_link_state, 1);
if (ret)
goto set_dev_active;
#if defined(CONFIG_SCSI_UFSHCD_QTI)
if (!hba->auto_bkops_enabled)
#endif
#if !defined(CONFIG_SCSI_UFSHCD_QTI)
ufshcd_vreg_set_lpm(hba);
#endif
disable_clks:
/*
@ -8825,6 +8824,10 @@ disable_clks:
/* Put the host controller in low power mode if possible */
ufshcd_hba_vreg_set_lpm(hba);
#if defined(CONFIG_SCSI_UFSHCD_QTI)
if (!hba->auto_bkops_enabled)
ufshcd_vreg_set_lpm(hba);
#endif
goto out;
set_link_active:
@ -8879,17 +8882,29 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
old_pwr_mode = hba->curr_dev_pwr_mode;
ufshcd_hba_vreg_set_hpm(hba);
#if defined(CONFIG_SCSI_UFSHCD_QTI)
ret = ufshcd_vreg_set_hpm(hba);
if (ret)
goto out;
#endif
/* Make sure clocks are enabled before accessing controller */
ret = ufshcd_setup_clocks(hba, true);
if (ret)
#if defined(CONFIG_SCSI_UFSHCD_QTI)
goto disable_vreg;
#else
goto out;
#endif
/* enable the host irq as host controller would be active soon */
ufshcd_enable_irq(hba);
#if !defined(CONFIG_SCSI_UFSHCD_QTI)
ret = ufshcd_vreg_set_hpm(hba);
if (ret)
goto disable_irq_and_vops_clks;
#endif
/*
* Call vendor specific resume callback. As these callbacks may access
@ -8898,7 +8913,11 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
*/
ret = ufshcd_vops_resume(hba, pm_op);
if (ret)
#if defined(CONFIG_SCSI_UFSHCD_QTI)
goto disable_irq_and_vops_clks;
#else
goto disable_vreg;
#endif
if (ufshcd_is_link_hibern8(hba)) {
ret = ufshcd_uic_hibern8_exit(hba);
@ -8967,8 +8986,10 @@ set_old_link_state:
ufshcd_link_state_transition(hba, old_link_state, 0);
vendor_suspend:
ufshcd_vops_suspend(hba, pm_op);
#if !defined(CONFIG_SCSI_UFSHCD_QTI)
disable_vreg:
ufshcd_vreg_set_lpm(hba);
#endif
disable_irq_and_vops_clks:
ufshcd_disable_irq(hba);
if (hba->clk_scaling.is_allowed)
@ -8979,6 +9000,10 @@ disable_irq_and_vops_clks:
trace_ufshcd_clk_gating(dev_name(hba->dev),
hba->clk_gating.state);
}
#if defined(CONFIG_SCSI_UFSHCD_QTI)
disable_vreg:
ufshcd_vreg_set_lpm(hba);
#endif
out:
hba->pm_op_in_progress = 0;
if (ret)