~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/frv/kernel/time.c

Version: ~ [ linux-5.8-rc3 ] ~ [ linux-5.7.5 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.48 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.129 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.185 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.228 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.228 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* time.c: FRV arch-specific time handling
  2  *
  3  * Copyright (C) 2003-5 Red Hat, Inc. All Rights Reserved.
  4  * Written by David Howells (dhowells@redhat.com)
  5  * - Derived from arch/m68k/kernel/time.c
  6  *
  7  * This program is free software; you can redistribute it and/or
  8  * modify it under the terms of the GNU General Public License
  9  * as published by the Free Software Foundation; either version
 10  * 2 of the License, or (at your option) any later version.
 11  */
 12 
 13 #include <linux/module.h>
 14 #include <linux/errno.h>
 15 #include <linux/sched.h>
 16 #include <linux/kernel.h>
 17 #include <linux/param.h>
 18 #include <linux/string.h>
 19 #include <linux/interrupt.h>
 20 #include <linux/profile.h>
 21 #include <linux/irq.h>
 22 #include <linux/mm.h>
 23 
 24 #include <asm/io.h>
 25 #include <asm/timer-regs.h>
 26 #include <asm/mb-regs.h>
 27 #include <asm/mb86943a.h>
 28 
 29 #include <linux/timex.h>
 30 
 31 #define TICK_SIZE (tick_nsec / 1000)
 32 
 33 unsigned long __nongprelbss __clkin_clock_speed_HZ;
 34 unsigned long __nongprelbss __ext_bus_clock_speed_HZ;
 35 unsigned long __nongprelbss __res_bus_clock_speed_HZ;
 36 unsigned long __nongprelbss __sdram_clock_speed_HZ;
 37 unsigned long __nongprelbss __core_bus_clock_speed_HZ;
 38 unsigned long __nongprelbss __core_clock_speed_HZ;
 39 unsigned long __nongprelbss __dsu_clock_speed_HZ;
 40 unsigned long __nongprelbss __serial_clock_speed_HZ;
 41 unsigned long __delay_loops_MHz;
 42 
 43 static irqreturn_t timer_interrupt(int irq, void *dummy);
 44 
 45 static struct irqaction timer_irq  = {
 46         .handler = timer_interrupt,
 47         .name = "timer",
 48 };
 49 
 50 /*
 51  * timer_interrupt() needs to keep up the real-time clock,
 52  * as well as call the "xtime_update()" routine every clocktick
 53  */
 54 static irqreturn_t timer_interrupt(int irq, void *dummy)
 55 {
 56         profile_tick(CPU_PROFILING);
 57 
 58         xtime_update(1);
 59 
 60 #ifdef CONFIG_HEARTBEAT
 61         static unsigned short n;
 62         n++;
 63         __set_LEDS(n);
 64 #endif /* CONFIG_HEARTBEAT */
 65 
 66         update_process_times(user_mode(get_irq_regs()));
 67 
 68         return IRQ_HANDLED;
 69 }
 70 
 71 void time_divisor_init(void)
 72 {
 73         unsigned short base, pre, prediv;
 74 
 75         /* set the scheduling timer going */
 76         pre = 1;
 77         prediv = 4;
 78         base = __res_bus_clock_speed_HZ / pre / HZ / (1 << prediv);
 79 
 80         __set_TPRV(pre);
 81         __set_TxCKSL_DATA(0, prediv);
 82         __set_TCTR(TCTR_SC_CTR0 | TCTR_RL_RW_LH8 | TCTR_MODE_2);
 83         __set_TCSR_DATA(0, base & 0xff);
 84         __set_TCSR_DATA(0, base >> 8);
 85 }
 86 
 87 
 88 void read_persistent_clock(struct timespec *ts)
 89 {
 90         unsigned int year, mon, day, hour, min, sec;
 91 
 92         extern void arch_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec);
 93 
 94         /* FIX by dqg : Set to zero for platforms that don't have tod */
 95         /* without this time is undefined and can overflow time_t, causing  */
 96         /* very strange errors */
 97         year = 1980;
 98         mon = day = 1;
 99         hour = min = sec = 0;
100         arch_gettod (&year, &mon, &day, &hour, &min, &sec);
101 
102         if ((year += 1900) < 1970)
103                 year += 100;
104         ts->tv_sec = mktime(year, mon, day, hour, min, sec);
105         ts->tv_nsec = 0;
106 }
107 
108 void time_init(void)
109 {
110         /* install scheduling interrupt handler */
111         setup_irq(IRQ_CPU_TIMER0, &timer_irq);
112 
113         time_divisor_init();
114 }
115 
116 /*
117  * Scheduler clock - returns current time in nanosec units.
118  */
119 unsigned long long sched_clock(void)
120 {
121         return jiffies_64 * (1000000000 / HZ);
122 }
123 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp