diff mbox series

[v3,2/4] scsi: ufs-mediatek: support linkoff state during suspend

Message ID 20200129073902.5786-3-stanley.chu@mediatek.com (mailing list archive)
State Mainlined
Commit 2a06ff207445ddb7aa643751f85c54e7e3895fb4
Headers show
Series MediaTek UFS vendor implemenation part III and Auto-Hibern8 fix | expand

Commit Message

Stanley Chu Jan. 29, 2020, 7:39 a.m. UTC
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.

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

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufs-mediatek.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Alim Akhtar Feb. 2, 2020, 2:35 p.m. UTC | #1
Hi Stanley

On Wed, Jan 29, 2020 at 1:11 PM Stanley Chu <stanley.chu@mediatek.com> wrote:
>
> 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.
>
> In the same time, remove redundant reference clock control
> in suspend and resume callbacks because such control can be
> well-handled in setup_clocks callback..
>
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>

> ---
>  drivers/scsi/ufs/ufs-mediatek.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> index 7ac838cc15d1..d78897a14905 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -167,7 +167,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
>
>         switch (status) {
>         case PRE_CHANGE:
> -               if (!on) {
> +               if (!on && !ufshcd_is_link_active(hba)) {
>                         ufs_mtk_setup_ref_clk(hba, on);
>                         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)
>                 err = ufs_mtk_link_set_lpm(hba);
>                 if (err)
>                         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;
>  }
>
> @@ -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);
>         int err;
>
> -       if (ufshcd_is_link_hibern8(hba)) {
> -               ufs_mtk_setup_ref_clk(hba, true);
> +       if (!ufshcd_is_link_active(hba))
>                 phy_power_on(host->mphy);
> +
> +       if (ufshcd_is_link_hibern8(hba)) {
>                 err = ufs_mtk_link_set_hpm(hba);
>                 if (err)
>                         return err;
> --
> 2.18.0
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 7ac838cc15d1..d78897a14905 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -167,7 +167,7 @@  static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
 
 	switch (status) {
 	case PRE_CHANGE:
-		if (!on) {
+		if (!on && !ufshcd_is_link_active(hba)) {
 			ufs_mtk_setup_ref_clk(hba, on);
 			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)
 		err = ufs_mtk_link_set_lpm(hba);
 		if (err)
 			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;
 }
 
@@ -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);
 	int err;
 
-	if (ufshcd_is_link_hibern8(hba)) {
-		ufs_mtk_setup_ref_clk(hba, true);
+	if (!ufshcd_is_link_active(hba))
 		phy_power_on(host->mphy);
+
+	if (ufshcd_is_link_hibern8(hba)) {
 		err = ufs_mtk_link_set_hpm(hba);
 		if (err)
 			return err;