public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc
@ 2012-07-04  2:19 Axel Lin
  2012-07-04  2:20 ` [PATCH RFT 2/2] regulator: gpio-regulator: Use core GPIO enable support Axel Lin
  2012-07-04 11:38 ` [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2012-07-04  2:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: Heiko Stübner, Liam Girdwood, linux-kernel

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/gpio-regulator.c |   12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 242851a..3ed8d15 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -39,7 +39,6 @@ struct gpio_regulator_data {
 	int enable_gpio;
 	bool enable_high;
 	bool is_enabled;
-	unsigned startup_delay;
 
 	struct gpio *gpios;
 	int nr_gpios;
@@ -81,13 +80,6 @@ static int gpio_regulator_disable(struct regulator_dev *dev)
 	return 0;
 }
 
-static int gpio_regulator_enable_time(struct regulator_dev *dev)
-{
-	struct gpio_regulator_data *data = rdev_get_drvdata(dev);
-
-	return data->startup_delay;
-}
-
 static int gpio_regulator_get_value(struct regulator_dev *dev)
 {
 	struct gpio_regulator_data *data = rdev_get_drvdata(dev);
@@ -156,7 +148,6 @@ static struct regulator_ops gpio_regulator_voltage_ops = {
 	.is_enabled = gpio_regulator_is_enabled,
 	.enable = gpio_regulator_enable,
 	.disable = gpio_regulator_disable,
-	.enable_time = gpio_regulator_enable_time,
 	.get_voltage = gpio_regulator_get_value,
 	.set_voltage = gpio_regulator_set_voltage,
 	.list_voltage = gpio_regulator_list_voltage,
@@ -166,7 +157,6 @@ static struct regulator_ops gpio_regulator_current_ops = {
 	.is_enabled = gpio_regulator_is_enabled,
 	.enable = gpio_regulator_enable,
 	.disable = gpio_regulator_disable,
-	.enable_time = gpio_regulator_enable_time,
 	.get_current_limit = gpio_regulator_get_value,
 	.set_current_limit = gpio_regulator_set_current_limit,
 };
@@ -213,6 +203,7 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
 	drvdata->nr_states = config->nr_states;
 
 	drvdata->desc.owner = THIS_MODULE;
+	drvdata->desc.enable_time = config->startup_delay;
 
 	/* handle regulator type*/
 	switch (config->type) {
@@ -233,7 +224,6 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
 	}
 
 	drvdata->enable_gpio = config->enable_gpio;
-	drvdata->startup_delay = config->startup_delay;
 
 	if (gpio_is_valid(config->enable_gpio)) {
 		drvdata->enable_high = config->enable_high;
-- 
1.7.9.5




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

* [PATCH RFT 2/2] regulator: gpio-regulator: Use core GPIO enable support
  2012-07-04  2:19 [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc Axel Lin
@ 2012-07-04  2:20 ` Axel Lin
  2012-07-04 11:39   ` Mark Brown
  2012-07-04 11:38 ` [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Axel Lin @ 2012-07-04  2:20 UTC (permalink / raw)
  To: Mark Brown; +Cc: Heiko Stübner, Liam Girdwood, linux-kernel

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/gpio-regulator.c |  103 ++++++------------------------------
 1 file changed, 16 insertions(+), 87 deletions(-)

diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 3ed8d15..34b67be 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -36,10 +36,6 @@ struct gpio_regulator_data {
 	struct regulator_desc desc;
 	struct regulator_dev *dev;
 
-	int enable_gpio;
-	bool enable_high;
-	bool is_enabled;
-
 	struct gpio *gpios;
 	int nr_gpios;
 
@@ -49,37 +45,6 @@ struct gpio_regulator_data {
 	int state;
 };
 
-static int gpio_regulator_is_enabled(struct regulator_dev *dev)
-{
-	struct gpio_regulator_data *data = rdev_get_drvdata(dev);
-
-	return data->is_enabled;
-}
-
-static int gpio_regulator_enable(struct regulator_dev *dev)
-{
-	struct gpio_regulator_data *data = rdev_get_drvdata(dev);
-
-	if (gpio_is_valid(data->enable_gpio)) {
-		gpio_set_value_cansleep(data->enable_gpio, data->enable_high);
-		data->is_enabled = true;
-	}
-
-	return 0;
-}
-
-static int gpio_regulator_disable(struct regulator_dev *dev)
-{
-	struct gpio_regulator_data *data = rdev_get_drvdata(dev);
-
-	if (gpio_is_valid(data->enable_gpio)) {
-		gpio_set_value_cansleep(data->enable_gpio, !data->enable_high);
-		data->is_enabled = false;
-	}
-
-	return 0;
-}
-
 static int gpio_regulator_get_value(struct regulator_dev *dev)
 {
 	struct gpio_regulator_data *data = rdev_get_drvdata(dev);
@@ -145,18 +110,12 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev,
 }
 
 static struct regulator_ops gpio_regulator_voltage_ops = {
-	.is_enabled = gpio_regulator_is_enabled,
-	.enable = gpio_regulator_enable,
-	.disable = gpio_regulator_disable,
 	.get_voltage = gpio_regulator_get_value,
 	.set_voltage = gpio_regulator_set_voltage,
 	.list_voltage = gpio_regulator_list_voltage,
 };
 
 static struct regulator_ops gpio_regulator_current_ops = {
-	.is_enabled = gpio_regulator_is_enabled,
-	.enable = gpio_regulator_enable,
-	.disable = gpio_regulator_disable,
 	.get_current_limit = gpio_regulator_get_value,
 	.set_current_limit = gpio_regulator_set_current_limit,
 };
@@ -223,51 +182,12 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
 		break;
 	}
 
-	drvdata->enable_gpio = config->enable_gpio;
-
-	if (gpio_is_valid(config->enable_gpio)) {
-		drvdata->enable_high = config->enable_high;
-
-		ret = gpio_request(config->enable_gpio, config->supply_name);
-		if (ret) {
-			dev_err(&pdev->dev,
-			   "Could not obtain regulator enable GPIO %d: %d\n",
-						config->enable_gpio, ret);
-			goto err_memstate;
-		}
-
-		/* set output direction without changing state
-		 * to prevent glitch
-		 */
-		if (config->enabled_at_boot) {
-			drvdata->is_enabled = true;
-			ret = gpio_direction_output(config->enable_gpio,
-						    config->enable_high);
-		} else {
-			drvdata->is_enabled = false;
-			ret = gpio_direction_output(config->enable_gpio,
-						    !config->enable_high);
-		}
-
-		if (ret) {
-			dev_err(&pdev->dev,
-			   "Could not configure regulator enable GPIO %d direction: %d\n",
-						config->enable_gpio, ret);
-			goto err_enablegpio;
-		}
-	} else {
-		/* Regulator without GPIO control is considered
-		 * always enabled
-		 */
-		drvdata->is_enabled = true;
-	}
-
 	drvdata->nr_gpios = config->nr_gpios;
 	ret = gpio_request_array(drvdata->gpios, drvdata->nr_gpios);
 	if (ret) {
 		dev_err(&pdev->dev,
 		   "Could not obtain regulator setting GPIOs: %d\n", ret);
-		goto err_enablegpio;
+		goto err_memstate;
 	}
 
 	/* build initial state from gpio init data. */
@@ -282,6 +202,21 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
 	cfg.init_data = config->init_data;
 	cfg.driver_data = drvdata;
 
+	if (config->enable_gpio >= 0)
+		cfg.ena_gpio = config->enable_gpio;
+	cfg.ena_gpio_invert = !config->enable_high;
+	if (config->enabled_at_boot) {
+		if (config->enable_high)
+			cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
+		else
+			cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
+	} else {
+		if (config->enable_high)
+			cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
+		else
+			cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
+	}
+
 	drvdata->dev = regulator_register(&drvdata->desc, &cfg);
 	if (IS_ERR(drvdata->dev)) {
 		ret = PTR_ERR(drvdata->dev);
@@ -295,9 +230,6 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
 
 err_stategpio:
 	gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
-err_enablegpio:
-	if (gpio_is_valid(config->enable_gpio))
-		gpio_free(config->enable_gpio);
 err_memstate:
 	kfree(drvdata->states);
 err_memgpio:
@@ -319,9 +251,6 @@ static int __devexit gpio_regulator_remove(struct platform_device *pdev)
 	kfree(drvdata->states);
 	kfree(drvdata->gpios);
 
-	if (gpio_is_valid(drvdata->enable_gpio))
-		gpio_free(drvdata->enable_gpio);
-
 	kfree(drvdata->desc.name);
 
 	return 0;
-- 
1.7.9.5




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

* Re: [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc
  2012-07-04  2:19 [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc Axel Lin
  2012-07-04  2:20 ` [PATCH RFT 2/2] regulator: gpio-regulator: Use core GPIO enable support Axel Lin
@ 2012-07-04 11:38 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-07-04 11:38 UTC (permalink / raw)
  To: Axel Lin; +Cc: Heiko Stübner, Liam Girdwood, linux-kernel

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

On Wed, Jul 04, 2012 at 10:19:46AM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

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

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

* Re: [PATCH RFT 2/2] regulator: gpio-regulator: Use core GPIO enable support
  2012-07-04  2:20 ` [PATCH RFT 2/2] regulator: gpio-regulator: Use core GPIO enable support Axel Lin
@ 2012-07-04 11:39   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-07-04 11:39 UTC (permalink / raw)
  To: Axel Lin; +Cc: Heiko Stübner, Liam Girdwood, linux-kernel

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

On Wed, Jul 04, 2012 at 10:20:46AM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

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

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

end of thread, other threads:[~2012-07-04 11:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-04  2:19 [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc Axel Lin
2012-07-04  2:20 ` [PATCH RFT 2/2] regulator: gpio-regulator: Use core GPIO enable support Axel Lin
2012-07-04 11:39   ` Mark Brown
2012-07-04 11:38 ` [PATCH RFT 1/2] regulator: gpio-regulator: Set enable enable_time in regulator_desc Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox