blob: afa9c89055e5c404086ca3bfe2110bfa78809285 [file] [log] [blame]
Alexey Romanovc52cd072023-09-21 11:13:34 +03001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2023 SberDevices, Inc.
4 *
5 * Author: Alexey Romanov <avromanov@salutedevices.ru>
6 */
7
8#ifndef __SM_H__
9#define __SM_H__
10
11/*
12 * NOTE: UCLASS_SM is designed with the idea that
13 * each driver should convert @cmd to some raw
14 * value, which is known only for driver, and set this
15 * value to the first element of the @args->regs array.
16 * Therefore, it is necessary to pass the remaining
17 * arguments starting at index = 1. Anyway, driver
18 * implementation may vary, so, please, check the specific
19 * implementation of the driver you are using.
20 */
21
22#include <asm/types.h>
23#include <asm/ptrace.h>
24
25struct udevice;
26
27/**
28 * sm_call - generic SMC call to the secure-monitor
29 *
30 * @dev: Pointer to UCLASS_SM device
31 * @cmd_index: Index of the SMC function ID
32 * @smc_ret: Returned value from secure world
33 * @args: SMC arguments
34 *
35 * @return: 0 on success, a negative value on error
36 */
37int sm_call(struct udevice *dev, u32 cmd, s32 *ret, struct pt_regs *args);
38
39/**
40 * sm_call_read - retrieve data from secure-monitor
41 *
42 * @dev: Pointer to UCLASS_MESON_SM device
43 * @buffer: Buffer to store the retrieved data
44 * @size: Size of the buffer
45 * @cmd: Index of the SMC function ID
46 * @args: SMC arguments
47 *
48 * @return: size of read data on success, a negative value on error
49 */
50int sm_call_read(struct udevice *dev, void *buffer, size_t size,
51 u32 cmd, struct pt_regs *args);
52
53/**
54 * sm_call_write - send data to secure-monitor
55 *
56 * @dev: Pointer to UCLASS_SM device
57 * @buffer: Buffer containing data to send
58 * @size: Size of the buffer
59 * @cmd: Index of the SMC function ID
60 * @args: SMC arguments
61 *
62 * @return: size of sent data on success, a negative value on error
63 */
64int sm_call_write(struct udevice *dev, void *buffer, size_t size,
65 u32 cmd, struct pt_regs *args);
66
67#endif /* __SM_H__ */