Skip to content

Commit 1b71a50

Browse files
committed
arch: xtensa: add waiti wakeup hook
On some platforms there is a need to perform tasks after coming back from waiti. There is no central interrupts processing function in SOF. Every interrupt is registered separaterly, so we need to execute 'wake up' functions in xtos interrupts handlers. Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
1 parent 0ca4545 commit 1b71a50

9 files changed

Lines changed: 45 additions & 1 deletion

File tree

src/arch/xtensa/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ config SMP
1717
help
1818
Indicates that architecture uses multiple cores
1919

20+
config WAKEUP_HOOK
21+
bool
22+
default n
23+
help
24+
Enables hook that is called and after coming back from WAITI.
25+
This config should be selected by other platform-level configs.
26+
Platforms that use it, have to implement hook function
27+
platform_interrupt_on_wakeup.
28+
2029
endmenu
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22

3-
add_local_sources(sof timer.c)
3+
add_local_sources(sof interrupt.c timer.c)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
//
3+
// Copyright(c) 2020 Intel Corporation. All rights reserved.
4+
//
5+
// Author: Janusz Jankowski <janusz.jankowski@linux.intel.com>
6+
7+
#include <sof/drivers/interrupt.h>
8+
9+
#if CONFIG_WAKEUP_HOOK
10+
void arch_interrupt_on_wakeup(void)
11+
{
12+
platform_interrupt_on_wakeup();
13+
}
14+
#endif

src/arch/xtensa/include/arch/drivers/interrupt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <xtensa/xtruntime.h>
1515
#include <stddef.h>
1616
#include <stdint.h>
17+
#include <config.h>
1718

1819
static inline int arch_interrupt_register(int irq,
1920
void (*handler)(void *arg), void *arg)
@@ -83,6 +84,10 @@ static inline void arch_interrupt_global_enable(uint32_t flags)
8384
:: "a" (flags) : "memory");
8485
}
8586

87+
#if CONFIG_WAKEUP_HOOK
88+
void arch_interrupt_on_wakeup(void);
89+
#endif
90+
8691
#endif /* __ARCH_DRIVERS_INTERRUPT_H__ */
8792

8893
#else

src/arch/xtensa/include/arch/lib/wait.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <sof/debug/panic.h>
1212
#include <sof/drivers/interrupt.h>
13+
#include <sof/lib/clk.h>
1314
#include <ipc/trace.h>
1415
#include <config.h>
1516
#include <xtensa/xtruntime.h>

src/arch/xtensa/xtos/int-medpri-dispatcher.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ no_context:
169169
* number and exception stack frame), then call the interrupt handler.
170170
* Note: The callx12 preserves the original user task's a4..a15.*/
171171

172+
xtos_on_wakeup
173+
172174
#if CONFIG_SMP
173175
xtos_addr_percore_add a12, xtos_interrupt_table, MAPINT(SINGLE_INT_NUM)*XIE_SIZE
174176
#else
@@ -228,6 +230,8 @@ no_context:
228230
/* set interrupt task context */
229231
xtos_task_ctx_store_percore a11, a14
230232

233+
xtos_on_wakeup
234+
231235
/* Loop to handle all pending interrupts. */
232236

233237
LABEL(.L1,_loop0):

src/arch/xtensa/xtos/xea1/int-lowpri-dispatcher.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ no_context:
159159
/* set interrupt task context */
160160
xtos_task_ctx_store_percore a11, a14
161161

162+
xtos_on_wakeup
163+
162164
/* Loop to handle all pending interrupts. */
163165

164166
LABEL(.L1,_loop0):

src/arch/xtensa/xtos/xea2/int-lowpri-dispatcher.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ no_context:
159159
/* set interrupt task context */
160160
xtos_task_ctx_store_percore a11, a14
161161

162+
xtos_on_wakeup
163+
162164
/* Loop to handle all pending interrupts. */
163165

164166
LABEL(.L1,_loop0):

src/arch/xtensa/xtos/xtos-internal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,13 @@ XTOS_PENDING_OFS: .space 4 /* _xtos_pending variable */
494494
s32i \ax, \ay, XTOS_TASK_CONTEXT_OFFSET
495495
.endm
496496

497+
// Executes optional callback on wake up
498+
.macro xtos_on_wakeup
499+
#if CONFIG_WAKEUP_HOOK
500+
call12 arch_interrupt_on_wakeup
501+
#endif
502+
.endm
503+
497504
#else /* !_ASMLANGUAGE && !__ASSEMBLER__ */
498505

499506
/*

0 commit comments

Comments
 (0)