Release 4.14 arch/blackfin/kernel/time.c
/*
* arch/blackfin/kernel/time.c
*
* This file contains the Blackfin-specific time handling details.
* Most of the stuff is located in the machine specific files.
*
* Copyright 2004-2008 Analog Devices Inc.
* Licensed under the GPL-2 or later.
*/
#include <linux/module.h>
#include <linux/profile.h>
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/irq.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <asm/blackfin.h>
#include <asm/time.h>
#include <asm/gptimers.h>
/* This is an NTP setting */
#define TICK_SIZE (tick_nsec / 1000)
static struct irqaction bfin_timer_irq = {
.name = "Blackfin Timer Tick",
};
#if defined(CONFIG_IPIPE)
void __init setup_system_timer0(void)
{
/* Power down the core timer, just to play safe. */
bfin_write_TCNTL(0);
disable_gptimers(TIMER0bit);
set_gptimer_status(0, TIMER_STATUS_TRUN0);
while (get_gptimer_status(0) & TIMER_STATUS_TRUN0)
udelay(10);
set_gptimer_config(0, 0x59); /* IRQ enable, periodic, PWM_OUT, SCLKed, OUT PAD disabled */
set_gptimer_period(TIMER0_id, get_sclk() / HZ);
set_gptimer_pwidth(TIMER0_id, 1);
SSYNC();
enable_gptimers(TIMER0bit);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 72 | 98.63% | 1 | 50.00% |
Mike Frysinger | 1 | 1.37% | 1 | 50.00% |
Total | 73 | 100.00% | 2 | 100.00% |
#else
void __init setup_core_timer(void)
{
u32 tcount;
/* power up the timer, but don't enable it just yet */
bfin_write_TCNTL(TMPWR);
CSYNC();
/* the TSCALE prescaler counter */
bfin_write_TSCALE(TIME_SCALE - 1);
tcount = ((get_cclk() / (HZ * TIME_SCALE)) - 1);
bfin_write_TPERIOD(tcount);
bfin_write_TCOUNT(tcount);
/* now enable the timer */
CSYNC();
bfin_write_TCNTL(TAUTORLD | TMREN | TMPWR);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Mike Frysinger | 68 | 100.00% | 3 | 100.00% |
Total | 68 | 100.00% | 3 | 100.00% |
#endif
static void __init
time_sched_init(irqreturn_t(*timer_routine) (int, void *))
{
#if defined(CONFIG_IPIPE)
setup_system_timer0();
bfin_timer_irq.handler = timer_routine;
setup_irq(IRQ_TIMER0, &bfin_timer_irq);
#else
setup_core_timer();
bfin_timer_irq.handler = timer_routine;
setup_irq(IRQ_CORETMR, &bfin_timer_irq);
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 32 | 50.79% | 1 | 20.00% |
Bryan Wu | 15 | 23.81% | 1 | 20.00% |
Mike Frysinger | 10 | 15.87% | 2 | 40.00% |
Yi Li | 6 | 9.52% | 1 | 20.00% |
Total | 63 | 100.00% | 5 | 100.00% |
#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
/*
* Should return useconds since last timer tick
*/
static u32 blackfin_gettimeoffset(void)
{
unsigned long offset;
unsigned long clocks_per_jiffy;
#if defined(CONFIG_IPIPE)
clocks_per_jiffy = bfin_read_TIMER0_PERIOD();
offset = bfin_read_TIMER0_COUNTER() / \
(((clocks_per_jiffy + 1) * HZ) / USEC_PER_SEC);
if ((get_gptimer_status(0) & TIMER_STATUS_TIMIL0) && offset < (100000 / HZ / 2))
offset += (USEC_PER_SEC / HZ);
#else
clocks_per_jiffy = bfin_read_TPERIOD();
offset = (clocks_per_jiffy - bfin_read_TCOUNT()) / \
(((clocks_per_jiffy + 1) * HZ) / USEC_PER_SEC);
/* Check if we just wrapped the counters and maybe missed a tick */
if ((bfin_read_ILAT() & (1 << IRQ_CORETMR))
&& (offset < (100000 / HZ / 2)))
offset += (USEC_PER_SEC / HZ);
#endif
return offset;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 78 | 53.42% | 1 | 20.00% |
Graf Yang | 59 | 40.41% | 1 | 20.00% |
Yi Li | 6 | 4.11% | 1 | 20.00% |
Stephen Warren | 2 | 1.37% | 1 | 20.00% |
John Stultz | 1 | 0.68% | 1 | 20.00% |
Total | 146 | 100.00% | 5 | 100.00% |
#endif
/*
* timer_interrupt() needs to keep up the real-time clock,
* as well as call the "xtime_update()" routine every clocktick
*/
#ifdef CONFIG_CORE_TIMER_IRQ_L1
__attribute__((l1_text))
#endif
irqreturn_t timer_interrupt(int irq, void *dummy)
{
xtime_update(1);
#ifdef CONFIG_IPIPE
update_root_process_times(get_irq_regs());
#else
update_process_times(user_mode(get_irq_regs()));
#endif
profile_tick(CPU_PROFILING);
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 18 | 38.30% | 1 | 20.00% |
Yi Li | 13 | 27.66% | 1 | 20.00% |
Peter Zijlstra | 9 | 19.15% | 1 | 20.00% |
Graf Yang | 6 | 12.77% | 1 | 20.00% |
Torben Hohn | 1 | 2.13% | 1 | 20.00% |
Total | 47 | 100.00% | 5 | 100.00% |
void read_persistent_clock(struct timespec *ts)
{
time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */
ts->tv_sec = secs_since_1970;
ts->tv_nsec = 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 22 | 55.00% | 1 | 50.00% |
John Stultz | 18 | 45.00% | 1 | 50.00% |
Total | 40 | 100.00% | 2 | 100.00% |
void __init time_init(void)
{
#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
arch_gettimeoffset = blackfin_gettimeoffset;
#endif
#ifdef CONFIG_RTC_DRV_BFIN
/* [#2663] hack to filter junk RTC values that would cause
* userspace to have to deal with time values greater than
* 2^31 seconds (which uClibc cannot cope with yet)
*/
if ((bfin_read_RTC_STAT() & 0xC0000000) == 0xC0000000) {
printk(KERN_NOTICE "bfin-rtc: invalid date; resetting\n");
bfin_write_RTC_STAT(0);
}
#endif
time_sched_init(timer_interrupt);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 36 | 69.23% | 1 | 33.33% |
Stephen Warren | 9 | 17.31% | 1 | 33.33% |
John Stultz | 7 | 13.46% | 1 | 33.33% |
Total | 52 | 100.00% | 3 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 208 | 36.94% | 1 | 7.14% |
Graf Yang | 177 | 31.44% | 1 | 7.14% |
Mike Frysinger | 89 | 15.81% | 3 | 21.43% |
Yi Li | 31 | 5.51% | 1 | 7.14% |
John Stultz | 29 | 5.15% | 2 | 14.29% |
Stephen Warren | 11 | 1.95% | 1 | 7.14% |
Peter Zijlstra | 9 | 1.60% | 1 | 7.14% |
Michael Hennerich | 3 | 0.53% | 1 | 7.14% |
Alexey Dobriyan | 3 | 0.53% | 1 | 7.14% |
Torben Hohn | 2 | 0.36% | 1 | 7.14% |
Yong Zhang | 1 | 0.18% | 1 | 7.14% |
Total | 563 | 100.00% | 14 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.