diff options
-rw-r--r-- | drivers/rtc/rtc-pl031.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 0f0609b1aa2c..7fbb5c1d38fc 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -371,6 +371,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) } } + device_init_wakeup(&adev->dev, 1); ldata->rtc = rtc_device_register("pl031", &adev->dev, ops, THIS_MODULE); if (IS_ERR(ldata->rtc)) { @@ -384,8 +385,6 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) goto out_no_irq; } - device_init_wakeup(&adev->dev, 1); - return 0; out_no_irq: @@ -402,6 +401,32 @@ err_req: return ret; } +#ifdef CONFIG_PM +static int pl031_suspend(struct device *dev) +{ + struct amba_device *adev = to_amba_device(dev); + + if (adev->irq[0] >= 0 && device_may_wakeup(&adev->dev)) + enable_irq_wake(adev->irq[0]); + return 0; +} + +static int pl031_resume(struct device *dev) +{ + struct amba_device *adev = to_amba_device(dev); + + if (adev->irq[0] >= 0 && device_may_wakeup(&adev->dev)) + disable_irq_wake(adev->irq[0]); + return 0; +} + +static SIMPLE_DEV_PM_OPS(pl031_pm, pl031_suspend, pl031_resume); + +#define PL031_PM (&pl031_pm) +#else +#define PL031_PM NULL +#endif + /* Operations for the original ARM version */ static struct pl031_vendor_data arm_pl031 = { .ops = { @@ -471,6 +496,7 @@ MODULE_DEVICE_TABLE(amba, pl031_ids); static struct amba_driver pl031_driver = { .drv = { .name = "rtc-pl031", + .pm = PL031_PM, }, .id_table = pl031_ids, .probe = pl031_probe, |