devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] regulator: max77686: Add GPIO control
@ 2014-10-29 15:06 Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 1/8] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Ben Dooks, Kukjin Kim,
	Russell King, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

Hi,


Patch 2/8: not tested on hardware. I am kindly asking for testing it
because I don't have the board with Maxim 77802.

Changes since v1
================
1. Add patch: 1/8 "regulator: max77686: Consistently index opmode
   array by rdev id".
2. Remove patch "regulator: max77686: Make regulator_desc array
   const" (applied).
3. Re-work patches removing from regulators board file support (2/8
   and 3/8). Parse regulators with of_regulator_match() at once, remove
   num_regulators.
4. Patch 4/8: Add depends on OF to mfd/Kconfig. Add Javier's
   reviewed-by.
5. Patch 5/8: Add Javier's reviewed-by.
6. Patch 6/8: Add depends on GPIOLIB to regulator/Kconfig. Rename
   "external control" to "GPIO control" and "ext_control_gpios" to
   simpler "gpios".
   I tried to use new GPIO API but it ended with more problems
   https://lkml.org/lkml/2014/10/29/239


Description
===========
This patch helps in proper description of max77686 regulators in DTS by
allowing to control them over GPIO. This allows removal of
fixed regulators from DTS which duplicate the description of hardware.

The first five patches are cleanups, including board support removal.

The whole patchset should be taken at once.

Patchset is rebased on next-20141023 AND:
1. ARM: EXYNOS: Call regulator suspend prepare/finish
   https://lkml.org/lkml/2014/10/20/545
2. regulator: max77686/trats2: Disable some regulators in suspend
   https://lkml.org/lkml/2014/10/27/280


Best regards,
Krzysztof

Krzysztof Kozlowski (8):
  regulator: max77686: Consistently index opmode array by rdev id
  regulator: max77802: Remove support for board files
  regulator: max77686: Remove support for board files
  mfd: max77686/802: Remove support for board files
  regulator: max77686: Initialize opmode explicitly to normal mode
  regulator: max77686: Add GPIO control
  mfd/regulator: dt-bindings: max77686: Document gpio property
  ARM: dts: exynos4412-trats: Switch max77686 regulators to GPIO control

 Documentation/devicetree/bindings/mfd/max77686.txt |   3 +
 arch/arm/boot/dts/exynos4412-trats2.dts            |  25 +--
 drivers/mfd/Kconfig                                |   1 +
 drivers/mfd/max77686.c                             |  23 ---
 drivers/regulator/Kconfig                          |   1 +
 drivers/regulator/max77686.c                       | 179 ++++++++++++++-------
 drivers/regulator/max77802.c                       |  87 ++++------
 include/linux/mfd/max77686-private.h               |   1 -
 include/linux/mfd/max77686.h                       |  28 ----
 9 files changed, 166 insertions(+), 182 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 1/8] regulator: max77686: Consistently index opmode array by rdev id
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  2014-10-29 15:06 ` [RFT v2 2/8] regulator: max77802: Remove support for board files Krzysztof Kozlowski
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

Mixed indexes were used for array of opmodes in max77686_data structure:
id of regulator and index of regulator_desc array.

These indexes are exactly the same but the mixture may confuse. Use
consistently the id of regulator.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/regulator/max77686.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 09b0d8c20a9d..27c5f4556044 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -82,6 +82,7 @@ enum max77686_ramp_rate {
 };
 
 struct max77686_data {
+	/* Array indexed by regulator id */
 	unsigned int opmode[MAX77686_REGULATORS];
 };
 
@@ -513,12 +514,13 @@ static int max77686_pmic_probe(struct platform_device *pdev)
 
 	for (i = 0; i < MAX77686_REGULATORS; i++) {
 		struct regulator_dev *rdev;
+		int id = regulators[i].id;
 
 		config.init_data = pdata->regulators[i].initdata;
 		config.of_node = pdata->regulators[i].of_node;
 
-		max77686->opmode[i] = regulators[i].enable_mask >>
-						max77686_get_opmode_shift(i);
+		max77686->opmode[id] = regulators[i].enable_mask >>
+						max77686_get_opmode_shift(id);
 		rdev = devm_regulator_register(&pdev->dev,
 						&regulators[i], &config);
 		if (IS_ERR(rdev)) {
-- 
1.9.1

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

* [RFT v2 2/8] regulator: max77802: Remove support for board files
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 1/8] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  2014-10-29 23:41   ` Javier Martinez Canillas
  2014-10-29 15:06 ` [PATCH v2 3/8] regulator: max77686: " Krzysztof Kozlowski
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

The driver is used only on Exynos based boards with DTS support.
Convert the driver to DTS-only version. Parse all regulators at once,
not one-by-one. Remove dependency on data provided by max77686 MFD
driver.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/regulator/max77802.c | 87 +++++++++++++++++---------------------------
 1 file changed, 34 insertions(+), 53 deletions(-)

diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index b9958d927297..e3390c7db5ae 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -70,6 +70,7 @@ static unsigned int ramp_table_77802_4bit[] = {
 };
 
 struct max77802_regulator_prv {
+	/* Array indexed by regulator id */
 	unsigned int opmode[MAX77802_REG_MAX];
 };
 
@@ -513,15 +514,14 @@ static struct regulator_desc regulators[] = {
 	regulator_77802_desc_n_ldo(35, 2, 1),
 };
 
-#ifdef CONFIG_OF
-static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
-					struct max77686_platform_data *pdata)
+static int max77802_pmic_dt_parse(struct platform_device *pdev,
+				struct of_regulator_match *rdata)
 {
 	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
 	struct device_node *pmic_np, *regulators_np;
-	struct max77686_regulator_data *rdata;
-	struct of_regulator_match rmatch;
-	unsigned int i;
+	int ret = 0;
+
+	BUILD_BUG_ON(MAX77802_REG_MAX != ARRAY_SIZE(regulators));
 
 	pmic_np = iodev->dev->of_node;
 	regulators_np = of_get_child_by_name(pmic_np, "regulators");
@@ -530,55 +530,27 @@ static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
 		return -EINVAL;
 	}
 
-	pdata->num_regulators = ARRAY_SIZE(regulators);
-	rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
-			     pdata->num_regulators, GFP_KERNEL);
-	if (!rdata) {
+	ret = of_regulator_match(&pdev->dev, regulators_np, rdata,
+			MAX77802_REG_MAX);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "error parsing regulators data\n");
 		of_node_put(regulators_np);
-		return -ENOMEM;
-	}
-
-	for (i = 0; i < pdata->num_regulators; i++) {
-		rmatch.name = regulators[i].name;
-		rmatch.init_data = NULL;
-		rmatch.of_node = NULL;
-		if (of_regulator_match(&pdev->dev, regulators_np, &rmatch,
-				       1) != 1) {
-			dev_warn(&pdev->dev, "No matching regulator for '%s'\n",
-				 rmatch.name);
-			continue;
-		}
-		rdata[i].initdata = rmatch.init_data;
-		rdata[i].of_node = rmatch.of_node;
-		rdata[i].id = regulators[i].id;
+		return ret;
 	}
+	/* else: don't care how many regulators were parsed from DTS. */
 
-	pdata->regulators = rdata;
 	of_node_put(regulators_np);
 
 	return 0;
 }
-#else
-static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
-					struct max77686_platform_data *pdata)
-{
-	return 0;
-}
-#endif /* CONFIG_OF */
 
 static int max77802_pmic_probe(struct platform_device *pdev)
 {
 	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
-	struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
 	struct max77802_regulator_prv *max77802;
 	int i, ret = 0, val;
 	struct regulator_config config = { };
-
-	/* This is allocated by the MFD driver */
-	if (!pdata) {
-		dev_err(&pdev->dev, "no platform data found for regulator\n");
-		return -ENODEV;
-	}
+	struct of_regulator_match *rdata;
 
 	max77802 = devm_kzalloc(&pdev->dev,
 				sizeof(struct max77802_regulator_prv),
@@ -586,24 +558,29 @@ static int max77802_pmic_probe(struct platform_device *pdev)
 	if (!max77802)
 		return -ENOMEM;
 
-	if (iodev->dev->of_node) {
-		ret = max77802_pmic_dt_parse_pdata(pdev, pdata);
-		if (ret)
-			return ret;
-	}
-
 	config.dev = iodev->dev;
 	config.regmap = iodev->regmap;
 	config.driver_data = max77802;
 	platform_set_drvdata(pdev, max77802);
 
+	rdata = kzalloc(sizeof(*rdata) * MAX77802_REG_MAX, GFP_KERNEL);
+	if (!rdata)
+		return -ENOMEM;
+
+	for (i = 0; i < MAX77802_REG_MAX; i++)
+		rdata[i].name = regulators[i].name;
+
+	ret = max77802_pmic_dt_parse(pdev, rdata);
+	if (ret)
+		goto out;
+
 	for (i = 0; i < MAX77802_REG_MAX; i++) {
 		struct regulator_dev *rdev;
-		int id = pdata->regulators[i].id;
+		int id = regulators[i].id;
 		int shift = max77802_get_opmode_shift(id);
 
-		config.init_data = pdata->regulators[i].initdata;
-		config.of_node = pdata->regulators[i].of_node;
+		config.init_data = rdata[i].init_data;
+		config.of_node = rdata[i].of_node;
 
 		ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val);
 		val = val >> shift & MAX77802_OPMODE_MASK;
@@ -621,13 +598,17 @@ static int max77802_pmic_probe(struct platform_device *pdev)
 		rdev = devm_regulator_register(&pdev->dev,
 					       &regulators[i], &config);
 		if (IS_ERR(rdev)) {
+			ret = PTR_ERR(rdev);
 			dev_err(&pdev->dev,
-				"regulator init failed for %d\n", i);
-			return PTR_ERR(rdev);
+				"regulator init failed for %d: %d\n", i, ret);
+			goto out;
 		}
 	}
 
-	return 0;
+out:
+	kfree(rdata);
+
+	return ret;
 }
 
 static const struct platform_device_id max77802_pmic_id[] = {
-- 
1.9.1

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

* [PATCH v2 3/8] regulator: max77686: Remove support for board files
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 1/8] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
  2014-10-29 15:06 ` [RFT v2 2/8] regulator: max77802: Remove support for board files Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 4/8] mfd: max77686/802: " Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

The driver is used only on Exynos based boards with DTS support.
Convert the driver to DTS-only version. Parse all regulators at once,
not one-by-one. Remove dependency on data provided by max77686 MFD
driver.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/regulator/max77686.c | 84 +++++++++++++++++---------------------------
 1 file changed, 33 insertions(+), 51 deletions(-)

diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 27c5f4556044..7ec9b4e5b917 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -428,15 +428,14 @@ static const struct regulator_desc regulators[] = {
 	regulator_desc_buck(9),
 };
 
-#ifdef CONFIG_OF
-static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
-					struct max77686_platform_data *pdata)
+static int max77686_pmic_dt_parse(struct platform_device *pdev,
+				struct of_regulator_match *rdata)
 {
 	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
 	struct device_node *pmic_np, *regulators_np;
-	struct max77686_regulator_data *rdata;
-	struct of_regulator_match rmatch;
-	unsigned int i;
+	int ret = 0;
+
+	BUILD_BUG_ON(MAX77686_REGULATORS != ARRAY_SIZE(regulators));
 
 	pmic_np = iodev->dev->of_node;
 	regulators_np = of_get_child_by_name(pmic_np, "voltage-regulators");
@@ -445,63 +444,31 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
 		return -EINVAL;
 	}
 
-	pdata->num_regulators = ARRAY_SIZE(regulators);
-	rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
-			     pdata->num_regulators, GFP_KERNEL);
-	if (!rdata) {
-		of_node_put(regulators_np);
-		return -ENOMEM;
-	}
 
-	for (i = 0; i < pdata->num_regulators; i++) {
-		rmatch.name = regulators[i].name;
-		rmatch.init_data = NULL;
-		rmatch.of_node = NULL;
-		of_regulator_match(&pdev->dev, regulators_np, &rmatch, 1);
-		rdata[i].initdata = rmatch.init_data;
-		rdata[i].of_node = rmatch.of_node;
+	ret = of_regulator_match(&pdev->dev, regulators_np, rdata,
+			MAX77686_REGULATORS);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "error parsing regulators data\n");
+		of_node_put(regulators_np);
+		return ret;
 	}
+	/* else: don't care how many regulators were parsed from DTS. */
 
-	pdata->regulators = rdata;
 	of_node_put(regulators_np);
 
 	return 0;
 }
-#else
-static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
-					struct max77686_platform_data *pdata)
-{
-	return 0;
-}
-#endif /* CONFIG_OF */
 
 static int max77686_pmic_probe(struct platform_device *pdev)
 {
 	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
-	struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
 	struct max77686_data *max77686;
 	int i, ret = 0;
 	struct regulator_config config = { };
+	struct of_regulator_match *rdata;
 
 	dev_dbg(&pdev->dev, "%s\n", __func__);
 
-	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(pdev, 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;
-	}
-
 	max77686 = devm_kzalloc(&pdev->dev, sizeof(struct max77686_data),
 				GFP_KERNEL);
 	if (!max77686)
@@ -512,25 +479,40 @@ static int max77686_pmic_probe(struct platform_device *pdev)
 	config.driver_data = max77686;
 	platform_set_drvdata(pdev, max77686);
 
+	rdata = kzalloc(sizeof(*rdata) * MAX77686_REGULATORS, GFP_KERNEL);
+	if (!rdata)
+		return -ENOMEM;
+
+	for (i = 0; i < MAX77686_REGULATORS; i++)
+		rdata[i].name = regulators[i].name;
+
+	ret = max77686_pmic_dt_parse(pdev, rdata);
+	if (ret)
+		goto out;
+
 	for (i = 0; i < MAX77686_REGULATORS; i++) {
 		struct regulator_dev *rdev;
 		int id = regulators[i].id;
 
-		config.init_data = pdata->regulators[i].initdata;
-		config.of_node = pdata->regulators[i].of_node;
+		config.init_data = rdata[i].init_data;
+		config.of_node = rdata[i].of_node;
 
 		max77686->opmode[id] = regulators[i].enable_mask >>
 						max77686_get_opmode_shift(id);
 		rdev = devm_regulator_register(&pdev->dev,
 						&regulators[i], &config);
 		if (IS_ERR(rdev)) {
+			ret = PTR_ERR(rdev);
 			dev_err(&pdev->dev,
-				"regulator init failed for %d\n", i);
-			return PTR_ERR(rdev);
+				"regulator init failed for %d: %d\n", i, ret);
+			goto out;
 		}
 	}
 
-	return 0;
+out:
+	kfree(rdata);
+
+	return ret;
 }
 
 static const struct platform_device_id max77686_pmic_id[] = {
-- 
1.9.1

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

* [PATCH v2 4/8] mfd: max77686/802: Remove support for board files
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2014-10-29 15:06 ` [PATCH v2 3/8] regulator: max77686: " Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 5/8] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

The driver is used only on Exynos based boards with DTS support.
Convert the driver to DTS-only version. This simplifies a little the
code:
1. No dead (unused) entries in platform_data structure.
2. More code removed (from all three patches: 68 insertions(+), 156
   deletions).
3. Regulator driver does not depend on allocated memory
   from MFD driver.
4. It makes also easier extending the regulator driver.

Add to the max77686 MFD driver dependency on CONFIG_OF because without
DTS the regulator drivers won't bind.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/mfd/Kconfig                  |  1 +
 drivers/mfd/max77686.c               | 23 -----------------------
 include/linux/mfd/max77686-private.h |  1 -
 include/linux/mfd/max77686.h         | 28 ----------------------------
 4 files changed, 1 insertion(+), 52 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index cbdb10918af1..fd9d19ccf8c0 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -401,6 +401,7 @@ config MFD_MAX14577
 config MFD_MAX77686
 	bool "Maxim Semiconductor MAX77686/802 PMIC Support"
 	depends on I2C=y
+	depends on OF
 	select MFD_CORE
 	select REGMAP_I2C
 	select REGMAP_IRQ
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index 929795eae9fc..3da237afacde 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -205,24 +205,10 @@ static const struct of_device_id max77686_pmic_dt_match[] = {
 	{ },
 };
 
-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)
-		return NULL;
-
-	dev->platform_data = pd;
-	return pd;
-}
-
 static int max77686_i2c_probe(struct i2c_client *i2c,
 			      const struct i2c_device_id *id)
 {
 	struct max77686_dev *max77686 = NULL;
-	struct max77686_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	const struct of_device_id *match;
 	unsigned int data;
 	int ret = 0;
@@ -233,14 +219,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	const struct mfd_cell *cells;
 	int n_devs;
 
-	if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node && !pdata)
-		pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
-
-	if (!pdata) {
-		dev_err(&i2c->dev, "No platform data found.\n");
-		return -EINVAL;
-	}
-
 	max77686 = devm_kzalloc(&i2c->dev,
 				sizeof(struct max77686_dev), GFP_KERNEL);
 	if (!max77686)
@@ -259,7 +237,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	max77686->dev = &i2c->dev;
 	max77686->i2c = i2c;
 
-	max77686->wakeup = pdata->wakeup;
 	max77686->irq = i2c->irq;
 
 	if (max77686->type == TYPE_MAX77686) {
diff --git a/include/linux/mfd/max77686-private.h b/include/linux/mfd/max77686-private.h
index 960b92ad450d..f5043490d67c 100644
--- a/include/linux/mfd/max77686-private.h
+++ b/include/linux/mfd/max77686-private.h
@@ -447,7 +447,6 @@ struct max77686_dev {
 	struct regmap_irq_chip_data *rtc_irq_data;
 
 	int irq;
-	bool wakeup;
 	struct mutex irqlock;
 	int irq_masks_cur[MAX77686_IRQ_GROUP_NR];
 	int irq_masks_cache[MAX77686_IRQ_GROUP_NR];
diff --git a/include/linux/mfd/max77686.h b/include/linux/mfd/max77686.h
index 553f7d09258a..bb995ab9a575 100644
--- a/include/linux/mfd/max77686.h
+++ b/include/linux/mfd/max77686.h
@@ -119,12 +119,6 @@ enum max77802_regulators {
 	MAX77802_REG_MAX,
 };
 
-struct max77686_regulator_data {
-	int id;
-	struct regulator_init_data *initdata;
-	struct device_node *of_node;
-};
-
 enum max77686_opmode {
 	MAX77686_OPMODE_NORMAL,
 	MAX77686_OPMODE_LP,
@@ -136,26 +130,4 @@ struct max77686_opmode_data {
 	int mode;
 };
 
-struct max77686_platform_data {
-	int ono;
-	int wakeup;
-
-	/* ---- PMIC ---- */
-	struct max77686_regulator_data *regulators;
-	int num_regulators;
-
-	struct max77686_opmode_data *opmode_data;
-
-	/*
-	 * GPIO-DVS feature is not enabled with the current version of
-	 * MAX77686 driver. Buck2/3/4_voltages[0] is used as the default
-	 * voltage at probe. DVS/SELB gpios are set as OUTPUT-LOW.
-	 */
-	int buck234_gpio_dvs[3]; /* GPIO of [0]DVS1, [1]DVS2, [2]DVS3 */
-	int buck234_gpio_selb[3]; /* [0]SELB2, [1]SELB3, [2]SELB4 */
-	unsigned int buck2_voltage[8]; /* buckx_voltage in uV */
-	unsigned int buck3_voltage[8];
-	unsigned int buck4_voltage[8];
-};
-
 #endif /* __LINUX_MFD_MAX77686_H */
-- 
1.9.1

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

* [PATCH v2 5/8] regulator: max77686: Initialize opmode explicitly to normal mode
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2014-10-29 15:06 ` [PATCH v2 4/8] mfd: max77686/802: " Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 6/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Chanwoo Choi,
	Kyungmin Park, Javier Martinez Canillas, Marek Szyprowski

Minor nit: Initialize the opmode for each regulator to normal mode in a
readable explicit way.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Suggested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Reviewed-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/regulator/max77686.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 7ec9b4e5b917..5497e10b9659 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -497,8 +497,8 @@ static int max77686_pmic_probe(struct platform_device *pdev)
 		config.init_data = rdata[i].init_data;
 		config.of_node = rdata[i].of_node;
 
-		max77686->opmode[id] = regulators[i].enable_mask >>
-						max77686_get_opmode_shift(id);
+		max77686->opmode[id] = MAX77686_NORMAL;
+
 		rdev = devm_regulator_register(&pdev->dev,
 						&regulators[i], &config);
 		if (IS_ERR(rdev)) {
-- 
1.9.1

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

* [PATCH v2 6/8] regulator: max77686: Add GPIO control
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2014-10-29 15:06 ` [PATCH v2 5/8] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 7/8] mfd/regulator: dt-bindings: max77686: Document gpio property Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 8/8] ARM: dts: exynos4412-trats: Switch max77686 regulators to GPIO control Krzysztof Kozlowski
  7 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

Add enable control over GPIO for regulators supporting this: LDO20,
LDO21, LDO22, buck8 and buck9.

This is needed for proper (and full) configuration of the Maxim 77686
PMIC without creating redundant 'regulator-fixed' entries.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/regulator/Kconfig    |  1 +
 drivers/regulator/max77686.c | 97 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 90 insertions(+), 8 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 55d7b7b0f2e0..156ab8032ea4 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -391,6 +391,7 @@ config REGULATOR_MAX8998
 config REGULATOR_MAX77686
 	tristate "Maxim 77686 regulator"
 	depends on MFD_MAX77686
+	depends on GPIOLIB
 	help
 	  This driver controls a Maxim 77686 regulator
 	  via I2C bus. The provided regulator is suitable for
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 5497e10b9659..9446509e7325 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -26,6 +26,7 @@
 #include <linux/bug.h>
 #include <linux/err.h>
 #include <linux/gpio.h>
+#include <linux/of_gpio.h>
 #include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
@@ -46,6 +47,11 @@
 #define MAX77686_DVS_UVSTEP	12500
 
 /*
+ * Value for configuring buck[89] and LDO{20,21,22} as GPIO control.
+ * It is the same as 'off' for other regulators.
+ */
+#define MAX77686_GPIO_CONTROL		0x0
+/*
  * Values used for configuring LDOs and bucks.
  * Forcing low power mode: LDO1, 3-5, 9, 13, 17-26
  */
@@ -82,6 +88,9 @@ enum max77686_ramp_rate {
 };
 
 struct max77686_data {
+	/* GPIO control over regulators */
+	int gpio[MAX77686_REGULATORS];
+
 	/* Array indexed by regulator id */
 	unsigned int opmode[MAX77686_REGULATORS];
 };
@@ -100,6 +109,25 @@ static unsigned int max77686_get_opmode_shift(int id)
 	}
 }
 
+/*
+ * When regulator is configured for GPIO control then it
+ * replaces "normal" mode. Any change from low power mode to normal
+ * should actually change to GPIO control.
+ * Map normal mode to proper value for such regulators.
+ */
+static int max77686_map_normal_mode(struct max77686_data *max77686, int id)
+{
+	switch (id) {
+	case MAX77686_BUCK8:
+	case MAX77686_BUCK9:
+	case MAX77686_LDO20 ... MAX77686_LDO22:
+		if (gpio_is_valid(max77686->gpio[id]))
+			return MAX77686_GPIO_CONTROL;
+	}
+
+	return MAX77686_NORMAL;
+}
+
 /* Some BUCKs and LDOs supports Normal[ON/OFF] mode during suspend */
 static int max77686_set_suspend_disable(struct regulator_dev *rdev)
 {
@@ -136,7 +164,7 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev,
 		val = MAX77686_LDO_LOWPOWER_PWRREQ;
 		break;
 	case REGULATOR_MODE_NORMAL:			/* ON in Normal Mode */
-		val = MAX77686_NORMAL;
+		val = max77686_map_normal_mode(max77686, id);
 		break;
 	default:
 		pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
@@ -160,7 +188,7 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
 {
 	unsigned int val;
 	struct max77686_data *max77686 = rdev_get_drvdata(rdev);
-	int ret;
+	int ret, id = rdev_get_id(rdev);
 
 	switch (mode) {
 	case REGULATOR_MODE_STANDBY:			/* switch off */
@@ -170,7 +198,7 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
 		val = MAX77686_LDO_LOWPOWER_PWRREQ;
 		break;
 	case REGULATOR_MODE_NORMAL:			/* ON in Normal Mode */
-		val = MAX77686_NORMAL;
+		val = max77686_map_normal_mode(max77686, id);
 		break;
 	default:
 		pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
@@ -184,7 +212,7 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
 	if (ret)
 		return ret;
 
-	max77686->opmode[rdev_get_id(rdev)] = val;
+	max77686->opmode[id] = val;
 	return 0;
 }
 
@@ -197,7 +225,7 @@ static int max77686_enable(struct regulator_dev *rdev)
 	shift = max77686_get_opmode_shift(id);
 
 	if (max77686->opmode[id] == MAX77686_OFF_PWRREQ)
-		max77686->opmode[id] = MAX77686_NORMAL;
+		max77686->opmode[id] = max77686_map_normal_mode(max77686, id);
 
 	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
 				  rdev->desc->enable_mask,
@@ -428,8 +456,46 @@ static const struct regulator_desc regulators[] = {
 	regulator_desc_buck(9),
 };
 
+static int max77686_enable_gpio_control(struct regulator_dev *rdev)
+{
+	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
+					rdev->desc->enable_mask,
+					MAX77686_GPIO_CONTROL);
+}
+
+static void max77686_pmic_dt_parse_gpio_control(struct platform_device *pdev,
+					struct max77686_data *max77686,
+					struct of_regulator_match *rdata)
+{
+	unsigned int i;
+	unsigned int valid_regulators[5] = { MAX77686_LDO20, MAX77686_LDO21,
+		MAX77686_LDO22, MAX77686_BUCK8, MAX77686_BUCK9 };
+
+	/*
+	 * 0 is a valid GPIO so initialize all GPIOs to negative value
+	 * to indicate that GPIO control won't be used for this regulator.
+	 */
+	for (i = 0; i < MAX77686_REGULATORS; i++)
+		max77686->gpio[i] = -EINVAL;
+
+	for (i = 0; i < ARRAY_SIZE(valid_regulators); i++) {
+		unsigned int id = valid_regulators[i];
+		int *gpio = &max77686->gpio[id];
+
+		/* Assuming that index of rdata matches 'id' */
+		if (!rdata[id].init_data || !rdata[id].of_node)
+			continue;
+
+		*gpio = of_get_named_gpio(rdata[id].of_node, "gpio", 0);
+		if (gpio_is_valid(*gpio))
+			dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n",
+				*gpio, id, rdata[id].of_node->name);
+	}
+}
+
 static int max77686_pmic_dt_parse(struct platform_device *pdev,
-				struct of_regulator_match *rdata)
+					struct max77686_data *max77686,
+					struct of_regulator_match *rdata)
 {
 	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
 	struct device_node *pmic_np, *regulators_np;
@@ -444,7 +510,6 @@ static int max77686_pmic_dt_parse(struct platform_device *pdev,
 		return -EINVAL;
 	}
 
-
 	ret = of_regulator_match(&pdev->dev, regulators_np, rdata,
 			MAX77686_REGULATORS);
 	if (ret < 0) {
@@ -454,6 +519,8 @@ static int max77686_pmic_dt_parse(struct platform_device *pdev,
 	}
 	/* else: don't care how many regulators were parsed from DTS. */
 
+	max77686_pmic_dt_parse_gpio_control(pdev, max77686, rdata);
+
 	of_node_put(regulators_np);
 
 	return 0;
@@ -477,6 +544,8 @@ static int max77686_pmic_probe(struct platform_device *pdev)
 	config.dev = &pdev->dev;
 	config.regmap = iodev->regmap;
 	config.driver_data = max77686;
+	config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
+	config.ena_gpio_initialized = true;
 	platform_set_drvdata(pdev, max77686);
 
 	rdata = kzalloc(sizeof(*rdata) * MAX77686_REGULATORS, GFP_KERNEL);
@@ -486,7 +555,7 @@ static int max77686_pmic_probe(struct platform_device *pdev)
 	for (i = 0; i < MAX77686_REGULATORS; i++)
 		rdata[i].name = regulators[i].name;
 
-	ret = max77686_pmic_dt_parse(pdev, rdata);
+	ret = max77686_pmic_dt_parse(pdev, max77686, rdata);
 	if (ret)
 		goto out;
 
@@ -496,6 +565,7 @@ static int max77686_pmic_probe(struct platform_device *pdev)
 
 		config.init_data = rdata[i].init_data;
 		config.of_node = rdata[i].of_node;
+		config.ena_gpio = max77686->gpio[id];
 
 		max77686->opmode[id] = MAX77686_NORMAL;
 
@@ -507,6 +577,17 @@ static int max77686_pmic_probe(struct platform_device *pdev)
 				"regulator init failed for %d: %d\n", i, ret);
 			goto out;
 		}
+
+		if (gpio_is_valid(config.ena_gpio)) {
+			ret = max77686_enable_gpio_control(rdev);
+
+			if (ret < 0) {
+				dev_err(&pdev->dev,
+					"regulator enable ext control failed for %d\n",
+					i);
+				goto out;
+			}
+		}
 	}
 
 out:
-- 
1.9.1

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

* [PATCH v2 7/8] mfd/regulator: dt-bindings: max77686: Document gpio property
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
                   ` (5 preceding siblings ...)
  2014-10-29 15:06 ` [PATCH v2 6/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  2014-10-29 15:06 ` [PATCH v2 8/8] ARM: dts: exynos4412-trats: Switch max77686 regulators to GPIO control Krzysztof Kozlowski
  7 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

Document usage of gpio property which turns on external/GPIO control
over regulator.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 Documentation/devicetree/bindings/mfd/max77686.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt b/Documentation/devicetree/bindings/mfd/max77686.txt
index 75fdfaf41831..7a62baa406a2 100644
--- a/Documentation/devicetree/bindings/mfd/max77686.txt
+++ b/Documentation/devicetree/bindings/mfd/max77686.txt
@@ -39,6 +39,9 @@ to get matched with their hardware counterparts as follow:
 	-BUCKn	:	1-4.
   Use standard regulator bindings for it ('regulator-off-in-suspend').
 
+  Optional properties:
+  - gpio : GPIO to use for enable control. Valid only for LDO20, LDO21,
+    LDO22, BUCK8 and BUCK9 regulators.
 
 Example:
 
-- 
1.9.1

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

* [PATCH v2 8/8] ARM: dts: exynos4412-trats: Switch max77686 regulators to GPIO control
  2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
                   ` (6 preceding siblings ...)
  2014-10-29 15:06 ` [PATCH v2 7/8] mfd/regulator: dt-bindings: max77686: Document gpio property Krzysztof Kozlowski
@ 2014-10-29 15:06 ` Krzysztof Kozlowski
  7 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-29 15:06 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Javier Martinez Canillas, Chanwoo Choi, Krzysztof Kozlowski

Remove fixed regulators (duplicating what max77686 provides) and
add GPIO control to max77686 regulators.

This gives the system full control over those regulators. Previously
the state of such regulators was a mixture of what max77686 driver set
over I2C and what regulator-fixed set through GPIO.

Removal of 'regulator-always-on' from CAM_ISP_CORE_1.2V (buck9) allows
disabling it when it is not used. Previously this regulator was always
enabled because its enable state is a OR of:
 - ENB9 GPIO (turned by regulator-fixed),
 - BUCK9EN field in BUCK9CTRL register (max77686 through I2C).

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-trats2.dts | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 7a68e0832cd6..ac1baff7130d 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -58,15 +58,6 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		vemmc_reg: regulator-0 {
-			compatible = "regulator-fixed";
-			regulator-name = "VMEM_VDD_2.8V";
-			regulator-min-microvolt = <2800000>;
-			regulator-max-microvolt = <2800000>;
-			gpio = <&gpk0 2 0>;
-			enable-active-high;
-		};
-
 		cam_io_reg: voltage-regulator-1 {
 			compatible = "regulator-fixed";
 			regulator-name = "CAM_SENSOR_A";
@@ -94,16 +85,6 @@
 			enable-active-high;
 		};
 
-		cam_isp_core_reg: voltage-regulator-4 {
-			compatible = "regulator-fixed";
-			regulator-name = "CAM_ISP_CORE_1.2V_EN";
-			regulator-min-microvolt = <1200000>;
-			regulator-max-microvolt = <1200000>;
-			gpio = <&gpm0 3 0>;
-			enable-active-high;
-			regulator-always-on;
-		};
-
 		ps_als_reg: voltage-regulator-5 {
 			compatible = "regulator-fixed";
 			regulator-name = "LED_A_3.0V";
@@ -405,6 +386,7 @@
 					regulator-name = "VTF_2.8V";
 					regulator-min-microvolt = <2800000>;
 					regulator-max-microvolt = <2800000>;
+					gpio = <&gpy2 0 0>;
 				};
 
 				ldo22_reg: ldo22 {
@@ -412,6 +394,7 @@
 					regulator-name = "VMEM_VDD_2.8V";
 					regulator-min-microvolt = <2800000>;
 					regulator-max-microvolt = <2800000>;
+					gpio = <&gpk0 2 0>;
 				};
 
 				ldo23_reg: ldo23 {
@@ -518,6 +501,7 @@
 					regulator-name = "VMEM_VDDF_3.0V";
 					regulator-min-microvolt = <2850000>;
 					regulator-max-microvolt = <2850000>;
+					gpio = <&gpk0 2 0>;
 				};
 
 				buck9_reg: buck9 {
@@ -525,6 +509,7 @@
 					regulator-name = "CAM_ISP_CORE_1.2V";
 					regulator-min-microvolt = <1000000>;
 					regulator-max-microvolt = <1200000>;
+					gpio = <&gpm0 3 0>;
 				};
 			};
 		};
@@ -591,7 +576,7 @@
 		broken-cd;
 		non-removable;
 		card-detect-delay = <200>;
-		vmmc-supply = <&vemmc_reg>;
+		vmmc-supply = <&ldo22_reg>;
 		clock-frequency = <400000000>;
 		samsung,dw-mshc-ciu-div = <0>;
 		samsung,dw-mshc-sdr-timing = <2 3>;
-- 
1.9.1

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

* Re: [RFT v2 2/8] regulator: max77802: Remove support for board files
  2014-10-29 15:06 ` [RFT v2 2/8] regulator: max77802: Remove support for board files Krzysztof Kozlowski
@ 2014-10-29 23:41   ` Javier Martinez Canillas
  2014-10-30  7:49     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 11+ messages in thread
From: Javier Martinez Canillas @ 2014-10-29 23:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Samuel Ortiz, Lee Jones, Liam Girdwood,
	Mark Brown, linux-kernel, Ben Dooks, Kukjin Kim, Russell King,
	linux-arm-kernel, linux-samsung-soc, devicetree
  Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Chanwoo Choi

Hello Krzysztof,

On 10/29/2014 04:06 PM, Krzysztof Kozlowski wrote:
>  
>  static int max77802_pmic_probe(struct platform_device *pdev)
>  {
>  	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> -	struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
>  	struct max77802_regulator_prv *max77802;
>  	int i, ret = 0, val;
>  	struct regulator_config config = { };
> -
> -	/* This is allocated by the MFD driver */
> -	if (!pdata) {
> -		dev_err(&pdev->dev, "no platform data found for regulator\n");
> -		return -ENODEV;
> -	}
> +	struct of_regulator_match *rdata;
>  
>  	max77802 = devm_kzalloc(&pdev->dev,
>  				sizeof(struct max77802_regulator_prv),
> @@ -586,24 +558,29 @@ static int max77802_pmic_probe(struct platform_device *pdev)
>  	if (!max77802)
>  		return -ENOMEM;
>  
> -	if (iodev->dev->of_node) {
> -		ret = max77802_pmic_dt_parse_pdata(pdev, pdata);
> -		if (ret)
> -			return ret;
> -	}
> -
>  	config.dev = iodev->dev;
>  	config.regmap = iodev->regmap;
>  	config.driver_data = max77802;
>  	platform_set_drvdata(pdev, max77802);
>  
> +	rdata = kzalloc(sizeof(*rdata) * MAX77802_REG_MAX, GFP_KERNEL);
> +	if (!rdata)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < MAX77802_REG_MAX; i++)
> +		rdata[i].name = regulators[i].name;
> +
> +	ret = max77802_pmic_dt_parse(pdev, rdata);
> +	if (ret)
> +		goto out;
> +
>  	for (i = 0; i < MAX77802_REG_MAX; i++) {
>  		struct regulator_dev *rdev;
> -		int id = pdata->regulators[i].id;
> +		int id = regulators[i].id;
>  		int shift = max77802_get_opmode_shift(id);
>  
> -		config.init_data = pdata->regulators[i].initdata;
> -		config.of_node = pdata->regulators[i].of_node;
> +		config.init_data = rdata[i].init_data;
> +		config.of_node = rdata[i].of_node;
>  
>  		ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val);
>  		val = val >> shift & MAX77802_OPMODE_MASK;
> @@ -621,13 +598,17 @@ static int max77802_pmic_probe(struct platform_device *pdev)
>  		rdev = devm_regulator_register(&pdev->dev,
>  					       &regulators[i], &config);

Thanks for your patch. It's indeed an improvement over the old code and I can
test it tomorrow when I've access to my machine with a max77802 PMIC.

However, I don't think this is the change that Mark asked. AFAIU what he wanted
is to fill the struct regulator_desc .of_match and .regulators_node fields so
the init_data is extracted by the core on regulator registration.

Look at commits a0c7b164 ("regulator: of: Provide simplified DT parsing method")
and 93a127b ("regulator: isl9305: Convert to new style DT parsing") to see what
I'm talking about.

Best regards,
Javier

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

* Re: [RFT v2 2/8] regulator: max77802: Remove support for board files
  2014-10-29 23:41   ` Javier Martinez Canillas
@ 2014-10-30  7:49     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2014-10-30  7:49 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
	Ben Dooks, Kukjin Kim, Russell King, linux-arm-kernel,
	linux-samsung-soc, devicetree, Kyungmin Park, Marek Szyprowski,
	Bartlomiej Zolnierkiewicz, Chanwoo Choi

On czw, 2014-10-30 at 00:41 +0100, Javier Martinez Canillas wrote:
> Hello Krzysztof,
> 
> On 10/29/2014 04:06 PM, Krzysztof Kozlowski wrote:
> >  
> >  static int max77802_pmic_probe(struct platform_device *pdev)
> >  {
> >  	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> > -	struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
> >  	struct max77802_regulator_prv *max77802;
> >  	int i, ret = 0, val;
> >  	struct regulator_config config = { };
> > -
> > -	/* This is allocated by the MFD driver */
> > -	if (!pdata) {
> > -		dev_err(&pdev->dev, "no platform data found for regulator\n");
> > -		return -ENODEV;
> > -	}
> > +	struct of_regulator_match *rdata;
> >  
> >  	max77802 = devm_kzalloc(&pdev->dev,
> >  				sizeof(struct max77802_regulator_prv),
> > @@ -586,24 +558,29 @@ static int max77802_pmic_probe(struct platform_device *pdev)
> >  	if (!max77802)
> >  		return -ENOMEM;
> >  
> > -	if (iodev->dev->of_node) {
> > -		ret = max77802_pmic_dt_parse_pdata(pdev, pdata);
> > -		if (ret)
> > -			return ret;
> > -	}
> > -
> >  	config.dev = iodev->dev;
> >  	config.regmap = iodev->regmap;
> >  	config.driver_data = max77802;
> >  	platform_set_drvdata(pdev, max77802);
> >  
> > +	rdata = kzalloc(sizeof(*rdata) * MAX77802_REG_MAX, GFP_KERNEL);
> > +	if (!rdata)
> > +		return -ENOMEM;
> > +
> > +	for (i = 0; i < MAX77802_REG_MAX; i++)
> > +		rdata[i].name = regulators[i].name;
> > +
> > +	ret = max77802_pmic_dt_parse(pdev, rdata);
> > +	if (ret)
> > +		goto out;
> > +
> >  	for (i = 0; i < MAX77802_REG_MAX; i++) {
> >  		struct regulator_dev *rdev;
> > -		int id = pdata->regulators[i].id;
> > +		int id = regulators[i].id;
> >  		int shift = max77802_get_opmode_shift(id);
> >  
> > -		config.init_data = pdata->regulators[i].initdata;
> > -		config.of_node = pdata->regulators[i].of_node;
> > +		config.init_data = rdata[i].init_data;
> > +		config.of_node = rdata[i].of_node;
> >  
> >  		ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val);
> >  		val = val >> shift & MAX77802_OPMODE_MASK;
> > @@ -621,13 +598,17 @@ static int max77802_pmic_probe(struct platform_device *pdev)
> >  		rdev = devm_regulator_register(&pdev->dev,
> >  					       &regulators[i], &config);
> 
> Thanks for your patch. It's indeed an improvement over the old code and I can
> test it tomorrow when I've access to my machine with a max77802 PMIC.
> 
> However, I don't think this is the change that Mark asked. AFAIU what he wanted
> is to fill the struct regulator_desc .of_match and .regulators_node fields so
> the init_data is extracted by the core on regulator registration.
> 
> Look at commits a0c7b164 ("regulator: of: Provide simplified DT parsing method")
> and 93a127b ("regulator: isl9305: Convert to new style DT parsing") to see what
> I'm talking about.

Ooo, I missed these changes. This should simplify the code even more.
I'll re-spin, so don't hurry with testing :)

Best regards,
Krzysztof

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

end of thread, other threads:[~2014-10-30  7:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 1/8] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
2014-10-29 15:06 ` [RFT v2 2/8] regulator: max77802: Remove support for board files Krzysztof Kozlowski
2014-10-29 23:41   ` Javier Martinez Canillas
2014-10-30  7:49     ` Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 3/8] regulator: max77686: " Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 4/8] mfd: max77686/802: " Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 5/8] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 6/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 7/8] mfd/regulator: dt-bindings: max77686: Document gpio property Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 8/8] ARM: dts: exynos4412-trats: Switch max77686 regulators to GPIO control Krzysztof Kozlowski

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