mfd: max77663: Set sleep enable bit before enter into suspend
Min-wuk Lee [Fri, 4 Nov 2011 07:51:27 +0000 (16:51 +0900)]
The sleep enable is required that AP can be placed MAX77663 into sleep mode
by pulling EN1 input low.

Bug 849360

Original Author : Jinyoung Park

Reviewed-on: http://git-master/r/59477
(cherry picked from commit 469106a1f8cf8d080f06ae0d2e8d0b2aa4bf3e4b)

Reviewed-on: http://git-master/r/62378
(cherry picked from commit 42c8b2466ead1a9382b87d9753afad7d3d7b9b72)

Change-Id: Id205c691bf629c080a533e5d38ef2f3823d35703
Reviewed-on: http://git-master/r/63758
Reviewed-by: Min-wuk Lee <mlee@nvidia.com>
Tested-by: Min-wuk Lee <mlee@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Rebase-Id: Rbab33031a6556f229a0bf6aef57f906a95152340

drivers/mfd/max77663-core.c

index 97b1980..05fda2d 100644 (file)
 #define GPIO_DBNC_32MS                 3
 
 #define ONOFF_SFT_RST_MASK             (1 << 7)
+#define ONOFF_SLPEN_MASK               (1 << 2)
 
 enum {
        CACHE_IRQ_LBT,
@@ -1316,10 +1317,21 @@ 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;
 }