Commit 2a06ff20 authored by Stanley Chu's avatar Stanley Chu Committed by Martin K. Petersen

scsi: ufs: ufs-mediatek: support linkoff state during suspend

If system suspend or runtime suspend mode is configured as linkoff state,
phy can be powered off and reference clock can be gated in MediaTek
Chipsets.

At the same time, remove redundant reference clock control in suspend and
resume callbacks because such control can be well-handled in setup_clocks
callback.

Link: https://lore.kernel.org/r/20200129105251.12466-3-stanley.chu@mediatek.comReviewed-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 7742ca79
...@@ -167,7 +167,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on, ...@@ -167,7 +167,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
switch (status) { switch (status) {
case PRE_CHANGE: case PRE_CHANGE:
if (!on) { if (!on && !ufshcd_is_link_active(hba)) {
ufs_mtk_setup_ref_clk(hba, on); ufs_mtk_setup_ref_clk(hba, on);
ret = phy_power_off(host->mphy); ret = phy_power_off(host->mphy);
} }
...@@ -437,10 +437,11 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) ...@@ -437,10 +437,11 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
err = ufs_mtk_link_set_lpm(hba); err = ufs_mtk_link_set_lpm(hba);
if (err) if (err)
return -EAGAIN; return -EAGAIN;
phy_power_off(host->mphy);
ufs_mtk_setup_ref_clk(hba, false);
} }
if (!ufshcd_is_link_active(hba))
phy_power_off(host->mphy);
return 0; return 0;
} }
...@@ -449,9 +450,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) ...@@ -449,9 +450,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
struct ufs_mtk_host *host = ufshcd_get_variant(hba); struct ufs_mtk_host *host = ufshcd_get_variant(hba);
int err; int err;
if (ufshcd_is_link_hibern8(hba)) { if (!ufshcd_is_link_active(hba))
ufs_mtk_setup_ref_clk(hba, true);
phy_power_on(host->mphy); phy_power_on(host->mphy);
if (ufshcd_is_link_hibern8(hba)) {
err = ufs_mtk_link_set_hpm(hba); err = ufs_mtk_link_set_hpm(hba);
if (err) if (err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment