Skip to contentSkip to conversation

Arizona regulator updates v2

PATCH In review Charles Keepax 2 participants 8 messages Mar 18, 2014 – Mar 19, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Arizona regulator updates v2

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 v1:
- Added of_node_put for nodes we take references to
- I have removed the last two MFD patches from the series and will submit seperately as they don't really depend on the rest of the series.

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                        |   40 +++++++-----
 drivers/regulator/arizona-ldo1.c                  |   68 +++++++++++++++++++++
 drivers/regulator/arizona-micsupp.c               |   50 +++++++++++++++
 include/linux/mfd/arizona/core.h                  |    3 +
 5 files changed, 166 insertions(+), 27 deletions(-)
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 1/5 arizona: Correct small errors in the DT binding documentation

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

---
 Documentation/devicetree/bindings/mfd/arizona.txt |   23 +++++++++++---------
 1 files changed, 13 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +13 -10
index 0e295c9..36a0c3d 100644
@@ -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
 	>;
 };
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH 2/5 mfd: arizona: Fix and factor out read of device tree GPIOs

In reply to Charles Keepax

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.

---
 drivers/mfd/arizona-core.c       |   33 ++++++++++++++++++++++++---------
 include/linux/mfd/arizona/core.h |    3 +++
 2 files changed, 27 insertions(+), 9 deletions(-)
drivers/mfd/arizona-core.c +24 -9
index a45aab9..333621e 100644
@@ -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",
include/linux/mfd/arizona/core.h +3 -0
index 5cf8b91..16150cc 100644
@@ -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
Signature · 1 line
1.7.2.5
#3 lore raw

PATCH 3/5 regulator: arizona-ldo1: Move setup processing from arizona-core

In reply to Charles Keepax

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.

---
 drivers/mfd/arizona-core.c       |    9 ---------
 drivers/regulator/arizona-ldo1.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 9 deletions(-)
drivers/mfd/arizona-core.c +0 -9
index 333621e..9f41eae 100644
@@ -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",
@@ -870,14 +869,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);
drivers/regulator/arizona-ldo1.c +28 -0
index b1033d3..1b59060 100644
@@ -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);
@@ -216,6 +232,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 +244,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);
Signature · 1 line
1.7.2.5
maintainer
#4 lore raw

Re: [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core

drivers/mfd/arizona-core.c int arizona_dev_init(struct arizona *arizona) · line 880

Quoted 8 lines · Charles Keepax
drivers/mfd/arizona-core.c +0 -8
-	/*
-	 * 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;
-

Actually now that I look at this again one issue here - the reason this is in the core is that if the system is using an external DCVDD it may not be building the regulator driver at all (it won't do anything at runtime) so the flag would never get set if it's done by the regulator driver.

#5 lore raw

Re: [PATCH 3/5] regulator: arizona-ldo1: Move setup processing from arizona-core

Quoted 16 lines · Mark Brown

drivers/mfd/arizona-core.c int arizona_dev_init(struct arizona *arizona) · line 880

Quoted 8 lines · Charles Keepax
drivers/mfd/arizona-core.c +0 -8
-	/*
-	 * 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;
-

Actually now that I look at this again one issue here - the reason this is in the core is that if the system is using an external DCVDD it may not be building the regulator driver at all (it won't do anything at runtime) so the flag would never get set if it's done by the regulator driver.

Ah... missed that. I will respin again.

Thanks,
Charles

#6 lore raw

PATCH 4/5 regulator: arizona-ldo1: Add processing of init_data from device tree

In reply to Charles Keepax
---
 Documentation/devicetree/bindings/mfd/arizona.txt |    7 +++
 drivers/regulator/arizona-ldo1.c                  |   46 +++++++++++++++++++-
 2 files changed, 50 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +7 -0
index 36a0c3d..9d54c70 100644
@@ -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 {
drivers/regulator/arizona-ldo1.c +43 -3

81 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#7 lore raw

PATCH 5/5 regulator: arizona-micsupp: Add processing of init_data from device tree

In reply to Charles Keepax
---
 Documentation/devicetree/bindings/mfd/arizona.txt |    6 ++-
 drivers/regulator/arizona-micsupp.c               |   50 +++++++++++++++++++++
 2 files changed, 54 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +4 -2
index 9d54c70..9c685b2 100644
@@ -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:
drivers/regulator/arizona-micsupp.c +50 -0

74 lines not on this page · raw message

Signature · 1 line
1.7.2.5