1 /* Copyright (c) 2022 Intel Corporation 2 * SPDX-License-Identifier: Apache-2.0 3 */ 4 5 /** 6 * @brief Macros for power gating memory banks specific for ACE 1.0 7 */ 8 9 #ifndef __ZEPHYR_ACE_LIB_ASM_MEMORY_MANAGEMENT_H__ 10 #define __ZEPHYR_ACE_LIB_ASM_MEMORY_MANAGEMENT_H__ 11 12 #ifdef _ASMLANGUAGE 13 14 /* These definitions should be placed elsewhere, but I can't find a good place for them. */ 15 #define LSPGCTL 0x71D80 16 #define LSPGCTL_HIGH ((LSPGCTL >> 4) & 0xff00) 17 #define LSPGCTL_LOW ((LSPGCTL >> 4) & 0xff) 18 #define MAX_MEMORY_SEGMENTS 1 19 #define EBB_SEGMENT_SIZE 32 20 #define PLATFORM_HPSRAM_EBB_COUNT 22 21 22 .macro m_ace_hpsram_power_change segment_index, mask, ax, ay, az, au, aw 23 .if \segment_index == 0 24 .if EBB_SEGMENT_SIZE > PLATFORM_HPSRAM_EBB_COUNT 25 .set i_end, PLATFORM_HPSRAM_EBB_COUNT 26 .else 27 .set i_end, EBB_SEGMENT_SIZE 28 .endif 29 .elseif PLATFORM_HPSRAM_EBB_COUNT >= EBB_SEGMENT_SIZE 30 .set i_end, PLATFORM_HPSRAM_EBB_COUNT - EBB_SEGMENT_SIZE 31 .else 32 .err 33 .endif 34 35 rsr.sar \aw /* store old sar value */ 36 37 /* SHIM_HSPGCTL(ebb_index): 0x17a800 >> 11 == 0x2f5 */ 38 movi \az, 0x2f5 39 slli \az, \az, 0xb 40 /* 8 * (\segment_index << 5) == (\segment_index << 5) << 3 == \segment_index << 8 */ 41 addmi \az, \az, \segment_index << 8 42 43 movi \au, i_end - 1 /* au = banks count in segment */ 44 2 : 45 /* au = current bank in segment */ 46 mov \ax, \mask /* ax = mask */ 47 ssr \au 48 srl \ax, \ax /* ax >>= current bank */ 49 extui \ax, \ax, 0, 1 /* ax &= BIT(1) */ 50 s8i \ax, \az, 0 /* HSxPGCTL.l2lmpge = ax */ 51 memw 52 1 : 53 l8ui \ay, \az, 4 /* ax=HSxPGISTS.l2lmpgis */ 54 bne \ax, \ay, 1b /* wait till status==request */ 55 56 addi \az, \az, 8 57 addi \au, \au, -1 58 bnez \au, 2b 59 60 wsr.sar \aw 61 .endm 62 63 .macro m_ace_lpsram_power_down_entire ax, ay, az, au 64 movi \au, 8 /* LPSRAM_EBB_QUANTITY */ 65 movi \az, LSPGCTL_LOW 66 addmi \az, \az, LSPGCTL_HIGH 67 slli \az, \az, 4 68 69 movi \ay, 1 70 2 : 71 s8i \ay, \az, 0 72 memw 73 74 1 : 75 l8ui \ax, \az, 4 76 bne \ax, \ay, 1b 77 78 addi \az, \az, 8 79 addi \au, \au, -1 80 bnez \au, 2b 81 .endm 82 #endif /* _ASMLANGUAGE */ 83 #endif /* __Z_ACE_LIB_ASM_MEMORY_MANAGEMENT_H__ */ 84