public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] regulator: fixed: dt: support for input supply
@ 2012-07-04 15:05 Laxman Dewangan
  2012-07-04 15:41 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Laxman Dewangan @ 2012-07-04 15:05 UTC (permalink / raw)
  To: broonie, grant.likely, rob, rob.herring
  Cc: linux-kernel, linux-doc, swarren, Laxman Dewangan

Add support for input supply in DT parsing of node.
The input supply will be provided by the property
"vin-supply" in the regulator node.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
Changes from V1:
Based on discussion on patch
[PATCH 2/2] regulator: fixed: dt: support for input supply
that the supply name should be passed through desc->supply_name
in both DT and non-DT case.
Making the change to have this.

 .../bindings/regulator/fixed-regulator.txt         |    2 ++
 drivers/regulator/fixed.c                          |   15 +++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
index 2f5b6b1..4fae41d 100644
--- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
@@ -10,6 +10,7 @@ Optional properties:
 If this property is missing, the default assumed is Active low.
 - gpio-open-drain: GPIO is open drain type.
   If this property is missing then default assumption is false.
+-vin-supply: Input supply name.
 
 Any property defined as part of the core regulator
 binding, defined in regulator.txt, can also be used.
@@ -29,4 +30,5 @@ Example:
 		enable-active-high;
 		regulator-boot-on;
 		gpio-open-drain;
+		vin-supply = <&parent_reg>;
 	};
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index b8c3a91..f56e575 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -45,13 +45,14 @@ struct fixed_voltage_data {
 /**
  * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
  * @dev: device requesting for fixed_voltage_config
+ * @vin_supply: pointer to store whether input supply is available or not.
  *
  * Populates fixed_voltage_config structure by extracting data from device
  * tree node, returns a pointer to the populated structure of NULL if memory
  * alloc fails.
  */
 static struct fixed_voltage_config *
-of_get_fixed_voltage_config(struct device *dev)
+of_get_fixed_voltage_config(struct device *dev, bool *vin_supply)
 {
 	struct fixed_voltage_config *config;
 	struct device_node *np = dev->of_node;
@@ -106,6 +107,9 @@ of_get_fixed_voltage_config(struct device *dev)
 	if (of_find_property(np, "gpio-open-drain", NULL))
 		config->gpio_is_open_drain = true;
 
+	if (of_find_property(np, "vin-supply", NULL))
+		*vin_supply = true;
+
 	return config;
 }
 
@@ -184,13 +188,18 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 	struct fixed_voltage_data *drvdata;
 	struct regulator_config cfg = { };
 	int ret;
+	const char *supply_reg = NULL;
 
 	if (pdev->dev.of_node) {
-		config = of_get_fixed_voltage_config(&pdev->dev);
+		bool vin_supply = false;
+		config = of_get_fixed_voltage_config(&pdev->dev, &vin_supply);
 		if (IS_ERR(config))
 			return PTR_ERR(config);
+		if (vin_supply)
+			supply_reg = "vin";
 	} else {
 		config = pdev->dev.platform_data;
+		supply_reg = config->init_data->supply_regulator;
 	}
 
 	if (!config)
@@ -213,6 +222,8 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 	drvdata->desc.type = REGULATOR_VOLTAGE;
 	drvdata->desc.owner = THIS_MODULE;
 
+	drvdata->desc.supply_name = supply_reg;
+
 	if (config->microvolts)
 		drvdata->desc.n_voltages = 1;
 
-- 
1.7.1.1


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

* Re: [PATCH V2] regulator: fixed: dt: support for input supply
  2012-07-04 15:05 [PATCH V2] regulator: fixed: dt: support for input supply Laxman Dewangan
@ 2012-07-04 15:41 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-07-04 15:41 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: grant.likely, rob, rob.herring, linux-kernel, linux-doc, swarren

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

On Wed, Jul 04, 2012 at 08:35:33PM +0530, Laxman Dewangan wrote:

> that the supply name should be passed through desc->supply_name
> in both DT and non-DT case.
> Making the change to have this.

>  .../bindings/regulator/fixed-regulator.txt         |    2 ++
>  drivers/regulator/fixed.c                          |   15 +++++++++++++--

The supply name would need to be passed in via platform data, we should
never end up with both the init data and descriptor setting the supply
name.

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

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-04 15:05 [PATCH V2] regulator: fixed: dt: support for input supply Laxman Dewangan
2012-07-04 15:41 ` Mark Brown

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