You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/08/10 15:17:58 UTC
[nuttx] 01/04: regulator:support always on
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 67aa12e762cb1709da830df08b6fd0bc04d59f60
Author: dulibo1 <du...@xiaomi.com>
AuthorDate: Thu Jul 13 20:47:13 2023 +0800
regulator:support always on
when add always on desc,the regulator is always enabled
Signed-off-by: dulibo1 <du...@xiaomi.com>
---
drivers/power/supply/regulator.c | 13 ++++++++++---
include/nuttx/power/regulator.h | 1 +
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/regulator.c b/drivers/power/supply/regulator.c
index 04c2ad3589..91fee66a6e 100644
--- a/drivers/power/supply/regulator.c
+++ b/drivers/power/supply/regulator.c
@@ -521,6 +521,11 @@ int regulator_is_enabled(FAR struct regulator_s *regulator)
rdev = regulator->rdev;
+ if (rdev->desc->always_on)
+ {
+ return 1;
+ }
+
nxmutex_lock(&rdev->regulator_lock);
ret = _regulator_is_enabled(rdev);
nxmutex_unlock(&rdev->regulator_lock);
@@ -634,7 +639,7 @@ int regulator_disable(FAR struct regulator_s *regulator)
goto err;
}
- if (rdev->use_count == 1)
+ if (rdev->use_count == 1 && !rdev->desc->always_on)
{
ret = _regulator_do_disable(rdev);
if (ret < 0)
@@ -813,11 +818,13 @@ regulator_register(FAR const struct regulator_desc_s *regulator_desc,
list_initialize(&rdev->consumer_list);
list_initialize(&rdev->list);
- if (rdev->desc->boot_on && !_regulator_is_enabled(rdev))
+ if ((rdev->desc->boot_on || rdev->desc->always_on)
+ && !_regulator_is_enabled(rdev))
{
_regulator_do_enable(rdev);
}
- else if (!rdev->desc->boot_on && _regulator_is_enabled(rdev))
+ else if (!rdev->desc->boot_on && !rdev->desc->always_on
+ && _regulator_is_enabled(rdev))
{
_regulator_do_disable(rdev);
}
diff --git a/include/nuttx/power/regulator.h b/include/nuttx/power/regulator.h
index 7a63583859..c973fa2a54 100644
--- a/include/nuttx/power/regulator.h
+++ b/include/nuttx/power/regulator.h
@@ -97,6 +97,7 @@ struct regulator_desc_s
unsigned int boot_on; /* true if this regulator is to be enabled
* at power up/reset
*/
+ unsigned int always_on;
};
struct regulator_dev_s