aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/rtc-at91sam9.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 831868904e02..1dd61f402b04 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -58,6 +58,7 @@ struct sam9_rtc {
58 struct rtc_device *rtcdev; 58 struct rtc_device *rtcdev;
59 u32 imr; 59 u32 imr;
60 void __iomem *gpbr; 60 void __iomem *gpbr;
61 int irq;
61}; 62};
62 63
63#define rtt_readl(rtc, field) \ 64#define rtt_readl(rtc, field) \
@@ -292,7 +293,7 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
292{ 293{
293 struct resource *r, *r_gpbr; 294 struct resource *r, *r_gpbr;
294 struct sam9_rtc *rtc; 295 struct sam9_rtc *rtc;
295 int ret; 296 int ret, irq;
296 u32 mr; 297 u32 mr;
297 298
298 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 299 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -302,10 +303,18 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
302 return -ENODEV; 303 return -ENODEV;
303 } 304 }
304 305
306 irq = platform_get_irq(pdev, 0);
307 if (irq < 0) {
308 dev_err(&pdev->dev, "failed to get interrupt resource\n");
309 return irq;
310 }
311
305 rtc = kzalloc(sizeof *rtc, GFP_KERNEL); 312 rtc = kzalloc(sizeof *rtc, GFP_KERNEL);
306 if (!rtc) 313 if (!rtc)
307 return -ENOMEM; 314 return -ENOMEM;
308 315
316 rtc->irq = irq;
317
309 /* platform setup code should have handled this; sigh */ 318 /* platform setup code should have handled this; sigh */
310 if (!device_can_wakeup(&pdev->dev)) 319 if (!device_can_wakeup(&pdev->dev))
311 device_init_wakeup(&pdev->dev, 1); 320 device_init_wakeup(&pdev->dev, 1);
@@ -345,11 +354,10 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
345 } 354 }
346 355
347 /* register irq handler after we know what name we'll use */ 356 /* register irq handler after we know what name we'll use */
348 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 357 ret = request_irq(rtc->irq, at91_rtc_interrupt, IRQF_SHARED,
349 IRQF_SHARED,
350 dev_name(&rtc->rtcdev->dev), rtc); 358 dev_name(&rtc->rtcdev->dev), rtc);
351 if (ret) { 359 if (ret) {
352 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); 360 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);
353 rtc_device_unregister(rtc->rtcdev); 361 rtc_device_unregister(rtc->rtcdev);
354 goto fail_register; 362 goto fail_register;
355 } 363 }
@@ -386,7 +394,7 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)
386 394
387 /* disable all interrupts */ 395 /* disable all interrupts */
388 rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)); 396 rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN));
389 free_irq(AT91_ID_SYS, rtc); 397 free_irq(rtc->irq, rtc);
390 398
391 rtc_device_unregister(rtc->rtcdev); 399 rtc_device_unregister(rtc->rtcdev);
392 400
@@ -423,7 +431,7 @@ static int at91_rtc_suspend(struct platform_device *pdev,
423 rtc->imr = mr & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); 431 rtc->imr = mr & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
424 if (rtc->imr) { 432 if (rtc->imr) {
425 if (device_may_wakeup(&pdev->dev) && (mr & AT91_RTT_ALMIEN)) { 433 if (device_may_wakeup(&pdev->dev) && (mr & AT91_RTT_ALMIEN)) {
426 enable_irq_wake(AT91_ID_SYS); 434 enable_irq_wake(rtc->irq);
427 /* don't let RTTINC cause wakeups */ 435 /* don't let RTTINC cause wakeups */
428 if (mr & AT91_RTT_RTTINCIEN) 436 if (mr & AT91_RTT_RTTINCIEN)
429 rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN); 437 rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN);
@@ -441,7 +449,7 @@ static int at91_rtc_resume(struct platform_device *pdev)
441 449
442 if (rtc->imr) { 450 if (rtc->imr) {
443 if (device_may_wakeup(&pdev->dev)) 451 if (device_may_wakeup(&pdev->dev))
444 disable_irq_wake(AT91_ID_SYS); 452 disable_irq_wake(rtc->irq);
445 mr = rtt_readl(rtc, MR); 453 mr = rtt_readl(rtc, MR);
446 rtt_writel(rtc, MR, mr | rtc->imr); 454 rtt_writel(rtc, MR, mr | rtc->imr);
447 } 455 }