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/smp.h>
23#include <linux/ioport.h>
24#include <linux/platform_device.h>
25
26#include <asm/cpu.h>
27#include <asm/vr41xx/irq.h>
28
29static struct resource rtc_type1_resource[] __initdata = {
30 {
31 .start = 0x0b0000c0,
32 .end = 0x0b0000df,
33 .flags = IORESOURCE_MEM,
34 },
35 {
36 .start = 0x0b0001c0,
37 .end = 0x0b0001df,
38 .flags = IORESOURCE_MEM,
39 },
40 {
41 .start = ELAPSEDTIME_IRQ,
42 .end = ELAPSEDTIME_IRQ,
43 .flags = IORESOURCE_IRQ,
44 },
45 {
46 .start = RTCLONG1_IRQ,
47 .end = RTCLONG1_IRQ,
48 .flags = IORESOURCE_IRQ,
49 },
50};
51
52static struct resource rtc_type2_resource[] __initdata = {
53 {
54 .start = 0x0f000100,
55 .end = 0x0f00011f,
56 .flags = IORESOURCE_MEM,
57 },
58 {
59 .start = 0x0f000120,
60 .end = 0x0f00013f,
61 .flags = IORESOURCE_MEM,
62 },
63 {
64 .start = ELAPSEDTIME_IRQ,
65 .end = ELAPSEDTIME_IRQ,
66 .flags = IORESOURCE_IRQ,
67 },
68 {
69 .start = RTCLONG1_IRQ,
70 .end = RTCLONG1_IRQ,
71 .flags = IORESOURCE_IRQ,
72 },
73};
74
75static int __init vr41xx_rtc_add(void)
76{
77 struct platform_device *pdev;
78 struct resource *res;
79 unsigned int num;
80 int retval;
81
82 pdev = platform_device_alloc("RTC", -1);
83 if (!pdev)
84 return -ENOMEM;
85
86 switch (current_cpu_type()) {
87 case CPU_VR4111:
88 case CPU_VR4121:
89 res = rtc_type1_resource;
90 num = ARRAY_SIZE(rtc_type1_resource);
91 break;
92 case CPU_VR4122:
93 case CPU_VR4131:
94 case CPU_VR4133:
95 res = rtc_type2_resource;
96 num = ARRAY_SIZE(rtc_type2_resource);
97 break;
98 default:
99 retval = -ENODEV;
100 goto err_free_device;
101 }
102
103 retval = platform_device_add_resources(pdev, res, num);
104 if (retval)
105 goto err_free_device;
106
107 retval = platform_device_add(pdev);
108 if (retval)
109 goto err_free_device;
110
111 return 0;
112
113err_free_device:
114 platform_device_put(pdev);
115
116 return retval;
117}
118device_initcall(vr41xx_rtc_add);
119