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 <[email protected]>
Signed-off-by: Kyungmin Park <[email protected]>
---
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
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 <[email protected]>
Signed-off-by: Kyungmin Park <[email protected]>
---
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
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 <[email protected]>
> Signed-off-by: Kyungmin Park <[email protected]>
Acked-by: Mark Brown <[email protected]>
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 <[email protected]>
> Signed-off-by: Kyungmin Park <[email protected]>
Acked-by: Mark Brown <[email protected]>
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 <[email protected]>
> Signed-off-by: Kyungmin Park <[email protected]>
> ---
> 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