aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-at91.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-06-25 08:48:27 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:14 -0400
commite7a8bb12c24af8e3e4bdf18a7484699acc9dbedb (patch)
treeb0e942d912bdb2755991bd675c5263c288ed8699 /drivers/rtc/rtc-at91.c
parent788b1fc619a31ebdbadd3a8863631f59a4bd2944 (diff)
[PATCH] at91rm9200-rtc-driver-tidy
- whitespace fixes (80-col display) - one unneeded cast of void* Cc: Andrew Victor <andrew@sanpeople.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/rtc/rtc-at91.c')
-rw-r--r--drivers/rtc/rtc-at91.c79
1 files changed, 49 insertions, 30 deletions
diff --git a/drivers/rtc/rtc-at91.c b/drivers/rtc/rtc-at91.c
index b03aba5f39eb..b676f443c17e 100644
--- a/drivers/rtc/rtc-at91.c
+++ b/drivers/rtc/rtc-at91.c
@@ -40,11 +40,11 @@
40static DECLARE_COMPLETION(at91_rtc_updated); 40static DECLARE_COMPLETION(at91_rtc_updated);
41static unsigned int at91_alarm_year = AT91_RTC_EPOCH; 41static unsigned int at91_alarm_year = AT91_RTC_EPOCH;
42 42
43
44/* 43/*
45 * Decode time/date into rtc_time structure 44 * Decode time/date into rtc_time structure
46 */ 45 */
47static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg, struct rtc_time *tm) 46static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
47 struct rtc_time *tm)
48{ 48{
49 unsigned int time, date; 49 unsigned int time, date;
50 50
@@ -52,7 +52,8 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg, struc
52 do { 52 do {
53 time = at91_sys_read(timereg); 53 time = at91_sys_read(timereg);
54 date = at91_sys_read(calreg); 54 date = at91_sys_read(calreg);
55 } while ((time != at91_sys_read(timereg)) || (date != at91_sys_read(calreg))); 55 } while ((time != at91_sys_read(timereg)) ||
56 (date != at91_sys_read(calreg)));
56 57
57 tm->tm_sec = BCD2BIN((time & AT91_RTC_SEC) >> 0); 58 tm->tm_sec = BCD2BIN((time & AT91_RTC_SEC) >> 0);
58 tm->tm_min = BCD2BIN((time & AT91_RTC_MIN) >> 8); 59 tm->tm_min = BCD2BIN((time & AT91_RTC_MIN) >> 8);
@@ -63,8 +64,8 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg, struc
63 * the year - so these will return an invalid value. When an 64 * the year - so these will return an invalid value. When an
64 * alarm is set, at91_alarm_year wille store the current year. 65 * alarm is set, at91_alarm_year wille store the current year.
65 */ 66 */
66 tm->tm_year = BCD2BIN(date & AT91_RTC_CENT) * 100; /* century */ 67 tm->tm_year = BCD2BIN(date & AT91_RTC_CENT) * 100; /* century */
67 tm->tm_year += BCD2BIN((date & AT91_RTC_YEAR) >> 8); /* year */ 68 tm->tm_year += BCD2BIN((date & AT91_RTC_YEAR) >> 8); /* year */
68 69
69 tm->tm_wday = BCD2BIN((date & AT91_RTC_DAY) >> 21) - 1; /* day of the week [0-6], Sunday=0 */ 70 tm->tm_wday = BCD2BIN((date & AT91_RTC_DAY) >> 21) - 1; /* day of the week [0-6], Sunday=0 */
70 tm->tm_mon = BCD2BIN((date & AT91_RTC_MONTH) >> 16) - 1; 71 tm->tm_mon = BCD2BIN((date & AT91_RTC_MONTH) >> 16) - 1;
@@ -81,7 +82,8 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
81 tm->tm_year = tm->tm_year - 1900; 82 tm->tm_year = tm->tm_year - 1900;
82 83
83 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 84 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
84 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); 85 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
86 tm->tm_hour, tm->tm_min, tm->tm_sec);
85 87
86 return 0; 88 return 0;
87} 89}
@@ -94,14 +96,15 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
94 unsigned long cr; 96 unsigned long cr;
95 97
96 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 98 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
97 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); 99 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
100 tm->tm_hour, tm->tm_min, tm->tm_sec);
98 101
99 /* Stop Time/Calendar from counting */ 102 /* Stop Time/Calendar from counting */
100 cr = at91_sys_read(AT91_RTC_CR); 103 cr = at91_sys_read(AT91_RTC_CR);
101 at91_sys_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM); 104 at91_sys_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM);
102 105
103 at91_sys_write(AT91_RTC_IER, AT91_RTC_ACKUPD); 106 at91_sys_write(AT91_RTC_IER, AT91_RTC_ACKUPD);
104 wait_for_completion(&at91_rtc_updated); /* wait for ACKUPD interrupt */ 107 wait_for_completion(&at91_rtc_updated); /* wait for ACKUPD interrupt */
105 at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD); 108 at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD);
106 109
107 at91_sys_write(AT91_RTC_TIMR, 110 at91_sys_write(AT91_RTC_TIMR,
@@ -110,10 +113,10 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
110 | BIN2BCD(tm->tm_hour) << 16); 113 | BIN2BCD(tm->tm_hour) << 16);
111 114
112 at91_sys_write(AT91_RTC_CALR, 115 at91_sys_write(AT91_RTC_CALR,
113 BIN2BCD((tm->tm_year + 1900) / 100) /* century */ 116 BIN2BCD((tm->tm_year + 1900) / 100) /* century */
114 | BIN2BCD(tm->tm_year % 100) << 8 /* year */ 117 | BIN2BCD(tm->tm_year % 100) << 8 /* year */
115 | BIN2BCD(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */ 118 | BIN2BCD(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */
116 | BIN2BCD(tm->tm_wday + 1) << 21 /* day of the week [0-6], Sunday=0 */ 119 | BIN2BCD(tm->tm_wday + 1) << 21 /* day of the week [0-6], Sunday=0 */
117 | BIN2BCD(tm->tm_mday) << 24); 120 | BIN2BCD(tm->tm_mday) << 24);
118 121
119 /* Restart Time/Calendar */ 122 /* Restart Time/Calendar */
@@ -135,7 +138,8 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
135 tm->tm_year = at91_alarm_year - 1900; 138 tm->tm_year = at91_alarm_year - 1900;
136 139
137 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 140 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
138 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); 141 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
142 tm->tm_hour, tm->tm_min, tm->tm_sec);
139 143
140 return 0; 144 return 0;
141} 145}
@@ -166,7 +170,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
166 | AT91_RTC_DATEEN | AT91_RTC_MTHEN); 170 | AT91_RTC_DATEEN | AT91_RTC_MTHEN);
167 171
168 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 172 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
169 at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); 173 at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
174 tm.tm_min, tm.tm_sec);
170 175
171 return 0; 176 return 0;
172} 177}
@@ -174,7 +179,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
174/* 179/*
175 * Handle commands from user-space 180 * Handle commands from user-space
176 */ 181 */
177static int at91_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 182static int at91_rtc_ioctl(struct device *dev, unsigned int cmd,
183 unsigned long arg)
178{ 184{
179 int ret = 0; 185 int ret = 0;
180 186
@@ -217,10 +223,14 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
217{ 223{
218 unsigned long imr = at91_sys_read(AT91_RTC_IMR); 224 unsigned long imr = at91_sys_read(AT91_RTC_IMR);
219 225
220 seq_printf(seq, "alarm_IRQ\t: %s\n", (imr & AT91_RTC_ALARM) ? "yes" : "no"); 226 seq_printf(seq, "alarm_IRQ\t: %s\n",
221 seq_printf(seq, "update_IRQ\t: %s\n", (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); 227 (imr & AT91_RTC_ALARM) ? "yes" : "no");
222 seq_printf(seq, "periodic_IRQ\t: %s\n", (imr & AT91_RTC_SECEV) ? "yes" : "no"); 228 seq_printf(seq, "update_IRQ\t: %s\n",
223 seq_printf(seq, "periodic_freq\t: %ld\n", (unsigned long) AT91_RTC_FREQ); 229 (imr & AT91_RTC_ACKUPD) ? "yes" : "no");
230 seq_printf(seq, "periodic_IRQ\t: %s\n",
231 (imr & AT91_RTC_SECEV) ? "yes" : "no");
232 seq_printf(seq, "periodic_freq\t: %ld\n",
233 (unsigned long) AT91_RTC_FREQ);
224 234
225 return 0; 235 return 0;
226} 236}
@@ -228,9 +238,10 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
228/* 238/*
229 * IRQ handler for the RTC 239 * IRQ handler for the RTC
230 */ 240 */
231static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs) 241static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id,
242 struct pt_regs *regs)
232{ 243{
233 struct platform_device *pdev = (struct platform_device *)dev_id; 244 struct platform_device *pdev = dev_id;
234 struct rtc_device *rtc = platform_get_drvdata(pdev); 245 struct rtc_device *rtc = platform_get_drvdata(pdev);
235 unsigned int rtsr; 246 unsigned int rtsr;
236 unsigned long events = 0; 247 unsigned long events = 0;
@@ -244,7 +255,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id, struct pt_regs *reg
244 if (rtsr & AT91_RTC_ACKUPD) 255 if (rtsr & AT91_RTC_ACKUPD)
245 complete(&at91_rtc_updated); 256 complete(&at91_rtc_updated);
246 257
247 at91_sys_write(AT91_RTC_SCCR, rtsr); /* clear status reg */ 258 at91_sys_write(AT91_RTC_SCCR, rtsr); /* clear status reg */
248 259
249 rtc_update_irq(&rtc->class_dev, 1, events); 260 rtc_update_irq(&rtc->class_dev, 1, events);
250 261
@@ -277,15 +288,20 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
277 at91_sys_write(AT91_RTC_MR, 0); /* 24 hour mode */ 288 at91_sys_write(AT91_RTC_MR, 0); /* 24 hour mode */
278 289
279 /* Disable all interrupts */ 290 /* Disable all interrupts */
280 at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | AT91_RTC_SECEV | AT91_RTC_TIMEV | AT91_RTC_CALEV); 291 at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM |
292 AT91_RTC_SECEV | AT91_RTC_TIMEV |
293 AT91_RTC_CALEV);
281 294
282 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, SA_SHIRQ, "at91_rtc", pdev); 295 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
296 SA_SHIRQ, "at91_rtc", pdev);
283 if (ret) { 297 if (ret) {
284 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", AT91_ID_SYS); 298 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n",
299 AT91_ID_SYS);
285 return ret; 300 return ret;
286 } 301 }
287 302
288 rtc = rtc_device_register(pdev->name, &pdev->dev, &at91_rtc_ops, THIS_MODULE); 303 rtc = rtc_device_register(pdev->name, &pdev->dev,
304 &at91_rtc_ops, THIS_MODULE);
289 if (IS_ERR(rtc)) { 305 if (IS_ERR(rtc)) {
290 free_irq(AT91_ID_SYS, pdev); 306 free_irq(AT91_ID_SYS, pdev);
291 return PTR_ERR(rtc); 307 return PTR_ERR(rtc);
@@ -304,7 +320,9 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)
304 struct rtc_device *rtc = platform_get_drvdata(pdev); 320 struct rtc_device *rtc = platform_get_drvdata(pdev);
305 321
306 /* Disable all interrupts */ 322 /* Disable all interrupts */
307 at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | AT91_RTC_SECEV | AT91_RTC_TIMEV | AT91_RTC_CALEV); 323 at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM |
324 AT91_RTC_SECEV | AT91_RTC_TIMEV |
325 AT91_RTC_CALEV);
308 free_irq(AT91_ID_SYS, pdev); 326 free_irq(AT91_ID_SYS, pdev);
309 327
310 rtc_device_unregister(rtc); 328 rtc_device_unregister(rtc);
@@ -332,7 +350,8 @@ static int at91_rtc_suspend(struct platform_device *pdev, pm_message_t state)
332 save_time_delta(&at91_rtc_delta, &time); 350 save_time_delta(&at91_rtc_delta, &time);
333 351
334 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 352 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
335 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); 353 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday,
354 tm.tm_hour, tm.tm_min, tm.tm_sec);
336 355
337 return 0; 356 return 0;
338} 357}
@@ -349,7 +368,8 @@ static int at91_rtc_resume(struct platform_device *pdev)
349 restore_time_delta(&at91_rtc_delta, &time); 368 restore_time_delta(&at91_rtc_delta, &time);
350 369
351 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 370 pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
352 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); 371 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday,
372 tm.tm_hour, tm.tm_min, tm.tm_sec);
353 373
354 return 0; 374 return 0;
355} 375}
@@ -379,7 +399,6 @@ static void __exit at91_rtc_exit(void)
379 platform_driver_unregister(&at91_rtc_driver); 399 platform_driver_unregister(&at91_rtc_driver);
380} 400}
381 401
382
383module_init(at91_rtc_init); 402module_init(at91_rtc_init);
384module_exit(at91_rtc_exit); 403module_exit(at91_rtc_exit);
385 404