diff options
Diffstat (limited to 'drivers/rtc/rtc-bfin.c')
-rw-r--r-- | drivers/rtc/rtc-bfin.c | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index a1af4c27939b..34439ce3967e 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -218,26 +218,6 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id) | |||
218 | return IRQ_NONE; | 218 | return IRQ_NONE; |
219 | } | 219 | } |
220 | 220 | ||
221 | static int bfin_rtc_open(struct device *dev) | ||
222 | { | ||
223 | int ret; | ||
224 | |||
225 | dev_dbg_stamp(dev); | ||
226 | |||
227 | ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_SHARED, to_platform_device(dev)->name, dev); | ||
228 | if (!ret) | ||
229 | bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE); | ||
230 | |||
231 | return ret; | ||
232 | } | ||
233 | |||
234 | static void bfin_rtc_release(struct device *dev) | ||
235 | { | ||
236 | dev_dbg_stamp(dev); | ||
237 | bfin_rtc_reset(dev, 0); | ||
238 | free_irq(IRQ_RTC, dev); | ||
239 | } | ||
240 | |||
241 | static void bfin_rtc_int_set(u16 rtc_int) | 221 | static void bfin_rtc_int_set(u16 rtc_int) |
242 | { | 222 | { |
243 | bfin_write_RTC_ISTAT(rtc_int); | 223 | bfin_write_RTC_ISTAT(rtc_int); |
@@ -370,8 +350,6 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq) | |||
370 | } | 350 | } |
371 | 351 | ||
372 | static struct rtc_class_ops bfin_rtc_ops = { | 352 | static struct rtc_class_ops bfin_rtc_ops = { |
373 | .open = bfin_rtc_open, | ||
374 | .release = bfin_rtc_release, | ||
375 | .ioctl = bfin_rtc_ioctl, | 353 | .ioctl = bfin_rtc_ioctl, |
376 | .read_time = bfin_rtc_read_time, | 354 | .read_time = bfin_rtc_read_time, |
377 | .set_time = bfin_rtc_set_time, | 355 | .set_time = bfin_rtc_set_time, |
@@ -383,29 +361,44 @@ static struct rtc_class_ops bfin_rtc_ops = { | |||
383 | static int __devinit bfin_rtc_probe(struct platform_device *pdev) | 361 | static int __devinit bfin_rtc_probe(struct platform_device *pdev) |
384 | { | 362 | { |
385 | struct bfin_rtc *rtc; | 363 | struct bfin_rtc *rtc; |
364 | struct device *dev = &pdev->dev; | ||
386 | int ret = 0; | 365 | int ret = 0; |
366 | unsigned long timeout; | ||
387 | 367 | ||
388 | dev_dbg_stamp(&pdev->dev); | 368 | dev_dbg_stamp(dev); |
389 | 369 | ||
370 | /* Allocate memory for our RTC struct */ | ||
390 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); | 371 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); |
391 | if (unlikely(!rtc)) | 372 | if (unlikely(!rtc)) |
392 | return -ENOMEM; | 373 | return -ENOMEM; |
374 | platform_set_drvdata(pdev, rtc); | ||
375 | device_init_wakeup(dev, 1); | ||
393 | 376 | ||
394 | rtc->rtc_dev = rtc_device_register(pdev->name, &pdev->dev, &bfin_rtc_ops, THIS_MODULE); | 377 | /* Grab the IRQ and init the hardware */ |
395 | if (IS_ERR(rtc)) { | 378 | ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_SHARED, pdev->name, dev); |
396 | ret = PTR_ERR(rtc->rtc_dev); | 379 | if (unlikely(ret)) |
397 | goto err; | 380 | goto err; |
398 | } | 381 | /* sometimes the bootloader touched things, but the write complete was not |
399 | 382 | * enabled, so let's just do a quick timeout here since the IRQ will not fire ... | |
400 | /* see comment at top of file about stopwatch/PIE */ | 383 | */ |
384 | timeout = jiffies + HZ; | ||
385 | while (bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_PENDING) | ||
386 | if (time_after(jiffies, timeout)) | ||
387 | break; | ||
388 | bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE); | ||
401 | bfin_write_RTC_SWCNT(0); | 389 | bfin_write_RTC_SWCNT(0); |
402 | 390 | ||
403 | platform_set_drvdata(pdev, rtc); | 391 | /* Register our RTC with the RTC framework */ |
404 | 392 | rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, THIS_MODULE); | |
405 | device_init_wakeup(&pdev->dev, 1); | 393 | if (unlikely(IS_ERR(rtc))) { |
394 | ret = PTR_ERR(rtc->rtc_dev); | ||
395 | goto err_irq; | ||
396 | } | ||
406 | 397 | ||
407 | return 0; | 398 | return 0; |
408 | 399 | ||
400 | err_irq: | ||
401 | free_irq(IRQ_RTC, dev); | ||
409 | err: | 402 | err: |
410 | kfree(rtc); | 403 | kfree(rtc); |
411 | return ret; | 404 | return ret; |
@@ -414,7 +407,10 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev) | |||
414 | static int __devexit bfin_rtc_remove(struct platform_device *pdev) | 407 | static int __devexit bfin_rtc_remove(struct platform_device *pdev) |
415 | { | 408 | { |
416 | struct bfin_rtc *rtc = platform_get_drvdata(pdev); | 409 | struct bfin_rtc *rtc = platform_get_drvdata(pdev); |
410 | struct device *dev = &pdev->dev; | ||
417 | 411 | ||
412 | bfin_rtc_reset(dev, 0); | ||
413 | free_irq(IRQ_RTC, dev); | ||
418 | rtc_device_unregister(rtc->rtc_dev); | 414 | rtc_device_unregister(rtc->rtc_dev); |
419 | platform_set_drvdata(pdev, NULL); | 415 | platform_set_drvdata(pdev, NULL); |
420 | kfree(rtc); | 416 | kfree(rtc); |