From 46f1220ddcc098825017c0340e08a3f40c362ffc Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 22 Jan 2018 23:24:24 +0000 Subject: [PATCH] arch: xtensa: Support wait_for_interrupt on LX6 Add LX6 version of wait_for_interrupt() as this will be needed for cannonlake. Signed-off-by: Liam Girdwood --- src/arch/xtensa/Makefile.am | 1 - src/arch/xtensa/include/arch/Makefile.am | 3 +- .../xtensa/{wait.S => include/arch/wait.h} | 51 ++++++++++++++----- src/include/reef/wait.h | 1 + 4 files changed, 41 insertions(+), 15 deletions(-) rename src/arch/xtensa/{wait.S => include/arch/wait.h} (71%) diff --git a/src/arch/xtensa/Makefile.am b/src/arch/xtensa/Makefile.am index 00f6b68fb..fe27c2448 100644 --- a/src/arch/xtensa/Makefile.am +++ b/src/arch/xtensa/Makefile.am @@ -31,7 +31,6 @@ reef_SOURCES = \ crt1-boards.S \ _vectors.S \ init.c \ - wait.S \ timer.c \ task.c diff --git a/src/arch/xtensa/include/arch/Makefile.am b/src/arch/xtensa/include/arch/Makefile.am index d8ba0dfad..42b3b700d 100644 --- a/src/arch/xtensa/include/arch/Makefile.am +++ b/src/arch/xtensa/include/arch/Makefile.am @@ -4,4 +4,5 @@ noinst_HEADERS = \ reef.h \ spinlock.h \ task.h \ - timer.h + timer.h \ + wait.h diff --git a/src/arch/xtensa/wait.S b/src/arch/xtensa/include/arch/wait.h similarity index 71% rename from src/arch/xtensa/wait.S rename to src/arch/xtensa/include/arch/wait.h index df9893dbf..2f6e4f568 100644 --- a/src/arch/xtensa/wait.S +++ b/src/arch/xtensa/include/arch/wait.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Intel Corporation + * Copyright (c) 2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,17 +28,42 @@ * Author: Liam Girdwood */ -#include -#include -#include "xtos-internal.h" +#include - .text - .align 4 - .global arch_wait_for_interrupt - .type arch_wait_for_interrupt,@function -arch_wait_for_interrupt: - abi_entry - waiti 0 - abi_return +#if defined(CONFIG_CANNONLAKE) + +static inline void arch_wait_for_interrupt(int level) +{ + int i; + + /* this sequnce must be atomic on LX6 */ + XTOS_SET_INTLEVEL(5); + + /* LX6 needs a delay */ + for (i = 0; i < 128; i++) + asm volatile("nop"); + + /* and to flush all loads/stores prior to wait */ + asm volatile("isync"); + asm volatile("extw"); + + /* now wait */ + asm volatile("waiti 0"); +} + +#else + +static inline void arch_wait_for_interrupt(int level) +{ + asm volatile("waiti 0"); +} + +#endif + +static inline void idelay(int n) +{ + while (n--) { + asm volatile("nop"); + } +} - .size arch_wait_for_interrupt, . - arch_wait_for_interrupt diff --git a/src/include/reef/wait.h b/src/include/reef/wait.h index 3354eb4a7..a598d48a7 100644 --- a/src/include/reef/wait.h +++ b/src/include/reef/wait.h @@ -35,6 +35,7 @@ #include #include +#include #include #include #include