In order to easily use get_tb() from C VDSO, move timebase functions into a new header named asm/timebase.h Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx> --- v13: new --- arch/powerpc/include/asm/time.h | 30 +-------------------- arch/powerpc/include/asm/timebase.h | 42 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 arch/powerpc/include/asm/timebase.h diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 2f566c1a754c..46d0d65cda0e 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -15,6 +15,7 @@ #include <asm/processor.h> #include <asm/cpu_has_feature.h> +#include <asm/timebase.h> /* time.c */ extern unsigned long tb_ticks_per_jiffy; @@ -38,12 +39,6 @@ struct div_result { u64 result_low; }; -/* For compatibility, get_tbl() is defined as get_tb() on ppc64 */ -static inline unsigned long get_tbl(void) -{ - return mftb(); -} - static inline u64 get_vtb(void) { #ifdef CONFIG_PPC_BOOK3S_64 @@ -53,29 +48,6 @@ static inline u64 get_vtb(void) return 0; } -static inline u64 get_tb(void) -{ - unsigned int tbhi, tblo, tbhi2; - - if (IS_ENABLED(CONFIG_PPC64)) - return mftb(); - - do { - tbhi = mftbu(); - tblo = mftb(); - tbhi2 = mftbu(); - } while (tbhi != tbhi2); - - return ((u64)tbhi << 32) | tblo; -} - -static inline void set_tb(unsigned int upper, unsigned int lower) -{ - mtspr(SPRN_TBWL, 0); - mtspr(SPRN_TBWU, upper); - mtspr(SPRN_TBWL, lower); -} - /* Accessor functions for the decrementer register. * The 4xx doesn't even have a decrementer. I tried to use the * generic timer interrupt code, which seems OK, with the 4xx PIT diff --git a/arch/powerpc/include/asm/timebase.h b/arch/powerpc/include/asm/timebase.h new file mode 100644 index 000000000000..a8eae3adaa91 --- /dev/null +++ b/arch/powerpc/include/asm/timebase.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Common timebase prototypes and such for all ppc machines. + * + * Written by Cort Dougan (cort@xxxxxxxxxx) to merge + * Paul Mackerras' version and mine for PReP and Pmac. + */ + +#ifndef __POWERPC_TIMEBASE_H +#define __POWERPC_TIMEBASE_H + +#include <asm/reg.h> + +/* For compatibility, get_tbl() is defined as get_tb() on ppc64 */ +static inline unsigned long get_tbl(void) +{ + return mftb(); +} + +static inline u64 get_tb(void) +{ + unsigned int tbhi, tblo, tbhi2; + + if (IS_ENABLED(CONFIG_PPC64)) + return mftb(); + + do { + tbhi = mftbu(); + tblo = mftb(); + tbhi2 = mftbu(); + } while (tbhi != tbhi2); + + return ((u64)tbhi << 32) | tblo; +} + +static inline void set_tb(unsigned int upper, unsigned int lower) +{ + mtspr(SPRN_TBWL, 0); + mtspr(SPRN_TBWU, upper); + mtspr(SPRN_TBWL, lower); +} +#endif /* __POWERPC_TIMEBASE_H */ -- 2.25.0