1 /* 2 * (C) Copyright 2017 Rockchip Electronics Co., Ltd 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #include <asm/arch/rockchip_smccc.h> 8 #include <asm/io.h> 9 #include <asm/psci.h> 10 #include <asm/suspend.h> 11 #include <linux/arm-smccc.h> 12 13 #ifdef CONFIG_ARM64 14 #define ARM_PSCI_1_0_SYSTEM_SUSPEND ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND 15 #else 16 #define ARM_PSCI_1_0_SYSTEM_SUSPEND ARM_PSCI_1_0_FN_SYSTEM_SUSPEND 17 #endif 18 19 /* Rockchip platform SiP call ID */ 20 #define SIP_SUSPEND_MODE 0x82000003 21 22 static struct arm_smccc_res __invoke_sip_fn_smc(unsigned long function_id, 23 unsigned long arg0, 24 unsigned long arg1, 25 unsigned long arg2) 26 { 27 struct arm_smccc_res res; 28 29 arm_smccc_smc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res); 30 return res; 31 } 32 33 int psci_system_suspend(unsigned long unused) 34 { 35 struct arm_smccc_res res; 36 37 res = __invoke_sip_fn_smc(ARM_PSCI_1_0_SYSTEM_SUSPEND, 38 virt_to_phys(cpu_resume), 0, 0); 39 return res.a0; 40 } 41 42 int sip_smc_set_suspend_mode(unsigned long ctrl, 43 unsigned long config1, 44 unsigned long config2) 45 { 46 struct arm_smccc_res res; 47 48 res = __invoke_sip_fn_smc(SIP_SUSPEND_MODE, ctrl, config1, config2); 49 return res.a0; 50 } 51