All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ankur Raina <Ankur.Raina@kpitcummins.com>
To: "broonie@opensource.wolfsonmicro.com" 
	<broonie@opensource.wolfsonmicro.com>
Cc: "lrg@ti.com" <lrg@ti.com>,
	"sameo@linux.intel.com" <sameo@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dchen@diasemi.com" <dchen@diasemi.com>
Subject: [patch v1 1/1]regulator: fix for DA9055 regulator
Date: Thu, 27 Jun 2013 14:11:44 +0000	[thread overview]
Message-ID: <4B6D9C89CD8BA349A71B74CA32C47E5850DA82B7@KCHJEXMB02.kpit.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3621 bytes --]

This patch adds support for usage of GPIO's by multiple bucks and regulators
of DA9055 for enable-disable and voltage set selection.Without this patch regulator
control through GPIO would fail for more than one regulator/buck.

Signed-off-by: Ankur <Ankur.Raina@kpitcummins.com>
---
 drivers/regulator/da9055-regulator.c |   73 +++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c
index 3022109..889a2b8 100644
--- a/drivers/regulator/da9055-regulator.c
+++ b/drivers/regulator/da9055-regulator.c
@@ -44,6 +44,10 @@
 #define DA9055_ID_LDO5		6
 #define DA9055_ID_LDO6		7
 
+/* Max Gpio's Controlling Regulators */
+#define MAX_GPIO_LDO		2
+#define GPI_NAME_LENGTH		18
+
 /* DA9055 BUCK current limit */
 static const int da9055_current_limits[] = { 500000, 600000, 700000, 800000 };
 
@@ -445,24 +449,30 @@ static int da9055_gpio_init(struct da9055_regulator *regulator,
 {
 	struct da9055_regulator_info *info = regulator->info;
 	int ret = 0;
+	static int alloc_gpio, req_gpio[MAX_GPIO_LDO];
+	char name[GPI_NAME_LENGTH];
 
-	if (pdata->gpio_ren && pdata->gpio_ren[id]) {
-		char name[18];
-		int gpio_mux = pdata->gpio_ren[id];
-
-		config->ena_gpio = pdata->ena_gpio[id];
-		config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
-		config->ena_gpio_invert = 1;
-
+	if (pdata->gpio_rsel && pdata->gpio_rsel[id]) {
 		/*
-		 * GPI pin is muxed with regulator to control the
-		 * regulator state.
+		 * Verify whether GPIO's to be requested are not
+		 * allocated before
 		 */
-		sprintf(name, "DA9055 GPI %d", gpio_mux);
-		ret = devm_gpio_request_one(config->dev, gpio_mux, GPIOF_DIR_IN,
-					    name);
-		if (ret < 0)
-			goto err;
+		if ((pdata->gpio_rsel[id] != req_gpio[0]
+		&& pdata->gpio_rsel[id] != req_gpio[1]) &&
+		(alloc_gpio < MAX_GPIO_LDO)) {
+			/*
+			 * GPI pin is muxed with regulator to control the
+			 * regulator state.
+			 */
+			sprintf(name, "DA9055 GPI %d", pdata->gpio_rsel[id]);
+			ret = devm_gpio_request_one(config->dev,
+						    pdata->gpio_rsel[id],
+						    GPIOF_DIR_IN, name);
+			if (ret < 0)
+				goto err;
+			req_gpio[alloc_gpio] = pdata->gpio_rsel[id];
+			alloc_gpio++;
+		}
 
 		/*
 		 * Let the regulator know that its state is controlled
@@ -476,21 +486,28 @@ static int da9055_gpio_init(struct da9055_regulator *regulator,
 			goto err;
 	}
 
-	if (pdata->gpio_rsel && pdata->gpio_rsel[id]) {
-		char name[18];
-		int gpio_mux = pdata->gpio_rsel[id];
-
-		regulator->reg_rselect = pdata->reg_rsel[id];
-
+	if (pdata->gpio_ren && pdata->gpio_ren[id]) {
 		/*
-		 * GPI pin is muxed with regulator to select the
-		 * regulator register set A/B for voltage ramping.
+		 * Verify whether GPIO's to be requested are not
+		 * allocated before
 		 */
-		sprintf(name, "DA9055 GPI %d", gpio_mux);
-		ret = devm_gpio_request_one(config->dev, gpio_mux, GPIOF_DIR_IN,
-					    name);
-		if (ret < 0)
-			goto err;
+		if ((pdata->gpio_ren[id] != req_gpio[0]
+		&& pdata->gpio_ren[id] != req_gpio[1]) &&
+		(alloc_gpio < MAX_GPIO_LDO)) {
+			regulator->reg_rselect = pdata->reg_rsel[id];
+			/*
+			 * GPI pin is muxed with regulator to select the
+			 * regulator register set A/B for voltage ramping.
+			 */
+			sprintf(name, "DA9055 GPI %d", pdata->gpio_ren[id]);
+			ret = devm_gpio_request_one(config->dev,
+						    pdata->gpio_ren[id],
+						    GPIOF_DIR_IN, name);
+			if (ret < 0)
+				goto err;
+			req_gpio[alloc_gpio] = pdata->gpio_ren[id];
+			alloc_gpio++;
+		}
 
 		/*
 		 * Let the regulator know that its register set A/B
-- 
1.7.1





[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 4446 bytes --]

             reply	other threads:[~2013-06-27 14:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27 14:11 Ankur Raina [this message]
2013-06-28  7:05 [patch v1 1/1]regulator: fix for DA9055 regulator Ankur Raina
2013-06-28  9:33 ` Mark Brown
2013-06-28 12:53   ` Ankur Raina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B6D9C89CD8BA349A71B74CA32C47E5850DA82B7@KCHJEXMB02.kpit.com \
    --to=ankur.raina@kpitcummins.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=dchen@diasemi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.