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 #include <zephyr/devicetree.h> 13 14 #ifdef _ASMLANGUAGE 15 16 .macro m_ace_lpsram_power_down_entire ax, ay, az, au 17 /* Retrieve the LPSRAM bank count from the ACE_L2MCAP register */ 18 movi \az, DT_REG_ADDR(DT_NODELABEL(hsbcap)) 19 l32i \az, \az, 0 20 /* Extract the 4-bit bank count field starting from bit 8 */ 21 extui \au, \az, 8, 4 22 23 movi \ay, 1 /* Power down command */ 24 25 /* Get the address of the LPSRAM control register from the Devicetree */ 26 movi \az, DT_REG_ADDR(DT_NODELABEL(lsbpm)) 27 2 : 28 /* Issue the power down command to the current LPSRAM bank */ 29 s8i \ay, \az, 0 30 memw 31 1 : 32 /* Poll the status register to confirm the power down command has taken effect */ 33 l8ui \ax, \az, 4 34 bne \ax, \ay, 1b 35 36 /* Move to the next LPSRAM bank control register */ 37 addi \az, \az, DT_REG_SIZE(DT_NODELABEL(lsbpm)) 38 addi \au, \au, -1 /* Decrement bank count */ 39 bnez \au, 2b /* If banks are left, continue loop */ 40 .endm 41 42 .macro m_ace_hpsram_power_down_entire ax, ay, az, au 43 /* Read the HPSRAM bank count from ACE_L2MCAP register */ 44 movi \au, DT_REG_ADDR(DT_NODELABEL(hsbcap)) 45 l32i \au, \au, 0 46 extui \au, \au, 0, 8 /* Bank count is in the lower 8 bits */ 47 48 movi \ay, 1 /* Power down command */ 49 50 /* Calculate the address of the HSxPGCTL register */ 51 movi \az, DT_REG_ADDR(DT_NODELABEL(hsbpm)) 52 2 : 53 s8i \ay, \az, 0 /* HSxPGCTL.l2lmpge = 1 (power down) */ 54 memw 55 1 : 56 l8ui \ax, \az, 4 /* ax = HSxPGISTS.l2lmpgis */ 57 bne \ax, \ay, 1b /* wait till status == request */ 58 59 addi \az, \az, DT_REG_SIZE(DT_NODELABEL(hsbpm)) /* Move to next bank control register */ 60 addi \au, \au, -1 /* Decrement bank count */ 61 bnez \au, 2b /* If banks are left, continue loop */ 62 .endm 63 #endif /* _ASMLANGUAGE */ 64 #endif /* __Z_ACE_LIB_ASM_MEMORY_MANAGEMENT_H__ */ 65