rtc-starfire.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* rtc-starfire.c: Starfire platform RTC driver.
  2. *
  3. * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/module.h>
  7. #include <linux/init.h>
  8. #include <linux/rtc.h>
  9. #include <linux/platform_device.h>
  10. #include <asm/oplib.h>
  11. MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
  12. MODULE_DESCRIPTION("Starfire RTC driver");
  13. MODULE_LICENSE("GPL");
  14. static u32 starfire_get_time(void)
  15. {
  16. static char obp_gettod[32];
  17. static u32 unix_tod;
  18. sprintf(obp_gettod, "h# %08x unix-gettod",
  19. (unsigned int) (long) &unix_tod);
  20. prom_feval(obp_gettod);
  21. return unix_tod;
  22. }
  23. static int starfire_read_time(struct device *dev, struct rtc_time *tm)
  24. {
  25. rtc_time_to_tm(starfire_get_time(), tm);
  26. return rtc_valid_tm(tm);
  27. }
  28. static const struct rtc_class_ops starfire_rtc_ops = {
  29. .read_time = starfire_read_time,
  30. };
  31. static int __init starfire_rtc_probe(struct platform_device *pdev)
  32. {
  33. struct rtc_device *rtc;
  34. rtc = devm_rtc_device_register(&pdev->dev, "starfire",
  35. &starfire_rtc_ops, THIS_MODULE);
  36. if (IS_ERR(rtc))
  37. return PTR_ERR(rtc);
  38. platform_set_drvdata(pdev, rtc);
  39. return 0;
  40. }
  41. static struct platform_driver starfire_rtc_driver = {
  42. .driver = {
  43. .name = "rtc-starfire",
  44. },
  45. };
  46. module_platform_driver_probe(starfire_rtc_driver, starfire_rtc_probe);