blob: 4656d273c1f773bf8aefeda47f59fedcda88eb8d [file] [log] [blame]
Masahiro Yamada573a3812017-04-14 11:10:24 +09001/*
2 * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
Simon Glass4af0d7e2017-05-17 17:18:07 -06007#include <common.h>
Simon Glass9d922452017-05-17 17:18:03 -06008#include <dm.h>
Masahiro Yamada573a3812017-04-14 11:10:24 +09009#include <sysreset.h>
10#include <linux/errno.h>
11#include <linux/psci.h>
12
13static int psci_sysreset_request(struct udevice *dev, enum sysreset_t type)
14{
15 unsigned long function_id;
16
17 switch (type) {
18 case SYSRESET_WARM:
19 case SYSRESET_COLD:
20 function_id = PSCI_0_2_FN_SYSTEM_RESET;
21 break;
22 case SYSRESET_POWER:
23 function_id = PSCI_0_2_FN_SYSTEM_OFF;
24 break;
25 default:
26 return -ENOSYS;
27 }
28
29 invoke_psci_fn(function_id, 0, 0, 0);
30
31 return -EINPROGRESS;
32}
33
34static struct sysreset_ops psci_sysreset_ops = {
35 .request = psci_sysreset_request,
36};
37
38U_BOOT_DRIVER(psci_sysreset) = {
39 .name = "psci-sysreset",
40 .id = UCLASS_SYSRESET,
41 .ops = &psci_sysreset_ops,
42};