mfd: max77663: Move sleep enable setting from suspend to resume
Jin Park [Thu, 27 Oct 2011 10:14:18 +0000 (19:14 +0900)]
Moving sleep enable setting from suspend to resume.
And add sleep enable setting into probe.

Bug 849360

Reviewed-on: http://git-master/r/60656
(cherry picked from commit 9ba5f1f22d73fe62d0f509fd6cad26f34e25a017)
Signed-off-by: Jin Park <jinyoungp@nvidia.com>

Change-Id: I7275a5f8d8e0f8d75826854c91946e82d52c8278
Reviewed-on: http://git-master/r/65694
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: Re4a4c87dd95180c17680c258b37490bdb3179634

drivers/mfd/max77663-core.c

index 05fda2d..e8b400a 100644 (file)
@@ -363,6 +363,22 @@ int max77663_power_off(void)
 }
 EXPORT_SYMBOL(max77663_power_off);
 
+static int max77663_sleep_enable(struct max77663_chip *chip)
+{
+       int ret;
+
+       /* Enable sleep that AP can be placed into sleep mode
+        * by pulling EN1 low */
+       ret = max77663_set_bits(chip->dev, MAX77663_REG_ONOFF_CFG1,
+                               ONOFF_SLPEN_MASK, ONOFF_SLPEN_MASK, 0);
+       if (ret < 0)
+               dev_err(chip->dev,
+                       "sleep_enable: Failed to set on/off config1\n",
+                       MAX77663_REG_ONOFF_CFG1);
+
+       return ret;
+}
+
 static inline int max77663_cache_write(struct device *dev, u8 addr, u8 mask,
                                       u8 val, u8 *cache)
 {
@@ -1277,6 +1293,7 @@ static int max77663_probe(struct i2c_client *client,
        max77663_gpio_init(chip);
        max77663_irq_init(chip);
        max77663_debugfs_init(chip);
+       max77663_sleep_enable(chip);
 
        ret = mfd_add_devices(&client->dev, 0, pdata->sub_devices,
                              pdata->num_subdevs, NULL, 0);
@@ -1317,31 +1334,23 @@ static int __devexit max77663_remove(struct i2c_client *client)
 static int max77663_suspend(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
-       struct max77663_chip *chip = i2c_get_clientdata(client);
-       int ret;
 
        if (client->irq)
                disable_irq(client->irq);
 
-       /* Enable sleep that AP can be placed into sleep mode
-        * by pulling EN1 low */
-       ret = max77663_set_bits(chip->dev, MAX77663_REG_ONOFF_CFG1,
-                                ONOFF_SLPEN_MASK, ONOFF_SLPEN_MASK, 0);
-       if (ret < 0)
-               dev_err(&client->dev,
-                       "suspend: Failed to set ONOFF_CFG1(0x%02x)\n",
-                       MAX77663_REG_ONOFF_CFG1);
-
        return 0;
 }
 
 static int max77663_resume(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
+       struct max77663_chip *chip = i2c_get_clientdata(client);
 
        if (client->irq)
                enable_irq(client->irq);
 
+       max77663_sleep_enable(chip);
+
        return 0;
 }
 #else