blob: 83ecbcb9d2cd5cd99bf52f8bf830ba1c28000df1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada836c55d2017-04-14 11:10:24 +09002/*
3 * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada836c55d2017-04-14 11:10:24 +09004 */
5
Simon Glass51a3ec32017-05-17 17:18:07 -06006#include <common.h>
Simon Glass11c89f32017-05-17 17:18:03 -06007#include <dm.h>
Masahiro Yamada836c55d2017-04-14 11:10:24 +09008#include <sysreset.h>
9#include <linux/errno.h>
10#include <linux/psci.h>
11
12static int psci_sysreset_request(struct udevice *dev, enum sysreset_t type)
13{
Masahiro Yamada836c55d2017-04-14 11:10:24 +090014 switch (type) {
15 case SYSRESET_WARM:
16 case SYSRESET_COLD:
Igor Opaniuk7999cfd2021-04-01 02:01:54 +030017 psci_sys_reset(type);
Masahiro Yamada836c55d2017-04-14 11:10:24 +090018 break;
Urja Rannikko25394e72019-05-16 21:48:41 +000019 case SYSRESET_POWER_OFF:
Igor Opaniuk7999cfd2021-04-01 02:01:54 +030020 psci_sys_poweroff();
Masahiro Yamada836c55d2017-04-14 11:10:24 +090021 break;
22 default:
23 return -ENOSYS;
24 }
25
Masahiro Yamada836c55d2017-04-14 11:10:24 +090026 return -EINPROGRESS;
27}
28
29static struct sysreset_ops psci_sysreset_ops = {
30 .request = psci_sysreset_request,
31};
32
33U_BOOT_DRIVER(psci_sysreset) = {
34 .name = "psci-sysreset",
35 .id = UCLASS_SYSRESET,
36 .ops = &psci_sysreset_ops,
37};