diff options
author | Kim Phillips <kim.phillips@freescale.com> | 2006-09-26 18:46:37 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-10-02 03:48:47 -0400 |
commit | 7a69af63e788a324d162201a0b23df41bcf158dd (patch) | |
tree | b25e776a04eedd122594d75841dd30b4419657b0 /arch | |
parent | 2bf118197cb4d9a5e7a9e45b5b007235fdc9f402 (diff) |
[POWERPC] Add powerpc get/set_rtc_time interface to new generic rtc class
Add powerpc get/set_rtc_time interface to new generic rtc class. This
abstracts rtc chip specific code from the platform code for rtc-over-i2c
platforms. Specific RTC chip support is now configured under
Device Drivers -> Real Time Clock. Setting time of day from the RTC
on startup is also configurable.
this time without the potentially platform breaking initcall.
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/time.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 7a3c3f791ade..b4ed362c457a 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -1048,6 +1048,48 @@ void __init time_init(void) | |||
1048 | set_dec(tb_ticks_per_jiffy); | 1048 | set_dec(tb_ticks_per_jiffy); |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | #ifdef CONFIG_RTC_CLASS | ||
1052 | static int set_rtc_class_time(struct rtc_time *tm) | ||
1053 | { | ||
1054 | int err; | ||
1055 | struct class_device *class_dev = | ||
1056 | rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); | ||
1057 | |||
1058 | if (class_dev == NULL) | ||
1059 | return -ENODEV; | ||
1060 | |||
1061 | err = rtc_set_time(class_dev, tm); | ||
1062 | |||
1063 | rtc_class_close(class_dev); | ||
1064 | |||
1065 | return 0; | ||
1066 | } | ||
1067 | |||
1068 | static void get_rtc_class_time(struct rtc_time *tm) | ||
1069 | { | ||
1070 | int err; | ||
1071 | struct class_device *class_dev = | ||
1072 | rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); | ||
1073 | |||
1074 | if (class_dev == NULL) | ||
1075 | return; | ||
1076 | |||
1077 | err = rtc_read_time(class_dev, tm); | ||
1078 | |||
1079 | rtc_class_close(class_dev); | ||
1080 | |||
1081 | return; | ||
1082 | } | ||
1083 | |||
1084 | int __init rtc_class_hookup(void) | ||
1085 | { | ||
1086 | ppc_md.get_rtc_time = get_rtc_class_time; | ||
1087 | ppc_md.set_rtc_time = set_rtc_class_time; | ||
1088 | |||
1089 | return 0; | ||
1090 | } | ||
1091 | #endif /* CONFIG_RTC_CLASS */ | ||
1092 | |||
1051 | 1093 | ||
1052 | #define FEBRUARY 2 | 1094 | #define FEBRUARY 2 |
1053 | #define STARTOFTIME 1970 | 1095 | #define STARTOFTIME 1970 |