All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch v1 1/1]regulator: fix for DA9055 regulator
@ 2013-06-28  7:05 Ankur Raina
  2013-06-28  9:33 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Ankur Raina @ 2013-06-28  7:05 UTC (permalink / raw)
  To: lgirdwood, broonie; +Cc: sameo, linux-kernel, david.chen

[-- 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 --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch v1 1/1]regulator: fix for DA9055 regulator
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2013-06-28  9:33 UTC (permalink / raw)
  To: Ankur Raina; +Cc: lgirdwood, sameo, linux-kernel, david.chen

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

On Fri, Jun 28, 2013 at 07:05:03AM +0000, Ankur Raina wrote:
> 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.

This needs a much better patch description.  What specifically is the
bug that you are trying to fix here?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch v1 1/1]regulator: fix for DA9055 regulator
  2013-06-28  9:33 ` Mark Brown
@ 2013-06-28 12:53   ` Ankur Raina
  0 siblings, 0 replies; 4+ messages in thread
From: Ankur Raina @ 2013-06-28 12:53 UTC (permalink / raw)
  To: Mark Brown; +Cc: lgirdwood, sameo, linux-kernel, david.chen

On Fri, 2013-06-28 at 10:33 +0100, Mark Brown wrote:
> On Fri, Jun 28, 2013 at 07:05:03AM +0000, Ankur Raina wrote:
> > 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.
> 
> This needs a much better patch description.  What specifically is the
> bug that you are trying to fix here?
The DA9055 hardware supports regulator control through GPIO for all its regulators and bucks.
For this, the contolling GPIO should be set as GPI.The current driver requests gpio for every regulator
that is gpio controlled.This request fails in case of a regulator requesting a gpio, which is already
been assigned to other regulators. The corresponding register update for that regulator also fails.
This patch fixes the above issue.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch v1 1/1]regulator: fix for DA9055 regulator
@ 2013-06-27 14:11 Ankur Raina
  0 siblings, 0 replies; 4+ messages in thread
From: Ankur Raina @ 2013-06-27 14:11 UTC (permalink / raw)
  To: broonie; +Cc: lrg, sameo, linux-kernel, dchen

[-- 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 --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-28 12:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2013-06-27 14:11 Ankur Raina

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.