From 0cbc11d014865a46a58c16b3b133216f8a70d360 Mon Sep 17 00:00:00 2001 From: "Bao D. Nguyen" Date: Wed, 15 Jul 2020 11:39:35 -0700 Subject: [PATCH] scsi:ufs: Keep UFS's high power mode when bkops enabled When bkops is enabled, the UFS device may do bkops during suspend. With bkops enabled during suspend, configure the UFS's vccq power in active operation configuration, allowing the device to draw high power to support bkops and avoid over current event. Change-Id: I6677b56cdb97689fa7ffc441f68a62af0dcbf53a Signed-off-by: Bao D. Nguyen --- drivers/scsi/ufs/ufs-qcom.c | 16 ++++++++-------- drivers/scsi/ufs/ufshcd.c | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 5c18c9efba11..d7d4437b4ba3 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -993,8 +993,7 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) err = ufs_qcom_disable_vreg(hba->dev, host->vddp_ref_clk); if (host->vccq_parent && !hba->auto_bkops_enabled) - ufs_qcom_config_vreg(hba->dev, - host->vccq_parent, false); + ufs_qcom_disable_vreg(hba->dev, host->vccq_parent); if (!err) err = ufs_qcom_unvote_qos_all(hba); } @@ -1011,8 +1010,9 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) hba->spm_lvl > UFS_PM_LVL_3)) ufs_qcom_enable_vreg(hba->dev, host->vddp_ref_clk); + if (host->vccq_parent) - ufs_qcom_config_vreg(hba->dev, host->vccq_parent, true); + ufs_qcom_enable_vreg(hba->dev, host->vccq_parent); err = ufs_qcom_enable_lane_clks(host); if (err) @@ -2563,9 +2563,9 @@ static int ufs_qcom_init(struct ufs_hba *hba) err = ufs_qcom_parse_reg_info(host, "qcom,vccq-parent", &host->vccq_parent); if (host->vccq_parent) { - err = ufs_qcom_config_vreg(hba->dev, host->vccq_parent, true); + err = ufs_qcom_enable_vreg(dev, host->vccq_parent); if (err) { - dev_err(dev, "%s: failed vccq-parent set load: %d\n", + dev_err(dev, "%s: failed enable vccq-parent err=%d\n", __func__, err); goto out_disable_vddp; } @@ -2573,7 +2573,7 @@ static int ufs_qcom_init(struct ufs_hba *hba) err = ufs_qcom_init_lane_clks(host); if (err) - goto out_set_load_vccq_parent; + goto out_disable_vccq_parent; ufs_qcom_parse_pm_level(hba); ufs_qcom_parse_limits(host); @@ -2617,9 +2617,9 @@ static int ufs_qcom_init(struct ufs_hba *hba) ufs_qcom_qos_init(hba); goto out; -out_set_load_vccq_parent: +out_disable_vccq_parent: if (host->vccq_parent) - ufs_qcom_config_vreg(hba->dev, host->vccq_parent, false); + ufs_qcom_disable_vreg(dev, host->vccq_parent); out_disable_vddp: if (host->vddp_ref_clk) ufs_qcom_disable_vreg(dev, host->vddp_ref_clk); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f9c3072ad5c7..54d6b73ffb42 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8480,8 +8480,10 @@ 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; - - ufshcd_vreg_set_lpm(hba); +#if defined(CONFIG_SCSI_UFSHCD_QTI) + if (!hba->auto_bkops_enabled) +#endif + ufshcd_vreg_set_lpm(hba); disable_clks: /*