1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro (at) socionext.com> 4 */ 5 6 #include <common.h> 7 #include <dm.h> 8 #include <sysreset.h> 9 #include <linux/errno.h> 10 #include <linux/psci.h> 11 12 static int psci_sysreset_request(struct udevice *dev, enum sysreset_t type) 13 { 14 unsigned long function_id; 15 16 switch (type) { 17 case SYSRESET_WARM: 18 case SYSRESET_COLD: 19 function_id = PSCI_0_2_FN_SYSTEM_RESET; 20 break; 21 case SYSRESET_POWER: 22 function_id = PSCI_0_2_FN_SYSTEM_OFF; 23 break; 24 default: 25 return -ENOSYS; 26 } 27 28 invoke_psci_fn(function_id, 0, 0, 0); 29 30 return -EINPROGRESS; 31 } 32 33 static struct sysreset_ops psci_sysreset_ops = { 34 .request = psci_sysreset_request, 35 }; 36 37 U_BOOT_DRIVER(psci_sysreset) = { 38 .name = "psci-sysreset", 39 .id = UCLASS_SYSRESET, 40 .ops = &psci_sysreset_ops, 41 }; 42