[<prev] [next>] [day] [month] [year] [list]
Message-ID: <A874F61F95741C4A9BA573A70FE3998F69E122A2@DQHE02.ent.ti.com>
Date: Thu, 10 Jan 2013 09:46:10 +0000
From: "Kim, Milo" <Milo.Kim@...com>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>
CC: Axel Lin <axel.lin@...ics.com>, "Girdwood, Liam" <lrg@...com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 1/3] regulator-core: support multiple enable GPIO
This patch fixes a limitation in case of multiple enable pin usages.
Several regulators can be enabled/disabled at the same time by one
shared GPIO pin.
If specific GPIO pin is already used, then skip requesting the GPIO.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@...com>
---
drivers/regulator/core.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index de47880..21b4247 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1456,6 +1456,23 @@ void devm_regulator_put(struct regulator *regulator)
}
EXPORT_SYMBOL_GPL(devm_regulator_put);
+static int regulator_enable_gpio_request(struct regulator_dev *rdev,
+ const struct regulator_config *config)
+{
+ struct regulator_dev *r;
+ int gpio = config->ena_gpio;
+
+ list_for_each_entry(r, ®ulator_list, list) {
+ if (r->ena_gpio == gpio) {
+ rdev_info(rdev, "GPIO %d is already used\n", gpio);
+ return 0;
+ }
+ }
+
+ return gpio_request_one(gpio, GPIOF_DIR_OUT | config->ena_gpio_flags,
+ rdev_get_name(rdev));
+}
+
static int _regulator_do_enable(struct regulator_dev *rdev)
{
int ret, delay;
@@ -3420,9 +3437,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
dev_set_drvdata(&rdev->dev, rdev);
if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) {
- ret = gpio_request_one(config->ena_gpio,
- GPIOF_DIR_OUT | config->ena_gpio_flags,
- rdev_get_name(rdev));
+ ret = regulator_enable_gpio_request(rdev, config);
if (ret != 0) {
rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
config->ena_gpio, ret);
--
1.7.9.5
Best Regards,
Milo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists