18a4da6e3SMark Rutland /* 28a4da6e3SMark Rutland * Copyright (C) 2012 ARM Ltd. 38a4da6e3SMark Rutland * 48a4da6e3SMark Rutland * This program is free software; you can redistribute it and/or modify 58a4da6e3SMark Rutland * it under the terms of the GNU General Public License version 2 as 68a4da6e3SMark Rutland * published by the Free Software Foundation. 78a4da6e3SMark Rutland * 88a4da6e3SMark Rutland * This program is distributed in the hope that it will be useful, 98a4da6e3SMark Rutland * but WITHOUT ANY WARRANTY; without even the implied warranty of 108a4da6e3SMark Rutland * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 118a4da6e3SMark Rutland * GNU General Public License for more details. 128a4da6e3SMark Rutland * 138a4da6e3SMark Rutland * You should have received a copy of the GNU General Public License 148a4da6e3SMark Rutland * along with this program. If not, see <http://www.gnu.org/licenses/>. 158a4da6e3SMark Rutland */ 168a4da6e3SMark Rutland #ifndef __CLKSOURCE_ARM_ARCH_TIMER_H 178a4da6e3SMark Rutland #define __CLKSOURCE_ARM_ARCH_TIMER_H 188a4da6e3SMark Rutland 1974d23cc7SRichard Cochran #include <linux/timecounter.h> 208a4da6e3SMark Rutland #include <linux/types.h> 218a4da6e3SMark Rutland 228a4da6e3SMark Rutland #define ARCH_TIMER_CTRL_ENABLE (1 << 0) 238a4da6e3SMark Rutland #define ARCH_TIMER_CTRL_IT_MASK (1 << 1) 248a4da6e3SMark Rutland #define ARCH_TIMER_CTRL_IT_STAT (1 << 2) 258a4da6e3SMark Rutland 26e09f3cc0SStephen Boyd enum arch_timer_reg { 27e09f3cc0SStephen Boyd ARCH_TIMER_REG_CTRL, 28e09f3cc0SStephen Boyd ARCH_TIMER_REG_TVAL, 29e09f3cc0SStephen Boyd }; 308a4da6e3SMark Rutland 318a4da6e3SMark Rutland #define ARCH_TIMER_PHYS_ACCESS 0 328a4da6e3SMark Rutland #define ARCH_TIMER_VIRT_ACCESS 1 3322006994SStephen Boyd #define ARCH_TIMER_MEM_PHYS_ACCESS 2 3422006994SStephen Boyd #define ARCH_TIMER_MEM_VIRT_ACCESS 3 358a4da6e3SMark Rutland 3628061758SSudeep KarkadaNagesha #define ARCH_TIMER_USR_PCT_ACCESS_EN (1 << 0) /* physical counter */ 3728061758SSudeep KarkadaNagesha #define ARCH_TIMER_USR_VCT_ACCESS_EN (1 << 1) /* virtual counter */ 3828061758SSudeep KarkadaNagesha #define ARCH_TIMER_VIRT_EVT_EN (1 << 2) 3928061758SSudeep KarkadaNagesha #define ARCH_TIMER_EVT_TRIGGER_SHIFT (4) 4028061758SSudeep KarkadaNagesha #define ARCH_TIMER_EVT_TRIGGER_MASK (0xF << ARCH_TIMER_EVT_TRIGGER_SHIFT) 4128061758SSudeep KarkadaNagesha #define ARCH_TIMER_USR_VT_ACCESS_EN (1 << 8) /* virtual timer registers */ 4228061758SSudeep KarkadaNagesha #define ARCH_TIMER_USR_PT_ACCESS_EN (1 << 9) /* physical timer registers */ 4328061758SSudeep KarkadaNagesha 44037f6377SWill Deacon #define ARCH_TIMER_EVT_STREAM_FREQ 10000 /* 100us */ 45037f6377SWill Deacon 468a4da6e3SMark Rutland #ifdef CONFIG_ARM_ARCH_TIMER 478a4da6e3SMark Rutland 488a4da6e3SMark Rutland extern u32 arch_timer_get_rate(void); 4922006994SStephen Boyd extern u64 (*arch_timer_read_counter)(void); 508a4da6e3SMark Rutland extern struct timecounter *arch_timer_get_timecounter(void); 518a4da6e3SMark Rutland 528a4da6e3SMark Rutland #else 538a4da6e3SMark Rutland 548a4da6e3SMark Rutland static inline u32 arch_timer_get_rate(void) 558a4da6e3SMark Rutland { 568a4da6e3SMark Rutland return 0; 578a4da6e3SMark Rutland } 588a4da6e3SMark Rutland 598a4da6e3SMark Rutland static inline u64 arch_timer_read_counter(void) 608a4da6e3SMark Rutland { 618a4da6e3SMark Rutland return 0; 628a4da6e3SMark Rutland } 638a4da6e3SMark Rutland 640582b053SOlof Johansson static inline struct timecounter *arch_timer_get_timecounter(void) 658a4da6e3SMark Rutland { 668a4da6e3SMark Rutland return NULL; 678a4da6e3SMark Rutland } 688a4da6e3SMark Rutland 698a4da6e3SMark Rutland #endif 708a4da6e3SMark Rutland 718a4da6e3SMark Rutland #endif 72