mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Courbot <acourbot@nvidia.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Cc: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<gnurou@gmail.com>, Alexandre Courbot <acourbot@nvidia.com>
Subject: [PATCH 3/6] regulator: fixed: Use of_get_regulator_gpio_config
Date: Wed, 22 Jun 2016 17:25:55 +0900	[thread overview]
Message-ID: <20160622082558.20935-4-acourbot@nvidia.com> (raw)
In-Reply-To: <20160622082558.20935-1-acourbot@nvidia.com>

If instanciated from the DT, use of_get_regulator_gpio_config to obtain
the enable GPIO configuration.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/regulator/fixed.c | 52 ++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 988a7472c2ab..76a8dea763cf 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -75,22 +75,14 @@ of_get_fixed_voltage_config(struct device *dev,
 		return ERR_PTR(-EINVAL);
 	}
 
-	if (init_data->constraints.boot_on)
-		config->enabled_at_boot = true;
-
-	config->gpio = of_get_named_gpio(np, "gpio", 0);
-	if ((config->gpio < 0) && (config->gpio != -ENOENT))
-		return ERR_PTR(config->gpio);
-
 	of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
 
-	config->enable_high = of_property_read_bool(np, "enable-active-high");
-	config->gpio_is_open_drain = of_property_read_bool(np,
-							   "gpio-open-drain");
-
 	if (of_find_property(np, "vin-supply", NULL))
 		config->input_supply = "vin";
 
+	/* GPIO info will be obtained via regulator_of_get_gpio_config */
+	config->gpio = -ENOENT;
+
 	return config;
 }
 
@@ -114,6 +106,12 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
 						     &drvdata->desc);
 		if (IS_ERR(config))
 			return PTR_ERR(config);
+
+		ret = of_get_regulator_gpio_config(&pdev->dev,
+						   pdev->dev.of_node, "gpio",
+						   &cfg);
+		if (ret)
+			return ret;
 	} else {
 		config = dev_get_platdata(&pdev->dev);
 	}
@@ -150,25 +148,29 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
 
 	drvdata->desc.fixed_uV = config->microvolts;
 
+	/*
+	 * For platform-defined regulators - DT is already handled by
+	 * of_get_regulator_gpio_config
+	 */
 	if (gpio_is_valid(config->gpio)) {
 		cfg.ena_gpio = config->gpio;
 		if (pdev->dev.of_node)
 			cfg.ena_gpio_initialized = true;
+		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;
+		}
+		if (config->gpio_is_open_drain)
+			cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN;
 	}
-	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;
-	}
-	if (config->gpio_is_open_drain)
-		cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN;
 
 	cfg.dev = &pdev->dev;
 	cfg.init_data = config->init_data;
-- 
2.8.3

  parent reply	other threads:[~2016-06-22  8:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22  8:25 [PATCH 0/6] regulator: add enable GPIO property to pwm-regulator Alexandre Courbot
2016-06-22  8:25 ` [PATCH 1/6] regulator: core: Allow simultaneous use of enable op and GPIO Alexandre Courbot
2016-06-22 10:34   ` Mark Brown
2016-06-23  1:10     ` Alexandre Courbot
2016-06-23  5:29       ` Alexandre Courbot
2016-06-23 10:01         ` Mark Brown
2016-06-22  8:25 ` [PATCH 2/6] regulator: of: Add enable GPIO configuration function Alexandre Courbot
2016-06-22 10:35   ` Mark Brown
2016-06-22  8:25 ` Alexandre Courbot [this message]
2016-06-22  8:25 ` [PATCH 4/6] regulator: gpio: Use of_get_regulator_gpio_config Alexandre Courbot
2016-06-22  8:25 ` [PATCH 5/6] pwm-regulator: Support for enable GPIO Alexandre Courbot
2016-06-22  8:25 ` [PATCH 6/6] dt-bindings: pwm-regulator: Document enable-gpio property Alexandre Courbot
2016-06-22 10:36   ` Mark Brown

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=20160622082558.20935-4-acourbot@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gnurou@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome