aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/max8997.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/max8997.c')
-rw-r--r--drivers/mfd/max8997.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 50ad93bb49dd..5be53ae9b61c 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/interrupt.h>
26#include <linux/pm_runtime.h> 27#include <linux/pm_runtime.h>
27#include <linux/module.h> 28#include <linux/module.h>
28#include <linux/mutex.h> 29#include <linux/mutex.h>
@@ -143,7 +144,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
143 144
144 max8997->irq_base = pdata->irq_base; 145 max8997->irq_base = pdata->irq_base;
145 max8997->ono = pdata->ono; 146 max8997->ono = pdata->ono;
146 max8997->wakeup = pdata->wakeup;
147 147
148 mutex_init(&max8997->iolock); 148 mutex_init(&max8997->iolock);
149 149
@@ -170,6 +170,9 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
170 if (ret < 0) 170 if (ret < 0)
171 goto err_mfd; 171 goto err_mfd;
172 172
173 /* MAX8997 has a power button input. */
174 device_init_wakeup(max8997->dev, pdata->wakeup);
175
173 return ret; 176 return ret;
174 177
175err_mfd: 178err_mfd:
@@ -399,7 +402,29 @@ static int max8997_restore(struct device *dev)
399 return 0; 402 return 0;
400} 403}
401 404
405static int max8997_suspend(struct device *dev)
406{
407 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
408 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
409
410 if (device_may_wakeup(dev))
411 irq_set_irq_wake(max8997->irq, 1);
412 return 0;
413}
414
415static int max8997_resume(struct device *dev)
416{
417 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
418 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
419
420 if (device_may_wakeup(dev))
421 irq_set_irq_wake(max8997->irq, 0);
422 return max8997_irq_resume(max8997);
423}
424
402const struct dev_pm_ops max8997_pm = { 425const struct dev_pm_ops max8997_pm = {
426 .suspend = max8997_suspend,
427 .resume = max8997_resume,
403 .freeze = max8997_freeze, 428 .freeze = max8997_freeze,
404 .restore = max8997_restore, 429 .restore = max8997_restore,
405}; 430};