RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / ppc / amiga / time.c
blob8c880c0ca380819af131bbba2a88aec9e3af704b
1 #include <linux/errno.h>
2 #include <linux/sched.h>
3 #include <linux/kernel.h>
4 #include <linux/param.h>
5 #include <linux/string.h>
6 #include <linux/mm.h>
8 #include <asm/machdep.h>
9 #include <asm/io.h>
11 #include <linux/timex.h>
13 unsigned long m68k_get_rtc_time(void)
15 unsigned int year, mon, day, hour, min, sec;
17 extern void arch_gettod(int *year, int *mon, int *day, int *hour,
18 int *min, int *sec);
20 arch_gettod (&year, &mon, &day, &hour, &min, &sec);
22 if ((year += 1900) < 1970)
23 year += 100;
25 return mktime(year, mon, day, hour, min, sec);
28 int m68k_set_rtc_time(unsigned long nowtime)
30 if (mach_set_clock_mmss)
31 return mach_set_clock_mmss (nowtime);
32 return -1;
35 void apus_heartbeat (void)
37 #ifdef CONFIG_HEARTBEAT
38 static unsigned cnt = 0, period = 0, dist = 0;
40 if (cnt == 0 || cnt == dist)
41 mach_heartbeat( 1 );
42 else if (cnt == 7 || cnt == dist+7)
43 mach_heartbeat( 0 );
45 if (++cnt > period) {
46 cnt = 0;
47 /* The hyperbolic function below modifies the heartbeat period
48 * length in dependency of the current (5min) load. It goes
49 * through the points f(0)=126, f(1)=86, f(5)=51,
50 * f(inf)->30. */
51 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
52 dist = period / 4;
54 #endif
55 /* should be made smarter */
56 ppc_md.heartbeat_count = 1;