diff options
Diffstat (limited to 'arch/arm/include/asm/arch_timer.h')
-rw-r--r-- | arch/arm/include/asm/arch_timer.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h index 5665134bfa3e..0704e0cf5571 100644 --- a/arch/arm/include/asm/arch_timer.h +++ b/arch/arm/include/asm/arch_timer.h | |||
@@ -87,17 +87,43 @@ static inline u64 arch_counter_get_cntvct(void) | |||
87 | return cval; | 87 | return cval; |
88 | } | 88 | } |
89 | 89 | ||
90 | static inline void arch_counter_set_user_access(void) | 90 | static inline u32 arch_timer_get_cntkctl(void) |
91 | { | 91 | { |
92 | u32 cntkctl; | 92 | u32 cntkctl; |
93 | |||
94 | asm volatile("mrc p15, 0, %0, c14, c1, 0" : "=r" (cntkctl)); | 93 | asm volatile("mrc p15, 0, %0, c14, c1, 0" : "=r" (cntkctl)); |
94 | return cntkctl; | ||
95 | } | ||
95 | 96 | ||
96 | /* disable user access to everything */ | 97 | static inline void arch_timer_set_cntkctl(u32 cntkctl) |
97 | cntkctl &= ~((3 << 8) | (7 << 0)); | 98 | { |
98 | |||
99 | asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl)); | 99 | asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl)); |
100 | } | 100 | } |
101 | |||
102 | static inline void arch_counter_set_user_access(void) | ||
103 | { | ||
104 | u32 cntkctl = arch_timer_get_cntkctl(); | ||
105 | |||
106 | /* Disable user access to both physical/virtual counters/timers */ | ||
107 | /* Also disable virtual event stream */ | ||
108 | cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN | ||
109 | | ARCH_TIMER_USR_VT_ACCESS_EN | ||
110 | | ARCH_TIMER_VIRT_EVT_EN | ||
111 | | ARCH_TIMER_USR_VCT_ACCESS_EN | ||
112 | | ARCH_TIMER_USR_PCT_ACCESS_EN); | ||
113 | arch_timer_set_cntkctl(cntkctl); | ||
114 | } | ||
115 | |||
116 | static inline void arch_timer_evtstrm_enable(int divider) | ||
117 | { | ||
118 | u32 cntkctl = arch_timer_get_cntkctl(); | ||
119 | cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK; | ||
120 | /* Set the divider and enable virtual event stream */ | ||
121 | cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT) | ||
122 | | ARCH_TIMER_VIRT_EVT_EN; | ||
123 | arch_timer_set_cntkctl(cntkctl); | ||
124 | elf_hwcap |= HWCAP_EVTSTRM; | ||
125 | } | ||
126 | |||
101 | #endif | 127 | #endif |
102 | 128 | ||
103 | #endif | 129 | #endif |