mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
scsi: ufs-mediatek: Introduce low-power mode for device power supply
Allow device power supply to enter low-power mode. Link: https://lore.kernel.org/r/20200601104646.15436-4-stanley.chu@mediatek.com Reviewed-by: Pengshun Zhao <pengshun.zhao@mediatek.com> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
9006e3986f
commit
488edafb11
@@ -12,6 +12,7 @@
|
|||||||
#include <linux/of_address.h>
|
#include <linux/of_address.h>
|
||||||
#include <linux/phy/phy.h>
|
#include <linux/phy/phy.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
#include <linux/soc/mediatek/mtk_sip_svc.h>
|
#include <linux/soc/mediatek/mtk_sip_svc.h>
|
||||||
|
|
||||||
#include "ufshcd.h"
|
#include "ufshcd.h"
|
||||||
@@ -521,6 +522,19 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
|
||||||
|
{
|
||||||
|
if (!hba->vreg_info.vccq2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (lpm & !hba->vreg_info.vcc->enabled)
|
||||||
|
regulator_set_mode(hba->vreg_info.vccq2->reg,
|
||||||
|
REGULATOR_MODE_IDLE);
|
||||||
|
else if (!lpm)
|
||||||
|
regulator_set_mode(hba->vreg_info.vccq2->reg,
|
||||||
|
REGULATOR_MODE_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
|
static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@@ -537,6 +551,12 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
|
|||||||
ufshcd_set_link_off(hba);
|
ufshcd_set_link_off(hba);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Make sure no error will be returned to prevent
|
||||||
|
* ufshcd_suspend() re-enabling regulators while vreg is still
|
||||||
|
* in low-power mode.
|
||||||
|
*/
|
||||||
|
ufs_mtk_vreg_set_lpm(hba, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ufshcd_is_link_active(hba))
|
if (!ufshcd_is_link_active(hba))
|
||||||
@@ -554,6 +574,7 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
|
|||||||
phy_power_on(host->mphy);
|
phy_power_on(host->mphy);
|
||||||
|
|
||||||
if (ufshcd_is_link_hibern8(hba)) {
|
if (ufshcd_is_link_hibern8(hba)) {
|
||||||
|
ufs_mtk_vreg_set_lpm(hba, false);
|
||||||
err = ufs_mtk_link_set_hpm(hba);
|
err = ufs_mtk_link_set_hpm(hba);
|
||||||
if (err) {
|
if (err) {
|
||||||
err = ufshcd_link_recovery(hba);
|
err = ufshcd_link_recovery(hba);
|
||||||
|
Reference in New Issue
Block a user