Select Git revision
time.c 7.48 KiB
/*
* linux/arch/m32r/kernel/time.c
*
* Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata,
* Hitoshi Yamamoto
* Taken from i386 version.
* Copyright (C) 1991, 1992, 1995 Linus Torvalds
* Copyright (C) 1996, 1997, 1998 Ralf Baechle
*
* This file contains the time handling details for PC-style clocks as
* found in some MIPS systems.
*
* Some code taken from sh version.
* Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
* Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
*/
#undef DEBUG_TIMER
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/param.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/profile.h>
#include <asm/io.h>
#include <asm/m32r.h>
#include <asm/hw_irq.h>
#ifdef CONFIG_SMP
extern void smp_local_timer_interrupt(void);
#endif
#define TICK_SIZE (tick_nsec / 1000)
/*
* Change this if you have some constant time drift
*/
/* This is for machines which generate the exact clock. */
#define USECS_PER_JIFFY (1000000/HZ)
static unsigned long latch;
static unsigned long do_gettimeoffset(void)
{
unsigned long elapsed_time = 0; /* [us] */
#if defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_XNUX2) \
|| defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_M32700) \
|| defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104)
#ifndef CONFIG_SMP
unsigned long count;
/* timer count may underflow right here */
count = inl(M32R_MFT2CUT_PORTL);
if (inl(M32R_ICU_CR18_PORTL) & 0x00000100) /* underflow check */
count = 0;
count = (latch - count) * TICK_SIZE;
elapsed_time = (count + latch / 2) / latch;
/* NOTE: LATCH is equal to the "interval" value (= reload count). */