Skip to content

Commit 0487fff

Browse files
Stanley Chumartinkpetersen
authored andcommitted
scsi: ufs: Fix regulator load and icc-level configuration
Currently if a regulator has "<name>-fixed-regulator" property in device tree, it will skip current limit initialization. This lead to a zero "max_uA" value in struct ufs_vreg. However, "regulator_set_load" operation shall be required on regulators which have valid current limits, otherwise a zero "max_uA" set by "regulator_set_load" may cause unexpected behavior when this regulator is enabled or set as high power mode. Similarly, in device's icc_level configuration flow, the target icc_level shall be updated if regulator also has valid current limit, otherwise a wrong icc_level will be calculated by zero "max_uA" and thus causes unexpected results after it is written to device. Signed-off-by: Stanley Chu <[email protected]> Reviewed-by: Avri Altman <[email protected]> Acked-by: Alim Akhtar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 3b141e8 commit 0487fff

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/scsi/ufs/ufshcd.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6294,19 +6294,19 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
62946294
goto out;
62956295
}
62966296

6297-
if (hba->vreg_info.vcc)
6297+
if (hba->vreg_info.vcc && hba->vreg_info.vcc->max_uA)
62986298
icc_level = ufshcd_get_max_icc_level(
62996299
hba->vreg_info.vcc->max_uA,
63006300
POWER_DESC_MAX_ACTV_ICC_LVLS - 1,
63016301
&desc_buf[PWR_DESC_ACTIVE_LVLS_VCC_0]);
63026302

6303-
if (hba->vreg_info.vccq)
6303+
if (hba->vreg_info.vccq && hba->vreg_info.vccq->max_uA)
63046304
icc_level = ufshcd_get_max_icc_level(
63056305
hba->vreg_info.vccq->max_uA,
63066306
icc_level,
63076307
&desc_buf[PWR_DESC_ACTIVE_LVLS_VCCQ_0]);
63086308

6309-
if (hba->vreg_info.vccq2)
6309+
if (hba->vreg_info.vccq2 && hba->vreg_info.vccq2->max_uA)
63106310
icc_level = ufshcd_get_max_icc_level(
63116311
hba->vreg_info.vccq2->max_uA,
63126312
icc_level,
@@ -7004,6 +7004,15 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
70047004
if (!vreg)
70057005
return 0;
70067006

7007+
/*
7008+
* "set_load" operation shall be required on those regulators
7009+
* which specifically configured current limitation. Otherwise
7010+
* zero max_uA may cause unexpected behavior when regulator is
7011+
* enabled or set as high power mode.
7012+
*/
7013+
if (!vreg->max_uA)
7014+
return 0;
7015+
70077016
ret = regulator_set_load(vreg->reg, ua);
70087017
if (ret < 0) {
70097018
dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n",

0 commit comments

Comments
 (0)