Skip to contentSkip to conversation

Add device tree support for mc13892 regulator driver

PATCH New Shawn Guo 5 participants 18 messages Dec 1, 2011 – Dec 12, 2011

Subsystems (4)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

cover Add device tree support for mc13892 regulator driver

Changes since v1:
* Drop '[PATCH 2/5] regulator: fix label names used in device tree bindings' which has been picked up
* Add binding document for mfd/mc13xxx-core device tree support
* Fix regulator/fixed.c breakage caused by interface change on of_get_regulator_init_data()
* Reword the commit message of patch #2 a little bit to make the reason for changing clear
* Retrieve the irq from gpio irq domain

Shawn Guo (4):
mfd: mc13xxx: add device tree probe support
regulator: pass device_node to of_get_regulator_init_data()
regulator: mc13892: add device tree probe support arm/imx: add mc13892 support into imx51-babbage.dts

 Documentation/devicetree/bindings/mfd/mc13xxx.txt |   50 ++++++++++
 arch/arm/boot/dts/imx51-babbage.dts               |  103 ++++++++++++++++++++-
 drivers/mfd/mc13xxx-core.c                        |  106 +++++++++++++++------
 drivers/regulator/fixed.c                         |    2 +-
 drivers/regulator/mc13892-regulator.c             |   43 ++++++--
 drivers/regulator/mc13xxx-regulator-core.c        |   57 +++++++++++
 drivers/regulator/mc13xxx.h                       |   20 ++++
 drivers/regulator/of_regulator.c                  |    7 +-
 include/linux/mfd/mc13xxx.h                       |    1 +
 include/linux/regulator/of_regulator.h            |    6 +-
 10 files changed, 345 insertions(+), 50 deletions(-)
author
#1 lore raw

PATCH v2 1/4 mfd: mc13xxx: add device tree probe support

It adds device tree probe support for mc13xxx mfd driver.

Cc Samuel Ortiz <[email protected]>
---
 Documentation/devicetree/bindings/mfd/mc13xxx.txt |   50 ++++++++++
 drivers/mfd/mc13xxx-core.c                        |  106 +++++++++++++++------
 2 files changed, 125 insertions(+), 31 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/mc13xxx.txt
Documentation/devicetree/bindings/mfd/mc13xxx.txt new file +50 -0
new file mode 100644
index 0000000..67f1718
@@ -0,0 +1,50 @@
+* Freescale MC13783/MC13892 Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible : Should be "fsl,mc13783" or "fsl,mc13892"
+
+Optional properties:
+- fsl,mc13xxx-uses-adc : Indicate the ADC is being used
+- fsl,mc13xxx-uses-codec : Indicate the Audio Codec is being used
+- fsl,mc13xxx-uses-rtc : Indicate the RTC is being used
+- fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used
+
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The bindings details of individual
+  regulator node can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+Examples:
+
+ecspi at 70010000 { /* ECSPI1 */
+	fsl,spi-num-chipselects = <2>;
+	cs-gpios = <&gpio3 24 0>, /* GPIO4_24 */
+		   <&gpio3 25 0>; /* GPIO4_25 */
+	status = "okay";
+
+	pmic: mc13892 at 0 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "fsl,mc13892";
+		spi-max-frequency = <6000000>;
+		reg = <0>;
+		interrupt-parent = <&gpio0>;
+		interrupts = <8>;
+
+		regulators {
+			sw1_reg: mc13892__sw1 {
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <1375000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+
+			sw2_reg: mc13892__sw2 {
+				regulator-min-microvolt = <900000>;
+				regulator-max-microvolt = <1850000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+		};
+	};
+};
drivers/mfd/mc13xxx-core.c +75 -31

166 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

PATCH v2 1/4 mfd: mc13xxx: add device tree probe support

Documentation/devicetree/bindings/mfd/mc13xxx.txt line 15

Quoted 4 lines · Shawn Guo
Documentation/devicetree/bindings/mfd/mc13xxx.txt new file +4 -0
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The bindings details of individual
+  regulator node can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt

How does the driver figure out which regulators map onto which subnodes?

#3 lore raw

PATCH v2 1/4 mfd: mc13xxx: add device tree probe support

Quoted 8 lines · Mark Brown

Documentation/devicetree/bindings/mfd/mc13xxx.txt line 15

Quoted 4 lines · Shawn Guo
Documentation/devicetree/bindings/mfd/mc13xxx.txt new file +4 -0
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The bindings details of individual
+  regulator node can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt

How does the driver figure out which regulators map onto which subnodes?

There should only be one sub-node named 'regulators', otherwise, DTC will report ERROR (duplicate_node_names).

Signature · 2 lines
Regards,
Shawn
#4 lore raw

PATCH v2 1/4 mfd: mc13xxx: add device tree probe support

Quoted 8 lines · Shawn Guo
Quoted 6 lines · Mark Brown
Quoted 4 lines · Shawn Guo
Documentation/devicetree/bindings/mfd/mc13xxx.txt new file +4 -0
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The bindings details of individual
+  regulator node can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
Quoted 4 lines
Quoted 1 line

How does the driver figure out which regulators map onto which subnodes?

There should only be one sub-node named 'regulators', otherwise, DTC will report ERROR (duplicate_node_names).

That doesn't answer the question - I've still no idea how the binding is supposed to map the nodes contained within regulators onto the physical regulators.

#5 lore raw

PATCH v2 1/4 mfd: mc13xxx: add device tree probe support

Quoted 9 lines · Mark Brown
Quoted 7 lines · Shawn Guo
Quoted 6 lines · Mark Brown
Quoted 4 lines · Shawn Guo
Documentation/devicetree/bindings/mfd/mc13xxx.txt new file +4 -0
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The bindings details of individual
+  regulator node can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
Quoted 9 lines
Quoted 4 lines
Quoted 1 line

How does the driver figure out which regulators map onto which subnodes?

There should only be one sub-node named 'regulators', otherwise, DTC will report ERROR (duplicate_node_names).

That doesn't answer the question - I've still no idea how the binding is supposed to map the nodes contained within regulators onto the physical regulators.

Oops, I missed the question. It's in the patch #3.

Quoted 14 lines
(quoted diff) +14 -0
+struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt(
+     struct platform_device *pdev, struct mc13xxx_regulator *regulators,
+     int num_regulators)
+{
+     struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
+     struct mc13xxx_regulator_init_data *data, *p;
+     struct device_node *parent, *child;
+     int i;
+
+     of_node_get(pdev->dev.parent->of_node);
+     parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators");
+     if (!parent)
+             return NULL;
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+     data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators,
+                         GFP_KERNEL);
+     if (!data)
+             return NULL;
+     p = data;
+
+     for_each_child_of_node(parent, child) {
+             for (i = 0; i < num_regulators; i++) {
+                     if (!of_node_cmp(child->name,
+                                      regulators[i].desc.name)) {

And here it is. It finds the regulator node by looking for the regulator name.

Regards,
Shawn

Quoted 12 lines
(quoted diff) +12 -0
+                             p->id = i;
+                             p->init_data = of_get_regulator_init_data(
+                                                     &pdev->dev, child);
+                             p->node = child;
+                             p++;
+                             break;
+                     }
+             }
+     }
+
+     return data;
+}
#6 lore raw

PATCH v2 1/4 mfd: mc13xxx: add device tree probe support

Quoted 8 lines · Shawn Guo
Quoted 3 lines · Mark Brown

That doesn't answer the question - I've still no idea how the binding is supposed to map the nodes contained within regulators onto the physical regulators.

And here it is. It finds the regulator node by looking for the regulator name.

OK, this needs to be documented in the binding documentation - people shouldn't need to look at the code to figure this out.

author
#7 lore raw

PATCH v3 1/1 mfd: mc13xxx: add device tree probe support

In reply to Shawn Guo

It adds device tree probe support for mc13xxx mfd driver.

Cc Samuel Ortiz <[email protected]>

---
Changes since v2:

* Add some note on how driver matches regulator device and the node in binding document

Since it's a small change, I only resend this patch (as v3) instead of the whole series. Hope it's fine.

Regards,
Shawn

 Documentation/devicetree/bindings/mfd/mc13xxx.txt |   53 ++++++++++
 drivers/mfd/mc13xxx-core.c                        |  106 +++++++++++++++------
 2 files changed, 128 insertions(+), 31 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/mc13xxx.txt
Documentation/devicetree/bindings/mfd/mc13xxx.txt new file +53 -0
new file mode 100644
index 0000000..4ed46a61
@@ -0,0 +1,53 @@
+* Freescale MC13783/MC13892 Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible : Should be "fsl,mc13783" or "fsl,mc13892"
+
+Optional properties:
+- fsl,mc13xxx-uses-adc : Indicate the ADC is being used
+- fsl,mc13xxx-uses-codec : Indicate the Audio Codec is being used
+- fsl,mc13xxx-uses-rtc : Indicate the RTC is being used
+- fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used
+
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The name of regulator node
+  is being used by mc13xxx regulator driver to find the correct relator
+  device.
+
+  The bindings details of individual regulator device can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+Examples:
+
+ecspi at 70010000 { /* ECSPI1 */
+	fsl,spi-num-chipselects = <2>;
+	cs-gpios = <&gpio3 24 0>, /* GPIO4_24 */
+		   <&gpio3 25 0>; /* GPIO4_25 */
+	status = "okay";
+
+	pmic: mc13892 at 0 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "fsl,mc13892";
+		spi-max-frequency = <6000000>;
+		reg = <0>;
+		interrupt-parent = <&gpio0>;
+		interrupts = <8>;
+
+		regulators {
+			sw1_reg: mc13892__sw1 {
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <1375000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+
+			sw2_reg: mc13892__sw2 {
+				regulator-min-microvolt = <900000>;
+				regulator-max-microvolt = <1850000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+		};
+	};
+};
drivers/mfd/mc13xxx-core.c +75 -31

166 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#8 lore raw

PATCH v3 1/1 mfd: mc13xxx: add device tree probe support

Hi Samuel,

Ping?

Regards,
Shawn

Quoted 20 lines · Shawn Guo

It adds device tree probe support for mc13xxx mfd driver.

Cc Samuel Ortiz <[email protected]>

---
Changes since v2:

* Add some note on how driver matches regulator device and the node in binding document

Since it's a small change, I only resend this patch (as v3) instead of the whole series. Hope it's fine.

Regards,
Shawn

 Documentation/devicetree/bindings/mfd/mc13xxx.txt |   53 ++++++++++
 drivers/mfd/mc13xxx-core.c                        |  106 +++++++++++++++------
 2 files changed, 128 insertions(+), 31 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/mc13xxx.txt
#9 lore raw

PATCH v3 1/1 mfd: mc13xxx: add device tree probe support

In reply to Shawn Guo

Hi Shawn,

Quoted 1 line · Shawn Guo

It adds device tree probe support for mc13xxx mfd driver.

Thanks, I applied this one.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author
#10 lore raw

PATCH v2 2/4 regulator: pass device_node to of_get_regulator_init_data()

In reply to Shawn Guo

It's not always true that the device_node of regulator can be found at dev->of_node at the time when of_get_regulator_init_data() is being called, because in some cases the regulator nodes in device tree do not have 'struct device' behind them until regulator_dev gets created for it by core function regulator_register().

The patch adds device_node as a new parameter to of_get_regulator_init_data(), so that caller can pass in the node of regulator directly.

Cc Mark Brown <[email protected]>
Cc Liam Girdwood <[email protected]>
---
 drivers/regulator/fixed.c              |    2 +-
 drivers/regulator/of_regulator.c       |    7 ++++---
 include/linux/regulator/of_regulator.h |    6 ++++--
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/regulator/fixed.c +1 -1
index 72abbf5..a44a017 100644
@@ -64,7 +64,7 @@ of_get_fixed_voltage_config(struct device *dev)
 	if (!config)
 		return NULL;
 
-	config->init_data = of_get_regulator_init_data(dev);
+	config->init_data = of_get_regulator_init_data(dev, dev->of_node);
 	if (!config->init_data)
 		return NULL;
 
drivers/regulator/of_regulator.c +4 -3
index acd7045..6caf641 100644
@@ -66,18 +66,19 @@ static void of_get_regulation_constraints(struct device_node *np,
  * tree node, returns a pointer to the populated struture or NULL if memory
  * alloc fails.
  */
-struct regulator_init_data *of_get_regulator_init_data(struct device *dev)
+struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
+						struct device_node *node)
 {
 	struct regulator_init_data *init_data;
 
-	if (!dev->of_node)
+	if (!node)
 		return NULL;
 
 	init_data = devm_kzalloc(dev, sizeof(*init_data), GFP_KERNEL);
 	if (!init_data)
 		return NULL; /* Out of memory? */
 
-	of_get_regulation_constraints(dev->of_node, &init_data);
+	of_get_regulation_constraints(node, &init_data);
 	return init_data;
 }
 EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
include/linux/regulator/of_regulator.h +4 -2
index d83a98d..769704f 100644
@@ -8,10 +8,12 @@
 
 #if defined(CONFIG_OF)
 extern struct regulator_init_data
-	*of_get_regulator_init_data(struct device *dev);
+	*of_get_regulator_init_data(struct device *dev,
+				    struct device_node *node);
 #else
 static inline struct regulator_init_data
-	*of_get_regulator_init_data(struct device *dev)
+	*of_get_regulator_init_data(struct device *dev,
+				    struct device_node *node)
 {
 	return NULL;
 }
Signature · 1 line
1.7.4.1
#11 lore raw

PATCH v2 2/4 regulator: pass device_node to of_get_regulator_init_data()

Quoted 40 lines · Shawn Guo

It's not always true that the device_node of regulator can be found at dev->of_node at the time when of_get_regulator_init_data() is being called, because in some cases the regulator nodes in device tree do not have 'struct device' behind them until regulator_dev gets created for it by core function regulator_register().

The patch adds device_node as a new parameter to of_get_regulator_init_data(), so that caller can pass in the node of regulator directly.

Cc Mark Brown <[email protected]>
Cc Liam Girdwood <[email protected]>

---

?drivers/regulator/fixed.c ? ? ? ? ? ? ?| ? ?2 +-
?drivers/regulator/of_regulator.c ? ? ? | ? ?7 ++++---
?include/linux/regulator/of_regulator.h | ? ?6 ++++--

?3 files changed, 9 insertions(+), 6 deletions(-)

drivers/regulator/fixed.c +1 -1
index 72abbf5..a44a017 100644
@@ -64,7 +64,7 @@ of_get_fixed_voltage_config(struct device *dev)
 ? ? ? ?if (!config)
 ? ? ? ? ? ? ? ?return NULL;
 
- ? ? ? config->init_data = of_get_regulator_init_data(dev);
+ ? ? ? config->init_data = of_get_regulator_init_data(dev, dev->of_node);
 ? ? ? ?if (!config->init_data)
 ? ? ? ? ? ? ? ?return NULL;
 
drivers/regulator/of_regulator.c +0 -0
index acd7045..6caf641 100644
@@ -66,18 +66,19 @@ static void of_get_regulation_constraints(struct device_node *np,

?* tree node, returns a pointer to the populated struture or NULL if memory ?* alloc fails.
?*/

drivers/regulator/of_regulator.c static void of_get_regulation_constraints(struct device_node *np,

Quoted 3 lines
drivers/regulator/of_regulator.c +2 -1
-struct regulator_init_data *of_get_regulator_init_data(struct device *dev)
+struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct device_node *node)

The new parameter 'node' should be added in the documentation which is above this function.

Quoted 27 lines

?{
? ? ? ?struct regulator_init_data *init_data;

- ? ? ? if (!dev->of_node)
+ ? ? ? if (!node)
? ? ? ? ? ? ? ?return NULL;

? ? ? ?init_data = devm_kzalloc(dev, sizeof(*init_data), GFP_KERNEL); ? ? ? ?if (!init_data)
? ? ? ? ? ? ? ?return NULL; /* Out of memory? */

- ? ? ? of_get_regulation_constraints(dev->of_node, &init_data);
+ ? ? ? of_get_regulation_constraints(node, &init_data); ? ? ? ?return init_data;
?}
?EXPORT_SYMBOL_GPL(of_get_regulator_init_data);

include/linux/regulator/of_regulator.h +0 -0
index d83a98d..769704f 100644
@@ -8,10 +8,12 @@
 
 ?#if defined(CONFIG_OF)

?extern struct regulator_init_data
- ? ? ? *of_get_regulator_init_data(struct device *dev);
+ ? ? ? *of_get_regulator_init_data(struct device *dev,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct device_node *node);

Quoted 8 lines

?#else
?static inline struct regulator_init_data
- ? ? ? *of_get_regulator_init_data(struct device *dev)
+ ? ? ? *of_get_regulator_init_data(struct device *dev,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct device_node *node) ?{
? ? ? ?return NULL;
?}

This was useful while adding regulator DT support for Origen board.

Quoted 8 lines

--
1.7.4.1

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss at lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

Applied
#12 lore raw

PATCH v2 2/4 regulator: pass device_node to of_get_regulator_init_data()

In reply to Shawn Guo
Quoted 5 lines · Shawn Guo

It's not always true that the device_node of regulator can be found at dev->of_node at the time when of_get_regulator_init_data() is being called, because in some cases the regulator nodes in device tree do not have 'struct device' behind them until regulator_dev gets created for it by core function regulator_register().

Applied, thanks.

author
#13 lore raw

PATCH v2 3/4 regulator: mc13892: add device tree probe support

In reply to Shawn Guo

It adds device tree probe support for mc13892-regulator driver.

Cc Mark Brown <[email protected]>
Cc Liam Girdwood <[email protected]>
---
 drivers/regulator/mc13892-regulator.c      |   43 +++++++++++++++-----
 drivers/regulator/mc13xxx-regulator-core.c |   57 ++++++++++++++++++++++++++++
 drivers/regulator/mc13xxx.h                |   20 ++++++++++
 include/linux/mfd/mc13xxx.h                |    1 +
 4 files changed, 110 insertions(+), 11 deletions(-)
drivers/regulator/mc13892-regulator.c +32 -11
index 2824804..46bfa4a 100644
@@ -527,18 +527,27 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
 	struct mc13xxx *mc13892 = dev_get_drvdata(pdev->dev.parent);
 	struct mc13xxx_regulator_platform_data *pdata =
 		dev_get_platdata(&pdev->dev);
-	struct mc13xxx_regulator_init_data *init_data;
+	struct mc13xxx_regulator_init_data *mc13xxx_data;
 	int i, ret;
+	int num_regulators = 0;
 	u32 val;
 
+	num_regulators = mc13xxx_get_num_regulators_dt(pdev);
+	if (num_regulators <= 0 && pdata)
+		num_regulators = pdata->num_regulators;
+	if (num_regulators <= 0)
+		return -EINVAL;
+
 	priv = kzalloc(sizeof(*priv) +
-		pdata->num_regulators * sizeof(priv->regulators[0]),
+		num_regulators * sizeof(priv->regulators[0]),
 		GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
+	priv->num_regulators = num_regulators;
 	priv->mc13xxx_regulators = mc13892_regulators;
 	priv->mc13xxx = mc13892;
+	platform_set_drvdata(pdev, priv);
 
 	mc13xxx_lock(mc13892);
 	ret = mc13xxx_reg_read(mc13892, MC13892_REVISION, &val);
@@ -569,11 +578,27 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
 		= mc13892_vcam_set_mode;
 	mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
 		= mc13892_vcam_get_mode;
-	for (i = 0; i < pdata->num_regulators; i++) {
-		init_data = &pdata->regulators[i];
+
+	mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
+					ARRAY_SIZE(mc13892_regulators));
+	for (i = 0; i < num_regulators; i++) {
+		struct regulator_init_data *init_data;
+		struct regulator_desc *desc;
+		struct device_node *node = NULL;
+		int id;
+
+		if (mc13xxx_data) {
+			id = mc13xxx_data[i].id;
+			init_data = mc13xxx_data[i].init_data;
+			node = mc13xxx_data[i].node;
+		} else {
+			id = pdata->regulators[i].id;
+			init_data = pdata->regulators[i].init_data;
+		}
+		desc = &mc13892_regulators[id].desc;
+
 		priv->regulators[i] = regulator_register(
-			&mc13892_regulators[init_data->id].desc,
-			&pdev->dev, init_data->init_data, priv, NULL);
+			desc, &pdev->dev, init_data, priv, node);
 
 		if (IS_ERR(priv->regulators[i])) {
 			dev_err(&pdev->dev, "failed to register regulator %s\n",
@@ -583,8 +608,6 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
 		}
 	}
 
-	platform_set_drvdata(pdev, priv);
-
 	return 0;
 err:
 	while (--i >= 0)
@@ -600,13 +623,11 @@ err_free:
 static int __devexit mc13892_regulator_remove(struct platform_device *pdev)
 {
 	struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
-	struct mc13xxx_regulator_platform_data *pdata =
-		dev_get_platdata(&pdev->dev);
 	int i;
 
 	platform_set_drvdata(pdev, NULL);
 
-	for (i = 0; i < pdata->num_regulators; i++)
+	for (i = 0; i < priv->num_regulators; i++)
 		regulator_unregister(priv->regulators[i]);
 
 	kfree(priv);
drivers/regulator/mc13xxx-regulator-core.c +57 -0

75 lines not on this page · raw message

drivers/regulator/mc13xxx.h +20 -0
index 2775826..419aee5 100644
@@ -29,6 +29,7 @@ struct mc13xxx_regulator_priv {
 	struct mc13xxx *mc13xxx;
 	u32 powermisc_pwgt_state;
 	struct mc13xxx_regulator *mc13xxx_regulators;
+	int num_regulators;
 	struct regulator_dev *regulators[];
 };
 
@@ -42,6 +43,25 @@ extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
 		int min_uV, int max_uV, unsigned *selector);
 extern int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev);
 
+#ifdef CONFIG_OF
+extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev);
+extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
+	struct platform_device *pdev, struct mc13xxx_regulator *regulators,
+	int num_regulators);
+#else
+static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
+{
+	return -ENODEV;
+}
+
+static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
+	struct platform_device *pdev, struct mc13xxx_regulator *regulators,
+	int num_regulators)
+{
+	return NULL;
+}
+#endif
+
 extern struct regulator_ops mc13xxx_regulator_ops;
 extern struct regulator_ops mc13xxx_fixed_regulator_ops;
 
include/linux/mfd/mc13xxx.h +1 -0
index 3816c2f..a98e2a3 100644
@@ -69,6 +69,7 @@ struct regulator_init_data;
 struct mc13xxx_regulator_init_data {
 	int id;
 	struct regulator_init_data *init_data;
+	struct device_node *node;
 };
 
 struct mc13xxx_regulator_platform_data {
Signature · 1 line
1.7.4.1
#14 lore raw

PATCH v2 3/4 regulator: mc13892: add device tree probe support

Hi Mark,

Ping?

Regards,
Shawn

Quoted 11 lines · Shawn Guo

It adds device tree probe support for mc13892-regulator driver.

Cc Mark Brown <[email protected]>
Cc Liam Girdwood <[email protected]>
---
 drivers/regulator/mc13892-regulator.c      |   43 +++++++++++++++-----
 drivers/regulator/mc13xxx-regulator-core.c |   57 ++++++++++++++++++++++++++++
 drivers/regulator/mc13xxx.h                |   20 ++++++++++
 include/linux/mfd/mc13xxx.h                |    1 +
 4 files changed, 110 insertions(+), 11 deletions(-)
#15 lore raw

PATCH v2 3/4 regulator: mc13892: add device tree probe support

Quoted 1 line · Shawn Guo

Ping?

I was rather expecting you to respin the series...

author
#17 lore raw

PATCH v2 4/4 arm/imx: add mc13892 support into imx51-babbage.dts

In reply to Shawn Guo

It adds mc13892 support into imx51-babbage device tree source.

Cc Sascha Hauer <[email protected]>
---
 arch/arm/boot/dts/imx51-babbage.dts |  103 ++++++++++++++++++++++++++++++++++-
 1 files changed, 101 insertions(+), 2 deletions(-)
arch/arm/boot/dts/imx51-babbage.dts +101 -2
index f8766af..407fc0b 100644
@@ -31,12 +31,14 @@
 				esdhc at 70004000 { /* ESDHC1 */
 					fsl,cd-internal;
 					fsl,wp-internal;
+					vmmc-supply = <&vsd_reg>;
 					status = "okay";
 				};
 
 				esdhc at 70008000 { /* ESDHC2 */
 					cd-gpios = <&gpio0 6 0>; /* GPIO1_6 */
 					wp-gpios = <&gpio0 5 0>; /* GPIO1_5 */
+					vmmc-supply = <&vsd_reg>;
 					status = "okay";
 				};
 
@@ -57,8 +59,105 @@
 						compatible = "fsl,mc13892";
 						spi-max-frequency = <6000000>;
 						reg = <0>;
-						mc13xxx-irq-gpios = <&gpio0 8 0>; /* GPIO1_8 */
-						fsl,mc13xxx-uses-regulator;
+						interrupt-parent = <&gpio0>;
+						interrupts = <8>;
+
+						regulators {
+							sw1_reg: mc13892__sw1 {
+								regulator-min-microvolt = <600000>;
+								regulator-max-microvolt = <1375000>;
+								regulator-boot-on;
+								regulator-always-on;
+							};
+
+							sw2_reg: mc13892__sw2 {
+								regulator-min-microvolt = <900000>;
+								regulator-max-microvolt = <1850000>;
+								regulator-boot-on;
+								regulator-always-on;
+							};
+
+							sw3_reg: mc13892__sw3 {
+								regulator-min-microvolt = <1100000>;
+								regulator-max-microvolt = <1850000>;
+								regulator-boot-on;
+								regulator-always-on;
+							};
+
+							sw4_reg: mc13892__sw4 {
+								regulator-min-microvolt = <1100000>;
+								regulator-max-microvolt = <1850000>;
+								regulator-boot-on;
+								regulator-always-on;
+							};
+
+							viohi_reg: mc13892__viohi {
+								regulator-boot-on;
+								regulator-always-on;
+							};
+
+							vpll_reg: mc13892__vpll {
+								regulator-min-microvolt = <1050000>;
+								regulator-max-microvolt = <1800000>;
+								regulator-boot-on;
+								regulator-always-on;
+							};
+
+							vdig_reg: mc13892__vdig {
+								regulator-min-microvolt = <1650000>;
+								regulator-max-microvolt = <1650000>;
+								regulator-boot-on;
+							};
+
+							vsd_reg: mc13892__vsd {
+								regulator-min-microvolt = <1800000>;
+								regulator-max-microvolt = <3150000>;
+							};
+
+							vusb2_reg: mc13892__vusb2 {
+								regulator-min-microvolt = <2400000>;
+								regulator-max-microvolt = <2775000>;
+								regulator-boot-on;
+								regulator-always-on;
+							};
+
+							vvideo_reg: mc13892__vvideo {
+								regulator-min-microvolt = <2775000>;
+								regulator-max-microvolt = <2775000>;
+							};
+
+							vaudio_reg: mc13892__vaudio {
+								regulator-min-microvolt = <2300000>;
+								regulator-max-microvolt = <3000000>;
+							};
+
+							vcam_reg: mc13892__vcam {
+								regulator-min-microvolt = <2500000>;
+								regulator-max-microvolt = <3000000>;
+							};
+
+							vgen1_reg: mc13892__vgen1 {
+								regulator-min-microvolt = <1200000>;
+								regulator-max-microvolt = <1200000>;
+							};
+
+							vgen2_reg: mc13892__vgen2 {
+								regulator-min-microvolt = <1200000>;
+								regulator-max-microvolt = <3150000>;
+								regulator-always-on;
+							};
+
+							vgen3_reg: mc13892__vgen3 {
+								regulator-min-microvolt = <1800000>;
+								regulator-max-microvolt = <2900000>;
+								regulator-always-on;
+							};
+
+							vusb_reg: mc13892__vusb {
+								regulator-boot-on;
+								regulator-always-on;
+							};
+						};
 					};
 
 					flash: at45db321d at 1 {
Signature · 1 line
1.7.4.1