mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yadwinder Singh Brar <yadi.brar01@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: sameo@linux.intel.com,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@ti.com>,
	Jonghwa Lee <jonghwa3.lee@samsung.com>,
	Myungjoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Chiwoong Byun <woong.byun@samsung.com>,
	Yadwinder Singh Brar <yadi.brar@samsung.com>
Subject: [PATCH v3] mfd: max77686: Add device tree support.
Date: Fri,  6 Jul 2012 17:02:55 +0530	[thread overview]
Message-ID: <1341574375-17397-1-git-send-email-yadi.brar@samsung.com> (raw)
In-Reply-To: <20120705124141.GB4111@opensource.wolfsonmicro.com>

This patch adds device tree support for mfd driver and adds
Documentation/devicetree/bindings/mfd/max77686.txt.
This patch also intialize max77686 pointer to NULL in max77686_i2c_probe
to silent a compile time warning.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 Documentation/devicetree/bindings/mfd/max77686.txt |   59 ++++++++++++++++++++
 drivers/mfd/max77686.c                             |   45 +++++++++++++--
 2 files changed, 98 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/max77686.txt

diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt b/Documentation/devicetree/bindings/mfd/max77686.txt
new file mode 100644
index 0000000..c6a3469
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max77686.txt
@@ -0,0 +1,59 @@
+Maxim MAX77686 multi-function device
+
+MAX77686 is a Mulitifunction device with PMIC, RTC and Charger on chip. It is
+interfaced to host controller using i2c interface. PMIC and Charger submodules
+are addressed using same i2c slave address whereas RTC submodule uses
+different i2c slave address,presently for which we are statically creating i2c
+client while probing.This document describes the binding for mfd device and
+PMIC submodule.
+
+Required properties:
+- compatible : Must be "maxim,max77686";
+- reg : Specifies the i2c slave address of PMIC block.
+- interrupts : This i2c device has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+- voltage-regulators : The regulators of max77686 have to be instantiated
+  under subnode named "voltage-regulators" using the following format.
+
+	regulator_name {
+		regulator-compatible = LDOn/BUCKn
+		standard regulator constraints....
+	};
+	refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+  The regulator-compatible property of regulator should initialized with string
+to get matched with their hardware counterparts as follow:
+
+	-LDOn 	:	for LDOs, where n can lie in range 1 to 26.
+		 	example: LDO1, LDO2, LDO26.
+	-BUCKn 	:	for BUCKs, where n can lie in range 1 to 9.
+			example: BUCK1, BUCK5, BUCK9.
+
+Example:
+
+	max77686@09 {
+		compatible = "maxim,max77686";
+		interrupt-parent = <&wakeup_eint>;
+		interrupts = <26 0>;
+		reg = <0x09>;
+
+		voltage-regulators {
+			ldo11_reg {
+				regulator-compatible = "LDO11";
+				regulator-name = "vdd_ldo11";
+				regulator-min-microvolt = <1900000>;
+				regulator-max-microvolt = <1900000>;
+				regulator-always-on;
+			};
+
+			buck1_reg {
+				regulator-compatible = "BUCK1";
+				regulator-name = "vdd_mif";
+				regulator-min-microvolt = <950000>;
+				regulator-max-microvolt = <1300000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+	}
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index 5c78e94..e0d95d6 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -35,6 +35,11 @@
 
 #define I2C_ADDR_RTC	(0x0C >> 1)
 
+static struct of_device_id __devinitdata max77686_pmic_dt_match[] = {
+	{.compatible = "maxim,max77686",        .data = 0},
+	{},
+};
+
 static struct mfd_cell max77686_devs[] = {
 	{ .name = "max77686-pmic", },
 	{ .name = "max77686-rtc", },
@@ -45,14 +50,46 @@ static struct regmap_config max77686_regmap_config = {
 	.val_bits = 8,
 };
 
+#ifdef CONFIG_OF
+static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
+								  *dev)
+{
+	struct max77686_platform_data *pd;
+
+	pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
+	if (!pd) {
+		dev_err(dev, "could not allocate memory for pdata\n");
+		return NULL;
+	}
+
+	dev->platform_data = pd;
+	return pd;
+}
+#else
+static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
+								  *dev)
+{
+	return 0;
+}
+#endif
+
 static int max77686_i2c_probe(struct i2c_client *i2c,
 			      const struct i2c_device_id *id)
 {
-	struct max77686_dev *max77686;
+	struct max77686_dev *max77686 = NULL;
 	struct max77686_platform_data *pdata = i2c->dev.platform_data;
 	unsigned int data;
 	int ret = 0;
 
+	if (i2c->dev.of_node)
+		pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
+
+	if (!pdata) {
+		ret = -EIO;
+		dev_err(&i2c->dev, "No platform data found.\n");
+		goto err;
+	}
+
 	max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL);
 	if (max77686 == NULL)
 		return -ENOMEM;
@@ -71,11 +108,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	max77686->i2c = i2c;
 	max77686->type = id->driver_data;
 
-	if (!pdata) {
-		ret = -EIO;
-		goto err;
-	}
-
 	max77686->wakeup = pdata->wakeup;
 	max77686->irq_gpio = pdata->irq_gpio;
 	max77686->irq = i2c->irq;
@@ -133,6 +165,7 @@ static struct i2c_driver max77686_i2c_driver = {
 	.driver = {
 		   .name = "max77686",
 		   .owner = THIS_MODULE,
+		   .of_match_table = of_match_ptr(max77686_pmic_dt_match),
 	},
 	.probe = max77686_i2c_probe,
 	.remove = max77686_i2c_remove,
-- 
1.7.0.4


  parent reply	other threads:[~2012-07-06 11:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05  3:58 [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register Yadwinder Singh Brar
2012-07-05  3:58 ` [PATCH 2/6] mfd: max77686: Apply irq_mask_cur before handling interrupts Yadwinder Singh Brar
2012-07-05  3:58 ` [PATCH 3/6] mfd: max77686: Allow to specify interrupt through DT or platform file also Yadwinder Singh Brar
2012-07-05  3:58 ` [PATCH 4/6] mfd: max77686: Add device tree support Yadwinder Singh Brar
2012-07-05 12:41   ` Mark Brown
2012-07-05 13:37     ` Yadwinder Singh Brar
2012-07-06  8:56     ` [PATCH v2] " Yadwinder Singh Brar
2012-07-06 11:32     ` Yadwinder Singh Brar [this message]
2012-07-06 18:09       ` [PATCH v3] " Mark Brown
2012-07-05  3:58 ` [PATCH 5/6] mfd: max77686: Remove the clocks from the list of regulators Yadwinder Singh Brar
2012-07-05  3:58 ` [PATCH 6/6] regulator: max77686: Add device tree support Yadwinder Singh Brar
2012-07-05 12:42   ` Mark Brown
2012-07-09 11:25 ` [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register Samuel Ortiz

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=1341574375-17397-1-git-send-email-yadi.brar@samsung.com \
    --to=yadi.brar01@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=jonghwa3.lee@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=sameo@linux.intel.com \
    --cc=woong.byun@samsung.com \
    --cc=yadi.brar@samsung.com \
    /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

all inboxes | Powered by JetHome®