diff --git a/drivers/st/regulator/regulator_core.c b/drivers/st/regulator/regulator_core.c index 94b3ceff7..5cc832915 100644 --- a/drivers/st/regulator/regulator_core.c +++ b/drivers/st/regulator/regulator_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, STMicroelectronics - All Rights Reserved + * Copyright (c) 2021-2022, STMicroelectronics - All Rights Reserved * * SPDX-License-Identifier: BSD-3-Clause */ @@ -156,6 +156,10 @@ int regulator_disable(struct rdev *rdev) assert(rdev != NULL); + if (rdev->flags & REGUL_ALWAYS_ON) { + return 0; + } + ret = __regulator_set_state(rdev, STATE_DISABLE); udelay(rdev->enable_ramp_delay); @@ -412,6 +416,21 @@ int regulator_set_flag(struct rdev *rdev, uint16_t flag) return 0; } +static int parse_properties(const void *fdt, struct rdev *rdev, int node) +{ + int ret; + + if (fdt_getprop(fdt, node, "regulator-always-on", NULL) != NULL) { + VERBOSE("%s: set regulator-always-on\n", rdev->desc->node_name); + ret = regulator_set_flag(rdev, REGUL_ALWAYS_ON); + if (ret != 0) { + return ret; + } + } + + return 0; +} + /* * Parse the device-tree for a regulator * @@ -476,6 +495,11 @@ static int parse_dt(struct rdev *rdev, int node) return ret; } + ret = parse_properties(fdt, rdev, node); + if (ret != 0) { + return ret; + } + return 0; }