All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Arizona regulator updates v3
@ 2014-03-19 10:18 Charles Keepax
  2014-03-19 10:18 ` [PATCH 1/5] arizona: Correct small errors in the DT binding documentation Charles Keepax
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Charles Keepax @ 2014-03-19 10:18 UTC (permalink / raw)
  To: broonie
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, rob,
	sameo, lee.jones, lgirdwood, ckeepax, linux-kernel

Hi,

This series of patches are small fixes/improvements to the
Arizona regulators. The main thing added is proper device
tree bindings for getting the regulator init_data.

Changes Since v2:
  - We now set external_dcvdd in arizona-core and then clear
  in the LDO1 regulator driver, such that if the regulator
  driver is not compiled in then we will default to an
  external DCVDD.

Thanks,
Charles

Charles Keepax (5):
  arizona: Correct small errors in the DT binding documentation
  mfd: arizona: Fix and factor out read of device tree GPIOs
  regulator: arizona-ldo1: Move setup processing from arizona-core
  regulator: arizona-ldo1: Add processing of init_data from device tree
  regulator: arizona-micsupp: Add processing of init_data from device
    tree

 Documentation/devicetree/bindings/mfd/arizona.txt |   32 +++++++---
 drivers/mfd/arizona-core.c                        |   43 ++++++++-----
 drivers/regulator/arizona-ldo1.c                  |   70 +++++++++++++++++++++
 drivers/regulator/arizona-micsupp.c               |   50 +++++++++++++++
 include/linux/mfd/arizona/core.h                  |    3 +
 5 files changed, 171 insertions(+), 27 deletions(-)

-- 
1.7.2.5


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

* [PATCH 1/5] arizona: Correct small errors in the DT binding documentation
  2014-03-19 10:18 [PATCH 0/5] Arizona regulator updates v3 Charles Keepax
@ 2014-03-19 10:18 ` Charles Keepax
  2014-03-21 10:54   ` Lee Jones
  2014-03-19 10:18 ` [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs Charles Keepax
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Charles Keepax @ 2014-03-19 10:18 UTC (permalink / raw)
  To: broonie
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, rob,
	sameo, lee.jones, lgirdwood, ckeepax, linux-kernel

This patch does not alter the binding at all it only brings the
documentation up to date with the existing binding.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 Documentation/devicetree/bindings/mfd/arizona.txt |   23 +++++++++++---------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 0e295c9..36a0c3d 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -5,9 +5,10 @@ of analogue I/O.
 
 Required properties:
 
-  - compatible : one of the following chip-specific strings:
-	"wlf,wm5102"
-	"wlf,wm5110"
+  - compatible : One of the following chip-specific strings:
+        "wlf,wm5102"
+        "wlf,wm5110"
+        "wlf,wm8997"
   - reg : I2C slave address when connected using I2C, chip select number when
     using SPI.
 
@@ -25,8 +26,9 @@ Required properties:
   - #gpio-cells : Must be 2. The first cell is the pin number and the
     second cell is used to specify optional parameters (currently unused).
 
-  - AVDD1-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply,
-    SPKVDDL-supply, SPKVDDR-supply : power supplies for the device, as covered
+  - AVDD-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply (wm5102, wm5110),
+    CPVDD-supply, SPKVDDL-supply (wm5102, wm5110), SPKVDDR-supply (wm5102,
+    wm5110), SPKVDD-supply (wm8997) : Power supplies for the device, as covered
     in Documentation/devicetree/bindings/regulator/regulator.txt
 
 Optional properties:
@@ -46,6 +48,7 @@ codec: wm5102@1a {
 	compatible = "wlf,wm5102";
 	reg = <0x1a>;
 	interrupts = <347>;
+	interrupt-controller;
 	#interrupt-cells = <2>;
         interrupt-parent = <&gic>;
 
@@ -53,10 +56,10 @@ codec: wm5102@1a {
 	#gpio-cells = <2>;
 
 	wlf,gpio-defaults = <
-		0x00000000, /* AIF1TXLRCLK */
-		0xffffffff,
-		0xffffffff,
-		0xffffffff,
-		0xffffffff,
+		0x00000000 /* AIF1TXLRCLK */
+		0xffffffff
+		0xffffffff
+		0xffffffff
+		0xffffffff
 	>;
 };
-- 
1.7.2.5


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

* [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs
  2014-03-19 10:18 [PATCH 0/5] Arizona regulator updates v3 Charles Keepax
  2014-03-19 10:18 ` [PATCH 1/5] arizona: Correct small errors in the DT binding documentation Charles Keepax
@ 2014-03-19 10:18 ` Charles Keepax
  2014-03-21 10:52   ` Lee Jones
  2014-03-19 10:18 ` [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core Charles Keepax
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Charles Keepax @ 2014-03-19 10:18 UTC (permalink / raw)
  To: broonie
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, rob,
	sameo, lee.jones, lgirdwood, ckeepax, linux-kernel

On non-DT systems with device tree built in the current device tree GPIO
reads will overwrite the pdata with zero when they fail. This patch
factors out the reading of GPIOs for the Arizona devices into a helper
function, and ensures that the pdata version will be preserved if the
device tree read fails.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c       |   33 ++++++++++++++++++++++++---------
 include/linux/mfd/arizona/core.h |    3 +++
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index a45aab9..333621e 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -512,19 +512,34 @@ int arizona_of_get_type(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(arizona_of_get_type);
 
+int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
+			      bool mandatory, int *gpio)
+{
+	int ret;
+
+	ret = of_get_named_gpio(arizona->dev->of_node, prop, 0);
+	if (ret >= 0) {
+		*gpio = ret;
+		return ret;
+	}
+
+	/* Warn if GPIO is mandatory and not specified */
+	if (mandatory && *gpio <= 0)
+		dev_err(arizona->dev,
+				"Mandatory DT gpio %s missing/malformed: %d\n",
+				prop, ret);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);
+
 static int arizona_of_get_core_pdata(struct arizona *arizona)
 {
+	struct arizona_pdata *pdata = &arizona->pdata;
 	int ret, i;
 
-	arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,
-						 "wlf,reset", 0);
-	if (arizona->pdata.reset < 0)
-		arizona->pdata.reset = 0;
-
-	arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
-						  "wlf,ldoena", 0);
-	if (arizona->pdata.ldoena < 0)
-		arizona->pdata.ldoena = 0;
+	arizona_of_get_named_gpio(arizona, "wlf,reset", true, &pdata->reset);
+	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
 
 	ret = of_property_read_u32_array(arizona->dev->of_node,
 					 "wlf,gpio-defaults",
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
index 5cf8b91..16150cc 100644
--- a/include/linux/mfd/arizona/core.h
+++ b/include/linux/mfd/arizona/core.h
@@ -124,4 +124,7 @@ int wm5102_patch(struct arizona *arizona);
 int wm5110_patch(struct arizona *arizona);
 int wm8997_patch(struct arizona *arizona);
 
+extern int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
+				     bool mandatory, int *gpio);
+
 #endif
-- 
1.7.2.5


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

* [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core
  2014-03-19 10:18 [PATCH 0/5] Arizona regulator updates v3 Charles Keepax
  2014-03-19 10:18 ` [PATCH 1/5] arizona: Correct small errors in the DT binding documentation Charles Keepax
  2014-03-19 10:18 ` [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs Charles Keepax
@ 2014-03-19 10:18 ` Charles Keepax
  2014-03-21 10:40   ` Lee Jones
  2014-03-19 10:18 ` [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree Charles Keepax
  2014-03-19 10:18 ` [PATCH 5/5] regulator: arizona-micsupp: " Charles Keepax
  4 siblings, 1 reply; 15+ messages in thread
From: Charles Keepax @ 2014-03-19 10:18 UTC (permalink / raw)
  To: broonie
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, rob,
	sameo, lee.jones, lgirdwood, ckeepax, linux-kernel

It is more idiomatic to process things relating to the regulator in its
driver. This patch moves both processing of device tree relating to the
regulator and checking if the regulator is external from arizona-core
into the regulator driver.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c       |   12 +++---------
 drivers/regulator/arizona-ldo1.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 333621e..c5fe3bb 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -539,7 +539,6 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
 	int ret, i;
 
 	arizona_of_get_named_gpio(arizona, "wlf,reset", true, &pdata->reset);
-	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
 
 	ret = of_property_read_u32_array(arizona->dev->of_node,
 					 "wlf,gpio-defaults",
@@ -671,6 +670,9 @@ int arizona_dev_init(struct arizona *arizona)
 		return -EINVAL;
 	}
 
+	/* Mark DCVDD as external, LDO1 driver will clear if internal */
+	arizona->external_dcvdd = true;
+
 	ret = mfd_add_devices(arizona->dev, -1, early_devs,
 			      ARRAY_SIZE(early_devs), NULL, 0, NULL);
 	if (ret != 0) {
@@ -870,14 +872,6 @@ int arizona_dev_init(struct arizona *arizona)
 			     arizona->pdata.gpio_defaults[i]);
 	}
 
-	/*
-	 * LDO1 can only be used to supply DCVDD so if it has no
-	 * consumers then DCVDD is supplied externally.
-	 */
-	if (arizona->pdata.ldo1 &&
-	    arizona->pdata.ldo1->num_consumer_supplies == 0)
-		arizona->external_dcvdd = true;
-
 	pm_runtime_set_autosuspend_delay(arizona->dev, 100);
 	pm_runtime_use_autosuspend(arizona->dev);
 	pm_runtime_enable(arizona->dev);
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index b1033d3..3ac4b95 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -178,6 +178,22 @@ static const struct regulator_init_data arizona_ldo1_default = {
 	.num_consumer_supplies = 1,
 };
 
+#ifdef CONFIG_OF
+static int arizona_ldo1_of_get_pdata(struct arizona *arizona)
+{
+	struct arizona_pdata *pdata = &arizona->pdata;
+
+	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
+
+	return 0;
+}
+#else
+static inline int arizona_ldo1_of_get_pdata(struct arizona *arizona)
+{
+	return 0;
+}
+#endif
+
 static int arizona_ldo1_probe(struct platform_device *pdev)
 {
 	struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
@@ -186,6 +202,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 	struct arizona_ldo1 *ldo1;
 	int ret;
 
+	arizona->external_dcvdd = false;
+
 	ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
 	if (!ldo1)
 		return -ENOMEM;
@@ -216,6 +234,11 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 	config.dev = arizona->dev;
 	config.driver_data = ldo1;
 	config.regmap = arizona->regmap;
+
+	ret = arizona_ldo1_of_get_pdata(arizona);
+	if (ret < 0)
+		return ret;
+
 	config.ena_gpio = arizona->pdata.ldoena;
 
 	if (arizona->pdata.ldo1)
@@ -223,6 +246,13 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 	else
 		config.init_data = &ldo1->init_data;
 
+	/*
+	 * LDO1 can only be used to supply DCVDD so if it has no
+	 * consumers then DCVDD is supplied externally.
+	 */
+	if (config.init_data->num_consumer_supplies == 0)
+		arizona->external_dcvdd = true;
+
 	ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
 	if (IS_ERR(ldo1->regulator)) {
 		ret = PTR_ERR(ldo1->regulator);
-- 
1.7.2.5


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

* [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree
  2014-03-19 10:18 [PATCH 0/5] Arizona regulator updates v3 Charles Keepax
                   ` (2 preceding siblings ...)
  2014-03-19 10:18 ` [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core Charles Keepax
@ 2014-03-19 10:18 ` Charles Keepax
  2014-03-21 10:34   ` Lee Jones
  2014-03-19 10:18 ` [PATCH 5/5] regulator: arizona-micsupp: " Charles Keepax
  4 siblings, 1 reply; 15+ messages in thread
From: Charles Keepax @ 2014-03-19 10:18 UTC (permalink / raw)
  To: broonie
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, rob,
	sameo, lee.jones, lgirdwood, ckeepax, linux-kernel

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 Documentation/devicetree/bindings/mfd/arizona.txt |    7 +++
 drivers/regulator/arizona-ldo1.c                  |   46 +++++++++++++++++++-
 2 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 36a0c3d..9d54c70 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -42,6 +42,13 @@ Optional properties:
     the chip default will be used.  If present exactly five values must
     be specified.
 
+  - ldo1 : Initial data for the LDO1 regulator, as covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt
+
+  - DCVDD-supply : Power supply, only needs to be specified if DCVDD is being
+    externally supplied. As covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt
+
 Example:
 
 codec: wm5102@1a {
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 3ac4b95..7a0d8e4 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
 #include <linux/gpio.h>
 #include <linux/slab.h>
 
@@ -179,19 +180,56 @@ static const struct regulator_init_data arizona_ldo1_default = {
 };
 
 #ifdef CONFIG_OF
-static int arizona_ldo1_of_get_pdata(struct arizona *arizona)
+static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
+				     struct regulator_config *config)
 {
 	struct arizona_pdata *pdata = &arizona->pdata;
+	struct arizona_ldo1 *ldo1 = config->driver_data;
+	struct device_node *init_node, *dcvdd_node;
+	struct regulator_init_data *init_data;
 
 	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
 
+	init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1");
+	dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0);
+
+	if (init_node) {
+		config->of_node = init_node;
+
+		init_data = of_get_regulator_init_data(arizona->dev, init_node);
+
+		if (init_data) {
+			init_data->consumer_supplies = &ldo1->supply;
+			init_data->num_consumer_supplies = 1;
+
+			if (dcvdd_node && dcvdd_node != init_node)
+				arizona->external_dcvdd = true;
+
+			pdata->ldo1 = init_data;
+		}
+	} else if (dcvdd_node) {
+		arizona->external_dcvdd = true;
+	}
+
+	of_node_put(dcvdd_node);
+
 	return 0;
 }
+
+static void arizona_ldo1_of_put_pdata(struct regulator_config *config)
+{
+	of_node_put(config->of_node);
+}
 #else
-static inline int arizona_ldo1_of_get_pdata(struct arizona *arizona)
+static inline int arizona_ldo1_of_get_pdata(struct arizona *arizona,
+					    struct regulator_config *config)
 {
 	return 0;
 }
+
+static inline void arizona_ldo1_of_put_pdata(struct regulator_config *config)
+{
+}
 #endif
 
 static int arizona_ldo1_probe(struct platform_device *pdev)
@@ -235,7 +273,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 	config.driver_data = ldo1;
 	config.regmap = arizona->regmap;
 
-	ret = arizona_ldo1_of_get_pdata(arizona);
+	ret = arizona_ldo1_of_get_pdata(arizona, &config);
 	if (ret < 0)
 		return ret;
 
@@ -261,6 +299,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	arizona_ldo1_of_put_pdata(&config);
+
 	platform_set_drvdata(pdev, ldo1);
 
 	return 0;
-- 
1.7.2.5


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

* [PATCH 5/5] regulator: arizona-micsupp: Add processing of init_data from device tree
  2014-03-19 10:18 [PATCH 0/5] Arizona regulator updates v3 Charles Keepax
                   ` (3 preceding siblings ...)
  2014-03-19 10:18 ` [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree Charles Keepax
@ 2014-03-19 10:18 ` Charles Keepax
  2014-03-21 10:28   ` Lee Jones
  4 siblings, 1 reply; 15+ messages in thread
From: Charles Keepax @ 2014-03-19 10:18 UTC (permalink / raw)
  To: broonie
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, rob,
	sameo, lee.jones, lgirdwood, ckeepax, linux-kernel

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 Documentation/devicetree/bindings/mfd/arizona.txt |    6 ++-
 drivers/regulator/arizona-micsupp.c               |   50 +++++++++++++++++++++
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 9d54c70..9c685b2 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -44,9 +44,11 @@ Optional properties:
 
   - ldo1 : Initial data for the LDO1 regulator, as covered in
     Documentation/devicetree/bindings/regulator/regulator.txt
+  - micvdd : Initial data for the MICVDD regulator, as covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt
 
-  - DCVDD-supply : Power supply, only needs to be specified if DCVDD is being
-    externally supplied. As covered in
+  - DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
+    they are being externally supplied. As covered in
     Documentation/devicetree/bindings/regulator/regulator.txt
 
 Example:
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 6fdd9bf..8b38f6b 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
 #include <linux/gpio.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
@@ -195,6 +196,49 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
 	.num_consumer_supplies = 1,
 };
 
+#ifdef CONFIG_OF
+static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
+					struct regulator_config *config)
+{
+	struct arizona_pdata *pdata = &arizona->pdata;
+	struct arizona_micsupp *micsupp = config->driver_data;
+	struct device_node *np;
+	struct regulator_init_data *init_data;
+
+	np = of_get_child_by_name(arizona->dev->of_node, "micvdd");
+
+	if (np) {
+		config->of_node = np;
+
+		init_data = of_get_regulator_init_data(arizona->dev, np);
+
+		if (init_data) {
+			init_data->consumer_supplies = &micsupp->supply;
+			init_data->num_consumer_supplies = 1;
+
+			pdata->micvdd = init_data;
+		}
+	}
+
+	return 0;
+}
+
+static void arizona_micsupp_of_put_pdata(struct regulator_config *config)
+{
+	of_node_put(config->of_node);
+}
+#else
+static inline int arizona_micsupp_of_get_pdata(struct arizona *arizona,
+					       struct regulator_config *config)
+{
+	return 0;
+}
+
+static inline void arizona_micsupp_of_put_pdata(struct regulator_config *config)
+{
+}
+#endif
+
 static int arizona_micsupp_probe(struct platform_device *pdev)
 {
 	struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
@@ -234,6 +278,10 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
 	config.driver_data = micsupp;
 	config.regmap = arizona->regmap;
 
+	ret = arizona_micsupp_of_get_pdata(arizona, &config);
+	if (ret < 0)
+		return ret;
+
 	if (arizona->pdata.micvdd)
 		config.init_data = arizona->pdata.micvdd;
 	else
@@ -253,6 +301,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	arizona_micsupp_of_put_pdata(&config);
+
 	platform_set_drvdata(pdev, micsupp);
 
 	return 0;
-- 
1.7.2.5


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

* Re: [PATCH 5/5] regulator: arizona-micsupp: Add processing of init_data from device tree
  2014-03-19 10:18 ` [PATCH 5/5] regulator: arizona-micsupp: " Charles Keepax
@ 2014-03-21 10:28   ` Lee Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Lee Jones @ 2014-03-21 10:28 UTC (permalink / raw)
  To: Charles Keepax
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt |    6 ++-
>  drivers/regulator/arizona-micsupp.c               |   50 +++++++++++++++++++++

For the sake of simplicity would you be kind enough to submit MFD
documentation separate from sub-device code please?

>  2 files changed, 54 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> index 9d54c70..9c685b2 100644
> --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> @@ -44,9 +44,11 @@ Optional properties:
>  
>    - ldo1 : Initial data for the LDO1 regulator, as covered in
>      Documentation/devicetree/bindings/regulator/regulator.txt
> +  - micvdd : Initial data for the MICVDD regulator, as covered in
> +    Documentation/devicetree/bindings/regulator/regulator.txt
>  
> -  - DCVDD-supply : Power supply, only needs to be specified if DCVDD is being
> -    externally supplied. As covered in
> +  - DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
> +    they are being externally supplied. As covered in
>      Documentation/devicetree/bindings/regulator/regulator.txt

Changes looks good to me, but I'd still like Mark's Ack at a minimum,
ideally someone from DT too.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree
  2014-03-19 10:18 ` [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree Charles Keepax
@ 2014-03-21 10:34   ` Lee Jones
  2014-03-21 15:45     ` Charles Keepax
  0 siblings, 1 reply; 15+ messages in thread
From: Lee Jones @ 2014-03-21 10:34 UTC (permalink / raw)
  To: Charles Keepax
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt |    7 +++

I can see why you're doing it like this, but it's probably best to do
all of the document changes in one single (separate) patch.

>  drivers/regulator/arizona-ldo1.c                  |   46 +++++++++++++++++++-
>  2 files changed, 50 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> index 36a0c3d..9d54c70 100644
> --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> @@ -42,6 +42,13 @@ Optional properties:
>      the chip default will be used.  If present exactly five values must
>      be specified.
>  
> +  - ldo1 : Initial data for the LDO1 regulator, as covered in
> +    Documentation/devicetree/bindings/regulator/regulator.txt
> +
> +  - DCVDD-supply : Power supply, only needs to be specified if DCVDD is being
> +    externally supplied. As covered in
> +    Documentation/devicetree/bindings/regulator/regulator.txt
> +

Looks fine to me again, but I'd still like a regulator and/or DT guy
to Ack.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core
  2014-03-19 10:18 ` [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core Charles Keepax
@ 2014-03-21 10:40   ` Lee Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Lee Jones @ 2014-03-21 10:40 UTC (permalink / raw)
  To: Charles Keepax
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

> It is more idiomatic to process things relating to the regulator in its
> driver. This patch moves both processing of device tree relating to the
> regulator and checking if the regulator is external from arizona-core
> into the regulator driver.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c       |   12 +++---------
>  drivers/regulator/arizona-ldo1.c |   30 ++++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index 333621e..c5fe3bb 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -539,7 +539,6 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
>  	int ret, i;
>  
>  	arizona_of_get_named_gpio(arizona, "wlf,reset", true, &pdata->reset);
> -	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
>  
>  	ret = of_property_read_u32_array(arizona->dev->of_node,
>  					 "wlf,gpio-defaults",
> @@ -671,6 +670,9 @@ int arizona_dev_init(struct arizona *arizona)
>  		return -EINVAL;
>  	}
>  
> +	/* Mark DCVDD as external, LDO1 driver will clear if internal */
> +	arizona->external_dcvdd = true;
> +

You don't need to do this, as it's already the default:

include/linux/mfd/arizona/core.h:

struct arizona {
 <snip>
        unsigned int external_dcvdd:1;
 <snip>
};

Also you're adding a bool value to a unsigned int.

Any reason for that?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs
  2014-03-19 10:18 ` [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs Charles Keepax
@ 2014-03-21 10:52   ` Lee Jones
  2014-03-21 15:44     ` Charles Keepax
  0 siblings, 1 reply; 15+ messages in thread
From: Lee Jones @ 2014-03-21 10:52 UTC (permalink / raw)
  To: Charles Keepax
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

On Wed, 19 Mar 2014, Charles Keepax wrote:

> On non-DT systems with device tree built in the current device tree GPIO
> reads will overwrite the pdata with zero when they fail. This patch
> factors out the reading of GPIOs for the Arizona devices into a helper
> function, and ensures that the pdata version will be preserved if the
> device tree read fails.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c       |   33 ++++++++++++++++++++++++---------
>  include/linux/mfd/arizona/core.h |    3 +++
>  2 files changed, 27 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index a45aab9..333621e 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -512,19 +512,34 @@ int arizona_of_get_type(struct device *dev)
>  }
>  EXPORT_SYMBOL_GPL(arizona_of_get_type);
>  
> +int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
> +			      bool mandatory, int *gpio)
> +{
> +	int ret;
> +
> +	ret = of_get_named_gpio(arizona->dev->of_node, prop, 0);
> +	if (ret >= 0) {
> +		*gpio = ret;
> +		return ret;
> +	}
> +
> +	/* Warn if GPIO is mandatory and not specified */
> +	if (mandatory && *gpio <= 0)
> +		dev_err(arizona->dev,
> +				"Mandatory DT gpio %s missing/malformed: %d\n",
> +				prop, ret);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);
> +
>  static int arizona_of_get_core_pdata(struct arizona *arizona)
>  {
> +	struct arizona_pdata *pdata = &arizona->pdata;
>  	int ret, i;
>  
> -	arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,
> -						 "wlf,reset", 0);
> -	if (arizona->pdata.reset < 0)
> -		arizona->pdata.reset = 0;
> -
> -	arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
> -						  "wlf,ldoena", 0);
> -	if (arizona->pdata.ldoena < 0)
> -		arizona->pdata.ldoena = 0;
> +	arizona_of_get_named_gpio(arizona, "wlf,reset", true, &pdata->reset);
> +	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
>  
>  	ret = of_property_read_u32_array(arizona->dev->of_node,
>  					 "wlf,gpio-defaults",

This doesn't look correct to me at all. Have you tested it in the DT
and !DT case? By the looks of it arizona_of_get_core_pdata() is only
called if no platform data is present. Yet you are dereferencing it
here without allocated any memory.

So how were any platform data passed variables being overwritten in
the first place?

> diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
> index 5cf8b91..16150cc 100644
> --- a/include/linux/mfd/arizona/core.h
> +++ b/include/linux/mfd/arizona/core.h
> @@ -124,4 +124,7 @@ int wm5102_patch(struct arizona *arizona);
>  int wm5110_patch(struct arizona *arizona);
>  int wm8997_patch(struct arizona *arizona);
>  
> +extern int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
> +				     bool mandatory, int *gpio);
> +
>  #endif

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 1/5] arizona: Correct small errors in the DT binding documentation
  2014-03-19 10:18 ` [PATCH 1/5] arizona: Correct small errors in the DT binding documentation Charles Keepax
@ 2014-03-21 10:54   ` Lee Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Lee Jones @ 2014-03-21 10:54 UTC (permalink / raw)
  To: Charles Keepax
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

> This patch does not alter the binding at all it only brings the
> documentation up to date with the existing binding.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt |   23 +++++++++++---------
>  1 files changed, 13 insertions(+), 10 deletions(-)

Looks reasonable to me. Applied until someone complains.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs
  2014-03-21 10:52   ` Lee Jones
@ 2014-03-21 15:44     ` Charles Keepax
  2014-03-24  8:44       ` Lee Jones
  0 siblings, 1 reply; 15+ messages in thread
From: Charles Keepax @ 2014-03-21 15:44 UTC (permalink / raw)
  To: Lee Jones
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

On Fri, Mar 21, 2014 at 10:52:18AM +0000, Lee Jones wrote:
> On Wed, 19 Mar 2014, Charles Keepax wrote:
> 
> > On non-DT systems with device tree built in the current device tree GPIO
> > reads will overwrite the pdata with zero when they fail. This patch
> > factors out the reading of GPIOs for the Arizona devices into a helper
> > function, and ensures that the pdata version will be preserved if the
> > device tree read fails.
> > 
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> > ---
> >  drivers/mfd/arizona-core.c       |   33 ++++++++++++++++++++++++---------
> >  include/linux/mfd/arizona/core.h |    3 +++
> >  2 files changed, 27 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> > index a45aab9..333621e 100644
> > --- a/drivers/mfd/arizona-core.c
> > +++ b/drivers/mfd/arizona-core.c
> > @@ -512,19 +512,34 @@ int arizona_of_get_type(struct device *dev)
> >  }
> >  EXPORT_SYMBOL_GPL(arizona_of_get_type);
> >  
> > +int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
> > +			      bool mandatory, int *gpio)
> > +{
> > +	int ret;
> > +
> > +	ret = of_get_named_gpio(arizona->dev->of_node, prop, 0);
> > +	if (ret >= 0) {
> > +		*gpio = ret;
> > +		return ret;
> > +	}
> > +
> > +	/* Warn if GPIO is mandatory and not specified */
> > +	if (mandatory && *gpio <= 0)
> > +		dev_err(arizona->dev,
> > +				"Mandatory DT gpio %s missing/malformed: %d\n",
> > +				prop, ret);
> > +
> > +	return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);
> > +
> >  static int arizona_of_get_core_pdata(struct arizona *arizona)
> >  {
> > +	struct arizona_pdata *pdata = &arizona->pdata;
> >  	int ret, i;
> >  
> > -	arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,
> > -						 "wlf,reset", 0);
> > -	if (arizona->pdata.reset < 0)
> > -		arizona->pdata.reset = 0;
> > -
> > -	arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
> > -						  "wlf,ldoena", 0);
> > -	if (arizona->pdata.ldoena < 0)
> > -		arizona->pdata.ldoena = 0;
> > +	arizona_of_get_named_gpio(arizona, "wlf,reset", true, &pdata->reset);
> > +	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
> >  
> >  	ret = of_property_read_u32_array(arizona->dev->of_node,
> >  					 "wlf,gpio-defaults",
> 
> This doesn't look correct to me at all. Have you tested it in the DT
> and !DT case? By the looks of it arizona_of_get_core_pdata() is only
> called if no platform data is present. Yet you are dereferencing it
> here without allocated any memory.

The pdata struct is contained within the arizona one so there is
no need to allocate memory for it.

> 
> So how were any platform data passed variables being overwritten in
> the first place?

Ah good point this is not called if the pdata exists, I will
update the commit message.

Thanks,
Charles

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

* Re: [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree
  2014-03-21 10:34   ` Lee Jones
@ 2014-03-21 15:45     ` Charles Keepax
  0 siblings, 0 replies; 15+ messages in thread
From: Charles Keepax @ 2014-03-21 15:45 UTC (permalink / raw)
  To: Lee Jones
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

On Fri, Mar 21, 2014 at 10:34:32AM +0000, Lee Jones wrote:
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> > ---
> >  Documentation/devicetree/bindings/mfd/arizona.txt |    7 +++
> 
> I can see why you're doing it like this, but it's probably best to do
> all of the document changes in one single (separate) patch.

I am happy to break this out into a seperate patch.

Thanks,
Charles

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

* Re: [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs
  2014-03-21 15:44     ` Charles Keepax
@ 2014-03-24  8:44       ` Lee Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Lee Jones @ 2014-03-24  8:44 UTC (permalink / raw)
  To: Charles Keepax
  Cc: broonie, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, rob, sameo, lgirdwood, linux-kernel

> > > On non-DT systems with device tree built in the current device tree GPIO
> > > reads will overwrite the pdata with zero when they fail. This patch
> > > factors out the reading of GPIOs for the Arizona devices into a helper
> > > function, and ensures that the pdata version will be preserved if the
> > > device tree read fails.
> > > 
> > > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> > > ---
> > >  drivers/mfd/arizona-core.c       |   33 ++++++++++++++++++++++++---------
> > >  include/linux/mfd/arizona/core.h |    3 +++
> > >  2 files changed, 27 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> > > index a45aab9..333621e 100644
> > > --- a/drivers/mfd/arizona-core.c
> > > +++ b/drivers/mfd/arizona-core.c
> > > @@ -512,19 +512,34 @@ int arizona_of_get_type(struct device *dev)
> > >  }
> > >  EXPORT_SYMBOL_GPL(arizona_of_get_type);
> > >  
> > > +int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
> > > +			      bool mandatory, int *gpio)
> > > +{
> > > +	int ret;
> > > +
> > > +	ret = of_get_named_gpio(arizona->dev->of_node, prop, 0);
> > > +	if (ret >= 0) {
> > > +		*gpio = ret;
> > > +		return ret;
> > > +	}
> > > +
> > > +	/* Warn if GPIO is mandatory and not specified */
> > > +	if (mandatory && *gpio <= 0)
> > > +		dev_err(arizona->dev,
> > > +				"Mandatory DT gpio %s missing/malformed: %d\n",
> > > +				prop, ret);
> > > +
> > > +	return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);
> > > +
> > >  static int arizona_of_get_core_pdata(struct arizona *arizona)
> > >  {
> > > +	struct arizona_pdata *pdata = &arizona->pdata;
> > >  	int ret, i;
> > >  
> > > -	arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,
> > > -						 "wlf,reset", 0);
> > > -	if (arizona->pdata.reset < 0)
> > > -		arizona->pdata.reset = 0;
> > > -
> > > -	arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
> > > -						  "wlf,ldoena", 0);
> > > -	if (arizona->pdata.ldoena < 0)
> > > -		arizona->pdata.ldoena = 0;
> > > +	arizona_of_get_named_gpio(arizona, "wlf,reset", true, &pdata->reset);
> > > +	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
> > >  
> > >  	ret = of_property_read_u32_array(arizona->dev->of_node,
> > >  					 "wlf,gpio-defaults",
> > 
> > This doesn't look correct to me at all. Have you tested it in the DT
> > and !DT case? By the looks of it arizona_of_get_core_pdata() is only
> > called if no platform data is present. Yet you are dereferencing it
> > here without allocated any memory.
> 
> The pdata struct is contained within the arizona one so there is
> no need to allocate memory for it.

Ah yes, I see that now. Thanks for the clarification.

> > So how were any platform data passed variables being overwritten in
> > the first place?
> 
> Ah good point this is not called if the pdata exists, I will
> update the commit message.

Great.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree
  2014-03-18 17:22 [PATCH 0/5] Arizona regulator updates v2 Charles Keepax
@ 2014-03-18 17:22 ` Charles Keepax
  0 siblings, 0 replies; 15+ messages in thread
From: Charles Keepax @ 2014-03-18 17:22 UTC (permalink / raw)
  To: broonie
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, rob,
	sameo, lee.jones, lgirdwood, ckeepax, linux-kernel

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 Documentation/devicetree/bindings/mfd/arizona.txt |    7 +++
 drivers/regulator/arizona-ldo1.c                  |   46 +++++++++++++++++++-
 2 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 36a0c3d..9d54c70 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -42,6 +42,13 @@ Optional properties:
     the chip default will be used.  If present exactly five values must
     be specified.
 
+  - ldo1 : Initial data for the LDO1 regulator, as covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt
+
+  - DCVDD-supply : Power supply, only needs to be specified if DCVDD is being
+    externally supplied. As covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt
+
 Example:
 
 codec: wm5102@1a {
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 1b59060..f936ff3 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
 #include <linux/gpio.h>
 #include <linux/slab.h>
 
@@ -179,19 +180,56 @@ static const struct regulator_init_data arizona_ldo1_default = {
 };
 
 #ifdef CONFIG_OF
-static int arizona_ldo1_of_get_pdata(struct arizona *arizona)
+static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
+				     struct regulator_config *config)
 {
 	struct arizona_pdata *pdata = &arizona->pdata;
+	struct arizona_ldo1 *ldo1 = config->driver_data;
+	struct device_node *init_node, *dcvdd_node;
+	struct regulator_init_data *init_data;
 
 	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
 
+	init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1");
+	dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0);
+
+	if (init_node) {
+		config->of_node = init_node;
+
+		init_data = of_get_regulator_init_data(arizona->dev, init_node);
+
+		if (init_data) {
+			init_data->consumer_supplies = &ldo1->supply;
+			init_data->num_consumer_supplies = 1;
+
+			if (dcvdd_node && dcvdd_node != init_node)
+				arizona->external_dcvdd = true;
+
+			pdata->ldo1 = init_data;
+		}
+	} else if (dcvdd_node) {
+		arizona->external_dcvdd = true;
+	}
+
+	of_node_put(dcvdd_node);
+
 	return 0;
 }
+
+static void arizona_ldo1_of_put_pdata(struct regulator_config *config)
+{
+	of_node_put(config->of_node);
+}
 #else
-static inline int arizona_ldo1_of_get_pdata(struct arizona *arizona)
+static inline int arizona_ldo1_of_get_pdata(struct arizona *arizona,
+					    struct regulator_config *config)
 {
 	return 0;
 }
+
+static inline void arizona_ldo1_of_put_pdata(struct regulator_config *config)
+{
+}
 #endif
 
 static int arizona_ldo1_probe(struct platform_device *pdev)
@@ -233,7 +271,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 	config.driver_data = ldo1;
 	config.regmap = arizona->regmap;
 
-	ret = arizona_ldo1_of_get_pdata(arizona);
+	ret = arizona_ldo1_of_get_pdata(arizona, &config);
 	if (ret < 0)
 		return ret;
 
@@ -259,6 +297,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	arizona_ldo1_of_put_pdata(&config);
+
 	platform_set_drvdata(pdev, ldo1);
 
 	return 0;
-- 
1.7.2.5


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

end of thread, other threads:[~2014-03-24  8:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 10:18 [PATCH 0/5] Arizona regulator updates v3 Charles Keepax
2014-03-19 10:18 ` [PATCH 1/5] arizona: Correct small errors in the DT binding documentation Charles Keepax
2014-03-21 10:54   ` Lee Jones
2014-03-19 10:18 ` [PATCH 2/5] mfd: arizona: Fix and factor out read of device tree GPIOs Charles Keepax
2014-03-21 10:52   ` Lee Jones
2014-03-21 15:44     ` Charles Keepax
2014-03-24  8:44       ` Lee Jones
2014-03-19 10:18 ` [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core Charles Keepax
2014-03-21 10:40   ` Lee Jones
2014-03-19 10:18 ` [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree Charles Keepax
2014-03-21 10:34   ` Lee Jones
2014-03-21 15:45     ` Charles Keepax
2014-03-19 10:18 ` [PATCH 5/5] regulator: arizona-micsupp: " Charles Keepax
2014-03-21 10:28   ` Lee Jones
  -- strict thread matches above, loose matches on Subject: below --
2014-03-18 17:22 [PATCH 0/5] Arizona regulator updates v2 Charles Keepax
2014-03-18 17:22 ` [PATCH 4/5] regulator: arizona-ldo1: Add processing of init_data from device tree Charles Keepax

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.