Release 4.11 arch/arm/plat-orion/time.c
/*
* arch/arm/plat-orion/time.c
*
* Marvell Orion SoC timer handling.
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*
* Timer 0 is used as free-running clocksource, while timer 1 is
* used as clock_event_device.
*/
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/clockchips.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/sched_clock.h>
#include <plat/time.h>
#include <asm/delay.h>
/*
* MBus bridge block registers.
*/
#define BRIDGE_CAUSE_OFF 0x0110
#define BRIDGE_MASK_OFF 0x0114
#define BRIDGE_INT_TIMER0 0x0002
#define BRIDGE_INT_TIMER1 0x0004
/*
* Timer block registers.
*/
#define TIMER_CTRL_OFF 0x0000
#define TIMER0_EN 0x0001
#define TIMER0_RELOAD_EN 0x0002
#define TIMER1_EN 0x0004
#define TIMER1_RELOAD_EN 0x0008
#define TIMER0_RELOAD_OFF 0x0010
#define TIMER0_VAL_OFF 0x0014
#define TIMER1_RELOAD_OFF 0x0018
#define TIMER1_VAL_OFF 0x001c
/*
* SoC-specific data.
*/
static void __iomem *bridge_base;
static u32 bridge_timer1_clr_mask;
static void __iomem *timer_base;
/*
* Number of timer ticks per jiffy.
*/
static u32 ticks_per_jiffy;
/*
* Orion's sched_clock implementation. It has a resolution of
* at least 7.5ns (133MHz TCLK).
*/
static u64 notrace orion_read_sched_clock(void)
{
return ~readl(timer_base + TIMER0_VAL_OFF);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 5 | 27.78% | 1 | 16.67% |
Lennert Buytenhek | 4 | 22.22% | 1 | 16.67% |
Nico Pitre | 4 | 22.22% | 1 | 16.67% |
Marc Zyngier | 3 | 16.67% | 1 | 16.67% |
Stephen Boyd | 1 | 5.56% | 1 | 16.67% |
Stefan Agner | 1 | 5.56% | 1 | 16.67% |
Total | 18 | 100.00% | 6 | 100.00% |
/*
* Clockevent handling.
*/
static int
orion_clkevt_next_event(unsigned long delta, struct clock_event_device *dev)
{
unsigned long flags;
u32 u;
if (delta == 0)
return -ETIME;
local_irq_save(flags);
/*
* Clear and enable clockevent timer interrupt.
*/
writel(bridge_timer1_clr_mask, bridge_base + BRIDGE_CAUSE_OFF);
u = readl(bridge_base + BRIDGE_MASK_OFF);
u |= BRIDGE_INT_TIMER1;
writel(u, bridge_base + BRIDGE_MASK_OFF);
/*
* Setup new clockevent timer value.
*/
writel(delta, timer_base + TIMER1_VAL_OFF);
/*
* Enable the timer.
*/
u = readl(timer_base + TIMER_CTRL_OFF);
u = (u & ~TIMER1_RELOAD_EN) | TIMER1_EN;
writel(u, timer_base + TIMER_CTRL_OFF);
local_irq_restore(flags);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Tzachi Perelstein | 60 | 51.28% | 1 | 33.33% |
Lennert Buytenhek | 57 | 48.72% | 2 | 66.67% |
Total | 117 | 100.00% | 3 | 100.00% |
static int orion_clkevt_shutdown(struct clock_event_device *evt)
{
unsigned long flags;
u32 u;
local_irq_save(flags);
/* Disable timer */
u = readl(timer_base + TIMER_CTRL_OFF);
writel(u & ~TIMER1_EN, timer_base + TIMER_CTRL_OFF);
/* Disable timer interrupt */
u = readl(bridge_base + BRIDGE_MASK_OFF);
writel(u & ~BRIDGE_INT_TIMER1, bridge_base + BRIDGE_MASK_OFF);
/* ACK pending timer interrupt */
writel(bridge_timer1_clr_mask, bridge_base + BRIDGE_CAUSE_OFF);
local_irq_restore(flags);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Tzachi Perelstein | 34 | 40.00% | 1 | 25.00% |
Viresh Kumar | 27 | 31.76% | 1 | 25.00% |
Lennert Buytenhek | 24 | 28.24% | 2 | 50.00% |
Total | 85 | 100.00% | 4 | 100.00% |
static int orion_clkevt_set_periodic(struct clock_event_device *evt)
{
unsigned long flags;
u32 u;
local_irq_save(flags);
/* Setup timer to fire at 1/HZ intervals */
writel(ticks_per_jiffy - 1, timer_base + TIMER1_RELOAD_OFF);
writel(ticks_per_jiffy - 1, timer_base + TIMER1_VAL_OFF);
/* Enable timer interrupt */
u = readl(bridge_base + BRIDGE_MASK_OFF);
writel(u | BRIDGE_INT_TIMER1, bridge_base + BRIDGE_MASK_OFF);
/* Enable timer */
u = readl(timer_base + TIMER_CTRL_OFF);
writel(u | TIMER1_EN | TIMER1_RELOAD_EN, timer_base + TIMER_CTRL_OFF);
local_irq_restore(flags);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Viresh Kumar | 53 | 54.08% | 1 | 25.00% |
Lennert Buytenhek | 25 | 25.51% | 2 | 50.00% |
Tzachi Perelstein | 20 | 20.41% | 1 | 25.00% |
Total | 98 | 100.00% | 4 | 100.00% |
static struct clock_event_device orion_clkevt = {
.name = "orion_tick",
.features = CLOCK_EVT_FEAT_ONESHOT |
CLOCK_EVT_FEAT_PERIODIC,
.rating = 300,
.set_next_event = orion_clkevt_next_event,
.set_state_shutdown = orion_clkevt_shutdown,
.set_state_periodic = orion_clkevt_set_periodic,
.set_state_oneshot = orion_clkevt_shutdown,
.tick_resume = orion_clkevt_shutdown,
};
static irqreturn_t orion_timer_interrupt(int irq, void *dev_id)
{
/*
* ACK timer interrupt and call event handler.
*/
writel(bridge_timer1_clr_mask, bridge_base + BRIDGE_CAUSE_OFF);
orion_clkevt.event_handler(&orion_clkevt);
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Tzachi Perelstein | 27 | 79.41% | 1 | 33.33% |
Lennert Buytenhek | 7 | 20.59% | 2 | 66.67% |
Total | 34 | 100.00% | 3 | 100.00% |
static struct irqaction orion_timer_irq = {
.name = "orion_tick",
.flags = IRQF_TIMER,
.handler = orion_timer_interrupt
};
void __init
orion_time_set_base(void __iomem *_timer_base)
{
timer_base = _timer_base;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 11 | 73.33% | 2 | 50.00% |
Thomas Petazzoni | 3 | 20.00% | 1 | 25.00% |
Tzachi Perelstein | 1 | 6.67% | 1 | 25.00% |
Total | 15 | 100.00% | 4 | 100.00% |
static unsigned long orion_delay_timer_read(void)
{
return ~readl(timer_base + TIMER0_VAL_OFF);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 18 | 100.00% | 1 | 100.00% |
Total | 18 | 100.00% | 1 | 100.00% |
static struct delay_timer orion_delay_timer = {
.read_current_timer = orion_delay_timer_read,
};
void __init
orion_time_init(void __iomem *_bridge_base, u32 _bridge_timer1_clr_mask,
unsigned int irq, unsigned int tclk)
{
u32 u;
/*
* Set SoC-specific data.
*/
bridge_base = _bridge_base;
bridge_timer1_clr_mask = _bridge_timer1_clr_mask;
ticks_per_jiffy = (tclk + HZ/2) / HZ;
orion_delay_timer.freq = tclk;
register_current_timer_delay(&orion_delay_timer);
/*
* Set scale and timer for sched_clock.
*/
sched_clock_register(orion_read_sched_clock, 32, tclk);
/*
* Setup free-running clocksource timer (interrupts
* disabled).
*/
writel(0xffffffff, timer_base + TIMER0_VAL_OFF);
writel(0xffffffff, timer_base + TIMER0_RELOAD_OFF);
u = readl(bridge_base + BRIDGE_MASK_OFF);
writel(u & ~BRIDGE_INT_TIMER0, bridge_base + BRIDGE_MASK_OFF);
u = readl(timer_base + TIMER_CTRL_OFF);
writel(u | TIMER0_EN | TIMER0_RELOAD_EN, timer_base + TIMER_CTRL_OFF);
clocksource_mmio_init(timer_base + TIMER0_VAL_OFF, "orion_clocksource",
tclk, 300, 32, clocksource_mmio_readl_down);
/*
* Setup clockevent timer (interrupt-driven).
*/
setup_irq(irq, &orion_timer_irq);
orion_clkevt.cpumask = cpumask_of(0);
clockevents_config_and_register(&orion_clkevt, tclk, 1, 0xfffffffe);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 86 | 48.59% | 2 | 16.67% |
Tzachi Perelstein | 39 | 22.03% | 1 | 8.33% |
Russell King | 26 | 14.69% | 3 | 25.00% |
Rusty Russell | 7 | 3.95% | 1 | 8.33% |
Shawn Guo | 7 | 3.95% | 1 | 8.33% |
Stefan Agner | 4 | 2.26% | 1 | 8.33% |
Marc Zyngier | 4 | 2.26% | 1 | 8.33% |
Thomas Petazzoni | 3 | 1.69% | 1 | 8.33% |
Stephen Boyd | 1 | 0.56% | 1 | 8.33% |
Total | 177 | 100.00% | 12 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lennert Buytenhek | 278 | 37.17% | 2 | 11.76% |
Tzachi Perelstein | 258 | 34.49% | 1 | 5.88% |
Viresh Kumar | 97 | 12.97% | 1 | 5.88% |
Russell King | 65 | 8.69% | 4 | 23.53% |
Stefan Agner | 9 | 1.20% | 1 | 5.88% |
Nico Pitre | 8 | 1.07% | 1 | 5.88% |
Rusty Russell | 7 | 0.94% | 1 | 5.88% |
Shawn Guo | 7 | 0.94% | 1 | 5.88% |
Marc Zyngier | 7 | 0.94% | 1 | 5.88% |
Thomas Petazzoni | 6 | 0.80% | 1 | 5.88% |
Stephen Boyd | 3 | 0.40% | 2 | 11.76% |
Andrew Lunn | 3 | 0.40% | 1 | 5.88% |
Total | 748 | 100.00% | 17 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.