diff options
Diffstat (limited to 'drivers/rtc/rtc-tegra.c')
-rw-r--r-- | drivers/rtc/rtc-tegra.c | 64 |
1 files changed, 17 insertions, 47 deletions
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c index 7c033756d6b5..a34315d25478 100644 --- a/drivers/rtc/rtc-tegra.c +++ b/drivers/rtc/rtc-tegra.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/pm.h> | ||
29 | 30 | ||
30 | /* set to 1 = busy every eight 32kHz clocks during copy of sec+msec to AHB */ | 31 | /* set to 1 = busy every eight 32kHz clocks during copy of sec+msec to AHB */ |
31 | #define TEGRA_RTC_REG_BUSY 0x004 | 32 | #define TEGRA_RTC_REG_BUSY 0x004 |
@@ -309,7 +310,7 @@ static const struct of_device_id tegra_rtc_dt_match[] = { | |||
309 | }; | 310 | }; |
310 | MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match); | 311 | MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match); |
311 | 312 | ||
312 | static int tegra_rtc_probe(struct platform_device *pdev) | 313 | static int __init tegra_rtc_probe(struct platform_device *pdev) |
313 | { | 314 | { |
314 | struct tegra_rtc_info *info; | 315 | struct tegra_rtc_info *info; |
315 | struct resource *res; | 316 | struct resource *res; |
@@ -348,53 +349,35 @@ static int tegra_rtc_probe(struct platform_device *pdev) | |||
348 | 349 | ||
349 | device_init_wakeup(&pdev->dev, 1); | 350 | device_init_wakeup(&pdev->dev, 1); |
350 | 351 | ||
351 | info->rtc_dev = rtc_device_register( | 352 | info->rtc_dev = devm_rtc_device_register(&pdev->dev, |
352 | pdev->name, &pdev->dev, &tegra_rtc_ops, THIS_MODULE); | 353 | dev_name(&pdev->dev), &tegra_rtc_ops, |
354 | THIS_MODULE); | ||
353 | if (IS_ERR(info->rtc_dev)) { | 355 | if (IS_ERR(info->rtc_dev)) { |
354 | ret = PTR_ERR(info->rtc_dev); | 356 | ret = PTR_ERR(info->rtc_dev); |
355 | info->rtc_dev = NULL; | 357 | dev_err(&pdev->dev, "Unable to register device (err=%d).\n", |
356 | dev_err(&pdev->dev, | ||
357 | "Unable to register device (err=%d).\n", | ||
358 | ret); | 358 | ret); |
359 | return ret; | 359 | return ret; |
360 | } | 360 | } |
361 | 361 | ||
362 | ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq, | 362 | ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq, |
363 | tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH, | 363 | tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH, |
364 | "rtc alarm", &pdev->dev); | 364 | dev_name(&pdev->dev), &pdev->dev); |
365 | if (ret) { | 365 | if (ret) { |
366 | dev_err(&pdev->dev, | 366 | dev_err(&pdev->dev, |
367 | "Unable to request interrupt for device (err=%d).\n", | 367 | "Unable to request interrupt for device (err=%d).\n", |
368 | ret); | 368 | ret); |
369 | goto err_dev_unreg; | 369 | return ret; |
370 | } | 370 | } |
371 | 371 | ||
372 | dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n"); | 372 | dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n"); |
373 | 373 | ||
374 | return 0; | 374 | return 0; |
375 | |||
376 | err_dev_unreg: | ||
377 | rtc_device_unregister(info->rtc_dev); | ||
378 | |||
379 | return ret; | ||
380 | } | 375 | } |
381 | 376 | ||
382 | static int tegra_rtc_remove(struct platform_device *pdev) | 377 | #ifdef CONFIG_PM_SLEEP |
378 | static int tegra_rtc_suspend(struct device *dev) | ||
383 | { | 379 | { |
384 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | 380 | struct tegra_rtc_info *info = dev_get_drvdata(dev); |
385 | |||
386 | rtc_device_unregister(info->rtc_dev); | ||
387 | |||
388 | platform_set_drvdata(pdev, NULL); | ||
389 | |||
390 | return 0; | ||
391 | } | ||
392 | |||
393 | #ifdef CONFIG_PM | ||
394 | static int tegra_rtc_suspend(struct platform_device *pdev, pm_message_t state) | ||
395 | { | ||
396 | struct device *dev = &pdev->dev; | ||
397 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | ||
398 | 381 | ||
399 | tegra_rtc_wait_while_busy(dev); | 382 | tegra_rtc_wait_while_busy(dev); |
400 | 383 | ||
@@ -416,10 +399,9 @@ static int tegra_rtc_suspend(struct platform_device *pdev, pm_message_t state) | |||
416 | return 0; | 399 | return 0; |
417 | } | 400 | } |
418 | 401 | ||
419 | static int tegra_rtc_resume(struct platform_device *pdev) | 402 | static int tegra_rtc_resume(struct device *dev) |
420 | { | 403 | { |
421 | struct device *dev = &pdev->dev; | 404 | struct tegra_rtc_info *info = dev_get_drvdata(dev); |
422 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | ||
423 | 405 | ||
424 | dev_vdbg(dev, "Resume (device_may_wakeup=%d)\n", | 406 | dev_vdbg(dev, "Resume (device_may_wakeup=%d)\n", |
425 | device_may_wakeup(dev)); | 407 | device_may_wakeup(dev)); |
@@ -431,6 +413,8 @@ static int tegra_rtc_resume(struct platform_device *pdev) | |||
431 | } | 413 | } |
432 | #endif | 414 | #endif |
433 | 415 | ||
416 | static SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume); | ||
417 | |||
434 | static void tegra_rtc_shutdown(struct platform_device *pdev) | 418 | static void tegra_rtc_shutdown(struct platform_device *pdev) |
435 | { | 419 | { |
436 | dev_vdbg(&pdev->dev, "disabling interrupts.\n"); | 420 | dev_vdbg(&pdev->dev, "disabling interrupts.\n"); |
@@ -439,30 +423,16 @@ static void tegra_rtc_shutdown(struct platform_device *pdev) | |||
439 | 423 | ||
440 | MODULE_ALIAS("platform:tegra_rtc"); | 424 | MODULE_ALIAS("platform:tegra_rtc"); |
441 | static struct platform_driver tegra_rtc_driver = { | 425 | static struct platform_driver tegra_rtc_driver = { |
442 | .remove = tegra_rtc_remove, | ||
443 | .shutdown = tegra_rtc_shutdown, | 426 | .shutdown = tegra_rtc_shutdown, |
444 | .driver = { | 427 | .driver = { |
445 | .name = "tegra_rtc", | 428 | .name = "tegra_rtc", |
446 | .owner = THIS_MODULE, | 429 | .owner = THIS_MODULE, |
447 | .of_match_table = tegra_rtc_dt_match, | 430 | .of_match_table = tegra_rtc_dt_match, |
431 | .pm = &tegra_rtc_pm_ops, | ||
448 | }, | 432 | }, |
449 | #ifdef CONFIG_PM | ||
450 | .suspend = tegra_rtc_suspend, | ||
451 | .resume = tegra_rtc_resume, | ||
452 | #endif | ||
453 | }; | 433 | }; |
454 | 434 | ||
455 | static int __init tegra_rtc_init(void) | 435 | module_platform_driver_probe(tegra_rtc_driver, tegra_rtc_probe); |
456 | { | ||
457 | return platform_driver_probe(&tegra_rtc_driver, tegra_rtc_probe); | ||
458 | } | ||
459 | module_init(tegra_rtc_init); | ||
460 | |||
461 | static void __exit tegra_rtc_exit(void) | ||
462 | { | ||
463 | platform_driver_unregister(&tegra_rtc_driver); | ||
464 | } | ||
465 | module_exit(tegra_rtc_exit); | ||
466 | 436 | ||
467 | MODULE_AUTHOR("Jon Mayo <jmayo@nvidia.com>"); | 437 | MODULE_AUTHOR("Jon Mayo <jmayo@nvidia.com>"); |
468 | MODULE_DESCRIPTION("driver for Tegra internal RTC"); | 438 | MODULE_DESCRIPTION("driver for Tegra internal RTC"); |