]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: ufs: ufs-qcom: Enable QUnipro Internal Clock Gating
authorNitin Rawat <quic_nitirawa@quicinc.com>
Mon, 14 Jul 2025 07:53:36 +0000 (13:23 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 14 Jul 2025 22:25:10 +0000 (18:25 -0400)
Enable internal clock gating for Qualcomm UFS host controller by setting
the following attributes to 1 during host controller initialization:

 - DL_VS_CLK_CFG
 - PA_VS_CLK_CFG_REG
 - DME_VS_CORE_CLK_CTRL.DME_HW_CGC_EN

This change is necessary to support the internal clock gating mechanism
in Qualcomm UFS host controller. This is power saving feature and hence
driver can continue to function correctly despite any error in enabling
these feature.

Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Link: https://lore.kernel.org/r/20250714075336.2133-4-quic_nitirawa@quicinc.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/host/ufs-qcom.c
drivers/ufs/host/ufs-qcom.h

index 53301a2c27be18d12d7afb620eb682ab69c7b497..2a72e7c1d13161ebb609d8bb0dad8ed730e73d63 100644 (file)
@@ -552,11 +552,32 @@ out_disable_phy:
  */
 static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba)
 {
+       int err;
+
+       /* Enable UTP internal clock gating */
        ufshcd_rmwl(hba, REG_UFS_CFG2_CGC_EN_ALL, REG_UFS_CFG2_CGC_EN_ALL,
                    REG_UFS_CFG2);
 
        /* Ensure that HW clock gating is enabled before next operations */
        ufshcd_readl(hba, REG_UFS_CFG2);
+
+       /* Enable Unipro internal clock gating */
+       err = ufshcd_dme_rmw(hba, DL_VS_CLK_CFG_MASK,
+                            DL_VS_CLK_CFG_MASK, DL_VS_CLK_CFG);
+       if (err)
+               goto out;
+
+       err = ufshcd_dme_rmw(hba, PA_VS_CLK_CFG_REG_MASK,
+                            PA_VS_CLK_CFG_REG_MASK, PA_VS_CLK_CFG_REG);
+       if (err)
+               goto out;
+
+       err = ufshcd_dme_rmw(hba, DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN,
+                            DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN,
+                            DME_VS_CORE_CLK_CTRL);
+out:
+       if (err)
+               dev_err(hba->dev, "hw clk gating enabled failed\n");
 }
 
 static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba,
index 0a5cfc2dd4f7d999dac9cbd671a078a65f877b68..e0e129af7c16b55c84d4a0ac52703da9bcc84db5 100644 (file)
 
 #define UFS_QCOM_LIMIT_HS_RATE         PA_HS_MODE_B
 
+/* bit and mask definitions for PA_VS_CLK_CFG_REG attribute */
+#define PA_VS_CLK_CFG_REG      0x9004
+#define PA_VS_CLK_CFG_REG_MASK GENMASK(8, 0)
+
+/* bit and mask definitions for DL_VS_CLK_CFG attribute */
+#define DL_VS_CLK_CFG          0xA00B
+#define DL_VS_CLK_CFG_MASK GENMASK(9, 0)
+#define DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN             BIT(9)
+
 /* QCOM UFS host controller vendor specific registers */
 enum {
        REG_UFS_SYS1CLK_1US                 = 0xC0,