]> git.ipfire.org Git - thirdparty/u-boot.git/blame - cmd/smccc.c
sysreset: switch to using SYSRESET_POWER_OFF for poweroff
[thirdparty/u-boot.git] / cmd / smccc.c
CommitLineData
666028fc
MP
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2018
4 * Michalis Pappas <mpappas@fastmail.fm>
5 */
6#include <asm/psci.h>
7#include <common.h>
8#include <command.h>
9#include <linux/arm-smccc.h>
10#include <linux/compiler.h>
11#include <linux/psci.h>
12
13static int do_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
14{
15 struct arm_smccc_res res;
16
17 unsigned long fid;
18
19 unsigned long a1;
20 unsigned long a2;
21 unsigned long a3;
22 unsigned long a4;
23 unsigned long a5;
24 unsigned long a6;
25 unsigned long a7;
26
27 if (argc < 2)
28 return CMD_RET_USAGE;
29
30 fid = simple_strtoul(argv[1], NULL, 16);
31
32 a1 = argc > 2 ? simple_strtoul(argv[2], NULL, 16) : 0;
33 a2 = argc > 3 ? simple_strtoul(argv[3], NULL, 16) : 0;
34 a3 = argc > 4 ? simple_strtoul(argv[4], NULL, 16) : 0;
35 a4 = argc > 5 ? simple_strtoul(argv[5], NULL, 16) : 0;
36 a5 = argc > 6 ? simple_strtoul(argv[6], NULL, 16) : 0;
37 a6 = argc > 7 ? simple_strtoul(argv[7], NULL, 16) : 0;
38 a7 = argc > 8 ? simple_strtoul(argv[8], NULL, 16) : 0;
39
40 if (!strcmp(argv[0], "smc"))
41 arm_smccc_smc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
42 else
43 arm_smccc_hvc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
44
45 printf("Res: %ld %ld %ld %ld\n", res.a0, res.a1, res.a2, res.a3);
46
47 return 0;
48}
49
50#ifdef CONFIG_CMD_SMC
51U_BOOT_CMD(
52 smc, 8, 2, do_call,
53 "Issue a Secure Monitor Call",
54 "<fid> [arg1 ... arg6] [id]\n"
55 " - fid Function ID\n"
56 " - arg SMC arguments, passed to X1-X6 (default to zero)\n"
57 " - id Secure OS ID / Session ID, passed to W7 (defaults to zero)\n"
58);
59#endif
60
61#ifdef CONFIG_CMD_HVC
62U_BOOT_CMD(
63 hvc, 8, 2, do_call,
64 "Issue a Hypervisor Call",
65 "<fid> [arg1...arg7] [id]\n"
66 " - fid Function ID\n"
67 " - arg HVC arguments, passed to X1-X6 (default to zero)\n"
68 " - id Session ID, passed to W7 (defaults to zero)\n"
69);
70#endif
71