1/* 2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 7#include <autoconf.h> 8#include <elfloader/gen_config.h> 9#include <printf.h> 10 11#ifdef CONFIG_ARCH_AARCH64 12#define SMC_FID_VER 0x84000000 13#define SMC_FID_CPU_SUSPEND 0xc4000001 14#define SMC_FID_CPU_OFF 0x84000002 15#define SMC_FID_CPU_ON 0xc4000003 16#define SMC_FID_SYSTEM_RESET 0x84000009 17#else 18#define SMC_FID_VER 0x80000000 19#define SMC_FID_CPU_SUSPEND 0x80000001 20#define SMC_FID_CPU_OFF 0x80000002 21#define SMC_FID_CPU_ON 0x80000003 22#define SMC_FID_SYSTEM_RESET 0x80000009 23#endif 24 25 26extern int psci_func(unsigned int id, unsigned long param1, 27 unsigned long param2, unsigned long param3); 28 29int psci_version(void) 30{ 31 int ver = psci_func(SMC_FID_VER, 0, 0, 0); 32 return ver; 33} 34 35 36int psci_cpu_suspend(int power_state, unsigned long entry_point, 37 unsigned long context_id) 38{ 39 int ret = psci_func(SMC_FID_CPU_SUSPEND, power_state, entry_point, context_id); 40 return ret; 41} 42 43/* this function does not return when successful */ 44int psci_cpu_off(void) 45{ 46 int ret = psci_func(SMC_FID_CPU_OFF, 0, 0, 0); 47 return ret; 48} 49 50int psci_cpu_on(unsigned long target_cpu, unsigned long entry_point, 51 unsigned long context_id) 52{ 53 int ret = psci_func(SMC_FID_CPU_ON, target_cpu, entry_point, context_id); 54 return ret; 55} 56 57int psci_system_reset(void) 58{ 59 int ret = psci_func(SMC_FID_SYSTEM_RESET, 0, 0, 0); 60 return ret; 61} 62 63