/* * Copyright 2001 MontaVista Software Inc. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net * Copyright (c) 2003, 2004 Maciej W. Rozycki * * Common time service routines for MIPS machines. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * forward reference */ DEFINE_SPINLOCK(rtc_lock); EXPORT_SYMBOL(rtc_lock); int __weak rtc_mips_set_time(unsigned long sec) { return 0; } int __weak rtc_mips_set_mmss(unsigned long nowtime) { return rtc_mips_set_time(nowtime); } int update_persistent_clock(struct timespec now) { return rtc_mips_set_mmss(now.tv_sec); } #if 0 /* * time_init() - it does the following things. * * 1) rlx_time_init() - * a) (optional) set up RTC routines, * b) (optional) calibrate and set the mips_hpt_frequency * (only needed if you intended to use cpu counter as timer interrupt * source) * 2) calculate a couple of cached variables for later usage */ unsigned int mips_hpt_frequency; void __init clocksource_set_clock(struct clocksource *cs, unsigned int clock) { u64 temp; u32 shift; /* Find a shift value */ for (shift = 32; shift > 0; shift--) { temp = (u64) NSEC_PER_SEC << shift; do_div(temp, clock); if ((temp >> 32) == 0) break; } cs->shift = shift; cs->mult = (u32) temp; } #endif void __cpuinit clockevent_set_clock(struct clock_event_device *cd, unsigned int clock) { u64 temp; u32 shift; /* Find a shift value */ for (shift = 32; shift > 0; shift--) { temp = (u64) clock << shift; do_div(temp, NSEC_PER_SEC); if ((temp >> 32) == 0) break; } cd->shift = shift; cd->mult = (u32) temp; } /* * This function exists in order to cause an error due to a duplicate * definition if platform code should have its own implementation. The hook * to use instead is bsp_time_init. bsp_time_init does not receive the * irqaction pointer argument anymore. This is because any function which * initializes an interrupt timer now takes care of its own request_irq rsp. * setup_irq calls and each clock_event_device should use its own * struct irqrequest. */ void __init time_init(void) { extern void bsp_timer_init(void); bsp_timer_init(); }