scsi: ufs-mediatek: Support option to disable auto-hibern8
authorStanley Chu <stanley.chu@mediatek.com>
Thu, 29 Oct 2020 11:57:48 +0000 (19:57 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 11 Nov 2020 04:03:18 +0000 (23:03 -0500)
Support an option to allow users to disable auto-hibern8 feature.

Instead, enable hibern8-during-clk-gating feature to keep similar power
consumption.

Link: https://lore.kernel.org/r/20201029115750.24391-5-stanley.chu@mediatek.com
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufs-mediatek.c
drivers/scsi/ufs/ufs-mediatek.h

index bff613f1d1266c3a13f7037670074a601d0b220e..478774801196870bdac2664ef5e5b4c3e31c1f59 100644 (file)
@@ -158,6 +158,7 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba,
                                     enum ufs_notify_change_status status)
 {
        struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+       unsigned long flags;
 
        if (status == PRE_CHANGE) {
                if (host->unipro_lpm) {
@@ -169,6 +170,17 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba,
 
                if (hba->caps & UFSHCD_CAP_CRYPTO)
                        ufs_mtk_crypto_enable(hba);
+
+               if (host->caps & UFS_MTK_CAP_DISABLE_AH8) {
+                       spin_lock_irqsave(hba->host->host_lock, flags);
+                       ufshcd_writel(hba, 0,
+                                     REG_AUTO_HIBERNATE_IDLE_TIMER);
+                       spin_unlock_irqrestore(hba->host->host_lock,
+                                              flags);
+
+                       hba->capabilities &= ~MASK_AUTO_HIBERN8_SUPPORT;
+                       hba->ahit = 0;
+               }
        }
 
        return 0;
@@ -496,6 +508,9 @@ static void ufs_mtk_init_host_caps(struct ufs_hba *hba)
        if (of_property_read_bool(np, "mediatek,ufs-support-va09"))
                ufs_mtk_init_va09_pwr_ctrl(hba);
 
+       if (of_property_read_bool(np, "mediatek,ufs-disable-ah8"))
+               host->caps |= UFS_MTK_CAP_DISABLE_AH8;
+
        dev_info(hba->dev, "caps: 0x%x", host->caps);
 }
 
@@ -609,6 +624,9 @@ static int ufs_mtk_init(struct ufs_hba *hba)
        hba->caps |= UFSHCD_CAP_WB_EN;
        hba->vps->wb_flush_threshold = UFS_WB_BUF_REMAIN_PERCENT(80);
 
+       if (host->caps & UFS_MTK_CAP_DISABLE_AH8)
+               hba->caps |= UFSHCD_CAP_HIBERN8_WITH_CLK_GATING;
+
        /*
         * ufshcd_vops_init() is invoked after
         * ufshcd_setup_clock(true) in ufshcd_hba_init() thus
index 0e76429f69d6550dafed998f672fd649320a694d..30f45dfce04c72db14e1036c99f3cf4914f6c968 100644 (file)
@@ -96,6 +96,7 @@ enum {
 enum ufs_mtk_host_caps {
        UFS_MTK_CAP_BOOST_CRYPT_ENGINE         = 1 << 0,
        UFS_MTK_CAP_VA09_PWR_CTRL              = 1 << 1,
+       UFS_MTK_CAP_DISABLE_AH8                = 1 << 2,
 };
 
 struct ufs_mtk_crypt_cfg {