linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] mfd: max8925: add irqdomain for dt
@ 2013-02-04 15:40 Haojian Zhuang
  2013-02-04 15:40 ` [PATCH 2/6] mfd: max8925: fix mfd device register failure Haojian Zhuang
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Haojian Zhuang @ 2013-02-04 15:40 UTC (permalink / raw)
  To: sameo, qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss
  Cc: patches, Haojian Zhuang

From: Qing Xu <qingx@marvell.com>

Add irqdomains for max8925's main irq, wrap irq register operations
into irqdomain's map func. it is necessary for dt support.

Also, add dt support for max8925 driver.

Signed-off-by: Qing Xu <qingx@marvell.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
---
 drivers/mfd/max8925-core.c  |   73 +++++++++++++++++++++++++------------------
 drivers/mfd/max8925-i2c.c   |   36 +++++++++++++++++++--
 include/linux/mfd/max8925.h |    3 +-
 3 files changed, 78 insertions(+), 34 deletions(-)

diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index e32466e..0ad8d9a 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -14,10 +14,13 @@
 #include <linux/i2c.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
+#include <linux/irqdomain.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/machine.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/max8925.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
 
 static struct resource bk_resources[] = {
 	{ 0x84, 0x84, "mode control", IORESOURCE_REG, },
@@ -639,17 +642,33 @@ static struct irq_chip max8925_irq_chip = {
 	.irq_disable	= max8925_irq_disable,
 };
 
+static int max8925_irq_domain_map(struct irq_domain *d, unsigned int virq,
+				 irq_hw_number_t hw)
+{
+	irq_set_chip_data(virq, d->host_data);
+	irq_set_chip_and_handler(virq, &max8925_irq_chip, handle_edge_irq);
+	irq_set_nested_thread(virq, 1);
+#ifdef CONFIG_ARM
+	set_irq_flags(virq, IRQF_VALID);
+#else
+	irq_set_noprobe(virq);
+#endif
+	return 0;
+}
+
+static struct irq_domain_ops max8925_irq_domain_ops = {
+	.map	= max8925_irq_domain_map,
+	.xlate	= irq_domain_xlate_onetwocell,
+};
+
+
 static int max8925_irq_init(struct max8925_chip *chip, int irq,
 			    struct max8925_platform_data *pdata)
 {
 	unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
-	int i, ret;
-	int __irq;
+	int ret;
+	struct device_node *node = chip->dev->of_node;
 
-	if (!pdata || !pdata->irq_base) {
-		dev_warn(chip->dev, "No interrupt support on IRQ base\n");
-		return -EINVAL;
-	}
 	/* clear all interrupts */
 	max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ1);
 	max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ2);
@@ -667,35 +686,30 @@ static int max8925_irq_init(struct max8925_chip *chip, int irq,
 	max8925_reg_write(chip->rtc, MAX8925_RTC_IRQ_MASK, 0xff);
 
 	mutex_init(&chip->irq_lock);
-	chip->core_irq = irq;
-	chip->irq_base = pdata->irq_base;
-
-	/* register with genirq */
-	for (i = 0; i < ARRAY_SIZE(max8925_irqs); i++) {
-		__irq = i + chip->irq_base;
-		irq_set_chip_data(__irq, chip);
-		irq_set_chip_and_handler(__irq, &max8925_irq_chip,
-					 handle_edge_irq);
-		irq_set_nested_thread(__irq, 1);
-#ifdef CONFIG_ARM
-		set_irq_flags(__irq, IRQF_VALID);
-#else
-		irq_set_noprobe(__irq);
-#endif
-	}
-	if (!irq) {
-		dev_warn(chip->dev, "No interrupt support on core IRQ\n");
-		goto tsc_irq;
+	chip->irq_base = irq_alloc_descs(-1, 0, MAX8925_NR_IRQS, 0);
+	if (chip->irq_base < 0) {
+		dev_err(chip->dev, "Failed to allocate interrupts, ret:%d\n",
+			chip->irq_base);
+		return -EBUSY;
 	}
 
+	irq_domain_add_legacy(node, MAX8925_NR_IRQS, chip->irq_base, 0,
+			      &max8925_irq_domain_ops, chip);
+
+	/* request irq handler for pmic main irq*/
+	chip->core_irq = irq;
+	if (!chip->core_irq)
+		return -EBUSY;
 	ret = request_threaded_irq(irq, NULL, max8925_irq, flags | IRQF_ONESHOT,
 				   "max8925", chip);
 	if (ret) {
 		dev_err(chip->dev, "Failed to request core IRQ: %d\n", ret);
 		chip->core_irq = 0;
+		return -EBUSY;
 	}
 
-tsc_irq:
+	/* request irq handler for pmic tsc irq*/
+
 	/* mask TSC interrupt */
 	max8925_reg_write(chip->adc, MAX8925_TSC_IRQ_MASK, 0x0f);
 
@@ -704,7 +718,6 @@ tsc_irq:
 		return 0;
 	}
 	chip->tsc_irq = pdata->tsc_irq;
-
 	ret = request_threaded_irq(chip->tsc_irq, NULL, max8925_tsc_irq,
 				   flags | IRQF_ONESHOT, "max8925-tsc", chip);
 	if (ret) {
@@ -875,11 +888,11 @@ int max8925_device_init(struct max8925_chip *chip,
 
 	if (pdata && pdata->power) {
 		ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
-					ARRAY_SIZE(power_devs),
+				      ARRAY_SIZE(power_devs),
 				      &power_supply_resources[0], 0, NULL);
 		if (ret < 0) {
-			dev_err(chip->dev, "Failed to add power supply "
-				"subdev\n");
+			dev_err(chip->dev,
+				"Failed to add power supply subdev\n");
 			goto out_dev;
 		}
 	}
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 00b5b45..92bbebd 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -135,13 +135,37 @@ static const struct i2c_device_id max8925_id_table[] = {
 };
 MODULE_DEVICE_TABLE(i2c, max8925_id_table);
 
+static int max8925_dt_init(struct device_node *np, struct device *dev,
+			   struct max8925_platform_data *pdata)
+{
+	int ret;
+
+	ret = of_property_read_u32(np, "maxim,tsc-irq", &pdata->tsc_irq);
+	if (ret) {
+		dev_err(dev, "Not found maxim,tsc-irq property\n");
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static int max8925_probe(struct i2c_client *client,
 				   const struct i2c_device_id *id)
 {
 	struct max8925_platform_data *pdata = client->dev.platform_data;
 	static struct max8925_chip *chip;
-
-	if (!pdata) {
+	struct device_node *node = client->dev.of_node;
+
+	if (node && !pdata) {
+		/* parse DT to get platform data */
+		pdata = devm_kzalloc(&client->dev,
+				     sizeof(struct max8925_platform_data),
+				     GFP_KERNEL);
+		if (!pdata)
+			return -ENOMEM;
+
+		if (max8925_dt_init(node, &client->dev, pdata))
+			return -EINVAL;
+	} else if (!pdata) {
 		pr_info("%s: platform data is missing\n", __func__);
 		return -EINVAL;
 	}
@@ -203,11 +227,18 @@ static int max8925_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume);
 
+static const struct of_device_id max8925_dt_ids[] = {
+	{ .compatible = "maxim,max8925", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, max8925_dt_ids);
+
 static struct i2c_driver max8925_driver = {
 	.driver	= {
 		.name	= "max8925",
 		.owner	= THIS_MODULE,
 		.pm     = &max8925_pm_ops,
+		.of_match_table = of_match_ptr(max8925_dt_ids),
 	},
 	.probe		= max8925_probe,
 	.remove		= max8925_remove,
@@ -217,7 +248,6 @@ static struct i2c_driver max8925_driver = {
 static int __init max8925_i2c_init(void)
 {
 	int ret;
-
 	ret = i2c_add_driver(&max8925_driver);
 	if (ret != 0)
 		pr_err("Failed to register MAX8925 I2C driver: %d\n", ret);
diff --git a/include/linux/mfd/max8925.h b/include/linux/mfd/max8925.h
index 74d8e29..ce8502e 100644
--- a/include/linux/mfd/max8925.h
+++ b/include/linux/mfd/max8925.h
@@ -190,6 +190,8 @@ enum {
 	MAX8925_NR_IRQS,
 };
 
+
+
 struct max8925_chip {
 	struct device		*dev;
 	struct i2c_client	*i2c;
@@ -201,7 +203,6 @@ struct max8925_chip {
 	int			irq_base;
 	int			core_irq;
 	int			tsc_irq;
-
 	unsigned int            wakeup_flag;
 };
 
-- 
1.7.10.4


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

* [PATCH 2/6] mfd: max8925: fix mfd device register failure
  2013-02-04 15:40 [PATCH 1/6] mfd: max8925: add irqdomain for dt Haojian Zhuang
@ 2013-02-04 15:40 ` Haojian Zhuang
  2013-02-04 15:40 ` [PATCH 3/6] mfd: max8925: fix onkey driver irq base Haojian Zhuang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Haojian Zhuang @ 2013-02-04 15:40 UTC (permalink / raw)
  To: sameo, qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss
  Cc: patches

From: Qing Xu <qingx@marvell.com>

we encounter rtc/power/touch driver registry failure, root cause
it is resources confilict in insert_resouce, solved by changing
mfd_add_devices 5th parameter to NULL

Signed-off-by: Qing Xu <qingx@marvell.com>
---
 drivers/mfd/max8925-core.c |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index 0ad8d9a..d7abbb3 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -859,7 +859,7 @@ int max8925_device_init(struct max8925_chip *chip,
 
 	ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
 			      ARRAY_SIZE(rtc_devs),
-			      &rtc_resources[0], chip->irq_base, NULL);
+			      NULL, chip->irq_base, NULL);
 	if (ret < 0) {
 		dev_err(chip->dev, "Failed to add rtc subdev\n");
 		goto out;
@@ -867,7 +867,7 @@ int max8925_device_init(struct max8925_chip *chip,
 
 	ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
 			      ARRAY_SIZE(onkey_devs),
-			      &onkey_resources[0], 0, NULL);
+			      NULL, 0, NULL);
 	if (ret < 0) {
 		dev_err(chip->dev, "Failed to add onkey subdev\n");
 		goto out_dev;
@@ -886,21 +886,19 @@ int max8925_device_init(struct max8925_chip *chip,
 		goto out_dev;
 	}
 
-	if (pdata && pdata->power) {
-		ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
-				      ARRAY_SIZE(power_devs),
-				      &power_supply_resources[0], 0, NULL);
-		if (ret < 0) {
-			dev_err(chip->dev,
-				"Failed to add power supply subdev\n");
-			goto out_dev;
-		}
+	ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
+			      ARRAY_SIZE(power_devs),
+			      NULL, 0, NULL);
+	if (ret < 0) {
+		dev_err(chip->dev,
+			"Failed to add power supply subdev, err = %d\n", ret);
+		goto out_dev;
 	}
 
 	if (pdata && pdata->touch) {
 		ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
 				      ARRAY_SIZE(touch_devs),
-				      &touch_resources[0], 0, NULL);
+				      NULL, chip->tsc_irq, NULL);
 		if (ret < 0) {
 			dev_err(chip->dev, "Failed to add touch subdev\n");
 			goto out_dev;
-- 
1.7.10.4


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

* [PATCH 3/6] mfd: max8925: fix onkey driver irq base
  2013-02-04 15:40 [PATCH 1/6] mfd: max8925: add irqdomain for dt Haojian Zhuang
  2013-02-04 15:40 ` [PATCH 2/6] mfd: max8925: fix mfd device register failure Haojian Zhuang
@ 2013-02-04 15:40 ` Haojian Zhuang
  2013-02-04 15:40 ` [PATCH 4/6] mfd: max8925: support dt for backlight Haojian Zhuang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Haojian Zhuang @ 2013-02-04 15:40 UTC (permalink / raw)
  To: sameo, qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss
  Cc: patches

From: Qing Xu <qingx@marvell.com>

update onkey driver's irq base, it should get from max8925,
but not save in a private value

Signed-off-by: Qing Xu <qingx@marvell.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/misc/max8925_onkey.c |    3 ---
 drivers/mfd/max8925-core.c         |    2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c
index 369a39d..f9179b2 100644
--- a/drivers/input/misc/max8925_onkey.c
+++ b/drivers/input/misc/max8925_onkey.c
@@ -100,9 +100,6 @@ static int max8925_onkey_probe(struct platform_device *pdev)
 	input->dev.parent = &pdev->dev;
 	input_set_capability(input, EV_KEY, KEY_POWER);
 
-	irq[0] += chip->irq_base;
-	irq[1] += chip->irq_base;
-
 	error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler,
 				     IRQF_ONESHOT, "onkey-down", info);
 	if (error < 0) {
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index d7abbb3..f0cc402 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -867,7 +867,7 @@ int max8925_device_init(struct max8925_chip *chip,
 
 	ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
 			      ARRAY_SIZE(onkey_devs),
-			      NULL, 0, NULL);
+			      NULL, chip->irq_base, NULL);
 	if (ret < 0) {
 		dev_err(chip->dev, "Failed to add onkey subdev\n");
 		goto out_dev;
-- 
1.7.10.4


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

* [PATCH 4/6] mfd: max8925: support dt for backlight
  2013-02-04 15:40 [PATCH 1/6] mfd: max8925: add irqdomain for dt Haojian Zhuang
  2013-02-04 15:40 ` [PATCH 2/6] mfd: max8925: fix mfd device register failure Haojian Zhuang
  2013-02-04 15:40 ` [PATCH 3/6] mfd: max8925: fix onkey driver irq base Haojian Zhuang
@ 2013-02-04 15:40 ` Haojian Zhuang
  2013-03-11 16:39   ` Arnd Bergmann
  2013-02-04 15:40 ` [PATCH 5/6] mfd: max8925: add dts Haojian Zhuang
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Haojian Zhuang @ 2013-02-04 15:40 UTC (permalink / raw)
  To: sameo, qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss
  Cc: patches, Haojian Zhuang

From: Qing Xu <qingx@marvell.com>

Add device tree support in max8925 backlight.

Signed-off-by: Qing Xu <qingx@marvell.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
---
 drivers/video/backlight/max8925_bl.c |   31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index 2c9bce0..5ca11b0 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = {
 	.get_brightness	= max8925_backlight_get_brightness,
 };
 
+#ifdef CONFIG_OF
+static int max8925_backlight_dt_init(struct platform_device *pdev,
+			      struct max8925_backlight_pdata *pdata)
+{
+	struct device_node *nproot = pdev->dev.parent->of_node, *np;
+	int dual_string;
+
+	if (!nproot)
+		return -ENODEV;
+	np = of_find_node_by_name(nproot, "backlight");
+	if (!np) {
+		dev_err(&pdev->dev, "failed to find backlight node\n");
+		return -ENODEV;
+	}
+
+	of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string);
+	pdata->dual_string = dual_string;
+	return 0;
+}
+#else
+#define max8925_backlight_dt_init(x, y)	(-1)
+#endif
+
 static int max8925_backlight_probe(struct platform_device *pdev)
 {
 	struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -147,6 +170,13 @@ static int max8925_backlight_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, bl);
 
 	value = 0;
+	if (pdev->dev.parent->of_node && !pdata) {
+		pdata = devm_kzalloc(&pdev->dev,
+				     sizeof(struct max8925_backlight_pdata),
+				     GFP_KERNEL);
+		max8925_backlight_dt_init(pdev, pdata);
+	}
+
 	if (pdata) {
 		if (pdata->lxw_scl)
 			value |= (1 << 7);
@@ -158,7 +188,6 @@ static int max8925_backlight_probe(struct platform_device *pdev)
 	ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value);
 	if (ret < 0)
 		goto out_brt;
-
 	backlight_update_status(bl);
 	return 0;
 out_brt:
-- 
1.7.10.4


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

* [PATCH 5/6] mfd: max8925: add dts
  2013-02-04 15:40 [PATCH 1/6] mfd: max8925: add irqdomain for dt Haojian Zhuang
                   ` (2 preceding siblings ...)
  2013-02-04 15:40 ` [PATCH 4/6] mfd: max8925: support dt for backlight Haojian Zhuang
@ 2013-02-04 15:40 ` Haojian Zhuang
  2013-02-04 15:40 ` [PATCH 6/6] Documentation: add docs for max8925 dt Haojian Zhuang
  2013-02-05  8:19 ` [PATCH 1/6] mfd: max8925: add irqdomain for dt Samuel Ortiz
  5 siblings, 0 replies; 10+ messages in thread
From: Haojian Zhuang @ 2013-02-04 15:40 UTC (permalink / raw)
  To: sameo, qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss
  Cc: patches, Haojian Zhuang

From: Qing Xu <qingx@marvell.com>

Add max8925 dts support into mmp2 brownstone platform

Signed-off-by: Qing Xu <qingx@marvell.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
---
 arch/arm/boot/dts/mmp2-brownstone.dts |  158 +++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/mmp2.dtsi           |    4 +-
 2 files changed, 161 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/mmp2-brownstone.dts b/arch/arm/boot/dts/mmp2-brownstone.dts
index c9b4f27..7f70a39 100644
--- a/arch/arm/boot/dts/mmp2-brownstone.dts
+++ b/arch/arm/boot/dts/mmp2-brownstone.dts
@@ -29,6 +29,164 @@
 			};
 			twsi1: i2c@d4011000 {
 				status = "okay";
+				pmic: max8925@3c {
+					compatible = "maxium,max8925";
+					reg = <0x3c>;
+					interrupts = <1>;
+					interrupt-parent = <&intcmux4>;
+					interrupt-controller;
+					#interrupt-cells = <1>;
+					maxim,tsc-irq = <0>;
+
+					regulators {
+						SDV1 {
+							regulator-min-microvolt = <637500>;
+							regulator-max-microvolt = <1425000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						SDV2 {
+							regulator-min-microvolt = <650000>;
+							regulator-max-microvolt = <2225000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						SDV3 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO1 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO2 {
+							regulator-min-microvolt = <650000>;
+							regulator-max-microvolt = <2250000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO3 {
+							regulator-min-microvolt = <650000>;
+							regulator-max-microvolt = <2250000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO4 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO5 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO6 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO7 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO8 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO9 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO10 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+						};
+						LDO11 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO12 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO13 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO14 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO15 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO16 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO17 {
+							regulator-min-microvolt = <650000>;
+							regulator-max-microvolt = <2250000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO18 {
+							regulator-min-microvolt = <650000>;
+							regulator-max-microvolt = <2250000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO19 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+						LDO20 {
+							regulator-min-microvolt = <750000>;
+							regulator-max-microvolt = <3900000>;
+							regulator-boot-on;
+							regulator-always-on;
+						};
+					};
+					backlight {
+						maxim,max8925-dual-string = <0>;
+					};
+					charger {
+						batt-detect = <0>;
+						topoff-threshold = <1>;
+						fast-charge = <7>;
+						no-temp-support = <0>;
+						no-insert-detect = <0>;
+					};
+				};
 			};
 			rtc: rtc@d4010000 {
 				status = "okay";
diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 0514fb4..1429ac0 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -46,7 +46,7 @@
 				mrvl,intc-nr-irqs = <64>;
 			};
 
-			intcmux4@d4282150 {
+			intcmux4: interrupt-controller@d4282150 {
 				compatible = "mrvl,mmp2-mux-intc";
 				interrupts = <4>;
 				interrupt-controller;
@@ -201,6 +201,8 @@
 				compatible = "mrvl,mmp-twsi";
 				reg = <0xd4011000 0x1000>;
 				interrupts = <7>;
+				#address-cells = <1>;
+				#size-cells = <0>;
 				mrvl,i2c-fast-mode;
 				status = "disabled";
 			};
-- 
1.7.10.4


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

* [PATCH 6/6] Documentation: add docs for max8925 dt
  2013-02-04 15:40 [PATCH 1/6] mfd: max8925: add irqdomain for dt Haojian Zhuang
                   ` (3 preceding siblings ...)
  2013-02-04 15:40 ` [PATCH 5/6] mfd: max8925: add dts Haojian Zhuang
@ 2013-02-04 15:40 ` Haojian Zhuang
  2013-02-05  8:19 ` [PATCH 1/6] mfd: max8925: add irqdomain for dt Samuel Ortiz
  5 siblings, 0 replies; 10+ messages in thread
From: Haojian Zhuang @ 2013-02-04 15:40 UTC (permalink / raw)
  To: sameo, qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss
  Cc: patches, Haojian Zhuang

From: Qing Xu <qingx@marvell.com>

add docs for dt of max8925-mfd, max8925-backlight, and
max8925-battery

Signed-off-by: Qing Xu <qingx@marvell.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
---
 Documentation/devicetree/bindings/mfd/max8925.txt  |   64 ++++++++++++++++++++
 .../bindings/power_supply/max8925_batter.txt       |   18 ++++++
 .../bindings/video/backlight/max8925-backlight.txt |   10 +++
 3 files changed, 92 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/max8925.txt
 create mode 100644 Documentation/devicetree/bindings/power_supply/max8925_batter.txt
 create mode 100644 Documentation/devicetree/bindings/video/backlight/max8925-backlight.txt

diff --git a/Documentation/devicetree/bindings/mfd/max8925.txt b/Documentation/devicetree/bindings/mfd/max8925.txt
new file mode 100644
index 0000000..4f0dc66
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max8925.txt
@@ -0,0 +1,64 @@
+* Maxim max8925 Power Management IC
+
+Required parent device properties:
+- compatible : "maxim,max8925"
+- reg : the I2C slave address for the max8925 chip
+- interrupts : IRQ line for the max8925 chip
+- interrupt-controller: describes the max8925 as an interrupt
+  controller (has its own domain)
+- #interrupt-cells : should be 1.
+	- The cell is the max8925 local IRQ number
+
+Optional parent device properties:
+- maxim,tsc-irq: there are 2 IRQ lines for max8925, one is indicated in
+  interrupts property, the other is indicated here.
+
+max8925 consists of a large and varied group of sub-devices:
+
+Device			 Supply Names	 Description
+------			 ------------	 -----------
+max8925-onkey		:		: On key
+max8925-rtc		:		: RTC
+max8925-regulator	:		: Regulators
+max8925-backlight	:		: Backlight
+max8925-touch		:		: Touchscreen
+max8925-power		:		: Charger
+
+Example:
+
+	pmic: max8925@3c {
+		compatible = "maxim,max8925";
+		reg = <0x3c>;
+		interrupts = <1>;
+		interrupt-parent = <&intcmux4>;
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		maxim,tsc-irq = <0>;
+
+		regulators {
+			SDV1 {
+				regulator-min-microvolt = <637500>;
+				regulator-max-microvolt = <1425000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+
+			LDO1 {
+				regulator-min-microvolt = <750000>;
+				regulator-max-microvolt = <3900000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+
+		};
+		backlight {
+			maxim,max8925-dual-string = <0>;
+		};
+		charger {
+			batt-detect = <0>;
+			topoff-threshold = <1>;
+			fast-charge = <7>;
+			no-temp-support = <0>;
+			no-insert-detect = <0>;
+		};
+	};
diff --git a/Documentation/devicetree/bindings/power_supply/max8925_batter.txt b/Documentation/devicetree/bindings/power_supply/max8925_batter.txt
new file mode 100644
index 0000000..d7e3e0c
--- /dev/null
+++ b/Documentation/devicetree/bindings/power_supply/max8925_batter.txt
@@ -0,0 +1,18 @@
+max8925-battery bindings
+~~~~~~~~~~~~~~~~
+
+Optional properties :
+ - batt-detect: whether support battery detect
+ - topoff-threshold: set charging current in topoff mode
+ - fast-charge: set charging current in fast mode
+ - no-temp-support: whether support temperature protection detect
+ - no-insert-detect: whether support insert detect
+
+Example:
+	charger {
+		batt-detect = <0>;
+		topoff-threshold = <1>;
+		fast-charge = <7>;
+		no-temp-support = <0>;
+		no-insert-detect = <0>;
+	};
diff --git a/Documentation/devicetree/bindings/video/backlight/max8925-backlight.txt b/Documentation/devicetree/bindings/video/backlight/max8925-backlight.txt
new file mode 100644
index 0000000..b4cffda
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/backlight/max8925-backlight.txt
@@ -0,0 +1,10 @@
+88pm860x-backlight bindings
+
+Optional properties:
+  - maxim,max8925-dual-string: whether support dual string
+
+Example:
+
+	backlights {
+		maxim,max8925-dual-string = <0>;
+	};
-- 
1.7.10.4


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

* Re: [PATCH 1/6] mfd: max8925: add irqdomain for dt
  2013-02-04 15:40 [PATCH 1/6] mfd: max8925: add irqdomain for dt Haojian Zhuang
                   ` (4 preceding siblings ...)
  2013-02-04 15:40 ` [PATCH 6/6] Documentation: add docs for max8925 dt Haojian Zhuang
@ 2013-02-05  8:19 ` Samuel Ortiz
  2013-02-05  8:21   ` Qing Xu
  2013-02-05  8:40   ` Haojian Zhuang
  5 siblings, 2 replies; 10+ messages in thread
From: Samuel Ortiz @ 2013-02-05  8:19 UTC (permalink / raw)
  To: Haojian Zhuang
  Cc: qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss, patches, Haojian Zhuang

Hi Haojian,

On Mon, Feb 04, 2013 at 11:40:42PM +0800, Haojian Zhuang wrote:
> From: Qing Xu <qingx@marvell.com>
> 
> Add irqdomains for max8925's main irq, wrap irq register operations
> into irqdomain's map func. it is necessary for dt support.
> 
> Also, add dt support for max8925 driver.
> 
> Signed-off-by: Qing Xu <qingx@marvell.com>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
> ---
>  drivers/mfd/max8925-core.c  |   73 +++++++++++++++++++++++++------------------
>  drivers/mfd/max8925-i2c.c   |   36 +++++++++++++++++++--
>  include/linux/mfd/max8925.h |    3 +-
>  3 files changed, 78 insertions(+), 34 deletions(-)
This and the next 5 patches applied, thanks for the heads up.

Cheers,
Samuel.

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

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

* Re: [PATCH 1/6] mfd: max8925: add irqdomain for dt
  2013-02-05  8:19 ` [PATCH 1/6] mfd: max8925: add irqdomain for dt Samuel Ortiz
@ 2013-02-05  8:21   ` Qing Xu
  2013-02-05  8:40   ` Haojian Zhuang
  1 sibling, 0 replies; 10+ messages in thread
From: Qing Xu @ 2013-02-05  8:21 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Haojian Zhuang, grant.likely, rob.herring, Chao Xie,
	linux-kernel, devicetree-discuss, patches, Haojian Zhuang

On 02/05/2013 04:19 PM, Samuel Ortiz wrote:
> Hi Haojian,
>
> On Mon, Feb 04, 2013 at 11:40:42PM +0800, Haojian Zhuang wrote:
>> From: Qing Xu <qingx@marvell.com>
>>
>> Add irqdomains for max8925's main irq, wrap irq register operations
>> into irqdomain's map func. it is necessary for dt support.
>>
>> Also, add dt support for max8925 driver.
>>
>> Signed-off-by: Qing Xu <qingx@marvell.com>
>> Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
>> ---
>>   drivers/mfd/max8925-core.c  |   73 +++++++++++++++++++++++++------------------
>>   drivers/mfd/max8925-i2c.c   |   36 +++++++++++++++++++--
>>   include/linux/mfd/max8925.h |    3 +-
>>   3 files changed, 78 insertions(+), 34 deletions(-)
> This and the next 5 patches applied, thanks for the heads up.
>
> Cheers,
> Samuel.
>
Hi Samuel, Haojian,

Thank you very much!

-Qing

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

* Re: [PATCH 1/6] mfd: max8925: add irqdomain for dt
  2013-02-05  8:19 ` [PATCH 1/6] mfd: max8925: add irqdomain for dt Samuel Ortiz
  2013-02-05  8:21   ` Qing Xu
@ 2013-02-05  8:40   ` Haojian Zhuang
  1 sibling, 0 replies; 10+ messages in thread
From: Haojian Zhuang @ 2013-02-05  8:40 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Haojian Zhuang, Qing Xu, Grant Likely, Rob Herring, cxie4,
	linux-kernel, devicetree-discuss, patches

On Tue, Feb 5, 2013 at 4:19 PM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> Hi Haojian,
>
> On Mon, Feb 04, 2013 at 11:40:42PM +0800, Haojian Zhuang wrote:
>> From: Qing Xu <qingx@marvell.com>
>>
>> Add irqdomains for max8925's main irq, wrap irq register operations
>> into irqdomain's map func. it is necessary for dt support.
>>
>> Also, add dt support for max8925 driver.
>>
>> Signed-off-by: Qing Xu <qingx@marvell.com>
>> Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
>> ---
>>  drivers/mfd/max8925-core.c  |   73 +++++++++++++++++++++++++------------------
>>  drivers/mfd/max8925-i2c.c   |   36 +++++++++++++++++++--
>>  include/linux/mfd/max8925.h |    3 +-
>>  3 files changed, 78 insertions(+), 34 deletions(-)
> This and the next 5 patches applied, thanks for the heads up.
>

Thanks :)

Best Regards
Haojian

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

* Re: [PATCH 4/6] mfd: max8925: support dt for backlight
  2013-02-04 15:40 ` [PATCH 4/6] mfd: max8925: support dt for backlight Haojian Zhuang
@ 2013-03-11 16:39   ` Arnd Bergmann
  0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2013-03-11 16:39 UTC (permalink / raw)
  To: Haojian Zhuang
  Cc: sameo, qingx, grant.likely, rob.herring, cxie4, linux-kernel,
	devicetree-discuss, patches, Haojian Zhuang

On Monday 04 February 2013, Haojian Zhuang wrote:
> From: Qing Xu <qingx@marvell.com>
> 
> Add device tree support in max8925 backlight.
> 
> Signed-off-by: Qing Xu <qingx@marvell.com>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>

Sorry, but after finding a build warning in this patch, I looked closer and
found more issues. I would recommend reverting this patch.

> diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
> index 2c9bce0..5ca11b0 100644
> --- a/drivers/video/backlight/max8925_bl.c
> +++ b/drivers/video/backlight/max8925_bl.c
> @@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = {
>  	.get_brightness	= max8925_backlight_get_brightness,
>  };
>  
> +#ifdef CONFIG_OF
> +static int max8925_backlight_dt_init(struct platform_device *pdev,
> +			      struct max8925_backlight_pdata *pdata)
> +{
> +	struct device_node *nproot = pdev->dev.parent->of_node, *np;
> +	int dual_string;
> +
> +	if (!nproot)
> +		return -ENODEV;
> +	np = of_find_node_by_name(nproot, "backlight");
> +	if (!np) {
> +		dev_err(&pdev->dev, "failed to find backlight node\n");
> +		return -ENODEV;
> +	}

It is nonsense to look at the device node for the parent and then find
the child by using of_find_node_by_name(). What you should do instead
is ensure that the backlight platform device gets connected to the
DT device node by the MFD core. I did not think I'd use the ab8500
driver as a positive example, but it gets this right by using the
of_compatible member for the mfd_cell.

> +
> +	of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string);
> +	pdata->dual_string = dual_string;

For boolean values, we should use of_property_read_bool, which checks
the presence of the property and returns "true" if it exists and false
otherwise. There is no need to assign a value to the property that way,
and it's more consistent with other drivers.

> +	return 0;
> +}
> +#else
> +#define max8925_backlight_dt_init(x, y)	(-1)
> +#endif

As I suggested in my earlier patch, the #ifdef is not necessary. I suggested
using "if (IS_ENABLED(CONFIG_OF))" earlier, but it's actually simpler
to just return from this function if no node was found. of_find_node_by_name
is already defined to an empty function returning NULL when CONFIG_OF
is turned off.

>  static int max8925_backlight_probe(struct platform_device *pdev)
>  {
>  	struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
> @@ -147,6 +170,13 @@ static int max8925_backlight_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, bl);
>  
>  	value = 0;
> +	if (pdev->dev.parent->of_node && !pdata) {
> +		pdata = devm_kzalloc(&pdev->dev,
> +				     sizeof(struct max8925_backlight_pdata),
> +				     GFP_KERNEL);

Using a dynamic allocation for pdata is way overkill here, since the data is
only used in one place below and then never again. A proper method to
do this would be

	if (of_property_read_bool(pdev->dev.of_node, "maxim,max8925-dual-string"))
		value |= 2;

No need to have a separate function or complex parsing at all, and if CONFIG_OF
is disabled, the code goes away entirely.


> +		max8925_backlight_dt_init(pdev, pdata);
> +	}

Note that when you have a function whose return value is never checked, it
should not return errors but just "void".

> @@ -158,7 +188,6 @@ static int max8925_backlight_probe(struct platform_device *pdev)
>  	ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value);
>  	if (ret < 0)
>  		goto out_brt;
> -
>  	backlight_update_status(bl);
>  	return 0;
>  out_brt:

Finally, there is no reason to remove the empty line. If it was a good idea
to remove it, that should probably be a separate patch to clean up the coding
style.

	Arnd

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

end of thread, other threads:[~2013-03-11 16:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-04 15:40 [PATCH 1/6] mfd: max8925: add irqdomain for dt Haojian Zhuang
2013-02-04 15:40 ` [PATCH 2/6] mfd: max8925: fix mfd device register failure Haojian Zhuang
2013-02-04 15:40 ` [PATCH 3/6] mfd: max8925: fix onkey driver irq base Haojian Zhuang
2013-02-04 15:40 ` [PATCH 4/6] mfd: max8925: support dt for backlight Haojian Zhuang
2013-03-11 16:39   ` Arnd Bergmann
2013-02-04 15:40 ` [PATCH 5/6] mfd: max8925: add dts Haojian Zhuang
2013-02-04 15:40 ` [PATCH 6/6] Documentation: add docs for max8925 dt Haojian Zhuang
2013-02-05  8:19 ` [PATCH 1/6] mfd: max8925: add irqdomain for dt Samuel Ortiz
2013-02-05  8:21   ` Qing Xu
2013-02-05  8:40   ` Haojian Zhuang

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