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 | { |
Masahiro Yamada | 836c55d | 2017-04-14 11:10:24 +0900 | [diff] [blame] | 14 | switch (type) { |
| 15 | case SYSRESET_WARM: |
| 16 | case SYSRESET_COLD: |
Igor Opaniuk | 7999cfd | 2021-04-01 02:01:54 +0300 | [diff] [blame] | 17 | psci_sys_reset(type); |
Masahiro Yamada | 836c55d | 2017-04-14 11:10:24 +0900 | [diff] [blame] | 18 | break; |
Urja Rannikko | 25394e7 | 2019-05-16 21:48:41 +0000 | [diff] [blame] | 19 | case SYSRESET_POWER_OFF: |
Igor Opaniuk | 7999cfd | 2021-04-01 02:01:54 +0300 | [diff] [blame] | 20 | psci_sys_poweroff(); |
Masahiro Yamada | 836c55d | 2017-04-14 11:10:24 +0900 | [diff] [blame] | 21 | break; |
| 22 | default: |
| 23 | return -ENOSYS; |
| 24 | } |
| 25 | |
Masahiro Yamada | 836c55d | 2017-04-14 11:10:24 +0900 | [diff] [blame] | 26 | return -EINPROGRESS; |
| 27 | } |
| 28 | |
| 29 | static struct sysreset_ops psci_sysreset_ops = { |
| 30 | .request = psci_sysreset_request, |
| 31 | }; |
| 32 | |
| 33 | U_BOOT_DRIVER(psci_sysreset) = { |
| 34 | .name = "psci-sysreset", |
| 35 | .id = UCLASS_SYSRESET, |
| 36 | .ops = &psci_sysreset_ops, |
| 37 | }; |