aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/arch_timer.c
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2012-11-12 11:18:00 -0500
committerMark Rutland <mark.rutland@arm.com>2013-01-31 10:51:22 -0500
commitec944c93a293bee6b4cc6b6f1c9560526c7ed635 (patch)
tree564dda7943e789ade94ec3aa4a4c70fa3204da5c /arch/arm/kernel/arch_timer.c
parentfd5583a4c271ec03e2da04196aaaab177b385eb8 (diff)
arm: arch_timer: factor out register accessors
Currently the arch_timer register accessors are thrown together with the main driver, preventing us from porting the driver to other architectures. This patch moves the register accessors into a header file, as with the arm64 version. Constants required by the accessors are also moved. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Diffstat (limited to 'arch/arm/kernel/arch_timer.c')
-rw-r--r--arch/arm/kernel/arch_timer.c92
1 files changed, 0 insertions, 92 deletions
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index f31c9ee18af2..e973cc0eaad1 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -46,98 +46,6 @@ static bool arch_timer_use_virtual = true;
46 * Architected system timer support. 46 * Architected system timer support.
47 */ 47 */
48 48
49#define ARCH_TIMER_CTRL_ENABLE (1 << 0)
50#define ARCH_TIMER_CTRL_IT_MASK (1 << 1)
51#define ARCH_TIMER_CTRL_IT_STAT (1 << 2)
52
53#define ARCH_TIMER_REG_CTRL 0
54#define ARCH_TIMER_REG_TVAL 1
55
56#define ARCH_TIMER_PHYS_ACCESS 0
57#define ARCH_TIMER_VIRT_ACCESS 1
58
59/*
60 * These register accessors are marked inline so the compiler can
61 * nicely work out which register we want, and chuck away the rest of
62 * the code. At least it does so with a recent GCC (4.6.3).
63 */
64static inline void arch_timer_reg_write(const int access, const int reg, u32 val)
65{
66 if (access == ARCH_TIMER_PHYS_ACCESS) {
67 switch (reg) {
68 case ARCH_TIMER_REG_CTRL:
69 asm volatile("mcr p15, 0, %0, c14, c2, 1" : : "r" (val));
70 break;
71 case ARCH_TIMER_REG_TVAL:
72 asm volatile("mcr p15, 0, %0, c14, c2, 0" : : "r" (val));
73 break;
74 }
75 }
76
77 if (access == ARCH_TIMER_VIRT_ACCESS) {
78 switch (reg) {
79 case ARCH_TIMER_REG_CTRL:
80 asm volatile("mcr p15, 0, %0, c14, c3, 1" : : "r" (val));
81 break;
82 case ARCH_TIMER_REG_TVAL:
83 asm volatile("mcr p15, 0, %0, c14, c3, 0" : : "r" (val));
84 break;
85 }
86 }
87
88 isb();
89}
90
91static inline u32 arch_timer_reg_read(const int access, const int reg)
92{
93 u32 val = 0;
94
95 if (access == ARCH_TIMER_PHYS_ACCESS) {
96 switch (reg) {
97 case ARCH_TIMER_REG_CTRL:
98 asm volatile("mrc p15, 0, %0, c14, c2, 1" : "=r" (val));
99 break;
100 case ARCH_TIMER_REG_TVAL:
101 asm volatile("mrc p15, 0, %0, c14, c2, 0" : "=r" (val));
102 break;
103 }
104 }
105
106 if (access == ARCH_TIMER_VIRT_ACCESS) {
107 switch (reg) {
108 case ARCH_TIMER_REG_CTRL:
109 asm volatile("mrc p15, 0, %0, c14, c3, 1" : "=r" (val));
110 break;
111 case ARCH_TIMER_REG_TVAL:
112 asm volatile("mrc p15, 0, %0, c14, c3, 0" : "=r" (val));
113 break;
114 }
115 }
116
117 return val;
118}
119
120static inline u32 arch_timer_get_cntfrq(void)
121{
122 u32 val;
123 asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (val));
124 return val;
125}
126
127static inline u64 arch_counter_get_cntpct(void)
128{
129 u64 cval;
130 asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (cval));
131 return cval;
132}
133
134static inline u64 arch_counter_get_cntvct(void)
135{
136 u64 cval;
137 asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (cval));
138 return cval;
139}
140
141static irqreturn_t inline timer_handler(const int access, 49static irqreturn_t inline timer_handler(const int access,
142 struct clock_event_device *evt) 50 struct clock_event_device *evt)
143{ 51{