Skip to content

Commit b99a506

Browse files
Merge patch series "ufs: ufs-qcom: Align programming sequence as per HW spec"
Nitin Rawat <[email protected]> says: This patch series adds programming support for Qualcomm UFS to align with Hardware Specification. In this patch series below changes are taken care. 1. Enable QUnipro Internal Clock Gating 2. Update esi_vec_mask for HW major version >= 6 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
2 parents 063bec4 + 5a6f304 commit b99a506

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4272,6 +4272,30 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
42724272
}
42734273
EXPORT_SYMBOL_GPL(ufshcd_dme_get_attr);
42744274

4275+
/**
4276+
* ufshcd_dme_rmw - get modify set a DME attribute
4277+
* @hba: per adapter instance
4278+
* @mask: indicates which bits to clear from the value that has been read
4279+
* @val: actual value to write
4280+
* @attr: dme attribute
4281+
*/
4282+
int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask,
4283+
u32 val, u32 attr)
4284+
{
4285+
u32 cfg = 0;
4286+
int err;
4287+
4288+
err = ufshcd_dme_get(hba, UIC_ARG_MIB(attr), &cfg);
4289+
if (err)
4290+
return err;
4291+
4292+
cfg &= ~mask;
4293+
cfg |= (val & mask);
4294+
4295+
return ufshcd_dme_set(hba, UIC_ARG_MIB(attr), cfg);
4296+
}
4297+
EXPORT_SYMBOL_GPL(ufshcd_dme_rmw);
4298+
42754299
/**
42764300
* ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power
42774301
* state) and waits for it to take effect.

drivers/ufs/host/ufs-qcom.c

Lines changed: 22 additions & 2 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,
@@ -2109,8 +2130,7 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
21092130

21102131
retain_and_null_ptr(qi);
21112132

2112-
if (host->hw_ver.major == 6 && host->hw_ver.minor == 0 &&
2113-
host->hw_ver.step == 0) {
2133+
if (host->hw_ver.major >= 6) {
21142134
ufshcd_rmwl(hba, ESI_VEC_MASK, FIELD_PREP(ESI_VEC_MASK, MAX_ESI_VEC - 1),
21152135
REG_UFS_CFG3);
21162136
}

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,

include/ufs/ufshcd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ void ufshcd_resume_complete(struct device *dev);
14801480
bool ufshcd_is_hba_active(struct ufs_hba *hba);
14811481
void ufshcd_pm_qos_init(struct ufs_hba *hba);
14821482
void ufshcd_pm_qos_exit(struct ufs_hba *hba);
1483+
int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask, u32 val, u32 attr);
14831484

14841485
/* Wrapper functions for safely calling variant operations */
14851486
static inline int ufshcd_vops_init(struct ufs_hba *hba)

0 commit comments

Comments
 (0)