Skip to content

Commit 3fd23b8

Browse files
powen-kao-mtkmartinkpetersen
authored andcommitted
scsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators
Currently the LPM configurations of device regulators may not work since VCC is not disabled yet while ufs_mtk_vreg_set_lpm() is executed. Fix this by changing the timing of invoking ufs_mtk_vreg_set_lpm(). Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Po-Wen Kao <[email protected]> Signed-off-by: Stanley Chu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 3f9b6ce commit 3fd23b8

File tree

1 file changed

+53
-5
lines changed

1 file changed

+53
-5
lines changed

drivers/ufs/host/ufs-mediatek.c

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,6 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
10821082
* ufshcd_suspend() re-enabling regulators while vreg is still
10831083
* in low-power mode.
10841084
*/
1085-
ufs_mtk_vreg_set_lpm(hba, true);
10861085
err = ufs_mtk_mphy_power_on(hba, false);
10871086
if (err)
10881087
goto fail;
@@ -1106,12 +1105,13 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
11061105
{
11071106
int err;
11081107

1108+
if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)
1109+
ufs_mtk_vreg_set_lpm(hba, false);
1110+
11091111
err = ufs_mtk_mphy_power_on(hba, true);
11101112
if (err)
11111113
goto fail;
11121114

1113-
ufs_mtk_vreg_set_lpm(hba, false);
1114-
11151115
if (ufshcd_is_link_hibern8(hba)) {
11161116
err = ufs_mtk_link_set_hpm(hba);
11171117
if (err)
@@ -1276,9 +1276,57 @@ static int ufs_mtk_remove(struct platform_device *pdev)
12761276
return 0;
12771277
}
12781278

1279+
int ufs_mtk_system_suspend(struct device *dev)
1280+
{
1281+
struct ufs_hba *hba = dev_get_drvdata(dev);
1282+
int ret;
1283+
1284+
ret = ufshcd_system_suspend(dev);
1285+
if (ret)
1286+
return ret;
1287+
1288+
ufs_mtk_vreg_set_lpm(hba, true);
1289+
1290+
return 0;
1291+
}
1292+
1293+
int ufs_mtk_system_resume(struct device *dev)
1294+
{
1295+
struct ufs_hba *hba = dev_get_drvdata(dev);
1296+
1297+
ufs_mtk_vreg_set_lpm(hba, false);
1298+
1299+
return ufshcd_system_resume(dev);
1300+
}
1301+
1302+
int ufs_mtk_runtime_suspend(struct device *dev)
1303+
{
1304+
struct ufs_hba *hba = dev_get_drvdata(dev);
1305+
int ret = 0;
1306+
1307+
ret = ufshcd_runtime_suspend(dev);
1308+
if (ret)
1309+
return ret;
1310+
1311+
ufs_mtk_vreg_set_lpm(hba, true);
1312+
1313+
return 0;
1314+
}
1315+
1316+
int ufs_mtk_runtime_resume(struct device *dev)
1317+
{
1318+
struct ufs_hba *hba = dev_get_drvdata(dev);
1319+
1320+
ufs_mtk_vreg_set_lpm(hba, false);
1321+
1322+
return ufshcd_runtime_resume(dev);
1323+
}
1324+
12791325
static const struct dev_pm_ops ufs_mtk_pm_ops = {
1280-
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
1281-
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
1326+
SET_SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend,
1327+
ufs_mtk_system_resume)
1328+
SET_RUNTIME_PM_OPS(ufs_mtk_runtime_suspend,
1329+
ufs_mtk_runtime_resume, NULL)
12821330
.prepare = ufshcd_suspend_prepare,
12831331
.complete = ufshcd_resume_complete,
12841332
};

0 commit comments

Comments
 (0)