Commit cfb6d656 authored by Thomas Gleixner's avatar Thomas Gleixner

Merge branch 'timers/clockevents-next' of...

Merge branch 'timers/clockevents-next' of git://git.linaro.org/people/dlezcano/clockevents into timers/core

* Support for memory mapped arch_timers
* Trivial fixes to the moxart timer code
* Documentation updates

Trivial conflicts in drivers/clocksource/arm_arch_timer.c. Fixed up
the newly added __cpuinit annotations as well.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parents fac778a2 22006994
* ARM architected timer * ARM architected timer
ARM cores may have a per-core architected timer, which provides per-cpu timers. ARM cores may have a per-core architected timer, which provides per-cpu timers,
or a memory mapped architected timer, which provides up to 8 frames with a
physical and optional virtual timer per frame.
The timer is attached to a GIC to deliver its per-processor interrupts. The per-core architected timer is attached to a GIC to deliver its
per-processor interrupts via PPIs. The memory mapped timer is attached to a GIC
to deliver its interrupts via SPIs.
** Timer node properties: ** CP15 Timer node properties:
- compatible : Should at least contain one of - compatible : Should at least contain one of
"arm,armv7-timer" "arm,armv7-timer"
...@@ -26,3 +30,52 @@ Example: ...@@ -26,3 +30,52 @@ Example:
<1 10 0xf08>; <1 10 0xf08>;
clock-frequency = <100000000>; clock-frequency = <100000000>;
}; };
** Memory mapped timer node properties:
- compatible : Should at least contain "arm,armv7-timer-mem".
- clock-frequency : The frequency of the main counter, in Hz. Optional.
- reg : The control frame base address.
Note that #address-cells, #size-cells, and ranges shall be present to ensure
the CPU can address a frame's registers.
A timer node has up to 8 frame sub-nodes, each with the following properties:
- frame-number: 0 to 7.
- interrupts : Interrupt list for physical and virtual timers in that order.
The virtual timer interrupt is optional.
- reg : The first and second view base addresses in that order. The second view
base address is optional.
- status : "disabled" indicates the frame is not available for use. Optional.
Example:
timer@f0000000 {
compatible = "arm,armv7-timer-mem";
#address-cells = <1>;
#size-cells = <1>;
ranges;
reg = <0xf0000000 0x1000>;
clock-frequency = <50000000>;
frame@f0001000 {
frame-number = <0>
interrupts = <0 13 0x8>,
<0 14 0x8>;
reg = <0xf0001000 0x1000>,
<0xf0002000 0x1000>;
};
frame@f0003000 {
frame-number = <1>
interrupts = <0 15 0x8>;
reg = <0xf0003000 0x1000>;
status = "disabled";
};
};
...@@ -2,10 +2,10 @@ MOXA ART timer ...@@ -2,10 +2,10 @@ MOXA ART timer
Required properties: Required properties:
- compatible : Should be "moxa,moxart-timer" - compatible : Must be "moxa,moxart-timer"
- reg : Should contain registers location and length - reg : Should contain registers location and length
- interrupts : Should contain the timer interrupt number - interrupts : Should contain the timer interrupt number
- clocks : Should contain phandle for APB clock "clkapb" - clocks : Should contain phandle for the clock that drives the counter
Example: Example:
...@@ -13,5 +13,5 @@ Example: ...@@ -13,5 +13,5 @@ Example:
compatible = "moxa,moxart-timer"; compatible = "moxa,moxart-timer";
reg = <0x98400000 0x42>; reg = <0x98400000 0x42>;
interrupts = <19 1>; interrupts = <19 1>;
clocks = <&clkapb>; clocks = <&coreclk>;
}; };
...@@ -17,7 +17,8 @@ int arch_timer_arch_init(void); ...@@ -17,7 +17,8 @@ int arch_timer_arch_init(void);
* nicely work out which register we want, and chuck away the rest of * nicely work out which register we want, and chuck away the rest of
* the code. At least it does so with a recent GCC (4.6.3). * the code. At least it does so with a recent GCC (4.6.3).
*/ */
static inline void arch_timer_reg_write(const int access, const int reg, u32 val) static __always_inline
void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u32 val)
{ {
if (access == ARCH_TIMER_PHYS_ACCESS) { if (access == ARCH_TIMER_PHYS_ACCESS) {
switch (reg) { switch (reg) {
...@@ -28,9 +29,7 @@ static inline void arch_timer_reg_write(const int access, const int reg, u32 val ...@@ -28,9 +29,7 @@ static inline void arch_timer_reg_write(const int access, const int reg, u32 val
asm volatile("mcr p15, 0, %0, c14, c2, 0" : : "r" (val)); asm volatile("mcr p15, 0, %0, c14, c2, 0" : : "r" (val));
break; break;
} }
} } else if (access == ARCH_TIMER_VIRT_ACCESS) {
if (access == ARCH_TIMER_VIRT_ACCESS) {
switch (reg) { switch (reg) {
case ARCH_TIMER_REG_CTRL: case ARCH_TIMER_REG_CTRL:
asm volatile("mcr p15, 0, %0, c14, c3, 1" : : "r" (val)); asm volatile("mcr p15, 0, %0, c14, c3, 1" : : "r" (val));
...@@ -44,7 +43,8 @@ static inline void arch_timer_reg_write(const int access, const int reg, u32 val ...@@ -44,7 +43,8 @@ static inline void arch_timer_reg_write(const int access, const int reg, u32 val
isb(); isb();
} }
static inline u32 arch_timer_reg_read(const int access, const int reg) static __always_inline
u32 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
{ {
u32 val = 0; u32 val = 0;
...@@ -57,9 +57,7 @@ static inline u32 arch_timer_reg_read(const int access, const int reg) ...@@ -57,9 +57,7 @@ static inline u32 arch_timer_reg_read(const int access, const int reg)
asm volatile("mrc p15, 0, %0, c14, c2, 0" : "=r" (val)); asm volatile("mrc p15, 0, %0, c14, c2, 0" : "=r" (val));
break; break;
} }
} } else if (access == ARCH_TIMER_VIRT_ACCESS) {
if (access == ARCH_TIMER_VIRT_ACCESS) {
switch (reg) { switch (reg) {
case ARCH_TIMER_REG_CTRL: case ARCH_TIMER_REG_CTRL:
asm volatile("mrc p15, 0, %0, c14, c3, 1" : "=r" (val)); asm volatile("mrc p15, 0, %0, c14, c3, 1" : "=r" (val));
......
...@@ -26,7 +26,13 @@ ...@@ -26,7 +26,13 @@
#include <clocksource/arm_arch_timer.h> #include <clocksource/arm_arch_timer.h>
static inline void arch_timer_reg_write(int access, int reg, u32 val) /*
* These register accessors are marked inline so the compiler can
* nicely work out which register we want, and chuck away the rest of
* the code.
*/
static __always_inline
void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u32 val)
{ {
if (access == ARCH_TIMER_PHYS_ACCESS) { if (access == ARCH_TIMER_PHYS_ACCESS) {
switch (reg) { switch (reg) {
...@@ -36,8 +42,6 @@ static inline void arch_timer_reg_write(int access, int reg, u32 val) ...@@ -36,8 +42,6 @@ static inline void arch_timer_reg_write(int access, int reg, u32 val)
case ARCH_TIMER_REG_TVAL: case ARCH_TIMER_REG_TVAL:
asm volatile("msr cntp_tval_el0, %0" : : "r" (val)); asm volatile("msr cntp_tval_el0, %0" : : "r" (val));
break; break;
default:
BUILD_BUG();
} }
} else if (access == ARCH_TIMER_VIRT_ACCESS) { } else if (access == ARCH_TIMER_VIRT_ACCESS) {
switch (reg) { switch (reg) {
...@@ -47,17 +51,14 @@ static inline void arch_timer_reg_write(int access, int reg, u32 val) ...@@ -47,17 +51,14 @@ static inline void arch_timer_reg_write(int access, int reg, u32 val)
case ARCH_TIMER_REG_TVAL: case ARCH_TIMER_REG_TVAL:
asm volatile("msr cntv_tval_el0, %0" : : "r" (val)); asm volatile("msr cntv_tval_el0, %0" : : "r" (val));
break; break;
default:
BUILD_BUG();
} }
} else {
BUILD_BUG();
} }
isb(); isb();
} }
static inline u32 arch_timer_reg_read(int access, int reg) static __always_inline
u32 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
{ {
u32 val; u32 val;
...@@ -69,8 +70,6 @@ static inline u32 arch_timer_reg_read(int access, int reg) ...@@ -69,8 +70,6 @@ static inline u32 arch_timer_reg_read(int access, int reg)
case ARCH_TIMER_REG_TVAL: case ARCH_TIMER_REG_TVAL:
asm volatile("mrs %0, cntp_tval_el0" : "=r" (val)); asm volatile("mrs %0, cntp_tval_el0" : "=r" (val));
break; break;
default:
BUILD_BUG();
} }
} else if (access == ARCH_TIMER_VIRT_ACCESS) { } else if (access == ARCH_TIMER_VIRT_ACCESS) {
switch (reg) { switch (reg) {
...@@ -80,11 +79,7 @@ static inline u32 arch_timer_reg_read(int access, int reg) ...@@ -80,11 +79,7 @@ static inline u32 arch_timer_reg_read(int access, int reg)
case ARCH_TIMER_REG_TVAL: case ARCH_TIMER_REG_TVAL:
asm volatile("mrs %0, cntv_tval_el0" : "=r" (val)); asm volatile("mrs %0, cntv_tval_el0" : "=r" (val));
break; break;
default:
BUILD_BUG();
} }
} else {
BUILD_BUG();
} }
return val; return val;
......
This diff is collapsed.
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/clocksource.h> #include <linux/clocksource.h>
#include <linux/bitops.h>
#define TIMER1_BASE 0x00 #define TIMER1_BASE 0x00
#define TIMER2_BASE 0x10 #define TIMER2_BASE 0x10
......
...@@ -23,16 +23,20 @@ ...@@ -23,16 +23,20 @@
#define ARCH_TIMER_CTRL_IT_MASK (1 << 1) #define ARCH_TIMER_CTRL_IT_MASK (1 << 1)
#define ARCH_TIMER_CTRL_IT_STAT (1 << 2) #define ARCH_TIMER_CTRL_IT_STAT (1 << 2)
#define ARCH_TIMER_REG_CTRL 0 enum arch_timer_reg {
#define ARCH_TIMER_REG_TVAL 1 ARCH_TIMER_REG_CTRL,
ARCH_TIMER_REG_TVAL,
};
#define ARCH_TIMER_PHYS_ACCESS 0 #define ARCH_TIMER_PHYS_ACCESS 0
#define ARCH_TIMER_VIRT_ACCESS 1 #define ARCH_TIMER_VIRT_ACCESS 1
#define ARCH_TIMER_MEM_PHYS_ACCESS 2
#define ARCH_TIMER_MEM_VIRT_ACCESS 3
#ifdef CONFIG_ARM_ARCH_TIMER #ifdef CONFIG_ARM_ARCH_TIMER
extern u32 arch_timer_get_rate(void); extern u32 arch_timer_get_rate(void);
extern u64 arch_timer_read_counter(void); extern u64 (*arch_timer_read_counter)(void);
extern struct timecounter *arch_timer_get_timecounter(void); extern struct timecounter *arch_timer_get_timecounter(void);
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment