linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 07/16] regulator: Enable Device Tree for the db8500-prcmu regulator driver
Date: Fri, 18 May 2012 09:39:06 +0100	[thread overview]
Message-ID: <1337330355-17747-8-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1337330355-17747-1-git-send-email-lee.jones@linaro.org>

Here we use the previous regulator register code separated from probe to
register each of the regulators mentioned in Device Tree.

Cc: linux-kernel at vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/regulator/db8500-prcmu.c |   76 ++++++++++++++++++++++++++++++++++----
 1 file changed, 69 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index d6b4d4c..968f97f 100644
--- a/drivers/regulator/db8500-prcmu.c
+++ b/drivers/regulator/db8500-prcmu.c
@@ -17,6 +17,8 @@
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/db8500-prcmu.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/of.h>
 #include <linux/module.h>
 #include "dbx500-prcmu.h"
 
@@ -449,23 +451,77 @@ static __devinit int db8500_regulator_register(struct platform_device *pdev,
 	return 0;
 }
 
+static struct of_regulator_match db8500_regulator_matches[] = {
+	{ .name	= "db8500-vape",          .driver_data = (void *) DB8500_REGULATOR_VAPE, },
+	{ .name	= "db8500-varm",          .driver_data = (void *) DB8500_REGULATOR_VARM, },
+	{ .name	= "db8500-vmodem",        .driver_data = (void *) DB8500_REGULATOR_VMODEM, },
+	{ .name	= "db8500-vpll",          .driver_data = (void *) DB8500_REGULATOR_VPLL, },
+	{ .name	= "db8500-vsmps1",        .driver_data = (void *) DB8500_REGULATOR_VSMPS1, },
+	{ .name	= "db8500-vsmps2",        .driver_data = (void *) DB8500_REGULATOR_VSMPS2, },
+	{ .name	= "db8500-vsmps3",        .driver_data = (void *) DB8500_REGULATOR_VSMPS3, },
+	{ .name	= "db8500-vrf1",          .driver_data = (void *) DB8500_REGULATOR_VRF1, },
+	{ .name	= "db8500-sva-mmdsp",     .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSP, },
+	{ .name	= "db8500-sva-mmdsp-ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSPRET, },
+	{ .name	= "db8500-sva-pipe",      .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAPIPE, },
+	{ .name	= "db8500-sia-mmdsp",     .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSP, },
+	{ .name	= "db8500-sia-mmdsp-ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSPRET, },
+	{ .name	= "db8500-sia-pipe",      .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAPIPE, },
+	{ .name	= "db8500-sga",           .driver_data = (void *) DB8500_REGULATOR_SWITCH_SGA, },
+	{ .name	= "db8500-b2r2-mcde",     .driver_data = (void *) DB8500_REGULATOR_SWITCH_B2R2_MCDE, },
+	{ .name	= "db8500-esram12",       .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12, },
+	{ .name	= "db8500-esram12-ret",   .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12RET, },
+	{ .name	= "db8500-esram34",       .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34, },
+	{ .name	= "db8500-esram34-ret",   .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34RET, },
+};
+
+static __devinit int
+db8500_regulator_of_probe(struct platform_device *pdev,
+			struct device_node *np)
+{
+	int i, err;
+
+	for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
+		err = db8500_regulator_register(
+			pdev, db8500_regulator_matches[i].init_data,
+			i, db8500_regulator_matches[i].of_node);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
 static int __devinit db8500_regulator_probe(struct platform_device *pdev)
 {
 	struct regulator_init_data *db8500_init_data =
 					dev_get_platdata(&pdev->dev);
+	struct device_node *np = pdev->dev.of_node;
 	int i, err;
 
 	/* register all regulators */
-	for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
-		err = db8500_regulator_register(pdev,
-						&db8500_init_data[i],
-						i, NULL);
-		if (err)
+	if (np) {
+		err = of_regulator_match(&pdev->dev, np,
+					db8500_regulator_matches,
+					ARRAY_SIZE(db8500_regulator_matches));
+		if (err < 0) {
+			dev_err(&pdev->dev,
+				"Error parsing regulator init data: %d\n", err);
 			return err;
+		}
 
-		dev_dbg(rdev_get_dev(info->rdev),
-			"regulator-%s-probed\n", info->desc.name);
+		err = db8500_regulator_of_probe(pdev, np);
+		if (err)
+			return err;
+	} else {
+		for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
+			err = db8500_regulator_register(pdev,
+							&db8500_init_data[i],
+							i, NULL);
+			if (err)
+				return err;
+		}
 	}
+
 	err = ux500_regulator_debug_init(pdev,
 					 dbx500_regulator_info,
 					 ARRAY_SIZE(dbx500_regulator_info));
@@ -491,10 +547,16 @@ static int __exit db8500_regulator_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id db8500_prcmu_regulator_match[] = {
+        { .compatible = "stericsson,db8500-prcmu-regulator", },
+        {}
+};
+
 static struct platform_driver db8500_regulator_driver = {
 	.driver = {
 		.name = "db8500-prcmu-regulators",
 		.owner = THIS_MODULE,
+		.of_match_table = db8500_prcmu_regulator_match,
 	},
 	.probe = db8500_regulator_probe,
 	.remove = __exit_p(db8500_regulator_remove),
-- 
1.7.9.5

  parent reply	other threads:[~2012-05-18  8:39 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-18  8:38 [PATCH 00/16] The last large installment of DT for Snowball Lee Jones
2012-05-18  8:39 ` [PATCH 01/16] Input: Add Device Tree support to the ab8500-ponkey driver Lee Jones
2012-05-21 21:32   ` Linus Walleij
2012-06-12  7:22     ` Dmitry Torokhov
2012-05-18  8:39 ` [PATCH 02/16] ARM: ux500: Enable LED heartbeat functionality on Snowball Lee Jones
2012-05-21 21:33   ` Linus Walleij
2012-05-22  7:38     ` Lee Jones
2012-05-18  8:39 ` [PATCH 03/16] ARM: ux500: Enable LED heartbeat functionality on Snowbal via DT Lee Jones
2012-05-21 21:34   ` Linus Walleij
2012-05-18  8:39 ` [PATCH 04/16] ARM: ux500: Only initialise STE's UIBs on boards which support them Lee Jones
2012-05-21 21:36   ` Linus Walleij
2012-05-22  7:39     ` Lee Jones
2012-05-18  8:39 ` [PATCH 05/16] regulator: db8500-prcmu: Separate regulator registration from probe Lee Jones
2012-05-18 15:36   ` Mark Brown
2012-05-21  6:58   ` Linus Walleij
2012-05-18  8:39 ` [PATCH 06/16] ARM: ux500: Apply db8500-prcmu regulator information to db8500 Device Tree Lee Jones
2012-05-21 21:37   ` Linus Walleij
2012-05-22  7:41     ` Lee Jones
2012-05-29  1:51   ` Linus Walleij
2012-05-18  8:39 ` Lee Jones [this message]
2012-05-18 15:36   ` [PATCH 07/16] regulator: Enable Device Tree for the db8500-prcmu regulator driver Mark Brown
2012-05-21  6:59   ` Linus Walleij
2012-05-18  8:39 ` [PATCH 08/16] ARM: ux500: Allow PRCMU regulator to be probed during a DT enabled boot Lee Jones
2012-05-21 21:37   ` Linus Walleij
2012-05-18  8:39 ` [PATCH 09/16] ARM: ux500: Provide regulator support for SMSC911x via Device Tree Lee Jones
2012-05-21 21:42   ` Linus Walleij
2012-05-22  6:44     ` Arnd Bergmann
2012-05-22  7:46     ` Lee Jones
2012-05-18  8:39 ` [PATCH 10/16] ARM: ux500: Add db8500 Device Tree node for ab8500-sysctrl Lee Jones
2012-05-21 21:43   ` Linus Walleij
2012-05-18  8:39 ` [PATCH 11/16] mfd: Enable Device Tree support in the ab8500-sysctrl driver Lee Jones
2012-05-19 15:35   ` Samuel Ortiz
2012-05-18  8:39 ` [PATCH 12/16] ARM: ux500: Add db8500 Device Tree node for misc/ab8500-pwm Lee Jones
2012-05-21 21:43   ` Linus Walleij
2012-05-18  8:39 ` [PATCH 13/16] mfd: Enable Device Tree support in the ab8500-pwm driver Lee Jones
2012-05-19 15:35   ` Samuel Ortiz
2012-05-18  8:39 ` [PATCH 14/16] ARM: ux500: Add a ab8500-usb Device Tree node for db8500 based devices Lee Jones
2012-05-21 21:44   ` Linus Walleij
2012-05-18  8:39 ` [PATCH 15/16] ARM: ux500: Add regulator support for nomadik-i2c into the db8500 Device Tree Lee Jones
2012-05-21 21:45   ` Linus Walleij
2012-05-22  8:00     ` Lee Jones
2012-05-29  1:53       ` Linus Walleij
2012-05-29  4:50         ` Lee Jones
2012-05-30  0:09           ` Linus Walleij
2012-05-30  0:33             ` Lee Jones
2012-05-30  2:51               ` Linus Walleij
2012-05-18  8:39 ` [PATCH 16/16] ARM: ux500: Re-enable SMSC911x platform code registration during non-DT boots Lee Jones
2012-05-21 21:46   ` Linus Walleij
2012-05-22  8:01     ` Lee Jones
2012-05-29  1:54       ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337330355-17747-8-git-send-email-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).