aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-sa1100.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-19 06:55:21 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-01-19 12:19:18 -0500
commita0164a574a3f284f438081c53fb864d275e54560 (patch)
tree7242b315b8a7ca31bf70764669b463028bde79d7 /drivers/rtc/rtc-sa1100.c
parenta55b5adaf403c4d032e0871ad4ee3367782f4db6 (diff)
Revert "RTC: sa1100: support sa1100, pxa and mmp soc families"
This reverts commit 7cea00657dd4daef66ad95e976d5d67ed94cb97e. The sa1100 cleanups fatally broke the SA1100 RTC driver - the first hint that something is wrong are these compiler warnings: drivers/rtc/rtc-sa1100.c:42:1: warning: "RCNR" redefined In file included from arch/arm/mach-sa1100/include/mach/hardware.h:73, from drivers/rtc/rtc-sa1100.c:35: arch/arm/mach-sa1100/include/mach/SA-1100.h:877:1: warning: this is the location of the previous definition drivers/rtc/rtc-sa1100.c:43:1: warning: "RTAR" redefined arch/arm/mach-sa1100/include/mach/SA-1100.h:876:1: warning: this is the location of the previous definition drivers/rtc/rtc-sa1100.c:44:1: warning: "RTSR" redefined arch/arm/mach-sa1100/include/mach/SA-1100.h:879:1: warning: this is the location of the previous definition drivers/rtc/rtc-sa1100.c:45:1: warning: "RTTR" redefined arch/arm/mach-sa1100/include/mach/SA-1100.h:878:1: warning: this is the location of the previous definition drivers/rtc/rtc-sa1100.c:47:1: warning: "RTSR_HZE" redefined arch/arm/mach-sa1100/include/mach/SA-1100.h:891:1: warning: this is the location of the previous definition drivers/rtc/rtc-sa1100.c:48:1: warning: "RTSR_ALE" redefined arch/arm/mach-sa1100/include/mach/SA-1100.h:890:1: warning: this is the location of the previous definition drivers/rtc/rtc-sa1100.c:49:1: warning: "RTSR_HZ" redefined arch/arm/mach-sa1100/include/mach/SA-1100.h:889:1: warning: this is the location of the previous definition drivers/rtc/rtc-sa1100.c:50:1: warning: "RTSR_AL" redefined arch/arm/mach-sa1100/include/mach/SA-1100.h:888:1: warning: this is the location of the previous definition and the second problem, which is far more severe, are the different register layouts, resulting in the wrong registers being read on SA11x0 platforms. This patch adds: #define RCNR 0x00 /* RTC Count Register */ #define RTAR 0x04 /* RTC Alarm Register */ #define RTSR 0x08 /* RTC Status Register */ #define RTTR 0x0c /* RTC Timer Trim Register */ but the SA11x0 registers are: #define RTAR __REG(0x90010000) /* RTC Alarm Reg. */ #define RCNR __REG(0x90010004) /* RTC CouNt Reg. */ #define RTTR __REG(0x90010008) /* RTC Trim Reg. */ #define RTSR __REG(0x90010010) /* RTC Status Reg. */
Diffstat (limited to 'drivers/rtc/rtc-sa1100.c')
-rw-r--r--drivers/rtc/rtc-sa1100.c256
1 files changed, 79 insertions, 177 deletions
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 4595d3e645a7..9683daf56d8e 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -27,42 +27,24 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/fs.h> 28#include <linux/fs.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/string.h>
30#include <linux/pm.h> 31#include <linux/pm.h>
31#include <linux/slab.h> 32#include <linux/bitops.h>
32#include <linux/clk.h>
33#include <linux/io.h>
34 33
35#include <mach/hardware.h> 34#include <mach/hardware.h>
36#include <asm/irq.h> 35#include <asm/irq.h>
37 36
37#ifdef CONFIG_ARCH_PXA
38#include <mach/regs-rtc.h>
39#endif
40
38#define RTC_DEF_DIVIDER (32768 - 1) 41#define RTC_DEF_DIVIDER (32768 - 1)
39#define RTC_DEF_TRIM 0 42#define RTC_DEF_TRIM 0
40#define RTC_FREQ 1024 43
41 44static const unsigned long RTC_FREQ = 1024;
42#define RCNR 0x00 /* RTC Count Register */ 45static struct rtc_time rtc_alarm;
43#define RTAR 0x04 /* RTC Alarm Register */ 46static DEFINE_SPINLOCK(sa1100_rtc_lock);
44#define RTSR 0x08 /* RTC Status Register */ 47
45#define RTTR 0x0c /* RTC Timer Trim Register */
46
47#define RTSR_HZE (1 << 3) /* HZ interrupt enable */
48#define RTSR_ALE (1 << 2) /* RTC alarm interrupt enable */
49#define RTSR_HZ (1 << 1) /* HZ rising-edge detected */
50#define RTSR_AL (1 << 0) /* RTC alarm detected */
51
52#define rtc_readl(sa1100_rtc, reg) \
53 readl_relaxed((sa1100_rtc)->base + (reg))
54#define rtc_writel(sa1100_rtc, reg, value) \
55 writel_relaxed((value), (sa1100_rtc)->base + (reg))
56
57struct sa1100_rtc {
58 struct resource *ress;
59 void __iomem *base;
60 struct clk *clk;
61 int irq_1Hz;
62 int irq_Alrm;
63 struct rtc_device *rtc;
64 spinlock_t lock; /* Protects this structure */
65};
66/* 48/*
67 * Calculate the next alarm time given the requested alarm time mask 49 * Calculate the next alarm time given the requested alarm time mask
68 * and the current time. 50 * and the current time.
@@ -93,23 +75,22 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
93static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) 75static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
94{ 76{
95 struct platform_device *pdev = to_platform_device(dev_id); 77 struct platform_device *pdev = to_platform_device(dev_id);
96 struct sa1100_rtc *sa1100_rtc = platform_get_drvdata(pdev); 78 struct rtc_device *rtc = platform_get_drvdata(pdev);
97 unsigned int rtsr; 79 unsigned int rtsr;
98 unsigned long events = 0; 80 unsigned long events = 0;
99 81
100 spin_lock(&sa1100_rtc->lock); 82 spin_lock(&sa1100_rtc_lock);
101 83
84 rtsr = RTSR;
102 /* clear interrupt sources */ 85 /* clear interrupt sources */
103 rtsr = rtc_readl(sa1100_rtc, RTSR); 86 RTSR = 0;
104 rtc_writel(sa1100_rtc, RTSR, 0);
105
106 /* Fix for a nasty initialization problem the in SA11xx RTSR register. 87 /* Fix for a nasty initialization problem the in SA11xx RTSR register.
107 * See also the comments in sa1100_rtc_probe(). */ 88 * See also the comments in sa1100_rtc_probe(). */
108 if (rtsr & (RTSR_ALE | RTSR_HZE)) { 89 if (rtsr & (RTSR_ALE | RTSR_HZE)) {
109 /* This is the original code, before there was the if test 90 /* This is the original code, before there was the if test
110 * above. This code does not clear interrupts that were not 91 * above. This code does not clear interrupts that were not
111 * enabled. */ 92 * enabled. */
112 rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ) & (rtsr >> 2)); 93 RTSR = (RTSR_AL | RTSR_HZ) & (rtsr >> 2);
113 } else { 94 } else {
114 /* For some reason, it is possible to enter this routine 95 /* For some reason, it is possible to enter this routine
115 * without interruptions enabled, it has been tested with 96 * without interruptions enabled, it has been tested with
@@ -118,13 +99,13 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
118 * This situation leads to an infinite "loop" of interrupt 99 * This situation leads to an infinite "loop" of interrupt
119 * routine calling and as a result the processor seems to 100 * routine calling and as a result the processor seems to
120 * lock on its first call to open(). */ 101 * lock on its first call to open(). */
121 rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ)); 102 RTSR = RTSR_AL | RTSR_HZ;
122 } 103 }
123 104
124 /* clear alarm interrupt if it has occurred */ 105 /* clear alarm interrupt if it has occurred */
125 if (rtsr & RTSR_AL) 106 if (rtsr & RTSR_AL)
126 rtsr &= ~RTSR_ALE; 107 rtsr &= ~RTSR_ALE;
127 rtc_writel(sa1100_rtc, RTSR, rtsr & (RTSR_ALE | RTSR_HZE)); 108 RTSR = rtsr & (RTSR_ALE | RTSR_HZE);
128 109
129 /* update irq data & counter */ 110 /* update irq data & counter */
130 if (rtsr & RTSR_AL) 111 if (rtsr & RTSR_AL)
@@ -132,100 +113,86 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
132 if (rtsr & RTSR_HZ) 113 if (rtsr & RTSR_HZ)
133 events |= RTC_UF | RTC_IRQF; 114 events |= RTC_UF | RTC_IRQF;
134 115
135 rtc_update_irq(sa1100_rtc->rtc, 1, events); 116 rtc_update_irq(rtc, 1, events);
136 117
137 spin_unlock(&sa1100_rtc->lock); 118 spin_unlock(&sa1100_rtc_lock);
138 119
139 return IRQ_HANDLED; 120 return IRQ_HANDLED;
140} 121}
141 122
142static int sa1100_rtc_open(struct device *dev) 123static int sa1100_rtc_open(struct device *dev)
143{ 124{
144 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
145 int ret; 125 int ret;
126 struct platform_device *plat_dev = to_platform_device(dev);
127 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
146 128
147 ret = request_irq(sa1100_rtc->irq_1Hz, sa1100_rtc_interrupt, 129 ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED,
148 IRQF_DISABLED, "rtc 1Hz", dev); 130 "rtc 1Hz", dev);
149 if (ret) { 131 if (ret) {
150 dev_err(dev, "IRQ %d already in use.\n", sa1100_rtc->irq_1Hz); 132 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz);
151 goto fail_ui; 133 goto fail_ui;
152 } 134 }
153 ret = request_irq(sa1100_rtc->irq_Alrm, sa1100_rtc_interrupt, 135 ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, IRQF_DISABLED,
154 IRQF_DISABLED, "rtc Alrm", dev); 136 "rtc Alrm", dev);
155 if (ret) { 137 if (ret) {
156 dev_err(dev, "IRQ %d already in use.\n", sa1100_rtc->irq_Alrm); 138 dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm);
157 goto fail_ai; 139 goto fail_ai;
158 } 140 }
159 sa1100_rtc->rtc->max_user_freq = RTC_FREQ; 141 rtc->max_user_freq = RTC_FREQ;
160 rtc_irq_set_freq(sa1100_rtc->rtc, NULL, RTC_FREQ); 142 rtc_irq_set_freq(rtc, NULL, RTC_FREQ);
161 143
162 return 0; 144 return 0;
163 145
164 fail_ai: 146 fail_ai:
165 free_irq(sa1100_rtc->irq_1Hz, dev); 147 free_irq(IRQ_RTC1Hz, dev);
166 fail_ui: 148 fail_ui:
167 return ret; 149 return ret;
168} 150}
169 151
170static void sa1100_rtc_release(struct device *dev) 152static void sa1100_rtc_release(struct device *dev)
171{ 153{
172 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 154 spin_lock_irq(&sa1100_rtc_lock);
155 RTSR = 0;
156 spin_unlock_irq(&sa1100_rtc_lock);
173 157
174 spin_lock_irq(&sa1100_rtc->lock); 158 free_irq(IRQ_RTCAlrm, dev);
175 rtc_writel(sa1100_rtc, RTSR, 0); 159 free_irq(IRQ_RTC1Hz, dev);
176 spin_unlock_irq(&sa1100_rtc->lock);
177
178 free_irq(sa1100_rtc->irq_Alrm, dev);
179 free_irq(sa1100_rtc->irq_1Hz, dev);
180} 160}
181 161
182static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) 162static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
183{ 163{
184 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 164 spin_lock_irq(&sa1100_rtc_lock);
185 unsigned int rtsr;
186
187 spin_lock_irq(&sa1100_rtc->lock);
188
189 rtsr = rtc_readl(sa1100_rtc, RTSR);
190 if (enabled) 165 if (enabled)
191 rtsr |= RTSR_ALE; 166 RTSR |= RTSR_ALE;
192 else 167 else
193 rtsr &= ~RTSR_ALE; 168 RTSR &= ~RTSR_ALE;
194 rtc_writel(sa1100_rtc, RTSR, rtsr); 169 spin_unlock_irq(&sa1100_rtc_lock);
195
196 spin_unlock_irq(&sa1100_rtc->lock);
197 return 0; 170 return 0;
198} 171}
199 172
200static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) 173static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
201{ 174{
202 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 175 rtc_time_to_tm(RCNR, tm);
203
204 rtc_time_to_tm(rtc_readl(sa1100_rtc, RCNR), tm);
205 return 0; 176 return 0;
206} 177}
207 178
208static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) 179static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
209{ 180{
210 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
211 unsigned long time; 181 unsigned long time;
212 int ret; 182 int ret;
213 183
214 ret = rtc_tm_to_time(tm, &time); 184 ret = rtc_tm_to_time(tm, &time);
215 if (ret == 0) 185 if (ret == 0)
216 rtc_writel(sa1100_rtc, RCNR, time); 186 RCNR = time;
217 return ret; 187 return ret;
218} 188}
219 189
220static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 190static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
221{ 191{
222 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 192 u32 rtsr;
223 unsigned long time;
224 unsigned int rtsr;
225 193
226 time = rtc_readl(sa1100_rtc, RCNR); 194 memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time));
227 rtc_time_to_tm(time, &alrm->time); 195 rtsr = RTSR;
228 rtsr = rtc_readl(sa1100_rtc, RTSR);
229 alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; 196 alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0;
230 alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; 197 alrm->pending = (rtsr & RTSR_AL) ? 1 : 0;
231 return 0; 198 return 0;
@@ -233,39 +200,31 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
233 200
234static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 201static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
235{ 202{
236 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
237 struct rtc_time now_tm, alarm_tm; 203 struct rtc_time now_tm, alarm_tm;
238 unsigned long time, alarm; 204 int ret;
239 unsigned int rtsr;
240
241 spin_lock_irq(&sa1100_rtc->lock);
242 205
243 time = rtc_readl(sa1100_rtc, RCNR); 206 spin_lock_irq(&sa1100_rtc_lock);
244 rtc_time_to_tm(time, &now_tm);
245 rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
246 rtc_tm_to_time(&alarm_tm, &alarm);
247 rtc_writel(sa1100_rtc, RTAR, alarm);
248 207
249 rtsr = rtc_readl(sa1100_rtc, RTSR); 208 now = RCNR;
209 rtc_time_to_tm(now, &now_tm);
210 rtc_next_alarm_time(&alarm_tm, &now_tm, alrm->time);
211 rtc_tm_to_time(&alarm_tm, &time);
212 RTAR = time;
250 if (alrm->enabled) 213 if (alrm->enabled)
251 rtsr |= RTSR_ALE; 214 RTSR |= RTSR_ALE;
252 else 215 else
253 rtsr &= ~RTSR_ALE; 216 RTSR &= ~RTSR_ALE;
254 rtc_writel(sa1100_rtc, RTSR, rtsr);
255 217
256 spin_unlock_irq(&sa1100_rtc->lock); 218 spin_unlock_irq(&sa1100_rtc_lock);
257 219
258 return 0; 220 return ret;
259} 221}
260 222
261static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) 223static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
262{ 224{
263 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev); 225 seq_printf(seq, "trim/divider\t\t: 0x%08x\n", (u32) RTTR);
226 seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", (u32)RTSR);
264 227
265 seq_printf(seq, "trim/divider\t\t: 0x%08x\n",
266 rtc_readl(sa1100_rtc, RTTR));
267 seq_printf(seq, "RTSR\t\t\t: 0x%08x\n",
268 rtc_readl(sa1100_rtc, RTSR));
269 return 0; 228 return 0;
270} 229}
271 230
@@ -282,51 +241,7 @@ static const struct rtc_class_ops sa1100_rtc_ops = {
282 241
283static int sa1100_rtc_probe(struct platform_device *pdev) 242static int sa1100_rtc_probe(struct platform_device *pdev)
284{ 243{
285 struct sa1100_rtc *sa1100_rtc; 244 struct rtc_device *rtc;
286 unsigned int rttr;
287 int ret;
288
289 sa1100_rtc = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL);
290 if (!sa1100_rtc)
291 return -ENOMEM;
292
293 spin_lock_init(&sa1100_rtc->lock);
294 platform_set_drvdata(pdev, sa1100_rtc);
295
296 ret = -ENXIO;
297 sa1100_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
298 if (!sa1100_rtc->ress) {
299 dev_err(&pdev->dev, "No I/O memory resource defined\n");
300 goto err_ress;
301 }
302
303 sa1100_rtc->irq_1Hz = platform_get_irq(pdev, 0);
304 if (sa1100_rtc->irq_1Hz < 0) {
305 dev_err(&pdev->dev, "No 1Hz IRQ resource defined\n");
306 goto err_ress;
307 }
308 sa1100_rtc->irq_Alrm = platform_get_irq(pdev, 1);
309 if (sa1100_rtc->irq_Alrm < 0) {
310 dev_err(&pdev->dev, "No alarm IRQ resource defined\n");
311 goto err_ress;
312 }
313
314 ret = -ENOMEM;
315 sa1100_rtc->base = ioremap(sa1100_rtc->ress->start,
316 resource_size(sa1100_rtc->ress));
317 if (!sa1100_rtc->base) {
318 dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n");
319 goto err_map;
320 }
321
322 sa1100_rtc->clk = clk_get(&pdev->dev, NULL);
323 if (IS_ERR(sa1100_rtc->clk)) {
324 dev_err(&pdev->dev, "failed to find rtc clock source\n");
325 ret = PTR_ERR(sa1100_rtc->clk);
326 goto err_clk;
327 }
328 clk_prepare(sa1100_rtc->clk);
329 clk_enable(sa1100_rtc->clk);
330 245
331 /* 246 /*
332 * According to the manual we should be able to let RTTR be zero 247 * According to the manual we should be able to let RTTR be zero
@@ -335,24 +250,24 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
335 * If the clock divider is uninitialized then reset it to the 250 * If the clock divider is uninitialized then reset it to the
336 * default value to get the 1Hz clock. 251 * default value to get the 1Hz clock.
337 */ 252 */
338 if (rtc_readl(sa1100_rtc, RTTR) == 0) { 253 if (RTTR == 0) {
339 rttr = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); 254 RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
340 rtc_writel(sa1100_rtc, RTTR, rttr); 255 dev_warn(&pdev->dev, "warning: "
341 dev_warn(&pdev->dev, "warning: initializing default clock" 256 "initializing default clock divider/trim value\n");
342 " divider/trim value\n");
343 /* The current RTC value probably doesn't make sense either */ 257 /* The current RTC value probably doesn't make sense either */
344 rtc_writel(sa1100_rtc, RCNR, 0); 258 RCNR = 0;
345 } 259 }
346 260
347 device_init_wakeup(&pdev->dev, 1); 261 device_init_wakeup(&pdev->dev, 1);
348 262
349 sa1100_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, 263 rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops,
350 &sa1100_rtc_ops, THIS_MODULE); 264 THIS_MODULE);
351 if (IS_ERR(sa1100_rtc->rtc)) { 265
352 dev_err(&pdev->dev, "Failed to register RTC device -> %d\n", 266 if (IS_ERR(rtc))
353 ret); 267 return PTR_ERR(rtc);
354 goto err_rtc_reg; 268
355 } 269 platform_set_drvdata(pdev, rtc);
270
356 /* Fix for a nasty initialization problem the in SA11xx RTSR register. 271 /* Fix for a nasty initialization problem the in SA11xx RTSR register.
357 * See also the comments in sa1100_rtc_interrupt(). 272 * See also the comments in sa1100_rtc_interrupt().
358 * 273 *
@@ -375,46 +290,33 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
375 * 290 *
376 * Notice that clearing bit 1 and 0 is accomplished by writting ONES to 291 * Notice that clearing bit 1 and 0 is accomplished by writting ONES to
377 * the corresponding bits in RTSR. */ 292 * the corresponding bits in RTSR. */
378 rtc_writel(sa1100_rtc, RTSR, (RTSR_AL | RTSR_HZ)); 293 RTSR = RTSR_AL | RTSR_HZ;
379 294
380 return 0; 295 return 0;
381
382err_rtc_reg:
383err_clk:
384 iounmap(sa1100_rtc->base);
385err_ress:
386err_map:
387 kfree(sa1100_rtc);
388 return ret;
389} 296}
390 297
391static int sa1100_rtc_remove(struct platform_device *pdev) 298static int sa1100_rtc_remove(struct platform_device *pdev)
392{ 299{
393 struct sa1100_rtc *sa1100_rtc = platform_get_drvdata(pdev); 300 struct rtc_device *rtc = platform_get_drvdata(pdev);
301
302 if (rtc)
303 rtc_device_unregister(rtc);
394 304
395 rtc_device_unregister(sa1100_rtc->rtc);
396 clk_disable(sa1100_rtc->clk);
397 clk_unprepare(sa1100_rtc->clk);
398 iounmap(sa1100_rtc->base);
399 return 0; 305 return 0;
400} 306}
401 307
402#ifdef CONFIG_PM 308#ifdef CONFIG_PM
403static int sa1100_rtc_suspend(struct device *dev) 309static int sa1100_rtc_suspend(struct device *dev)
404{ 310{
405 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
406
407 if (device_may_wakeup(dev)) 311 if (device_may_wakeup(dev))
408 enable_irq_wake(sa1100_rtc->irq_Alrm); 312 enable_irq_wake(IRQ_RTCAlrm);
409 return 0; 313 return 0;
410} 314}
411 315
412static int sa1100_rtc_resume(struct device *dev) 316static int sa1100_rtc_resume(struct device *dev)
413{ 317{
414 struct sa1100_rtc *sa1100_rtc = dev_get_drvdata(dev);
415
416 if (device_may_wakeup(dev)) 318 if (device_may_wakeup(dev))
417 disable_irq_wake(sa1100_rtc->irq_Alrm); 319 disable_irq_wake(IRQ_RTCAlrm);
418 return 0; 320 return 0;
419} 321}
420 322