linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] regulator: fixed: Support for open drain gpio pin
@ 2012-03-07 10:28 Laxman Dewangan
  2012-03-07 10:55 ` Mark Brown
  2012-04-02 22:18 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Laxman Dewangan @ 2012-03-07 10:28 UTC (permalink / raw)
  To: lrg, broonie; +Cc: linux-kernel, linux-tegra, ldewanagn, Laxman Dewangan

Adding flag on fixed regulator board configuration structure
to specify whether gpio is open drain type or not.
Passing this information to gpio library when requesting
gpio so that gpio driver can set the pin state accordingly,
for open drain type:
- Pin can be set HIGH as setting as input, PULL UP on
  pin make this as HIGH.
- Pin can be set LOW as setting it as output and drive to LOW.

The non-open drain pin can be  set HIGH/LOW by setting it to
output and driving it to HIGH/LOW.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
This is the continuation of effort on supporting open drain gpio
which was discussed in patch V1.
[PATCH V1] regulator: fixed: Support for open-drain gpio
The changes from V1:
The open drain support is added in gpo library and hence in place
of handling open drain condition in the fixed regulator, passing
appropriate flag to gpio driver library to handle this condition
in gpio driver.

 drivers/regulator/fixed.c       |   24 +++++++++++-------------
 include/linux/regulator/fixed.h |    7 +++++++
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 40f3803..13a3d2c 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -201,6 +201,7 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 	drvdata->startup_delay = config->startup_delay;
 
 	if (gpio_is_valid(config->gpio)) {
+		int gpio_flag;
 		drvdata->enable_high = config->enable_high;
 
 		/* FIXME: Remove below print warning
@@ -218,29 +219,26 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 			dev_warn(&pdev->dev,
 				"using GPIO 0 for regulator enable control\n");
 
-		ret = gpio_request(config->gpio, config->supply_name);
-		if (ret) {
-			dev_err(&pdev->dev,
-			   "Could not obtain regulator enable GPIO %d: %d\n",
-							config->gpio, ret);
-			goto err_name;
-		}
-
-		/* set output direction without changing state
+		/*
+		 * set output direction without changing state
 		 * to prevent glitch
 		 */
 		drvdata->is_enabled = config->enabled_at_boot;
 		ret = drvdata->is_enabled ?
 				config->enable_high : !config->enable_high;
+		gpio_flag = ret ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
+
+		if (config->gpio_is_open_drain)
+			gpio_flag |= GPIOF_OPEN_DRAIN;
 
-		ret = gpio_direction_output(config->gpio, ret);
+		ret = gpio_request_one(config->gpio, gpio_flag,
+						config->supply_name);
 		if (ret) {
 			dev_err(&pdev->dev,
-			   "Could not configure regulator enable GPIO %d direction: %d\n",
+			   "Could not obtain regulator enable GPIO %d: %d\n",
 							config->gpio, ret);
-			goto err_gpio;
+			goto err_name;
 		}
-
 	} else {
 		/* Regulator without GPIO control is considered
 		 * always enabled
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h
index 936a7d8..f83f744 100644
--- a/include/linux/regulator/fixed.h
+++ b/include/linux/regulator/fixed.h
@@ -26,6 +26,12 @@ struct regulator_init_data;
  * @gpio:		GPIO to use for enable control
  * 			set to -EINVAL if not used
  * @startup_delay:	Start-up time in microseconds
+ * @gpio_is_open_drain: Gpio pin is open drain or normal type.
+ *			If it is open drain type then HIGH will be set
+ *			through PULL-UP with setting gpio as input
+ *			and low will be set as gpio-output with driven
+ *			to low. For non-open-drain case, the gpio will
+ *			will be in output and drive to low/high accordingly.
  * @enable_high:	Polarity of enable GPIO
  *			1 = Active high, 0 = Active low
  * @enabled_at_boot:	Whether regulator has been enabled at
@@ -43,6 +49,7 @@ struct fixed_voltage_config {
 	int microvolts;
 	int gpio;
 	unsigned startup_delay;
+	unsigned gpio_is_open_drain:1;
 	unsigned enable_high:1;
 	unsigned enabled_at_boot:1;
 	struct regulator_init_data *init_data;
-- 
1.7.1.1


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

* Re: [PATCH V2] regulator: fixed: Support for open drain gpio pin
  2012-03-07 10:28 [PATCH V2] regulator: fixed: Support for open drain gpio pin Laxman Dewangan
@ 2012-03-07 10:55 ` Mark Brown
  2012-04-02 22:18 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-03-07 10:55 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: lrg, linux-kernel, linux-tegra, ldewanagn

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

On Wed, Mar 07, 2012 at 03:58:33PM +0530, Laxman Dewangan wrote:
> Adding flag on fixed regulator board configuration structure
> to specify whether gpio is open drain type or not.

This looks good, I'll apply it after the next merge window - it'll need
to wait for the GPIO side of things to be merged up via Linus' tree.

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

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

* Re: [PATCH V2] regulator: fixed: Support for open drain gpio pin
  2012-03-07 10:28 [PATCH V2] regulator: fixed: Support for open drain gpio pin Laxman Dewangan
  2012-03-07 10:55 ` Mark Brown
@ 2012-04-02 22:18 ` Mark Brown
  2012-04-03  5:17   ` Laxman Dewangan
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-04-02 22:18 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: lrg, linux-kernel, linux-tegra, ldewanagn

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

On Wed, Mar 07, 2012 at 03:58:33PM +0530, Laxman Dewangan wrote:
> Adding flag on fixed regulator board configuration structure
> to specify whether gpio is open drain type or not.

Applied, but I had to fix up some conflicts caused by other development
that had happened in the meantime.  Please check that I resolved those
correctly.

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

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

* Re: [PATCH V2] regulator: fixed: Support for open drain gpio pin
  2012-04-02 22:18 ` Mark Brown
@ 2012-04-03  5:17   ` Laxman Dewangan
  0 siblings, 0 replies; 4+ messages in thread
From: Laxman Dewangan @ 2012-04-03  5:17 UTC (permalink / raw)
  To: Mark Brown; +Cc: lrg, linux-kernel, linux-tegra, ldewanagn

On Tuesday 03 April 2012 03:48 AM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Wed, Mar 07, 2012 at 03:58:33PM +0530, Laxman Dewangan wrote:
>> Adding flag on fixed regulator board configuration structure
>> to specify whether gpio is open drain type or not.
> Applied, but I had to fix up some conflicts caused by other development
> that had happened in the meantime.  Please check that I resolved those
> correctly.

Verified that the patch applied correctly.

Thanks,
Laxman

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

end of thread, other threads:[~2012-04-03  5:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-07 10:28 [PATCH V2] regulator: fixed: Support for open drain gpio pin Laxman Dewangan
2012-03-07 10:55 ` Mark Brown
2012-04-02 22:18 ` Mark Brown
2012-04-03  5:17   ` Laxman Dewangan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).