Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: arch_timer: add support to configure and enable event stream

This patch adds support for configuring the event stream frequency
and enabling it.

It also adds the hwcaps definitions to the user to detect this event
stream feature.

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

+27 -4
+25 -4
arch/arm/include/asm/arch_timer.h
··· 87 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 92 u32 cntkctl; 93 - 94 93 asm volatile("mrc p15, 0, %0, c14, c1, 0" : "=r" (cntkctl)); 94 + return cntkctl; 95 + } 96 + 97 + static inline void arch_timer_set_cntkctl(u32 cntkctl) 98 + { 99 + asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl)); 100 + } 101 + 102 + static inline void arch_counter_set_user_access(void) 103 + { 104 + u32 cntkctl = arch_timer_get_cntkctl(); 95 105 96 106 /* Disable user access to both physical/virtual counters/timers */ 97 107 /* Also disable virtual event stream */ ··· 110 100 | ARCH_TIMER_VIRT_EVT_EN 111 101 | ARCH_TIMER_USR_VCT_ACCESS_EN 112 102 | ARCH_TIMER_USR_PCT_ACCESS_EN); 113 - 114 - asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl)); 103 + arch_timer_set_cntkctl(cntkctl); 115 104 } 105 + 106 + static inline void arch_timer_evtstrm_enable(int divider) 107 + { 108 + u32 cntkctl = arch_timer_get_cntkctl(); 109 + cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK; 110 + /* Set the divider and enable virtual event stream */ 111 + cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT) 112 + | ARCH_TIMER_VIRT_EVT_EN; 113 + arch_timer_set_cntkctl(cntkctl); 114 + elf_hwcap |= HWCAP_EVTSTRM; 115 + } 116 + 116 117 #endif 117 118 118 119 #endif
+1
arch/arm/include/uapi/asm/hwcap.h
··· 26 26 #define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */ 27 27 #define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT) 28 28 #define HWCAP_LPAE (1 << 20) 29 + #define HWCAP_EVTSTRM (1 << 21) 29 30 30 31 #endif /* _UAPI__ASMARM_HWCAP_H */
+1
arch/arm/kernel/setup.c
··· 975 975 "idivt", 976 976 "vfpd32", 977 977 "lpae", 978 + "evtstrm", 978 979 NULL 979 980 }; 980 981