mfd: tps6586x: add suspend/resume handlers
Varun Wadekar [Mon, 28 Feb 2011 09:42:44 +0000 (14:42 +0530)]
if the system is woken by an alarm, tps' irq handler
gets called and it tries to communicate on i2c. i2c adapters
resume later which causes communication failures in tps' irq
handler. the right way is to disable tps' irq while suspending
in order to avoid such i2c communication failures.

Original-Change-Id: I8487c8b9039d2736acf66e8b02463658428bd5a3
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-on: http://git-master/r/21099
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Rebase-Id: R9822f05d8d72a91407a64d5c96d963e698efd5ec

drivers/mfd/tps6586x.c

index 6d842fa..49b1127 100644 (file)
@@ -602,6 +602,25 @@ static int __devexit tps6586x_i2c_remove(struct i2c_client *client)
        return 0;
 }
 
+#ifdef CONFIG_PM
+static int tps6586x_i2c_suspend(struct i2c_client *client,
+       pm_message_t state)
+{
+       if (client->irq)
+               disable_irq(client->irq);
+
+       return 0;
+}
+
+static int tps6586x_i2c_resume(struct i2c_client *client)
+{
+       if (client->irq)
+               enable_irq(client->irq);
+
+       return 0;
+}
+#endif
+
 static const struct i2c_device_id tps6586x_id_table[] = {
        { "tps6586x", 0 },
        { },
@@ -616,6 +635,10 @@ static struct i2c_driver tps6586x_driver = {
        .probe          = tps6586x_i2c_probe,
        .remove         = __devexit_p(tps6586x_i2c_remove),
        .id_table       = tps6586x_id_table,
+#ifdef CONFIG_PM
+       .suspend        = tps6586x_i2c_suspend,
+       .resume         = tps6586x_i2c_resume,
+#endif
 };
 
 static int __init tps6586x_init(void)