diff options
Diffstat (limited to 'drivers/rtc/rtc-bfin.c')
| -rw-r--r-- | drivers/rtc/rtc-bfin.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index d4fb82d85e9b..b4b6087f2234 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Blackfin On-Chip Real Time Clock Driver | 2 | * Blackfin On-Chip Real Time Clock Driver |
| 3 | * Supports BF51x/BF52x/BF53[123]/BF53[467]/BF54x | 3 | * Supports BF51x/BF52x/BF53[123]/BF53[467]/BF54x |
| 4 | * | 4 | * |
| 5 | * Copyright 2004-2009 Analog Devices Inc. | 5 | * Copyright 2004-2010 Analog Devices Inc. |
| 6 | * | 6 | * |
| 7 | * Enter bugs at http://blackfin.uclinux.org/ | 7 | * Enter bugs at http://blackfin.uclinux.org/ |
| 8 | * | 8 | * |
| @@ -183,29 +183,33 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id) | |||
| 183 | struct bfin_rtc *rtc = dev_get_drvdata(dev); | 183 | struct bfin_rtc *rtc = dev_get_drvdata(dev); |
| 184 | unsigned long events = 0; | 184 | unsigned long events = 0; |
| 185 | bool write_complete = false; | 185 | bool write_complete = false; |
| 186 | u16 rtc_istat, rtc_ictl; | 186 | u16 rtc_istat, rtc_istat_clear, rtc_ictl, bits; |
| 187 | 187 | ||
| 188 | dev_dbg_stamp(dev); | 188 | dev_dbg_stamp(dev); |
| 189 | 189 | ||
| 190 | rtc_istat = bfin_read_RTC_ISTAT(); | 190 | rtc_istat = bfin_read_RTC_ISTAT(); |
| 191 | rtc_ictl = bfin_read_RTC_ICTL(); | 191 | rtc_ictl = bfin_read_RTC_ICTL(); |
| 192 | rtc_istat_clear = 0; | ||
| 192 | 193 | ||
| 193 | if (rtc_istat & RTC_ISTAT_WRITE_COMPLETE) { | 194 | bits = RTC_ISTAT_WRITE_COMPLETE; |
| 194 | bfin_write_RTC_ISTAT(RTC_ISTAT_WRITE_COMPLETE); | 195 | if (rtc_istat & bits) { |
| 196 | rtc_istat_clear |= bits; | ||
| 195 | write_complete = true; | 197 | write_complete = true; |
| 196 | complete(&bfin_write_complete); | 198 | complete(&bfin_write_complete); |
| 197 | } | 199 | } |
| 198 | 200 | ||
| 199 | if (rtc_ictl & (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)) { | 201 | bits = (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY); |
| 200 | if (rtc_istat & (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)) { | 202 | if (rtc_ictl & bits) { |
| 201 | bfin_write_RTC_ISTAT(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY); | 203 | if (rtc_istat & bits) { |
| 204 | rtc_istat_clear |= bits; | ||
| 202 | events |= RTC_AF | RTC_IRQF; | 205 | events |= RTC_AF | RTC_IRQF; |
| 203 | } | 206 | } |
| 204 | } | 207 | } |
| 205 | 208 | ||
| 206 | if (rtc_ictl & RTC_ISTAT_SEC) { | 209 | bits = RTC_ISTAT_SEC; |
| 207 | if (rtc_istat & RTC_ISTAT_SEC) { | 210 | if (rtc_ictl & bits) { |
| 208 | bfin_write_RTC_ISTAT(RTC_ISTAT_SEC); | 211 | if (rtc_istat & bits) { |
| 212 | rtc_istat_clear |= bits; | ||
| 209 | events |= RTC_UF | RTC_IRQF; | 213 | events |= RTC_UF | RTC_IRQF; |
| 210 | } | 214 | } |
| 211 | } | 215 | } |
| @@ -213,9 +217,10 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id) | |||
| 213 | if (events) | 217 | if (events) |
| 214 | rtc_update_irq(rtc->rtc_dev, 1, events); | 218 | rtc_update_irq(rtc->rtc_dev, 1, events); |
| 215 | 219 | ||
| 216 | if (write_complete || events) | 220 | if (write_complete || events) { |
| 221 | bfin_write_RTC_ISTAT(rtc_istat_clear); | ||
| 217 | return IRQ_HANDLED; | 222 | return IRQ_HANDLED; |
| 218 | else | 223 | } else |
| 219 | return IRQ_NONE; | 224 | return IRQ_NONE; |
| 220 | } | 225 | } |
| 221 | 226 | ||
| @@ -422,9 +427,13 @@ static int __devexit bfin_rtc_remove(struct platform_device *pdev) | |||
| 422 | #ifdef CONFIG_PM | 427 | #ifdef CONFIG_PM |
| 423 | static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state) | 428 | static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state) |
| 424 | { | 429 | { |
| 425 | if (device_may_wakeup(&pdev->dev)) { | 430 | struct device *dev = &pdev->dev; |
| 431 | |||
| 432 | dev_dbg_stamp(dev); | ||
| 433 | |||
| 434 | if (device_may_wakeup(dev)) { | ||
| 426 | enable_irq_wake(IRQ_RTC); | 435 | enable_irq_wake(IRQ_RTC); |
| 427 | bfin_rtc_sync_pending(&pdev->dev); | 436 | bfin_rtc_sync_pending(dev); |
| 428 | } else | 437 | } else |
| 429 | bfin_rtc_int_clear(0); | 438 | bfin_rtc_int_clear(0); |
| 430 | 439 | ||
| @@ -433,7 +442,11 @@ static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
| 433 | 442 | ||
| 434 | static int bfin_rtc_resume(struct platform_device *pdev) | 443 | static int bfin_rtc_resume(struct platform_device *pdev) |
| 435 | { | 444 | { |
| 436 | if (device_may_wakeup(&pdev->dev)) | 445 | struct device *dev = &pdev->dev; |
| 446 | |||
| 447 | dev_dbg_stamp(dev); | ||
| 448 | |||
| 449 | if (device_may_wakeup(dev)) | ||
| 437 | disable_irq_wake(IRQ_RTC); | 450 | disable_irq_wake(IRQ_RTC); |
| 438 | 451 | ||
| 439 | /* | 452 | /* |
