Skip to contentSkip to conversation

Arizona regulator updates

PATCH Applied Charles Keepax 2 participants 15 messages Mar 18, 2014

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

cover Arizona regulator updates

Hi,

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

I would probably suggest putting the whole series through the regulator tree since that is the focus of the work.

Thanks,
Charles

Charles Keepax (8):
arizona: Correct small errors in the DT binding documentation
mfd: arizona: 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
mfd: arizona: Add MICVDD to mapped regulators
mfd: wm8997: Add registers for high power mode
regulator: arizona-ldo1: Correct default regulator init_data

 Documentation/devicetree/bindings/mfd/arizona.txt |   32 ++++++---
 drivers/mfd/arizona-core.c                        |   41 +++++++-----
 drivers/mfd/wm8997-tables.c                       |    2 +
 drivers/regulator/arizona-ldo1.c                  |   74 ++++++++++++++++++---
 drivers/regulator/arizona-micsupp.c               |   47 ++++++++++++-
 include/linux/mfd/arizona/core.h                  |    3 +
 6 files changed, 159 insertions(+), 40 deletions(-)
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 1/8 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/8 mfd: arizona: Factor out read of device tree GPIOs

In reply to Charles Keepax

Factor out the reading of GPIOs for the Arizona devices into a helper function.

---
 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..97eafce 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);
+	*gpio = ret;
+	if (ret >= 0)
+		return ret;
+
+	*gpio = 0;
+
+	if (mandatory)
+		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/8 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 |   41 +++++++++++++++++++++++++++++++++----
 2 files changed, 36 insertions(+), 14 deletions(-)
drivers/mfd/arizona-core.c +0 -9
index 97eafce..0bab354 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 +36 -5

54 lines not on this page · raw message

Signature · 1 line
1.7.2.5
maintainer
#4 lore raw

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

Quoted 6 lines · Charles Keepax
drivers/regulator/arizona-ldo1.c +6 -0
+#ifdef CONFIG_OF
+static int arizona_ldo1_get_pdata(struct arizona *arizona,
+				  struct regulator_config *config)
+{
+	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true,
+				  &config->ena_gpio);

drivers/regulator/arizona-ldo1.c static const struct regulator_init_data arizona_ldo1_default = { · line 198

Quoted 10 lines
drivers/regulator/arizona-ldo1.c +10 -0
+
+	return 0;
+}
+#else
+static inline int arizona_ldo1_get_pdata(struct arizona *arizona,
+					 struct regulator_config *config)
+{
+	struct arizona_pdata *pdata = &arizona->pdata;
+
+	config->ena_gpio = arizona->pdata.ldoena;

This breaks non-DT systems booting a kernel which has DT support compiled in. It's also more than simple code motion which is what the changelog claimed this was doing.

#5 lore raw

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

Quoted 14 lines · Mark Brown
Quoted 12 lines · Charles Keepax
drivers/regulator/arizona-ldo1.c +12 -0
+#ifdef CONFIG_OF
+static int arizona_ldo1_get_pdata(struct arizona *arizona,
+				  struct regulator_config *config)
+{
+	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true,
+				  &config->ena_gpio);
+
+	return 0;
+}
+#else
+static inline int arizona_ldo1_get_pdata(struct arizona *arizona,
+					 struct regulator_config *config)
Quoted 8 lines

drivers/regulator/arizona-ldo1.c static const struct regulator_init_data arizona_ldo1_default = { · line 198

Quoted 4 lines
drivers/regulator/arizona-ldo1.c +4 -0
+{
+	struct arizona_pdata *pdata = &arizona->pdata;
+
+	config->ena_gpio = arizona->pdata.ldoena;

This breaks non-DT systems booting a kernel which has DT support compiled in. It's also more than simple code motion which is what the changelog claimed this was doing.

Oops.. sorry that is a good point I will respin these.

Thanks,
Charles

#6 lore raw

PATCH 4/8 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                  |   26 +++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +7 -0
index 36a0c3d..d78f1aa 100644
@@ -42,6 +42,13 @@ Optional properties:
     the chip default will be used.  If present exactly five values must
     be specified.
 
+  - wlf,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 +26 -0
index 6379fd3..a67013f 100644
@@ -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>
 
@@ -184,9 +185,34 @@ static const struct regulator_init_data arizona_ldo1_default = {
 static int arizona_ldo1_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 *np_init, *np_dcvdd;
+
 	arizona_of_get_named_gpio(arizona, "wlf,ldoena", true,
 				  &config->ena_gpio);
 
+	np_init = of_get_child_by_name(arizona->dev->of_node, "wlf,ldo1");
+	np_dcvdd = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0);
+
+	if (np_init) {
+		config->of_node = np_init;
+
+		pdata->ldo1 = of_get_regulator_init_data(arizona->dev, np_init);
+
+		if (np_dcvdd) {
+			if (np_dcvdd != np_init)
+				arizona->external_dcvdd = true;
+		} else {
+			pdata->ldo1->consumer_supplies = &ldo1->supply;
+			pdata->ldo1->num_consumer_supplies = 1;
+		}
+
+		config->init_data = pdata->ldo1;
+	} else if (np_dcvdd) {
+		arizona->external_dcvdd = true;
+	}
+
 	return 0;
 }
 #else
Signature · 1 line
1.7.2.5
maintainer
#7 lore raw

Re: [PATCH 4/8] regulator: arizona-ldo1: Add processing of init_data from device tree

Review

Quoted 2 lines · Charles Keepax
(quoted diff) +2 -0
+  - wlf,ldo1 : Initial data for the LDO1 regulator, as covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt

We don't normally prefix the names of the regulator data with a vendor.

drivers/regulator/arizona-ldo1.c static const struct regulator_init_data arizona_ldo1_default = { · line 195

Quoted 1 line
drivers/regulator/arizona-ldo1.c +1 -0
+	np_init = of_get_child_by_name(arizona->dev->of_node, "wlf,ldo1");

You're missing an of_node_put() for this and if you're going to use hungarian notation please use a convention other people use. Calling things _node seems more common.

#8 lore raw

Re: [PATCH 4/8] regulator: arizona-ldo1: Add processing of init_data from device tree

Quoted 5 lines · Mark Brown

Review

Quoted 2 lines · Charles Keepax
(quoted diff) +2 -0
+  - wlf,ldo1 : Initial data for the LDO1 regulator, as covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt
Quoted 7 lines

We don't normally prefix the names of the regulator data with a vendor.

drivers/regulator/arizona-ldo1.c static const struct regulator_init_data arizona_ldo1_default = { · line 195

Quoted 1 line
drivers/regulator/arizona-ldo1.c +1 -0
+	np_init = of_get_child_by_name(arizona->dev->of_node, "wlf,ldo1");

You're missing an of_node_put() for this and if you're going to use hungarian notation please use a convention other people use. Calling things _node seems more common.

The DCVDD one needs an of_node_put but I am not sure this one does. As it will be copied into the regulator device of_node by the regulator core so wont of_node_put be called when the device is destroyed? Admittedly I haven't checked that but seems sensible that the device structure would put its of_node when it closes down.

Thanks,
Charles

maintainer
#9 lore raw

Re: [PATCH 4/8] regulator: arizona-ldo1: Add processing of init_data from device tree

Quoted 9 lines · Charles Keepax
Quoted 7 lines · Mark Brown

drivers/regulator/arizona-ldo1.c static const struct regulator_init_data arizona_ldo1_default = { · line 195

Quoted 1 line · Charles Keepax
drivers/regulator/arizona-ldo1.c +1 -0
+	np_init = of_get_child_by_name(arizona->dev->of_node, "wlf,ldo1");

You're missing an of_node_put() for this and if you're going to use hungarian notation please use a convention other people use. Calling things _node seems more common.

Quoted 6 lines

The DCVDD one needs an of_node_put but I am not sure this one does. As it will be copied into the regulator device of_node by the regulator core so wont of_node_put be called when the device is destroyed? Admittedly I haven't checked that but seems sensible that the device structure would put its of_node when it closes down.

You just took an extra reference by calling of_get_child_by_name(), you need to free it.

#10 lore raw

PATCH 5/8 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               |   47 +++++++++++++++++++--
 2 files changed, 47 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +4 -2
index d78f1aa..88c1c0f 100644
@@ -44,9 +44,11 @@ Optional properties:
 
   - wlf,ldo1 : Initial data for the LDO1 regulator, as covered in
     Documentation/devicetree/bindings/regulator/regulator.txt
+  - wlf,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 +43 -4

66 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#11 lore raw

PATCH 6/8 mfd: arizona: Add MICVDD to mapped regulators

In reply to Charles Keepax

Currently, MICVDD only binds because it is both the regulator name and the consumer name and we will always match against the regulator name regardless of the consumer device. If the regulator was renamed using the init_data ASoC will no longer be able to locate the supply, as it will be looking on the CODEC device where as the MICVDD consumer is on the Arizona device. Add a mapping as we do for the other regulators.

---
 drivers/mfd/arizona-core.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +1 -0
index 0bab354..06e3f1b 100644
@@ -589,6 +589,7 @@ static const char *wm5102_supplies[] = {
 	"CPVDD",
 	"SPKVDDL",
 	"SPKVDDR",
+	"MICVDD",
 };
 
 static const struct mfd_cell wm5102_devs[] = {
Signature · 1 line
1.7.2.5
#12 lore raw

PATCH 7/8 mfd: wm8997: Add registers for high power mode

In reply to Charles Keepax

Some output configurations can require a 50Mhz SYSCLK which requires DCVDD to be 1.8V. This patch adds the registers necessary for supporting this operational mode.

---
 drivers/mfd/wm8997-tables.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/mfd/wm8997-tables.c +2 -0
index 5aa8076..c9c6519 100644
@@ -846,6 +846,7 @@ static bool wm8997_readable_register(struct device *dev, unsigned int reg)
 	case ARIZONA_RATE_ESTIMATOR_3:
 	case ARIZONA_RATE_ESTIMATOR_4:
 	case ARIZONA_RATE_ESTIMATOR_5:
+	case ARIZONA_DYNAMIC_FREQUENCY_SCALING_1:
 	case ARIZONA_FLL1_CONTROL_1:
 	case ARIZONA_FLL1_CONTROL_2:
 	case ARIZONA_FLL1_CONTROL_3:
@@ -880,6 +881,7 @@ static bool wm8997_readable_register(struct device *dev, unsigned int reg)
 	case ARIZONA_FLL2_GPIO_CLOCK:
 	case ARIZONA_MIC_CHARGE_PUMP_1:
 	case ARIZONA_LDO1_CONTROL_1:
+	case ARIZONA_LDO1_CONTROL_2:
 	case ARIZONA_LDO2_CONTROL_1:
 	case ARIZONA_MIC_BIAS_CTRL_1:
 	case ARIZONA_MIC_BIAS_CTRL_2:
Signature · 1 line
1.7.2.5
#13 lore raw

PATCH 8/8 regulator: arizona-ldo1: Correct default regulator init_data

In reply to Charles Keepax

Both 5102 and 8997 have the regulator capable of supplying 1.8V, and the voltage step from the 5110 regulator is different from what is specified in the default description. This patch updates the default regulator description to match 5110 and selects the 1.8V capable description for 8997.

---
 drivers/regulator/arizona-ldo1.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/regulator/arizona-ldo1.c +3 -4
index a67013f..9a3c292 100644
@@ -154,11 +154,9 @@ static const struct regulator_desc arizona_ldo1 = {
 
 	.vsel_reg = ARIZONA_LDO1_CONTROL_1,
 	.vsel_mask = ARIZONA_LDO1_VSEL_MASK,
-	.bypass_reg = ARIZONA_LDO1_CONTROL_1,
-	.bypass_mask = ARIZONA_LDO1_BYPASS,
 	.min_uV = 900000,
-	.uV_step = 50000,
-	.n_voltages = 7,
+	.uV_step = 25000,
+	.n_voltages = 13,
 	.enable_time = 500,
 
 	.owner = THIS_MODULE,
@@ -261,6 +259,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 	 */
 	switch (arizona->type) {
 	case WM5102:
+	case WM8997:
 		desc = &arizona_ldo1_hc;
 		ldo1->init_data = arizona_ldo1_dvfs;
 		break;
Signature · 1 line
1.7.2.5
maintainer Applied
#14 lore raw

Re: [PATCH 8/8] regulator: arizona-ldo1: Correct default regulator init_data

Quoted 5 lines · Charles Keepax

Both 5102 and 8997 have the regulator capable of supplying 1.8V, and the voltage step from the 5110 regulator is different from what is specified in the default description. This patch updates the default regulator description to match 5110 and selects the 1.8V capable description for 8997.

Applied, thanks. This should probably have been two patches.