regulator: ap72200: avoid keeping EN pin always high

Keeping enable GPIO always high leads to higher power consumption,
even in RBSC, when the regulator is not in use. Toggle GPIO to high
state only when regulator is enabled and toggle it low after regulator
disable to avoid power consumption when the regulator is not in use.

Change-Id: Ic2f9c0ef350051776f094e55e6fb4967b0d45248
Signed-off-by: Jishnu Prakash <quic_jprakash@quicinc.com>
This commit is contained in:
Jishnu Prakash 2024-08-19 18:30:31 +05:30
parent b713dee329
commit d40c483b77

View File

@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. */
/* Copyright (c) 2023-2024, Qualcomm Innovation Center, Inc. All rights reserved. */
#define pr_fmt(fmt) "ap72200-reg: %s: " fmt, __func__
@ -44,6 +44,8 @@ static int ap72200_vreg_enable(struct regulator_dev *rdev)
struct ap72200_vreg *vreg = rdev_get_drvdata(rdev);
int rc, val;
gpiod_set_value_cansleep(vreg->ena_gpiod, 1);
val = DIV_ROUND_UP(vreg->rdesc.fixed_uV - AP72200_MIN_UV, AP72200_STEP_UV);
/* Set the voltage */
@ -82,6 +84,8 @@ static int ap72200_vreg_disable(struct regulator_dev *rdev)
vreg->is_enabled = false;
gpiod_set_value_cansleep(vreg->ena_gpiod, 0);
return rc;
}
@ -157,9 +161,6 @@ static int ap72200_probe(struct i2c_client *client,
return PTR_ERR(vreg->ena_gpiod);
}
/* Keep the EN pin of this regulator always high */
gpiod_set_value_cansleep(vreg->ena_gpiod, 1);
vreg->rdev = devm_regulator_register(vreg->dev, &vreg->rdesc, &reg_config);
if (IS_ERR(vreg->rdev)) {
ret = PTR_ERR(vreg->rdev);