Release 4.14 arch/blackfin/kernel/time-ts.c
/*
* Based on arm clockevents implementation and old bfin time tick.
*
* Copyright 2008-2009 Analog Devics Inc.
* 2008 GeoTechnologies
* Vitja Makarov
*
* Licensed under the GPL-2
*/
#include <linux/module.h>
#include <linux/profile.h>
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/timex.h>
#include <linux/irq.h>
#include <linux/clocksource.h>
#include <linux/clockchips.h>
#include <linux/cpufreq.h>
#include <asm/blackfin.h>
#include <asm/time.h>
#include <asm/gptimers.h>
#include <asm/nmi.h>
#if defined(CONFIG_CYCLES_CLOCKSOURCE)
static notrace u64 bfin_read_cycles(struct clocksource *cs)
{
#ifdef CONFIG_CPU_FREQ
return __bfin_cycles_off + (get_cycles() << __bfin_cycles_mod);
#else
return get_cycles();
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitja Makarov | 13 | 39.39% | 2 | 25.00% |
Graf Yang | 12 | 36.36% | 2 | 25.00% |
Magnus Damm | 4 | 12.12% | 1 | 12.50% |
Mike Frysinger | 2 | 6.06% | 1 | 12.50% |
Yi Li | 1 | 3.03% | 1 | 12.50% |
Thomas Gleixner | 1 | 3.03% | 1 | 12.50% |
Total | 33 | 100.00% | 8 | 100.00% |
static struct clocksource bfin_cs_cycles = {
.name = "bfin_cs_cycles",
.rating = 400,
.read = bfin_read_cycles,
.mask = CLOCKSOURCE_MASK(64),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
static inline unsigned long long bfin_cs_cycles_sched_clock(void)
{
return clocksource_cyc2ns(bfin_read_cycles(&bfin_cs_cycles),
bfin_cs_cycles.mult, bfin_cs_cycles.shift);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Magnus Damm | 15 | 51.72% | 1 | 25.00% |
Mike Frysinger | 9 | 31.03% | 1 | 25.00% |
Yi Li | 3 | 10.34% | 1 | 25.00% |
Graf Yang | 2 | 6.90% | 1 | 25.00% |
Total | 29 | 100.00% | 4 | 100.00% |
static int __init bfin_cs_cycles_init(void)
{
if (clocksource_register_hz(&bfin_cs_cycles, get_cclk()))
panic("failed to register clocksource");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 17 | 60.71% | 1 | 33.33% |
Vitja Makarov | 7 | 25.00% | 1 | 33.33% |
John Stultz | 4 | 14.29% | 1 | 33.33% |
Total | 28 | 100.00% | 3 | 100.00% |
#else
# define bfin_cs_cycles_init()
#endif
#ifdef CONFIG_GPTMR0_CLOCKSOURCE
void __init setup_gptimer0(void)
{
disable_gptimers(TIMER0bit);
#ifdef CONFIG_BF60x
bfin_write16(TIMER_DATA_IMSK, 0);
set_gptimer_config(TIMER0_id, TIMER_OUT_DIS
| TIMER_MODE_PWM_CONT | TIMER_PULSE_HI | TIMER_IRQ_PER);
#else
set_gptimer_config(TIMER0_id, \
TIMER_OUT_DIS | TIMER_PERIOD_CNT | TIMER_MODE_PWM);
#endif
set_gptimer_period(TIMER0_id, -1);
set_gptimer_pwidth(TIMER0_id, -2);
SSYNC();
enable_gptimers(TIMER0bit);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 48 | 64.00% | 1 | 50.00% |
Steven Miao | 27 | 36.00% | 1 | 50.00% |
Total | 75 | 100.00% | 2 | 100.00% |
static u64 bfin_read_gptimer0(struct clocksource *cs)
{
return bfin_read_TIMER0_COUNTER();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 10 | 66.67% | 1 | 33.33% |
Yi Li | 4 | 26.67% | 1 | 33.33% |
Thomas Gleixner | 1 | 6.67% | 1 | 33.33% |
Total | 15 | 100.00% | 3 | 100.00% |
static struct clocksource bfin_cs_gptimer0 = {
.name = "bfin_cs_gptimer0",
.rating = 350,
.read = bfin_read_gptimer0,
.mask = CLOCKSOURCE_MASK(32),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
static inline unsigned long long bfin_cs_gptimer0_sched_clock(void)
{
return clocksource_cyc2ns(bfin_read_TIMER0_COUNTER(),
bfin_cs_gptimer0.mult, bfin_cs_gptimer0.shift);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 17 | 65.38% | 1 | 50.00% |
Mike Frysinger | 9 | 34.62% | 1 | 50.00% |
Total | 26 | 100.00% | 2 | 100.00% |
static int __init bfin_cs_gptimer0_init(void)
{
setup_gptimer0();
if (clocksource_register_hz(&bfin_cs_gptimer0, get_sclk()))
panic("failed to register clocksource");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 27 | 87.10% | 1 | 50.00% |
John Stultz | 4 | 12.90% | 1 | 50.00% |
Total | 31 | 100.00% | 2 | 100.00% |
#else
# define bfin_cs_gptimer0_init()
#endif
#if defined(CONFIG_GPTMR0_CLOCKSOURCE) || defined(CONFIG_CYCLES_CLOCKSOURCE)
/* prefer to use cycles since it has higher rating */
notrace unsigned long long sched_clock(void)
{
#if defined(CONFIG_CYCLES_CLOCKSOURCE)
return bfin_cs_cycles_sched_clock();
#else
return bfin_cs_gptimer0_sched_clock();
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 28 | 100.00% | 1 | 100.00% |
Total | 28 | 100.00% | 1 | 100.00% |
#endif
#if defined(CONFIG_TICKSOURCE_GPTMR0)
static int bfin_gptmr0_set_next_event(unsigned long cycles,
struct clock_event_device *evt)
{
disable_gptimers(TIMER0bit);
/* it starts counting three SCLK cycles after the TIMENx bit is set */
set_gptimer_pwidth(TIMER0_id, cycles - 3);
enable_gptimers(TIMER0bit);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 37 | 97.37% | 1 | 50.00% |
Yi Li | 1 | 2.63% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
static int bfin_gptmr0_set_periodic(struct clock_event_device *evt)
{
#ifndef CONFIG_BF60x
set_gptimer_config(TIMER0_id,
TIMER_OUT_DIS | TIMER_IRQ_ENA |
TIMER_PERIOD_CNT | TIMER_MODE_PWM);
#else
set_gptimer_config(TIMER0_id,
TIMER_OUT_DIS | TIMER_MODE_PWM_CONT |
TIMER_PULSE_HI | TIMER_IRQ_PER);
#endif
set_gptimer_period(TIMER0_id, get_sclk() / HZ);
set_gptimer_pwidth(TIMER0_id, get_sclk() / HZ - 1);
enable_gptimers(TIMER0bit);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 48 | 64.86% | 1 | 33.33% |
Steven Miao | 20 | 27.03% | 1 | 33.33% |
Viresh Kumar | 6 | 8.11% | 1 | 33.33% |
Total | 74 | 100.00% | 3 | 100.00% |
static int bfin_gptmr0_set_oneshot(struct clock_event_device *evt)
{
disable_gptimers(TIMER0bit);
#ifndef CONFIG_BF60x
set_gptimer_config(TIMER0_id,
TIMER_OUT_DIS | TIMER_IRQ_ENA | TIMER_MODE_PWM);
#else
set_gptimer_config(TIMER0_id,
TIMER_OUT_DIS | TIMER_MODE_PWM | TIMER_PULSE_HI |
TIMER_IRQ_WID_DLY);
#endif
set_gptimer_period(TIMER0_id, 0);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 22 | 38.60% | 1 | 33.33% |
Steven Miao | 20 | 35.09% | 1 | 33.33% |
Viresh Kumar | 15 | 26.32% | 1 | 33.33% |
Total | 57 | 100.00% | 3 | 100.00% |
static int bfin_gptmr0_shutdown(struct clock_event_device *evt)
{
disable_gptimers(TIMER0bit);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Viresh Kumar | 13 | 68.42% | 1 | 50.00% |
Graf Yang | 6 | 31.58% | 1 | 50.00% |
Total | 19 | 100.00% | 2 | 100.00% |
static void bfin_gptmr0_ack(void)
{
clear_gptimer_intr(TIMER0_id);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 10 | 76.92% | 1 | 33.33% |
Steven Miao | 2 | 15.38% | 1 | 33.33% |
Yi Li | 1 | 7.69% | 1 | 33.33% |
Total | 13 | 100.00% | 3 | 100.00% |
static void __init bfin_gptmr0_init(void)
{
disable_gptimers(TIMER0bit);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 11 | 78.57% | 1 | 33.33% |
Vitja Makarov | 2 | 14.29% | 1 | 33.33% |
Yi Li | 1 | 7.14% | 1 | 33.33% |
Total | 14 | 100.00% | 3 | 100.00% |
#ifdef CONFIG_CORE_TIMER_IRQ_L1
__attribute__((l1_text))
#endif
irqreturn_t bfin_gptmr0_interrupt(int irq, void *dev_id)
{
struct clock_event_device *evt = dev_id;
smp_mb();
/*
* We want to ACK before we handle so that we can handle smaller timer
* intervals. This way if the timer expires again while we're handling
* things, we're more likely to see that 2nd int rather than swallowing
* it by ACKing the int at the end of this handler.
*/
bfin_gptmr0_ack();
evt->event_handler(evt);
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 24 | 66.67% | 1 | 25.00% |
Mike Frysinger | 4 | 11.11% | 1 | 25.00% |
Vitja Makarov | 4 | 11.11% | 1 | 25.00% |
Graf Yang | 4 | 11.11% | 1 | 25.00% |
Total | 36 | 100.00% | 4 | 100.00% |
static struct irqaction gptmr0_irq = {
.name = "Blackfin GPTimer0",
.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_PERCPU,
.handler = bfin_gptmr0_interrupt,
};
static struct clock_event_device clockevent_gptmr0 = {
.name = "bfin_gptimer0",
.rating = 300,
.irq = IRQ_TIMER0,
.shift = 32,
.features = CLOCK_EVT_FEAT_PERIODIC |
CLOCK_EVT_FEAT_ONESHOT,
.set_next_event = bfin_gptmr0_set_next_event,
.set_state_shutdown = bfin_gptmr0_shutdown,
.set_state_periodic = bfin_gptmr0_set_periodic,
.set_state_oneshot = bfin_gptmr0_set_oneshot,
};
static void __init bfin_gptmr0_clockevent_init(struct clock_event_device *evt)
{
unsigned long clock_tick;
clock_tick = get_sclk();
evt->mult = div_sc(clock_tick, NSEC_PER_SEC, evt->shift);
evt->max_delta_ns = clockevent_delta2ns(-1, evt);
evt->max_delta_ticks = (unsigned long)-1;
evt->min_delta_ns = clockevent_delta2ns(100, evt);
evt->min_delta_ticks = 100;
evt->cpumask = cpumask_of(0);
clockevents_register_device(evt);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 70 | 77.78% | 1 | 25.00% |
Nicolai Stange | 17 | 18.89% | 1 | 25.00% |
Graf Yang | 2 | 2.22% | 1 | 25.00% |
Vitja Makarov | 1 | 1.11% | 1 | 25.00% |
Total | 90 | 100.00% | 4 | 100.00% |
#endif /* CONFIG_TICKSOURCE_GPTMR0 */
#if defined(CONFIG_TICKSOURCE_CORETMR)
/* per-cpu local core timer */
DEFINE_PER_CPU(struct clock_event_device, coretmr_events);
static int bfin_coretmr_set_next_event(unsigned long cycles,
struct clock_event_device *evt)
{
bfin_write_TCNTL(TMPWR);
CSYNC();
bfin_write_TCOUNT(cycles);
CSYNC();
bfin_write_TCNTL(TMPWR | TMREN);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitja Makarov | 25 | 60.98% | 1 | 33.33% |
Graf Yang | 15 | 36.59% | 1 | 33.33% |
Yi Li | 1 | 2.44% | 1 | 33.33% |
Total | 41 | 100.00% | 3 | 100.00% |
static int bfin_coretmr_set_periodic(struct clock_event_device *evt)
{
unsigned long tcount = ((get_cclk() / (HZ * TIME_SCALE)) - 1);
bfin_write_TCNTL(TMPWR);
CSYNC();
bfin_write_TSCALE(TIME_SCALE - 1);
bfin_write_TPERIOD(tcount);
bfin_write_TCOUNT(tcount);
CSYNC();
bfin_write_TCNTL(TMPWR | TMREN | TAUTORLD);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitja Makarov | 51 | 72.86% | 1 | 25.00% |
Michael Hennerich | 8 | 11.43% | 1 | 25.00% |
Graf Yang | 6 | 8.57% | 1 | 25.00% |
Viresh Kumar | 5 | 7.14% | 1 | 25.00% |
Total | 70 | 100.00% | 4 | 100.00% |
static int bfin_coretmr_set_oneshot(struct clock_event_device *evt)
{
bfin_write_TCNTL(TMPWR);
CSYNC();
bfin_write_TSCALE(TIME_SCALE - 1);
bfin_write_TPERIOD(0);
bfin_write_TCOUNT(0);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Viresh Kumar | 14 | 35.90% | 1 | 20.00% |
Graf Yang | 11 | 28.21% | 1 | 20.00% |
Vitja Makarov | 10 | 25.64% | 2 | 40.00% |
Michael Hennerich | 4 | 10.26% | 1 | 20.00% |
Total | 39 | 100.00% | 5 | 100.00% |
static int bfin_coretmr_shutdown(struct clock_event_device *evt)
{
bfin_write_TCNTL(0);
CSYNC();
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Viresh Kumar | 13 | 59.09% | 1 | 33.33% |
Vitja Makarov | 8 | 36.36% | 1 | 33.33% |
Yi Li | 1 | 4.55% | 1 | 33.33% |
Total | 22 | 100.00% | 3 | 100.00% |
void bfin_coretmr_init(void)
{
/* 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);
bfin_write_TPERIOD(0);
bfin_write_TCOUNT(0);
CSYNC();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitja Makarov | 32 | 86.49% | 1 | 33.33% |
Michael Hennerich | 3 | 8.11% | 1 | 33.33% |
Yi Li | 2 | 5.41% | 1 | 33.33% |
Total | 37 | 100.00% | 3 | 100.00% |
#ifdef CONFIG_CORE_TIMER_IRQ_L1
__attribute__((l1_text))
#endif
irqreturn_t bfin_coretmr_interrupt(int irq, void *dev_id)
{
int cpu = smp_processor_id();
struct clock_event_device *evt = &per_cpu(coretmr_events, cpu);
smp_mb();
evt->event_handler(evt);
touch_nmi_watchdog();
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitja Makarov | 27 | 57.45% | 1 | 25.00% |
Yi Li | 14 | 29.79% | 1 | 25.00% |
Graf Yang | 6 | 12.77% | 2 | 50.00% |
Total | 47 | 100.00% | 4 | 100.00% |
static struct irqaction coretmr_irq = {
.name = "Blackfin CoreTimer",
.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_PERCPU,
.handler = bfin_coretmr_interrupt,
};
void bfin_coretmr_clockevent_init(void)
{
unsigned long clock_tick;
unsigned int cpu = smp_processor_id();
struct clock_event_device *evt = &per_cpu(coretmr_events, cpu);
#ifdef CONFIG_SMP
evt->broadcast = smp_timer_broadcast;
#endif
evt->name = "bfin_core_timer";
evt->rating = 350;
evt->irq = -1;
evt->shift = 32;
evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
evt->set_next_event = bfin_coretmr_set_next_event;
evt->set_state_shutdown = bfin_coretmr_shutdown;
evt->set_state_periodic = bfin_coretmr_set_periodic;
evt->set_state_oneshot = bfin_coretmr_set_oneshot;
clock_tick = get_cclk() / TIME_SCALE;
evt->mult = div_sc(clock_tick, NSEC_PER_SEC, evt->shift);
evt->max_delta_ns = clockevent_delta2ns(-1, evt);
evt->max_delta_ticks = (unsigned long)-1;
evt->min_delta_ns = clockevent_delta2ns(100, evt);
evt->min_delta_ticks = 100;
evt->cpumask = cpumask_of(cpu);
clockevents_register_device(evt);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 84 | 48.00% | 1 | 14.29% |
Vitja Makarov | 43 | 24.57% | 2 | 28.57% |
Nicolai Stange | 17 | 9.71% | 1 | 14.29% |
Viresh Kumar | 14 | 8.00% | 1 | 14.29% |
Bob Liu | 11 | 6.29% | 1 | 14.29% |
Rusty Russell | 6 | 3.43% | 1 | 14.29% |
Total | 175 | 100.00% | 7 | 100.00% |
#endif /* CONFIG_TICKSOURCE_CORETMR */
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 |
Vitja Makarov | 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_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
bfin_cs_cycles_init();
bfin_cs_gptimer0_init();
#if defined(CONFIG_TICKSOURCE_CORETMR)
bfin_coretmr_init();
setup_irq(IRQ_CORETMR, &coretmr_irq);
bfin_coretmr_clockevent_init();
#endif
#if defined(CONFIG_TICKSOURCE_GPTMR0)
bfin_gptmr0_init();
setup_irq(IRQ_TIMER0, &gptmr0_irq);
gptmr0_irq.dev_id = &clockevent_gptmr0;
bfin_gptmr0_clockevent_init(&clockevent_gptmr0);
#endif
#if !defined(CONFIG_TICKSOURCE_CORETMR) && !defined(CONFIG_TICKSOURCE_GPTMR0)
# error at least one clock event device is required
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 70 | 60.34% | 1 | 25.00% |
Vitja Makarov | 35 | 30.17% | 1 | 25.00% |
John Stultz | 7 | 6.03% | 1 | 25.00% |
Graf Yang | 4 | 3.45% | 1 | 25.00% |
Total | 116 | 100.00% | 4 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 470 | 31.48% | 3 | 13.04% |
Graf Yang | 368 | 24.65% | 4 | 17.39% |
Vitja Makarov | 340 | 22.77% | 2 | 8.70% |
Viresh Kumar | 92 | 6.16% | 1 | 4.35% |
Steven Miao | 69 | 4.62% | 1 | 4.35% |
Nicolai Stange | 34 | 2.28% | 1 | 4.35% |
John Stultz | 33 | 2.21% | 2 | 8.70% |
Mike Frysinger | 27 | 1.81% | 3 | 13.04% |
Michael Hennerich | 21 | 1.41% | 1 | 4.35% |
Magnus Damm | 19 | 1.27% | 1 | 4.35% |
Bob Liu | 11 | 0.74% | 1 | 4.35% |
Rusty Russell | 6 | 0.40% | 1 | 4.35% |
Thomas Gleixner | 2 | 0.13% | 1 | 4.35% |
Robin Getz | 1 | 0.07% | 1 | 4.35% |
Total | 1493 | 100.00% | 23 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.