blob: de2ec8aeb1ee73052e0ec5f03a6eb4dc3421c117 [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{
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
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};