blob: c7907b3226d96193c741f9bd56404051234b2a7a [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{
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;
Urja Rannikko857f39d2019-05-16 21:48:41 +000021 case SYSRESET_POWER_OFF:
Masahiro Yamada573a3812017-04-14 11:10:24 +090022 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
33static struct sysreset_ops psci_sysreset_ops = {
34 .request = psci_sysreset_request,
35};
36
37U_BOOT_DRIVER(psci_sysreset) = {
38 .name = "psci-sysreset",
39 .id = UCLASS_SYSRESET,
40 .ops = &psci_sysreset_ops,
41};