rtc.c 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Registration of Cobalt RTC platform device.
  4. *
  5. * Copyright (C) 2007 Yoichi Yuasa <[email protected]>
  6. */
  7. #include <linux/errno.h>
  8. #include <linux/init.h>
  9. #include <linux/ioport.h>
  10. #include <linux/mc146818rtc.h>
  11. #include <linux/platform_device.h>
  12. static struct resource cobalt_rtc_resource[] __initdata = {
  13. {
  14. .start = 0x70,
  15. .end = 0x77,
  16. .flags = IORESOURCE_IO,
  17. },
  18. {
  19. .start = RTC_IRQ,
  20. .end = RTC_IRQ,
  21. .flags = IORESOURCE_IRQ,
  22. },
  23. };
  24. static __init int cobalt_rtc_add(void)
  25. {
  26. struct platform_device *pdev;
  27. int retval;
  28. pdev = platform_device_alloc("rtc_cmos", -1);
  29. if (!pdev)
  30. return -ENOMEM;
  31. retval = platform_device_add_resources(pdev, cobalt_rtc_resource,
  32. ARRAY_SIZE(cobalt_rtc_resource));
  33. if (retval)
  34. goto err_free_device;
  35. retval = platform_device_add(pdev);
  36. if (retval)
  37. goto err_free_device;
  38. return 0;
  39. err_free_device:
  40. platform_device_put(pdev);
  41. return retval;
  42. }
  43. device_initcall(cobalt_rtc_add);