diff options
-rw-r--r-- | arch/powerpc/kernel/time.c | 42 | ||||
-rw-r--r-- | include/asm-powerpc/time.h | 6 |
2 files changed, 47 insertions, 1 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 |
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h index 5785ac4737b5..b051d4c88c3b 100644 --- a/include/asm-powerpc/time.h +++ b/include/asm-powerpc/time.h | |||
@@ -39,6 +39,10 @@ extern void generic_calibrate_decr(void); | |||
39 | extern void wakeup_decrementer(void); | 39 | extern void wakeup_decrementer(void); |
40 | extern void snapshot_timebase(void); | 40 | extern void snapshot_timebase(void); |
41 | 41 | ||
42 | #ifdef CONFIG_RTC_CLASS | ||
43 | extern int __init rtc_class_hookup(void); | ||
44 | #endif | ||
45 | |||
42 | /* Some sane defaults: 125 MHz timebase, 1GHz processor */ | 46 | /* Some sane defaults: 125 MHz timebase, 1GHz processor */ |
43 | extern unsigned long ppc_proc_freq; | 47 | extern unsigned long ppc_proc_freq; |
44 | #define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8) | 48 | #define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8) |
@@ -234,4 +238,4 @@ extern void snapshot_timebases(void); | |||
234 | #endif | 238 | #endif |
235 | 239 | ||
236 | #endif /* __KERNEL__ */ | 240 | #endif /* __KERNEL__ */ |
237 | #endif /* __PPC64_TIME_H */ | 241 | #endif /* __POWERPC_TIME_H */ |