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