1 | /* |
---|
2 | * RTEMS for Nintendo DS realtime clock driver. |
---|
3 | * |
---|
4 | * Copyright (c) 2008 by Cedric Gestes <ctaf42@gmail.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * |
---|
9 | * http://www.rtems.org/license/LICENSE |
---|
10 | */ |
---|
11 | |
---|
12 | #include <rtems.h> |
---|
13 | #include <libchip/rtc.h> |
---|
14 | #include <bsp.h> |
---|
15 | #include <nds.h> |
---|
16 | |
---|
17 | rtems_device_minor_number RTC_Minor; |
---|
18 | size_t RTC_Count = 1; |
---|
19 | |
---|
20 | /* |
---|
21 | * probe for a rtc. we always claim to have one. |
---|
22 | */ |
---|
23 | |
---|
24 | bool |
---|
25 | nds_rtc_probe (int minor) |
---|
26 | { |
---|
27 | return true; |
---|
28 | } |
---|
29 | |
---|
30 | /* |
---|
31 | * initialize the nds rtc. |
---|
32 | */ |
---|
33 | |
---|
34 | void |
---|
35 | nds_rtc_init (int minor) |
---|
36 | { |
---|
37 | /* nothing to do here (already done in the arm7 main) */ |
---|
38 | printk ("[+] rtc started\n"); |
---|
39 | } |
---|
40 | |
---|
41 | /* |
---|
42 | * read current time from nds real-time clock chip and convert it |
---|
43 | * to the rtems_time_of_day structure. |
---|
44 | */ |
---|
45 | |
---|
46 | int |
---|
47 | nds_rtc_get_time (int minor, rtems_time_of_day * time) |
---|
48 | { |
---|
49 | time->year = 2000 + IPC->time.rtc.year; |
---|
50 | time->month = IPC->time.rtc.month; |
---|
51 | time->day = IPC->time.rtc.day; |
---|
52 | time->hour = IPC->time.rtc.hours; |
---|
53 | time->minute = IPC->time.rtc.minutes; |
---|
54 | time->second = IPC->time.rtc.seconds; |
---|
55 | time->ticks = 0; |
---|
56 | |
---|
57 | return 0; |
---|
58 | } |
---|
59 | |
---|
60 | /* |
---|
61 | * set time to the arm7 nds rtc. |
---|
62 | * NOTE: this is not supported. |
---|
63 | */ |
---|
64 | |
---|
65 | int |
---|
66 | nds_rtc_set_time (int minor, const rtems_time_of_day * time) |
---|
67 | { |
---|
68 | return -1; |
---|
69 | } |
---|
70 | |
---|
71 | /* |
---|
72 | * driver function table. |
---|
73 | */ |
---|
74 | |
---|
75 | rtc_fns nds_rtc_fns = { |
---|
76 | nds_rtc_init, |
---|
77 | nds_rtc_get_time, |
---|
78 | nds_rtc_set_time |
---|
79 | }; |
---|
80 | |
---|
81 | /* |
---|
82 | * the following table configures the RTC drivers used in this BSP |
---|
83 | */ |
---|
84 | |
---|
85 | rtc_tbl RTC_Table[] = { |
---|
86 | { |
---|
87 | "/dev/rtc", /* sDeviceName */ |
---|
88 | RTC_CUSTOM, /* deviceType */ |
---|
89 | &nds_rtc_fns, /* pDeviceFns */ |
---|
90 | nds_rtc_probe, /* deviceProbe */ |
---|
91 | NULL, /* pDeviceParams */ |
---|
92 | 0, /* ulCtrlPort1 */ |
---|
93 | 0, /* ulDataPort */ |
---|
94 | NULL, /* getRegister */ |
---|
95 | NULL /* setRegister */ |
---|
96 | } |
---|
97 | }; |
---|