1/* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright(c) 2019 Intel Corporation. All rights reserved. 4 * 5 * Author: Marcin Maka <marcin.maka@linux.intel.com> 6 */ 7 8#include <xtensa/coreasm.h> 9#include <xtensa/cacheattrasm.h> 10#include <cavs/lps_ctx.h> 11#include <sof/lib/memory.h> 12 13#define MEMCTL_INIT_BIT 23 14#define MEMCTL_INIT_VAL (MEMCTL_L0IBUF_EN | 1 << MEMCTL_INIT_BIT) 15#define SW_INT_NUM 7 16#define SW_INT_MASK (1<<SW_INT_NUM) 17 18 .section .lps_vector, "ax" 19lps_pic_restore_vector_literals: 20 .literal_position 21 .align 4 22 23 .macro restore_vector level 24 l32i a4, a3, lps_ctx_vector_level_&level 25 wsr a4, EXCSAVE+\level 26 .endm 27 28 .global lps_pic_restore_vector_literals 29 .global lps_pic_restore_vector 30 .global lps_pic_restore_vector_end 31 32lps_pic_restore_vector: 33 movi a0, 0 34 movi a1, 1 35 wsr a1, WINDOWSTART 36 wsr a0, WINDOWBASE 37 rsync 38 39 movi a3, MEMCTL_INIT_VAL 40 wsr a3, MEMCTL 41 rsync 42 43 movi a3, 0x15 /* RCW for non-coherent dcache */ 44 wsr a3, ATOMCTL 45 46 movi a2, L1_CACHE_PREFCTL_VALUE 47 wsr a2, PREFCTL 48 49 movi a3, PS_UM|PS_WOE 50 wsr a3, PS 51 rsync 52 53 movi a2, _memmap_cacheattr_reset 54 cacheattr_set 55 56 movi a3, (~MEMCTL_SNOOP_EN) 57 wsr a3, MEMCTL 58 rsync 59 60 movi a3, (MEMCTL_SNOOP_EN | MEMCTL_L0IBUF_EN) 61 rsr a2, MEMCTL 62 or a2, a2, a3 63 wsr a2, MEMCTL 64 rsync 65 66 /* setup the stack */ 67 movi sp, lps_boot_stack 68 movi a2, 0x1000 69 add sp, sp, a2 70 71 /* Restore things saved by the platform code before sleep */ 72 73 movi a3, lps_restore 74 75 l32i a2, a3, lps_ctx_threadptr 76 wur a2, THREADPTR 77 78 l32i a4, a3, lps_ctx_memmap_vecbase_reset 79 wsr a4, vecbase 80 rsync 81 82 restore_vector 2 83 restore_vector 3 84 restore_vector 4 85 restore_vector 5 86 87 /* generate sw interrupt (# 7)*/ 88 movi a3, SW_INT_MASK 89 rsr a4, intenable 90 or a4, a4, a3 91 wsr a4, intenable 92 rsync 93 wsr a3, interrupt 94 rsync 95 96loop: 97 j loop 98 /* should never go here */ 99_HaltLoop: 100 j _HaltLoop 101 102 /* alignment is needed to ensure that vector 103 * will be copied with proper alignment 104 */ 105 .align 64 106lps_pic_restore_vector_end: 107 108 .size lps_pic_restore_vector, . - lps_pic_restore_vector 109