blob: 83ecbcb9d2cd5cd99bf52f8bf830ba1c28000df1 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada573a3812017-04-14 11:10:24 +09002/*
3 * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada573a3812017-04-14 11:10:24 +09004 */
5
Simon Glass4af0d7e2017-05-17 17:18:07 -06006#include <common.h>
Simon Glass9d922452017-05-17 17:18:03 -06007#include <dm.h>
Masahiro Yamada573a3812017-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 Yamada573a3812017-04-14 11:10:24 +090014 switch (type) {
15 case SYSRESET_WARM:
16 case SYSRESET_COLD:
Igor Opaniuk91f00ba2021-04-01 02:01:54 +030017 psci_sys_reset(type);
Masahiro Yamada573a3812017-04-14 11:10:24 +090018 break;
Urja Rannikko857f39d2019-05-16 21:48:41 +000019 case SYSRESET_POWER_OFF:
Igor Opaniuk91f00ba2021-04-01 02:01:54 +030020 psci_sys_poweroff();
Masahiro Yamada573a3812017-04-14 11:10:24 +090021 break;
22 default:
23 return -ENOSYS;
24 }
25
Masahiro Yamada573a3812017-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};