Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Real Time Clock interface for StrongARM SA1x00 and XScale PXA2xx |
| 3 | * |
| 4 | * Copyright (c) 2000 Nils Faerber |
| 5 | * |
| 6 | * Based on rtc.c by Paul Gortmaker |
| 7 | * |
| 8 | * Original Driver by Nils Faerber <nils@kernelconcepts.de> |
| 9 | * |
| 10 | * Modifications from: |
| 11 | * CIH <cih@coventive.com> |
Nicolas Pitre | 2f82af0 | 2009-09-14 03:25:28 -0400 | [diff] [blame] | 12 | * Nicolas Pitre <nico@fluxnic.net> |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 13 | * Andrew Christian <andrew.christian@hp.com> |
| 14 | * |
| 15 | * Converted to the RTC subsystem and Driver Model |
| 16 | * by Richard Purdie <rpurdie@rpsys.net> |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or |
| 19 | * modify it under the terms of the GNU General Public License |
| 20 | * as published by the Free Software Foundation; either version |
| 21 | * 2 of the License, or (at your option) any later version. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/rtc.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/fs.h> |
| 29 | #include <linux/interrupt.h> |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 30 | #include <linux/string.h> |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 31 | #include <linux/pm.h> |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 32 | #include <linux/bitops.h> |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 33 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/hardware.h> |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 35 | #include <asm/irq.h> |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 36 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 37 | #ifdef CONFIG_ARCH_PXA |
| 38 | #include <mach/regs-rtc.h> |
| 39 | #endif |
| 40 | |
Marcelo Roberto Jimenez | a404ad1 | 2010-10-18 22:33:53 +0100 | [diff] [blame] | 41 | #define RTC_DEF_DIVIDER (32768 - 1) |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 42 | #define RTC_DEF_TRIM 0 |
| 43 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 44 | static const unsigned long RTC_FREQ = 1024; |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 45 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 46 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 47 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 48 | { |
| 49 | struct platform_device *pdev = to_platform_device(dev_id); |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 50 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 51 | unsigned int rtsr; |
| 52 | unsigned long events = 0; |
| 53 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 54 | spin_lock(&sa1100_rtc_lock); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 55 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 56 | rtsr = RTSR; |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 57 | /* clear interrupt sources */ |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 58 | RTSR = 0; |
Marcelo Roberto Jimenez | 7decaa5 | 2010-10-18 22:35:54 +0100 | [diff] [blame] | 59 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
| 60 | * See also the comments in sa1100_rtc_probe(). */ |
| 61 | if (rtsr & (RTSR_ALE | RTSR_HZE)) { |
| 62 | /* This is the original code, before there was the if test |
| 63 | * above. This code does not clear interrupts that were not |
| 64 | * enabled. */ |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 65 | RTSR = (RTSR_AL | RTSR_HZ) & (rtsr >> 2); |
Marcelo Roberto Jimenez | 7decaa5 | 2010-10-18 22:35:54 +0100 | [diff] [blame] | 66 | } else { |
| 67 | /* For some reason, it is possible to enter this routine |
| 68 | * without interruptions enabled, it has been tested with |
| 69 | * several units (Bug in SA11xx chip?). |
| 70 | * |
| 71 | * This situation leads to an infinite "loop" of interrupt |
| 72 | * routine calling and as a result the processor seems to |
| 73 | * lock on its first call to open(). */ |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 74 | RTSR = RTSR_AL | RTSR_HZ; |
Marcelo Roberto Jimenez | 7decaa5 | 2010-10-18 22:35:54 +0100 | [diff] [blame] | 75 | } |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 76 | |
| 77 | /* clear alarm interrupt if it has occurred */ |
| 78 | if (rtsr & RTSR_AL) |
| 79 | rtsr &= ~RTSR_ALE; |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 80 | RTSR = rtsr & (RTSR_ALE | RTSR_HZE); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 81 | |
| 82 | /* update irq data & counter */ |
| 83 | if (rtsr & RTSR_AL) |
| 84 | events |= RTC_AF | RTC_IRQF; |
| 85 | if (rtsr & RTSR_HZ) |
| 86 | events |= RTC_UF | RTC_IRQF; |
| 87 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 88 | rtc_update_irq(rtc, 1, events); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 89 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 90 | spin_unlock(&sa1100_rtc_lock); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 91 | |
| 92 | return IRQ_HANDLED; |
| 93 | } |
| 94 | |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 95 | static int sa1100_rtc_open(struct device *dev) |
| 96 | { |
| 97 | int ret; |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 98 | struct platform_device *plat_dev = to_platform_device(dev); |
| 99 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 100 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 101 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED, |
| 102 | "rtc 1Hz", dev); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 103 | if (ret) { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 104 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 105 | goto fail_ui; |
| 106 | } |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 107 | ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, IRQF_DISABLED, |
| 108 | "rtc Alrm", dev); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 109 | if (ret) { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 110 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 111 | goto fail_ai; |
| 112 | } |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 113 | rtc->max_user_freq = RTC_FREQ; |
| 114 | rtc_irq_set_freq(rtc, NULL, RTC_FREQ); |
Marcelo Roberto Jimenez | d2ccb52 | 2010-12-16 21:31:32 +0100 | [diff] [blame] | 115 | |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 116 | return 0; |
| 117 | |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 118 | fail_ai: |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 119 | free_irq(IRQ_RTC1Hz, dev); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 120 | fail_ui: |
| 121 | return ret; |
| 122 | } |
| 123 | |
| 124 | static void sa1100_rtc_release(struct device *dev) |
| 125 | { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 126 | spin_lock_irq(&sa1100_rtc_lock); |
| 127 | RTSR = 0; |
| 128 | spin_unlock_irq(&sa1100_rtc_lock); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 129 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 130 | free_irq(IRQ_RTCAlrm, dev); |
| 131 | free_irq(IRQ_RTC1Hz, dev); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 132 | } |
| 133 | |
John Stultz | 16380c1 | 2011-02-02 17:02:41 -0800 | [diff] [blame] | 134 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
| 135 | { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 136 | spin_lock_irq(&sa1100_rtc_lock); |
John Stultz | 16380c1 | 2011-02-02 17:02:41 -0800 | [diff] [blame] | 137 | if (enabled) |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 138 | RTSR |= RTSR_ALE; |
John Stultz | 16380c1 | 2011-02-02 17:02:41 -0800 | [diff] [blame] | 139 | else |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 140 | RTSR &= ~RTSR_ALE; |
| 141 | spin_unlock_irq(&sa1100_rtc_lock); |
John Stultz | 16380c1 | 2011-02-02 17:02:41 -0800 | [diff] [blame] | 142 | return 0; |
| 143 | } |
| 144 | |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 145 | static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) |
| 146 | { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 147 | rtc_time_to_tm(RCNR, tm); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) |
| 152 | { |
| 153 | unsigned long time; |
| 154 | int ret; |
| 155 | |
| 156 | ret = rtc_tm_to_time(tm, &time); |
| 157 | if (ret == 0) |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 158 | RCNR = time; |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 159 | return ret; |
| 160 | } |
| 161 | |
| 162 | static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
| 163 | { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 164 | u32 rtsr; |
David Brownell | 32b49da | 2007-02-20 13:58:13 -0800 | [diff] [blame] | 165 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 166 | rtsr = RTSR; |
David Brownell | 32b49da | 2007-02-20 13:58:13 -0800 | [diff] [blame] | 167 | alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; |
| 168 | alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
| 173 | { |
Haojian Zhuang | 1d8c38c | 2012-02-20 19:49:30 +0800 | [diff] [blame^] | 174 | unsigned long time; |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 175 | int ret; |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 176 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 177 | spin_lock_irq(&sa1100_rtc_lock); |
Haojian Zhuang | 1d8c38c | 2012-02-20 19:49:30 +0800 | [diff] [blame^] | 178 | ret = rtc_tm_to_time(&alrm->time, &time); |
| 179 | if (ret != 0) |
| 180 | goto out; |
| 181 | RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL); |
| 182 | RTAR = time; |
| 183 | if (alrm->enabled) |
| 184 | RTSR |= RTSR_ALE; |
| 185 | else |
| 186 | RTSR &= ~RTSR_ALE; |
| 187 | out: |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 188 | spin_unlock_irq(&sa1100_rtc_lock); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 189 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 190 | return ret; |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) |
| 194 | { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 195 | seq_printf(seq, "trim/divider\t\t: 0x%08x\n", (u32) RTTR); |
| 196 | seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", (u32)RTSR); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 197 | |
| 198 | return 0; |
| 199 | } |
| 200 | |
David Brownell | ff8371a | 2006-09-30 23:28:17 -0700 | [diff] [blame] | 201 | static const struct rtc_class_ops sa1100_rtc_ops = { |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 202 | .open = sa1100_rtc_open, |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 203 | .release = sa1100_rtc_release, |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 204 | .read_time = sa1100_rtc_read_time, |
| 205 | .set_time = sa1100_rtc_set_time, |
| 206 | .read_alarm = sa1100_rtc_read_alarm, |
| 207 | .set_alarm = sa1100_rtc_set_alarm, |
| 208 | .proc = sa1100_rtc_proc, |
John Stultz | 16380c1 | 2011-02-02 17:02:41 -0800 | [diff] [blame] | 209 | .alarm_irq_enable = sa1100_rtc_alarm_irq_enable, |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | static int sa1100_rtc_probe(struct platform_device *pdev) |
| 213 | { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 214 | struct rtc_device *rtc; |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 215 | |
| 216 | /* |
| 217 | * According to the manual we should be able to let RTTR be zero |
| 218 | * and then a default diviser for a 32.768KHz clock is used. |
| 219 | * Apparently this doesn't work, at least for my SA1110 rev 5. |
| 220 | * If the clock divider is uninitialized then reset it to the |
| 221 | * default value to get the 1Hz clock. |
| 222 | */ |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 223 | if (RTTR == 0) { |
| 224 | RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); |
| 225 | dev_warn(&pdev->dev, "warning: " |
| 226 | "initializing default clock divider/trim value\n"); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 227 | /* The current RTC value probably doesn't make sense either */ |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 228 | RCNR = 0; |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 229 | } |
| 230 | |
Uli Luckas | e5a2c9c | 2008-06-18 09:54:03 +0100 | [diff] [blame] | 231 | device_init_wakeup(&pdev->dev, 1); |
| 232 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 233 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, |
| 234 | THIS_MODULE); |
| 235 | |
| 236 | if (IS_ERR(rtc)) |
| 237 | return PTR_ERR(rtc); |
| 238 | |
| 239 | platform_set_drvdata(pdev, rtc); |
| 240 | |
Marcelo Roberto Jimenez | 7decaa5 | 2010-10-18 22:35:54 +0100 | [diff] [blame] | 241 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
| 242 | * See also the comments in sa1100_rtc_interrupt(). |
| 243 | * |
| 244 | * Sometimes bit 1 of the RTSR (RTSR_HZ) will wake up 1, which means an |
| 245 | * interrupt pending, even though interrupts were never enabled. |
| 246 | * In this case, this bit it must be reset before enabling |
| 247 | * interruptions to avoid a nonexistent interrupt to occur. |
| 248 | * |
| 249 | * In principle, the same problem would apply to bit 0, although it has |
| 250 | * never been observed to happen. |
| 251 | * |
| 252 | * This issue is addressed both here and in sa1100_rtc_interrupt(). |
| 253 | * If the issue is not addressed here, in the times when the processor |
| 254 | * wakes up with the bit set there will be one spurious interrupt. |
| 255 | * |
| 256 | * The issue is also dealt with in sa1100_rtc_interrupt() to be on the |
| 257 | * safe side, once the condition that lead to this strange |
| 258 | * initialization is unknown and could in principle happen during |
| 259 | * normal processing. |
| 260 | * |
| 261 | * Notice that clearing bit 1 and 0 is accomplished by writting ONES to |
| 262 | * the corresponding bits in RTSR. */ |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 263 | RTSR = RTSR_AL | RTSR_HZ; |
Marcelo Roberto Jimenez | 7decaa5 | 2010-10-18 22:35:54 +0100 | [diff] [blame] | 264 | |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | static int sa1100_rtc_remove(struct platform_device *pdev) |
| 269 | { |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 270 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 271 | |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 272 | if (rtc) |
| 273 | rtc_device_unregister(rtc); |
| 274 | |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 275 | return 0; |
| 276 | } |
| 277 | |
Russell King | 6bc54e6 | 2007-11-12 22:49:58 +0000 | [diff] [blame] | 278 | #ifdef CONFIG_PM |
Haojian Zhuang | 5d027cd | 2009-07-21 14:31:09 +0800 | [diff] [blame] | 279 | static int sa1100_rtc_suspend(struct device *dev) |
Russell King | 6bc54e6 | 2007-11-12 22:49:58 +0000 | [diff] [blame] | 280 | { |
Haojian Zhuang | 5d027cd | 2009-07-21 14:31:09 +0800 | [diff] [blame] | 281 | if (device_may_wakeup(dev)) |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 282 | enable_irq_wake(IRQ_RTCAlrm); |
Russell King | 6bc54e6 | 2007-11-12 22:49:58 +0000 | [diff] [blame] | 283 | return 0; |
| 284 | } |
| 285 | |
Haojian Zhuang | 5d027cd | 2009-07-21 14:31:09 +0800 | [diff] [blame] | 286 | static int sa1100_rtc_resume(struct device *dev) |
Russell King | 6bc54e6 | 2007-11-12 22:49:58 +0000 | [diff] [blame] | 287 | { |
Haojian Zhuang | 5d027cd | 2009-07-21 14:31:09 +0800 | [diff] [blame] | 288 | if (device_may_wakeup(dev)) |
Russell King | a0164a5 | 2012-01-19 11:55:21 +0000 | [diff] [blame] | 289 | disable_irq_wake(IRQ_RTCAlrm); |
Russell King | 6bc54e6 | 2007-11-12 22:49:58 +0000 | [diff] [blame] | 290 | return 0; |
| 291 | } |
Haojian Zhuang | 5d027cd | 2009-07-21 14:31:09 +0800 | [diff] [blame] | 292 | |
Alexey Dobriyan | 4714521 | 2009-12-14 18:00:08 -0800 | [diff] [blame] | 293 | static const struct dev_pm_ops sa1100_rtc_pm_ops = { |
Haojian Zhuang | 5d027cd | 2009-07-21 14:31:09 +0800 | [diff] [blame] | 294 | .suspend = sa1100_rtc_suspend, |
| 295 | .resume = sa1100_rtc_resume, |
| 296 | }; |
Russell King | 6bc54e6 | 2007-11-12 22:49:58 +0000 | [diff] [blame] | 297 | #endif |
| 298 | |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 299 | static struct platform_driver sa1100_rtc_driver = { |
| 300 | .probe = sa1100_rtc_probe, |
| 301 | .remove = sa1100_rtc_remove, |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 302 | .driver = { |
Haojian Zhuang | 5d027cd | 2009-07-21 14:31:09 +0800 | [diff] [blame] | 303 | .name = "sa1100-rtc", |
| 304 | #ifdef CONFIG_PM |
| 305 | .pm = &sa1100_rtc_pm_ops, |
| 306 | #endif |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 307 | }, |
| 308 | }; |
| 309 | |
Axel Lin | 0c4eae6 | 2012-01-10 15:10:48 -0800 | [diff] [blame] | 310 | module_platform_driver(sa1100_rtc_driver); |
Richard Purdie | e842f1c | 2006-03-27 01:16:46 -0800 | [diff] [blame] | 311 | |
| 312 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); |
| 313 | MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)"); |
| 314 | MODULE_LICENSE("GPL"); |
Kay Sievers | ad28a07 | 2008-04-10 21:29:25 -0700 | [diff] [blame] | 315 | MODULE_ALIAS("platform:sa1100-rtc"); |