|
@@ -58,6 +58,7 @@ struct sam9_rtc {
|
|
struct rtc_device *rtcdev;
|
|
struct rtc_device *rtcdev;
|
|
u32 imr;
|
|
u32 imr;
|
|
void __iomem *gpbr;
|
|
void __iomem *gpbr;
|
|
|
|
+ int irq;
|
|
};
|
|
};
|
|
|
|
|
|
#define rtt_readl(rtc, field) \
|
|
#define rtt_readl(rtc, field) \
|
|
@@ -292,7 +293,7 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
|
|
{
|
|
{
|
|
struct resource *r, *r_gpbr;
|
|
struct resource *r, *r_gpbr;
|
|
struct sam9_rtc *rtc;
|
|
struct sam9_rtc *rtc;
|
|
- int ret;
|
|
|
|
|
|
+ int ret, irq;
|
|
u32 mr;
|
|
u32 mr;
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
@@ -302,10 +303,18 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ irq = platform_get_irq(pdev, 0);
|
|
|
|
+ if (irq < 0) {
|
|
|
|
+ dev_err(&pdev->dev, "failed to get interrupt resource\n");
|
|
|
|
+ return irq;
|
|
|
|
+ }
|
|
|
|
+
|
|
rtc = kzalloc(sizeof *rtc, GFP_KERNEL);
|
|
rtc = kzalloc(sizeof *rtc, GFP_KERNEL);
|
|
if (!rtc)
|
|
if (!rtc)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
+ rtc->irq = irq;
|
|
|
|
+
|
|
/* platform setup code should have handled this; sigh */
|
|
/* platform setup code should have handled this; sigh */
|
|
if (!device_can_wakeup(&pdev->dev))
|
|
if (!device_can_wakeup(&pdev->dev))
|
|
device_init_wakeup(&pdev->dev, 1);
|
|
device_init_wakeup(&pdev->dev, 1);
|
|
@@ -345,11 +354,10 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
|
|
}
|
|
}
|
|
|
|
|
|
/* register irq handler after we know what name we'll use */
|
|
/* register irq handler after we know what name we'll use */
|
|
- ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
|
|
|
|
- IRQF_SHARED,
|
|
|
|
|
|
+ ret = request_irq(rtc->irq, at91_rtc_interrupt, IRQF_SHARED,
|
|
dev_name(&rtc->rtcdev->dev), rtc);
|
|
dev_name(&rtc->rtcdev->dev), rtc);
|
|
if (ret) {
|
|
if (ret) {
|
|
- dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS);
|
|
|
|
|
|
+ dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);
|
|
rtc_device_unregister(rtc->rtcdev);
|
|
rtc_device_unregister(rtc->rtcdev);
|
|
goto fail_register;
|
|
goto fail_register;
|
|
}
|
|
}
|
|
@@ -386,7 +394,7 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)
|
|
|
|
|
|
/* disable all interrupts */
|
|
/* disable all interrupts */
|
|
rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN));
|
|
rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN));
|
|
- free_irq(AT91_ID_SYS, rtc);
|
|
|
|
|
|
+ free_irq(rtc->irq, rtc);
|
|
|
|
|
|
rtc_device_unregister(rtc->rtcdev);
|
|
rtc_device_unregister(rtc->rtcdev);
|
|
|
|
|
|
@@ -423,7 +431,7 @@ static int at91_rtc_suspend(struct platform_device *pdev,
|
|
rtc->imr = mr & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
|
|
rtc->imr = mr & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
|
|
if (rtc->imr) {
|
|
if (rtc->imr) {
|
|
if (device_may_wakeup(&pdev->dev) && (mr & AT91_RTT_ALMIEN)) {
|
|
if (device_may_wakeup(&pdev->dev) && (mr & AT91_RTT_ALMIEN)) {
|
|
- enable_irq_wake(AT91_ID_SYS);
|
|
|
|
|
|
+ enable_irq_wake(rtc->irq);
|
|
/* don't let RTTINC cause wakeups */
|
|
/* don't let RTTINC cause wakeups */
|
|
if (mr & AT91_RTT_RTTINCIEN)
|
|
if (mr & AT91_RTT_RTTINCIEN)
|
|
rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN);
|
|
rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN);
|
|
@@ -441,7 +449,7 @@ static int at91_rtc_resume(struct platform_device *pdev)
|
|
|
|
|
|
if (rtc->imr) {
|
|
if (rtc->imr) {
|
|
if (device_may_wakeup(&pdev->dev))
|
|
if (device_may_wakeup(&pdev->dev))
|
|
- disable_irq_wake(AT91_ID_SYS);
|
|
|
|
|
|
+ disable_irq_wake(rtc->irq);
|
|
mr = rtt_readl(rtc, MR);
|
|
mr = rtt_readl(rtc, MR);
|
|
rtt_writel(rtc, MR, mr | rtc->imr);
|
|
rtt_writel(rtc, MR, mr | rtc->imr);
|
|
}
|
|
}
|