public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition.
@ 2010-12-21  5:04 MyungJoo Ham
  2010-12-21  5:04 ` [PATCH 2/2] regulator: max8952 - support hibernation MyungJoo Ham
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: MyungJoo Ham @ 2010-12-21  5:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, Axel Lin, Kyungmin Park

In the current implementation, the GPIO pin, vid0 is checked twice
(duplicated!) while vid1 is never checked; however, both vid0 and
vid1 should be checked. This patch fixes the typo that stated vid0 where
should've stated vid1.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/regulator/max8952.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index 0d5dda4..c7dae2b 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -139,7 +139,7 @@ static int max8952_set_voltage(struct regulator_dev *rdev,
 	s8 vid = -1, i;
 
 	if (!gpio_is_valid(max8952->pdata->gpio_vid0) ||
-			!gpio_is_valid(max8952->pdata->gpio_vid0)) {
+			!gpio_is_valid(max8952->pdata->gpio_vid1)) {
 		/* DVS not supported */
 		return -EPERM;
 	}
-- 
1.7.1


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

* [PATCH 2/2] regulator: max8952 - support hibernation
  2010-12-21  5:04 [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition MyungJoo Ham
@ 2010-12-21  5:04 ` MyungJoo Ham
  2010-12-21 11:32   ` Mark Brown
  2010-12-21 11:30 ` [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition Mark Brown
  2010-12-21 12:58 ` Liam Girdwood
  2 siblings, 1 reply; 5+ messages in thread
From: MyungJoo Ham @ 2010-12-21  5:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, Axel Lin, Kyungmin Park

Unlike suspend, where the registers of max8952 are not reset, during
hibernation, the register values are reset with an instance of
hibernation.

This patch lets max8952 save and restore register values during
hibernation.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/regulator/max8952.c |   61 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index c7dae2b..530d3b6 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -30,10 +30,11 @@
 #include <linux/gpio.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/pm_runtime.h>
 
 /* Registers */
 enum {
-	MAX8952_REG_MODE0,
+	MAX8952_REG_MODE0 = 0,
 	MAX8952_REG_MODE1,
 	MAX8952_REG_MODE2,
 	MAX8952_REG_MODE3,
@@ -311,6 +312,8 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, max8952);
 
+	pm_runtime_set_active(max8952->dev);
+
 	return 0;
 
 err_reg:
@@ -340,11 +343,67 @@ static const struct i2c_device_id max8952_ids[] = {
 };
 MODULE_DEVICE_TABLE(i2c, max8952_ids);
 
+struct max8952_reg_dump {
+	u8	addr;
+	u8	val;
+};
+#define SAVE_ITEM(x)	{ .addr = (x), .val = 0x0, }
+static struct max8952_reg_dump max8952_dump[] = {
+	SAVE_ITEM(MAX8952_REG_MODE0),
+	SAVE_ITEM(MAX8952_REG_MODE1),
+	SAVE_ITEM(MAX8952_REG_MODE2),
+	SAVE_ITEM(MAX8952_REG_MODE3),
+	SAVE_ITEM(MAX8952_REG_CONTROL),
+	SAVE_ITEM(MAX8952_REG_SYNC),
+	SAVE_ITEM(MAX8952_REG_RAMP),
+};
+
+/* Save registers before hibernation */
+static int max8952_freeze(struct device *dev)
+{
+	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
+	struct max8952_data *max8952 = i2c_get_clientdata(i2c);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(max8952_dump); i++) {
+		int val = max8952_read_reg(max8952, max8952_dump[i].addr);
+		if (val >= 0)
+			max8952_dump[i].val = val;
+		else {
+			dev_emerg(dev, "reading error %d\n", val);
+			return val;
+		}
+	}
+
+	return 0;
+}
+
+/* Restore registers after hibernation */
+static int max8952_restore(struct device *dev)
+{
+	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
+	struct max8952_data *max8952 = i2c_get_clientdata(i2c);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(max8952_dump); i++)
+		max8952_write_reg(max8952, max8952_dump[i].addr,
+				max8952_dump[i].val);
+
+	return 0;
+}
+
+static const struct dev_pm_ops max8952_pm = {
+	.freeze = max8952_freeze,
+	.restore = max8952_restore,
+};
+
 static struct i2c_driver max8952_pmic_driver = {
 	.probe		= max8952_pmic_probe,
 	.remove		= __devexit_p(max8952_pmic_remove),
 	.driver		= {
 		.name	= "max8952",
+		.owner	= THIS_MODULE,
+		.pm	= &max8952_pm,
 	},
 	.id_table	= max8952_ids,
 };
-- 
1.7.1


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

* Re: [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition.
  2010-12-21  5:04 [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition MyungJoo Ham
  2010-12-21  5:04 ` [PATCH 2/2] regulator: max8952 - support hibernation MyungJoo Ham
@ 2010-12-21 11:30 ` Mark Brown
  2010-12-21 12:58 ` Liam Girdwood
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-12-21 11:30 UTC (permalink / raw)
  To: MyungJoo Ham; +Cc: linux-kernel, Liam Girdwood, Axel Lin, Kyungmin Park

On Tue, Dec 21, 2010 at 02:04:39PM +0900, MyungJoo Ham wrote:
> In the current implementation, the GPIO pin, vid0 is checked twice
> (duplicated!) while vid1 is never checked; however, both vid0 and
> vid1 should be checked. This patch fixes the typo that stated vid0 where
> should've stated vid1.
> 
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

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

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

* Re: [PATCH 2/2] regulator: max8952 - support hibernation
  2010-12-21  5:04 ` [PATCH 2/2] regulator: max8952 - support hibernation MyungJoo Ham
@ 2010-12-21 11:32   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-12-21 11:32 UTC (permalink / raw)
  To: MyungJoo Ham; +Cc: linux-kernel, Liam Girdwood, Axel Lin, Kyungmin Park

On Tue, Dec 21, 2010 at 02:04:40PM +0900, MyungJoo Ham wrote:
> Unlike suspend, where the registers of max8952 are not reset, during
> hibernation, the register values are reset with an instance of
> hibernation.
> 
> This patch lets max8952 save and restore register values during
> hibernation.
> 
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

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

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

* Re: [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition.
  2010-12-21  5:04 [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition MyungJoo Ham
  2010-12-21  5:04 ` [PATCH 2/2] regulator: max8952 - support hibernation MyungJoo Ham
  2010-12-21 11:30 ` [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition Mark Brown
@ 2010-12-21 12:58 ` Liam Girdwood
  2 siblings, 0 replies; 5+ messages in thread
From: Liam Girdwood @ 2010-12-21 12:58 UTC (permalink / raw)
  To: MyungJoo Ham; +Cc: linux-kernel, Mark Brown, Axel Lin, Kyungmin Park

On Tue, 2010-12-21 at 14:04 +0900, MyungJoo Ham wrote:
> In the current implementation, the GPIO pin, vid0 is checked twice
> (duplicated!) while vid1 is never checked; however, both vid0 and
> vid1 should be checked. This patch fixes the typo that stated vid0 where
> should've stated vid1.
> 
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
>  drivers/regulator/max8952.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
> index 0d5dda4..c7dae2b 100644
> --- a/drivers/regulator/max8952.c
> +++ b/drivers/regulator/max8952.c
> @@ -139,7 +139,7 @@ static int max8952_set_voltage(struct regulator_dev *rdev,
>  	s8 vid = -1, i;
>  
>  	if (!gpio_is_valid(max8952->pdata->gpio_vid0) ||
> -			!gpio_is_valid(max8952->pdata->gpio_vid0)) {
> +			!gpio_is_valid(max8952->pdata->gpio_vid1)) {
>  		/* DVS not supported */
>  		return -EPERM;
>  	}

Does this series depend on your MFD MAX8998/LP3974 hibernation, charger
patch ?

Thanks

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


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

end of thread, other threads:[~2010-12-21 12:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-21  5:04 [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition MyungJoo Ham
2010-12-21  5:04 ` [PATCH 2/2] regulator: max8952 - support hibernation MyungJoo Ham
2010-12-21 11:32   ` Mark Brown
2010-12-21 11:30 ` [PATCH 1/2] regulator: max8952 - fix max8952_set_voltage check condition Mark Brown
2010-12-21 12:58 ` Liam Girdwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox