1 /* 2 * Copyright (c) 2021, MediaTek Inc. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <stddef.h> 8 9 #include <lib/mmio.h> 10 11 #include <mt_spm_notifier.h> 12 #include <mt_spm_sspm_intc.h> 13 14 #define MT_SPM_SSPM_MBOX_OFF(x) (SSPM_MBOX_BASE + x) 15 #define MT_SPM_MBOX(slot) MT_SPM_SSPM_MBOX_OFF((slot << 2UL)) 16 17 #define SSPM_MBOX_SPM_LP_LOOKUP1 MT_SPM_MBOX(0) 18 #define SSPM_MBOX_SPM_LP_LOOKUP2 MT_SPM_MBOX(1) 19 #define SSPM_MBOX_SPM_LP1 MT_SPM_MBOX(2) 20 #define SSPM_MBOX_SPM_LP2 MT_SPM_MBOX(3) 21 mt_spm_sspm_notify(int type,unsigned int lp_mode)22int mt_spm_sspm_notify(int type, unsigned int lp_mode) 23 { 24 switch (type) { 25 case MT_SPM_NOTIFY_LP_ENTER: 26 mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode); 27 DO_SPM_SSPM_LP_SUSPEND(); 28 break; 29 case MT_SPM_NOTIFY_LP_LEAVE: 30 mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode); 31 DO_SPM_SSPM_LP_RESUME(); 32 break; 33 default: 34 break; 35 } 36 37 return 0; 38 } 39