6b13f685e
김민수
BSP 최초 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#include <linux/module.h>
#include <linux/device.h>
#include <linux/rtc.h>
#include <linux/platform_device.h>
static struct platform_device *tile_rtc_platform_device;
static int read_rtc_time(struct device *dev, struct rtc_time *tm)
{
HV_RTCTime hvtm = hv_get_rtc();
tm->tm_sec = hvtm.tm_sec;
tm->tm_min = hvtm.tm_min;
tm->tm_hour = hvtm.tm_hour;
tm->tm_mday = hvtm.tm_mday;
tm->tm_mon = hvtm.tm_mon;
tm->tm_year = hvtm.tm_year;
tm->tm_wday = 0;
tm->tm_yday = 0;
tm->tm_isdst = 0;
if (rtc_valid_tm(tm) < 0)
dev_warn(dev, "Read invalid date/time from RTC
");
return 0;
}
static int set_rtc_time(struct device *dev, struct rtc_time *tm)
{
HV_RTCTime hvtm;
hvtm.tm_sec = tm->tm_sec;
hvtm.tm_min = tm->tm_min;
hvtm.tm_hour = tm->tm_hour;
hvtm.tm_mday = tm->tm_mday;
hvtm.tm_mon = tm->tm_mon;
hvtm.tm_year = tm->tm_year;
hv_set_rtc(hvtm);
return 0;
}
static const struct rtc_class_ops tile_rtc_ops = {
.read_time = read_rtc_time,
.set_time = set_rtc_time,
};
static int tile_rtc_probe(struct platform_device *dev)
{
struct rtc_device *rtc;
rtc = devm_rtc_device_register(&dev->dev, "tile",
&tile_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
platform_set_drvdata(dev, rtc);
return 0;
}
static struct platform_driver tile_rtc_platform_driver = {
.driver = {
.name = "rtc-tile",
.owner = THIS_MODULE,
},
.probe = tile_rtc_probe,
};
static int __init tile_rtc_driver_init(void)
{
int err;
err = platform_driver_register(&tile_rtc_platform_driver);
if (err)
return err;
tile_rtc_platform_device = platform_device_alloc("rtc-tile", 0);
if (tile_rtc_platform_device == NULL) {
err = -ENOMEM;
goto exit_driver_unregister;
}
err = platform_device_add(tile_rtc_platform_device);
if (err)
goto exit_device_put;
return 0;
exit_device_put:
platform_device_put(tile_rtc_platform_device);
exit_driver_unregister:
platform_driver_unregister(&tile_rtc_platform_driver);
return err;
}
static void __exit tile_rtc_driver_exit(void)
{
platform_device_unregister(tile_rtc_platform_device);
platform_driver_unregister(&tile_rtc_platform_driver);
}
module_init(tile_rtc_driver_init);
module_exit(tile_rtc_driver_exit);
MODULE_DESCRIPTION("Tilera-specific Real Time Clock Driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:rtc-tile");
|