]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: ufs: ufs-mediatek: Prevent host hang by setting CLK_CG early
authorPeter Wang <peter.wang@mediatek.com>
Thu, 23 Jun 2022 03:50:47 +0000 (11:50 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 28 Jun 2022 03:17:36 +0000 (23:17 -0400)
Some UFSHCI hosts in MediaTek UFS platform need workaround to prevent host
hang issue by setting CLK_CG bit before host is enabled.

This operation shall have no side effect on those platforms which do not
support this bit.

Link: https://lore.kernel.org/r/20220623035052.18802-4-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@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 b8f2a74d2a5143e5dbfdda8608f3e740b41ea1b1..b15351c2235bf80d6c37ad227287d86b26d272d0 100644 (file)
@@ -183,6 +183,14 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba,
                        hba->capabilities &= ~MASK_AUTO_HIBERN8_SUPPORT;
                        hba->ahit = 0;
                }
+
+               /*
+                * Turn on CLK_CG early to bypass abnormal ERR_CHK signal
+                * to prevent host hang issue
+                */
+               ufshcd_writel(hba,
+                             ufshcd_readl(hba, REG_UFS_XOUFS_CTRL) | 0x80,
+                             REG_UFS_XOUFS_CTRL);
        }
 
        return 0;
index 49a2137fb2519d3906b70e2d7f615b308b881fb6..f5c1c643dd52a8192e04c6dfe8e0d287b99752d9 100644 (file)
@@ -12,6 +12,7 @@
 /*
  * Vendor specific UFSHCI Registers
  */
+#define REG_UFS_XOUFS_CTRL          0x140
 #define REG_UFS_REFCLK_CTRL         0x144
 #define REG_UFS_EXTREG              0x2100
 #define REG_UFS_MPHYCTRL            0x2200