]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: ufs: ufs-mediatek: Support host power control
authorPo-Wen Kao <powen.kao@mediatek.com>
Thu, 23 Jun 2022 03:50:50 +0000 (11:50 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 28 Jun 2022 03:17:36 +0000 (23:17 -0400)
Add interfaces for controlling the host power to optimize the power
consumption in MediaTek UFS platforms.

Link: https://lore.kernel.org/r/20220623035052.18802-7-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/host/ufs-mediatek.c
drivers/ufs/host/ufs-mediatek.h

index a7482f530f27d44b4bb4392d026fffa343c4bb62..7254629484aba5d4539f094dae828ccf022db509 100644 (file)
@@ -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 @@ fail:
 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;
index c12ceb4d941fb8d312de8de534b26ea537d5ed27..cdf40851e626b3a467c88fb3afa309cc8f769a8b 100644 (file)
@@ -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))