Skip to contentSkip to conversation

scsi: ufs: fix up regulator operations

PATCH Superseded Stanley Chu 1 participant 4 messages Mar 14, 2019 1 message not in the archive

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

Hi,

This patch series tries to clean-up and fix-up regulator operations in ufs driver.

[PATCH 1/2] scsi: ufs: cleanup unused min_uA in struct ufs_vreg
- min_uA in strcut ufs_vreg is not used by any ufs drivers thus remove it.
[PATCH 2/2] scsi: ufs: fix regulator set load and icc-level re-configuration
- Fix up "regulator_set_load" condition and icc_level value during icc_level configuration flow.

Stanley Chu (2):
scsi: ufs: cleanup unused min_uA in struct ufs_vreg
scsi: ufs: fix regulator set load and icc-level configuration

 drivers/scsi/ufs/ufs.h           |  1 -
 drivers/scsi/ufs/ufshcd-pltfrm.c |  1 -
 drivers/scsi/ufs/ufshcd.c        | 15 ++++++++++++---
 3 files changed, 12 insertions(+), 5 deletions(-)

A message that is not in the archive (sent off-list or not yet received): 1552560005-31001-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/[email protected]

#2 lore raw

cover scsi: ufs: fix up regulator operations

Hi,

This patch series tries to clean-up and fix-up regulator operations in ufs driver.

[PATCH 1/2] scsi: ufs: cleanup unused min_uA in struct ufs_vreg
- min_uA in strcut ufs_vreg is not used by any ufs drivers thus remove it.
[PATCH 2/2] scsi: ufs: fix regulator set load and icc-level re-configuration
- Fix up "regulator_set_load" condition and icc_level value during icc_level configuration flow.

Stanley Chu (2):
scsi: ufs: cleanup unused min_uA in struct ufs_vreg
scsi: ufs: fix regulator set load and icc-level configuration

 drivers/scsi/ufs/ufs.h           |  1 -
 drivers/scsi/ufs/ufshcd-pltfrm.c |  1 -
 drivers/scsi/ufs/ufshcd.c        | 15 ++++++++++++---
 3 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
2.18.0
#3 lore raw

PATCH 1/2 scsi: ufs: cleanup unused min_uA in struct ufs_vreg

In reply to a message not in the archive

min_uA in strcut ufs_vreg is not used by any ufs
drivers thus remove it.

---
 drivers/scsi/ufs/ufs.h           | 1 -
 drivers/scsi/ufs/ufshcd-pltfrm.c | 1 -
 2 files changed, 2 deletions(-)
drivers/scsi/ufs/ufs.h +0 -1
index 7da7318eb6a6..0f23ac80bacd 100644
@@ -516,7 +516,6 @@ struct ufs_vreg {
 	bool enabled;
 	int min_uV;
 	int max_uV;
-	int min_uA;
 	int max_uA;
 };
 
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -1
index 895a9b5ac989..588079286e8a 100644
@@ -164,7 +164,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 		goto out;
 	}
 
-	vreg->min_uA = 0;
 	if (!strcmp(name, "vcc")) {
 		if (of_property_read_bool(np, "vcc-supply-1p8")) {
 			vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
Signature · 1 line
2.18.0
#4 lore raw

PATCH 2/2 scsi: ufs: fix regulator set load and icc-level configuration

In reply to a message not in the archive

Currently if a regulator has "<name>-fixed-regulator" property in device tree, it will skip "max_uA" configuration.

However, "regulator_set_load" operation shall be required on those regulators which specifically configured current limitation, i.e., "max_uA". Otherwise zero max_uA value may cause unexpected behavior when this regulator is enabled or set as high power mode.

Similarly, in icc_level configuration flow, icc_level shall be updated if specified regulator has configured "max_uA", otherwise wrong icc_level may be written to device and cause unexpected results.

---
 drivers/scsi/ufs/ufshcd.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufshcd.c +12 -3
index 8b9a01073d62..61cdae74de62 100644
@@ -6279,19 +6279,19 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
 		goto out;
 	}
 
-	if (hba->vreg_info.vcc)
+	if (hba->vreg_info.vcc && hba->vreg_info.vcc->max_uA)
 		icc_level = ufshcd_get_max_icc_level(
 				hba->vreg_info.vcc->max_uA,
 				POWER_DESC_MAX_ACTV_ICC_LVLS - 1,
 				&desc_buf[PWR_DESC_ACTIVE_LVLS_VCC_0]);
 
-	if (hba->vreg_info.vccq)
+	if (hba->vreg_info.vccq && hba->vreg_info.vccq->max_uA)
 		icc_level = ufshcd_get_max_icc_level(
 				hba->vreg_info.vccq->max_uA,
 				icc_level,
 				&desc_buf[PWR_DESC_ACTIVE_LVLS_VCCQ_0]);
 
-	if (hba->vreg_info.vccq2)
+	if (hba->vreg_info.vccq2 && hba->vreg_info.vccq2->max_uA)
 		icc_level = ufshcd_get_max_icc_level(
 				hba->vreg_info.vccq2->max_uA,
 				icc_level,
@@ -6989,6 +6989,15 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
 	if (!vreg)
 		return 0;
 
+	/*
+	 * "set_load" operation shall be required on those regulators
+	 * which specifically configured current limitation. Otherwise
+	 * zero max_uA may cause unexpected behavior when regulator is
+	 * enabled or set as high power mode.
+	 */
+	if (!vreg->max_uA)
+		return 0;
+
 	ret = regulator_set_load(vreg->reg, ua);
 	if (ret < 0) {
 		dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n",
Signature · 1 line
2.18.0