[POWERPC] Fix timekeeping on PowerPC 601

Recent changes to the timekeeping code broke support for the PowerPC 601
processor which doesn't have the usual timebase facility but a slightly
different thing called (yuck) the RTC.

This fixes it, boot tested on an old 601 based PowerMac 7200.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by Benjamin Herrenschmidt and committed by Paul Mackerras c27da339 7b5acbaa

+10 -3
+5 -3
arch/powerpc/kernel/time.c
··· 239 239 struct cpu_purr_data *p = &__get_cpu_var(cpu_purr_data); 240 240 241 241 local_irq_save(flags); 242 - p->tb = mftb(); 242 + p->tb = get_tb_or_rtc(); 243 243 p->purr = mfspr(SPRN_PURR); 244 244 wmb(); 245 245 p->initialized = 1; ··· 317 317 */ 318 318 void snapshot_timebase(void) 319 319 { 320 - __get_cpu_var(last_jiffy) = get_tb(); 320 + __get_cpu_var(last_jiffy) = get_tb_or_rtc(); 321 321 snapshot_purr(); 322 322 } 323 323 ··· 684 684 685 685 write_seqlock(&xtime_lock); 686 686 tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy; 687 + if (__USE_RTC() && tb_next_jiffy >= 1000000000) 688 + tb_next_jiffy -= 1000000000; 687 689 if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) { 688 690 tb_last_jiffy = tb_next_jiffy; 689 691 do_timer(1); ··· 979 977 tb_to_ns_scale = scale; 980 978 tb_to_ns_shift = shift; 981 979 /* Save the current timebase to pretty up CONFIG_PRINTK_TIME */ 982 - boot_tb = get_tb(); 980 + boot_tb = get_tb_or_rtc(); 983 981 984 982 tm = get_boot_time(); 985 983
+5
include/asm-powerpc/time.h
··· 149 149 } 150 150 #endif /* !CONFIG_PPC64 */ 151 151 152 + static inline u64 get_tb_or_rtc(void) 153 + { 154 + return __USE_RTC() ? get_rtc() : get_tb(); 155 + } 156 + 152 157 static inline void set_tb(unsigned int upper, unsigned int lower) 153 158 { 154 159 mtspr(SPRN_TBWL, 0);