[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220622073719.21599-7-stanley.chu@mediatek.com>
Date: Wed, 22 Jun 2022 15:37:18 +0800
From: Stanley Chu <stanley.chu@...iatek.com>
To: <linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<martin.petersen@...cle.com>, <avri.altman@....com>,
<alim.akhtar@...sung.com>, <jejb@...ux.ibm.com>,
<bvanassche@....org>
CC: <peter.wang@...iatek.com>, <chun-hung.wu@...iatek.com>,
<alice.chao@...iatek.com>, <powen.kao@...iatek.com>,
<mason.zhang@...iatek.com>, <qilin.tan@...iatek.com>,
<lin.gui@...iatek.com>, <eddie.huang@...iatek.com>,
<tun-yu.yu@...iatek.com>, <cc.chou@...iatek.com>,
<chaotian.jing@...iatek.com>, <jiajie.hao@...iatek.com>,
<stanley.chu@...iatek.com>
Subject: [PATCH v1 6/7] scsi: ufs-mediatek: Support host power control
From: Po-Wen Kao <powen.kao@...iatek.com>
Add interfaces for controlling the host power to
optimize the power consumption in MediaTek UFS platforms.
Reviewed-by: Stanley Chu <stanley.chu@...iatek.com>
Signed-off-by: Po-Wen Kao <powen.kao@...iatek.com>
Signed-off-by: Stanley Chu <stanley.chu@...iatek.com>
---
drivers/ufs/host/ufs-mediatek.c | 5 +++++
drivers/ufs/host/ufs-mediatek.h | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 348966dbad78..085ba05ff4d4 100755
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1190,6 +1190,8 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
if (ufshcd_is_link_off(hba))
ufs_mtk_device_reset_ctrl(0, res);
+ ufs_mtk_host_pwr_ctrl(HOST_PWR_HCI, false, res);
+
return 0;
fail:
/*
@@ -1204,10 +1206,13 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
{
int err;
+ struct arm_smccc_res res;
if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)
ufs_mtk_dev_vreg_set_lpm(hba, false);
+ ufs_mtk_host_pwr_ctrl(HOST_PWR_HCI, true, res);
+
err = ufs_mtk_mphy_power_on(hba, true);
if (err)
goto fail;
diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediatek.h
index c12ceb4d941f..cdf40851e626 100755
--- a/drivers/ufs/host/ufs-mediatek.h
+++ b/drivers/ufs/host/ufs-mediatek.h
@@ -84,6 +84,7 @@ enum {
#define UFS_MTK_SIP_DEVICE_RESET BIT(1)
#define UFS_MTK_SIP_CRYPTO_CTRL BIT(2)
#define UFS_MTK_SIP_REF_CLK_NOTIFICATION BIT(3)
+#define UFS_MTK_SIP_HOST_PWR_CTRL BIT(5)
#define UFS_MTK_SIP_GET_VCC_NUM BIT(6)
#define UFS_MTK_SIP_DEVICE_PWR_CTRL BIT(7)
@@ -156,6 +157,14 @@ enum ufs_mtk_vcc_num {
UFS_VCC_MAX
};
+/*
+ * Host Power Control options
+ */
+enum {
+ HOST_PWR_HCI = 0,
+ HOST_PWR_MPHY
+};
+
/*
* SMC call wrapper function
*/
@@ -195,6 +204,9 @@ static void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
#define ufs_mtk_device_reset_ctrl(high, res) \
ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, &(res), high)
+#define ufs_mtk_host_pwr_ctrl(opt, on, res) \
+ ufs_mtk_smc(UFS_MTK_SIP_HOST_PWR_CTRL, &(res), opt, on)
+
#define ufs_mtk_get_vcc_num(res) \
ufs_mtk_smc(UFS_MTK_SIP_GET_VCC_NUM, &(res))
--
2.18.0
Powered by blists - more mailing lists