diff options
| author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2011-08-19 01:39:40 -0400 |
|---|---|---|
| committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-10-24 08:09:11 -0400 |
| commit | 01fdaab8ffced1deeee14d9c7d2745f37349484e (patch) | |
| tree | bed9ea0b9bdface7747ca7b472b53f970f696134 | |
| parent | 5f40c6b6508b622ea03c6b32c57b2e26eba2e4f1 (diff) | |
mfd: Wake-up from Suspend MAX8997 support
- Support wake-up from suspend-to-ram.
- Handle pending interrupt after a resume.
- If pdata->wakeup is enabled, by default, the device is assumed to be
capable of wakeup (the interrupt pin is connected to a wakeup-source GPIO)
and may wakeup the system (MAX8997 has a power button input pin).
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
| -rw-r--r-- | drivers/mfd/max8997.c | 27 | ||||
| -rw-r--r-- | include/linux/mfd/max8997-private.h | 1 |
2 files changed, 26 insertions, 2 deletions
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c index f83103b8970d..dc58750bb71b 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/mutex.h> | 28 | #include <linux/mutex.h> |
| 28 | #include <linux/mfd/core.h> | 29 | #include <linux/mfd/core.h> |
| @@ -142,7 +143,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c, | |||
| 142 | 143 | ||
| 143 | max8997->irq_base = pdata->irq_base; | 144 | max8997->irq_base = pdata->irq_base; |
| 144 | max8997->ono = pdata->ono; | 145 | max8997->ono = pdata->ono; |
| 145 | max8997->wakeup = pdata->wakeup; | ||
| 146 | 146 | ||
| 147 | mutex_init(&max8997->iolock); | 147 | mutex_init(&max8997->iolock); |
| 148 | 148 | ||
| @@ -169,6 +169,9 @@ static int max8997_i2c_probe(struct i2c_client *i2c, | |||
| 169 | if (ret < 0) | 169 | if (ret < 0) |
| 170 | goto err_mfd; | 170 | goto err_mfd; |
| 171 | 171 | ||
| 172 | /* MAX8997 has a power button input. */ | ||
| 173 | device_init_wakeup(max8997->dev, pdata->wakeup); | ||
| 174 | |||
| 172 | return ret; | 175 | return ret; |
| 173 | 176 | ||
| 174 | err_mfd: | 177 | err_mfd: |
| @@ -398,7 +401,29 @@ static int max8997_restore(struct device *dev) | |||
| 398 | return 0; | 401 | return 0; |
| 399 | } | 402 | } |
| 400 | 403 | ||
| 404 | static int max8997_suspend(struct device *dev) | ||
| 405 | { | ||
| 406 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | ||
| 407 | struct max8997_dev *max8997 = i2c_get_clientdata(i2c); | ||
| 408 | |||
| 409 | if (device_may_wakeup(dev)) | ||
| 410 | irq_set_irq_wake(max8997->irq, 1); | ||
| 411 | return 0; | ||
| 412 | } | ||
| 413 | |||
| 414 | static int max8997_resume(struct device *dev) | ||
| 415 | { | ||
| 416 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | ||
| 417 | struct max8997_dev *max8997 = i2c_get_clientdata(i2c); | ||
| 418 | |||
| 419 | if (device_may_wakeup(dev)) | ||
| 420 | irq_set_irq_wake(max8997->irq, 0); | ||
| 421 | return max8997_irq_resume(max8997); | ||
| 422 | } | ||
| 423 | |||
| 401 | const struct dev_pm_ops max8997_pm = { | 424 | const struct dev_pm_ops max8997_pm = { |
| 425 | .suspend = max8997_suspend, | ||
| 426 | .resume = max8997_resume, | ||
| 402 | .freeze = max8997_freeze, | 427 | .freeze = max8997_freeze, |
| 403 | .restore = max8997_restore, | 428 | .restore = max8997_restore, |
| 404 | }; | 429 | }; |
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h index 5ff2400ad46c..3f4deb62d6b0 100644 --- a/include/linux/mfd/max8997-private.h +++ b/include/linux/mfd/max8997-private.h | |||
| @@ -326,7 +326,6 @@ struct max8997_dev { | |||
| 326 | int irq; | 326 | int irq; |
| 327 | int ono; | 327 | int ono; |
| 328 | int irq_base; | 328 | int irq_base; |
| 329 | bool wakeup; | ||
| 330 | struct mutex irqlock; | 329 | struct mutex irqlock; |
| 331 | int irq_masks_cur[MAX8997_IRQ_GROUP_NR]; | 330 | int irq_masks_cur[MAX8997_IRQ_GROUP_NR]; |
| 332 | int irq_masks_cache[MAX8997_IRQ_GROUP_NR]; | 331 | int irq_masks_cache[MAX8997_IRQ_GROUP_NR]; |
