1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/ioport.h>
23#include <linux/mc146818rtc.h>
24#include <linux/platform_device.h>
25
26static struct resource cobalt_rtc_resource[] __initdata = {
27 {
28 .start = 0x70,
29 .end = 0x77,
30 .flags = IORESOURCE_IO,
31 },
32 {
33 .start = RTC_IRQ,
34 .end = RTC_IRQ,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39static __init int cobalt_rtc_add(void)
40{
41 struct platform_device *pdev;
42 int retval;
43
44 pdev = platform_device_alloc("rtc_cmos", -1);
45 if (!pdev)
46 return -ENOMEM;
47
48 retval = platform_device_add_resources(pdev, cobalt_rtc_resource,
49 ARRAY_SIZE(cobalt_rtc_resource));
50 if (retval)
51 goto err_free_device;
52
53 retval = platform_device_add(pdev);
54 if (retval)
55 goto err_free_device;
56
57 return 0;
58
59err_free_device:
60 platform_device_put(pdev);
61
62 return retval;
63}
64device_initcall(cobalt_rtc_add);
65