Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 836c55d | 2017-04-14 11:10:24 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 836c55d | 2017-04-14 11:10:24 +0900 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | 51a3ec3 | 2017-05-17 17:18:07 -0600 | [diff] [blame] | 6 | #include <common.h> |
Simon Glass | 11c89f3 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 7 | #include <dm.h> |
Masahiro Yamada | 836c55d | 2017-04-14 11:10:24 +0900 | [diff] [blame] | 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 | }; |