Skip to content

Commit 5a6f304

Browse files
Nitin Rawatmartinkpetersen
authored andcommitted
scsi: ufs: ufs-qcom: Enable QUnipro Internal Clock Gating
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent c496016 commit 5a6f304

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

drivers/ufs/host/ufs-qcom.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,32 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
552552
*/
553553
static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba)
554554
{
555+
int err;
556+
557+
/* Enable UTP internal clock gating */
555558
ufshcd_rmwl(hba, REG_UFS_CFG2_CGC_EN_ALL, REG_UFS_CFG2_CGC_EN_ALL,
556559
REG_UFS_CFG2);
557560

558561
/* Ensure that HW clock gating is enabled before next operations */
559562
ufshcd_readl(hba, REG_UFS_CFG2);
563+
564+
/* Enable Unipro internal clock gating */
565+
err = ufshcd_dme_rmw(hba, DL_VS_CLK_CFG_MASK,
566+
DL_VS_CLK_CFG_MASK, DL_VS_CLK_CFG);
567+
if (err)
568+
goto out;
569+
570+
err = ufshcd_dme_rmw(hba, PA_VS_CLK_CFG_REG_MASK,
571+
PA_VS_CLK_CFG_REG_MASK, PA_VS_CLK_CFG_REG);
572+
if (err)
573+
goto out;
574+
575+
err = ufshcd_dme_rmw(hba, DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN,
576+
DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN,
577+
DME_VS_CORE_CLK_CTRL);
578+
out:
579+
if (err)
580+
dev_err(hba->dev, "hw clk gating enabled failed\n");
560581
}
561582

562583
static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba,

drivers/ufs/host/ufs-qcom.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424

2525
#define UFS_QCOM_LIMIT_HS_RATE PA_HS_MODE_B
2626

27+
/* bit and mask definitions for PA_VS_CLK_CFG_REG attribute */
28+
#define PA_VS_CLK_CFG_REG 0x9004
29+
#define PA_VS_CLK_CFG_REG_MASK GENMASK(8, 0)
30+
31+
/* bit and mask definitions for DL_VS_CLK_CFG attribute */
32+
#define DL_VS_CLK_CFG 0xA00B
33+
#define DL_VS_CLK_CFG_MASK GENMASK(9, 0)
34+
#define DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN BIT(9)
35+
2736
/* QCOM UFS host controller vendor specific registers */
2837
enum {
2938
REG_UFS_SYS1CLK_1US = 0xC0,

0 commit comments

Comments
 (0)