diff mbox series

[v4,2/8] scsi: ufs: set load before setting voltage in regulators

Message ID 1579764349-15578-3-git-send-email-cang@codeaurora.org (mailing list archive)
State Superseded
Headers show
Series UFS driver general fixes bundle 4 | expand

Commit Message

Can Guo Jan. 23, 2020, 7:25 a.m. UTC
From: Asutosh Das <asutoshd@codeaurora.org>

This sequence change is required to avoid dips in voltage
during boot-up.

Apparently, this dip is caused because in the original
sequence, the regulators are initialized in lpm mode.
And then when the load is set to high, and more current
is drawn, than is allowed in lpm, the dip is seen.

Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
---
 drivers/scsi/ufs/ufshcd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

hongwus@codeaurora.org Jan. 23, 2020, 7:50 a.m. UTC | #1
Hi Can,
   It makes sense that set the load before enable regulator or set 
voltage. Just avoid voltage drop.

On 2020-01-23 15:25, Can Guo wrote:
> From: Asutosh Das <asutoshd@codeaurora.org>
> 
> This sequence change is required to avoid dips in voltage
> during boot-up.
> 
> Apparently, this dip is caused because in the original
> sequence, the regulators are initialized in lpm mode.
> And then when the load is set to high, and more current
> is drawn, than is allowed in lpm, the dip is seen.
> 
> Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
> Signed-off-by: Can Guo <cang@codeaurora.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index c2de29f..c386c2d 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -7225,6 +7225,11 @@ static int ufshcd_config_vreg(struct device 
> *dev,
>  	name = vreg->name;
> 
>  	if (regulator_count_voltages(reg) > 0) {
> +		uA_load = on ? vreg->max_uA : 0;
> +		ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
> +		if (ret)
> +			goto out;
> +
>  		if (vreg->min_uV && vreg->max_uV) {
>  			min_uV = on ? vreg->min_uV : 0;
>  			ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
> @@ -7235,11 +7240,6 @@ static int ufshcd_config_vreg(struct device 
> *dev,
>  				goto out;
>  			}
>  		}
> -
> -		uA_load = on ? vreg->max_uA : 0;
> -		ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
> -		if (ret)
> -			goto out;
>  	}
>  out:
>  	return ret;


Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c2de29f..c386c2d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7225,6 +7225,11 @@  static int ufshcd_config_vreg(struct device *dev,
 	name = vreg->name;
 
 	if (regulator_count_voltages(reg) > 0) {
+		uA_load = on ? vreg->max_uA : 0;
+		ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
+		if (ret)
+			goto out;
+
 		if (vreg->min_uV && vreg->max_uV) {
 			min_uV = on ? vreg->min_uV : 0;
 			ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
@@ -7235,11 +7240,6 @@  static int ufshcd_config_vreg(struct device *dev,
 				goto out;
 			}
 		}
-
-		uA_load = on ? vreg->max_uA : 0;
-		ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
-		if (ret)
-			goto out;
 	}
 out:
 	return ret;