@@ -43,25 +43,4 @@ static inline void mtmsr(uint64_t msr)
asm volatile ("mtmsrd %[msr]" :: [msr] "r" (msr) : "memory");
}
-static inline uint64_t get_tb(void)
-{
- return mfspr(SPR_TB);
-}
-
-extern void delay(uint64_t cycles);
-extern void udelay(uint64_t us);
-extern void sleep_tb(uint64_t cycles);
-extern void usleep(uint64_t us);
-
-static inline void mdelay(uint64_t ms)
-{
- while (ms--)
- udelay(1000);
-}
-
-static inline void msleep(uint64_t ms)
-{
- usleep(ms * 1000);
-}
-
#endif /* _ASMPOWERPC_PROCESSOR_H_ */
new file mode 100644
@@ -0,0 +1,30 @@
+#ifndef _ASMPOWERPC_TIME_H_
+#define _ASMPOWERPC_TIME_H_
+
+#include <libcflat.h>
+#include <asm/processor.h>
+
+static inline uint64_t get_tb(void)
+{
+ return mfspr(SPR_TB);
+}
+
+extern uint64_t get_clock_us(void);
+extern uint64_t get_clock_ms(void);
+extern void delay(uint64_t cycles);
+extern void udelay(uint64_t us);
+extern void sleep_tb(uint64_t cycles);
+extern void usleep(uint64_t us);
+
+static inline void mdelay(uint64_t ms)
+{
+ while (ms--)
+ udelay(1000);
+}
+
+static inline void msleep(uint64_t ms)
+{
+ usleep(ms * 1000);
+}
+
+#endif /* _ASMPOWERPC_TIME_H_ */
@@ -7,6 +7,7 @@
#include <libcflat.h>
#include <asm/processor.h>
+#include <asm/time.h>
#include <asm/ptrace.h>
#include <asm/setup.h>
#include <asm/barrier.h>
@@ -54,6 +55,16 @@ void do_handle_exception(struct pt_regs *regs)
abort();
}
+uint64_t get_clock_us(void)
+{
+ return get_tb() * 1000000 / tb_hz;
+}
+
+uint64_t get_clock_ms(void)
+{
+ return get_tb() * 1000 / tb_hz;
+}
+
void delay(uint64_t cycles)
{
uint64_t start = get_tb();
@@ -7,6 +7,7 @@
*/
#include <devicetree.h>
+#include <asm/time.h>
#include <asm/setup.h>
#include <asm/rtas.h>
#include <asm/smp.h>
new file mode 100644
@@ -0,0 +1 @@
+#include "../../powerpc/asm/time.h"
@@ -10,6 +10,7 @@
#include <util.h>
#include <alloc.h>
#include <asm/processor.h>
+#include <asm/time.h>
#include <asm/setup.h>
#include <asm/hcall.h>
#include <asm/vpa.h>
@@ -26,6 +26,7 @@
#include <asm/handlers.h>
#include <asm/hcall.h>
#include <asm/processor.h>
+#include <asm/time.h>
#include <asm/barrier.h>
uint64_t before[1024], after[1024];
@@ -8,6 +8,7 @@
#include <libcflat.h>
#include <asm/hcall.h>
#include <asm/processor.h>
+#include <asm/time.h>
#include <asm/handlers.h>
#include <asm/smp.h>
#include <asm/setup.h>
This matches s390x clock and delay APIs, so common test code can start using time facilities. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- lib/powerpc/asm/processor.h | 21 --------------------- lib/powerpc/asm/time.h | 30 ++++++++++++++++++++++++++++++ lib/powerpc/processor.c | 11 +++++++++++ lib/powerpc/smp.c | 1 + lib/ppc64/asm/time.h | 1 + powerpc/spapr_vpa.c | 1 + powerpc/sprs.c | 1 + powerpc/tm.c | 1 + 8 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 lib/powerpc/asm/time.h create mode 100644 lib/ppc64/asm/time.h