Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Registration of Cobalt RTC platform device.
0004  *
0005  *  Copyright (C) 2007  Yoichi Yuasa <yuasa@linux-mips.org>
0006  */
0007 #include <linux/errno.h>
0008 #include <linux/init.h>
0009 #include <linux/ioport.h>
0010 #include <linux/mc146818rtc.h>
0011 #include <linux/platform_device.h>
0012 
0013 static struct resource cobalt_rtc_resource[] __initdata = {
0014     {
0015         .start  = 0x70,
0016         .end    = 0x77,
0017         .flags  = IORESOURCE_IO,
0018     },
0019     {
0020         .start  = RTC_IRQ,
0021         .end    = RTC_IRQ,
0022         .flags  = IORESOURCE_IRQ,
0023     },
0024 };
0025 
0026 static __init int cobalt_rtc_add(void)
0027 {
0028     struct platform_device *pdev;
0029     int retval;
0030 
0031     pdev = platform_device_alloc("rtc_cmos", -1);
0032     if (!pdev)
0033         return -ENOMEM;
0034 
0035     retval = platform_device_add_resources(pdev, cobalt_rtc_resource,
0036                            ARRAY_SIZE(cobalt_rtc_resource));
0037     if (retval)
0038         goto err_free_device;
0039 
0040     retval = platform_device_add(pdev);
0041     if (retval)
0042         goto err_free_device;
0043 
0044     return 0;
0045 
0046 err_free_device:
0047     platform_device_put(pdev);
0048 
0049     return retval;
0050 }
0051 device_initcall(cobalt_rtc_add);