mfd: as3722: Handle interrupts on suspend
[deliverable/linux.git] / drivers / mfd / as3722.c
index 924ea90494ae5befe09595ecd007497465acc4da..3b21eb4bc480ef13c618294ad4e443ddec45b1ed 100644 (file)
@@ -405,6 +405,8 @@ static int as3722_i2c_probe(struct i2c_client *i2c,
                goto scrub;
        }
 
+       device_init_wakeup(as3722->dev, true);
+
        dev_dbg(as3722->dev, "AS3722 core driver initialized successfully\n");
        return 0;
 
@@ -422,6 +424,29 @@ static int as3722_i2c_remove(struct i2c_client *i2c)
        return 0;
 }
 
+static int as3722_i2c_suspend(struct device *dev)
+{
+       struct as3722 *as3722 = dev_get_drvdata(dev);
+
+       if (device_may_wakeup(dev))
+               enable_irq_wake(as3722->chip_irq);
+       disable_irq(as3722->chip_irq);
+
+       return 0;
+}
+
+static int as3722_i2c_resume(struct device *dev)
+{
+       struct as3722 *as3722 = dev_get_drvdata(dev);
+
+       enable_irq(as3722->chip_irq);
+
+       if (device_may_wakeup(dev))
+               disable_irq_wake(as3722->chip_irq);
+
+       return 0;
+}
+
 static const struct of_device_id as3722_of_match[] = {
        { .compatible = "ams,as3722", },
        {},
@@ -434,10 +459,15 @@ static const struct i2c_device_id as3722_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, as3722_i2c_id);
 
+static const struct dev_pm_ops as3722_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(as3722_i2c_suspend, as3722_i2c_resume)
+};
+
 static struct i2c_driver as3722_i2c_driver = {
        .driver = {
                .name = "as3722",
                .of_match_table = as3722_of_match,
+               .pm = &as3722_pm_ops,
        },
        .probe = as3722_i2c_probe,
        .remove = as3722_i2c_remove,
This page took 0.026372 seconds and 5 git commands to generate.