1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright (c) 2021, Microchip 4 */ 5 6 #include <drivers/atmel_rstc.h> 7 #include <drivers/atmel_shdwc.h> 8 #include <kernel/panic.h> 9 #include <sm/psci.h> 10 #include <sm/std_smc.h> 11 #include <stdint.h> 12 #include <trace.h> 13 14 void __noreturn psci_system_off(void) 15 { 16 if (!atmel_shdwc_available()) 17 panic(); 18 19 atmel_shdwc_shutdown(); 20 } 21 22 void __noreturn psci_system_reset(void) 23 { 24 if (!atmel_rstc_available()) 25 panic(); 26 27 atmel_rstc_reset(); 28 } 29 30 int psci_features(uint32_t psci_fid) 31 { 32 switch (psci_fid) { 33 case ARM_SMCCC_VERSION: 34 case PSCI_PSCI_FEATURES: 35 case PSCI_VERSION: 36 return PSCI_RET_SUCCESS; 37 case PSCI_SYSTEM_RESET: 38 if (atmel_rstc_available()) 39 return PSCI_RET_SUCCESS; 40 return PSCI_RET_NOT_SUPPORTED; 41 case PSCI_SYSTEM_OFF: 42 if (atmel_shdwc_available()) 43 return PSCI_RET_SUCCESS; 44 return PSCI_RET_NOT_SUPPORTED; 45 default: 46 return PSCI_RET_NOT_SUPPORTED; 47 } 48 } 49 50 uint32_t psci_version(void) 51 { 52 return PSCI_VERSION_1_0; 53 } 54