linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register.
@ 2012-07-05  3:58 Yadwinder Singh Brar
  2012-07-05  3:58 ` [PATCH 2/6] mfd: max77686: Apply irq_mask_cur before handling interrupts Yadwinder Singh Brar
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-05  3:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

PMIC's regmap should be used to read pmic interrupt registers.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 drivers/mfd/max77686-irq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/max77686-irq.c b/drivers/mfd/max77686-irq.c
index fc10122..09e593a 100644
--- a/drivers/mfd/max77686-irq.c
+++ b/drivers/mfd/max77686-irq.c
@@ -180,7 +180,7 @@ static irqreturn_t max77686_irq_thread(int irq, void *data)
 		pr_info("%s: irq_src=0x%x\n", __func__, irq_src);
 
 	if (irq_src == MAX77686_IRQSRC_PMIC) {
-		ret = regmap_bulk_read(max77686->rtc_regmap,
+		ret = regmap_bulk_read(max77686->regmap,
 					 MAX77686_REG_INT1, irq_reg, 2);
 		if (ret < 0) {
 			dev_err(max77686->dev, "Failed to read interrupt source: %d\n",
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/6] mfd: max77686: Apply irq_mask_cur before handling interrupts.
  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 ` 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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-05  3:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

According to TRM, though we mask the interrupts in interrupt-mask register,
interrupt source-register still provide the status of the masked interrupts.
So we should apply irq_mask_cur to read interrupt source-register value before
handling.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 drivers/mfd/max77686-irq.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/max77686-irq.c b/drivers/mfd/max77686-irq.c
index 09e593a..0758fac 100644
--- a/drivers/mfd/max77686-irq.c
+++ b/drivers/mfd/max77686-irq.c
@@ -208,6 +208,9 @@ static irqreturn_t max77686_irq_thread(int irq, void *data)
 
 	}
 
+	for (i = 0; i < MAX77686_IRQ_GROUP_NR; i++)
+		irq_reg[i] &= ~max77686->irq_masks_cur[i];
+
 	for (i = 0; i < MAX77686_IRQ_NR; i++) {
 		if (irq_reg[max77686_irqs[i].group] & max77686_irqs[i].mask) {
 			cur_irq = irq_find_mapping(max77686->irq_domain, i);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/6] mfd: max77686: Allow to specify interrupt through DT or platform file also.
  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 ` Yadwinder Singh Brar
  2012-07-05  3:58 ` [PATCH 4/6] mfd: max77686: Add device tree support Yadwinder Singh Brar
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-05  3:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

Presently driver expects irq_gpio pin in platform data and maps it to irq
itself. But we can also directly specify the interrupt in DT or platform file.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 drivers/mfd/max77686-irq.c |   33 ++++++++++++++++++++-------------
 drivers/mfd/max77686.c     |    1 +
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/max77686-irq.c b/drivers/mfd/max77686-irq.c
index 0758fac..1fbbc64 100644
--- a/drivers/mfd/max77686-irq.c
+++ b/drivers/mfd/max77686-irq.c
@@ -252,21 +252,28 @@ int max77686_irq_init(struct max77686_dev *max77686)
 
 	mutex_init(&max77686->irqlock);
 
-	max77686->irq = gpio_to_irq(max77686->irq_gpio);
-
-	if (debug_mask & MAX77686_DEBUG_IRQ_INT) {
-		ret = gpio_request(max77686->irq_gpio, "pmic_irq");
-		if (ret < 0) {
-			dev_err(max77686->dev,
-				"Failed to request gpio %d with ret: %d\n",
-				max77686->irq_gpio, ret);
-			return IRQ_NONE;
+	if (max77686->irq_gpio && !max77686->irq) {
+		max77686->irq = gpio_to_irq(max77686->irq_gpio);
+
+		if (debug_mask & MAX77686_DEBUG_IRQ_INT) {
+			ret = gpio_request(max77686->irq_gpio, "pmic_irq");
+			if (ret < 0) {
+				dev_err(max77686->dev,
+					"Failed to request gpio %d with ret:"
+					"%d\n",	max77686->irq_gpio, ret);
+				return IRQ_NONE;
+			}
+
+			gpio_direction_input(max77686->irq_gpio);
+			val = gpio_get_value(max77686->irq_gpio);
+			gpio_free(max77686->irq_gpio);
+			pr_info("%s: gpio_irq=%x\n", __func__, val);
 		}
+	}
 
-		gpio_direction_input(max77686->irq_gpio);
-		val = gpio_get_value(max77686->irq_gpio);
-		gpio_free(max77686->irq_gpio);
-		pr_info("%s: gpio_irq=%x\n", __func__, val);
+	if (!max77686->irq) {
+		dev_err(max77686->dev, "irq is not specified\n");
+		return -ENODEV;
 	}
 
 	/* Mask individual interrupt sources */
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index 11e5601..5c78e94 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -78,6 +78,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 
 	max77686->wakeup = pdata->wakeup;
 	max77686->irq_gpio = pdata->irq_gpio;
+	max77686->irq = i2c->irq;
 
 	mutex_init(&max77686->iolock);
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/6] mfd: max77686: Add device tree support.
  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 ` Yadwinder Singh Brar
  2012-07-05 12:41   ` Mark Brown
  2012-07-05  3:58 ` [PATCH 5/6] mfd: max77686: Remove the clocks from the list of regulators Yadwinder Singh Brar
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-05  3:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

This patch adds device tree support for mfd driver and adds
Documentation/devicetree/bindings/mfd/max77686.txt

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 Documentation/devicetree/bindings/mfd/max77686.txt |   57 ++++++++++++++++++++
 drivers/mfd/max77686.c                             |   43 +++++++++++++--
 2 files changed, 95 insertions(+), 5 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..b14434f
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max77686.txt
@@ -0,0 +1,57 @@
+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" uing the following format.
+
+	regulator_name {
+		standard regulator constraints....
+	};
+	refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+  The names of regulator should be 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: LDO11 {
+				regulator-name = "vdd_ldo11";
+				regulator-min-microvolt = <1900000>;
+				regulator-max-microvolt = <1900000>;
+				regulator-always-on;
+			};
+
+			buck1_reg: 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..21bc8c5 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,6 +50,29 @@ 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)
 {
@@ -53,6 +81,15 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/6] mfd: max77686: Remove the clocks from the list of regulators
  2012-07-05  3:58 [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register Yadwinder Singh Brar
                   ` (2 preceding siblings ...)
  2012-07-05  3:58 ` [PATCH 4/6] mfd: max77686: Add device tree support Yadwinder Singh Brar
@ 2012-07-05  3:58 ` Yadwinder Singh Brar
  2012-07-05  3:58 ` [PATCH 6/6] regulator: max77686: Add device tree support Yadwinder Singh Brar
  2012-07-09 11:25 ` [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register Samuel Ortiz
  5 siblings, 0 replies; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-05  3:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

Remove the clocks from the list of regulators to correct the value of
MAX77686_REG_MAX which is used in the regulator driver to represent the no.
of regulators present in max77686.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 include/linux/mfd/max77686.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/include/linux/mfd/max77686.h b/include/linux/mfd/max77686.h
index fcf3126..3d7ae4d 100644
--- a/include/linux/mfd/max77686.h
+++ b/include/linux/mfd/max77686.h
@@ -67,9 +67,6 @@ enum max77686_regulators {
 	MAX77686_BUCK7,
 	MAX77686_BUCK8,
 	MAX77686_BUCK9,
-	MAX77686_EN32KHZ_AP,
-	MAX77686_EN32KHZ_CP,
-	MAX77686_P32KH,
 
 	MAX77686_REG_MAX,
 };
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/6] regulator: max77686: Add device tree support.
  2012-07-05  3:58 [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register Yadwinder Singh Brar
                   ` (3 preceding siblings ...)
  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 ` 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
  5 siblings, 1 reply; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-05  3:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

This patch device tree support for regulator driver. It uses the parent
(mfd's) DT node to parse the regulator data for max77686.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 drivers/regulator/max77686.c |   58 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 57 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 23f956a..fc695eb 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -31,6 +31,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
 #include <linux/mfd/max77686.h>
 #include <linux/mfd/max77686-private.h>
 
@@ -233,6 +234,50 @@ static struct regulator_desc regulators[] = {
 	regulator_desc_buck(9),
 };
 
+#ifdef CONFIG_OF
+static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev,
+					struct max77686_platform_data *pdata)
+{
+	struct device_node *pmic_np, *regulators_np;
+	struct max77686_regulator_data *rdata;
+	struct of_regulator_match rmatch;
+	unsigned int i;
+
+	pmic_np = iodev->dev->of_node;
+	regulators_np = of_find_node_by_name(pmic_np, "voltage-regulators");
+	if (!regulators_np) {
+		dev_err(iodev->dev, "could not find regulators sub-node\n");
+		return -EINVAL;
+	}
+
+	pdata->num_regulators = ARRAY_SIZE(regulators);
+	rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
+			     pdata->num_regulators, GFP_KERNEL);
+	if (!rdata) {
+		dev_err(iodev->dev,
+			"could not allocate memory for regulator data\n");
+		return -ENOMEM;
+	}
+
+	for (i = 0; i < pdata->num_regulators; i++) {
+		rmatch.name = regulators[i].name;
+		rmatch.init_data = NULL;
+		of_regulator_match(iodev->dev, regulators_np, &rmatch, 1);
+		rdata[i].initdata = rmatch.init_data;
+	}
+
+	pdata->regulators = rdata;
+
+	return 0;
+}
+#else
+static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev,
+					struct max77686_platform_data *pdata)
+{
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 static __devinit int max77686_pmic_probe(struct platform_device *pdev)
 {
 	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
@@ -245,7 +290,18 @@ static __devinit int max77686_pmic_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "%s\n", __func__);
 
-	if (!pdata || pdata->num_regulators != MAX77686_REGULATORS) {
+	if (!pdata) {
+		dev_err(&pdev->dev, "no platform data found for regulator\n");
+		return -ENODEV;
+	}
+
+	if (iodev->dev->of_node) {
+		ret = max77686_pmic_dt_parse_pdata(iodev, pdata);
+		if (ret)
+			return ret;
+	}
+
+	if (pdata->num_regulators != MAX77686_REGULATORS) {
 		dev_err(&pdev->dev,
 			"Invalid initial data for regulator's initialiation\n");
 		return -EINVAL;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/6] mfd: max77686: Add device tree support.
  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
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Mark Brown @ 2012-07-05 12:41 UTC (permalink / raw)
  To: Yadwinder Singh Brar
  Cc: linux-kernel, sameo, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

On Thu, Jul 05, 2012 at 09:28:23AM +0530, Yadwinder Singh Brar wrote:

> +	regulator_name {
> +		standard regulator constraints....
> +	};
> +	refer Documentation/devicetree/bindings/regulator/regulator.txt

> +  The names of regulator should be 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.

You need to update this to use the regulator-compatible property.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 6/6] regulator: max77686: Add device tree support.
  2012-07-05  3:58 ` [PATCH 6/6] regulator: max77686: Add device tree support Yadwinder Singh Brar
@ 2012-07-05 12:42   ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2012-07-05 12:42 UTC (permalink / raw)
  To: Yadwinder Singh Brar
  Cc: linux-kernel, sameo, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

On Thu, Jul 05, 2012 at 09:28:25AM +0530, Yadwinder Singh Brar wrote:
> This patch device tree support for regulator driver. It uses the parent
> (mfd's) DT node to parse the regulator data for max77686.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/6] mfd: max77686: Add device tree support.
  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     ` [PATCH v3] " Yadwinder Singh Brar
  2 siblings, 0 replies; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-05 13:37 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-kernel, sameo, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

On Thu, Jul 5, 2012 at 6:11 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Thu, Jul 05, 2012 at 09:28:23AM +0530, Yadwinder Singh Brar wrote:
>
>> +     regulator_name {
>> +             standard regulator constraints....
>> +     };
>> +     refer Documentation/devicetree/bindings/regulator/regulator.txt
>
>> +  The names of regulator should be 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.
>
> You need to update this to use the regulator-compatible property.

Yes. I missed it. I will update Documentation.

Thanks.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2] mfd: max77686: Add device tree support.
  2012-07-05 12:41   ` Mark Brown
  2012-07-05 13:37     ` Yadwinder Singh Brar
@ 2012-07-06  8:56     ` Yadwinder Singh Brar
  2012-07-06 11:32     ` [PATCH v3] " Yadwinder Singh Brar
  2 siblings, 0 replies; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-06  8:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

This patch adds device tree support for mfd driver and adds
Documentation/devicetree/bindings/mfd/max77686.txt

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
---
 Documentation/devicetree/bindings/mfd/max77686.txt |   59 ++++++++++++++++++++
 drivers/mfd/max77686.c                             |   43 +++++++++++++--
 2 files changed, 97 insertions(+), 5 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..21bc8c5 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,6 +50,29 @@ 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)
 {
@@ -53,6 +81,15 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3] mfd: max77686: Add device tree support.
  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
  2012-07-06 18:09       ` Mark Brown
  2 siblings, 1 reply; 13+ messages in thread
From: Yadwinder Singh Brar @ 2012-07-06 11:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: sameo, Mark Brown, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3] mfd: max77686: Add device tree support.
  2012-07-06 11:32     ` [PATCH v3] " Yadwinder Singh Brar
@ 2012-07-06 18:09       ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2012-07-06 18:09 UTC (permalink / raw)
  To: Yadwinder Singh Brar
  Cc: linux-kernel, sameo, Liam Girdwood, Jonghwa Lee, Myungjoo Ham,
	Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

[-- Attachment #1: Type: text/plain, Size: 300 bytes --]

On Fri, Jul 06, 2012 at 05:02:55PM +0530, Yadwinder Singh Brar wrote:

> +	regulator_name {
> +		regulator-compatible = LDOn/BUCKn

Trivial thing but this should really have "" as it's a string.  But
people will probably figure that out.

Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register.
  2012-07-05  3:58 [PATCH 1/6] mfd: max77686: Use pmic regmap to read pmic interrupt register Yadwinder Singh Brar
                   ` (4 preceding siblings ...)
  2012-07-05  3:58 ` [PATCH 6/6] regulator: max77686: Add device tree support Yadwinder Singh Brar
@ 2012-07-09 11:25 ` Samuel Ortiz
  5 siblings, 0 replies; 13+ messages in thread
From: Samuel Ortiz @ 2012-07-09 11:25 UTC (permalink / raw)
  To: Yadwinder Singh Brar
  Cc: linux-kernel, Mark Brown, Liam Girdwood, Jonghwa Lee,
	Myungjoo Ham, Kyungmin Park, Chiwoong Byun, Yadwinder Singh Brar

Hi Yadwinder,

On Thu, Jul 05, 2012 at 09:28:20AM +0530, Yadwinder Singh Brar wrote:
> PMIC's regmap should be used to read pmic interrupt registers.
> 
> Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
> ---
>  drivers/mfd/max77686-irq.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
This one and the 4 other mfd patches applied to my for-next branch. Thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-07-09 11:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` [PATCH v3] " Yadwinder Singh Brar
2012-07-06 18:09       ` 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

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).