Skip to content

Commit 07d2290

Browse files
Nitin Rawatmartinkpetersen
authored andcommitted
scsi: ufs: qcom: Update MAX_CORE_CLK_1US_CYCLES for UFS V4 and above
UFS Controller V4 and above, the register layout for DME_VS_CORE_CLK_CTRL register has changed. MAX_CORE_CLK_1US_CYCLES offset has changed from 0 to 0x10 and length of attrbute is changed from 8bit to 12bit. Add support to configure MAX_CORE_CLK_1US_CYCLES for UFS V4 and above as per new register layout. Co-developed-by: Naveen Kumar Goud Arepalli <[email protected]> Signed-off-by: Naveen Kumar Goud Arepalli <[email protected]> Signed-off-by: Nitin Rawat <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Can Guo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 0bb80ec commit 07d2290

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

drivers/ufs/host/ufs-qcom.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,20 +1299,28 @@ static void ufs_qcom_exit(struct ufs_hba *hba)
12991299
static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba *hba,
13001300
u32 clk_cycles)
13011301
{
1302+
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
13021303
int err;
13031304
u32 core_clk_ctrl_reg;
13041305

1305-
if (clk_cycles > DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK)
1306-
return -EINVAL;
1307-
13081306
err = ufshcd_dme_get(hba,
13091307
UIC_ARG_MIB(DME_VS_CORE_CLK_CTRL),
13101308
&core_clk_ctrl_reg);
13111309
if (err)
13121310
return err;
13131311

1314-
core_clk_ctrl_reg &= ~DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK;
1315-
core_clk_ctrl_reg |= clk_cycles;
1312+
/* Bit mask is different for UFS host controller V4.0.0 onwards */
1313+
if (host->hw_ver.major >= 4) {
1314+
if (!FIELD_FIT(CLK_1US_CYCLES_MASK_V4, clk_cycles))
1315+
return -ERANGE;
1316+
core_clk_ctrl_reg &= ~CLK_1US_CYCLES_MASK_V4;
1317+
core_clk_ctrl_reg |= FIELD_PREP(CLK_1US_CYCLES_MASK_V4, clk_cycles);
1318+
} else {
1319+
if (!FIELD_FIT(CLK_1US_CYCLES_MASK, clk_cycles))
1320+
return -ERANGE;
1321+
core_clk_ctrl_reg &= ~CLK_1US_CYCLES_MASK;
1322+
core_clk_ctrl_reg |= FIELD_PREP(CLK_1US_CYCLES_MASK, clk_cycles);
1323+
}
13161324

13171325
/* Clear CORE_CLK_DIV_EN */
13181326
core_clk_ctrl_reg &= ~DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT;

drivers/ufs/host/ufs-qcom.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ enum {
129129
#define PA_VS_CONFIG_REG1 0x9000
130130
#define DME_VS_CORE_CLK_CTRL 0xD002
131131
/* bit and mask definitions for DME_VS_CORE_CLK_CTRL attribute */
132-
#define DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT BIT(8)
133-
#define DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK 0xFF
132+
#define CLK_1US_CYCLES_MASK_V4 GENMASK(27, 16)
133+
#define CLK_1US_CYCLES_MASK GENMASK(7, 0)
134+
#define DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT BIT(8)
134135

135136
static inline void
136137
ufs_qcom_get_controller_revision(struct ufs_hba *hba,

0 commit comments

Comments
 (0)